2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
#ifndef AnyByteBinary_h_Included
|
|
27 |
#define AnyByteBinary_h_Included
|
|
28 |
|
|
29 |
#include <string.h>
|
|
30 |
|
|
31 |
#include "AlphaMacros.h"
|
|
32 |
#include "GraphicsPrimitiveMgr.h"
|
|
33 |
#include "LoopMacros.h"
|
|
34 |
#include "LineUtils.h"
|
|
35 |
|
|
36 |
/*
|
|
37 |
* This file contains macros that are similar to those found in LoopMacros.h
|
|
38 |
* and AlphaMacros.h, yet have been specialized to manipulate any one of the
|
|
39 |
* surfaces in the "ByteBinary" family. It also contains generalized versions
|
|
40 |
* of some macros that are used by the more specific ByteBinary surfaces.
|
|
41 |
*/
|
|
42 |
|
|
43 |
/* REMIND: the ByteBinary store macros should probably do ordered dithering */
|
|
44 |
#define DeclareByteBinaryLoadVars(PREFIX) \
|
|
45 |
jint *PREFIX ## Lut;
|
|
46 |
|
|
47 |
#define DeclareByteBinaryStoreVars(PREFIX) \
|
|
48 |
unsigned char *PREFIX ## InvLut;
|
|
49 |
|
|
50 |
#define SetByteBinaryStoreVarsYPos(PREFIX, pRasInfo, LOC)
|
|
51 |
#define SetByteBinaryStoreVarsXPos(PREFIX, pRasInfo, LOC)
|
|
52 |
|
|
53 |
#define InitByteBinaryLoadVars(PREFIX, pRasInfo) \
|
|
54 |
PREFIX ## Lut = (pRasInfo)->lutBase
|
|
55 |
|
|
56 |
#define InitByteBinaryStoreVarsY(PREFIX, pRasInfo) \
|
|
57 |
PREFIX ## InvLut = (pRasInfo)->invColorTable
|
|
58 |
|
|
59 |
#define InitByteBinaryStoreVarsX(PREFIX, pRasInfo)
|
|
60 |
#define NextByteBinaryStoreVarsX(PREFIX)
|
|
61 |
#define NextByteBinaryStoreVarsY(PREFIX)
|
|
62 |
|
|
63 |
|
|
64 |
#define DeclareByteBinaryInitialLoadVars(TYPE, INFO, pRas, PREFIX, x) \
|
|
65 |
int PREFIX ## adjx = (x) + (INFO)->pixelBitOffset / TYPE ## BitsPerPixel; \
|
|
66 |
int PREFIX ## index = (PREFIX ## adjx) / TYPE ## PixelsPerByte; \
|
|
67 |
int PREFIX ## bits = TYPE ## MaxBitOffset - \
|
|
68 |
(((PREFIX ## adjx) % TYPE ## PixelsPerByte) * \
|
|
69 |
TYPE ## BitsPerPixel); \
|
|
70 |
int PREFIX ## bbpix = (pRas)[PREFIX ## index];
|
|
71 |
|
|
72 |
#define InitialLoadByteBinary(TYPE, pRas, PREFIX) \
|
|
73 |
do { \
|
|
74 |
if (PREFIX ## bits < 0) { \
|
|
75 |
(pRas)[PREFIX ## index] = (jubyte) PREFIX ## bbpix; \
|
|
76 |
PREFIX ## bbpix = (pRas)[++(PREFIX ## index)]; \
|
|
77 |
PREFIX ## bits = TYPE ## MaxBitOffset; \
|
|
78 |
} \
|
|
79 |
} while (0)
|
|
80 |
|
|
81 |
#define ShiftBitsByteBinary(TYPE, PREFIX) \
|
|
82 |
PREFIX ## bits -= TYPE ## BitsPerPixel
|
|
83 |
|
|
84 |
#define FinalStoreByteBinary(TYPE, pRas, PREFIX) \
|
|
85 |
(pRas)[PREFIX ## index] = (jubyte) PREFIX ## bbpix
|
|
86 |
|
|
87 |
#define CurrentPixelByteBinary(TYPE, PREFIX) \
|
|
88 |
((PREFIX ## bbpix >> PREFIX ## bits) & TYPE ## PixelMask)
|
|
89 |
|
|
90 |
|
|
91 |
#define StoreByteBinaryPixel(TYPE, pRas, x, pixel)
|
|
92 |
|
|
93 |
#define StoreByteBinaryPixelData(TYPE, pPix, x, pixel, PREFIX) \
|
|
94 |
do { \
|
|
95 |
PREFIX ## bbpix &= ~(TYPE ## PixelMask << PREFIX ## bits); \
|
|
96 |
PREFIX ## bbpix |= (pixel << PREFIX ## bits); \
|
|
97 |
} while (0)
|
|
98 |
|
|
99 |
#define ByteBinaryPixelFromArgb(TYPE, pixel, rgb, pRasInfo) \
|
|
100 |
do { \
|
|
101 |
jint r, g, b; \
|
|
102 |
ExtractIntDcmComponentsX123(rgb, r, g, b); \
|
|
103 |
(pixel) = SurfaceData_InvColorMap((pRasInfo)->invColorTable, \
|
|
104 |
r, g, b); \
|
|
105 |
} while (0)
|
|
106 |
|
|
107 |
#define XorByteBinaryPixelData(TYPE, pDst, x, PREFIX, \
|
|
108 |
srcpixel, xorpixel, mask) \
|
|
109 |
PREFIX ## bbpix ^= ((((srcpixel) ^ (xorpixel)) & TYPE ## PixelMask) \
|
|
110 |
<< PREFIX ## bits)
|
|
111 |
|
|
112 |
|
|
113 |
#define LoadByteBinaryTo1IntRgb(TYPE, pRas, PREFIX, x, rgb) \
|
|
114 |
(rgb) = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]
|
|
115 |
|
|
116 |
#define LoadByteBinaryTo1IntArgb(TYPE, pRas, PREFIX, x, argb) \
|
|
117 |
(argb) = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]
|
|
118 |
|
|
119 |
#define LoadByteBinaryTo3ByteRgb(TYPE, pRas, PREFIX, x, r, g, b) \
|
|
120 |
do { \
|
|
121 |
jint rgb = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]; \
|
|
122 |
ExtractIntDcmComponentsX123(rgb, r, g, b); \
|
|
123 |
} while (0)
|
|
124 |
|
|
125 |
#define LoadByteBinaryTo4ByteArgb(TYPE, pRas, PREFIX, x, a, r, g, b) \
|
|
126 |
do { \
|
|
127 |
jint argb = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]; \
|
|
128 |
ExtractIntDcmComponents1234(argb, a, r, g, b); \
|
|
129 |
} while (0)
|
|
130 |
|
|
131 |
#define StoreByteBinaryFrom1IntRgb(TYPE, pRas, PREFIX, x, rgb) \
|
|
132 |
do { \
|
|
133 |
int r, g, b; \
|
|
134 |
ExtractIntDcmComponentsX123(rgb, r, g, b); \
|
|
135 |
StoreByteBinaryFrom3ByteRgb(TYPE, pRas, PREFIX, x, r, g, b); \
|
|
136 |
} while (0)
|
|
137 |
|
|
138 |
#define StoreByteBinaryFrom1IntArgb(TYPE, pRas, PREFIX, x, argb) \
|
|
139 |
StoreByteBinaryFrom1IntRgb(TYPE, pRas, PREFIX, x, argb)
|
|
140 |
|
|
141 |
#define StoreByteBinaryFrom3ByteRgb(TYPE, pRas, PREFIX, x, r, g, b) \
|
|
142 |
StoreByteBinaryPixelData(TYPE, pRas, x, \
|
|
143 |
SurfaceData_InvColorMap(PREFIX ## InvLut, \
|
|
144 |
r, g, b), \
|
|
145 |
PREFIX)
|
|
146 |
|
|
147 |
#define StoreByteBinaryFrom4ByteArgb(TYPE, pRas, PREFIX, x, a, r, g, b) \
|
|
148 |
StoreByteBinaryFrom3ByteRgb(TYPE, pRas, PREFIX, x, r, g, b)
|
|
149 |
|
|
150 |
|
|
151 |
#define DeclareByteBinaryAlphaLoadData(TYPE, PREFIX) \
|
|
152 |
jint *PREFIX ## Lut; \
|
|
153 |
jint PREFIX ## rgb;
|
|
154 |
|
|
155 |
#define InitByteBinaryAlphaLoadData(TYPE, PREFIX, pRasInfo) \
|
|
156 |
PREFIX ## Lut = (pRasInfo)->lutBase
|
|
157 |
|
|
158 |
#define LoadAlphaFromByteBinaryFor4ByteArgb(TYPE, pRas, PREFIX, COMP_PREFIX) \
|
|
159 |
do { \
|
|
160 |
PREFIX ## rgb = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]; \
|
|
161 |
COMP_PREFIX ## A = ((juint) PREFIX ## rgb) >> 24; \
|
|
162 |
} while (0)
|
|
163 |
|
|
164 |
#define Postload4ByteArgbFromByteBinary(TYPE, pRas, PREFIX, COMP_PREFIX) \
|
|
165 |
do { \
|
|
166 |
COMP_PREFIX ## R = (PREFIX ## rgb >> 16) & 0xff; \
|
|
167 |
COMP_PREFIX ## G = (PREFIX ## rgb >> 8) & 0xff; \
|
|
168 |
COMP_PREFIX ## B = (PREFIX ## rgb >> 0) & 0xff; \
|
|
169 |
} while (0)
|
|
170 |
|
|
171 |
|
|
172 |
#define ByteBinaryIsPremultiplied 0
|
|
173 |
|
|
174 |
#define StoreByteBinaryFrom4ByteArgbComps(TYPE, pRas, PREFIX, x, COMP_PREFIX)\
|
|
175 |
StoreByteBinaryFrom4ByteArgb(TYPE, pRas, PREFIX, x, \
|
|
176 |
COMP_PREFIX ## A, COMP_PREFIX ## R, \
|
|
177 |
COMP_PREFIX ## G, COMP_PREFIX ## B)
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
#define BBBlitLoopWidthHeight(SRCTYPE, SRCPTR, SRCBASE, SRCINFO, SRCPREFIX, \
|
|
183 |
DSTTYPE, DSTPTR, DSTBASE, DSTINFO, DSTPREFIX, \
|
|
184 |
WIDTH, HEIGHT, BODY) \
|
|
185 |
do { \
|
|
186 |
SRCTYPE ## DataType *SRCPTR = (SRCTYPE ## DataType *) (SRCBASE); \
|
|
187 |
DSTTYPE ## DataType *DSTPTR = (DSTTYPE ## DataType *) (DSTBASE); \
|
|
188 |
jint srcScan = (SRCINFO)->scanStride; \
|
|
189 |
jint dstScan = (DSTINFO)->scanStride; \
|
|
190 |
jint srcx1 = (SRCINFO)->bounds.x1; \
|
|
191 |
jint dstx1 = (DSTINFO)->bounds.x1; \
|
|
192 |
Init ## DSTTYPE ## StoreVarsY(DSTPREFIX, DSTINFO); \
|
|
193 |
srcScan -= (WIDTH) * SRCTYPE ## PixelStride; \
|
|
194 |
dstScan -= (WIDTH) * DSTTYPE ## PixelStride; \
|
|
195 |
do { \
|
|
196 |
Declare ## SRCTYPE ## InitialLoadVars(SRCINFO, SRCPTR, SRCPREFIX, \
|
|
197 |
srcx1) \
|
|
198 |
Declare ## DSTTYPE ## InitialLoadVars(DSTINFO, DSTPTR, DSTPREFIX, \
|
|
199 |
dstx1) \
|
|
200 |
juint w = WIDTH; \
|
|
201 |
Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \
|
|
202 |
do { \
|
|
203 |
InitialLoad ## SRCTYPE(SRCPTR, SRCPREFIX); \
|
|
204 |
InitialLoad ## DSTTYPE(DSTPTR, DSTPREFIX); \
|
|
205 |
BODY; \
|
|
206 |
ShiftBits ## SRCTYPE(SRCPREFIX); \
|
|
207 |
ShiftBits ## DSTTYPE(DSTPREFIX); \
|
|
208 |
SRCPTR = PtrAddBytes(SRCPTR, SRCTYPE ## PixelStride); \
|
|
209 |
DSTPTR = PtrAddBytes(DSTPTR, DSTTYPE ## PixelStride); \
|
|
210 |
Next ## DSTTYPE ## StoreVarsX(DSTPREFIX); \
|
|
211 |
} while (--w > 0); \
|
|
212 |
FinalStore ## DSTTYPE(DSTPTR, DSTPREFIX); \
|
|
213 |
SRCPTR = PtrAddBytes(SRCPTR, srcScan); \
|
|
214 |
DSTPTR = PtrAddBytes(DSTPTR, dstScan); \
|
|
215 |
Next ## DSTTYPE ## StoreVarsY(DSTPREFIX); \
|
|
216 |
} while (--HEIGHT > 0); \
|
|
217 |
} while (0)
|
|
218 |
|
|
219 |
#define BBXorVia1IntArgb(SRCPTR, SRCTYPE, SRCPREFIX, \
|
|
220 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
221 |
XVAR, XORPIXEL, MASK, DSTINFOPTR) \
|
|
222 |
do { \
|
|
223 |
jint srcpixel; \
|
|
224 |
Load ## SRCTYPE ## To1IntArgb(SRCPTR, SRCPREFIX, XVAR, srcpixel); \
|
|
225 |
\
|
|
226 |
if (IsArgbTransparent(srcpixel)) { \
|
|
227 |
break; \
|
|
228 |
} \
|
|
229 |
\
|
|
230 |
DSTTYPE ## PixelFromArgb(srcpixel, srcpixel, DSTINFOPTR); \
|
|
231 |
\
|
|
232 |
Xor ## DSTTYPE ## PixelData(DSTPTR, XVAR, DSTPREFIX, srcpixel, \
|
|
233 |
XORPIXEL, MASK); \
|
|
234 |
} while (0)
|
|
235 |
|
|
236 |
#define DEFINE_BYTE_BINARY_CONVERT_BLIT(SRC, DST, STRATEGY) \
|
|
237 |
void NAME_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
238 |
juint width, juint height, \
|
|
239 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
240 |
SurfaceDataRasInfo *pDstInfo, \
|
|
241 |
NativePrimitive *pPrim, \
|
|
242 |
CompositeInfo *pCompInfo) \
|
|
243 |
{ \
|
|
244 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
245 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
246 |
\
|
|
247 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
248 |
BBBlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, SrcRead, \
|
|
249 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
250 |
width, height, \
|
|
251 |
ConvertVia ## STRATEGY(pSrc, SRC, SrcRead, \
|
|
252 |
pDst, DST, DstWrite, \
|
|
253 |
0, 0)); \
|
|
254 |
}
|
|
255 |
|
|
256 |
#define DEFINE_BYTE_BINARY_XOR_BLIT(SRC, DST) \
|
|
257 |
void NAME_XOR_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
258 |
juint width, juint height, \
|
|
259 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
260 |
SurfaceDataRasInfo *pDstInfo, \
|
|
261 |
NativePrimitive *pPrim, \
|
|
262 |
CompositeInfo *pCompInfo) \
|
|
263 |
{ \
|
|
264 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
265 |
juint alphamask = pCompInfo->alphaMask; \
|
|
266 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
267 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
268 |
\
|
|
269 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
270 |
BBBlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, SrcRead, \
|
|
271 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
272 |
width, height, \
|
|
273 |
BBXorVia1IntArgb(pSrc, SRC, SrcRead, \
|
|
274 |
pDst, DST, DstWrite, \
|
|
275 |
0, xorpixel, \
|
|
276 |
alphamask, pDstInfo)); \
|
|
277 |
}
|
|
278 |
|
|
279 |
#define DEFINE_BYTE_BINARY_SOLID_FILLRECT(DST) \
|
|
280 |
void NAME_SOLID_FILLRECT(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
281 |
jint lox, jint loy, \
|
|
282 |
jint hix, jint hiy, \
|
|
283 |
jint pixel, \
|
|
284 |
NativePrimitive *pPrim, \
|
|
285 |
CompositeInfo *pCompInfo) \
|
|
286 |
{ \
|
|
287 |
DST ## DataType *pPix; \
|
|
288 |
jint scan = pRasInfo->scanStride; \
|
|
289 |
juint height = hiy - loy; \
|
|
290 |
juint width = hix - lox; \
|
|
291 |
\
|
|
292 |
pPix = PtrCoord(pRasInfo->rasBase, lox, DST ## PixelStride, loy, scan); \
|
|
293 |
do { \
|
|
294 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, lox) \
|
|
295 |
jint w = width; \
|
|
296 |
do { \
|
|
297 |
InitialLoad ## DST(pPix, DstPix); \
|
|
298 |
Store ## DST ## PixelData(pPix, 0, pixel, DstPix); \
|
|
299 |
ShiftBits ## DST(DstPix); \
|
|
300 |
} while (--w > 0); \
|
|
301 |
FinalStore ## DST(pPix, DstPix); \
|
|
302 |
pPix = PtrAddBytes(pPix, scan); \
|
|
303 |
} while (--height > 0); \
|
|
304 |
}
|
|
305 |
|
|
306 |
#define DEFINE_BYTE_BINARY_SOLID_FILLSPANS(DST) \
|
|
307 |
void NAME_SOLID_FILLSPANS(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
308 |
SpanIteratorFuncs *pSpanFuncs, void *siData, \
|
|
309 |
jint pixel, NativePrimitive *pPrim, \
|
|
310 |
CompositeInfo *pCompInfo) \
|
|
311 |
{ \
|
|
312 |
void *pBase = pRasInfo->rasBase; \
|
|
313 |
jint scan = pRasInfo->scanStride; \
|
|
314 |
jint bbox[4]; \
|
|
315 |
\
|
|
316 |
while ((*pSpanFuncs->nextSpan)(siData, bbox)) { \
|
|
317 |
jint x = bbox[0]; \
|
|
318 |
jint y = bbox[1]; \
|
|
319 |
juint w = bbox[2] - x; \
|
|
320 |
juint h = bbox[3] - y; \
|
|
321 |
DST ## DataType *pPix = PtrCoord(pBase, \
|
|
322 |
x, DST ## PixelStride, \
|
|
323 |
y, scan); \
|
|
324 |
do { \
|
|
325 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x) \
|
|
326 |
jint relx = w; \
|
|
327 |
do { \
|
|
328 |
InitialLoad ## DST(pPix, DstPix); \
|
|
329 |
Store ## DST ## PixelData(pPix, 0, pixel, DstPix); \
|
|
330 |
ShiftBits ## DST(DstPix); \
|
|
331 |
} while (--relx > 0); \
|
|
332 |
FinalStore ## DST(pPix, DstPix); \
|
|
333 |
pPix = PtrAddBytes(pPix, scan); \
|
|
334 |
} while (--h > 0); \
|
|
335 |
} \
|
|
336 |
}
|
|
337 |
|
|
338 |
#define DEFINE_BYTE_BINARY_SOLID_DRAWLINE(DST) \
|
|
339 |
void NAME_SOLID_DRAWLINE(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
340 |
jint x1, jint y1, jint pixel, \
|
|
341 |
jint steps, jint error, \
|
|
342 |
jint bumpmajormask, jint errmajor, \
|
|
343 |
jint bumpminormask, jint errminor, \
|
|
344 |
NativePrimitive *pPrim, \
|
|
345 |
CompositeInfo *pCompInfo) \
|
|
346 |
{ \
|
|
347 |
jint scan = pRasInfo->scanStride; \
|
|
348 |
DST ## DataType *pPix = PtrCoord(pRasInfo->rasBase, \
|
|
349 |
x1, DST ## PixelStride, \
|
|
350 |
y1, scan); \
|
|
351 |
DeclareBumps(bumpmajor, bumpminor) \
|
|
352 |
\
|
|
353 |
scan *= DST ## PixelsPerByte; \
|
|
354 |
InitBumps(bumpmajor, bumpminor, bumpmajormask, bumpminormask, 1, scan); \
|
|
355 |
if (errmajor == 0) { \
|
|
356 |
do { \
|
|
357 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x1) \
|
|
358 |
Store ## DST ## PixelData(pPix, 0, pixel, DstPix); \
|
|
359 |
FinalStore ## DST(pPix, DstPix); \
|
|
360 |
x1 += bumpmajor; \
|
|
361 |
} while (--steps > 0); \
|
|
362 |
} else { \
|
|
363 |
do { \
|
|
364 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x1) \
|
|
365 |
Store ## DST ## PixelData(pPix, 0, pixel, DstPix); \
|
|
366 |
FinalStore ## DST(pPix, DstPix); \
|
|
367 |
if (error < 0) { \
|
|
368 |
x1 += bumpmajor; \
|
|
369 |
error += errmajor; \
|
|
370 |
} else { \
|
|
371 |
x1 += bumpminor; \
|
|
372 |
error -= errminor; \
|
|
373 |
} \
|
|
374 |
} while (--steps > 0); \
|
|
375 |
} \
|
|
376 |
}
|
|
377 |
|
|
378 |
#define DEFINE_BYTE_BINARY_XOR_FILLRECT(DST) \
|
|
379 |
void NAME_XOR_FILLRECT(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
380 |
jint lox, jint loy, \
|
|
381 |
jint hix, jint hiy, \
|
|
382 |
jint pixel, \
|
|
383 |
NativePrimitive *pPrim, \
|
|
384 |
CompositeInfo *pCompInfo) \
|
|
385 |
{ \
|
|
386 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
387 |
juint alphamask = pCompInfo->alphaMask; \
|
|
388 |
DST ## DataType *pPix; \
|
|
389 |
jint scan = pRasInfo->scanStride; \
|
|
390 |
juint height = hiy - loy; \
|
|
391 |
juint width = hix - lox; \
|
|
392 |
\
|
|
393 |
pPix = PtrCoord(pRasInfo->rasBase, lox, DST ## PixelStride, loy, scan); \
|
|
394 |
do { \
|
|
395 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, lox) \
|
|
396 |
jint w = width; \
|
|
397 |
do { \
|
|
398 |
InitialLoad ## DST(pPix, DstPix); \
|
|
399 |
Xor ## DST ## PixelData(pPix, 0, DstPix, \
|
|
400 |
pixel, xorpixel, alphamask); \
|
|
401 |
ShiftBits ## DST(DstPix); \
|
|
402 |
} while (--w > 0); \
|
|
403 |
FinalStore ## DST(pPix, DstPix); \
|
|
404 |
pPix = PtrAddBytes(pPix, scan); \
|
|
405 |
} while (--height > 0); \
|
|
406 |
}
|
|
407 |
|
|
408 |
#define DEFINE_BYTE_BINARY_XOR_FILLSPANS(DST) \
|
|
409 |
void NAME_XOR_FILLSPANS(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
410 |
SpanIteratorFuncs *pSpanFuncs, \
|
|
411 |
void *siData, jint pixel, \
|
|
412 |
NativePrimitive *pPrim, \
|
|
413 |
CompositeInfo *pCompInfo) \
|
|
414 |
{ \
|
|
415 |
void *pBase = pRasInfo->rasBase; \
|
|
416 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
417 |
juint alphamask = pCompInfo->alphaMask; \
|
|
418 |
jint scan = pRasInfo->scanStride; \
|
|
419 |
jint bbox[4]; \
|
|
420 |
\
|
|
421 |
while ((*pSpanFuncs->nextSpan)(siData, bbox)) { \
|
|
422 |
jint x = bbox[0]; \
|
|
423 |
jint y = bbox[1]; \
|
|
424 |
juint w = bbox[2] - x; \
|
|
425 |
juint h = bbox[3] - y; \
|
|
426 |
DST ## DataType *pPix = PtrCoord(pBase, \
|
|
427 |
x, DST ## PixelStride, \
|
|
428 |
y, scan); \
|
|
429 |
do { \
|
|
430 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x) \
|
|
431 |
jint relx = w; \
|
|
432 |
do { \
|
|
433 |
InitialLoad ## DST(pPix, DstPix); \
|
|
434 |
Xor ## DST ## PixelData(pPix, 0, DstPix, \
|
|
435 |
pixel, xorpixel, alphamask); \
|
|
436 |
ShiftBits ## DST(DstPix); \
|
|
437 |
} while (--relx > 0); \
|
|
438 |
FinalStore ## DST(pPix, DstPix); \
|
|
439 |
pPix = PtrAddBytes(pPix, scan); \
|
|
440 |
} while (--h > 0); \
|
|
441 |
} \
|
|
442 |
}
|
|
443 |
|
|
444 |
#define DEFINE_BYTE_BINARY_XOR_DRAWLINE(DST) \
|
|
445 |
void NAME_XOR_DRAWLINE(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
446 |
jint x1, jint y1, jint pixel, \
|
|
447 |
jint steps, jint error, \
|
|
448 |
jint bumpmajormask, jint errmajor, \
|
|
449 |
jint bumpminormask, jint errminor, \
|
|
450 |
NativePrimitive *pPrim, \
|
|
451 |
CompositeInfo *pCompInfo) \
|
|
452 |
{ \
|
|
453 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
454 |
juint alphamask = pCompInfo->alphaMask; \
|
|
455 |
jint scan = pRasInfo->scanStride; \
|
|
456 |
DST ## DataType *pPix = PtrCoord(pRasInfo->rasBase, \
|
|
457 |
x1, DST ## PixelStride, \
|
|
458 |
y1, scan); \
|
|
459 |
DeclareBumps(bumpmajor, bumpminor) \
|
|
460 |
\
|
|
461 |
scan *= DST ## PixelsPerByte; \
|
|
462 |
InitBumps(bumpmajor, bumpminor, bumpmajormask, bumpminormask, 1, scan); \
|
|
463 |
\
|
|
464 |
if (errmajor == 0) { \
|
|
465 |
do { \
|
|
466 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x1) \
|
|
467 |
Xor ## DST ## PixelData(pPix, 0, DstPix, \
|
|
468 |
pixel, xorpixel, alphamask); \
|
|
469 |
FinalStore ## DST(pPix, DstPix); \
|
|
470 |
x1 += bumpmajor; \
|
|
471 |
} while (--steps > 0); \
|
|
472 |
} else { \
|
|
473 |
do { \
|
|
474 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x1) \
|
|
475 |
Xor ## DST ## PixelData(pPix, 0, DstPix, \
|
|
476 |
pixel, xorpixel, alphamask); \
|
|
477 |
FinalStore ## DST(pPix, DstPix); \
|
|
478 |
if (error < 0) { \
|
|
479 |
x1 += bumpmajor; \
|
|
480 |
error += errmajor; \
|
|
481 |
} else { \
|
|
482 |
x1 += bumpminor; \
|
|
483 |
error -= errminor; \
|
|
484 |
} \
|
|
485 |
} while (--steps > 0); \
|
|
486 |
} \
|
|
487 |
}
|
|
488 |
|
|
489 |
#define DEFINE_BYTE_BINARY_SOLID_DRAWGLYPHLIST(DST) \
|
|
490 |
void NAME_SOLID_DRAWGLYPHLIST(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
491 |
ImageRef *glyphs, \
|
|
492 |
jint totalGlyphs, jint fgpixel, \
|
|
493 |
jint argbcolor, \
|
|
494 |
jint clipLeft, jint clipTop, \
|
|
495 |
jint clipRight, jint clipBottom, \
|
|
496 |
NativePrimitive *pPrim, \
|
|
497 |
CompositeInfo *pCompInfo) \
|
|
498 |
{ \
|
|
499 |
jint glyphCounter; \
|
|
500 |
jint scan = pRasInfo->scanStride; \
|
|
501 |
DST ## DataType *pPix; \
|
|
502 |
\
|
|
503 |
for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
|
|
504 |
DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
|
|
505 |
left, top, right, bottom) \
|
|
506 |
ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
|
|
507 |
left, top, right, bottom, \
|
|
508 |
clipLeft, clipTop, clipRight, clipBottom, \
|
|
509 |
glyphs, glyphCounter, continue) \
|
|
510 |
pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
|
|
511 |
\
|
|
512 |
do { \
|
|
513 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, left) \
|
|
514 |
jint x = 0; \
|
|
515 |
do { \
|
|
516 |
InitialLoad ## DST(pPix, DstPix); \
|
|
517 |
if (pixels[x]) { \
|
|
518 |
Store ## DST ## PixelData(pPix, 0, fgpixel, DstPix); \
|
|
519 |
} \
|
|
520 |
ShiftBits ## DST(DstPix); \
|
|
521 |
} while (++x < width); \
|
|
522 |
FinalStore ## DST(pPix, DstPix); \
|
|
523 |
pPix = PtrAddBytes(pPix, scan); \
|
|
524 |
pixels += rowBytes; \
|
|
525 |
} while (--height > 0); \
|
|
526 |
} \
|
|
527 |
}
|
|
528 |
|
|
529 |
/*
|
|
530 |
* REMIND: we shouldn't be attempting to do antialiased text for the
|
|
531 |
* ByteBinary surfaces in the first place
|
|
532 |
*/
|
|
533 |
#define DEFINE_BYTE_BINARY_SOLID_DRAWGLYPHLISTAA(DST, STRATEGY) \
|
|
534 |
void NAME_SOLID_DRAWGLYPHLISTAA(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
535 |
ImageRef *glyphs, \
|
|
536 |
jint totalGlyphs, jint fgpixel, \
|
|
537 |
jint argbcolor, \
|
|
538 |
jint clipLeft, jint clipTop, \
|
|
539 |
jint clipRight, jint clipBottom, \
|
|
540 |
NativePrimitive *pPrim, \
|
|
541 |
CompositeInfo *pCompInfo) \
|
|
542 |
{ \
|
|
543 |
jint glyphCounter; \
|
|
544 |
jint scan = pRasInfo->scanStride; \
|
|
545 |
DST ## DataType *pPix; \
|
|
546 |
DeclareAlphaVarFor ## STRATEGY(srcA) \
|
|
547 |
DeclareCompVarsFor ## STRATEGY(src) \
|
|
548 |
\
|
|
549 |
Declare ## DST ## LoadVars(pix) \
|
|
550 |
Declare ## DST ## StoreVars(pix) \
|
|
551 |
\
|
|
552 |
Init ## DST ## LoadVars(pix, pRasInfo); \
|
|
553 |
Init ## DST ## StoreVarsY(pix, pRasInfo); \
|
|
554 |
Init ## DST ## StoreVarsX(pix, pRasInfo); \
|
|
555 |
Extract ## STRATEGY ## CompsAndAlphaFromArgb(argbcolor, src); \
|
|
556 |
\
|
|
557 |
for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
|
|
558 |
DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
|
|
559 |
left, top, right, bottom) \
|
|
560 |
ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
|
|
561 |
left, top, right, bottom, \
|
|
562 |
clipLeft, clipTop, clipRight, clipBottom, \
|
|
563 |
glyphs, glyphCounter, continue) \
|
|
564 |
pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
|
|
565 |
\
|
|
566 |
Set ## DST ## StoreVarsYPos(pix, pRasInfo, top); \
|
|
567 |
do { \
|
|
568 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, pix, left) \
|
|
569 |
int x = 0; \
|
|
570 |
Set ## DST ## StoreVarsXPos(pix, pRasInfo, left); \
|
|
571 |
do { \
|
|
572 |
InitialLoad ## DST(pPix, pix); \
|
|
573 |
GlyphListAABlend ## STRATEGY(DST, pixels, x, pPix, \
|
|
574 |
fgpixel, pix, src); \
|
|
575 |
ShiftBits ## DST(pix); \
|
|
576 |
Next ## DST ## StoreVarsX(pix); \
|
|
577 |
} while (++x < width); \
|
|
578 |
FinalStore ## DST(pPix, pix); \
|
|
579 |
pPix = PtrAddBytes(pPix, scan); \
|
|
580 |
pixels += rowBytes; \
|
|
581 |
Next ## DST ## StoreVarsY(pix); \
|
|
582 |
} while (--height > 0); \
|
|
583 |
} \
|
|
584 |
}
|
|
585 |
|
|
586 |
#define DEFINE_BYTE_BINARY_XOR_DRAWGLYPHLIST(DST) \
|
|
587 |
void NAME_XOR_DRAWGLYPHLIST(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
588 |
ImageRef *glyphs, \
|
|
589 |
jint totalGlyphs, jint fgpixel, \
|
|
590 |
jint argbcolor, \
|
|
591 |
jint clipLeft, jint clipTop, \
|
|
592 |
jint clipRight, jint clipBottom, \
|
|
593 |
NativePrimitive *pPrim, \
|
|
594 |
CompositeInfo *pCompInfo) \
|
|
595 |
{ \
|
|
596 |
jint glyphCounter; \
|
|
597 |
jint scan = pRasInfo->scanStride; \
|
|
598 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
599 |
juint alphamask = pCompInfo->alphaMask; \
|
|
600 |
DST ## DataType *pPix; \
|
|
601 |
\
|
|
602 |
for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
|
|
603 |
DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
|
|
604 |
left, top, right, bottom) \
|
|
605 |
ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
|
|
606 |
left, top, right, bottom, \
|
|
607 |
clipLeft, clipTop, clipRight, clipBottom, \
|
|
608 |
glyphs, glyphCounter, continue) \
|
|
609 |
pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
|
|
610 |
\
|
|
611 |
do { \
|
|
612 |
Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, left) \
|
|
613 |
jint x = 0; \
|
|
614 |
do { \
|
|
615 |
InitialLoad ## DST(pPix, DstPix); \
|
|
616 |
if (pixels[x]) { \
|
|
617 |
Xor ## DST ## PixelData(pPix, 0, DstPix, \
|
|
618 |
fgpixel, xorpixel, alphamask); \
|
|
619 |
} \
|
|
620 |
ShiftBits ## DST(DstPix); \
|
|
621 |
} while (++x < width); \
|
|
622 |
FinalStore ## DST(pPix, DstPix); \
|
|
623 |
pPix = PtrAddBytes(pPix, scan); \
|
|
624 |
pixels += rowBytes; \
|
|
625 |
} while (--height > 0); \
|
|
626 |
} \
|
|
627 |
}
|
|
628 |
|
|
629 |
#define DEFINE_BYTE_BINARY_ALPHA_MASKBLIT(SRC, DST, STRATEGY) \
|
|
630 |
void NAME_ALPHA_MASKBLIT(SRC, DST) \
|
|
631 |
(void *dstBase, void *srcBase, \
|
|
632 |
jubyte *pMask, jint maskOff, jint maskScan, \
|
|
633 |
jint width, jint height, \
|
|
634 |
SurfaceDataRasInfo *pDstInfo, \
|
|
635 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
636 |
NativePrimitive *pPrim, \
|
|
637 |
CompositeInfo *pCompInfo) \
|
|
638 |
{ \
|
|
639 |
DeclareAndSetOpaqueAlphaVarFor ## STRATEGY(pathA) \
|
|
640 |
DeclareAndClearAlphaVarFor ## STRATEGY(srcA) \
|
|
641 |
DeclareAndClearAlphaVarFor ## STRATEGY(dstA) \
|
|
642 |
DeclareAndInitExtraAlphaFor ## STRATEGY(extraA) \
|
|
643 |
jint srcScan = pSrcInfo->scanStride; \
|
|
644 |
jint dstScan = pDstInfo->scanStride; \
|
|
645 |
jboolean loadsrc, loaddst; \
|
|
646 |
jint srcx1 = pSrcInfo->bounds.x1; \
|
|
647 |
jint dstx1 = pDstInfo->bounds.x1; \
|
|
648 |
SRC ## DataType *pSrc = (SRC ## DataType *) (srcBase); \
|
|
649 |
DST ## DataType *pDst = (DST ## DataType *) (dstBase); \
|
|
650 |
Declare ## SRC ## AlphaLoadData(SrcRead) \
|
|
651 |
Declare ## DST ## AlphaLoadData(DstWrite) \
|
|
652 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
653 |
DeclareAlphaOperands(SrcOp) \
|
|
654 |
DeclareAlphaOperands(DstOp) \
|
|
655 |
\
|
|
656 |
ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].srcOps, \
|
|
657 |
SrcOp); \
|
|
658 |
ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].dstOps, \
|
|
659 |
DstOp); \
|
|
660 |
loadsrc = !FuncIsZero(SrcOp) || FuncNeedsAlpha(DstOp); \
|
|
661 |
loaddst = pMask || !FuncIsZero(DstOp) || FuncNeedsAlpha(SrcOp); \
|
|
662 |
\
|
|
663 |
Init ## SRC ## AlphaLoadData(SrcRead, pSrcInfo); \
|
|
664 |
Init ## DST ## AlphaLoadData(DstWrite, pDstInfo); \
|
|
665 |
srcScan -= width * SRC ## PixelStride; \
|
|
666 |
dstScan -= width * DST ## PixelStride; \
|
|
667 |
maskScan -= width; \
|
|
668 |
if (pMask) { \
|
|
669 |
pMask += maskOff; \
|
|
670 |
} \
|
|
671 |
\
|
|
672 |
Init ## DST ## StoreVarsY(DstWrite, pDstInfo); \
|
|
673 |
do { \
|
|
674 |
Declare ## SRC ## InitialLoadVars(pSrcInfo, pSrc, SrcRead, srcx1) \
|
|
675 |
Declare ## DST ## InitialLoadVars(pDstInfo, pDst, DstWrite, dstx1) \
|
|
676 |
jint w = width; \
|
|
677 |
Init ## DST ## StoreVarsX(DstWrite, pDstInfo); \
|
|
678 |
do { \
|
|
679 |
DeclareAlphaVarFor ## STRATEGY(resA) \
|
|
680 |
DeclareCompVarsFor ## STRATEGY(res) \
|
|
681 |
DeclareAlphaVarFor ## STRATEGY(srcF) \
|
|
682 |
DeclareAlphaVarFor ## STRATEGY(dstF) \
|
|
683 |
\
|
|
684 |
InitialLoad ## SRC(pSrc, SrcRead); \
|
|
685 |
InitialLoad ## DST(pDst, DstWrite); \
|
|
686 |
if (pMask) { \
|
|
687 |
pathA = *pMask++; \
|
|
688 |
if (!pathA) { \
|
|
689 |
ShiftBits ## SRC(SrcRead); \
|
|
690 |
ShiftBits ## DST(DstWrite); \
|
|
691 |
pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
|
|
692 |
pDst = PtrAddBytes(pDst, DST ## PixelStride); \
|
|
693 |
Next ## DST ## StoreVarsX(DstWrite); \
|
|
694 |
continue; \
|
|
695 |
} \
|
|
696 |
PromoteByteAlphaFor ## STRATEGY(pathA); \
|
|
697 |
} \
|
|
698 |
if (loadsrc) { \
|
|
699 |
LoadAlphaFrom ## SRC ## For ## STRATEGY(pSrc,SrcRead,src); \
|
|
700 |
srcA = MultiplyAlphaFor ## STRATEGY(extraA, srcA); \
|
|
701 |
} \
|
|
702 |
if (loaddst) { \
|
|
703 |
LoadAlphaFrom ## DST ## For ## STRATEGY(pDst,DstWrite,dst); \
|
|
704 |
} \
|
|
705 |
srcF = ApplyAlphaOperands(SrcOp, dstA); \
|
|
706 |
dstF = ApplyAlphaOperands(DstOp, srcA); \
|
|
707 |
if (pathA != MaxValFor ## STRATEGY) { \
|
|
708 |
srcF = MultiplyAlphaFor ## STRATEGY(pathA, srcF); \
|
|
709 |
dstF = MaxValFor ## STRATEGY - pathA + \
|
|
710 |
MultiplyAlphaFor ## STRATEGY(pathA, dstF); \
|
|
711 |
} \
|
|
712 |
if (srcF) { \
|
|
713 |
resA = MultiplyAlphaFor ## STRATEGY(srcF, srcA); \
|
|
714 |
if (!(SRC ## IsPremultiplied)) { \
|
|
715 |
srcF = resA; \
|
|
716 |
} else { \
|
|
717 |
srcF = MultiplyAlphaFor ## STRATEGY(srcF, extraA); \
|
|
718 |
} \
|
|
719 |
if (srcF) { \
|
|
720 |
/* assert(loadsrc); */ \
|
|
721 |
Postload ## STRATEGY ## From ## SRC(pSrc, SrcRead, res); \
|
|
722 |
if (srcF != MaxValFor ## STRATEGY) { \
|
|
723 |
MultiplyAndStore ## STRATEGY ## Comps(res, \
|
|
724 |
srcF, res); \
|
|
725 |
} \
|
|
726 |
} else { \
|
|
727 |
Set ## STRATEGY ## CompsToZero(res); \
|
|
728 |
} \
|
|
729 |
} else { \
|
|
730 |
if (dstF == MaxValFor ## STRATEGY) { \
|
|
731 |
ShiftBits ## SRC(SrcRead); \
|
|
732 |
ShiftBits ## DST(DstWrite); \
|
|
733 |
pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
|
|
734 |
pDst = PtrAddBytes(pDst, DST ## PixelStride); \
|
|
735 |
Next ## DST ## StoreVarsX(DstWrite); \
|
|
736 |
continue; \
|
|
737 |
} \
|
|
738 |
resA = 0; \
|
|
739 |
Set ## STRATEGY ## CompsToZero(res); \
|
|
740 |
} \
|
|
741 |
if (dstF) { \
|
|
742 |
dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA); \
|
|
743 |
if (!(DST ## IsPremultiplied)) { \
|
|
744 |
dstF = dstA; \
|
|
745 |
} \
|
|
746 |
resA += dstA; \
|
|
747 |
if (dstF) { \
|
|
748 |
DeclareCompVarsFor ## STRATEGY(tmp) \
|
|
749 |
/* assert(loaddst); */ \
|
|
750 |
Postload ## STRATEGY ## From ## DST(pDst,DstWrite,tmp); \
|
|
751 |
if (dstF != MaxValFor ## STRATEGY) { \
|
|
752 |
MultiplyAndStore ## STRATEGY ## Comps(tmp, \
|
|
753 |
dstF, tmp); \
|
|
754 |
} \
|
|
755 |
Store ## STRATEGY ## CompsUsingOp(res, +=, tmp); \
|
|
756 |
} \
|
|
757 |
} \
|
|
758 |
if (!(DST ## IsPremultiplied) && resA && \
|
|
759 |
resA < MaxValFor ## STRATEGY) \
|
|
760 |
{ \
|
|
761 |
DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
|
|
762 |
} \
|
|
763 |
Store ## DST ## From ## STRATEGY ## Comps(pDst, DstWrite, \
|
|
764 |
0, res); \
|
|
765 |
ShiftBits ## SRC(SrcRead); \
|
|
766 |
ShiftBits ## DST(DstWrite); \
|
|
767 |
pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
|
|
768 |
pDst = PtrAddBytes(pDst, DST ## PixelStride); \
|
|
769 |
Next ## DST ## StoreVarsX(DstWrite); \
|
|
770 |
} while (--w > 0); \
|
|
771 |
FinalStore ## DST(pDst, DstWrite); \
|
|
772 |
pSrc = PtrAddBytes(pSrc, srcScan); \
|
|
773 |
pDst = PtrAddBytes(pDst, dstScan); \
|
|
774 |
Next ## DST ## StoreVarsY(DstWrite); \
|
|
775 |
if (pMask) { \
|
|
776 |
pMask = PtrAddBytes(pMask, maskScan); \
|
|
777 |
} \
|
|
778 |
} while (--height > 0); \
|
|
779 |
}
|
|
780 |
|
|
781 |
#define DEFINE_BYTE_BINARY_ALPHA_MASKFILL(TYPE, STRATEGY) \
|
|
782 |
void NAME_ALPHA_MASKFILL(TYPE) \
|
|
783 |
(void *rasBase, \
|
|
784 |
jubyte *pMask, jint maskOff, jint maskScan, \
|
|
785 |
jint width, jint height, \
|
|
786 |
jint fgColor, \
|
|
787 |
SurfaceDataRasInfo *pRasInfo, \
|
|
788 |
NativePrimitive *pPrim, \
|
|
789 |
CompositeInfo *pCompInfo) \
|
|
790 |
{ \
|
|
791 |
DeclareAndSetOpaqueAlphaVarFor ## STRATEGY(pathA) \
|
|
792 |
DeclareAlphaVarFor ## STRATEGY(srcA) \
|
|
793 |
DeclareCompVarsFor ## STRATEGY(src) \
|
|
794 |
DeclareAndClearAlphaVarFor ## STRATEGY(dstA) \
|
|
795 |
DeclareAlphaVarFor ## STRATEGY(dstF) \
|
|
796 |
DeclareAlphaVarFor ## STRATEGY(dstFbase) \
|
|
797 |
jint rasScan = pRasInfo->scanStride; \
|
|
798 |
jboolean loaddst; \
|
|
799 |
jint x1 = pRasInfo->bounds.x1; \
|
|
800 |
TYPE ## DataType *pRas = (TYPE ## DataType *) (rasBase); \
|
|
801 |
Declare ## TYPE ## AlphaLoadData(DstWrite) \
|
|
802 |
Declare ## TYPE ## StoreVars(DstWrite) \
|
|
803 |
DeclareAlphaOperands(SrcOp) \
|
|
804 |
DeclareAlphaOperands(DstOp) \
|
|
805 |
\
|
|
806 |
Extract ## STRATEGY ## CompsAndAlphaFromArgb(fgColor, src); \
|
|
807 |
if (srcA != MaxValFor ## STRATEGY) { \
|
|
808 |
MultiplyAndStore ## STRATEGY ## Comps(src, srcA, src); \
|
|
809 |
} \
|
|
810 |
\
|
|
811 |
ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].srcOps, \
|
|
812 |
SrcOp); \
|
|
813 |
ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].dstOps, \
|
|
814 |
DstOp); \
|
|
815 |
loaddst = pMask || !FuncIsZero(DstOp) || FuncNeedsAlpha(SrcOp); \
|
|
816 |
\
|
|
817 |
dstFbase = dstF = ApplyAlphaOperands(DstOp, srcA); \
|
|
818 |
\
|
|
819 |
Init ## TYPE ## AlphaLoadData(DstWrite, pRasInfo); \
|
|
820 |
maskScan -= width; \
|
|
821 |
if (pMask) { \
|
|
822 |
pMask += maskOff; \
|
|
823 |
} \
|
|
824 |
\
|
|
825 |
Init ## TYPE ## StoreVarsY(DstWrite, pRasInfo); \
|
|
826 |
do { \
|
|
827 |
Declare ## TYPE ## InitialLoadVars(pRasInfo, pRas, DstWrite, x1) \
|
|
828 |
jint w = width; \
|
|
829 |
Init ## TYPE ## StoreVarsX(DstWrite, pRasInfo); \
|
|
830 |
do { \
|
|
831 |
DeclareAlphaVarFor ## STRATEGY(resA) \
|
|
832 |
DeclareCompVarsFor ## STRATEGY(res) \
|
|
833 |
DeclareAlphaVarFor ## STRATEGY(srcF) \
|
|
834 |
\
|
|
835 |
InitialLoad ## TYPE(pRas, DstWrite); \
|
|
836 |
if (pMask) { \
|
|
837 |
pathA = *pMask++; \
|
|
838 |
if (!pathA) { \
|
|
839 |
ShiftBits ## TYPE(DstWrite); \
|
|
840 |
Next ## TYPE ## StoreVarsX(DstWrite); \
|
|
841 |
continue; \
|
|
842 |
} \
|
|
843 |
PromoteByteAlphaFor ## STRATEGY(pathA); \
|
|
844 |
dstF = dstFbase; \
|
|
845 |
} \
|
|
846 |
if (loaddst) { \
|
|
847 |
LoadAlphaFrom ## TYPE ## For ## STRATEGY(pRas,DstWrite,dst);\
|
|
848 |
} \
|
|
849 |
srcF = ApplyAlphaOperands(SrcOp, dstA); \
|
|
850 |
if (pathA != MaxValFor ## STRATEGY) { \
|
|
851 |
srcF = MultiplyAlphaFor ## STRATEGY(pathA, srcF); \
|
|
852 |
dstF = MaxValFor ## STRATEGY - pathA + \
|
|
853 |
MultiplyAlphaFor ## STRATEGY(pathA, dstF); \
|
|
854 |
} \
|
|
855 |
if (srcF) { \
|
|
856 |
if (srcF == MaxValFor ## STRATEGY) { \
|
|
857 |
resA = srcA; \
|
|
858 |
Store ## STRATEGY ## CompsUsingOp(res, =, src); \
|
|
859 |
} else { \
|
|
860 |
resA = MultiplyAlphaFor ## STRATEGY(srcF, srcA); \
|
|
861 |
MultiplyAndStore ## STRATEGY ## Comps(res, srcF, src); \
|
|
862 |
} \
|
|
863 |
} else { \
|
|
864 |
if (dstF == MaxValFor ## STRATEGY) { \
|
|
865 |
ShiftBits ## TYPE(DstWrite); \
|
|
866 |
Next ## TYPE ## StoreVarsX(DstWrite); \
|
|
867 |
continue; \
|
|
868 |
} \
|
|
869 |
resA = 0; \
|
|
870 |
Set ## STRATEGY ## CompsToZero(res); \
|
|
871 |
} \
|
|
872 |
if (dstF) { \
|
|
873 |
dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA); \
|
|
874 |
if (!(TYPE ## IsPremultiplied)) { \
|
|
875 |
dstF = dstA; \
|
|
876 |
} \
|
|
877 |
resA += dstA; \
|
|
878 |
if (dstF) { \
|
|
879 |
DeclareCompVarsFor ## STRATEGY(tmp) \
|
|
880 |
/* assert(loaddst); */ \
|
|
881 |
Postload ## STRATEGY ## From ## TYPE(pRas,DstWrite,tmp); \
|
|
882 |
if (dstF != MaxValFor ## STRATEGY) { \
|
|
883 |
MultiplyAndStore ## STRATEGY ## Comps(tmp, \
|
|
884 |
dstF, tmp); \
|
|
885 |
} \
|
|
886 |
Store ## STRATEGY ## CompsUsingOp(res, +=, tmp); \
|
|
887 |
} \
|
|
888 |
} \
|
|
889 |
if (!(TYPE ## IsPremultiplied) && resA && \
|
|
890 |
resA < MaxValFor ## STRATEGY) \
|
|
891 |
{ \
|
|
892 |
DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
|
|
893 |
} \
|
|
894 |
Store ## TYPE ## From ## STRATEGY ## Comps(pRas, DstWrite, \
|
|
895 |
0, res); \
|
|
896 |
ShiftBits ## TYPE(DstWrite); \
|
|
897 |
Next ## TYPE ## StoreVarsX(DstWrite); \
|
|
898 |
} while (--w > 0); \
|
|
899 |
FinalStore ## TYPE(pRas, DstWrite); \
|
|
900 |
pRas = PtrAddBytes(pRas, rasScan); \
|
|
901 |
Next ## TYPE ## StoreVarsY(DstWrite); \
|
|
902 |
if (pMask) { \
|
|
903 |
pMask = PtrAddBytes(pMask, maskScan); \
|
|
904 |
} \
|
|
905 |
} while (--height > 0); \
|
|
906 |
}
|
|
907 |
|
|
908 |
|
|
909 |
/*
|
|
910 |
* The macros defined above use the following macro definitions supplied
|
|
911 |
* for the various ByteBinary-specific surface types to manipulate pixel data.
|
|
912 |
*
|
|
913 |
* In the macro names in the following definitions, the string <stype>
|
|
914 |
* is used as a place holder for the SurfaceType name (eg. ByteBinary2Bit).
|
|
915 |
* The macros above access these type specific macros using the ANSI
|
|
916 |
* CPP token concatenation operator "##".
|
|
917 |
*
|
|
918 |
* Declare<stype>InitialLoadVars Declare and initialize the variables used
|
|
919 |
* for managing byte/bit offsets
|
|
920 |
* InitialLoad<stype> Store the current byte, fetch the next
|
|
921 |
* byte, and reset the bit offset
|
|
922 |
* ShiftBits<stype> Advance to the next pixel by adjusting
|
|
923 |
* the bit offset (1, 2, or 4 bits)
|
|
924 |
* FinalStore<stype> Store the current byte
|
|
925 |
* CurrentPixel<stype> Represents the current pixel by shifting
|
|
926 |
* the value with the current bit offset and
|
|
927 |
* then masking the value to either 1, 2, or
|
|
928 |
* 4 bits
|
|
929 |
*/
|
|
930 |
|
|
931 |
#endif /* AnyByteBinary_h_Included */
|