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 { 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: 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 { | 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 gradient color + 83 // linear 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 { 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 // live resizing info 301 @Native static final int kCanDrawDuringLiveResizeIndex = 49; 302 303 @Native static final int kSizeOfParameters = kCanDrawDuringLiveResizeIndex + 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 kColorLinearOrRadialGradient = 4; 340 341 // possible gradient color states 342 @Native static final int kColorNonCyclic = 0; 343 @Native static final int kColorCyclic = 1; 344 345 // possible clip states 346 @Native static final int kClipRect = 0; 347 @Native static final int kClipShape = 1; 348 349 static int getRendererTypeForPrimitive(int primitiveType) { 350 switch (primitiveType) { 351 case kImage: 352 return kImage; 353 case kCopyArea: 354 return kCopyArea; 355 case kExternal: 356 return kExternal; 357 case kString: 358 case kGlyphs: 359 case kUnicodes: 558 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 559 } 560 } else if (sg2d.paint instanceof GradientPaint) { 561 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorGradient) || (lastPaint != sg2d.paint)) { 562 GradientPaint color = (GradientPaint) sg2d.paint; 563 this.fGraphicsStatesInt.put(kColorStateIndex, kColorGradient); 564 this.fGraphicsStatesInt.put(kColorRGBValue1Index, color.getColor1().getRGB()); 565 this.fGraphicsStatesInt.put(kColorRGBValue2Index, color.getColor2().getRGB()); 566 this.fGraphicsStatesInt.put(kColorIsCyclicIndex, (color.isCyclic()) ? kColorCyclic : kColorNonCyclic); 567 Point2D p = color.getPoint1(); 568 this.fGraphicsStatesFloat.put(kColorx1Index, (float) p.getX()); 569 this.fGraphicsStatesFloat.put(kColory1Index, (float) p.getY()); 570 p = color.getPoint2(); 571 this.fGraphicsStatesFloat.put(kColorx2Index, (float) p.getX()); 572 this.fGraphicsStatesFloat.put(kColory2Index, (float) p.getY()); 573 574 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 575 } else { 576 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 577 } 578 } else if (sg2d.paint instanceof LinearGradientPaint) { 579 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorGradient) || (lastPaint != sg2d.paint)) { 580 LinearGradientPaint color = (LinearGradientPaint) sg2d.paint; 581 this.fGraphicsStatesInt.put(kColorStateIndex, kColorLinearOrRadialGradient); 582 int numColor = color.getColors().length; 583 int colorArray[] = new int[numColor]; 584 for (int i = 0; i < numColor; i++) { 585 colorArray[i] = color.getColors()[i].getRGB(); 586 } 587 this.fGraphicsStatesObject[kColorArrayIndex] = colorArray; 588 589 int numFractions = color.getFractions().length; 590 float fractionArray[] = new float[numFractions]; 591 for (int i = 0; i < numFractions; i++) { 592 fractionArray[i] = color.getFractions()[i]; 593 } 594 this.fGraphicsStatesObject[kFractionsArrayIndex] = color.getFractions(); 595 596 this.fGraphicsStatesInt.put(kColorIsCyclicIndex, (color.getCycleMethod() == LinearGradientPaint.CycleMethod.NO_CYCLE) ? kColorNonCyclic : kColorCyclic); 597 Point2D p = color.getStartPoint(); 598 this.fGraphicsStatesFloat.put(kColorx1Index, (float) p.getX()); 599 this.fGraphicsStatesFloat.put(kColory1Index, (float) p.getY()); 600 p = color.getEndPoint(); 601 this.fGraphicsStatesFloat.put(kColorx2Index, (float) p.getX()); 602 this.fGraphicsStatesFloat.put(kColory2Index, (float) p.getY()); 603 604 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 605 } else { 606 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 607 } 608 } else if (sg2d.paint instanceof TexturePaint) { 609 if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint)) { 610 TexturePaint color = (TexturePaint) sg2d.paint; 611 this.fGraphicsStatesInt.put(kColorStateIndex, kColorTexture); 612 texturePaintImage = color.getImage(); 613 SurfaceData textureSurfaceData = BufImgSurfaceData.createData(texturePaintImage); 614 this.fGraphicsStatesInt.put(kColorWidthIndex, texturePaintImage.getWidth()); 615 this.fGraphicsStatesInt.put(kColorHeightIndex, texturePaintImage.getHeight()); 616 Rectangle2D anchor = color.getAnchorRect(); 617 this.fGraphicsStatesFloat.put(kColortxIndex, (float) anchor.getX()); 618 this.fGraphicsStatesFloat.put(kColortyIndex, (float) anchor.getY()); 619 this.fGraphicsStatesFloat.put(kColorsxIndex, (float) (anchor.getWidth() / texturePaintImage.getWidth())); 620 this.fGraphicsStatesFloat.put(kColorsyIndex, (float) (anchor.getHeight() / texturePaintImage.getHeight())); 621 this.fGraphicsStatesObject[kTextureImageIndex] = textureSurfaceData; 622 623 this.fChangeFlag = (this.fChangeFlag | kColorChangedBit); 624 } else { 625 this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit); 626 } 627 } else { |