Path: blob/master/src/java.desktop/share/native/libawt/java2d/loops/FourByteAbgrPre.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 FourByteAbgrPre_h_Included26#define FourByteAbgrPre_h_Included2728/*29* This file contains macro and type definitions used by the macros in30* LoopMacros.h to manipulate a surface of type "FourByteAbgrPre".31*/3233typedef jint FourByteAbgrPrePixelType;34typedef jubyte FourByteAbgrPreDataType;3536#define FourByteAbgrPreIsOpaque 03738#define FourByteAbgrPrePixelStride 43940#define DeclareFourByteAbgrPreLoadVars(PREFIX)41#define DeclareFourByteAbgrPreStoreVars(PREFIX)42#define SetFourByteAbgrPreStoreVarsYPos(PREFIX, pRasInfo, y)43#define SetFourByteAbgrPreStoreVarsXPos(PREFIX, pRasInfo, x)44#define InitFourByteAbgrPreLoadVars(PREFIX, pRasInfo)45#define InitFourByteAbgrPreStoreVarsY(PREFIX, pRasInfo)46#define InitFourByteAbgrPreStoreVarsX(PREFIX, pRasInfo)47#define NextFourByteAbgrPreStoreVarsX(PREFIX)48#define NextFourByteAbgrPreStoreVarsY(PREFIX)495051#define FourByteAbgrPrePixelFromArgb(pixel, rgb, pRasInfo) \52do { \53jint a, r, g, b; \54if (((rgb) >> 24) == -1) { \55(pixel) = (((rgb) << 8) | (((juint) (rgb)) >> 24)); \56} else { \57ExtractIntDcmComponents1234(rgb, a, r, g, b); \58r = MUL8(a, r); \59g = MUL8(a, g); \60b = MUL8(a, b); \61(pixel) = ComposeIntDcmComponents1234(r, g, b, a); \62} \63} while (0)6465#define StoreFourByteAbgrPrePixel(pRas, x, pixel) \66do { \67(pRas)[4*(x)+0] = (jubyte) ((pixel) >> 0); \68(pRas)[4*(x)+1] = (jubyte) ((pixel) >> 8); \69(pRas)[4*(x)+2] = (jubyte) ((pixel) >> 16); \70(pRas)[4*(x)+3] = (jubyte) ((pixel) >> 24); \71} while (0)7273#define DeclareFourByteAbgrPrePixelData(PREFIX) \74jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2, PREFIX ## 3;7576#define ExtractFourByteAbgrPrePixelData(PIXEL, PREFIX) \77do { \78PREFIX ## 0 = (jubyte) (PIXEL >> 0); \79PREFIX ## 1 = (jubyte) (PIXEL >> 8); \80PREFIX ## 2 = (jubyte) (PIXEL >> 16); \81PREFIX ## 3 = (jubyte) (PIXEL >> 24); \82} while (0)8384#define StoreFourByteAbgrPrePixelData(pPix, x, pixel, PREFIX) \85do { \86pPix[4*(x)+0] = PREFIX ## 0; \87pPix[4*(x)+1] = PREFIX ## 1; \88pPix[4*(x)+2] = PREFIX ## 2; \89pPix[4*(x)+3] = PREFIX ## 3; \90} while (0)919293#define LoadFourByteAbgrPreTo1IntRgb(pRas, PREFIX, x, rgb) \94LoadFourByteAbgrPreTo1IntArgb(pRas, PREFIX, x, rgb)9596#define LoadFourByteAbgrPreTo1IntArgb(pRas, PREFIX, x, argb) \97do { \98jint a = (pRas)[4*(x)+0]; \99if ((a == 0xff) || (a == 0)) { \100(argb) = (((pRas)[4*(x)+1] << 0) | \101((pRas)[4*(x)+2] << 8) | \102((pRas)[4*(x)+3] << 16) | \103(a << 24)); \104} else { \105jint r, g, b; \106b = DIV8((pRas)[4*(x)+1], a); \107g = DIV8((pRas)[4*(x)+2], a); \108r = DIV8((pRas)[4*(x)+3], a); \109(argb) = ComposeIntDcmComponents1234(a, r, g, b); \110} \111} while (0)112113#define LoadFourByteAbgrPreTo3ByteRgb(pRas, PREFIX, x, r, g, b) \114do { \115jint a; \116LoadFourByteAbgrPreTo4ByteArgb(pRas, PREFIX, x, a, r, g, b); \117} while (0)118119#define LoadFourByteAbgrPreTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \120do { \121(a) = (pRas)[4*(x)+0]; \122(b) = (pRas)[4*(x)+1]; \123(g) = (pRas)[4*(x)+2]; \124(r) = (pRas)[4*(x)+3]; \125if ((a != 0xff) && (a != 0)) { \126r = DIV8(r, a); \127g = DIV8(g, a); \128b = DIV8(b, a); \129} \130} while (0)131132#define StoreFourByteAbgrPreFrom1IntRgb(pRas, PREFIX, x, rgb) \133do { \134(pRas)[4*(x)+0] = (jubyte) 0xff; \135(pRas)[4*(x)+1] = (jubyte) ((rgb) >> 0); \136(pRas)[4*(x)+2] = (jubyte) ((rgb) >> 8); \137(pRas)[4*(x)+3] = (jubyte) ((rgb) >> 16); \138} while (0)139140#define StoreFourByteAbgrPreFrom1IntArgb(pRas, PREFIX, x, argb) \141do { \142if ((((argb) >> 24) + 1) == 0) { \143(pRas)[4*(x)+0] = (jubyte) ((argb) >> 24); \144(pRas)[4*(x)+1] = (jubyte) ((argb) >> 0); \145(pRas)[4*(x)+2] = (jubyte) ((argb) >> 8); \146(pRas)[4*(x)+3] = (jubyte) ((argb) >> 16); \147} else { \148jint a, r, g, b; \149ExtractIntDcmComponents1234(argb, a, r, g, b); \150(pRas)[4*(x)+0] = (jubyte) a; \151(pRas)[4*(x)+1] = MUL8(a, b); \152(pRas)[4*(x)+2] = MUL8(a, g); \153(pRas)[4*(x)+3] = MUL8(a, r); \154} \155} while (0)156157#define StoreFourByteAbgrPreFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \158do { \159(pRas)[4*(x)+0] = (jubyte) 0xff; \160(pRas)[4*(x)+1] = (jubyte) (b); \161(pRas)[4*(x)+2] = (jubyte) (g); \162(pRas)[4*(x)+3] = (jubyte) (r); \163} while (0)164165#define StoreFourByteAbgrPreFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \166do { \167if ((a) == 0xff) { \168StoreFourByteAbgrPreFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \169} else { \170(pRas)[4*(x)+0] = (jubyte) (a); \171(pRas)[4*(x)+1] = MUL8(a, b); \172(pRas)[4*(x)+2] = MUL8(a, g); \173(pRas)[4*(x)+3] = MUL8(a, r); \174} \175} while (0)176177#define CopyFourByteAbgrPreToIntArgbPre(pRGB, i, PREFIX, pRow, x) \178(pRGB)[i] = (((pRow)[4*(x)+0] << 24) | \179((pRow)[4*(x)+1] << 0) | \180((pRow)[4*(x)+2] << 8) | \181((pRow)[4*(x)+3] << 16))182183184#define DeclareFourByteAbgrPreAlphaLoadData(PREFIX)185#define InitFourByteAbgrPreAlphaLoadData(PREFIX, pRasInfo)186187#define LoadAlphaFromFourByteAbgrPreFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \188COMP_PREFIX ## A = (pRas)[0]189190#define Postload4ByteArgbFromFourByteAbgrPre(pRas, PREFIX, COMP_PREFIX) \191do { \192COMP_PREFIX ## B = (pRas)[1]; \193COMP_PREFIX ## G = (pRas)[2]; \194COMP_PREFIX ## R = (pRas)[3]; \195} while (0)196197198#define FourByteAbgrPreIsPremultiplied 1199200#define DeclareFourByteAbgrPreBlendFillVars(PREFIX)201202#define ClearFourByteAbgrPreBlendFillVars(PREFIX, argb)203204#define InitFourByteAbgrPreBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX)205206#define InitFourByteAbgrPreBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)207208#define StoreFourByteAbgrPreBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \209StoreFourByteAbgrPreFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX)210211#define StoreFourByteAbgrPreFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX)\212do { \213(pRas)[4*(x)+0] = (jubyte) COMP_PREFIX ## A; \214(pRas)[4*(x)+1] = (jubyte) COMP_PREFIX ## B; \215(pRas)[4*(x)+2] = (jubyte) COMP_PREFIX ## G; \216(pRas)[4*(x)+3] = (jubyte) COMP_PREFIX ## R; \217} while (0)218219/*220* SrcOver ## TYPE ## BlendFactor221* Returns appropriate blend value for use in blending calculations.222*/223#define SrcOverFourByteAbgrPreBlendFactor(dF, dA) \224(dF)225226#endif /* FourByteAbgrPre_h_Included */227228229