Print this page
rev 54883 : JDK-8220154 Improve java2d rendering performance on macOS by using Metal framework
Split |
Close |
Expand all |
Collapse all |
--- old/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.c
+++ new/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.c
1 1 /*
2 2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Oracle designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Oracle in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 22 * or visit www.oracle.com if you need additional information or have any
23 23 * questions.
24 24 */
25 25
26 26 #include "jni_util.h"
27 27 #include "jlong.h"
28 28
29 29 #include "sun_java2d_loops_GraphicsPrimitiveMgr.h"
30 30
31 31 #include "Region.h"
32 32 #include "GraphicsPrimitiveMgr.h"
33 33 #include "AlphaMacros.h"
34 34
35 35 static char *InitName = "<init>";
36 36 static char *InitSig = ("(JLsun/java2d/loops/SurfaceType;"
37 37 "Lsun/java2d/loops/CompositeType;"
38 38 "Lsun/java2d/loops/SurfaceType;)V");
39 39
40 40 static char *RegisterName = "register";
41 41 static char *RegisterSig = "([Lsun/java2d/loops/GraphicsPrimitive;)V";
42 42
43 43 static jclass GraphicsPrimitiveMgr;
44 44 static jclass GraphicsPrimitive;
45 45
46 46 static jmethodID RegisterID;
47 47 static jfieldID pNativePrimID;
48 48 static jfieldID pixelID;
49 49 static jfieldID eargbID;
50 50 static jfieldID clipRegionID;
51 51 static jfieldID compositeID;
52 52 static jfieldID lcdTextContrastID;
53 53 static jfieldID xorPixelID;
54 54 static jfieldID xorColorID;
55 55 static jfieldID alphaMaskID;
56 56 static jfieldID ruleID;
57 57 static jfieldID extraAlphaID;
58 58
59 59 static jfieldID m00ID;
60 60 static jfieldID m01ID;
61 61 static jfieldID m02ID;
62 62 static jfieldID m10ID;
63 63 static jfieldID m11ID;
64 64 static jfieldID m12ID;
65 65
66 66 static jmethodID getRgbID;
67 67
↓ open down ↓ |
67 lines elided |
↑ open up ↑ |
68 68 static jboolean InitPrimTypes(JNIEnv *env);
69 69 static jboolean InitSurfaceTypes(JNIEnv *env, jclass SurfaceType);
70 70 static jboolean InitCompositeTypes(JNIEnv *env, jclass CompositeType);
71 71
72 72 JNIEXPORT jfieldID path2DTypesID;
73 73 JNIEXPORT jfieldID path2DNumTypesID;
74 74 JNIEXPORT jfieldID path2DWindingRuleID;
75 75 JNIEXPORT jfieldID path2DFloatCoordsID;
76 76 JNIEXPORT jfieldID sg2dStrokeHintID;
77 77 JNIEXPORT jint sunHints_INTVAL_STROKE_PURE;
78 +JNIEXPORT jint graphicsPrimitive_traceflags = 0;
78 79
79 80 /*
80 81 * Class: sun_java2d_loops_GraphicsPrimitiveMgr
81 82 * Method: initIDs
82 83 * Signature: (Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;Ljava/lang/Class;)V
83 84 */
84 85 JNIEXPORT void JNICALL
85 86 Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs
86 87 (JNIEnv *env, jclass GPMgr,
87 88 jclass GP, jclass ST, jclass CT,
88 89 jclass SG2D, jclass Color, jclass AT,
89 90 jclass XORComp, jclass AlphaComp,
90 91 jclass Path2D, jclass Path2DFloat,
91 92 jclass SHints)
92 93 {
93 94 jfieldID fid;
94 95 initAlphaTables();
95 96 GraphicsPrimitiveMgr = (*env)->NewGlobalRef(env, GPMgr);
96 97 GraphicsPrimitive = (*env)->NewGlobalRef(env, GP);
97 98 if (GraphicsPrimitiveMgr == NULL || GraphicsPrimitive == NULL) {
98 99 JNU_ThrowOutOfMemoryError(env, "creating global refs");
99 100 return;
100 101 }
101 102 if (!InitPrimTypes(env) ||
102 103 !InitSurfaceTypes(env, ST) ||
103 104 !InitCompositeTypes(env, CT))
104 105 {
105 106 return;
106 107 }
107 108 CHECK_NULL(RegisterID =
108 109 (*env)->GetStaticMethodID(env, GPMgr, RegisterName, RegisterSig));
109 110 CHECK_NULL(pNativePrimID = (*env)->GetFieldID(env, GP, "pNativePrim", "J"));
110 111 CHECK_NULL(pixelID = (*env)->GetFieldID(env, SG2D, "pixel", "I"));
111 112 CHECK_NULL(eargbID = (*env)->GetFieldID(env, SG2D, "eargb", "I"));
112 113 CHECK_NULL(clipRegionID =
113 114 (*env)->GetFieldID(env, SG2D, "clipRegion", "Lsun/java2d/pipe/Region;"));
114 115 CHECK_NULL(compositeID =
115 116 (*env)->GetFieldID(env, SG2D, "composite", "Ljava/awt/Composite;"));
116 117 CHECK_NULL(lcdTextContrastID =
117 118 (*env)->GetFieldID(env, SG2D, "lcdTextContrast", "I"));
118 119 CHECK_NULL(getRgbID = (*env)->GetMethodID(env, Color, "getRGB", "()I"));
119 120 CHECK_NULL(xorPixelID = (*env)->GetFieldID(env, XORComp, "xorPixel", "I"));
120 121 CHECK_NULL(xorColorID =
121 122 (*env)->GetFieldID(env, XORComp, "xorColor", "Ljava/awt/Color;"));
122 123 CHECK_NULL(alphaMaskID =
123 124 (*env)->GetFieldID(env, XORComp, "alphaMask", "I"));
124 125 CHECK_NULL(ruleID = (*env)->GetFieldID(env, AlphaComp, "rule", "I"));
125 126 CHECK_NULL(extraAlphaID =
126 127 (*env)->GetFieldID(env, AlphaComp, "extraAlpha", "F"));
127 128
128 129
129 130 CHECK_NULL(m00ID = (*env)->GetFieldID(env, AT, "m00", "D"));
130 131 CHECK_NULL(m01ID = (*env)->GetFieldID(env, AT, "m01", "D"));
131 132 CHECK_NULL(m02ID = (*env)->GetFieldID(env, AT, "m02", "D"));
132 133 CHECK_NULL(m10ID = (*env)->GetFieldID(env, AT, "m10", "D"));
133 134 CHECK_NULL(m11ID = (*env)->GetFieldID(env, AT, "m11", "D"));
134 135 CHECK_NULL(m12ID = (*env)->GetFieldID(env, AT, "m12", "D"));
135 136
136 137 CHECK_NULL(path2DTypesID =
137 138 (*env)->GetFieldID(env, Path2D, "pointTypes", "[B"));
138 139 CHECK_NULL(path2DNumTypesID =
139 140 (*env)->GetFieldID(env, Path2D, "numTypes", "I"));
140 141 CHECK_NULL(path2DWindingRuleID =
↓ open down ↓ |
53 lines elided |
↑ open up ↑ |
141 142 (*env)->GetFieldID(env, Path2D, "windingRule", "I"));
142 143 CHECK_NULL(path2DFloatCoordsID =
143 144 (*env)->GetFieldID(env, Path2DFloat, "floatCoords", "[F"));
144 145 CHECK_NULL(sg2dStrokeHintID =
145 146 (*env)->GetFieldID(env, SG2D, "strokeHint", "I"));
146 147 CHECK_NULL(fid =
147 148 (*env)->GetStaticFieldID(env, SHints, "INTVAL_STROKE_PURE", "I"));
148 149 sunHints_INTVAL_STROKE_PURE = (*env)->GetStaticIntField(env, SHints, fid);
149 150 }
150 151
152 +JNIEXPORT void JNICALL
153 +Java_sun_java2d_loops_GraphicsPrimitiveMgr_setTraceFlags
154 + (JNIEnv *env, jclass GPMgr, jint traceflags)
155 +{
156 + graphicsPrimitive_traceflags = traceflags;
157 +}
158 +
151 159 void GrPrim_RefineBounds(SurfaceDataBounds *bounds, jint transX, jint transY,
152 160 jfloat *coords, jint maxCoords)
153 161 {
154 162 jint xmin, ymin, xmax, ymax;
155 163 if (maxCoords > 1) {
156 164 xmin = xmax = transX + (jint)(*coords++ + 0.5);
157 165 ymin = ymax = transY + (jint)(*coords++ + 0.5);
158 166 for (;maxCoords > 1; maxCoords -= 2) {
159 167 jint x = transX + (jint)(*coords++ + 0.5);
160 168 jint y = transY + (jint)(*coords++ + 0.5);
161 169 if (xmin > x) xmin = x;
162 170 if (ymin > y) ymin = y;
163 171 if (xmax < x) xmax = x;
164 172 if (ymax < y) ymax = y;
165 173 }
166 174 if (++xmax < xmin) xmax--;
167 175 if (++ymax < ymin) ymax--;
168 176 if (bounds->x1 < xmin) bounds->x1 = xmin;
169 177 if (bounds->y1 < ymin) bounds->y1 = ymin;
170 178 if (bounds->x2 > xmax) bounds->x2 = xmax;
171 179 if (bounds->y2 > ymax) bounds->y2 = ymax;
172 180 } else {
173 181 bounds->x2 = bounds->x1;
174 182 bounds->y2 = bounds->y1;
175 183 }
176 184 }
177 185
178 186 /*
179 187 * Class: sun_java2d_loops_GraphicsPrimitiveMgr
180 188 * Method: registerNativeLoops
181 189 * Signature: ()V
182 190 */
183 191 JNIEXPORT void JNICALL
184 192 Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops
185 193 (JNIEnv *env, jclass GPMgr)
186 194 {
187 195 RegisterFunc RegisterAnyByte;
188 196 RegisterFunc RegisterByteBinary1Bit;
189 197 RegisterFunc RegisterByteBinary2Bit;
190 198 RegisterFunc RegisterByteBinary4Bit;
191 199 RegisterFunc RegisterByteIndexed;
192 200 RegisterFunc RegisterByteGray;
193 201 RegisterFunc RegisterIndex8Gray;
194 202 RegisterFunc RegisterIndex12Gray;
195 203 RegisterFunc RegisterAnyShort;
196 204 RegisterFunc RegisterUshort555Rgb;
197 205 RegisterFunc RegisterUshort565Rgb;
198 206 RegisterFunc RegisterUshort4444Argb;
199 207 RegisterFunc RegisterUshort555Rgbx;
200 208 RegisterFunc RegisterUshortGray;
201 209 RegisterFunc RegisterUshortIndexed;
202 210 RegisterFunc RegisterAny3Byte;
203 211 RegisterFunc RegisterThreeByteBgr;
204 212 RegisterFunc RegisterAnyInt;
205 213 RegisterFunc RegisterIntArgb;
206 214 RegisterFunc RegisterIntArgbPre;
207 215 RegisterFunc RegisterIntArgbBm;
208 216 RegisterFunc RegisterIntRgb;
209 217 RegisterFunc RegisterIntBgr;
210 218 RegisterFunc RegisterIntRgbx;
211 219 RegisterFunc RegisterAny4Byte;
212 220 RegisterFunc RegisterFourByteAbgr;
213 221 RegisterFunc RegisterFourByteAbgrPre;
214 222
215 223 if (!RegisterAnyByte(env) ||
216 224 !RegisterByteBinary1Bit(env) ||
217 225 !RegisterByteBinary2Bit(env) ||
218 226 !RegisterByteBinary4Bit(env) ||
219 227 !RegisterByteIndexed(env) ||
220 228 !RegisterByteGray(env) ||
221 229 !RegisterIndex8Gray(env) ||
222 230 !RegisterIndex12Gray(env) ||
223 231 !RegisterAnyShort(env) ||
224 232 !RegisterUshort555Rgb(env) ||
225 233 !RegisterUshort565Rgb(env) ||
226 234 !RegisterUshort4444Argb(env) ||
227 235 !RegisterUshort555Rgbx(env) ||
228 236 !RegisterUshortGray(env) ||
229 237 !RegisterUshortIndexed(env) ||
230 238 !RegisterAny3Byte(env) ||
231 239 !RegisterThreeByteBgr(env) ||
232 240 !RegisterAnyInt(env) ||
233 241 !RegisterIntArgb(env) ||
234 242 !RegisterIntArgbPre(env) ||
235 243 !RegisterIntArgbBm(env) ||
236 244 !RegisterIntRgb(env) ||
237 245 !RegisterIntBgr(env) ||
238 246 !RegisterIntRgbx(env) ||
239 247 !RegisterAny4Byte(env) ||
240 248 !RegisterFourByteAbgr(env) ||
241 249 !RegisterFourByteAbgrPre(env))
242 250 {
243 251 return;
244 252 }
245 253 }
246 254
247 255 #define _StartOf(T) ((T *) (&T##s))
248 256 #define _NumberOf(T) (sizeof(T##s) / sizeof(T))
249 257 #define _EndOf(T) (_StartOf(T) + _NumberOf(T))
250 258
251 259 #define PrimTypeStart _StartOf(PrimitiveType)
252 260 #define PrimTypeEnd _EndOf(PrimitiveType)
253 261
254 262 #define SurfTypeStart _StartOf(SurfaceType)
255 263 #define SurfTypeEnd _EndOf(SurfaceType)
256 264
257 265 #define CompTypeStart _StartOf(CompositeType)
258 266 #define CompTypeEnd _EndOf(CompositeType)
259 267
260 268 /*
261 269 * This function initializes the global collection of PrimitiveType
262 270 * structures by retrieving the necessary Java Class object and the
263 271 * associated methodID of the necessary constructor.
264 272 *
265 273 * See PrimitiveTypes.* below.
266 274 */
267 275 static jboolean InitPrimTypes(JNIEnv *env)
268 276 {
269 277 jboolean ok = JNI_TRUE;
270 278 PrimitiveType *pPrimType;
271 279 jclass cl;
272 280
273 281 for (pPrimType = PrimTypeStart; pPrimType < PrimTypeEnd; pPrimType++) {
274 282 cl = (*env)->FindClass(env, pPrimType->ClassName);
275 283 if (cl == NULL) {
276 284 ok = JNI_FALSE;
277 285 break;
278 286 }
279 287 pPrimType->ClassObject = (*env)->NewGlobalRef(env, cl);
280 288 pPrimType->Constructor =
281 289 (*env)->GetMethodID(env, cl, InitName, InitSig);
282 290
283 291 (*env)->DeleteLocalRef(env, cl);
284 292 if (pPrimType->ClassObject == NULL ||
285 293 pPrimType->Constructor == NULL)
286 294 {
287 295 ok = JNI_FALSE;
288 296 break;
289 297 }
290 298 }
291 299
292 300 if (!ok) {
293 301 for (pPrimType = PrimTypeStart; pPrimType < PrimTypeEnd; pPrimType++) {
294 302 if (pPrimType->ClassObject != NULL) {
295 303 (*env)->DeleteGlobalRef(env, pPrimType->ClassObject);
296 304 pPrimType->ClassObject = NULL;
297 305 }
298 306 pPrimType->Constructor = NULL;
299 307 }
300 308 }
301 309
302 310 return ok;
303 311 }
304 312
305 313 /*
306 314 * This function initializes the global collection of SurfaceType
307 315 * or CompositeType structures by retrieving the corresponding Java
308 316 * object stored as a static field on the Java Class.
309 317 *
310 318 * See SurfaceTypes.* below.
311 319 * See CompositeeTypes.* below.
312 320 */
313 321 static jboolean InitSimpleTypes
314 322 (JNIEnv *env, jclass SimpleClass, char *SimpleSig,
315 323 SurfCompHdr *pStart, SurfCompHdr *pEnd, jsize size)
316 324 {
317 325 jboolean ok = JNI_TRUE;
318 326 SurfCompHdr *pHdr;
319 327 jfieldID field;
320 328 jobject obj;
321 329
322 330 for (pHdr = pStart; pHdr < pEnd; pHdr = PtrAddBytes(pHdr, size)) {
323 331 field = (*env)->GetStaticFieldID(env,
324 332 SimpleClass,
325 333 pHdr->Name,
326 334 SimpleSig);
327 335 if (field == NULL) {
328 336 ok = JNI_FALSE;
329 337 break;
330 338 }
331 339 obj = (*env)->GetStaticObjectField(env, SimpleClass, field);
332 340 if (obj == NULL) {
333 341 ok = JNI_FALSE;
334 342 break;
335 343 }
336 344 pHdr->Object = (*env)->NewGlobalRef(env, obj);
337 345 (*env)->DeleteLocalRef(env, obj);
338 346 if (pHdr->Object == NULL) {
339 347 ok = JNI_FALSE;
340 348 break;
341 349 }
342 350 }
343 351
344 352 if (!ok) {
345 353 for (pHdr = pStart; pHdr < pEnd; pHdr = PtrAddBytes(pHdr, size)) {
346 354 if (pHdr->Object != NULL) {
347 355 (*env)->DeleteGlobalRef(env, pHdr->Object);
348 356 pHdr->Object = NULL;
349 357 }
350 358 }
351 359 }
352 360
353 361 return ok;
354 362 }
355 363
356 364 static jboolean InitSurfaceTypes(JNIEnv *env, jclass ST)
357 365 {
358 366 return InitSimpleTypes(env, ST, "Lsun/java2d/loops/SurfaceType;",
359 367 (SurfCompHdr *) SurfTypeStart,
360 368 (SurfCompHdr *) SurfTypeEnd,
361 369 sizeof(SurfaceType));
362 370 }
363 371
364 372 static jboolean InitCompositeTypes(JNIEnv *env, jclass CT)
365 373 {
366 374 return InitSimpleTypes(env, CT, "Lsun/java2d/loops/CompositeType;",
367 375 (SurfCompHdr *) CompTypeStart,
368 376 (SurfCompHdr *) CompTypeEnd,
369 377 sizeof(CompositeType));
370 378 }
371 379
372 380 /*
373 381 * This function registers a set of Java GraphicsPrimitive objects
374 382 * based on information stored in an array of NativePrimitive structures.
375 383 */
376 384 jboolean RegisterPrimitives(JNIEnv *env,
377 385 NativePrimitive *pPrim,
378 386 jint NumPrimitives)
379 387 {
380 388 jarray primitives;
381 389 int i;
382 390
383 391 primitives = (*env)->NewObjectArray(env, NumPrimitives,
384 392 GraphicsPrimitive, NULL);
385 393 if (primitives == NULL) {
386 394 return JNI_FALSE;
387 395 }
388 396
389 397 for (i = 0; i < NumPrimitives; i++, pPrim++) {
390 398 jint srcflags, dstflags;
391 399 jobject prim;
392 400 PrimitiveType *pType = pPrim->pPrimType;
393 401 SurfaceType *pSrc = pPrim->pSrcType;
394 402 CompositeType *pComp = pPrim->pCompType;
395 403 SurfaceType *pDst = pPrim->pDstType;
396 404
397 405 pPrim->funcs.initializer = MapAccelFunction(pPrim->funcs_c.initializer);
398 406
399 407 /*
400 408 * Calculate the necessary SurfaceData lock flags for the
401 409 * source and destination surfaces based on the information
402 410 * stored in the PrimitiveType, SurfaceType, and CompositeType
403 411 * structures. The starting point is the values that are
404 412 * already stored in the NativePrimitive structure. These
405 413 * flags are usually left as 0, but can be filled in by
406 414 * native primitive loops that have special needs that are
407 415 * not deducible from their declared attributes.
408 416 */
409 417 srcflags = pPrim->srcflags;
410 418 dstflags = pPrim->dstflags;
411 419 srcflags |= pType->srcflags;
412 420 dstflags |= pType->dstflags;
413 421 dstflags |= pComp->dstflags;
414 422 if (srcflags & SD_LOCK_READ) srcflags |= pSrc->readflags;
415 423 /* if (srcflags & SD_LOCK_WRITE) srcflags |= pSrc->writeflags; */
416 424 if (dstflags & SD_LOCK_READ) dstflags |= pDst->readflags;
417 425 if (dstflags & SD_LOCK_WRITE) dstflags |= pDst->writeflags;
418 426 pPrim->srcflags = srcflags;
419 427 pPrim->dstflags = dstflags;
420 428
421 429 prim = (*env)->NewObject(env,
422 430 pType->ClassObject,
423 431 pType->Constructor,
424 432 ptr_to_jlong(pPrim),
425 433 pSrc->hdr.Object,
426 434 pComp->hdr.Object,
427 435 pDst->hdr.Object);
428 436 if (prim == NULL) {
429 437 break;
430 438 }
431 439 (*env)->SetObjectArrayElement(env, primitives, i, prim);
432 440 (*env)->DeleteLocalRef(env, prim);
433 441 if ((*env)->ExceptionCheck(env)) {
434 442 break;
435 443 }
436 444 }
437 445
438 446 if (i >= NumPrimitives) {
439 447 /* No error - upcall to GraphicsPrimitiveMgr to register the
440 448 * new primitives... */
441 449 (*env)->CallStaticVoidMethod(env, GraphicsPrimitiveMgr, RegisterID,
442 450 primitives);
443 451 }
444 452 (*env)->DeleteLocalRef(env, primitives);
445 453
446 454 return !((*env)->ExceptionCheck(env));
447 455 }
448 456
449 457 JNIEXPORT NativePrimitive * JNICALL
450 458 GetNativePrim(JNIEnv *env, jobject gp)
451 459 {
452 460 NativePrimitive *pPrim;
453 461
454 462 pPrim = (NativePrimitive *) JNU_GetLongFieldAsPtr(env, gp, pNativePrimID);
455 463 if (pPrim == NULL) {
456 464 JNU_ThrowInternalError(env, "Non-native Primitive invoked natively");
457 465 }
458 466
459 467 return pPrim;
460 468 }
461 469
462 470 JNIEXPORT void JNICALL
463 471 GrPrim_Sg2dGetCompInfo(JNIEnv *env, jobject sg2d,
464 472 NativePrimitive *pPrim, CompositeInfo *pCompInfo)
465 473 {
466 474 jobject comp;
467 475
468 476 comp = (*env)->GetObjectField(env, sg2d, compositeID);
469 477 (*pPrim->pCompType->getCompInfo)(env, pCompInfo, comp);
470 478 (*env)->DeleteLocalRef(env, comp);
471 479 }
472 480
473 481 JNIEXPORT jint JNICALL
474 482 GrPrim_CompGetXorColor(JNIEnv *env, jobject comp)
475 483 {
476 484 jobject color;
477 485 jint rgb;
478 486
479 487 color = (*env)->GetObjectField(env, comp, xorColorID);
480 488 rgb = (*env)->CallIntMethod(env, color, getRgbID);
481 489 (*env)->DeleteLocalRef(env, color);
482 490
483 491 return rgb;
484 492 }
485 493
486 494 JNIEXPORT void JNICALL
487 495 GrPrim_Sg2dGetClip(JNIEnv *env, jobject sg2d, SurfaceDataBounds *bounds)
488 496 {
489 497 jobject clip = (*env)->GetObjectField(env, sg2d, clipRegionID);
490 498 Region_GetBounds(env, clip, bounds);
491 499 }
492 500
493 501 JNIEXPORT jint JNICALL
494 502 GrPrim_Sg2dGetPixel(JNIEnv *env, jobject sg2d)
495 503 {
496 504 return (*env)->GetIntField(env, sg2d, pixelID);
497 505 }
498 506
499 507 JNIEXPORT jint JNICALL
500 508 GrPrim_Sg2dGetEaRGB(JNIEnv *env, jobject sg2d)
501 509 {
502 510 return (*env)->GetIntField(env, sg2d, eargbID);
503 511 }
504 512
505 513 JNIEXPORT jint JNICALL
506 514 GrPrim_Sg2dGetLCDTextContrast(JNIEnv *env, jobject sg2d)
507 515 {
508 516 return (*env)->GetIntField(env, sg2d, lcdTextContrastID);
509 517 }
510 518
511 519 /*
512 520 * Helper function for CompositeTypes.Xor
513 521 */
514 522 JNIEXPORT void JNICALL
515 523 GrPrim_CompGetXorInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp)
516 524 {
517 525 pCompInfo->rule = RULE_Xor;
518 526 pCompInfo->details.xorPixel = (*env)->GetIntField(env, comp, xorPixelID);
519 527 pCompInfo->alphaMask = (*env)->GetIntField(env, comp, alphaMaskID);
520 528 }
521 529
522 530 /*
523 531 * Helper function for CompositeTypes.AnyAlpha
524 532 */
525 533 JNIEXPORT void JNICALL
526 534 GrPrim_CompGetAlphaInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp)
527 535 {
528 536 pCompInfo->rule =
529 537 (*env)->GetIntField(env, comp, ruleID);
530 538 pCompInfo->details.extraAlpha =
531 539 (*env)->GetFloatField(env, comp, extraAlphaID);
532 540 }
533 541
534 542 JNIEXPORT void JNICALL
535 543 Transform_GetInfo(JNIEnv *env, jobject txform, TransformInfo *pTxInfo)
536 544 {
537 545 pTxInfo->dxdx = (*env)->GetDoubleField(env, txform, m00ID);
538 546 pTxInfo->dxdy = (*env)->GetDoubleField(env, txform, m01ID);
539 547 pTxInfo->tx = (*env)->GetDoubleField(env, txform, m02ID);
540 548 pTxInfo->dydx = (*env)->GetDoubleField(env, txform, m10ID);
541 549 pTxInfo->dydy = (*env)->GetDoubleField(env, txform, m11ID);
542 550 pTxInfo->ty = (*env)->GetDoubleField(env, txform, m12ID);
543 551 }
544 552
545 553 JNIEXPORT void JNICALL
546 554 Transform_transform(TransformInfo *pTxInfo, jdouble *pX, jdouble *pY)
547 555 {
548 556 jdouble x = *pX;
549 557 jdouble y = *pY;
550 558
551 559 *pX = pTxInfo->dxdx * x + pTxInfo->dxdy * y + pTxInfo->tx;
552 560 *pY = pTxInfo->dydx * x + pTxInfo->dydy * y + pTxInfo->ty;
553 561 }
554 562
555 563 /*
556 564 * External declarations for the pixelFor helper methods for the various
557 565 * named surface types. These functions are defined in the various
558 566 * files that contain the loop functions for their type.
559 567 */
560 568 extern PixelForFunc PixelForByteBinary;
561 569 extern PixelForFunc PixelForByteIndexed;
562 570 extern PixelForFunc PixelForByteGray;
563 571 extern PixelForFunc PixelForIndex8Gray;
564 572 extern PixelForFunc PixelForIndex12Gray;
565 573 extern PixelForFunc PixelForUshort555Rgb;
566 574 extern PixelForFunc PixelForUshort555Rgbx;
567 575 extern PixelForFunc PixelForUshort565Rgb;
568 576 extern PixelForFunc PixelForUshort4444Argb;
569 577 extern PixelForFunc PixelForUshortGray;
570 578 extern PixelForFunc PixelForUshortIndexed;
571 579 extern PixelForFunc PixelForIntArgbPre;
572 580 extern PixelForFunc PixelForIntArgbBm;
573 581 extern PixelForFunc PixelForIntBgr;
574 582 extern PixelForFunc PixelForIntRgbx;
575 583 extern PixelForFunc PixelForFourByteAbgr;
576 584 extern PixelForFunc PixelForFourByteAbgrPre;
577 585
578 586 /*
579 587 * Definition and initialization of the globally accessible PrimitiveTypes.
580 588 */
581 589 struct _PrimitiveTypes PrimitiveTypes = {
582 590 { "sun/java2d/loops/Blit", SD_LOCK_READ, SD_LOCK_WRITE, NULL, NULL},
583 591 { "sun/java2d/loops/BlitBg", SD_LOCK_READ, SD_LOCK_WRITE, NULL, NULL},
584 592 { "sun/java2d/loops/ScaledBlit", SD_LOCK_READ, SD_LOCK_WRITE, NULL, NULL},
585 593 { "sun/java2d/loops/FillRect", 0, SD_LOCK_WRITE, NULL, NULL},
586 594 { "sun/java2d/loops/FillSpans", 0, SD_LOCK_PARTIAL_WRITE, NULL, NULL},
587 595 { "sun/java2d/loops/FillParallelogram", 0, SD_LOCK_PARTIAL_WRITE, NULL, NULL},
588 596 { "sun/java2d/loops/DrawParallelogram", 0, SD_LOCK_PARTIAL_WRITE, NULL, NULL},
589 597 { "sun/java2d/loops/DrawLine", 0, SD_LOCK_PARTIAL_WRITE, NULL, NULL},
590 598 { "sun/java2d/loops/DrawRect", 0, SD_LOCK_PARTIAL_WRITE, NULL, NULL},
591 599 { "sun/java2d/loops/DrawPolygons", 0, SD_LOCK_PARTIAL_WRITE, NULL, NULL},
592 600 { "sun/java2d/loops/DrawPath", 0, SD_LOCK_PARTIAL_WRITE, NULL, NULL},
593 601 { "sun/java2d/loops/FillPath", 0, SD_LOCK_PARTIAL_WRITE, NULL, NULL},
594 602 { "sun/java2d/loops/MaskBlit", SD_LOCK_READ, SD_LOCK_RD_WR, NULL, NULL},
595 603 { "sun/java2d/loops/MaskFill", 0, SD_LOCK_RD_WR, NULL, NULL},
596 604 { "sun/java2d/loops/DrawGlyphList", 0, SD_LOCK_PARTIAL_WRITE |
597 605 SD_LOCK_FASTEST, NULL, NULL},
598 606 { "sun/java2d/loops/DrawGlyphListAA", 0, SD_LOCK_RD_WR | SD_LOCK_FASTEST, NULL, NULL},
599 607 { "sun/java2d/loops/DrawGlyphListLCD", 0, SD_LOCK_RD_WR | SD_LOCK_FASTEST, NULL, NULL},
600 608 { "sun/java2d/loops/TransformHelper", SD_LOCK_READ, 0, NULL, NULL}
601 609 };
602 610
603 611 /*
604 612 * Definition and initialization of the globally accessible SurfaceTypes.
605 613 */
606 614 struct _SurfaceTypes SurfaceTypes = {
607 615 { { "OpaqueColor", NULL}, NULL, 0, 0 },
608 616 { { "AnyColor", NULL}, NULL, 0, 0 },
609 617 { { "AnyByte", NULL}, NULL, 0, 0 },
610 618 { { "ByteBinary1Bit", NULL},
611 619 PixelForByteBinary, SD_LOCK_LUT, SD_LOCK_INVCOLOR },
612 620 { { "ByteBinary2Bit", NULL},
613 621 PixelForByteBinary, SD_LOCK_LUT, SD_LOCK_INVCOLOR },
614 622 { { "ByteBinary4Bit", NULL},
615 623 PixelForByteBinary, SD_LOCK_LUT, SD_LOCK_INVCOLOR },
616 624 { { "ByteIndexed", NULL},
617 625 PixelForByteIndexed, SD_LOCK_LUT, SD_LOCK_INVCOLOR },
618 626 { { "ByteIndexedBm", NULL},
619 627 PixelForByteIndexed, SD_LOCK_LUT, SD_LOCK_INVCOLOR },
620 628 { { "ByteGray", NULL}, PixelForByteGray, 0, 0},
621 629 { { "Index8Gray", NULL},
622 630 PixelForIndex8Gray, SD_LOCK_LUT, SD_LOCK_INVGRAY },
623 631 { { "Index12Gray", NULL},
624 632 PixelForIndex12Gray, SD_LOCK_LUT, SD_LOCK_INVGRAY },
625 633 { { "AnyShort", NULL}, NULL, 0, 0 },
626 634 { { "Ushort555Rgb", NULL}, PixelForUshort555Rgb, 0, 0},
627 635 { { "Ushort555Rgbx", NULL}, PixelForUshort555Rgbx, 0, 0},
628 636 { { "Ushort565Rgb", NULL}, PixelForUshort565Rgb, 0, 0 },
629 637 { { "Ushort4444Argb", NULL}, PixelForUshort4444Argb, 0, 0 },
630 638 { { "UshortGray", NULL}, PixelForUshortGray, 0, 0},
631 639 { { "UshortIndexed", NULL},
632 640 PixelForUshortIndexed, SD_LOCK_LUT, SD_LOCK_INVCOLOR },
633 641 { { "Any3Byte", NULL}, NULL, 0, 0 },
634 642 { { "ThreeByteBgr", NULL}, NULL, 0, 0 },
635 643 { { "AnyInt", NULL}, NULL, 0, 0 },
636 644 { { "IntArgb", NULL}, NULL, 0, 0 },
637 645 { { "IntArgbPre", NULL}, PixelForIntArgbPre, 0, 0},
638 646 { { "IntArgbBm", NULL}, PixelForIntArgbBm, 0, 0},
639 647 { { "IntRgb", NULL}, NULL, 0, 0 },
640 648 { { "IntBgr", NULL}, PixelForIntBgr, 0, 0},
641 649 { { "IntRgbx", NULL}, PixelForIntRgbx, 0, 0},
642 650 { { "Any4Byte", NULL}, NULL, 0, 0 },
643 651 { { "FourByteAbgr", NULL}, PixelForFourByteAbgr, 0, 0},
644 652 { { "FourByteAbgrPre", NULL}, PixelForFourByteAbgrPre, 0, 0},
645 653 };
646 654
647 655 /*
648 656 * Definition and initialization of the globally accessible CompositeTypes.
649 657 */
650 658 struct _CompositeTypes CompositeTypes = {
651 659 { { "SrcNoEa", NULL}, NULL, 0},
652 660 { { "SrcOverNoEa", NULL}, NULL, SD_LOCK_RD_WR },
653 661 { { "SrcOverNoEa", NULL}, NULL, SD_LOCK_PARTIAL_WRITE }, /* SrcOverBmNoEa */
654 662 { { "Src", NULL}, GrPrim_CompGetAlphaInfo, 0},
655 663 { { "SrcOver", NULL}, GrPrim_CompGetAlphaInfo, SD_LOCK_RD_WR },
656 664 { { "Xor", NULL}, GrPrim_CompGetXorInfo, SD_LOCK_RD_WR },
657 665 { { "AnyAlpha", NULL}, GrPrim_CompGetAlphaInfo, SD_LOCK_RD_WR },
658 666 };
↓ open down ↓ |
498 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX