Path: blob/master/src/java.desktop/share/native/libawt/java2d/loops/FourByteAbgr.h
41159 views
/*1* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef FourByteAbgr_h_Included26#define FourByteAbgr_h_Included2728/*29* This file contains macro and type definitions used by the macros in30* LoopMacros.h to manipulate a surface of type "FourByteAbgr".31*/3233typedef jint FourByteAbgrPixelType;34typedef jubyte FourByteAbgrDataType;3536#define FourByteAbgrIsOpaque 03738#define FourByteAbgrPixelStride 43940#define DeclareFourByteAbgrLoadVars(PREFIX)41#define DeclareFourByteAbgrStoreVars(PREFIX)42#define SetFourByteAbgrStoreVarsYPos(PREFIX, pRasInfo, y)43#define SetFourByteAbgrStoreVarsXPos(PREFIX, pRasInfo, x)44#define InitFourByteAbgrLoadVars(PREFIX, pRasInfo)45#define InitFourByteAbgrStoreVarsY(PREFIX, pRasInfo)46#define InitFourByteAbgrStoreVarsX(PREFIX, pRasInfo)47#define NextFourByteAbgrStoreVarsX(PREFIX)48#define NextFourByteAbgrStoreVarsY(PREFIX)495051#define FourByteAbgrPixelFromArgb(pixel, rgb, pRasInfo) \52(pixel) = (((rgb) << 8) | (((juint) (rgb)) >> 24))5354#define StoreFourByteAbgrPixel(pRas, x, pixel) \55do { \56(pRas)[4*(x)+0] = (jubyte) ((pixel) >> 0); \57(pRas)[4*(x)+1] = (jubyte) ((pixel) >> 8); \58(pRas)[4*(x)+2] = (jubyte) ((pixel) >> 16); \59(pRas)[4*(x)+3] = (jubyte) ((pixel) >> 24); \60} while (0)6162#define DeclareFourByteAbgrPixelData(PREFIX) \63jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2, PREFIX ## 3;6465#define ExtractFourByteAbgrPixelData(PIXEL, PREFIX) \66do { \67PREFIX ## 0 = (jubyte) (PIXEL >> 0); \68PREFIX ## 1 = (jubyte) (PIXEL >> 8); \69PREFIX ## 2 = (jubyte) (PIXEL >> 16); \70PREFIX ## 3 = (jubyte) (PIXEL >> 24); \71} while (0)7273#define StoreFourByteAbgrPixelData(pPix, x, pixel, PREFIX) \74do { \75pPix[4*x+0] = PREFIX ## 0; \76pPix[4*x+1] = PREFIX ## 1; \77pPix[4*x+2] = PREFIX ## 2; \78pPix[4*x+3] = PREFIX ## 3; \79} while (0)808182#define LoadFourByteAbgrTo1IntRgb(pRas, PREFIX, x, rgb) \83(rgb) = (((pRas)[4*(x)+1] << 0) | \84((pRas)[4*(x)+2] << 8) | \85((pRas)[4*(x)+3] << 16))8687#define LoadFourByteAbgrTo1IntArgb(pRas, PREFIX, x, argb) \88(argb) = (((pRas)[4*(x)+0] << 24) | \89((pRas)[4*(x)+1] << 0) | \90((pRas)[4*(x)+2] << 8) | \91((pRas)[4*(x)+3] << 16))9293#define LoadFourByteAbgrTo3ByteRgb(pRas, PREFIX, x, r, g, b) \94do { \95(b) = (pRas)[4*(x)+1]; \96(g) = (pRas)[4*(x)+2]; \97(r) = (pRas)[4*(x)+3]; \98} while (0)99100#define LoadFourByteAbgrTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \101do { \102(a) = (pRas)[4*(x)+0]; \103LoadFourByteAbgrTo3ByteRgb(pRas, PREFIX, x, r, g, b); \104} while (0)105106#define StoreFourByteAbgrFrom1IntRgb(pRas, PREFIX, x, rgb) \107do { \108(pRas)[4*(x)+0] = (jubyte) 0xff; \109(pRas)[4*(x)+1] = (jubyte) ((rgb) >> 0); \110(pRas)[4*(x)+2] = (jubyte) ((rgb) >> 8); \111(pRas)[4*(x)+3] = (jubyte) ((rgb) >> 16); \112} while (0)113114#define StoreFourByteAbgrFrom1IntArgb(pRas, PREFIX, x, argb) \115do { \116(pRas)[4*(x)+0] = (jubyte) ((argb) >> 24); \117(pRas)[4*(x)+1] = (jubyte) ((argb) >> 0); \118(pRas)[4*(x)+2] = (jubyte) ((argb) >> 8); \119(pRas)[4*(x)+3] = (jubyte) ((argb) >> 16); \120} while (0)121122#define StoreFourByteAbgrFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \123StoreFourByteAbgrFrom4ByteArgb(pRas, PREFIX, x, 0xff, r, g, b)124125#define StoreFourByteAbgrFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \126do { \127(pRas)[4*(x)+0] = (jubyte) (a); \128(pRas)[4*(x)+1] = (jubyte) (b); \129(pRas)[4*(x)+2] = (jubyte) (g); \130(pRas)[4*(x)+3] = (jubyte) (r); \131} while (0)132133#define CopyFourByteAbgrToIntArgbPre(pRGB, i, PREFIX, pRow, x) \134do { \135jint a = (pRow)[4*(x)+0]; \136if (a != 0) { \137jint b = (pRow)[4*(x)+1]; \138jint g = (pRow)[4*(x)+2]; \139jint r = (pRow)[4*(x)+3]; \140if (a < 0xff) { \141b = MUL8(a, b); \142g = MUL8(a, g); \143r = MUL8(a, r); \144} \145a = ComposeIntDcmComponents1234(a, r, g, b); \146} \147(pRGB)[i] = a; \148} while (0)149150151#define DeclareFourByteAbgrAlphaLoadData(PREFIX)152#define InitFourByteAbgrAlphaLoadData(PREFIX, pRasInfo)153154#define LoadAlphaFromFourByteAbgrFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \155COMP_PREFIX ## A = (pRas)[0]156157#define Postload4ByteArgbFromFourByteAbgr(pRas, PREFIX, COMP_PREFIX) \158LoadFourByteAbgrTo3ByteRgb(pRas, PREFIX, 0, COMP_PREFIX ## R, \159COMP_PREFIX ## G, COMP_PREFIX ## B)160161162#define FourByteAbgrIsPremultiplied 0163164#define DeclareFourByteAbgrBlendFillVars(PREFIX) \165jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2, PREFIX ## 3;166167#define ClearFourByteAbgrBlendFillVars(PREFIX, argb) \168(PREFIX ## 0 = PREFIX ## 1 = PREFIX ## 2 = PREFIX ## 3 = 0)169170#define InitFourByteAbgrBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \171do { \172PREFIX ## 0 = (jubyte) COMP_PREFIX ## A; \173PREFIX ## 1 = (jubyte) COMP_PREFIX ## B; \174PREFIX ## 2 = (jubyte) COMP_PREFIX ## G; \175PREFIX ## 3 = (jubyte) COMP_PREFIX ## R; \176} while (0)177178#define InitFourByteAbgrBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)179180#define StoreFourByteAbgrBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \181do { \182(pRas)[4*x+0] = PREFIX ## 0; \183(pRas)[4*x+1] = PREFIX ## 1; \184(pRas)[4*x+2] = PREFIX ## 2; \185(pRas)[4*x+3] = PREFIX ## 3; \186} while (0)187188#define StoreFourByteAbgrFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \189StoreFourByteAbgrFrom4ByteArgb(pRas, PREFIX, x, \190COMP_PREFIX ## A, COMP_PREFIX ## R, \191COMP_PREFIX ## G, COMP_PREFIX ## B)192193/*194* SrcOver ## TYPE ## BlendFactor195* Returns appropriate blend value for use in blending calculations.196*/197#define SrcOverFourByteAbgrBlendFactor(dF, dA) \198(dA)199200#endif /* FourByteAbgr_h_Included */201202203