57 sQuartzPipe = new CRenderer(); // Creates the singleton quartz pipe. 58 } 59 60 // NOTE: Any subclasses must eventually call QuartzSurfaceData_InitOps in OSXSurfaceData.h 61 // This sets up the native side for the SurfaceData, and is required. 62 public OSXSurfaceData(SurfaceType sType, ColorModel cm) { 63 this(sType, cm, null, new Rectangle()); 64 } 65 66 public OSXSurfaceData(SurfaceType sType, ColorModel cm, GraphicsConfiguration config, Rectangle bounds) { 67 super(sType, cm); 68 69 this.fConfig = config; 70 71 this.fBounds = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.y + bounds.height); 72 73 this.fGraphicsStates = getBufferOfSize(kSizeOfParameters); 74 this.fGraphicsStatesInt = this.fGraphicsStates.asIntBuffer(); 75 this.fGraphicsStatesFloat = this.fGraphicsStates.asFloatBuffer(); 76 this.fGraphicsStatesLong = this.fGraphicsStates.asLongBuffer(); 77 this.fGraphicsStatesObject = new Object[6]; // clip coordinates + clip types + texture paint image + stroke dash 78 // array + font + font paint 79 80 // NOTE: All access to the DrawingQueue comes through this OSXSurfaceData instance. Therefore 81 // every instance method of OSXSurfaceData that accesses the fDrawingQueue is synchronized. 82 83 // Thread.dumpStack(); 84 } 85 86 public void validatePipe(SunGraphics2D sg2d) { 87 88 if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) { 89 if (sCocoaTextPipe == null) { 90 sCocoaTextPipe = new CTextPipe(); 91 } 92 93 sg2d.imagepipe = sQuartzPipe; 94 sg2d.drawpipe = sQuartzPipe; 95 sg2d.fillpipe = sQuartzPipe; 96 sg2d.shapepipe = sQuartzPipe; 97 sg2d.textpipe = sCocoaTextPipe; 98 } else { 275 @Native static final int kColortyIndex = 32; 276 @Native static final int kColorx2Index = 33; 277 @Native static final int kColorsxIndex = 34; 278 @Native static final int kColory2Index = 35; 279 @Native static final int kColorsyIndex = 36; 280 // composite info 281 @Native static final int kCompositeRuleIndex = 37; // kCGCompositeClear or ... or kCGCompositeXor 282 @Native static final int kCompositeValueIndex = 38; 283 // stroke info 284 @Native static final int kStrokeJoinIndex = 39; // see BasicStroke.java 285 @Native static final int kStrokeCapIndex = 40; // see BasicStroke.java 286 @Native static final int kStrokeWidthIndex = 41; 287 @Native static final int kStrokeDashPhaseIndex = 42; 288 @Native static final int kStrokeLimitIndex = 43; 289 // hints info 290 @Native static final int kHintsAntialiasIndex = 44; 291 @Native static final int kHintsTextAntialiasIndex = 45; 292 @Native static final int kHintsFractionalMetricsIndex = 46; 293 @Native static final int kHintsRenderingIndex = 47; 294 @Native static final int kHintsInterpolationIndex = 48; 295 // live resizing info 296 @Native static final int kCanDrawDuringLiveResizeIndex = 49; 297 298 @Native static final int kSizeOfParameters = kCanDrawDuringLiveResizeIndex + 1; 299 300 // for objectParameters 301 @Native static final int kClipCoordinatesIndex = 0; 302 @Native static final int kClipTypesIndex = 1; 303 @Native static final int kTextureImageIndex = 2; 304 @Native static final int kStrokeDashArrayIndex = 3; 305 @Native static final int kFontIndex = 4; 306 @Native static final int kFontPaintIndex = 5; 307 308 // possible state changes 309 @Native static final int kBoundsChangedBit = 1 << 0; 310 @Native static final int kBoundsNotChangedBit = ~kBoundsChangedBit; 311 @Native static final int kClipChangedBit = 1 << 1; 312 @Native static final int kClipNotChangedBit = ~kClipChangedBit; 313 @Native static final int kCTMChangedBit = 1 << 2; 314 @Native static final int kCTMNotChangedBit = ~kCTMChangedBit; 315 @Native static final int kColorChangedBit = 1 << 3; 316 @Native static final int kColorNotChangedBit = ~kColorChangedBit; 317 @Native static final int kCompositeChangedBit = 1 << 4; 318 @Native static final int kCompositeNotChangedBit = ~kCompositeChangedBit; 319 @Native static final int kStrokeChangedBit = 1 << 5; 320 @Native static final int kStrokeNotChangedBit = ~kStrokeChangedBit; 321 @Native static final int kHintsChangedBit = 1 << 6; 322 @Native static final int kHintsNotChangedBit = ~kHintsChangedBit; 323 @Native static final int kFontChangedBit = 1 << 7; 324 @Native static final int kFontNotChangedBit = ~kFontChangedBit; 325 @Native static final int kEverythingChangedFlag = 0xffffffff; 326 327 // possible color states 328 @Native static final int kColorSimple = 0; 329 @Native static final int kColorSystem = 1; 330 @Native static final int kColorGradient = 2; 331 @Native static final int kColorTexture = 3; 332 333 // possible gradient color states 334 @Native static final int kColorNonCyclic = 0; 335 @Native static final int kColorCyclic = 1; 336 337 // possible clip states 338 @Native static final int kClipRect = 0; 339 @Native static final int kClipShape = 1; 340 341 static int getRendererTypeForPrimitive(int primitiveType) { 342 switch (primitiveType) { 343 case kImage: 344 return kImage; 345 case kCopyArea: 346 return kCopyArea; 347 case kExternal: 348 return kExternal; 349 case kString: 350 case kGlyphs: 351 case kUnicodes: 505 lastCTMa = a; 506 lastCTMb = b; 507 lastCTMc = c; 508 lastCTMd = d; 509 lastCTMtx = tx; 510 lastCTMty = ty; 511 512 this.fChangeFlag = (this.fChangeFlag | kCTMChangedBit); 513 } else { 514 this.fChangeFlag = (this.fChangeFlag & kCTMNotChangedBit); 515 } 516 } 517 518 static AffineTransform sIdentityMatrix = new AffineTransform(); 519 Paint lastPaint = null; 520 long lastPaintPtr = 0; 521 int lastPaintRGB = 0; 522 int lastPaintIndex = 0; 523 BufferedImage texturePaintImage = null; 524 525 void setupPaint(SunGraphics2D sg2d, int x, int y, int w, int h) { 526 if (sg2d.paint instanceof SystemColor) { 527 SystemColor color = (SystemColor) sg2d.paint; 528 int index = color.hashCode(); // depends on Color.java hashCode implementation! (returns "value" of color) 529 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorSystem) || (index != this.lastPaintIndex)) { 530 this.lastPaintIndex = index; 531 532 this.fGraphicsStatesInt.put(kColorStateIndex, kColorSystem); 533 this.fGraphicsStatesInt.put(kColorIndexValueIndex, index); 534 535 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 536 } else { 537 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 538 } 539 } else if (sg2d.paint instanceof Color) { 540 Color color = (Color) sg2d.paint; 541 int rgb = color.getRGB(); 542 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorSimple) || (rgb != this.lastPaintRGB)) { 543 this.lastPaintRGB = rgb; 544 550 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 551 } 552 } else if (sg2d.paint instanceof GradientPaint) { 553 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorGradient) || (lastPaint != sg2d.paint)) { 554 GradientPaint color = (GradientPaint) sg2d.paint; 555 this.fGraphicsStatesInt.put(kColorStateIndex, kColorGradient); 556 this.fGraphicsStatesInt.put(kColorRGBValue1Index, color.getColor1().getRGB()); 557 this.fGraphicsStatesInt.put(kColorRGBValue2Index, color.getColor2().getRGB()); 558 this.fGraphicsStatesInt.put(kColorIsCyclicIndex, (color.isCyclic()) ? kColorCyclic : kColorNonCyclic); 559 Point2D p = color.getPoint1(); 560 this.fGraphicsStatesFloat.put(kColorx1Index, (float) p.getX()); 561 this.fGraphicsStatesFloat.put(kColory1Index, (float) p.getY()); 562 p = color.getPoint2(); 563 this.fGraphicsStatesFloat.put(kColorx2Index, (float) p.getX()); 564 this.fGraphicsStatesFloat.put(kColory2Index, (float) p.getY()); 565 566 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 567 } else { 568 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 569 } 570 } else if (sg2d.paint instanceof TexturePaint) { 571 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint)) { 572 TexturePaint color = (TexturePaint) sg2d.paint; 573 this.fGraphicsStatesInt.put(kColorStateIndex, kColorTexture); 574 texturePaintImage = color.getImage(); 575 SurfaceData textureSurfaceData = BufImgSurfaceData.createData(texturePaintImage); 576 this.fGraphicsStatesInt.put(kColorWidthIndex, texturePaintImage.getWidth()); 577 this.fGraphicsStatesInt.put(kColorHeightIndex, texturePaintImage.getHeight()); 578 Rectangle2D anchor = color.getAnchorRect(); 579 this.fGraphicsStatesFloat.put(kColortxIndex, (float) anchor.getX()); 580 this.fGraphicsStatesFloat.put(kColortyIndex, (float) anchor.getY()); 581 this.fGraphicsStatesFloat.put(kColorsxIndex, (float) (anchor.getWidth() / texturePaintImage.getWidth())); 582 this.fGraphicsStatesFloat.put(kColorsyIndex, (float) (anchor.getHeight() / texturePaintImage.getHeight())); 583 this.fGraphicsStatesObject[kTextureImageIndex] = textureSurfaceData; 584 585 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 586 } else { 587 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 588 } 589 } else { 590 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint) || ((this.fChangeFlag & kBoundsChangedBit) != 0)) { 591 PaintContext context = sg2d.paint.createContext(sg2d.getDeviceColorModel(), userBounds, userBounds, sIdentityMatrix, sg2d.getRenderingHints()); 592 WritableRaster raster = (WritableRaster) (context.getRaster(userBounds.x, userBounds.y, userBounds.width, userBounds.height)); 593 ColorModel cm = context.getColorModel(); 594 texturePaintImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); 595 596 this.fGraphicsStatesInt.put(kColorStateIndex, kColorTexture); 597 this.fGraphicsStatesInt.put(kColorWidthIndex, texturePaintImage.getWidth()); 598 this.fGraphicsStatesInt.put(kColorHeightIndex, texturePaintImage.getHeight()); 599 this.fGraphicsStatesFloat.put(kColortxIndex, (float) userBounds.getX()); 600 this.fGraphicsStatesFloat.put(kColortyIndex, (float) userBounds.getY()); 601 this.fGraphicsStatesFloat.put(kColorsxIndex, 1.0f); 602 this.fGraphicsStatesFloat.put(kColorsyIndex, 1.0f); 603 this.fGraphicsStatesObject[kTextureImageIndex] = sun.awt.image.BufImgSurfaceData.createData(texturePaintImage); 604 605 context.dispose(); 606 607 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 608 } else { 609 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 610 } 611 } 612 lastPaint = sg2d.paint; 613 } 614 615 Composite lastComposite; 616 int lastCompositeAlphaRule = 0; 617 float lastCompositeAlphaValue = 0; 618 619 void setupComposite(SunGraphics2D sg2d) { 620 Composite composite = sg2d.composite; 621 622 if (lastComposite != composite) { 623 lastComposite = composite; 624 625 // For composite state COMP_ISCOPY, COMP_XOR or COMP_CUSTOM set alpha compositor to COPY: 626 int alphaRule = AlphaComposite.SRC_OVER; 627 float alphaValue = 1.0f; 628 629 // For composite state COMP_ISCOPY composite could be null. If it's not (or composite state == COMP_ALPHA) 630 // get alpha compositor's values: | 57 sQuartzPipe = new CRenderer(); // Creates the singleton quartz pipe. 58 } 59 60 // NOTE: Any subclasses must eventually call QuartzSurfaceData_InitOps in OSXSurfaceData.h 61 // This sets up the native side for the SurfaceData, and is required. 62 public OSXSurfaceData(SurfaceType sType, ColorModel cm) { 63 this(sType, cm, null, new Rectangle()); 64 } 65 66 public OSXSurfaceData(SurfaceType sType, ColorModel cm, GraphicsConfiguration config, Rectangle bounds) { 67 super(sType, cm); 68 69 this.fConfig = config; 70 71 this.fBounds = new Rectangle(bounds.x, bounds.y, bounds.width, bounds.y + bounds.height); 72 73 this.fGraphicsStates = getBufferOfSize(kSizeOfParameters); 74 this.fGraphicsStatesInt = this.fGraphicsStates.asIntBuffer(); 75 this.fGraphicsStatesFloat = this.fGraphicsStates.asFloatBuffer(); 76 this.fGraphicsStatesLong = this.fGraphicsStates.asLongBuffer(); 77 this.fGraphicsStatesObject = new Object[8]; // clip coordinates + 78 // clip types + 79 // texture paint image + 80 // stroke dash array + 81 // font + font paint + 82 // linear/radial gradient color + 83 // linear/radial gradient fractions 84 85 // NOTE: All access to the DrawingQueue comes through this OSXSurfaceData instance. Therefore 86 // every instance method of OSXSurfaceData that accesses the fDrawingQueue is synchronized. 87 88 // Thread.dumpStack(); 89 } 90 91 public void validatePipe(SunGraphics2D sg2d) { 92 93 if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) { 94 if (sCocoaTextPipe == null) { 95 sCocoaTextPipe = new CTextPipe(); 96 } 97 98 sg2d.imagepipe = sQuartzPipe; 99 sg2d.drawpipe = sQuartzPipe; 100 sg2d.fillpipe = sQuartzPipe; 101 sg2d.shapepipe = sQuartzPipe; 102 sg2d.textpipe = sCocoaTextPipe; 103 } else { 280 @Native static final int kColortyIndex = 32; 281 @Native static final int kColorx2Index = 33; 282 @Native static final int kColorsxIndex = 34; 283 @Native static final int kColory2Index = 35; 284 @Native static final int kColorsyIndex = 36; 285 // composite info 286 @Native static final int kCompositeRuleIndex = 37; // kCGCompositeClear or ... or kCGCompositeXor 287 @Native static final int kCompositeValueIndex = 38; 288 // stroke info 289 @Native static final int kStrokeJoinIndex = 39; // see BasicStroke.java 290 @Native static final int kStrokeCapIndex = 40; // see BasicStroke.java 291 @Native static final int kStrokeWidthIndex = 41; 292 @Native static final int kStrokeDashPhaseIndex = 42; 293 @Native static final int kStrokeLimitIndex = 43; 294 // hints info 295 @Native static final int kHintsAntialiasIndex = 44; 296 @Native static final int kHintsTextAntialiasIndex = 45; 297 @Native static final int kHintsFractionalMetricsIndex = 46; 298 @Native static final int kHintsRenderingIndex = 47; 299 @Native static final int kHintsInterpolationIndex = 48; 300 //gradient info 301 @Native static final int kRadiusIndex = 49; 302 303 @Native static final int kSizeOfParameters = kRadiusIndex + 1; 304 305 // for objectParameters 306 @Native static final int kClipCoordinatesIndex = 0; 307 @Native static final int kClipTypesIndex = 1; 308 @Native static final int kTextureImageIndex = 2; 309 @Native static final int kStrokeDashArrayIndex = 3; 310 @Native static final int kFontIndex = 4; 311 @Native static final int kFontPaintIndex = 5; 312 @Native static final int kColorArrayIndex = 6; 313 @Native static final int kFractionsArrayIndex = 7; 314 315 // possible state changes 316 @Native static final int kBoundsChangedBit = 1 << 0; 317 @Native static final int kBoundsNotChangedBit = ~kBoundsChangedBit; 318 @Native static final int kClipChangedBit = 1 << 1; 319 @Native static final int kClipNotChangedBit = ~kClipChangedBit; 320 @Native static final int kCTMChangedBit = 1 << 2; 321 @Native static final int kCTMNotChangedBit = ~kCTMChangedBit; 322 @Native static final int kColorChangedBit = 1 << 3; 323 @Native static final int kColorNotChangedBit = ~kColorChangedBit; 324 @Native static final int kCompositeChangedBit = 1 << 4; 325 @Native static final int kCompositeNotChangedBit = ~kCompositeChangedBit; 326 @Native static final int kStrokeChangedBit = 1 << 5; 327 @Native static final int kStrokeNotChangedBit = ~kStrokeChangedBit; 328 @Native static final int kHintsChangedBit = 1 << 6; 329 @Native static final int kHintsNotChangedBit = ~kHintsChangedBit; 330 @Native static final int kFontChangedBit = 1 << 7; 331 @Native static final int kFontNotChangedBit = ~kFontChangedBit; 332 @Native static final int kEverythingChangedFlag = 0xffffffff; 333 334 // possible color states 335 @Native static final int kColorSimple = 0; 336 @Native static final int kColorSystem = 1; 337 @Native static final int kColorGradient = 2; 338 @Native static final int kColorTexture = 3; 339 @Native static final int kColorLinearGradient = 4; 340 @Native static final int kColorRadialGradient = 5; 341 342 // possible gradient color states 343 @Native static final int kColorNonCyclic = 0; 344 @Native static final int kColorCyclic = 1; 345 346 // possible clip states 347 @Native static final int kClipRect = 0; 348 @Native static final int kClipShape = 1; 349 350 static int getRendererTypeForPrimitive(int primitiveType) { 351 switch (primitiveType) { 352 case kImage: 353 return kImage; 354 case kCopyArea: 355 return kCopyArea; 356 case kExternal: 357 return kExternal; 358 case kString: 359 case kGlyphs: 360 case kUnicodes: 514 lastCTMa = a; 515 lastCTMb = b; 516 lastCTMc = c; 517 lastCTMd = d; 518 lastCTMtx = tx; 519 lastCTMty = ty; 520 521 this.fChangeFlag = (this.fChangeFlag | kCTMChangedBit); 522 } else { 523 this.fChangeFlag = (this.fChangeFlag & kCTMNotChangedBit); 524 } 525 } 526 527 static AffineTransform sIdentityMatrix = new AffineTransform(); 528 Paint lastPaint = null; 529 long lastPaintPtr = 0; 530 int lastPaintRGB = 0; 531 int lastPaintIndex = 0; 532 BufferedImage texturePaintImage = null; 533 534 void setGradientViaRasterPath(SunGraphics2D sg2d) { 535 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint) || ((this.fChangeFlag & kBoundsChangedBit) != 0)) { 536 PaintContext context = sg2d.paint.createContext(sg2d.getDeviceColorModel(), userBounds, userBounds, sIdentityMatrix, sg2d.getRenderingHints()); 537 WritableRaster raster = (WritableRaster) (context.getRaster(userBounds.x, userBounds.y, userBounds.width, userBounds.height)); 538 ColorModel cm = context.getColorModel(); 539 texturePaintImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null); 540 541 this.fGraphicsStatesInt.put(kColorStateIndex, kColorTexture); 542 this.fGraphicsStatesInt.put(kColorWidthIndex, texturePaintImage.getWidth()); 543 this.fGraphicsStatesInt.put(kColorHeightIndex, texturePaintImage.getHeight()); 544 this.fGraphicsStatesFloat.put(kColortxIndex, (float) userBounds.getX()); 545 this.fGraphicsStatesFloat.put(kColortyIndex, (float) userBounds.getY()); 546 this.fGraphicsStatesFloat.put(kColorsxIndex, 1.0f); 547 this.fGraphicsStatesFloat.put(kColorsyIndex, 1.0f); 548 this.fGraphicsStatesObject[kTextureImageIndex] = OSXOffScreenSurfaceData.createNewSurface(texturePaintImage); 549 550 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 551 } else { 552 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 553 } 554 } 555 556 void setupPaint(SunGraphics2D sg2d, int x, int y, int w, int h) { 557 if (sg2d.paint instanceof SystemColor) { 558 SystemColor color = (SystemColor) sg2d.paint; 559 int index = color.hashCode(); // depends on Color.java hashCode implementation! (returns "value" of color) 560 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorSystem) || (index != this.lastPaintIndex)) { 561 this.lastPaintIndex = index; 562 563 this.fGraphicsStatesInt.put(kColorStateIndex, kColorSystem); 564 this.fGraphicsStatesInt.put(kColorIndexValueIndex, index); 565 566 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 567 } else { 568 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 569 } 570 } else if (sg2d.paint instanceof Color) { 571 Color color = (Color) sg2d.paint; 572 int rgb = color.getRGB(); 573 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorSimple) || (rgb != this.lastPaintRGB)) { 574 this.lastPaintRGB = rgb; 575 581 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 582 } 583 } else if (sg2d.paint instanceof GradientPaint) { 584 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorGradient) || (lastPaint != sg2d.paint)) { 585 GradientPaint color = (GradientPaint) sg2d.paint; 586 this.fGraphicsStatesInt.put(kColorStateIndex, kColorGradient); 587 this.fGraphicsStatesInt.put(kColorRGBValue1Index, color.getColor1().getRGB()); 588 this.fGraphicsStatesInt.put(kColorRGBValue2Index, color.getColor2().getRGB()); 589 this.fGraphicsStatesInt.put(kColorIsCyclicIndex, (color.isCyclic()) ? kColorCyclic : kColorNonCyclic); 590 Point2D p = color.getPoint1(); 591 this.fGraphicsStatesFloat.put(kColorx1Index, (float) p.getX()); 592 this.fGraphicsStatesFloat.put(kColory1Index, (float) p.getY()); 593 p = color.getPoint2(); 594 this.fGraphicsStatesFloat.put(kColorx2Index, (float) p.getX()); 595 this.fGraphicsStatesFloat.put(kColory2Index, (float) p.getY()); 596 597 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 598 } else { 599 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 600 } 601 } else if (sg2d.paint instanceof LinearGradientPaint) { 602 LinearGradientPaint color = (LinearGradientPaint) sg2d.paint; 603 if (color.getCycleMethod() == LinearGradientPaint.CycleMethod.NO_CYCLE) { 604 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorLinearGradient) || (lastPaint != sg2d.paint)) { 605 606 this.fGraphicsStatesInt.put(kColorStateIndex, kColorLinearGradient); 607 int numColor = color.getColors().length; 608 int colorArray[] = new int[numColor]; 609 for (int i = 0; i < numColor; i++) { 610 colorArray[i] = color.getColors()[i].getRGB(); 611 } 612 this.fGraphicsStatesObject[kColorArrayIndex] = colorArray; 613 614 int numFractions = color.getFractions().length; 615 float fractionArray[] = new float[numFractions]; 616 for (int i = 0; i < numFractions; i++) { 617 fractionArray[i] = color.getFractions()[i]; 618 } 619 this.fGraphicsStatesObject[kFractionsArrayIndex] = color.getFractions(); 620 621 Point2D p = color.getStartPoint(); 622 this.fGraphicsStatesFloat.put(kColorx1Index, (float) p.getX()); 623 this.fGraphicsStatesFloat.put(kColory1Index, (float) p.getY()); 624 p = color.getEndPoint(); 625 this.fGraphicsStatesFloat.put(kColorx2Index, (float) p.getX()); 626 this.fGraphicsStatesFloat.put(kColory2Index, (float) p.getY()); 627 628 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 629 } else { 630 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 631 } 632 } else { 633 setGradientViaRasterPath(sg2d); 634 } 635 } else if (sg2d.paint instanceof RadialGradientPaint) { 636 RadialGradientPaint color = (RadialGradientPaint) sg2d.paint; 637 if (color.getCycleMethod() == RadialGradientPaint.CycleMethod.NO_CYCLE) { 638 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorRadialGradient) || (lastPaint != sg2d.paint)) { 639 640 this.fGraphicsStatesInt.put(kColorStateIndex, kColorRadialGradient); 641 int numColor = color.getColors().length; 642 int colorArray[] = new int[numColor]; 643 for (int i = 0; i < numColor; i++) { 644 colorArray[i] = color.getColors()[i].getRGB(); 645 } 646 this.fGraphicsStatesObject[kColorArrayIndex] = colorArray; 647 648 int numStops = color.getFractions().length; 649 float stopsArray[] = new float[numStops]; 650 for (int i = 0; i < numStops; i++) { 651 stopsArray[i] = color.getFractions()[i]; 652 } 653 this.fGraphicsStatesObject[kFractionsArrayIndex] = color.getFractions(); 654 655 Point2D p = color.getFocusPoint(); 656 this.fGraphicsStatesFloat.put(kColorx1Index, (float) p.getX()); 657 this.fGraphicsStatesFloat.put(kColory1Index, (float) p.getY()); 658 p = color.getCenterPoint(); 659 this.fGraphicsStatesFloat.put(kColorx2Index, (float) p.getX()); 660 this.fGraphicsStatesFloat.put(kColory2Index, (float) p.getY()); 661 this.fGraphicsStatesFloat.put(kRadiusIndex, color.getRadius()); 662 663 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 664 } else { 665 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 666 } 667 } else { 668 setGradientViaRasterPath(sg2d); 669 } 670 } else if (sg2d.paint instanceof TexturePaint) { 671 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint)) { 672 TexturePaint color = (TexturePaint) sg2d.paint; 673 this.fGraphicsStatesInt.put(kColorStateIndex, kColorTexture); 674 texturePaintImage = color.getImage(); 675 SurfaceData textureSurfaceData = BufImgSurfaceData.createData(texturePaintImage); 676 this.fGraphicsStatesInt.put(kColorWidthIndex, texturePaintImage.getWidth()); 677 this.fGraphicsStatesInt.put(kColorHeightIndex, texturePaintImage.getHeight()); 678 Rectangle2D anchor = color.getAnchorRect(); 679 this.fGraphicsStatesFloat.put(kColortxIndex, (float) anchor.getX()); 680 this.fGraphicsStatesFloat.put(kColortyIndex, (float) anchor.getY()); 681 this.fGraphicsStatesFloat.put(kColorsxIndex, (float) (anchor.getWidth() / texturePaintImage.getWidth())); 682 this.fGraphicsStatesFloat.put(kColorsyIndex, (float) (anchor.getHeight() / texturePaintImage.getHeight())); 683 this.fGraphicsStatesObject[kTextureImageIndex] = textureSurfaceData; 684 685 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 686 } else { 687 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 688 } 689 } else { 690 setGradientViaRasterPath(sg2d); 691 } 692 lastPaint = sg2d.paint; 693 } 694 695 Composite lastComposite; 696 int lastCompositeAlphaRule = 0; 697 float lastCompositeAlphaValue = 0; 698 699 void setupComposite(SunGraphics2D sg2d) { 700 Composite composite = sg2d.composite; 701 702 if (lastComposite != composite) { 703 lastComposite = composite; 704 705 // For composite state COMP_ISCOPY, COMP_XOR or COMP_CUSTOM set alpha compositor to COPY: 706 int alphaRule = AlphaComposite.SRC_OVER; 707 float alphaValue = 1.0f; 708 709 // For composite state COMP_ISCOPY composite could be null. If it's not (or composite state == COMP_ALPHA) 710 // get alpha compositor's values: |