jdk/src/share/native/sun/java2d/loops/FourByteAbgr.h
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 549 4273b1234967
child 5506 202f599c92aa
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 549
diff changeset
     2
 * Copyright 2000-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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 FourByteAbgr_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define FourByteAbgr_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * This file contains macro and type definitions used by the macros in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * LoopMacros.h to manipulate a surface of type "FourByteAbgr".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
typedef jint    FourByteAbgrPixelType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
typedef jubyte  FourByteAbgrDataType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
    37
#define FourByteAbgrIsOpaque 0
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
    38
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#define FourByteAbgrPixelStride         4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define DeclareFourByteAbgrLoadVars(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#define DeclareFourByteAbgrStoreVars(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#define SetFourByteAbgrStoreVarsYPos(PREFIX, pRasInfo, y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define SetFourByteAbgrStoreVarsXPos(PREFIX, pRasInfo, x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define InitFourByteAbgrLoadVars(PREFIX, pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define InitFourByteAbgrStoreVarsY(PREFIX, pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define InitFourByteAbgrStoreVarsX(PREFIX, pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#define NextFourByteAbgrStoreVarsX(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#define NextFourByteAbgrStoreVarsY(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define FourByteAbgrPixelFromArgb(pixel, rgb, pRasInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    (pixel) = (((rgb) << 8) | (((juint) (rgb)) >> 24))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#define StoreFourByteAbgrPixel(pRas, x, pixel) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        (pRas)[4*(x)+0] = (jubyte) ((pixel) >> 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        (pRas)[4*(x)+1] = (jubyte) ((pixel) >> 8); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        (pRas)[4*(x)+2] = (jubyte) ((pixel) >> 16); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        (pRas)[4*(x)+3] = (jubyte) ((pixel) >> 24); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#define DeclareFourByteAbgrPixelData(PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2, PREFIX ## 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define ExtractFourByteAbgrPixelData(PIXEL, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        PREFIX ## 0 = (jubyte) (PIXEL >> 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        PREFIX ## 1 = (jubyte) (PIXEL >> 8); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        PREFIX ## 2 = (jubyte) (PIXEL >> 16); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        PREFIX ## 3 = (jubyte) (PIXEL >> 24); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#define StoreFourByteAbgrPixelData(pPix, x, pixel, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        pPix[4*x+0] = PREFIX ## 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        pPix[4*x+1] = PREFIX ## 1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        pPix[4*x+2] = PREFIX ## 2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        pPix[4*x+3] = PREFIX ## 3; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
#define LoadFourByteAbgrTo1IntRgb(pRas, PREFIX, x, rgb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    (rgb) = (((pRas)[4*(x)+1] << 0) | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
             ((pRas)[4*(x)+2] << 8) | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
             ((pRas)[4*(x)+3] << 16))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#define LoadFourByteAbgrTo1IntArgb(pRas, PREFIX, x, argb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    (argb) = (((pRas)[4*(x)+0] << 24) | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
              ((pRas)[4*(x)+1] << 0) | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
              ((pRas)[4*(x)+2] << 8) | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
              ((pRas)[4*(x)+3] << 16))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#define LoadFourByteAbgrTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        (b) = (pRas)[4*(x)+1]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        (g) = (pRas)[4*(x)+2]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        (r) = (pRas)[4*(x)+3]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#define LoadFourByteAbgrTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        (a) = (pRas)[4*(x)+0]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        LoadFourByteAbgrTo3ByteRgb(pRas, PREFIX, x, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#define StoreFourByteAbgrFrom1IntRgb(pRas, PREFIX, x, rgb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        (pRas)[4*(x)+0] = (jubyte) 0xff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        (pRas)[4*(x)+1] = (jubyte) ((rgb) >> 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        (pRas)[4*(x)+2] = (jubyte) ((rgb) >> 8); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        (pRas)[4*(x)+3] = (jubyte) ((rgb) >> 16); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
#define StoreFourByteAbgrFrom1IntArgb(pRas, PREFIX, x, argb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        (pRas)[4*(x)+0] = (jubyte) ((argb) >> 24); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        (pRas)[4*(x)+1] = (jubyte) ((argb) >> 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        (pRas)[4*(x)+2] = (jubyte) ((argb) >> 8); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        (pRas)[4*(x)+3] = (jubyte) ((argb) >> 16); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#define StoreFourByteAbgrFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    StoreFourByteAbgrFrom4ByteArgb(pRas, PREFIX, x, 0xff, r, g, b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
#define StoreFourByteAbgrFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        (pRas)[4*(x)+0] = (jubyte) (a); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        (pRas)[4*(x)+1] = (jubyte) (b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        (pRas)[4*(x)+2] = (jubyte) (g); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        (pRas)[4*(x)+3] = (jubyte) (r); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
#define CopyFourByteAbgrToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        jint a = (pRow)[4*(x)+0]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        if (a != 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            jint b = (pRow)[4*(x)+1]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            jint g = (pRow)[4*(x)+2]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            jint r = (pRow)[4*(x)+3]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            if (a < 0xff) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                b = MUL8(a, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                g = MUL8(a, g); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                r = MUL8(a, r); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            a = ComposeIntDcmComponents1234(a, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        (pRGB)[i] = a; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
#define DeclareFourByteAbgrAlphaLoadData(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
#define InitFourByteAbgrAlphaLoadData(PREFIX, pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
#define LoadAlphaFromFourByteAbgrFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    COMP_PREFIX ## A = (pRas)[0]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
#define Postload4ByteArgbFromFourByteAbgr(pRas, PREFIX, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    LoadFourByteAbgrTo3ByteRgb(pRas, PREFIX, 0, COMP_PREFIX ## R, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                               COMP_PREFIX ## G, COMP_PREFIX ## B)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
#define FourByteAbgrIsPremultiplied     0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
#define DeclareFourByteAbgrBlendFillVars(PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2, PREFIX ## 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
#define ClearFourByteAbgrBlendFillVars(PREFIX, argb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    (PREFIX ## 0 = PREFIX ## 1 = PREFIX ## 2 = PREFIX ## 3 = 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
#define InitFourByteAbgrBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        PREFIX ## 0 = (jubyte) COMP_PREFIX ## A; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        PREFIX ## 1 = (jubyte) COMP_PREFIX ## B; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        PREFIX ## 2 = (jubyte) COMP_PREFIX ## G; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        PREFIX ## 3 = (jubyte) COMP_PREFIX ## R; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
#define InitFourByteAbgrBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
#define StoreFourByteAbgrBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        (pRas)[4*x+0] = PREFIX ## 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        (pRas)[4*x+1] = PREFIX ## 1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        (pRas)[4*x+2] = PREFIX ## 2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        (pRas)[4*x+3] = PREFIX ## 3; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
#define StoreFourByteAbgrFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    StoreFourByteAbgrFrom4ByteArgb(pRas, PREFIX, x, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                                   COMP_PREFIX ## A, COMP_PREFIX ## R, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                                   COMP_PREFIX ## G, COMP_PREFIX ## B)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
#endif /* FourByteAbgr_h_Included */