jdk/src/java.desktop/share/native/libawt/java2d/loops/ByteGray.h
author ntv
Fri, 06 May 2016 11:23:49 +0000
changeset 37800 518e44c93fbb
parent 26751 70bac69b37c9
permissions -rw-r--r--
8015070: Antialiased text on translucent backgrounds gets bright artifacts Reviewed-by: flar, prr, jdv Contributed-by: prahalad.kumar.narayanan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     2
 * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef ByteGray_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define ByteGray_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "IntDcm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * This file contains macro and type definitions used by the macros in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * LoopMacros.h to manipulate a surface of type "ByteGray".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
typedef jubyte  ByteGrayPixelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
typedef jubyte  ByteGrayDataType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
    39
#define ByteGrayIsOpaque 1
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
    40
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define ByteGrayPixelStride     1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#define ByteGrayBitsPerPixel    8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define DeclareByteGrayLoadVars(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define DeclareByteGrayStoreVars(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define SetByteGrayStoreVarsYPos(PREFIX, pRasInfo, y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define SetByteGrayStoreVarsXPos(PREFIX, pRasInfo, x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#define InitByteGrayLoadVars(PREFIX, pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#define InitByteGrayStoreVarsY(PREFIX, pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define InitByteGrayStoreVarsX(PREFIX, pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#define NextByteGrayStoreVarsX(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define NextByteGrayStoreVarsY(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#define DeclareByteGrayPixelData(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#define ExtractByteGrayPixelData(PIXEL, PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#define ByteGrayXparLutEntry            -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#define ByteGrayIsXparLutEntry(pix)     (pix < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#define StoreByteGrayNonXparFromArgb    StoreByteGrayFrom1IntArgb
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#define ComposeByteGrayFrom3ByteRgb(r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    (ByteGrayDataType)(((77*(r)) + (150*(g)) + (29*(b)) + 128) / 256)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#define StoreByteGrayPixel(pRas, x, pixel) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    ((pRas)[x] = (jubyte) (pixel))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#define StoreByteGrayPixelData(pPix, x, pixel, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    StoreByteGrayPixel(pPix, x, pixel)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#define ByteGrayPixelFromArgb(pixel, rgb, pRasInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        jint r, g, b; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        ExtractIntDcmComponentsX123(rgb, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        (pixel) = ComposeByteGrayFrom3ByteRgb(r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#define LoadByteGrayTo1IntRgb(pRas, PREFIX, x, rgb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        int gray = (pRas)[x]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        (rgb) = (((gray << 8) | gray) << 8) | gray; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#define LoadByteGrayTo1IntArgb(pRas, PREFIX, x, argb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        int gray = (pRas)[x]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        (argb) = (((((0xff << 8) | gray) << 8) | gray) << 8) | gray; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#define LoadByteGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    ((r) = (g) = (b) = (pRas)[x])
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#define LoadByteGrayTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        LoadByteGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        (a) = 0xff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define LoadByteGrayTo1ByteGray(pRas, PREFIX, x, gray) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    (gray) = (pRas)[x]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
#define StoreByteGrayFrom1IntRgb(pRas, PREFIX, x, rgb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        int r, g, b; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        ExtractIntDcmComponentsX123(rgb, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#define StoreByteGrayFrom1IntArgb(pRas, PREFIX, x, argb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    StoreByteGrayFrom1IntRgb(pRas, PREFIX, x, argb)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
#define StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    (pRas)[x] = ComposeByteGrayFrom3ByteRgb(r, g, b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#define StoreByteGrayFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
#define StoreByteGrayFrom1ByteGray(pRas, PREFIX, x, gray) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    StoreByteGrayPixel(pRas, x, gray)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
#define CopyByteGrayToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    LoadByteGrayTo1IntArgb(pRow, PREFIX, x, pRGB[i])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
#define DeclareByteGrayAlphaLoadData(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
#define InitByteGrayAlphaLoadData(PREFIX, pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
#define LoadAlphaFromByteGrayFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    COMP_PREFIX ## A = 0xff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
#define Postload1ByteGrayFromByteGray(pRas, PREFIX, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    COMP_PREFIX ## G = pRas[0]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
#define ByteGrayIsPremultiplied 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
#define DeclareByteGrayBlendFillVars(PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    jubyte PREFIX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
#define ClearByteGrayBlendFillVars(PREFIX, argb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    PREFIX = 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
#define InitByteGrayBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    PREFIX = (jubyte) COMP_PREFIX ## G
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
#define InitByteGrayBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
#define StoreByteGrayBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    (pRas)[x] = PREFIX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
#define StoreByteGrayFrom1ByteGrayComps(pRas, PREFIX, x, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    StoreByteGrayPixel(pRas, x, COMP_PREFIX ## G)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
#endif /* ByteGray_h_Included */