411 public boolean canRenderLCDText(SunGraphics2D sg2d) { 412 return 413 graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) && 414 sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY && 415 sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR && 416 sg2d.surfaceData.getTransparency() == Transparency.OPAQUE; 417 } 418 419 public void validatePipe(SunGraphics2D sg2d) { 420 TextPipe textpipe; 421 boolean validated = false; 422 423 // OGLTextRenderer handles both AA and non-AA text, but 424 // only works with the following modes: 425 // (Note: For LCD text we only enter this code path if 426 // canRenderLCDText() has already validated that the mode is 427 // CompositeType.SrcNoEa (opaque color), which will be subsumed 428 // by the CompositeType.SrcNoEa (any color) test below.) 429 430 if (/* CompositeType.SrcNoEa (any color) */ 431 (sg2d.compositeState <= sg2d.COMP_ISCOPY && 432 sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) || 433 434 /* CompositeType.SrcOver (any color) */ 435 (sg2d.compositeState == sg2d.COMP_ALPHA && 436 sg2d.paintState <= sg2d.PAINT_ALPHACOLOR && 437 (((AlphaComposite)sg2d.composite).getRule() == 438 AlphaComposite.SRC_OVER)) || 439 440 /* CompositeType.Xor (any color) */ 441 (sg2d.compositeState == sg2d.COMP_XOR && 442 sg2d.paintState <= sg2d.PAINT_ALPHACOLOR)) 443 { 444 textpipe = oglTextPipe; 445 } else { 446 // do this to initialize textpipe correctly; we will attempt 447 // to override the non-text pipes below 448 super.validatePipe(sg2d); 449 textpipe = sg2d.textpipe; 450 validated = true; 451 } 452 453 PixelToParallelogramConverter txPipe = null; 454 OGLRenderer nonTxPipe = null; 455 456 if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) { 457 if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) { 458 if (sg2d.compositeState <= sg2d.COMP_XOR) { 459 txPipe = oglTxRenderPipe; 460 nonTxPipe = oglRenderPipe; 461 } 462 } else if (sg2d.compositeState <= sg2d.COMP_ALPHA) { 463 if (OGLPaints.isValid(sg2d)) { 464 txPipe = oglTxRenderPipe; 465 nonTxPipe = oglRenderPipe; 466 } 467 // custom paints handled by super.validatePipe() below 468 } 469 } else { 470 if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) { 471 if (graphicsConfig.isCapPresent(CAPS_PS30) && 472 (sg2d.imageComp == CompositeType.SrcOverNoEa || 473 sg2d.imageComp == CompositeType.SrcOver)) 474 { 475 if (!validated) { 476 super.validatePipe(sg2d); 477 validated = true; 478 } 479 PixelToParallelogramConverter aaConverter = 480 new PixelToParallelogramConverter(sg2d.shapepipe, 481 oglAAPgramPipe, 482 1.0/8.0, 0.499, 483 false); 484 sg2d.drawpipe = aaConverter; 485 sg2d.fillpipe = aaConverter; 486 sg2d.shapepipe = aaConverter; 487 } else if (sg2d.compositeState == sg2d.COMP_XOR) { 488 // install the solid pipes when AA and XOR are both enabled 489 txPipe = oglTxRenderPipe; 490 nonTxPipe = oglRenderPipe; 491 } 492 } 493 // other cases handled by super.validatePipe() below 494 } 495 496 if (txPipe != null) { 497 if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) { 498 sg2d.drawpipe = txPipe; 499 sg2d.fillpipe = txPipe; 500 } else if (sg2d.strokeState != sg2d.STROKE_THIN) { 501 sg2d.drawpipe = txPipe; 502 sg2d.fillpipe = nonTxPipe; 503 } else { 504 sg2d.drawpipe = nonTxPipe; 505 sg2d.fillpipe = nonTxPipe; 506 } 507 // Note that we use the transforming pipe here because it 508 // will examine the shape and possibly perform an optimized 509 // operation if it can be simplified. The simplifications 510 // will be valid for all STROKE and TRANSFORM types. 511 sg2d.shapepipe = txPipe; 512 } else { 513 if (!validated) { 514 super.validatePipe(sg2d); 515 } 516 } 517 518 // install the text pipe based on our earlier decision 519 sg2d.textpipe = textpipe; 520 521 // always override the image pipe with the specialized OGL pipe 522 sg2d.imagepipe = oglImagePipe; 523 } 524 525 @Override 526 protected MaskFill getMaskFill(SunGraphics2D sg2d) { 527 if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) { 528 /* 529 * We can only accelerate non-Color MaskFill operations if 530 * all of the following conditions hold true: 531 * - there is an implementation for the given paintState 532 * - the current Paint can be accelerated for this destination 533 * - multitexturing is available (since we need to modulate 534 * the alpha mask texture with the paint texture) 535 * 536 * In all other cases, we return null, in which case the 537 * validation code will choose a more general software-based loop. 538 */ 539 if (!OGLPaints.isValid(sg2d) || 540 !graphicsConfig.isCapPresent(CAPS_MULTITEXTURE)) 541 { 542 return null; 543 } 544 } 545 return super.getMaskFill(sg2d); 546 } 547 548 public boolean copyArea(SunGraphics2D sg2d, 549 int x, int y, int w, int h, int dx, int dy) 550 { 551 if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE && 552 sg2d.compositeState < sg2d.COMP_XOR) 553 { 554 x += sg2d.transX; 555 y += sg2d.transY; 556 557 oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy); 558 559 return true; 560 } 561 return false; 562 } 563 564 public void flush() { 565 invalidate(); 566 OGLRenderQueue rq = OGLRenderQueue.getInstance(); 567 rq.lock(); 568 try { 569 // make sure we have a current context before 570 // disposing the native resources (e.g. texture object) 571 OGLContext.setScratchSurface(graphicsConfig); 572 | 411 public boolean canRenderLCDText(SunGraphics2D sg2d) { 412 return 413 graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) && 414 sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY && 415 sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR && 416 sg2d.surfaceData.getTransparency() == Transparency.OPAQUE; 417 } 418 419 public void validatePipe(SunGraphics2D sg2d) { 420 TextPipe textpipe; 421 boolean validated = false; 422 423 // OGLTextRenderer handles both AA and non-AA text, but 424 // only works with the following modes: 425 // (Note: For LCD text we only enter this code path if 426 // canRenderLCDText() has already validated that the mode is 427 // CompositeType.SrcNoEa (opaque color), which will be subsumed 428 // by the CompositeType.SrcNoEa (any color) test below.) 429 430 if (/* CompositeType.SrcNoEa (any color) */ 431 (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY && 432 sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) || 433 434 /* CompositeType.SrcOver (any color) */ 435 (sg2d.compositeState == SunGraphics2D.COMP_ALPHA && 436 sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR && 437 (((AlphaComposite)sg2d.composite).getRule() == 438 AlphaComposite.SRC_OVER)) || 439 440 /* CompositeType.Xor (any color) */ 441 (sg2d.compositeState == SunGraphics2D.COMP_XOR && 442 sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR)) 443 { 444 textpipe = oglTextPipe; 445 } else { 446 // do this to initialize textpipe correctly; we will attempt 447 // to override the non-text pipes below 448 super.validatePipe(sg2d); 449 textpipe = sg2d.textpipe; 450 validated = true; 451 } 452 453 PixelToParallelogramConverter txPipe = null; 454 OGLRenderer nonTxPipe = null; 455 456 if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) { 457 if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) { 458 if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) { 459 txPipe = oglTxRenderPipe; 460 nonTxPipe = oglRenderPipe; 461 } 462 } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) { 463 if (OGLPaints.isValid(sg2d)) { 464 txPipe = oglTxRenderPipe; 465 nonTxPipe = oglRenderPipe; 466 } 467 // custom paints handled by super.validatePipe() below 468 } 469 } else { 470 if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) { 471 if (graphicsConfig.isCapPresent(CAPS_PS30) && 472 (sg2d.imageComp == CompositeType.SrcOverNoEa || 473 sg2d.imageComp == CompositeType.SrcOver)) 474 { 475 if (!validated) { 476 super.validatePipe(sg2d); 477 validated = true; 478 } 479 PixelToParallelogramConverter aaConverter = 480 new PixelToParallelogramConverter(sg2d.shapepipe, 481 oglAAPgramPipe, 482 1.0/8.0, 0.499, 483 false); 484 sg2d.drawpipe = aaConverter; 485 sg2d.fillpipe = aaConverter; 486 sg2d.shapepipe = aaConverter; 487 } else if (sg2d.compositeState == SunGraphics2D.COMP_XOR) { 488 // install the solid pipes when AA and XOR are both enabled 489 txPipe = oglTxRenderPipe; 490 nonTxPipe = oglRenderPipe; 491 } 492 } 493 // other cases handled by super.validatePipe() below 494 } 495 496 if (txPipe != null) { 497 if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { 498 sg2d.drawpipe = txPipe; 499 sg2d.fillpipe = txPipe; 500 } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) { 501 sg2d.drawpipe = txPipe; 502 sg2d.fillpipe = nonTxPipe; 503 } else { 504 sg2d.drawpipe = nonTxPipe; 505 sg2d.fillpipe = nonTxPipe; 506 } 507 // Note that we use the transforming pipe here because it 508 // will examine the shape and possibly perform an optimized 509 // operation if it can be simplified. The simplifications 510 // will be valid for all STROKE and TRANSFORM types. 511 sg2d.shapepipe = txPipe; 512 } else { 513 if (!validated) { 514 super.validatePipe(sg2d); 515 } 516 } 517 518 // install the text pipe based on our earlier decision 519 sg2d.textpipe = textpipe; 520 521 // always override the image pipe with the specialized OGL pipe 522 sg2d.imagepipe = oglImagePipe; 523 } 524 525 @Override 526 protected MaskFill getMaskFill(SunGraphics2D sg2d) { 527 if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) { 528 /* 529 * We can only accelerate non-Color MaskFill operations if 530 * all of the following conditions hold true: 531 * - there is an implementation for the given paintState 532 * - the current Paint can be accelerated for this destination 533 * - multitexturing is available (since we need to modulate 534 * the alpha mask texture with the paint texture) 535 * 536 * In all other cases, we return null, in which case the 537 * validation code will choose a more general software-based loop. 538 */ 539 if (!OGLPaints.isValid(sg2d) || 540 !graphicsConfig.isCapPresent(CAPS_MULTITEXTURE)) 541 { 542 return null; 543 } 544 } 545 return super.getMaskFill(sg2d); 546 } 547 548 public boolean copyArea(SunGraphics2D sg2d, 549 int x, int y, int w, int h, int dx, int dy) 550 { 551 if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE && 552 sg2d.compositeState < SunGraphics2D.COMP_XOR) 553 { 554 x += sg2d.transX; 555 y += sg2d.transY; 556 557 oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy); 558 559 return true; 560 } 561 return false; 562 } 563 564 public void flush() { 565 invalidate(); 566 OGLRenderQueue rq = OGLRenderQueue.getInstance(); 567 rq.lock(); 568 try { 569 // make sure we have a current context before 570 // disposing the native resources (e.g. texture object) 571 OGLContext.setScratchSurface(graphicsConfig); 572 |