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