2
|
1 |
/*
|
|
2 |
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
|
|
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
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
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 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
#ifndef LoopMacros_h_Included
|
|
27 |
#define LoopMacros_h_Included
|
|
28 |
|
|
29 |
#include "j2d_md.h"
|
|
30 |
|
|
31 |
#include "LineUtils.h"
|
|
32 |
|
|
33 |
/*
|
|
34 |
* This file contains macros to aid in defining native graphics
|
|
35 |
* primitive functions.
|
|
36 |
*
|
|
37 |
* A number of useful building block macros are defined, but the
|
|
38 |
* vast majority of primitives are defined completely by a single
|
|
39 |
* macro expansion which uses macro names in the argument list to
|
|
40 |
* choose not only from a small number of strategies but also to
|
|
41 |
* choose macro packages specific to the source and destination
|
|
42 |
* pixel formats - greatly simplifying all aspects of creating
|
|
43 |
* a new loop.
|
|
44 |
*
|
|
45 |
* See the following macros which define entire functions with
|
|
46 |
* just one or two surface names and sometimes a strategy name:
|
|
47 |
* DEFINE_ISOCOPY_BLIT(ANYTYPE)
|
|
48 |
* DEFINE_ISOXOR_BLIT(ANYTYPE)
|
|
49 |
* DEFINE_CONVERT_BLIT(SRC, DST, CONV_METHOD)
|
|
50 |
* DEFINE_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY)
|
|
51 |
* DEFINE_XPAR_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY)
|
|
52 |
* DEFINE_XPAR_BLITBG_LUT(SRC, DST, LUT_STRATEGY)
|
|
53 |
* DEFINE_SOLID_FILLRECT(DST)
|
|
54 |
* DEFINE_SOLID_FILLSPANS(DST)
|
|
55 |
* DEFINE_SOLID_DRAWLINE(DST)
|
|
56 |
*
|
|
57 |
* Many of these loop macros take the name of a SurfaceType as
|
|
58 |
* an argument and use the ANSI CPP token concatenation operator
|
|
59 |
* "##" to reference macro and type definitions that are specific
|
|
60 |
* to that type of surface.
|
|
61 |
*
|
|
62 |
* A description of the various surface specific macro utilities
|
|
63 |
* that are used by these loop macros appears at the end of the
|
|
64 |
* file. The definitions of these surface-specific macros will
|
|
65 |
* usually appear in a header file named after the SurfaceType
|
|
66 |
* name (i.e. IntArgb.h, ByteGray.h, etc.).
|
|
67 |
*/
|
|
68 |
|
|
69 |
/*
|
|
70 |
* This loop is the standard "while (--height > 0)" loop used by
|
|
71 |
* some of the blits below.
|
|
72 |
*/
|
|
73 |
#define BlitLoopHeight(SRCTYPE, SRCPTR, SRCBASE, SRCINFO, \
|
|
74 |
DSTTYPE, DSTPTR, DSTBASE, DSTINFO, DSTPREFIX, \
|
|
75 |
HEIGHT, BODY) \
|
|
76 |
do { \
|
|
77 |
SRCTYPE ## DataType *SRCPTR = (SRCTYPE ## DataType *) (SRCBASE); \
|
|
78 |
DSTTYPE ## DataType *DSTPTR = (DSTTYPE ## DataType *) (DSTBASE); \
|
|
79 |
jint srcScan = (SRCINFO)->scanStride; \
|
|
80 |
jint dstScan = (DSTINFO)->scanStride; \
|
|
81 |
Init ## DSTTYPE ## StoreVarsY(DSTPREFIX, DSTINFO); \
|
|
82 |
do { \
|
|
83 |
BODY; \
|
|
84 |
SRCPTR = PtrAddBytes(SRCPTR, srcScan); \
|
|
85 |
DSTPTR = PtrAddBytes(DSTPTR, dstScan); \
|
|
86 |
Next ## DSTTYPE ## StoreVarsY(DSTPREFIX); \
|
|
87 |
} while (--HEIGHT > 0); \
|
|
88 |
} while (0)
|
|
89 |
|
|
90 |
/*
|
|
91 |
* This loop is the standard nested "while (--width/height > 0)" loop
|
|
92 |
* used by most of the basic blits below.
|
|
93 |
*/
|
|
94 |
#define BlitLoopWidthHeight(SRCTYPE, SRCPTR, SRCBASE, SRCINFO, \
|
|
95 |
DSTTYPE, DSTPTR, DSTBASE, DSTINFO, DSTPREFIX, \
|
|
96 |
WIDTH, HEIGHT, BODY) \
|
|
97 |
do { \
|
|
98 |
SRCTYPE ## DataType *SRCPTR = (SRCTYPE ## DataType *) (SRCBASE); \
|
|
99 |
DSTTYPE ## DataType *DSTPTR = (DSTTYPE ## DataType *) (DSTBASE); \
|
|
100 |
jint srcScan = (SRCINFO)->scanStride; \
|
|
101 |
jint dstScan = (DSTINFO)->scanStride; \
|
|
102 |
Init ## DSTTYPE ## StoreVarsY(DSTPREFIX, DSTINFO); \
|
|
103 |
srcScan -= (WIDTH) * SRCTYPE ## PixelStride; \
|
|
104 |
dstScan -= (WIDTH) * DSTTYPE ## PixelStride; \
|
|
105 |
do { \
|
|
106 |
juint w = WIDTH; \
|
|
107 |
Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \
|
|
108 |
do { \
|
|
109 |
BODY; \
|
|
110 |
SRCPTR = PtrAddBytes(SRCPTR, SRCTYPE ## PixelStride); \
|
|
111 |
DSTPTR = PtrAddBytes(DSTPTR, DSTTYPE ## PixelStride); \
|
|
112 |
Next ## DSTTYPE ## StoreVarsX(DSTPREFIX); \
|
|
113 |
} while (--w > 0); \
|
|
114 |
SRCPTR = PtrAddBytes(SRCPTR, srcScan); \
|
|
115 |
DSTPTR = PtrAddBytes(DSTPTR, dstScan); \
|
|
116 |
Next ## DSTTYPE ## StoreVarsY(DSTPREFIX); \
|
|
117 |
} while (--HEIGHT > 0); \
|
|
118 |
} while (0)
|
|
119 |
|
|
120 |
/*
|
|
121 |
* This loop is the standard nested "while (--width/height > 0)" loop
|
|
122 |
* used by most of the scaled blits below. It calculates the proper
|
|
123 |
* X source variable
|
|
124 |
*/
|
|
125 |
#define BlitLoopScaleWidthHeight(SRCTYPE, SRCPTR, SRCBASE, SRCINFO, \
|
|
126 |
DSTTYPE, DSTPTR, DSTBASE, DSTINFO, DSTPREFIX, \
|
|
127 |
XVAR, WIDTH, HEIGHT, \
|
|
128 |
SXLOC, SYLOC, SXINC, SYINC, SHIFT, \
|
|
129 |
BODY) \
|
|
130 |
do { \
|
|
131 |
SRCTYPE ## DataType *SRCPTR; \
|
|
132 |
DSTTYPE ## DataType *DSTPTR = (DSTTYPE ## DataType *) (DSTBASE); \
|
|
133 |
jint srcScan = (SRCINFO)->scanStride; \
|
|
134 |
jint dstScan = (DSTINFO)->scanStride; \
|
|
135 |
Init ## DSTTYPE ## StoreVarsY(DSTPREFIX, DSTINFO); \
|
|
136 |
dstScan -= (WIDTH) * DSTTYPE ## PixelStride; \
|
|
137 |
do { \
|
|
138 |
juint w = WIDTH; \
|
|
139 |
jint tmpsxloc = SXLOC; \
|
|
140 |
SRCPTR = PtrAddBytes(SRCBASE, ((SYLOC >> SHIFT) * srcScan)); \
|
|
141 |
Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \
|
|
142 |
do { \
|
|
143 |
jint XVAR = (tmpsxloc >> SHIFT); \
|
|
144 |
BODY; \
|
|
145 |
DSTPTR = PtrAddBytes(DSTPTR, DSTTYPE ## PixelStride); \
|
|
146 |
Next ## DSTTYPE ## StoreVarsX(DSTPREFIX); \
|
|
147 |
tmpsxloc += SXINC; \
|
|
148 |
} while (--w > 0); \
|
|
149 |
DSTPTR = PtrAddBytes(DSTPTR, dstScan); \
|
|
150 |
Next ## DSTTYPE ## StoreVarsY(DSTPREFIX); \
|
|
151 |
SYLOC += SYINC; \
|
|
152 |
} while (--HEIGHT > 0); \
|
|
153 |
} while (0)
|
|
154 |
|
|
155 |
/*
|
|
156 |
* This loop is a standard horizontal loop iterating with a "relative"
|
|
157 |
* X coordinate (0 <= X < WIDTH) used primarily by the LUT conversion
|
|
158 |
* preprocessing loops below.
|
|
159 |
*/
|
|
160 |
#define BlitLoopXRel(DSTTYPE, DSTINFO, DSTPREFIX, \
|
|
161 |
XVAR, WIDTH, BODY) \
|
|
162 |
do { \
|
|
163 |
juint XVAR = 0; \
|
|
164 |
Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \
|
|
165 |
do { \
|
|
166 |
BODY; \
|
|
167 |
Next ## DSTTYPE ## StoreVarsX(DSTPREFIX); \
|
|
168 |
} while (++XVAR < WIDTH); \
|
|
169 |
} while (0)
|
|
170 |
|
|
171 |
/*
|
|
172 |
* This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
|
|
173 |
* macros. It converts from the source pixel format to the destination
|
|
174 |
* via an intermediate "jint rgb" format.
|
|
175 |
*/
|
|
176 |
#define ConvertVia1IntRgb(SRCPTR, SRCTYPE, SRCPREFIX, \
|
|
177 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
178 |
SXVAR, DXVAR) \
|
|
179 |
do { \
|
|
180 |
int rgb; \
|
|
181 |
Load ## SRCTYPE ## To1IntRgb(SRCPTR, SRCPREFIX, SXVAR, rgb); \
|
|
182 |
Store ## DSTTYPE ## From1IntRgb(DSTPTR, DSTPREFIX, DXVAR, rgb); \
|
|
183 |
} while (0)
|
|
184 |
|
|
185 |
/*
|
|
186 |
* This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
|
|
187 |
* macros. It converts from the source pixel format to the destination
|
|
188 |
* via an intermediate "jint argb" format.
|
|
189 |
*/
|
|
190 |
#define ConvertVia1IntArgb(SRCPTR, SRCTYPE, SRCPREFIX, \
|
|
191 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
192 |
SXVAR, DXVAR) \
|
|
193 |
do { \
|
|
194 |
int argb; \
|
|
195 |
Load ## SRCTYPE ## To1IntArgb(SRCPTR, SRCPREFIX, SXVAR, argb); \
|
|
196 |
Store ## DSTTYPE ## From1IntArgb(DSTPTR, DSTPREFIX, DXVAR, argb); \
|
|
197 |
} while (0)
|
|
198 |
|
|
199 |
/*
|
|
200 |
* This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
|
|
201 |
* macros. It converts from the source pixel format to the destination
|
|
202 |
* via an intermediate set of 3 component variables "jint r, g, b".
|
|
203 |
*/
|
|
204 |
#define ConvertVia3ByteRgb(SRCPTR, SRCTYPE, SRCPREFIX, \
|
|
205 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
206 |
SXVAR, DXVAR) \
|
|
207 |
do { \
|
|
208 |
jint r, g, b; \
|
|
209 |
Load ## SRCTYPE ## To3ByteRgb(SRCPTR, SRCPREFIX, SXVAR, r, g, b); \
|
|
210 |
Store ## DSTTYPE ## From3ByteRgb(DSTPTR, DSTPREFIX, DXVAR, r, g, b); \
|
|
211 |
} while (0)
|
|
212 |
|
|
213 |
/*
|
|
214 |
* This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
|
|
215 |
* macros. It converts from the source pixel format to the destination
|
|
216 |
* via an intermediate set of 4 component variables "jint a, r, g, b".
|
|
217 |
*/
|
|
218 |
#define ConvertVia4ByteArgb(SRCPTR, SRCTYPE, SRCPREFIX, \
|
|
219 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
220 |
SXVAR, DXVAR) \
|
|
221 |
do { \
|
|
222 |
jint a, r, g, b; \
|
|
223 |
Load ## SRCTYPE ## To4ByteArgb(SRCPTR, SRCPREFIX, SXVAR, a, r, g, b); \
|
|
224 |
Store ## DSTTYPE ## From4ByteArgb(DSTPTR, DSTPREFIX, DXVAR, \
|
|
225 |
a, r, g, b); \
|
|
226 |
} while (0)
|
|
227 |
|
|
228 |
/*
|
|
229 |
* This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
|
|
230 |
* macros. It converts from the source pixel format to the destination
|
|
231 |
* via an intermediate "jint gray" format.
|
|
232 |
*/
|
|
233 |
#define ConvertVia1ByteGray(SRCPTR, SRCTYPE, SRCPREFIX, \
|
|
234 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
235 |
SXVAR, DXVAR) \
|
|
236 |
do { \
|
|
237 |
jint gray; \
|
|
238 |
Load ## SRCTYPE ## To1ByteGray(SRCPTR, SRCPREFIX, SXVAR, gray); \
|
|
239 |
Store ## DSTTYPE ## From1ByteGray(DSTPTR, DSTPREFIX, DXVAR, gray); \
|
|
240 |
} while (0)
|
|
241 |
|
|
242 |
/*
|
|
243 |
* This is a "conversion strategy" for use with the DEFINE_XPAR_CONVERT_BLIT
|
|
244 |
* macros. It converts from the source pixel format to the destination
|
|
245 |
* via the specified intermediate format while testing for transparent pixels.
|
|
246 |
*/
|
|
247 |
#define ConvertXparVia1IntRgb(SRCPTR, SRCTYPE, SRCPREFIX, \
|
|
248 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
249 |
SXVAR, DXVAR) \
|
|
250 |
do { \
|
|
251 |
Declare ## SRCTYPE ## Data(XparLoad); \
|
|
252 |
Load ## SRCTYPE ## Data(SRCPTR, SRCPREFIX, SXVAR, XparLoad); \
|
|
253 |
if (! (Is ## SRCTYPE ## DataTransparent(XparLoad))) { \
|
|
254 |
int rgb; \
|
|
255 |
Convert ## SRCTYPE ## DataTo1IntRgb(XparLoad, rgb); \
|
|
256 |
Store ## DSTTYPE ## From1IntRgb(DSTPTR, DSTPREFIX, DXVAR, rgb); \
|
|
257 |
} \
|
|
258 |
} while (0)
|
|
259 |
|
|
260 |
/*
|
|
261 |
* This is a "conversion strategy" for use with the DEFINE_XPAR_BLITBG
|
|
262 |
* macros. It converts from the source pixel format to the destination
|
|
263 |
* via the specified intermediate format while substituting the specified
|
|
264 |
* bgcolor for transparent pixels.
|
|
265 |
*/
|
|
266 |
#define BgCopyXparVia1IntRgb(SRCPTR, SRCTYPE, SRCPREFIX, \
|
|
267 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
268 |
SXVAR, DXVAR, BGPIXEL, BGPREFIX) \
|
|
269 |
do { \
|
|
270 |
Declare ## SRCTYPE ## Data(XparLoad); \
|
|
271 |
Load ## SRCTYPE ## Data(SRCPTR, SRCPREFIX, SXVAR, XparLoad); \
|
|
272 |
if (Is ## SRCTYPE ## DataTransparent(XparLoad)) { \
|
|
273 |
Store ## DSTTYPE ## PixelData(DSTPTR, DXVAR, BGPIXEL, BGPREFIX); \
|
|
274 |
} else { \
|
|
275 |
int rgb; \
|
|
276 |
Convert ## SRCTYPE ## DataTo1IntRgb(XparLoad, rgb); \
|
|
277 |
Store ## DSTTYPE ## From1IntRgb(DSTPTR, DSTPREFIX, DXVAR, rgb); \
|
|
278 |
} \
|
|
279 |
} while (0)
|
|
280 |
|
|
281 |
/*
|
|
282 |
* This macro determines whether or not the given pixel is considered
|
|
283 |
* "transparent" for XOR purposes. The ARGB pixel is considered
|
|
284 |
* "transparent" if the alpha value is < 0.5.
|
|
285 |
*/
|
|
286 |
#define IsArgbTransparent(pixel) \
|
|
287 |
(((jint) pixel) >= 0)
|
|
288 |
|
|
289 |
/*
|
|
290 |
* This is a "conversion strategy" for use with the DEFINE_XOR_BLIT macro. It
|
|
291 |
* converts the source pixel to an intermediate ARGB value and then converts
|
|
292 |
* the ARGB value to the pixel representation for the destination surface. It
|
|
293 |
* then XORs the srcpixel, xorpixel, and destination pixel together and stores
|
|
294 |
* the result in the destination surface.
|
|
295 |
*/
|
|
296 |
#define XorVia1IntArgb(SRCPTR, SRCTYPE, SRCPREFIX, \
|
|
297 |
DSTPTR, DSTTYPE, DSTANYTYPE, \
|
|
298 |
XVAR, XORPIXEL, XORPREFIX, \
|
|
299 |
MASK, MASKPREFIX, DSTINFOPTR) \
|
|
300 |
do { \
|
|
301 |
jint srcpixel; \
|
|
302 |
Declare ## DSTANYTYPE ## PixelData(pix) \
|
|
303 |
Load ## SRCTYPE ## To1IntArgb(SRCPTR, SRCPREFIX, XVAR, srcpixel); \
|
|
304 |
\
|
|
305 |
if (IsArgbTransparent(srcpixel)) { \
|
|
306 |
break; \
|
|
307 |
} \
|
|
308 |
\
|
|
309 |
DSTTYPE ## PixelFromArgb(srcpixel, srcpixel, DSTINFOPTR); \
|
|
310 |
\
|
|
311 |
Extract ## DSTANYTYPE ## PixelData(srcpixel, pix); \
|
|
312 |
Xor ## DSTANYTYPE ## PixelData(srcpixel, pix, DSTPTR, XVAR, \
|
|
313 |
XORPIXEL, XORPREFIX, \
|
|
314 |
MASK, MASKPREFIX); \
|
|
315 |
} while (0)
|
|
316 |
|
|
317 |
/*
|
|
318 |
* "LUT_STRATEGY" macro sets.
|
|
319 |
*
|
|
320 |
* There are 2 major strategies for dealing with luts and 3
|
|
321 |
* implementations of those strategies.
|
|
322 |
*
|
|
323 |
* The 2 strategies are "PreProcessLut" and "ConvertOnTheFly".
|
|
324 |
*
|
|
325 |
* For the "PreProcessLut" strategy, the raw ARGB lut supplied
|
|
326 |
* by the SD_LOCK_LUT flag is converted at the beginning into a
|
|
327 |
* form that is more suited for storing into the destination
|
|
328 |
* pixel format. The inner loop consists of a series of table
|
|
329 |
* lookups with very little conversion from that intermediate
|
|
330 |
* pixel format.
|
|
331 |
*
|
|
332 |
* For the "ConvertOnTheFly" strategy, the raw ARGB values are
|
|
333 |
* converted on a pixel by pixel basis in the inner loop itself.
|
|
334 |
* This strategy is most useful for formats which tend to use
|
|
335 |
* the ARGB color format as their pixel format also.
|
|
336 |
*
|
|
337 |
* Each of these strategies has 3 implementations which are needed
|
|
338 |
* for the special cases:
|
|
339 |
* - straight conversion (invoked from DEFINE_CONVERT_BLIT_LUT)
|
|
340 |
* - straight conversion with transparency handling (invoked from
|
|
341 |
* DEFINE_XPAR_CONVERT_BLIT_LUT)
|
|
342 |
* - straight conversion with a bgcolor for the transparent pixels
|
|
343 |
* (invoked from DEFINE_XPAR_BLITBG_LUT)
|
|
344 |
*/
|
|
345 |
|
|
346 |
/***
|
|
347 |
* Start of PreProcessLut strategy macros, CONVERT_BLIT implementation.
|
|
348 |
*/
|
|
349 |
#define LutSize(TYPE) \
|
|
350 |
(1 << TYPE ## BitsPerPixel)
|
|
351 |
|
|
352 |
#define DeclarePreProcessLutLut(SRC, DST, PIXLUT) \
|
|
353 |
DST ## PixelType PIXLUT[LutSize(SRC)];
|
|
354 |
|
|
355 |
#define SetupPreProcessLutLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO) \
|
|
356 |
do { \
|
|
357 |
jint *srcLut = (SRCINFO)->lutBase; \
|
|
358 |
juint lutSize = (SRCINFO)->lutSize; \
|
|
359 |
Declare ## DST ## StoreVars(PreLut) \
|
|
360 |
Init ## DST ## StoreVarsY(PreLut, DSTINFO); \
|
|
361 |
if (lutSize >= LutSize(SRC)) { \
|
|
362 |
lutSize = LutSize(SRC); \
|
|
363 |
} else { \
|
|
364 |
DST ## PixelType *pPIXLUT = &PIXLUT[lutSize]; \
|
|
365 |
do { \
|
|
366 |
Store ## DST ## From1IntArgb(pPIXLUT, PreLut, 0, 0); \
|
|
367 |
} while (++pPIXLUT < &PIXLUT[LutSize(SRC)]); \
|
|
368 |
} \
|
|
369 |
BlitLoopXRel(DST, DSTINFO, PreLut, x, lutSize, \
|
|
370 |
do { \
|
|
371 |
jint argb = srcLut[x]; \
|
|
372 |
Store ## DST ## From1IntArgb(PIXLUT, PreLut, x, argb); \
|
|
373 |
} while (0)); \
|
|
374 |
} while (0)
|
|
375 |
|
|
376 |
#define BodyPreProcessLutLut(SRCPTR, SRCTYPE, PIXLUT, \
|
|
377 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
378 |
SXVAR, DXVAR) \
|
|
379 |
DSTPTR[DXVAR] = PIXLUT[SRCPTR[SXVAR]]
|
|
380 |
|
|
381 |
/*
|
|
382 |
* End of PreProcessLut/CONVERT_BLIT macros.
|
|
383 |
***/
|
|
384 |
|
|
385 |
/***
|
|
386 |
* Start of ConvertOnTheFly strategy macros, CONVERT_BLIT implementation.
|
|
387 |
*/
|
|
388 |
#define DeclareConvertOnTheFlyLut(SRC, DST, PIXLUT) \
|
|
389 |
Declare ## SRC ## LoadVars(PIXLUT)
|
|
390 |
|
|
391 |
#define SetupConvertOnTheFlyLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO) \
|
|
392 |
Init ## SRC ## LoadVars(PIXLUT, SRCINFO)
|
|
393 |
|
|
394 |
#define BodyConvertOnTheFlyLut(SRCPTR, SRCTYPE, PIXLUT, \
|
|
395 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
396 |
SXVAR, DXVAR) \
|
|
397 |
ConvertVia1IntArgb(SRCPTR, SRCTYPE, PIXLUT, \
|
|
398 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
399 |
SXVAR, DXVAR)
|
|
400 |
|
|
401 |
/*
|
|
402 |
* End of ConvertOnTheFly/CONVERT_BLIT macros.
|
|
403 |
***/
|
|
404 |
|
|
405 |
/***
|
|
406 |
* Start of PreProcessLut strategy macros, XPAR_CONVERT_BLIT implementation.
|
|
407 |
*/
|
|
408 |
#define DeclarePreProcessLutXparLut(SRC, DST, PIXLUT) \
|
|
409 |
jint PIXLUT[LutSize(SRC)];
|
|
410 |
|
|
411 |
#define SetupPreProcessLutXparLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO) \
|
|
412 |
do { \
|
|
413 |
jint *srcLut = (SRCINFO)->lutBase; \
|
|
414 |
juint lutSize = (SRCINFO)->lutSize; \
|
|
415 |
Declare ## DST ## StoreVars(PreLut) \
|
|
416 |
Init ## DST ## StoreVarsY(PreLut, DSTINFO); \
|
|
417 |
if (lutSize >= LutSize(SRC)) { \
|
|
418 |
lutSize = LutSize(SRC); \
|
|
419 |
} else { \
|
|
420 |
jint *pPIXLUT = &PIXLUT[lutSize]; \
|
|
421 |
do { \
|
|
422 |
pPIXLUT[0] = DST ## XparLutEntry; \
|
|
423 |
} while (++pPIXLUT < &PIXLUT[LutSize(SRC)]); \
|
|
424 |
} \
|
|
425 |
BlitLoopXRel(DST, DSTINFO, PreLut, x, lutSize, \
|
|
426 |
do { \
|
|
427 |
jint argb = srcLut[x]; \
|
|
428 |
if (argb < 0) { \
|
|
429 |
Store ## DST ## NonXparFromArgb \
|
|
430 |
(PIXLUT, PreLut, x, argb); \
|
|
431 |
} else { \
|
|
432 |
PIXLUT[x] = DST ## XparLutEntry; \
|
|
433 |
} \
|
|
434 |
} while (0)); \
|
|
435 |
} while (0)
|
|
436 |
|
|
437 |
#define BodyPreProcessLutXparLut(SRCPTR, SRCTYPE, PIXLUT, \
|
|
438 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
439 |
SXVAR, DXVAR) \
|
|
440 |
do { \
|
|
441 |
jint pix = PIXLUT[SRCPTR[SXVAR]]; \
|
|
442 |
if (! DSTTYPE ## IsXparLutEntry(pix)) { \
|
|
443 |
DSTPTR[DXVAR] = (DSTTYPE ## PixelType) pix; \
|
|
444 |
} \
|
|
445 |
} while (0)
|
|
446 |
|
|
447 |
/*
|
|
448 |
* End of PreProcessLut/XPAR_CONVERT_BLIT macros.
|
|
449 |
***/
|
|
450 |
|
|
451 |
/***
|
|
452 |
* Start of ConvertOnTheFly strategy macros, CONVERT_BLIT implementation.
|
|
453 |
*/
|
|
454 |
#define DeclareConvertOnTheFlyXparLut(SRC, DST, PIXLUT) \
|
|
455 |
Declare ## SRC ## LoadVars(PIXLUT)
|
|
456 |
|
|
457 |
#define SetupConvertOnTheFlyXparLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO) \
|
|
458 |
Init ## SRC ## LoadVars(PIXLUT, SRCINFO)
|
|
459 |
|
|
460 |
#define BodyConvertOnTheFlyXparLut(SRCPTR, SRCTYPE, PIXLUT, \
|
|
461 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
462 |
SXVAR, DXVAR) \
|
|
463 |
do { \
|
|
464 |
jint argb; \
|
|
465 |
Load ## SRCTYPE ## To1IntArgb(SRCPTR, PIXLUT, SXVAR, argb); \
|
|
466 |
if (argb < 0) { \
|
|
467 |
Store ## DSTTYPE ## From1IntArgb(DSTPTR, DSTPREFIX, DXVAR, argb); \
|
|
468 |
} \
|
|
469 |
} while (0)
|
|
470 |
|
|
471 |
/*
|
|
472 |
* End of ConvertOnTheFly/CONVERT_BLIT macros.
|
|
473 |
***/
|
|
474 |
|
|
475 |
/***
|
|
476 |
* Start of PreProcessLut strategy macros, BLITBG implementation.
|
|
477 |
*/
|
|
478 |
#define DeclarePreProcessLutBgLut(SRC, DST, PIXLUT) \
|
|
479 |
jint PIXLUT[LutSize(SRC)];
|
|
480 |
|
|
481 |
#define SetupPreProcessLutBgLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO, BGPIXEL) \
|
|
482 |
do { \
|
|
483 |
jint *srcLut = (SRCINFO)->lutBase; \
|
|
484 |
juint lutSize = (SRCINFO)->lutSize; \
|
|
485 |
Declare ## DST ## StoreVars(PreLut) \
|
|
486 |
Init ## DST ## StoreVarsY(PreLut, DSTINFO); \
|
|
487 |
if (lutSize >= LutSize(SRC)) { \
|
|
488 |
lutSize = LutSize(SRC); \
|
|
489 |
} else { \
|
|
490 |
jint *pPIXLUT = &PIXLUT[lutSize]; \
|
|
491 |
do { \
|
|
492 |
pPIXLUT[0] = BGPIXEL; \
|
|
493 |
} while (++pPIXLUT < &PIXLUT[LutSize(SRC)]); \
|
|
494 |
} \
|
|
495 |
BlitLoopXRel(DST, DSTINFO, PreLut, x, lutSize, \
|
|
496 |
do { \
|
|
497 |
jint argb = srcLut[x]; \
|
|
498 |
if (argb < 0) { \
|
|
499 |
Store ## DST ## From1IntArgb(PIXLUT, PreLut, \
|
|
500 |
x, argb); \
|
|
501 |
} else { \
|
|
502 |
PIXLUT[x] = BGPIXEL; \
|
|
503 |
} \
|
|
504 |
} while (0)); \
|
|
505 |
} while (0)
|
|
506 |
|
|
507 |
#define BodyPreProcessLutBgLut(SRCPTR, SRCTYPE, PIXLUT, \
|
|
508 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
509 |
SXVAR, DXVAR, BGPIXEL) \
|
|
510 |
do { \
|
|
511 |
jint pix = PIXLUT[SRCPTR[SXVAR]]; \
|
|
512 |
Store ## DSTTYPE ## Pixel(DSTPTR, DXVAR, pix); \
|
|
513 |
} while (0)
|
|
514 |
|
|
515 |
/*
|
|
516 |
* End of PreProcessLut/BLITBG implementation.
|
|
517 |
***/
|
|
518 |
|
|
519 |
/***
|
|
520 |
* Start of ConvertOnTheFly strategy macros, BLITBG implementation.
|
|
521 |
*/
|
|
522 |
#define DeclareConvertOnTheFlyBgLut(SRC, DST, PIXLUT) \
|
|
523 |
Declare ## SRC ## LoadVars(PIXLUT) \
|
|
524 |
Declare ## DST ## PixelData(bgpix);
|
|
525 |
|
|
526 |
#define SetupConvertOnTheFlyBgLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO, BGPIXEL) \
|
|
527 |
do { \
|
|
528 |
Init ## SRC ## LoadVars(PIXLUT, SRCINFO); \
|
|
529 |
Extract ## DST ## PixelData(BGPIXEL, bgpix); \
|
|
530 |
} while (0)
|
|
531 |
|
|
532 |
#define BodyConvertOnTheFlyBgLut(SRCPTR, SRCTYPE, PIXLUT, \
|
|
533 |
DSTPTR, DSTTYPE, DSTPREFIX, \
|
|
534 |
SXVAR, DXVAR, BGPIXEL) \
|
|
535 |
do { \
|
|
536 |
jint argb; \
|
|
537 |
Load ## SRCTYPE ## To1IntArgb(SRCPTR, PIXLUT, SXVAR, argb); \
|
|
538 |
if (argb < 0) { \
|
|
539 |
Store ## DSTTYPE ## From1IntArgb(DSTPTR, DSTPREFIX, DXVAR, argb); \
|
|
540 |
} else { \
|
|
541 |
Store ## DSTTYPE ## PixelData(DSTPTR, DXVAR, BGPIXEL, bgpix); \
|
|
542 |
} \
|
|
543 |
} while (0)
|
|
544 |
|
|
545 |
/*
|
|
546 |
* End of ConvertOnTheFly/BLITBG macros.
|
|
547 |
***/
|
|
548 |
|
|
549 |
/*
|
|
550 |
* These macros provide consistent naming conventions for the
|
|
551 |
* various types of native primitive inner loop functions.
|
|
552 |
* The names are mechanically constructed from the SurfaceType names.
|
|
553 |
*/
|
|
554 |
#define NAME_CONVERT_BLIT(SRC, DST) SRC ## To ## DST ## Convert
|
|
555 |
|
|
556 |
#define NAME_SCALE_BLIT(SRC, DST) SRC ## To ## DST ## ScaleConvert
|
|
557 |
|
|
558 |
#define NAME_XPAR_CONVERT_BLIT(SRC, DST) SRC ## To ## DST ## XparOver
|
|
559 |
|
|
560 |
#define NAME_XPAR_SCALE_BLIT(SRC, DST) SRC ## To ## DST ## ScaleXparOver
|
|
561 |
|
|
562 |
#define NAME_XPAR_BLITBG(SRC, DST) SRC ## To ## DST ## XparBgCopy
|
|
563 |
|
|
564 |
#define NAME_XOR_BLIT(SRC, DST) SRC ## To ## DST ## XorBlit
|
|
565 |
|
|
566 |
#define NAME_ISOCOPY_BLIT(ANYTYPE) ANYTYPE ## IsomorphicCopy
|
|
567 |
|
|
568 |
#define NAME_ISOSCALE_BLIT(ANYTYPE) ANYTYPE ## IsomorphicScaleCopy
|
|
569 |
|
|
570 |
#define NAME_ISOXOR_BLIT(ANYTYPE) ANYTYPE ## IsomorphicXorCopy
|
|
571 |
|
|
572 |
#define NAME_SOLID_FILLRECT(TYPE) TYPE ## SetRect
|
|
573 |
|
|
574 |
#define NAME_SOLID_FILLSPANS(TYPE) TYPE ## SetSpans
|
|
575 |
|
|
576 |
#define NAME_SOLID_DRAWLINE(TYPE) TYPE ## SetLine
|
|
577 |
|
|
578 |
#define NAME_XOR_FILLRECT(TYPE) TYPE ## XorRect
|
|
579 |
|
|
580 |
#define NAME_XOR_FILLSPANS(TYPE) TYPE ## XorSpans
|
|
581 |
|
|
582 |
#define NAME_XOR_DRAWLINE(TYPE) TYPE ## XorLine
|
|
583 |
|
|
584 |
#define NAME_SRC_MASKFILL(TYPE) TYPE ## SrcMaskFill
|
|
585 |
|
|
586 |
#define NAME_SRCOVER_MASKFILL(TYPE) TYPE ## SrcOverMaskFill
|
|
587 |
|
|
588 |
#define NAME_ALPHA_MASKFILL(TYPE) TYPE ## AlphaMaskFill
|
|
589 |
|
|
590 |
#define NAME_SRCOVER_MASKBLIT(SRC, DST) SRC ## To ## DST ## SrcOverMaskBlit
|
|
591 |
|
|
592 |
#define NAME_ALPHA_MASKBLIT(SRC, DST) SRC ## To ## DST ## AlphaMaskBlit
|
|
593 |
|
|
594 |
#define NAME_SOLID_DRAWGLYPHLIST(TYPE) TYPE ## DrawGlyphList
|
|
595 |
|
|
596 |
#define NAME_SOLID_DRAWGLYPHLISTAA(TYPE) TYPE ## DrawGlyphListAA
|
|
597 |
|
|
598 |
#define NAME_SOLID_DRAWGLYPHLISTLCD(TYPE) TYPE ## DrawGlyphListLCD
|
|
599 |
|
|
600 |
#define NAME_XOR_DRAWGLYPHLIST(TYPE) TYPE ## DrawGlyphListXor
|
|
601 |
|
|
602 |
#define NAME_TRANSFORMHELPER(TYPE, MODE) TYPE ## MODE ## TransformHelper
|
|
603 |
|
|
604 |
#define NAME_TRANSFORMHELPER_NN(TYPE) NAME_TRANSFORMHELPER(TYPE, NrstNbr)
|
|
605 |
#define NAME_TRANSFORMHELPER_BL(TYPE) NAME_TRANSFORMHELPER(TYPE, Bilinear)
|
|
606 |
#define NAME_TRANSFORMHELPER_BC(TYPE) NAME_TRANSFORMHELPER(TYPE, Bicubic)
|
|
607 |
|
|
608 |
#define NAME_TRANSFORMHELPER_FUNCS(TYPE) TYPE ## TransformHelperFuncs
|
|
609 |
|
|
610 |
/*
|
|
611 |
* These macros conveniently name and declare the indicated native
|
|
612 |
* primitive loop function for forward referencing.
|
|
613 |
*/
|
|
614 |
#define DECLARE_CONVERT_BLIT(SRC, DST) \
|
|
615 |
BlitFunc NAME_CONVERT_BLIT(SRC, DST)
|
|
616 |
|
|
617 |
#define DECLARE_SCALE_BLIT(SRC, DST) \
|
|
618 |
ScaleBlitFunc NAME_SCALE_BLIT(SRC, DST)
|
|
619 |
|
|
620 |
#define DECLARE_XPAR_CONVERT_BLIT(SRC, DST) \
|
|
621 |
BlitFunc NAME_XPAR_CONVERT_BLIT(SRC, DST)
|
|
622 |
|
|
623 |
#define DECLARE_XPAR_SCALE_BLIT(SRC, DST) \
|
|
624 |
ScaleBlitFunc NAME_XPAR_SCALE_BLIT(SRC, DST)
|
|
625 |
|
|
626 |
#define DECLARE_XPAR_BLITBG(SRC, DST) \
|
|
627 |
BlitBgFunc NAME_XPAR_BLITBG(SRC, DST)
|
|
628 |
|
|
629 |
#define DECLARE_XOR_BLIT(SRC, DST) \
|
|
630 |
BlitFunc NAME_XOR_BLIT(SRC, DST)
|
|
631 |
|
|
632 |
#define DECLARE_ISOCOPY_BLIT(ANYTYPE) \
|
|
633 |
BlitFunc NAME_ISOCOPY_BLIT(ANYTYPE)
|
|
634 |
|
|
635 |
#define DECLARE_ISOSCALE_BLIT(ANYTYPE) \
|
|
636 |
ScaleBlitFunc NAME_ISOSCALE_BLIT(ANYTYPE)
|
|
637 |
|
|
638 |
#define DECLARE_ISOXOR_BLIT(ANYTYPE) \
|
|
639 |
BlitFunc NAME_ISOXOR_BLIT(ANYTYPE)
|
|
640 |
|
|
641 |
#define DECLARE_SOLID_FILLRECT(TYPE) \
|
|
642 |
FillRectFunc NAME_SOLID_FILLRECT(TYPE)
|
|
643 |
|
|
644 |
#define DECLARE_SOLID_FILLSPANS(TYPE) \
|
|
645 |
FillSpansFunc NAME_SOLID_FILLSPANS(TYPE)
|
|
646 |
|
|
647 |
#define DECLARE_SOLID_DRAWLINE(TYPE) \
|
|
648 |
DrawLineFunc NAME_SOLID_DRAWLINE(TYPE)
|
|
649 |
|
|
650 |
#define DECLARE_XOR_FILLRECT(TYPE) \
|
|
651 |
FillRectFunc NAME_XOR_FILLRECT(TYPE)
|
|
652 |
|
|
653 |
#define DECLARE_XOR_FILLSPANS(TYPE) \
|
|
654 |
FillSpansFunc NAME_XOR_FILLSPANS(TYPE)
|
|
655 |
|
|
656 |
#define DECLARE_XOR_DRAWLINE(TYPE) \
|
|
657 |
DrawLineFunc NAME_XOR_DRAWLINE(TYPE)
|
|
658 |
|
|
659 |
#define DECLARE_ALPHA_MASKFILL(TYPE) \
|
|
660 |
MaskFillFunc NAME_ALPHA_MASKFILL(TYPE)
|
|
661 |
|
|
662 |
#define DECLARE_SRC_MASKFILL(TYPE) \
|
|
663 |
MaskFillFunc NAME_SRC_MASKFILL(TYPE)
|
|
664 |
|
|
665 |
#define DECLARE_SRCOVER_MASKFILL(TYPE) \
|
|
666 |
MaskFillFunc NAME_SRCOVER_MASKFILL(TYPE)
|
|
667 |
|
|
668 |
#define DECLARE_SRCOVER_MASKBLIT(SRC, DST) \
|
|
669 |
MaskBlitFunc NAME_SRCOVER_MASKBLIT(SRC, DST)
|
|
670 |
|
|
671 |
#define DECLARE_ALPHA_MASKBLIT(SRC, DST) \
|
|
672 |
MaskBlitFunc NAME_ALPHA_MASKBLIT(SRC, DST)
|
|
673 |
|
|
674 |
#define DECLARE_SOLID_DRAWGLYPHLIST(TYPE) \
|
|
675 |
DrawGlyphListFunc NAME_SOLID_DRAWGLYPHLIST(TYPE)
|
|
676 |
|
|
677 |
#define DECLARE_SOLID_DRAWGLYPHLISTAA(TYPE) \
|
|
678 |
DrawGlyphListAAFunc NAME_SOLID_DRAWGLYPHLISTAA(TYPE)
|
|
679 |
|
|
680 |
#define DECLARE_SOLID_DRAWGLYPHLISTLCD(TYPE) \
|
|
681 |
DrawGlyphListLCDFunc NAME_SOLID_DRAWGLYPHLISTLCD(TYPE)
|
|
682 |
|
|
683 |
#define DECLARE_XOR_DRAWGLYPHLIST(TYPE) \
|
|
684 |
DrawGlyphListFunc NAME_XOR_DRAWGLYPHLIST(TYPE)
|
|
685 |
|
|
686 |
#define DECLARE_TRANSFORMHELPER_FUNCS(TYPE) \
|
|
687 |
TransformHelperFunc NAME_TRANSFORMHELPER_NN(TYPE); \
|
|
688 |
TransformHelperFunc NAME_TRANSFORMHELPER_BL(TYPE); \
|
|
689 |
TransformHelperFunc NAME_TRANSFORMHELPER_BC(TYPE); \
|
|
690 |
TransformHelperFuncs NAME_TRANSFORMHELPER_FUNCS(TYPE)
|
|
691 |
|
|
692 |
/*
|
|
693 |
* These macros construct the necessary NativePrimitive structure
|
|
694 |
* for the indicated native primitive loop function which will be
|
|
695 |
* declared somewhere prior and defined elsewhere (usually after).
|
|
696 |
*/
|
|
697 |
#define REGISTER_CONVERT_BLIT(SRC, DST) \
|
|
698 |
REGISTER_BLIT(SRC, SrcNoEa, DST, NAME_CONVERT_BLIT(SRC, DST))
|
|
699 |
|
|
700 |
#define REGISTER_CONVERT_BLIT_FLAGS(SRC, DST, SFLAGS, DFLAGS) \
|
|
701 |
REGISTER_BLIT_FLAGS(SRC, SrcNoEa, DST, NAME_CONVERT_BLIT(SRC, DST), \
|
|
702 |
SFLAGS, DFLAGS)
|
|
703 |
|
|
704 |
#define REGISTER_CONVERT_BLIT_EQUIV(SRC, DST, FUNC) \
|
|
705 |
REGISTER_BLIT(SRC, SrcNoEa, DST, FUNC)
|
|
706 |
|
|
707 |
#define REGISTER_SCALE_BLIT(SRC, DST) \
|
|
708 |
REGISTER_SCALEBLIT(SRC, SrcNoEa, DST, NAME_SCALE_BLIT(SRC, DST))
|
|
709 |
|
|
710 |
#define REGISTER_SCALE_BLIT_FLAGS(SRC, DST, SFLAGS, DFLAGS) \
|
|
711 |
REGISTER_SCALEBLIT_FLAGS(SRC, SrcNoEa, DST, NAME_SCALE_BLIT(SRC, DST), \
|
|
712 |
SFLAGS, DFLAGS)
|
|
713 |
|
|
714 |
#define REGISTER_SCALE_BLIT_EQUIV(SRC, DST, FUNC) \
|
|
715 |
REGISTER_SCALEBLIT(SRC, SrcNoEa, DST, FUNC)
|
|
716 |
|
|
717 |
#define REGISTER_XPAR_CONVERT_BLIT(SRC, DST) \
|
|
718 |
REGISTER_BLIT(SRC, SrcOverBmNoEa, DST, NAME_XPAR_CONVERT_BLIT(SRC, DST))
|
|
719 |
|
|
720 |
#define REGISTER_XPAR_CONVERT_BLIT_EQUIV(SRC, DST, FUNC) \
|
|
721 |
REGISTER_BLIT(SRC, SrcOverBmNoEa, DST, FUNC)
|
|
722 |
|
|
723 |
#define REGISTER_XPAR_SCALE_BLIT(SRC, DST) \
|
|
724 |
REGISTER_SCALEBLIT(SRC, SrcOverBmNoEa, DST, NAME_XPAR_SCALE_BLIT(SRC, DST))
|
|
725 |
|
|
726 |
#define REGISTER_XPAR_SCALE_BLIT_EQUIV(SRC, DST, FUNC) \
|
|
727 |
REGISTER_SCALEBLIT(SRC, SrcOverBmNoEa, DST, FUNC)
|
|
728 |
|
|
729 |
#define REGISTER_XPAR_BLITBG(SRC, DST) \
|
|
730 |
REGISTER_BLITBG(SRC, SrcNoEa, DST, NAME_XPAR_BLITBG(SRC, DST))
|
|
731 |
|
|
732 |
#define REGISTER_XPAR_BLITBG_EQUIV(SRC, DST, FUNC) \
|
|
733 |
REGISTER_BLITBG(SRC, SrcNoEa, DST, FUNC)
|
|
734 |
|
|
735 |
#define REGISTER_XOR_BLIT(SRC, DST) \
|
|
736 |
REGISTER_BLIT(SRC, Xor, DST, NAME_XOR_BLIT(SRC, DST))
|
|
737 |
|
|
738 |
#define REGISTER_ISOCOPY_BLIT(THISTYPE, ANYTYPE) \
|
|
739 |
REGISTER_BLIT(THISTYPE, SrcNoEa, THISTYPE, NAME_ISOCOPY_BLIT(ANYTYPE))
|
|
740 |
|
|
741 |
#define REGISTER_ISOSCALE_BLIT(THISTYPE, ANYTYPE) \
|
|
742 |
REGISTER_SCALEBLIT(THISTYPE, SrcNoEa, THISTYPE, NAME_ISOSCALE_BLIT(ANYTYPE))
|
|
743 |
|
|
744 |
#define REGISTER_ISOXOR_BLIT(THISTYPE, ANYTYPE) \
|
|
745 |
REGISTER_BLIT(THISTYPE, Xor, THISTYPE, NAME_ISOXOR_BLIT(ANYTYPE))
|
|
746 |
|
|
747 |
#define REGISTER_SOLID_FILLRECT(TYPE) \
|
|
748 |
REGISTER_FILLRECT(AnyColor, SrcNoEa, TYPE, NAME_SOLID_FILLRECT(TYPE))
|
|
749 |
|
|
750 |
#define REGISTER_SOLID_FILLSPANS(TYPE) \
|
|
751 |
REGISTER_FILLSPANS(AnyColor, SrcNoEa, TYPE, NAME_SOLID_FILLSPANS(TYPE))
|
|
752 |
|
|
753 |
#define REGISTER_SOLID_LINE_PRIMITIVES(TYPE) \
|
|
754 |
REGISTER_LINE_PRIMITIVES(AnyColor, SrcNoEa, TYPE, \
|
|
755 |
NAME_SOLID_DRAWLINE(TYPE))
|
|
756 |
|
|
757 |
#define REGISTER_XOR_FILLRECT(TYPE) \
|
|
758 |
REGISTER_FILLRECT(AnyColor, Xor, TYPE, NAME_XOR_FILLRECT(TYPE))
|
|
759 |
|
|
760 |
#define REGISTER_XOR_FILLSPANS(TYPE) \
|
|
761 |
REGISTER_FILLSPANS(AnyColor, Xor, TYPE, NAME_XOR_FILLSPANS(TYPE))
|
|
762 |
|
|
763 |
#define REGISTER_XOR_LINE_PRIMITIVES(TYPE) \
|
|
764 |
REGISTER_LINE_PRIMITIVES(AnyColor, Xor, TYPE, NAME_XOR_DRAWLINE(TYPE))
|
|
765 |
|
|
766 |
#define REGISTER_ALPHA_MASKFILL(TYPE) \
|
|
767 |
REGISTER_MASKFILL(AnyColor, AnyAlpha, TYPE, NAME_ALPHA_MASKFILL(TYPE))
|
|
768 |
|
|
769 |
#define REGISTER_SRC_MASKFILL(TYPE) \
|
|
770 |
REGISTER_MASKFILL(AnyColor, Src, TYPE, NAME_SRC_MASKFILL(TYPE))
|
|
771 |
|
|
772 |
#define REGISTER_SRCOVER_MASKFILL(TYPE) \
|
|
773 |
REGISTER_MASKFILL(AnyColor, SrcOver, TYPE, NAME_SRCOVER_MASKFILL(TYPE))
|
|
774 |
|
|
775 |
#define REGISTER_SRCOVER_MASKBLIT(SRC, DST) \
|
|
776 |
REGISTER_MASKBLIT(SRC, SrcOver, DST, NAME_SRCOVER_MASKBLIT(SRC, DST))
|
|
777 |
|
|
778 |
#define REGISTER_ALPHA_MASKBLIT(SRC, DST) \
|
|
779 |
REGISTER_MASKBLIT(SRC, AnyAlpha, DST, NAME_ALPHA_MASKBLIT(SRC, DST))
|
|
780 |
|
|
781 |
#define REGISTER_SOLID_DRAWGLYPHLIST(TYPE) \
|
|
782 |
REGISTER_DRAWGLYPHLIST(AnyColor, SrcNoEa, TYPE, \
|
|
783 |
NAME_SOLID_DRAWGLYPHLIST(TYPE))
|
|
784 |
|
|
785 |
#define REGISTER_SOLID_DRAWGLYPHLISTAA(TYPE) \
|
|
786 |
REGISTER_DRAWGLYPHLISTAA(AnyColor, SrcNoEa, TYPE, \
|
|
787 |
NAME_SOLID_DRAWGLYPHLISTAA(TYPE))
|
|
788 |
|
|
789 |
#define REGISTER_SOLID_DRAWGLYPHLISTLCD(TYPE) \
|
|
790 |
REGISTER_DRAWGLYPHLISTLCD(AnyColor, SrcNoEa, TYPE, \
|
|
791 |
NAME_SOLID_DRAWGLYPHLISTLCD(TYPE))
|
|
792 |
|
|
793 |
#define REGISTER_XOR_DRAWGLYPHLIST(TYPE) \
|
|
794 |
REGISTER_DRAWGLYPHLIST(AnyColor, Xor, TYPE, \
|
|
795 |
NAME_XOR_DRAWGLYPHLIST(TYPE)), \
|
|
796 |
REGISTER_DRAWGLYPHLISTAA(AnyColor, Xor, TYPE, \
|
|
797 |
NAME_XOR_DRAWGLYPHLIST(TYPE))
|
|
798 |
|
|
799 |
#define REGISTER_TRANSFORMHELPER_FUNCS(TYPE) \
|
|
800 |
REGISTER_PRIMITIVE(TransformHelper, TYPE, SrcNoEa, IntArgbPre, \
|
|
801 |
(AnyFunc *) &NAME_TRANSFORMHELPER_FUNCS(TYPE))
|
|
802 |
|
|
803 |
/*
|
|
804 |
* This macro defines an entire function to implement a Blit inner loop
|
|
805 |
* for copying pixels of a common type from one buffer to another.
|
|
806 |
*/
|
|
807 |
#define DEFINE_ISOCOPY_BLIT(ANYTYPE) \
|
|
808 |
void NAME_ISOCOPY_BLIT(ANYTYPE)(void *srcBase, void *dstBase, \
|
|
809 |
juint width, juint height, \
|
|
810 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
811 |
SurfaceDataRasInfo *pDstInfo, \
|
|
812 |
NativePrimitive *pPrim, \
|
|
813 |
CompositeInfo *pCompInfo) \
|
|
814 |
{ \
|
|
815 |
Declare ## ANYTYPE ## StoreVars(DstWrite) \
|
|
816 |
BlitLoopHeight(ANYTYPE, pSrc, srcBase, pSrcInfo, \
|
|
817 |
ANYTYPE, pDst, dstBase, pDstInfo, DstWrite, \
|
|
818 |
height, \
|
|
819 |
memcpy(pDst, pSrc, width * ANYTYPE ## PixelStride)); \
|
|
820 |
}
|
|
821 |
|
|
822 |
/*
|
|
823 |
* This macro defines an entire function to implement a ScaleBlit inner loop
|
|
824 |
* for scaling pixels of a common type from one buffer to another.
|
|
825 |
*/
|
|
826 |
#define DEFINE_ISOSCALE_BLIT(ANYTYPE) \
|
|
827 |
void NAME_ISOSCALE_BLIT(ANYTYPE)(void *srcBase, void *dstBase, \
|
|
828 |
juint width, juint height, \
|
|
829 |
jint sxloc, jint syloc, \
|
|
830 |
jint sxinc, jint syinc, jint shift, \
|
|
831 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
832 |
SurfaceDataRasInfo *pDstInfo, \
|
|
833 |
NativePrimitive *pPrim, \
|
|
834 |
CompositeInfo *pCompInfo) \
|
|
835 |
{ \
|
|
836 |
Declare ## ANYTYPE ## StoreVars(DstWrite) \
|
|
837 |
BlitLoopScaleWidthHeight(ANYTYPE, pSrc, srcBase, pSrcInfo, \
|
|
838 |
ANYTYPE, pDst, dstBase, pDstInfo, DstWrite, \
|
|
839 |
x, width, height, \
|
|
840 |
sxloc, syloc, sxinc, syinc, shift, \
|
|
841 |
Copy ## ANYTYPE ## PixelData(pSrc, x, pDst, 0)); \
|
|
842 |
}
|
|
843 |
|
|
844 |
/*
|
|
845 |
* This macro defines an entire function to implement a Blit inner loop
|
|
846 |
* for XORing pixels of a common type from one buffer into another.
|
|
847 |
*/
|
|
848 |
#define DEFINE_ISOXOR_BLIT(ANYTYPE) \
|
|
849 |
void NAME_ISOXOR_BLIT(ANYTYPE)(void *srcBase, void *dstBase, \
|
|
850 |
juint width, juint height, \
|
|
851 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
852 |
SurfaceDataRasInfo *pDstInfo, \
|
|
853 |
NativePrimitive *pPrim, \
|
|
854 |
CompositeInfo *pCompInfo) \
|
|
855 |
{ \
|
|
856 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
857 |
Declare ## ANYTYPE ## PixelData(xor) \
|
|
858 |
Declare ## ANYTYPE ## StoreVars(DstWrite) \
|
|
859 |
\
|
|
860 |
Extract ## ANYTYPE ## PixelData(xorpixel, xor); \
|
|
861 |
\
|
|
862 |
BlitLoopWidthHeight(ANYTYPE, pSrc, srcBase, pSrcInfo, \
|
|
863 |
ANYTYPE, pDst, dstBase, pDstInfo, DstWrite, \
|
|
864 |
width, height, \
|
|
865 |
XorCopy ## ANYTYPE ## PixelData(pSrc, pDst, 0, \
|
|
866 |
xorpixel, xor)); \
|
|
867 |
}
|
|
868 |
|
|
869 |
/*
|
|
870 |
* This macro defines an entire function to implement a Blit inner loop
|
|
871 |
* for converting pixels from a buffer of one type into a buffer of
|
|
872 |
* another type. No blending is done of the pixels.
|
|
873 |
*/
|
|
874 |
#define DEFINE_CONVERT_BLIT(SRC, DST, STRATEGY) \
|
|
875 |
void NAME_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
876 |
juint width, juint height, \
|
|
877 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
878 |
SurfaceDataRasInfo *pDstInfo, \
|
|
879 |
NativePrimitive *pPrim, \
|
|
880 |
CompositeInfo *pCompInfo) \
|
|
881 |
{ \
|
|
882 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
883 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
884 |
\
|
|
885 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
886 |
BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
887 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
888 |
width, height, \
|
|
889 |
ConvertVia ## STRATEGY(pSrc, SRC, SrcRead, \
|
|
890 |
pDst, DST, DstWrite, \
|
|
891 |
0, 0)); \
|
|
892 |
}
|
|
893 |
|
|
894 |
/*
|
|
895 |
* This macro defines an entire function to implement a Blit inner loop
|
|
896 |
* for converting pixels from a buffer of byte pixels with a lookup
|
|
897 |
* table into a buffer of another type. No blending is done of the pixels.
|
|
898 |
*/
|
|
899 |
#define DEFINE_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY) \
|
|
900 |
void NAME_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
901 |
juint width, juint height, \
|
|
902 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
903 |
SurfaceDataRasInfo *pDstInfo, \
|
|
904 |
NativePrimitive *pPrim, \
|
|
905 |
CompositeInfo *pCompInfo) \
|
|
906 |
{ \
|
|
907 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
908 |
Declare ## LUT_STRATEGY ## Lut(SRC, DST, pixLut) \
|
|
909 |
\
|
|
910 |
Setup ## LUT_STRATEGY ## Lut(SRC, DST, pixLut,\
|
|
911 |
pSrcInfo, pDstInfo); \
|
|
912 |
BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
913 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
914 |
width, height, \
|
|
915 |
Body ## LUT_STRATEGY ## Lut(pSrc, SRC, \
|
|
916 |
pixLut, \
|
|
917 |
pDst, DST, \
|
|
918 |
DstWrite, 0, 0));\
|
|
919 |
}
|
|
920 |
#define DEFINE_CONVERT_BLIT_LUT8(SRC, DST, LUT_STRATEGY) \
|
|
921 |
DEFINE_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY)
|
|
922 |
|
|
923 |
/*
|
|
924 |
* This macro defines an entire function to implement a ScaleBlit inner
|
|
925 |
* loop for scaling and converting pixels from a buffer of one type into
|
|
926 |
* a buffer of another type. No blending is done of the pixels.
|
|
927 |
*/
|
|
928 |
#define DEFINE_SCALE_BLIT(SRC, DST, STRATEGY) \
|
|
929 |
void NAME_SCALE_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
930 |
juint width, juint height, \
|
|
931 |
jint sxloc, jint syloc, \
|
|
932 |
jint sxinc, jint syinc, jint shift, \
|
|
933 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
934 |
SurfaceDataRasInfo *pDstInfo, \
|
|
935 |
NativePrimitive *pPrim, \
|
|
936 |
CompositeInfo *pCompInfo) \
|
|
937 |
{ \
|
|
938 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
939 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
940 |
\
|
|
941 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
942 |
BlitLoopScaleWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
943 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
944 |
x, width, height, \
|
|
945 |
sxloc, syloc, sxinc, syinc, shift, \
|
|
946 |
ConvertVia ## STRATEGY(pSrc, SRC, SrcRead, \
|
|
947 |
pDst, DST, DstWrite, \
|
|
948 |
x, 0)); \
|
|
949 |
}
|
|
950 |
|
|
951 |
/*
|
|
952 |
* This macro defines an entire function to implement a ScaleBlit inner
|
|
953 |
* loop for scaling and converting pixels from a buffer of byte pixels
|
|
954 |
* with a lookup table into a buffer of another type. No blending is
|
|
955 |
* done of the pixels.
|
|
956 |
*/
|
|
957 |
#define DEFINE_SCALE_BLIT_LUT(SRC, DST, LUT_STRATEGY) \
|
|
958 |
void NAME_SCALE_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
959 |
juint width, juint height, \
|
|
960 |
jint sxloc, jint syloc, \
|
|
961 |
jint sxinc, jint syinc, jint shift, \
|
|
962 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
963 |
SurfaceDataRasInfo *pDstInfo, \
|
|
964 |
NativePrimitive *pPrim, \
|
|
965 |
CompositeInfo *pCompInfo) \
|
|
966 |
{ \
|
|
967 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
968 |
Declare ## LUT_STRATEGY ## Lut(SRC, DST, pixLut) \
|
|
969 |
\
|
|
970 |
Setup ## LUT_STRATEGY ## Lut(SRC, DST, pixLut, pSrcInfo, pDstInfo); \
|
|
971 |
BlitLoopScaleWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
972 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
973 |
x, width, height, \
|
|
974 |
sxloc, syloc, sxinc, syinc, shift, \
|
|
975 |
Body ## LUT_STRATEGY ## Lut(pSrc, SRC, pixLut, \
|
|
976 |
pDst, DST, \
|
|
977 |
DstWrite, x, 0));\
|
|
978 |
}
|
|
979 |
#define DEFINE_SCALE_BLIT_LUT8(SRC, DST, LUT_STRATEGY) \
|
|
980 |
DEFINE_SCALE_BLIT_LUT(SRC, DST, LUT_STRATEGY)
|
|
981 |
|
|
982 |
/*
|
|
983 |
* This macro defines an entire function to implement a Blit inner loop
|
|
984 |
* for drawing opaque pixels from a buffer of one type onto a buffer of
|
|
985 |
* another type, ignoring the transparent pixels in the source buffer.
|
|
986 |
* No blending is done of the pixels - the converted pixel value is
|
|
987 |
* either copied or the destination is left untouched.
|
|
988 |
*/
|
|
989 |
#define DEFINE_XPAR_CONVERT_BLIT(SRC, DST, STRATEGY) \
|
|
990 |
void NAME_XPAR_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
991 |
juint width, juint height, \
|
|
992 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
993 |
SurfaceDataRasInfo *pDstInfo, \
|
|
994 |
NativePrimitive *pPrim, \
|
|
995 |
CompositeInfo *pCompInfo) \
|
|
996 |
{ \
|
|
997 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
998 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
999 |
\
|
|
1000 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
1001 |
BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
1002 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
1003 |
width, height, \
|
|
1004 |
ConvertXparVia ## STRATEGY(pSrc, SRC, SrcRead, \
|
|
1005 |
pDst, DST, DstWrite, \
|
|
1006 |
0, 0)); \
|
|
1007 |
}
|
|
1008 |
|
|
1009 |
/*
|
|
1010 |
* This macro defines an entire function to implement a Blit inner loop
|
|
1011 |
* for converting pixels from a buffer of byte pixels with a lookup
|
|
1012 |
* table containing transparent pixels into a buffer of another type.
|
|
1013 |
* No blending is done of the pixels - the converted pixel value is
|
|
1014 |
* either copied or the destination is left untouched.
|
|
1015 |
*/
|
|
1016 |
#define DEFINE_XPAR_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY) \
|
|
1017 |
void NAME_XPAR_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
1018 |
juint width, juint height, \
|
|
1019 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
1020 |
SurfaceDataRasInfo *pDstInfo, \
|
|
1021 |
NativePrimitive *pPrim, \
|
|
1022 |
CompositeInfo *pCompInfo) \
|
|
1023 |
{ \
|
|
1024 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
1025 |
Declare ## LUT_STRATEGY ## XparLut(SRC, DST, pixLut) \
|
|
1026 |
\
|
|
1027 |
Setup ## LUT_STRATEGY ## XparLut(SRC, DST, pixLut, pSrcInfo, pDstInfo); \
|
|
1028 |
BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
1029 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
1030 |
width, height, \
|
|
1031 |
Body ## LUT_STRATEGY ## XparLut(pSrc, SRC, pixLut, \
|
|
1032 |
pDst, DST, \
|
|
1033 |
DstWrite, 0, 0)); \
|
|
1034 |
}
|
|
1035 |
#define DEFINE_XPAR_CONVERT_BLIT_LUT8(SRC, DST, LUT_STRATEGY) \
|
|
1036 |
DEFINE_XPAR_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY)
|
|
1037 |
|
|
1038 |
/*
|
|
1039 |
* This macro defines an entire function to implement a ScaleBlit inner
|
|
1040 |
* loop for scaling and converting pixels from a buffer of byte pixels
|
|
1041 |
* with a lookup table containing transparent pixels into a buffer of
|
|
1042 |
* another type.
|
|
1043 |
* No blending is done of the pixels - the converted pixel value is
|
|
1044 |
* either copied or the destination is left untouched.
|
|
1045 |
*/
|
|
1046 |
#define DEFINE_XPAR_SCALE_BLIT_LUT(SRC, DST, LUT_STRATEGY) \
|
|
1047 |
void NAME_XPAR_SCALE_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
1048 |
juint width, juint height, \
|
|
1049 |
jint sxloc, jint syloc, \
|
|
1050 |
jint sxinc, jint syinc, jint shift, \
|
|
1051 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
1052 |
SurfaceDataRasInfo *pDstInfo, \
|
|
1053 |
NativePrimitive *pPrim, \
|
|
1054 |
CompositeInfo *pCompInfo) \
|
|
1055 |
{ \
|
|
1056 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
1057 |
Declare ## LUT_STRATEGY ## XparLut(SRC, DST, pixLut) \
|
|
1058 |
\
|
|
1059 |
Setup ## LUT_STRATEGY ## XparLut(SRC, DST, pixLut, pSrcInfo, pDstInfo); \
|
|
1060 |
BlitLoopScaleWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
1061 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
1062 |
x, width, height, \
|
|
1063 |
sxloc, syloc, sxinc, syinc, shift, \
|
|
1064 |
Body ## LUT_STRATEGY ## XparLut(pSrc, SRC, pixLut, \
|
|
1065 |
pDst, DST, \
|
|
1066 |
DstWrite, \
|
|
1067 |
x, 0)); \
|
|
1068 |
}
|
|
1069 |
#define DEFINE_XPAR_SCALE_BLIT_LUT8(SRC, DST, LUT_STRATEGY) \
|
|
1070 |
DEFINE_XPAR_SCALE_BLIT_LUT(SRC, DST, LUT_STRATEGY)
|
|
1071 |
|
|
1072 |
/*
|
|
1073 |
* This macro defines an entire function to implement a ScaleBlit inner
|
|
1074 |
* loop for scaling and converting pixels from a buffer of one type
|
|
1075 |
* containing transparent pixels into a buffer of another type.
|
|
1076 |
*
|
|
1077 |
* No blending is done of the pixels - the converted pixel value is
|
|
1078 |
* either copied or the destination is left untouched.
|
|
1079 |
*/
|
|
1080 |
#define DEFINE_XPAR_SCALE_BLIT(SRC, DST, STRATEGY) \
|
|
1081 |
void NAME_XPAR_SCALE_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
1082 |
juint width, juint height, \
|
|
1083 |
jint sxloc, jint syloc, \
|
|
1084 |
jint sxinc, jint syinc, jint shift, \
|
|
1085 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
1086 |
SurfaceDataRasInfo *pDstInfo, \
|
|
1087 |
NativePrimitive *pPrim, \
|
|
1088 |
CompositeInfo *pCompInfo) \
|
|
1089 |
{ \
|
|
1090 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
1091 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
1092 |
\
|
|
1093 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
1094 |
BlitLoopScaleWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
1095 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
1096 |
x, width, height, \
|
|
1097 |
sxloc, syloc, sxinc, syinc, shift, \
|
|
1098 |
ConvertXparVia ## STRATEGY(pSrc, SRC, SrcRead, \
|
|
1099 |
pDst, DST, DstWrite, \
|
|
1100 |
x, 0)); \
|
|
1101 |
}
|
|
1102 |
|
|
1103 |
/*
|
|
1104 |
* This macro defines an entire function to implement a BlitBg inner loop
|
|
1105 |
* for converting pixels from a buffer of one type containing transparent
|
|
1106 |
* pixels into a buffer of another type with a specified bgcolor for the
|
|
1107 |
* transparent pixels.
|
|
1108 |
* No blending is done of the pixels other than to substitute the
|
|
1109 |
* bgcolor for any transparent pixels.
|
|
1110 |
*/
|
|
1111 |
#define DEFINE_XPAR_BLITBG(SRC, DST, STRATEGY) \
|
|
1112 |
void NAME_XPAR_BLITBG(SRC, DST)(void *srcBase, void *dstBase, \
|
|
1113 |
juint width, juint height, \
|
|
1114 |
jint bgpixel, \
|
|
1115 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
1116 |
SurfaceDataRasInfo *pDstInfo, \
|
|
1117 |
NativePrimitive *pPrim, \
|
|
1118 |
CompositeInfo *pCompInfo) \
|
|
1119 |
{ \
|
|
1120 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
1121 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
1122 |
Declare ## DST ## PixelData(bgdata) \
|
|
1123 |
\
|
|
1124 |
Extract ## DST ## PixelData(bgpixel, bgdata); \
|
|
1125 |
BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
1126 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
1127 |
width, height, \
|
|
1128 |
BgCopyXparVia ## STRATEGY(pSrc, SRC, SrcRead, \
|
|
1129 |
pDst, DST, DstWrite, \
|
|
1130 |
0, 0, bgpixel, bgdata)); \
|
|
1131 |
}
|
|
1132 |
|
|
1133 |
/*
|
|
1134 |
* This macro defines an entire function to implement a BlitBg inner loop
|
|
1135 |
* for converting pixels from a buffer of byte pixels with a lookup
|
|
1136 |
* table containing transparent pixels into a buffer of another type
|
|
1137 |
* with a specified bgcolor for the transparent pixels.
|
|
1138 |
* No blending is done of the pixels other than to substitute the
|
|
1139 |
* bgcolor for any transparent pixels.
|
|
1140 |
*/
|
|
1141 |
#define DEFINE_XPAR_BLITBG_LUT(SRC, DST, LUT_STRATEGY) \
|
|
1142 |
void NAME_XPAR_BLITBG(SRC, DST)(void *srcBase, void *dstBase, \
|
|
1143 |
juint width, juint height, \
|
|
1144 |
jint bgpixel, \
|
|
1145 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
1146 |
SurfaceDataRasInfo *pDstInfo, \
|
|
1147 |
NativePrimitive *pPrim, \
|
|
1148 |
CompositeInfo *pCompInfo) \
|
|
1149 |
{ \
|
|
1150 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
1151 |
Declare ## LUT_STRATEGY ## BgLut(SRC, DST, pixLut) \
|
|
1152 |
\
|
|
1153 |
Setup ## LUT_STRATEGY ## BgLut(SRC, DST, pixLut, pSrcInfo, pDstInfo, \
|
|
1154 |
bgpixel); \
|
|
1155 |
BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
1156 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
1157 |
width, height, \
|
|
1158 |
Body ## LUT_STRATEGY ## BgLut(pSrc, SRC, pixLut, \
|
|
1159 |
pDst, DST, \
|
|
1160 |
DstWrite, 0, 0, \
|
|
1161 |
bgpixel)); \
|
|
1162 |
}
|
|
1163 |
#define DEFINE_XPAR_BLITBG_LUT8(SRC, DST, LUT_STRATEGY) \
|
|
1164 |
DEFINE_XPAR_BLITBG_LUT(SRC, DST, LUT_STRATEGY)
|
|
1165 |
|
|
1166 |
/*
|
|
1167 |
* This macro defines an entire function to implement a Blit inner loop
|
|
1168 |
* for converting pixels from a buffer of one type into a buffer of
|
|
1169 |
* another type. Each source pixel is XORed with the current XOR color value.
|
|
1170 |
* That result is then XORed with the destination pixel and the final
|
|
1171 |
* result is stored in the destination surface.
|
|
1172 |
*/
|
|
1173 |
#define DEFINE_XOR_BLIT(SRC, DST, DSTANYTYPE) \
|
|
1174 |
void NAME_XOR_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
|
|
1175 |
juint width, juint height, \
|
|
1176 |
SurfaceDataRasInfo *pSrcInfo, \
|
|
1177 |
SurfaceDataRasInfo *pDstInfo, \
|
|
1178 |
NativePrimitive *pPrim, \
|
|
1179 |
CompositeInfo *pCompInfo) \
|
|
1180 |
{ \
|
|
1181 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
1182 |
juint alphamask = pCompInfo->alphaMask; \
|
|
1183 |
Declare ## DSTANYTYPE ## PixelData(xor) \
|
|
1184 |
Declare ## DSTANYTYPE ## PixelData(mask) \
|
|
1185 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
1186 |
Declare ## DST ## StoreVars(DstWrite) \
|
|
1187 |
\
|
|
1188 |
Extract ## DSTANYTYPE ## PixelData(xorpixel, xor); \
|
|
1189 |
Extract ## DSTANYTYPE ## PixelData(alphamask, mask); \
|
|
1190 |
\
|
|
1191 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
1192 |
BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
|
|
1193 |
DST, pDst, dstBase, pDstInfo, DstWrite, \
|
|
1194 |
width, height, \
|
|
1195 |
XorVia1IntArgb(pSrc, SRC, SrcRead, \
|
|
1196 |
pDst, DST, DSTANYTYPE, \
|
|
1197 |
0, xorpixel, xor, \
|
|
1198 |
alphamask, mask, pDstInfo)); \
|
|
1199 |
}
|
|
1200 |
|
|
1201 |
/*
|
|
1202 |
* This macro defines an entire function to implement a FillRect inner loop
|
|
1203 |
* for setting a rectangular region of pixels to a specific pixel value.
|
|
1204 |
* No blending of the fill color is done with the pixels.
|
|
1205 |
*/
|
|
1206 |
#define DEFINE_SOLID_FILLRECT(DST) \
|
|
1207 |
void NAME_SOLID_FILLRECT(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1208 |
jint lox, jint loy, \
|
|
1209 |
jint hix, jint hiy, \
|
|
1210 |
jint pixel, \
|
|
1211 |
NativePrimitive *pPrim, \
|
|
1212 |
CompositeInfo *pCompInfo) \
|
|
1213 |
{ \
|
|
1214 |
Declare ## DST ## PixelData(pix) \
|
|
1215 |
DST ## DataType *pPix; \
|
|
1216 |
jint scan = pRasInfo->scanStride; \
|
|
1217 |
juint height = hiy - loy; \
|
|
1218 |
juint width = hix - lox; \
|
|
1219 |
\
|
|
1220 |
pPix = PtrCoord(pRasInfo->rasBase, lox, DST ## PixelStride, loy, scan); \
|
|
1221 |
Extract ## DST ## PixelData(pixel, pix); \
|
|
1222 |
do { \
|
|
1223 |
juint x = 0; \
|
|
1224 |
do { \
|
|
1225 |
Store ## DST ## PixelData(pPix, x, pixel, pix); \
|
|
1226 |
} while (++x < width); \
|
|
1227 |
pPix = PtrAddBytes(pPix, scan); \
|
|
1228 |
} while (--height > 0); \
|
|
1229 |
}
|
|
1230 |
|
|
1231 |
/*
|
|
1232 |
* This macro defines an entire function to implement a FillSpans inner loop
|
|
1233 |
* for iterating through a list of spans and setting those regions of pixels
|
|
1234 |
* to a specific pixel value. No blending of the fill color is done with
|
|
1235 |
* the pixels.
|
|
1236 |
*/
|
|
1237 |
#define DEFINE_SOLID_FILLSPANS(DST) \
|
|
1238 |
void NAME_SOLID_FILLSPANS(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1239 |
SpanIteratorFuncs *pSpanFuncs, void *siData, \
|
|
1240 |
jint pixel, NativePrimitive *pPrim, \
|
|
1241 |
CompositeInfo *pCompInfo) \
|
|
1242 |
{ \
|
|
1243 |
void *pBase = pRasInfo->rasBase; \
|
|
1244 |
Declare ## DST ## PixelData(pix) \
|
|
1245 |
jint scan = pRasInfo->scanStride; \
|
|
1246 |
jint bbox[4]; \
|
|
1247 |
\
|
|
1248 |
Extract ## DST ## PixelData(pixel, pix); \
|
|
1249 |
while ((*pSpanFuncs->nextSpan)(siData, bbox)) { \
|
|
1250 |
jint x = bbox[0]; \
|
|
1251 |
jint y = bbox[1]; \
|
|
1252 |
juint w = bbox[2] - x; \
|
|
1253 |
juint h = bbox[3] - y; \
|
|
1254 |
DST ## DataType *pPix = PtrCoord(pBase, \
|
|
1255 |
x, DST ## PixelStride, \
|
|
1256 |
y, scan); \
|
|
1257 |
do { \
|
|
1258 |
juint relx; \
|
|
1259 |
for (relx = 0; relx < w; relx++) { \
|
|
1260 |
Store ## DST ## PixelData(pPix, relx, pixel, pix); \
|
|
1261 |
} \
|
|
1262 |
pPix = PtrAddBytes(pPix, scan); \
|
|
1263 |
} while (--h > 0); \
|
|
1264 |
} \
|
|
1265 |
}
|
|
1266 |
|
|
1267 |
/*
|
|
1268 |
* This macro declares the bumpmajor and bumpminor variables used for the
|
|
1269 |
* DrawLine functions.
|
|
1270 |
*/
|
|
1271 |
#define DeclareBumps(BUMPMAJOR, BUMPMINOR) \
|
|
1272 |
jint BUMPMAJOR, BUMPMINOR;
|
|
1273 |
|
|
1274 |
/*
|
|
1275 |
* This macro extracts "instructions" from the bumpmajor and bumpminor masks
|
|
1276 |
* that determine the initial bumpmajor and bumpminor values. The bumpmajor
|
|
1277 |
* and bumpminor masks are laid out in the following format:
|
|
1278 |
*
|
|
1279 |
* bumpmajormask: bumpminormask:
|
|
1280 |
* bit0: bumpmajor = pixelStride bit0: bumpminor = pixelStride
|
|
1281 |
* bit1: bumpmajor = -pixelStride bit1: bumpminor = -pixelStride
|
|
1282 |
* bit2: bumpmajor = scanStride bit2: bumpminor = scanStride
|
|
1283 |
* bit3: bumpmajor = -scanStride bit3: bumpminor = -scanStride
|
|
1284 |
*/
|
|
1285 |
#define InitBumps(BUMPMAJOR, BUMPMINOR, \
|
|
1286 |
BUMPMAJORMASK, BUMPMINORMASK, \
|
|
1287 |
PIXELSTRIDE, SCANSTRIDE) \
|
|
1288 |
BUMPMAJOR = (BUMPMAJORMASK & BUMP_POS_PIXEL) ? PIXELSTRIDE : \
|
|
1289 |
(BUMPMAJORMASK & BUMP_NEG_PIXEL) ? -PIXELSTRIDE : \
|
|
1290 |
(BUMPMAJORMASK & BUMP_POS_SCAN) ? SCANSTRIDE : \
|
|
1291 |
-SCANSTRIDE; \
|
|
1292 |
BUMPMINOR = (BUMPMINORMASK & BUMP_POS_PIXEL) ? PIXELSTRIDE : \
|
|
1293 |
(BUMPMINORMASK & BUMP_NEG_PIXEL) ? -PIXELSTRIDE : \
|
|
1294 |
(BUMPMINORMASK & BUMP_POS_SCAN) ? SCANSTRIDE : \
|
|
1295 |
(BUMPMINORMASK & BUMP_NEG_SCAN) ? -SCANSTRIDE : \
|
|
1296 |
0; \
|
|
1297 |
BUMPMINOR += BUMPMAJOR;
|
|
1298 |
|
|
1299 |
/*
|
|
1300 |
* This macro defines an entire function to implement a DrawLine inner loop
|
|
1301 |
* for iterating along a horizontal or vertical line and setting the pixels
|
|
1302 |
* on that line to a specific pixel value. No blending of the fill color
|
|
1303 |
* is done with the pixels.
|
|
1304 |
*/
|
|
1305 |
#define DEFINE_SOLID_DRAWLINE(DST) \
|
|
1306 |
void NAME_SOLID_DRAWLINE(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1307 |
jint x1, jint y1, jint pixel, \
|
|
1308 |
jint steps, jint error, \
|
|
1309 |
jint bumpmajormask, jint errmajor, \
|
|
1310 |
jint bumpminormask, jint errminor, \
|
|
1311 |
NativePrimitive *pPrim, \
|
|
1312 |
CompositeInfo *pCompInfo) \
|
|
1313 |
{ \
|
|
1314 |
Declare ## DST ## PixelData(pix) \
|
|
1315 |
jint scan = pRasInfo->scanStride; \
|
|
1316 |
DST ## DataType *pPix = PtrCoord(pRasInfo->rasBase, \
|
|
1317 |
x1, DST ## PixelStride, \
|
|
1318 |
y1, scan); \
|
|
1319 |
DeclareBumps(bumpmajor, bumpminor) \
|
|
1320 |
\
|
|
1321 |
InitBumps(bumpmajor, bumpminor, bumpmajormask, bumpminormask, \
|
|
1322 |
DST ## PixelStride, scan); \
|
|
1323 |
Extract ## DST ## PixelData(pixel, pix); \
|
|
1324 |
if (errmajor == 0) { \
|
|
1325 |
do { \
|
|
1326 |
Store ## DST ## PixelData(pPix, 0, pixel, pix); \
|
|
1327 |
pPix = PtrAddBytes(pPix, bumpmajor); \
|
|
1328 |
} while (--steps > 0); \
|
|
1329 |
} else { \
|
|
1330 |
do { \
|
|
1331 |
Store ## DST ## PixelData(pPix, 0, pixel, pix); \
|
|
1332 |
if (error < 0) { \
|
|
1333 |
pPix = PtrAddBytes(pPix, bumpmajor); \
|
|
1334 |
error += errmajor; \
|
|
1335 |
} else { \
|
|
1336 |
pPix = PtrAddBytes(pPix, bumpminor); \
|
|
1337 |
error -= errminor; \
|
|
1338 |
} \
|
|
1339 |
} while (--steps > 0); \
|
|
1340 |
} \
|
|
1341 |
}
|
|
1342 |
|
|
1343 |
/*
|
|
1344 |
* This macro defines an entire function to implement a FillRect inner loop
|
|
1345 |
* for setting a rectangular region of pixels to a specific pixel value.
|
|
1346 |
* Each destination pixel is XORed with the current XOR mode color as well as
|
|
1347 |
* the current fill color.
|
|
1348 |
*/
|
|
1349 |
#define DEFINE_XOR_FILLRECT(DST) \
|
|
1350 |
void NAME_XOR_FILLRECT(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1351 |
jint lox, jint loy, \
|
|
1352 |
jint hix, jint hiy, \
|
|
1353 |
jint pixel, \
|
|
1354 |
NativePrimitive *pPrim, \
|
|
1355 |
CompositeInfo *pCompInfo) \
|
|
1356 |
{ \
|
|
1357 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
1358 |
juint alphamask = pCompInfo->alphaMask; \
|
|
1359 |
Declare ## DST ## PixelData(xor) \
|
|
1360 |
Declare ## DST ## PixelData(pix) \
|
|
1361 |
Declare ## DST ## PixelData(mask) \
|
|
1362 |
DST ## DataType *pPix; \
|
|
1363 |
jint scan = pRasInfo->scanStride; \
|
|
1364 |
juint height = hiy - loy; \
|
|
1365 |
juint width = hix - lox; \
|
|
1366 |
\
|
|
1367 |
pPix = PtrCoord(pRasInfo->rasBase, lox, DST ## PixelStride, loy, scan); \
|
|
1368 |
Extract ## DST ## PixelData(xorpixel, xor); \
|
|
1369 |
Extract ## DST ## PixelData(pixel, pix); \
|
|
1370 |
Extract ## DST ## PixelData(alphamask, mask); \
|
|
1371 |
\
|
|
1372 |
do { \
|
|
1373 |
juint x = 0; \
|
|
1374 |
do { \
|
|
1375 |
Xor ## DST ## PixelData(pixel, pix, pPix, x, \
|
|
1376 |
xorpixel, xor, alphamask, mask); \
|
|
1377 |
} while (++x < width); \
|
|
1378 |
pPix = PtrAddBytes(pPix, scan); \
|
|
1379 |
} while (--height > 0); \
|
|
1380 |
}
|
|
1381 |
|
|
1382 |
/*
|
|
1383 |
* This macro defines an entire function to implement a FillSpans inner loop
|
|
1384 |
* for iterating through a list of spans and setting those regions of pixels
|
|
1385 |
* to a specific pixel value. Each destination pixel is XORed with the
|
|
1386 |
* current XOR mode color as well as the current fill color.
|
|
1387 |
*/
|
|
1388 |
#define DEFINE_XOR_FILLSPANS(DST) \
|
|
1389 |
void NAME_XOR_FILLSPANS(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1390 |
SpanIteratorFuncs *pSpanFuncs, \
|
|
1391 |
void *siData, jint pixel, \
|
|
1392 |
NativePrimitive *pPrim, \
|
|
1393 |
CompositeInfo *pCompInfo) \
|
|
1394 |
{ \
|
|
1395 |
void *pBase = pRasInfo->rasBase; \
|
|
1396 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
1397 |
juint alphamask = pCompInfo->alphaMask; \
|
|
1398 |
Declare ## DST ## PixelData(xor) \
|
|
1399 |
Declare ## DST ## PixelData(pix) \
|
|
1400 |
Declare ## DST ## PixelData(mask) \
|
|
1401 |
jint scan = pRasInfo->scanStride; \
|
|
1402 |
jint bbox[4]; \
|
|
1403 |
\
|
|
1404 |
Extract ## DST ## PixelData(xorpixel, xor); \
|
|
1405 |
Extract ## DST ## PixelData(pixel, pix); \
|
|
1406 |
Extract ## DST ## PixelData(alphamask, mask); \
|
|
1407 |
\
|
|
1408 |
while ((*pSpanFuncs->nextSpan)(siData, bbox)) { \
|
|
1409 |
jint x = bbox[0]; \
|
|
1410 |
jint y = bbox[1]; \
|
|
1411 |
juint w = bbox[2] - x; \
|
|
1412 |
juint h = bbox[3] - y; \
|
|
1413 |
DST ## DataType *pPix = PtrCoord(pBase, \
|
|
1414 |
x, DST ## PixelStride, \
|
|
1415 |
y, scan); \
|
|
1416 |
do { \
|
|
1417 |
juint relx; \
|
|
1418 |
for (relx = 0; relx < w; relx++) { \
|
|
1419 |
Xor ## DST ## PixelData(pixel, pix, pPix, relx, \
|
|
1420 |
xorpixel, xor, alphamask, mask); \
|
|
1421 |
} \
|
|
1422 |
pPix = PtrAddBytes(pPix, scan); \
|
|
1423 |
} while (--h > 0); \
|
|
1424 |
} \
|
|
1425 |
}
|
|
1426 |
|
|
1427 |
/*
|
|
1428 |
* This macro defines an entire function to implement a DrawLine inner loop
|
|
1429 |
* for iterating along a horizontal or vertical line and setting the pixels
|
|
1430 |
* on that line to a specific pixel value. Each destination pixel is XORed
|
|
1431 |
* with the current XOR mode color as well as the current draw color.
|
|
1432 |
*/
|
|
1433 |
#define DEFINE_XOR_DRAWLINE(DST) \
|
|
1434 |
void NAME_XOR_DRAWLINE(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1435 |
jint x1, jint y1, jint pixel, \
|
|
1436 |
jint steps, jint error, \
|
|
1437 |
jint bumpmajormask, jint errmajor, \
|
|
1438 |
jint bumpminormask, jint errminor, \
|
|
1439 |
NativePrimitive *pPrim, \
|
|
1440 |
CompositeInfo *pCompInfo) \
|
|
1441 |
{ \
|
|
1442 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
1443 |
juint alphamask = pCompInfo->alphaMask; \
|
|
1444 |
Declare ## DST ## PixelData(xor) \
|
|
1445 |
Declare ## DST ## PixelData(pix) \
|
|
1446 |
Declare ## DST ## PixelData(mask) \
|
|
1447 |
jint scan = pRasInfo->scanStride; \
|
|
1448 |
DST ## DataType *pPix = PtrCoord(pRasInfo->rasBase, \
|
|
1449 |
x1, DST ## PixelStride, \
|
|
1450 |
y1, scan); \
|
|
1451 |
DeclareBumps(bumpmajor, bumpminor) \
|
|
1452 |
\
|
|
1453 |
InitBumps(bumpmajor, bumpminor, bumpmajormask, bumpminormask, \
|
|
1454 |
DST ## PixelStride, scan); \
|
|
1455 |
Extract ## DST ## PixelData(xorpixel, xor); \
|
|
1456 |
Extract ## DST ## PixelData(pixel, pix); \
|
|
1457 |
Extract ## DST ## PixelData(alphamask, mask); \
|
|
1458 |
\
|
|
1459 |
if (errmajor == 0) { \
|
|
1460 |
do { \
|
|
1461 |
Xor ## DST ## PixelData(pixel, pix, pPix, 0, \
|
|
1462 |
xorpixel, xor, alphamask, mask); \
|
|
1463 |
pPix = PtrAddBytes(pPix, bumpmajor); \
|
|
1464 |
} while (--steps > 0); \
|
|
1465 |
} else { \
|
|
1466 |
do { \
|
|
1467 |
Xor ## DST ## PixelData(pixel, pix, pPix, 0, \
|
|
1468 |
xorpixel, xor, alphamask, mask); \
|
|
1469 |
if (error < 0) { \
|
|
1470 |
pPix = PtrAddBytes(pPix, bumpmajor); \
|
|
1471 |
error += errmajor; \
|
|
1472 |
} else { \
|
|
1473 |
pPix = PtrAddBytes(pPix, bumpminor); \
|
|
1474 |
error -= errminor; \
|
|
1475 |
} \
|
|
1476 |
} while (--steps > 0); \
|
|
1477 |
} \
|
|
1478 |
}
|
|
1479 |
|
|
1480 |
/*
|
|
1481 |
* This macro is used to declare the variables needed by the glyph clipping
|
|
1482 |
* macro.
|
|
1483 |
*/
|
|
1484 |
#define DeclareDrawGlyphListClipVars(PIXELS, ROWBYTES, WIDTH, HEIGHT, \
|
|
1485 |
LEFT, TOP, RIGHT, BOTTOM) \
|
|
1486 |
const jubyte * PIXELS; \
|
|
1487 |
int ROWBYTES; \
|
|
1488 |
int LEFT, TOP; \
|
|
1489 |
int WIDTH, HEIGHT; \
|
|
1490 |
int RIGHT, BOTTOM;
|
|
1491 |
|
|
1492 |
/*
|
|
1493 |
* This macro represents the glyph clipping code used in the various
|
|
1494 |
* DRAWGLYPHLIST macros. This macro is typically used within a loop. Note
|
|
1495 |
* that the body of this macro is NOT wrapped in a do..while block due to
|
|
1496 |
* the use of continue statements within the block (those continue statements
|
|
1497 |
* are intended skip the outer loop, not the do..while loop). To combat this
|
|
1498 |
* problem, pass in the code (typically a continue statement) that should be
|
|
1499 |
* executed when a null glyph is encountered.
|
|
1500 |
*/
|
|
1501 |
#define ClipDrawGlyphList(DST, PIXELS, BYTESPERPIXEL, ROWBYTES, WIDTH, HEIGHT,\
|
|
1502 |
LEFT, TOP, RIGHT, BOTTOM, \
|
|
1503 |
CLIPLEFT, CLIPTOP, CLIPRIGHT, CLIPBOTTOM, \
|
|
1504 |
GLYPHS, GLYPHCOUNTER, NULLGLYPHCODE) \
|
|
1505 |
PIXELS = (const jubyte *)GLYPHS[GLYPHCOUNTER].pixels; \
|
|
1506 |
if (!PIXELS) { \
|
|
1507 |
NULLGLYPHCODE; \
|
|
1508 |
} \
|
|
1509 |
ROWBYTES = GLYPHS[GLYPHCOUNTER].rowBytes; \
|
|
1510 |
LEFT = GLYPHS[GLYPHCOUNTER].x; \
|
|
1511 |
TOP = GLYPHS[GLYPHCOUNTER].y; \
|
|
1512 |
WIDTH = GLYPHS[GLYPHCOUNTER].width; \
|
|
1513 |
HEIGHT = GLYPHS[GLYPHCOUNTER].height; \
|
|
1514 |
\
|
|
1515 |
/* if any clipping required, modify parameters now */ \
|
|
1516 |
RIGHT = LEFT + WIDTH; \
|
|
1517 |
BOTTOM = TOP + HEIGHT; \
|
|
1518 |
if (LEFT < CLIPLEFT) { \
|
|
1519 |
/* Multiply needed for LCD text as PIXELS is really BYTES */ \
|
|
1520 |
PIXELS += (CLIPLEFT - LEFT) * BYTESPERPIXEL ; \
|
|
1521 |
LEFT = CLIPLEFT; \
|
|
1522 |
} \
|
|
1523 |
if (TOP < CLIPTOP) { \
|
|
1524 |
PIXELS += (CLIPTOP - TOP) * ROWBYTES; \
|
|
1525 |
TOP = CLIPTOP; \
|
|
1526 |
} \
|
|
1527 |
if (RIGHT > CLIPRIGHT) { \
|
|
1528 |
RIGHT = CLIPRIGHT; \
|
|
1529 |
} \
|
|
1530 |
if (BOTTOM > CLIPBOTTOM) { \
|
|
1531 |
BOTTOM = CLIPBOTTOM; \
|
|
1532 |
} \
|
|
1533 |
if (RIGHT <= LEFT || BOTTOM <= TOP) { \
|
|
1534 |
NULLGLYPHCODE; \
|
|
1535 |
} \
|
|
1536 |
WIDTH = RIGHT - LEFT; \
|
|
1537 |
HEIGHT = BOTTOM - TOP;
|
|
1538 |
|
|
1539 |
#define DEFINE_SOLID_DRAWGLYPHLIST(DST) \
|
|
1540 |
void NAME_SOLID_DRAWGLYPHLIST(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1541 |
ImageRef *glyphs, \
|
|
1542 |
jint totalGlyphs, jint fgpixel, \
|
|
1543 |
jint argbcolor, \
|
|
1544 |
jint clipLeft, jint clipTop, \
|
|
1545 |
jint clipRight, jint clipBottom, \
|
|
1546 |
NativePrimitive *pPrim, \
|
|
1547 |
CompositeInfo *pCompInfo) \
|
|
1548 |
{ \
|
|
1549 |
jint glyphCounter; \
|
|
1550 |
jint scan = pRasInfo->scanStride; \
|
|
1551 |
Declare ## DST ## PixelData(pix) \
|
|
1552 |
DST ## DataType *pPix; \
|
|
1553 |
\
|
|
1554 |
Extract ## DST ## PixelData(fgpixel, pix); \
|
|
1555 |
for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
|
|
1556 |
DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
|
|
1557 |
left, top, right, bottom) \
|
|
1558 |
ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
|
|
1559 |
left, top, right, bottom, \
|
|
1560 |
clipLeft, clipTop, clipRight, clipBottom, \
|
|
1561 |
glyphs, glyphCounter, continue) \
|
|
1562 |
pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
|
|
1563 |
\
|
|
1564 |
do { \
|
|
1565 |
int x = 0; \
|
|
1566 |
do { \
|
|
1567 |
if (pixels[x]) { \
|
|
1568 |
Store ## DST ## PixelData(pPix, x, fgpixel, pix); \
|
|
1569 |
} \
|
|
1570 |
} while (++x < width); \
|
|
1571 |
pPix = PtrAddBytes(pPix, scan); \
|
|
1572 |
pixels += rowBytes; \
|
|
1573 |
} while (--height > 0); \
|
|
1574 |
} \
|
|
1575 |
}
|
|
1576 |
|
|
1577 |
#define GlyphListAABlend3ByteRgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
|
|
1578 |
FG_PIXEL, PREFIX, SRC_PREFIX) \
|
|
1579 |
do { \
|
|
1580 |
DeclareCompVarsFor3ByteRgb(dst) \
|
|
1581 |
jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
|
|
1582 |
if (mixValSrc) { \
|
|
1583 |
if (mixValSrc < 255) { \
|
|
1584 |
jint mixValDst = 255 - mixValSrc; \
|
|
1585 |
Load ## DST ## To3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
|
|
1586 |
dstR, dstG, dstB); \
|
|
1587 |
MultMultAddAndStore3ByteRgbComps(dst, mixValDst, dst, \
|
|
1588 |
mixValSrc, SRC_PREFIX); \
|
|
1589 |
Store ## DST ## From3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
|
|
1590 |
dstR, dstG, dstB); \
|
|
1591 |
} else { \
|
|
1592 |
Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
|
|
1593 |
FG_PIXEL, PREFIX); \
|
|
1594 |
} \
|
|
1595 |
} \
|
|
1596 |
} while (0);
|
|
1597 |
|
|
1598 |
#define GlyphListAABlend4ByteArgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
|
|
1599 |
FG_PIXEL, PREFIX, SRC_PREFIX) \
|
|
1600 |
do { \
|
|
1601 |
DeclareAlphaVarFor4ByteArgb(dstA) \
|
|
1602 |
DeclareCompVarsFor4ByteArgb(dst) \
|
|
1603 |
jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
|
|
1604 |
if (mixValSrc) { \
|
|
1605 |
if (mixValSrc < 255) { \
|
|
1606 |
jint mixValDst = 255 - mixValSrc; \
|
|
1607 |
Load ## DST ## To4ByteArgb(DST_PTR, pix, PIXEL_INDEX, \
|
|
1608 |
dstA, dstR, dstG, dstB); \
|
|
1609 |
dstA = MUL8(dstA, mixValDst) + \
|
|
1610 |
MUL8(SRC_PREFIX ## A, mixValSrc); \
|
|
1611 |
MultMultAddAndStore4ByteArgbComps(dst, mixValDst, dst, \
|
|
1612 |
mixValSrc, SRC_PREFIX); \
|
549
|
1613 |
if (!(DST ## IsOpaque) && \
|
|
1614 |
!(DST ## IsPremultiplied) && dstA && dstA < 255) { \
|
|
1615 |
DivideAndStore4ByteArgbComps(dst, dst, dstA); \
|
|
1616 |
} \
|
|
1617 |
Store ## DST ## From4ByteArgbComps(DST_PTR, pix, \
|
|
1618 |
PIXEL_INDEX, dst); \
|
2
|
1619 |
} else { \
|
|
1620 |
Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
|
|
1621 |
FG_PIXEL, PREFIX); \
|
|
1622 |
} \
|
|
1623 |
} \
|
|
1624 |
} while (0);
|
|
1625 |
|
|
1626 |
#define GlyphListAABlend1ByteGray(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
|
|
1627 |
FG_PIXEL, PREFIX, SRC_PREFIX) \
|
|
1628 |
do { \
|
|
1629 |
DeclareCompVarsFor1ByteGray(dst) \
|
|
1630 |
jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
|
|
1631 |
if (mixValSrc) { \
|
|
1632 |
if (mixValSrc < 255) { \
|
|
1633 |
jint mixValDst = 255 - mixValSrc; \
|
|
1634 |
Load ## DST ## To1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
|
|
1635 |
dstG); \
|
|
1636 |
MultMultAddAndStore1ByteGrayComps(dst, mixValDst, dst, \
|
|
1637 |
mixValSrc, SRC_PREFIX); \
|
|
1638 |
Store ## DST ## From1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
|
|
1639 |
dstG); \
|
|
1640 |
} else { \
|
|
1641 |
Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
|
|
1642 |
FG_PIXEL, PREFIX); \
|
|
1643 |
} \
|
|
1644 |
} \
|
|
1645 |
} while (0);
|
|
1646 |
|
|
1647 |
#define GlyphListAABlend1ShortGray(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
|
|
1648 |
FG_PIXEL, PREFIX, SRC_PREFIX) \
|
|
1649 |
do { \
|
|
1650 |
DeclareCompVarsFor1ShortGray(dst) \
|
|
1651 |
juint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
|
|
1652 |
if (mixValSrc) { \
|
|
1653 |
if (mixValSrc < 255) { \
|
|
1654 |
juint mixValDst; \
|
|
1655 |
PromoteByteAlphaFor1ShortGray(mixValSrc); \
|
|
1656 |
mixValDst = 0xffff - mixValSrc; \
|
|
1657 |
Load ## DST ## To1ShortGray(DST_PTR, pix, PIXEL_INDEX, \
|
|
1658 |
dstG); \
|
|
1659 |
MultMultAddAndStore1ShortGrayComps(dst, mixValDst, dst, \
|
|
1660 |
mixValSrc, SRC_PREFIX); \
|
|
1661 |
Store ## DST ## From1ShortGray(DST_PTR, pix, PIXEL_INDEX, \
|
|
1662 |
dstG); \
|
|
1663 |
} else { \
|
|
1664 |
Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
|
|
1665 |
FG_PIXEL, PREFIX); \
|
|
1666 |
} \
|
|
1667 |
} \
|
|
1668 |
} while (0);
|
|
1669 |
|
|
1670 |
#define DEFINE_SOLID_DRAWGLYPHLISTAA(DST, STRATEGY) \
|
|
1671 |
void NAME_SOLID_DRAWGLYPHLISTAA(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1672 |
ImageRef *glyphs, \
|
|
1673 |
jint totalGlyphs, jint fgpixel, \
|
|
1674 |
jint argbcolor, \
|
|
1675 |
jint clipLeft, jint clipTop, \
|
|
1676 |
jint clipRight, jint clipBottom, \
|
|
1677 |
NativePrimitive *pPrim, \
|
|
1678 |
CompositeInfo *pCompInfo) \
|
|
1679 |
{ \
|
|
1680 |
jint glyphCounter; \
|
|
1681 |
jint scan = pRasInfo->scanStride; \
|
|
1682 |
DST ## DataType *pPix; \
|
|
1683 |
Declare ## DST ## PixelData(solidpix) \
|
|
1684 |
DeclareAlphaVarFor ## STRATEGY(srcA) \
|
|
1685 |
DeclareCompVarsFor ## STRATEGY(src) \
|
|
1686 |
\
|
|
1687 |
Declare ## DST ## LoadVars(pix) \
|
|
1688 |
Declare ## DST ## StoreVars(pix) \
|
|
1689 |
\
|
|
1690 |
Init ## DST ## LoadVars(pix, pRasInfo); \
|
|
1691 |
Init ## DST ## StoreVarsY(pix, pRasInfo); \
|
|
1692 |
Init ## DST ## StoreVarsX(pix, pRasInfo); \
|
|
1693 |
Extract ## STRATEGY ## CompsAndAlphaFromArgb(argbcolor, src); \
|
|
1694 |
Extract ## DST ## PixelData(fgpixel, solidpix); \
|
|
1695 |
\
|
|
1696 |
for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
|
|
1697 |
DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
|
|
1698 |
left, top, right, bottom) \
|
|
1699 |
ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
|
|
1700 |
left, top, right, bottom, \
|
|
1701 |
clipLeft, clipTop, clipRight, clipBottom, \
|
|
1702 |
glyphs, glyphCounter, continue) \
|
|
1703 |
pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
|
|
1704 |
\
|
|
1705 |
Set ## DST ## StoreVarsYPos(pix, pRasInfo, top); \
|
|
1706 |
do { \
|
|
1707 |
int x = 0; \
|
|
1708 |
Set ## DST ## StoreVarsXPos(pix, pRasInfo, left); \
|
|
1709 |
do { \
|
|
1710 |
GlyphListAABlend ## STRATEGY(DST, pixels, x, pPix, \
|
|
1711 |
fgpixel, solidpix, src); \
|
|
1712 |
Next ## DST ## StoreVarsX(pix); \
|
|
1713 |
} while (++x < width); \
|
|
1714 |
pPix = PtrAddBytes(pPix, scan); \
|
|
1715 |
pixels += rowBytes; \
|
|
1716 |
Next ## DST ## StoreVarsY(pix); \
|
|
1717 |
} while (--height > 0); \
|
|
1718 |
} \
|
|
1719 |
}
|
|
1720 |
|
|
1721 |
|
|
1722 |
#define GlyphListLCDBlend3ByteRgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
|
|
1723 |
FG_PIXEL, PREFIX, SRC_PREFIX) \
|
|
1724 |
do { \
|
|
1725 |
DeclareCompVarsFor3ByteRgb(dst) \
|
|
1726 |
jint mixValSrcG = GLYPH_PIXELS[PIXEL_INDEX*3+1]; \
|
|
1727 |
jint mixValSrcR, mixValSrcB; \
|
|
1728 |
if (rgbOrder) { \
|
|
1729 |
mixValSrcR = GLYPH_PIXELS[PIXEL_INDEX*3]; \
|
|
1730 |
mixValSrcB = GLYPH_PIXELS[PIXEL_INDEX*3+2]; \
|
|
1731 |
} else { \
|
|
1732 |
mixValSrcR = GLYPH_PIXELS[PIXEL_INDEX*3+2]; \
|
|
1733 |
mixValSrcB = GLYPH_PIXELS[PIXEL_INDEX*3]; \
|
|
1734 |
} \
|
|
1735 |
if ((mixValSrcR | mixValSrcG | mixValSrcB) != 0) { \
|
|
1736 |
if ((mixValSrcR & mixValSrcG & mixValSrcB) < 255) { \
|
|
1737 |
jint mixValDstR = 255 - mixValSrcR; \
|
|
1738 |
jint mixValDstG = 255 - mixValSrcG; \
|
|
1739 |
jint mixValDstB = 255 - mixValSrcB; \
|
|
1740 |
Load ## DST ## To3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
|
|
1741 |
dstR, dstG, dstB); \
|
|
1742 |
dstR = invGammaLut[dstR]; \
|
|
1743 |
dstG = invGammaLut[dstG]; \
|
|
1744 |
dstB = invGammaLut[dstB]; \
|
|
1745 |
MultMultAddAndStoreLCD3ByteRgbComps(dst, mixValDst, dst, \
|
|
1746 |
mixValSrc, SRC_PREFIX); \
|
|
1747 |
dstR = gammaLut[dstR]; \
|
|
1748 |
dstG = gammaLut[dstG]; \
|
|
1749 |
dstB = gammaLut[dstB]; \
|
|
1750 |
Store ## DST ## From3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
|
|
1751 |
dstR, dstG, dstB); \
|
|
1752 |
} else { \
|
|
1753 |
Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
|
|
1754 |
FG_PIXEL, PREFIX); \
|
|
1755 |
} \
|
|
1756 |
} \
|
|
1757 |
} while (0)
|
|
1758 |
|
|
1759 |
|
|
1760 |
/* There is no alpha channel in the glyph data with which to interpolate
|
|
1761 |
* between the src and dst alphas, but a reasonable approximation is to
|
|
1762 |
* sum the coverage alphas of the colour channels and divide by 3.
|
|
1763 |
* We can approximate division by 3 using mult and shift. See
|
|
1764 |
* sun/font/scalerMethods.c for a detailed explanation of why "21931"
|
|
1765 |
*/
|
|
1766 |
#define GlyphListLCDBlend4ByteArgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
|
|
1767 |
FG_PIXEL, PREFIX, SRC_PREFIX) \
|
|
1768 |
do { \
|
|
1769 |
DeclareAlphaVarFor4ByteArgb(dstA) \
|
|
1770 |
DeclareCompVarsFor4ByteArgb(dst) \
|
|
1771 |
jint mixValSrcG = GLYPH_PIXELS[PIXEL_INDEX*3+1]; \
|
|
1772 |
jint mixValSrcR, mixValSrcB; \
|
|
1773 |
if (rgbOrder) { \
|
|
1774 |
mixValSrcR = GLYPH_PIXELS[PIXEL_INDEX*3]; \
|
|
1775 |
mixValSrcB = GLYPH_PIXELS[PIXEL_INDEX*3+2]; \
|
|
1776 |
} else { \
|
|
1777 |
mixValSrcR = GLYPH_PIXELS[PIXEL_INDEX*3+2]; \
|
|
1778 |
mixValSrcB = GLYPH_PIXELS[PIXEL_INDEX*3]; \
|
|
1779 |
} \
|
|
1780 |
if ((mixValSrcR | mixValSrcG | mixValSrcB) != 0) { \
|
|
1781 |
if ((mixValSrcR & mixValSrcG & mixValSrcB) < 255) { \
|
|
1782 |
jint mixValDstR = 255 - mixValSrcR; \
|
|
1783 |
jint mixValDstG = 255 - mixValSrcG; \
|
|
1784 |
jint mixValDstB = 255 - mixValSrcB; \
|
|
1785 |
jint mixValSrcA = ((mixValSrcR + mixValSrcG + mixValSrcB) \
|
|
1786 |
* 21931) >> 16;\
|
|
1787 |
jint mixValDstA = 255 - mixValSrcA; \
|
|
1788 |
Load ## DST ## To4ByteArgb(DST_PTR, pix, PIXEL_INDEX, \
|
|
1789 |
dstA, dstR, dstG, dstB); \
|
|
1790 |
dstR = invGammaLut[dstR]; \
|
|
1791 |
dstG = invGammaLut[dstG]; \
|
|
1792 |
dstB = invGammaLut[dstB]; \
|
|
1793 |
dstA = MUL8(dstA, mixValDstA) + \
|
|
1794 |
MUL8(SRC_PREFIX ## A, mixValSrcA); \
|
|
1795 |
MultMultAddAndStoreLCD4ByteArgbComps(dst, mixValDst, dst, \
|
|
1796 |
mixValSrc, SRC_PREFIX); \
|
|
1797 |
dstR = gammaLut[dstR]; \
|
|
1798 |
dstG = gammaLut[dstG]; \
|
|
1799 |
dstB = gammaLut[dstB]; \
|
549
|
1800 |
if (!(DST ## IsOpaque) && \
|
|
1801 |
!(DST ## IsPremultiplied) && dstA && dstA < 255) { \
|
|
1802 |
DivideAndStore4ByteArgbComps(dst, dst, dstA); \
|
|
1803 |
} \
|
|
1804 |
Store ## DST ## From4ByteArgbComps(DST_PTR, pix, \
|
|
1805 |
PIXEL_INDEX, dst); \
|
2
|
1806 |
} else { \
|
|
1807 |
Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
|
|
1808 |
FG_PIXEL, PREFIX); \
|
|
1809 |
} \
|
|
1810 |
} \
|
|
1811 |
} while (0);
|
|
1812 |
|
|
1813 |
#define DEFINE_SOLID_DRAWGLYPHLISTLCD(DST, STRATEGY) \
|
|
1814 |
void NAME_SOLID_DRAWGLYPHLISTLCD(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1815 |
ImageRef *glyphs, \
|
|
1816 |
jint totalGlyphs, jint fgpixel, \
|
|
1817 |
jint argbcolor, \
|
|
1818 |
jint clipLeft, jint clipTop, \
|
|
1819 |
jint clipRight, jint clipBottom, \
|
|
1820 |
jint rgbOrder, \
|
|
1821 |
unsigned char *gammaLut, \
|
|
1822 |
unsigned char * invGammaLut, \
|
|
1823 |
NativePrimitive *pPrim, \
|
|
1824 |
CompositeInfo *pCompInfo) \
|
|
1825 |
{ \
|
|
1826 |
jint glyphCounter, bpp; \
|
|
1827 |
jint scan = pRasInfo->scanStride; \
|
|
1828 |
DST ## DataType *pPix; \
|
|
1829 |
Declare ## DST ## PixelData(solidpix) \
|
|
1830 |
DeclareAlphaVarFor ## STRATEGY(srcA) \
|
|
1831 |
DeclareCompVarsFor ## STRATEGY(src) \
|
|
1832 |
\
|
|
1833 |
Declare ## DST ## LoadVars(pix) \
|
|
1834 |
Declare ## DST ## StoreVars(pix) \
|
|
1835 |
\
|
|
1836 |
Init ## DST ## LoadVars(pix, pRasInfo); \
|
|
1837 |
Init ## DST ## StoreVarsY(pix, pRasInfo); \
|
|
1838 |
Init ## DST ## StoreVarsX(pix, pRasInfo); \
|
|
1839 |
Extract ## STRATEGY ## CompsAndAlphaFromArgb(argbcolor, src); \
|
|
1840 |
Extract ## DST ## PixelData(fgpixel, solidpix); \
|
|
1841 |
srcR = invGammaLut[srcR]; \
|
|
1842 |
srcG = invGammaLut[srcG]; \
|
|
1843 |
srcB = invGammaLut[srcB]; \
|
|
1844 |
\
|
|
1845 |
for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
|
|
1846 |
DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
|
|
1847 |
left, top, right, bottom) \
|
|
1848 |
bpp = \
|
|
1849 |
(glyphs[glyphCounter].rowBytes == glyphs[glyphCounter].width) ? 1 : 3;\
|
|
1850 |
ClipDrawGlyphList(DST, pixels, bpp, rowBytes, width, height, \
|
|
1851 |
left, top, right, bottom, \
|
|
1852 |
clipLeft, clipTop, clipRight, clipBottom, \
|
|
1853 |
glyphs, glyphCounter, continue) \
|
|
1854 |
pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
|
|
1855 |
\
|
|
1856 |
Set ## DST ## StoreVarsYPos(pix, pRasInfo, top); \
|
|
1857 |
if (bpp!=1) { \
|
|
1858 |
/* subpixel positioning adjustment */ \
|
|
1859 |
pixels += glyphs[glyphCounter].rowBytesOffset; \
|
|
1860 |
} \
|
|
1861 |
do { \
|
|
1862 |
int x = 0; \
|
|
1863 |
Set ## DST ## StoreVarsXPos(pix, pRasInfo, left); \
|
|
1864 |
if (bpp==1) { \
|
|
1865 |
do { \
|
|
1866 |
if (pixels[x]) { \
|
|
1867 |
Store ## DST ## PixelData(pPix, x, fgpixel, solidpix);\
|
|
1868 |
} \
|
|
1869 |
} while (++x < width); \
|
|
1870 |
} else { \
|
|
1871 |
do { \
|
|
1872 |
GlyphListLCDBlend ## STRATEGY(DST, pixels, x, pPix, \
|
|
1873 |
fgpixel, solidpix, src); \
|
|
1874 |
Next ## DST ## StoreVarsX(pix); \
|
|
1875 |
} while (++x < width); \
|
|
1876 |
} \
|
|
1877 |
pPix = PtrAddBytes(pPix, scan); \
|
|
1878 |
pixels += rowBytes; \
|
|
1879 |
Next ## DST ## StoreVarsY(pix); \
|
|
1880 |
} while (--height > 0); \
|
|
1881 |
} \
|
|
1882 |
}
|
|
1883 |
|
|
1884 |
#define DEFINE_XOR_DRAWGLYPHLIST(DST) \
|
|
1885 |
void NAME_XOR_DRAWGLYPHLIST(DST)(SurfaceDataRasInfo *pRasInfo, \
|
|
1886 |
ImageRef *glyphs, \
|
|
1887 |
jint totalGlyphs, jint fgpixel, \
|
|
1888 |
jint argbcolor, \
|
|
1889 |
jint clipLeft, jint clipTop, \
|
|
1890 |
jint clipRight, jint clipBottom, \
|
|
1891 |
NativePrimitive *pPrim, \
|
|
1892 |
CompositeInfo *pCompInfo) \
|
|
1893 |
{ \
|
|
1894 |
jint glyphCounter; \
|
|
1895 |
jint scan = pRasInfo->scanStride; \
|
|
1896 |
jint xorpixel = pCompInfo->details.xorPixel; \
|
|
1897 |
juint alphamask = pCompInfo->alphaMask; \
|
|
1898 |
Declare ## DST ## PixelData(xor) \
|
|
1899 |
Declare ## DST ## PixelData(pix) \
|
|
1900 |
Declare ## DST ## PixelData(mask) \
|
|
1901 |
DST ## DataType *pPix; \
|
|
1902 |
\
|
|
1903 |
Extract ## DST ## PixelData(xorpixel, xor); \
|
|
1904 |
Extract ## DST ## PixelData(fgpixel, pix); \
|
|
1905 |
Extract ## DST ## PixelData(alphamask, mask); \
|
|
1906 |
for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
|
|
1907 |
DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
|
|
1908 |
left, top, right, bottom) \
|
|
1909 |
ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
|
|
1910 |
left, top, right, bottom, \
|
|
1911 |
clipLeft, clipTop, clipRight, clipBottom, \
|
|
1912 |
glyphs, glyphCounter, continue) \
|
|
1913 |
pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
|
|
1914 |
\
|
|
1915 |
do { \
|
|
1916 |
int x = 0; \
|
|
1917 |
do { \
|
|
1918 |
if (pixels[x]) { \
|
|
1919 |
Xor ## DST ## PixelData(fgpixel, pix, pPix, x, \
|
|
1920 |
xorpixel, xor, alphamask, mask); \
|
|
1921 |
} \
|
|
1922 |
} while (++x < width); \
|
|
1923 |
pPix = PtrAddBytes(pPix, scan); \
|
|
1924 |
pixels += rowBytes; \
|
|
1925 |
} while (--height > 0); \
|
|
1926 |
} \
|
|
1927 |
}
|
|
1928 |
|
|
1929 |
#define DEFINE_TRANSFORMHELPER_NN(SRC) \
|
|
1930 |
void NAME_TRANSFORMHELPER_NN(SRC)(SurfaceDataRasInfo *pSrcInfo, \
|
|
1931 |
jint *pRGB, jint numpix, \
|
|
1932 |
jlong xlong, jlong dxlong, \
|
|
1933 |
jlong ylong, jlong dylong) \
|
|
1934 |
{ \
|
|
1935 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
1936 |
SRC ## DataType *pBase = pSrcInfo->rasBase; \
|
|
1937 |
jint scan = pSrcInfo->scanStride; \
|
|
1938 |
jint *pEnd = pRGB + numpix; \
|
|
1939 |
\
|
|
1940 |
xlong += IntToLong(pSrcInfo->bounds.x1); \
|
|
1941 |
ylong += IntToLong(pSrcInfo->bounds.y1); \
|
|
1942 |
\
|
|
1943 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
1944 |
while (pRGB < pEnd) { \
|
|
1945 |
SRC ## DataType *pRow = PtrAddBytes(pBase, WholeOfLong(ylong) * scan); \
|
|
1946 |
Copy ## SRC ## ToIntArgbPre(pRGB, 0, \
|
|
1947 |
SrcRead, pRow, WholeOfLong(xlong)); \
|
|
1948 |
pRGB++; \
|
|
1949 |
xlong += dxlong; \
|
|
1950 |
ylong += dylong; \
|
|
1951 |
} \
|
|
1952 |
}
|
|
1953 |
|
|
1954 |
#define DEFINE_TRANSFORMHELPER_BL(SRC) \
|
|
1955 |
void NAME_TRANSFORMHELPER_BL(SRC)(SurfaceDataRasInfo *pSrcInfo, \
|
|
1956 |
jint *pRGB, jint numpix, \
|
|
1957 |
jlong xlong, jlong dxlong, \
|
|
1958 |
jlong ylong, jlong dylong) \
|
|
1959 |
{ \
|
|
1960 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
1961 |
jint scan = pSrcInfo->scanStride; \
|
|
1962 |
jint cx, cy, cw, ch; \
|
|
1963 |
jint *pEnd = pRGB + numpix*4; \
|
|
1964 |
\
|
|
1965 |
cx = pSrcInfo->bounds.x1; \
|
|
1966 |
cw = pSrcInfo->bounds.x2-cx; \
|
|
1967 |
\
|
|
1968 |
cy = pSrcInfo->bounds.y1; \
|
|
1969 |
ch = pSrcInfo->bounds.y2-cy; \
|
|
1970 |
\
|
|
1971 |
xlong -= LongOneHalf; \
|
|
1972 |
ylong -= LongOneHalf; \
|
|
1973 |
\
|
|
1974 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
1975 |
while (pRGB < pEnd) { \
|
|
1976 |
jint xwhole = WholeOfLong(xlong); \
|
|
1977 |
jint ywhole = WholeOfLong(ylong); \
|
|
1978 |
jint xdelta, ydelta, isneg; \
|
|
1979 |
SRC ## DataType *pRow; \
|
|
1980 |
\
|
|
1981 |
xdelta = ((juint) (xwhole + 1 - cw)) >> 31; \
|
|
1982 |
isneg = xwhole >> 31; \
|
|
1983 |
xwhole -= isneg; \
|
|
1984 |
xdelta += isneg; \
|
|
1985 |
\
|
|
1986 |
ydelta = ((ywhole + 1 - ch) >> 31); \
|
|
1987 |
isneg = ywhole >> 31; \
|
|
1988 |
ywhole -= isneg; \
|
|
1989 |
ydelta -= isneg; \
|
|
1990 |
ydelta &= scan; \
|
|
1991 |
\
|
|
1992 |
xwhole += cx; \
|
|
1993 |
pRow = PtrAddBytes(pSrcInfo->rasBase, (ywhole + cy) * scan); \
|
|
1994 |
Copy ## SRC ## ToIntArgbPre(pRGB, 0, SrcRead, pRow, xwhole); \
|
|
1995 |
Copy ## SRC ## ToIntArgbPre(pRGB, 1, SrcRead, pRow, xwhole+xdelta); \
|
|
1996 |
pRow = PtrAddBytes(pRow, ydelta); \
|
|
1997 |
Copy ## SRC ## ToIntArgbPre(pRGB, 2, SrcRead, pRow, xwhole); \
|
|
1998 |
Copy ## SRC ## ToIntArgbPre(pRGB, 3, SrcRead, pRow, xwhole+xdelta); \
|
|
1999 |
\
|
|
2000 |
pRGB += 4; \
|
|
2001 |
xlong += dxlong; \
|
|
2002 |
ylong += dylong; \
|
|
2003 |
} \
|
|
2004 |
}
|
|
2005 |
|
|
2006 |
#define DEFINE_TRANSFORMHELPER_BC(SRC) \
|
|
2007 |
void NAME_TRANSFORMHELPER_BC(SRC)(SurfaceDataRasInfo *pSrcInfo, \
|
|
2008 |
jint *pRGB, jint numpix, \
|
|
2009 |
jlong xlong, jlong dxlong, \
|
|
2010 |
jlong ylong, jlong dylong) \
|
|
2011 |
{ \
|
|
2012 |
Declare ## SRC ## LoadVars(SrcRead) \
|
|
2013 |
jint scan = pSrcInfo->scanStride; \
|
|
2014 |
jint cx, cy, cw, ch; \
|
|
2015 |
jint *pEnd = pRGB + numpix*16; \
|
|
2016 |
\
|
|
2017 |
cx = pSrcInfo->bounds.x1; \
|
|
2018 |
cw = pSrcInfo->bounds.x2-cx; \
|
|
2019 |
\
|
|
2020 |
cy = pSrcInfo->bounds.y1; \
|
|
2021 |
ch = pSrcInfo->bounds.y2-cy; \
|
|
2022 |
\
|
|
2023 |
xlong -= LongOneHalf; \
|
|
2024 |
ylong -= LongOneHalf; \
|
|
2025 |
\
|
|
2026 |
Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
|
|
2027 |
while (pRGB < pEnd) { \
|
|
2028 |
jint xwhole = WholeOfLong(xlong); \
|
|
2029 |
jint ywhole = WholeOfLong(ylong); \
|
|
2030 |
jint xdelta0, xdelta1, xdelta2; \
|
|
2031 |
jint ydelta0, ydelta1, ydelta2; \
|
|
2032 |
jint isneg; \
|
|
2033 |
SRC ## DataType *pRow; \
|
|
2034 |
\
|
|
2035 |
xdelta0 = (-xwhole) >> 31; \
|
|
2036 |
xdelta1 = ((juint) (xwhole + 1 - cw)) >> 31; \
|
|
2037 |
xdelta2 = ((juint) (xwhole + 2 - cw)) >> 31; \
|
|
2038 |
isneg = xwhole >> 31; \
|
|
2039 |
xwhole -= isneg; \
|
|
2040 |
xdelta1 += isneg; \
|
|
2041 |
xdelta2 += xdelta1; \
|
|
2042 |
\
|
|
2043 |
ydelta0 = ((-ywhole) >> 31) & (-scan); \
|
|
2044 |
ydelta1 = ((ywhole + 1 - ch) >> 31) & scan; \
|
|
2045 |
ydelta2 = ((ywhole + 2 - ch) >> 31) & scan; \
|
|
2046 |
isneg = ywhole >> 31; \
|
|
2047 |
ywhole -= isneg; \
|
|
2048 |
ydelta1 += (isneg & -scan); \
|
|
2049 |
\
|
|
2050 |
xwhole += cx; \
|
|
2051 |
pRow = PtrAddBytes(pSrcInfo->rasBase, (ywhole + cy) * scan); \
|
|
2052 |
pRow = PtrAddBytes(pRow, ydelta0); \
|
|
2053 |
Copy ## SRC ## ToIntArgbPre(pRGB, 0, SrcRead, pRow, xwhole+xdelta0); \
|
|
2054 |
Copy ## SRC ## ToIntArgbPre(pRGB, 1, SrcRead, pRow, xwhole ); \
|
|
2055 |
Copy ## SRC ## ToIntArgbPre(pRGB, 2, SrcRead, pRow, xwhole+xdelta1); \
|
|
2056 |
Copy ## SRC ## ToIntArgbPre(pRGB, 3, SrcRead, pRow, xwhole+xdelta2); \
|
|
2057 |
pRow = PtrAddBytes(pRow, -ydelta0); \
|
|
2058 |
Copy ## SRC ## ToIntArgbPre(pRGB, 4, SrcRead, pRow, xwhole+xdelta0); \
|
|
2059 |
Copy ## SRC ## ToIntArgbPre(pRGB, 5, SrcRead, pRow, xwhole ); \
|
|
2060 |
Copy ## SRC ## ToIntArgbPre(pRGB, 6, SrcRead, pRow, xwhole+xdelta1); \
|
|
2061 |
Copy ## SRC ## ToIntArgbPre(pRGB, 7, SrcRead, pRow, xwhole+xdelta2); \
|
|
2062 |
pRow = PtrAddBytes(pRow, ydelta1); \
|
|
2063 |
Copy ## SRC ## ToIntArgbPre(pRGB, 8, SrcRead, pRow, xwhole+xdelta0); \
|
|
2064 |
Copy ## SRC ## ToIntArgbPre(pRGB, 9, SrcRead, pRow, xwhole ); \
|
|
2065 |
Copy ## SRC ## ToIntArgbPre(pRGB, 10, SrcRead, pRow, xwhole+xdelta1); \
|
|
2066 |
Copy ## SRC ## ToIntArgbPre(pRGB, 11, SrcRead, pRow, xwhole+xdelta2); \
|
|
2067 |
pRow = PtrAddBytes(pRow, ydelta2); \
|
|
2068 |
Copy ## SRC ## ToIntArgbPre(pRGB, 12, SrcRead, pRow, xwhole+xdelta0); \
|
|
2069 |
Copy ## SRC ## ToIntArgbPre(pRGB, 13, SrcRead, pRow, xwhole ); \
|
|
2070 |
Copy ## SRC ## ToIntArgbPre(pRGB, 14, SrcRead, pRow, xwhole+xdelta1); \
|
|
2071 |
Copy ## SRC ## ToIntArgbPre(pRGB, 15, SrcRead, pRow, xwhole+xdelta2); \
|
|
2072 |
\
|
|
2073 |
pRGB += 16; \
|
|
2074 |
xlong += dxlong; \
|
|
2075 |
ylong += dylong; \
|
|
2076 |
} \
|
|
2077 |
}
|
|
2078 |
|
|
2079 |
#define DEFINE_TRANSFORMHELPER_FUNCS(SRC) \
|
|
2080 |
TransformHelperFuncs NAME_TRANSFORMHELPER_FUNCS(SRC) = { \
|
|
2081 |
NAME_TRANSFORMHELPER_NN(SRC), \
|
|
2082 |
NAME_TRANSFORMHELPER_BL(SRC), \
|
|
2083 |
NAME_TRANSFORMHELPER_BC(SRC), \
|
|
2084 |
};
|
|
2085 |
|
|
2086 |
#define DEFINE_TRANSFORMHELPERS(SRC) \
|
|
2087 |
DEFINE_TRANSFORMHELPER_NN(SRC) \
|
|
2088 |
DEFINE_TRANSFORMHELPER_BL(SRC) \
|
|
2089 |
DEFINE_TRANSFORMHELPER_BC(SRC) \
|
|
2090 |
DEFINE_TRANSFORMHELPER_FUNCS(SRC)
|
|
2091 |
|
|
2092 |
/*
|
|
2093 |
* The macros defined above use the following macro definitions supplied
|
|
2094 |
* for the various surface types to manipulate pixels and pixel data.
|
|
2095 |
* The surface-specific macros are typically supplied by header files
|
|
2096 |
* named after the SurfaceType name (i.e. IntArgb.h, ByteGray.h, etc.).
|
|
2097 |
*
|
|
2098 |
* In the macro names in the following definitions, the string <stype>
|
|
2099 |
* is used as a place holder for the SurfaceType name (i.e. IntArgb).
|
|
2100 |
* The macros above access these type specific macros using the ANSI
|
|
2101 |
* CPP token concatenation operator "##".
|
|
2102 |
*
|
|
2103 |
* <stype>DataType A typedef for the type of the pointer
|
|
2104 |
* that is used to access the raster data
|
|
2105 |
* for the given surface type.
|
|
2106 |
* <stype>PixelStride Pixel stride for the surface type.
|
|
2107 |
*
|
|
2108 |
* Declare<stype>LoadVars Declare the variables needed to control
|
|
2109 |
* loading color information from an stype
|
|
2110 |
* raster (i.e. lookup tables).
|
|
2111 |
* Init<stype>LoadVars Init the lookup table variables.
|
|
2112 |
* Declare<stype>StoreVars Declare the storage variables needed to
|
|
2113 |
* control storing pixel data based on the
|
|
2114 |
* pixel coordinate (i.e. dithering variables).
|
|
2115 |
* Init<stype>StoreVarsY Init the dither variables for starting Y.
|
|
2116 |
* Next<stype>StoreVarsY Increment the dither variables for next Y.
|
|
2117 |
* Init<stype>StoreVarsX Init the dither variables for starting X.
|
|
2118 |
* Next<stype>StoreVarsX Increment the dither variables for next X.
|
|
2119 |
*
|
|
2120 |
* Load<stype>To1IntRgb Load a pixel and form an INT_RGB integer.
|
|
2121 |
* Store<stype>From1IntRgb Store a pixel from an INT_RGB integer.
|
|
2122 |
* Load<stype>To1IntArgb Load a pixel and form an INT_ARGB integer.
|
|
2123 |
* Store<stype>From1IntArgb Store a pixel from an INT_ARGB integer.
|
|
2124 |
* Load<stype>To3ByteRgb Load a pixel into R, G, and B components.
|
|
2125 |
* Store<stype>From3ByteRgb Store a pixel from R, G, and B components.
|
|
2126 |
* Load<stype>To4ByteArgb Load a pixel into A, R, G, and B components.
|
|
2127 |
* Store<stype>From4ByteArgb Store a pixel from A, R, G, and B components.
|
|
2128 |
* Load<stype>To1ByteGray Load a pixel and form a BYTE_GRAY byte.
|
|
2129 |
* Store<stype>From1ByteGray Store a pixel from a BYTE_GRAY byte.
|
|
2130 |
*
|
|
2131 |
* <stype>PixelType Typedef for a "single quantity pixel" (SQP)
|
|
2132 |
* that can hold the data for one stype pixel.
|
|
2133 |
* <stype>XparLutEntry An SQP that can be used to represent a
|
|
2134 |
* transparent pixel for stype.
|
|
2135 |
* Store<stype>NonXparFromArgb Store an SQP from an INT_ARGB integer in
|
|
2136 |
* such a way that it would not be confused
|
|
2137 |
* with the XparLutEntry value for stype.
|
|
2138 |
* <stype>IsXparLutEntry Test an SQP for the XparLutEntry value.
|
|
2139 |
* Store<stype>Pixel Store the pixel data from an SQP.
|
|
2140 |
* <stype>PixelFromArgb Converts an INT_ARGB value into the specific
|
|
2141 |
* pixel representation for the surface type.
|
|
2142 |
*
|
|
2143 |
* Declare<stype>PixelData Declare the pixel data variables (PDV) needed
|
|
2144 |
* to hold the elements of pixel data ready to
|
|
2145 |
* store into an stype raster (may be empty for
|
|
2146 |
* stypes whose SQP format is their data format).
|
|
2147 |
* Extract<stype>PixelData Extract an SQP value into the PDVs.
|
|
2148 |
* Store<stype>PixelData Store the PDVs into an stype raster.
|
|
2149 |
* XorCopy<stype>PixelData Xor the PDVs into an stype raster.
|
|
2150 |
*/
|
|
2151 |
#endif /* LoopMacros_h_Included */
|