/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This is the SurfaceData for a CGContextRef.
*/
static {
}
// NOTE: Any subclasses must eventually call QuartzSurfaceData_InitOps in OSXSurfaceData.h
// This sets up the native side for the SurfaceData, and is required.
}
public OSXSurfaceData(SurfaceType sType, ColorModel cm, GraphicsConfiguration config, Rectangle bounds) {
this.fGraphicsStatesObject = new Object[6]; // clip coordinates + clip types + texture paint image + stroke dash
// array + font + font paint
// NOTE: All access to the DrawingQueue comes through this OSXSurfaceData instance. Therefore
// every instance method of OSXSurfaceData that accesses the fDrawingQueue is synchronized.
// Thread.dumpStack();
}
if (sCocoaTextPipe == null) {
sCocoaTextPipe = new CTextPipe();
}
} else {
}
}
if (sQuartzCompositePipe == null) {
sQuartzCompositePipe = new CompositeCRenderer();
}
if (sCocoaTextPipe == null) {
sCocoaTextPipe = new CTextPipe();
}
}
// gznote: always return a copy, not the rect itself and translate into device space
}
return fConfig;
}
protected void setBounds(int x, int y, int w, int h) {
}
// START compositing support API
public abstract BufferedImage copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, BufferedImage image);
public abstract boolean xorSurfacePixels(SunGraphics2D sg2d, BufferedImage srcPixels, int x, int y, int w, int h, int colorXOR);
if (sDefaultGraphicsConfiguration == null) {
sDefaultGraphicsConfiguration = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
// clear the image.
return img;
}
img = getCompositingImage(w, h);
}
return img;
}
// <rdar://problem/3720263>. Changed from getCompositingImageBiggerOrSame() to
// getCompositingImageSame(). (vm)
sSrcComposite = bim;
return bim;
}
return bim;
}
return bim;
}
g.dispose();
}
// END compositing support API
public void invalidate() {
// always valid
}
// graphics primitives drawing implementation:
// certain primitives don't care about all the states (ex. drawing an image needs not involve setting current paint)
// static final int kImage = 12; // belongs to kImage
// static final int kCopyArea = 16; // belongs to kCopyArea
// static final int kExternal = 17; // belongs to kExternal
static final int kCommonParameterCount = 1 + 1 + 4 + 4; // type + change flags + color info (type(1) align(1) and
// value(2)) + parameters ((x1, y1, x2, y2) OR (x, y, w, h))
static final int kRectParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
static final int kRoundRectParametersCount = kCommonParameterCount + 2 + 1; // kCommonParameterCount + arcW + arcH +
// isfill
static final int kOvalParametersCount = kCommonParameterCount + 1; // kCommonParameterCount + isfill
static final int kArcParametersCount = kCommonParameterCount + 2 + 1 + 1;// kCommonParameterCount + startAngle +
// arcAngle + isfill + type
static final int kImageParametersCount = kCommonParameterCount + 2 + 2 + 4 + 4; // flip horz vert + w&h + src + dst
// for intParameters
// states info
// bounds info
// clip info
// ctm info
// color info
// composite info
// stroke info
// hints info
// live resizing info
// for objectParameters
// possible state changes
// possible color states
// possible gradient color states
// possible clip states
switch (primitiveType) {
case kImage:
return kImage;
case kCopyArea:
return kCopyArea;
case kExternal:
return kExternal;
case kString:
case kGlyphs:
case kUnicodes:
return kText;
default:
return kPrimitive;
}
}
int fChangeFlag;
lastUserX = x;
lastUserY = y;
} else {
}
}
return buffer;
}
case SunGraphics2D.CLIP_DEVICE:
case SunGraphics2D.CLIP_RECTANGULAR: {
(x != lastClipX) ||
(y != lastClipY) ||
(w != lastClipW) ||
(h != lastClipH)) {
lastClipX = x;
lastClipY = y;
lastClipW = w;
lastClipH = h;
} else {
}
break;
}
case SunGraphics2D.CLIP_SHAPE: {
// if (lastClipShape != sg2d.usrClip) shapes are mutable!, and doing "equals" traverses all
// the coordinates, so we might as well do all of it anyhow
} else {
}
// max of 6 coordinates
}
}
break;
}
}
}
float a = (float) lastCTM[0];
float b = (float) lastCTM[1];
float c = (float) lastCTM[2];
float d = (float) lastCTM[3];
a != lastCTMa ||
b != lastCTMb ||
c != lastCTMc ||
d != lastCTMd) {
lastCTMa = a;
lastCTMb = b;
lastCTMc = c;
lastCTMd = d;
} else {
}
}
int index = color.hashCode(); // depends on Color.java hashCode implementation! (returns "value" of color)
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorSystem) || (index != this.lastPaintIndex)) {
this.lastPaintIndex = index;
} else {
}
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorSimple) || (rgb != this.lastPaintRGB)) {
this.lastPaintRGB = rgb;
} else {
}
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorGradient) || (lastPaint != sg2d.paint)) {
this.fGraphicsStatesInt.put(kColorIsCyclicIndex, (color.isCyclic()) ? kColorCyclic : kColorNonCyclic);
} else {
}
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint)) {
this.fGraphicsStatesFloat.put(kColorsxIndex, (float) (anchor.getWidth() / texturePaintImage.getWidth()));
this.fGraphicsStatesFloat.put(kColorsyIndex, (float) (anchor.getHeight() / texturePaintImage.getHeight()));
} else {
}
} else {
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint) || ((this.fChangeFlag & kBoundsChangedBit) != 0)) {
PaintContext context = sg2d.paint.createContext(sg2d.getDeviceColorModel(), userBounds, userBounds, sIdentityMatrix, sg2d.getRenderingHints());
WritableRaster raster = (WritableRaster) (context.getRaster(userBounds.x, userBounds.y, userBounds.width, userBounds.height));
this.fGraphicsStatesObject[kTextureImageIndex] = sun.awt.image.BufImgSurfaceData.createData(texturePaintImage);
} else {
}
}
}
if (lastComposite != composite) {
// For composite state COMP_ISCOPY, COMP_XOR or COMP_CUSTOM set alpha compositor to COPY:
float alphaValue = 1.0f;
// For composite state COMP_ISCOPY composite could be null. If it's not (or composite state == COMP_ALPHA)
// get alpha compositor's values:
}
// 2-17-03 VL: [Radar 3174922]
// For COMP_XOR and COMP_CUSTOM compositing modes we should be setting alphaRule = AlphaComposite.SRC
// which should map to kCGCompositeCopy.
} else {
}
} else {
}
}
}
if (lastStroke != stroke) {
lastStroke = stroke;
} else {
}
}
// We have to setup the kFontPaintIndex if we have changed the color so we added the last
// test to see if the color has changed - needed for complex strings
// see Radar 3368674
} else {
}
}
boolean hintsChanged = false;
// Significant for draw, fill, text, and image ops:
hintsChanged = true;
}
// Significant only for text ops:
hintsChanged = true;
}
// Significant only for text ops:
hintsChanged = true;
}
// Significant only for image ops:
hintsChanged = true;
}
// Significant only for image ops:
hintsChanged = true;
}
if (hintsChanged) {
} else {
}
}
setupGraphicsState(sg2d, primitiveType, sg2d.font, 0, 0, fBounds.width, fBounds.height); // deviceBounds into userBounds
}
}
// the method below is overriden by CPeerSurface to check the last peer used to draw
// if the peer changed we finish lazy drawing
void setupGraphicsState(SunGraphics2D sg2d, int primitiveType, Font font, int x, int y, int w, int h) {
this.fChangeFlag = 0;
setUserBounds(sg2d, x, y, w, h);
this.sg2dCurrent = sg2d;
this.threadCurrent = thread;
setupPaint(sg2d, x, y, w, h);
this.fChangeFlag = kEverythingChangedFlag;
} else {
if (rendererType != kCopyArea) {
if ((rendererType != kImage)) {
setupPaint(sg2d, x, y, w, h);
}
if (rendererType != kPrimitive) {
}
}
}
}
if ((sg2d.paint instanceof Color) || (sg2d.paint instanceof SystemColor) || (sg2d.paint instanceof GradientPaint) || (sg2d.paint instanceof TexturePaint)) { return false; }
return true;
}
int length = 0;
length++;
}
return length;
}
// System.err.println("getPathCoordinates");
boolean skip = false;
coordinates.clear();
int type;
skip = false;
switch (type) {
case PathIterator.SEG_MOVETO:
// System.err.println(" SEG_MOVETO ("+segmentCoordinatesArray[0]+", "+segmentCoordinatesArray[1]+")");
} else {
skip = true;
}
break;
case PathIterator.SEG_LINETO:
// System.err.println(" SEG_LINETO ("+segmentCoordinatesArray[0]+", "+segmentCoordinatesArray[1]+")");
} else {
skip = true;
}
break;
case PathIterator.SEG_QUADTO:
// System.err.println(" SEG_QUADTO ("+segmentCoordinatesArray[0]+", "+segmentCoordinatesArray[1]+"), ("+segmentCoordinatesArray[2]+", "+segmentCoordinatesArray[3]+")");
} else {
skip = true;
}
break;
case PathIterator.SEG_CUBICTO:
// System.err.println(" SEG_QUADTO ("+segmentCoordinatesArray[0]+", "+segmentCoordinatesArray[1]+"), ("+segmentCoordinatesArray[2]+", "+segmentCoordinatesArray[3]+"), ("+segmentCoordinatesArray[4]+", "+segmentCoordinatesArray[5]+")");
} else {
skip = true;
}
break;
case PathIterator.SEG_CLOSE:
// System.err.println(" SEG_CLOSE");
break;
}
if (!skip) {
}
}
return pi.getWindingRule();
}
public void doLine(CRenderer renderer, SunGraphics2D sg2d, float x1, float y1, float x2, float y2) {
// System.err.println("-- doLine x1="+x1+" y1="+y1+" x2="+x2+" y2="+y2+" paint="+sg2d.paint);
}
public void doRect(CRenderer renderer, SunGraphics2D sg2d, float x, float y, float width, float height, boolean isfill) {
// System.err.println("-- doRect x="+x+" y="+y+" w="+width+" h="+height+" isfill="+isfill+" paint="+sg2d.paint);
} else {
}
}
public void doRoundRect(CRenderer renderer, SunGraphics2D sg2d, float x, float y, float width, float height, float arcW, float arcH, boolean isfill) {
// System.err.println("--- doRoundRect");
} else {
}
}
public void doOval(CRenderer renderer, SunGraphics2D sg2d, float x, float y, float width, float height, boolean isfill) {
// System.err.println("--- doOval");
} else {
}
}
public void doArc(CRenderer renderer, SunGraphics2D sg2d, float x, float y, float width, float height, float startAngle, float arcAngle, int type, boolean isfill) {
// System.err.println("--- doArc");
} else {
}
}
public void doPolygon(CRenderer renderer, SunGraphics2D sg2d, int xpoints[], int ypoints[], int npoints, boolean ispolygon, boolean isfill) {
// System.err.println("--- doPolygon");
for (int i = 1; i < npoints; i++) {
int x = xpoints[i];
if (x < minx) {
minx = x;
} else if (x > maxx) {
maxx = x;
}
int y = ypoints[i];
if (y < miny) {
miny = y;
} else if (y > maxy) {
maxy = y;
}
}
} else {
}
}
public void drawfillShape(CRenderer renderer, SunGraphics2D sg2d, GeneralPath gp, boolean isfill, boolean shouldApplyOffset) {
// System.err.println("--- drawfillShape");
} else {
}
shapeCoordinatesArray = getBufferOfSize(shapeLength * 6).asFloatBuffer(); // segment can have a max of 6
// coordinates
}
}
renderer.doShape(this, shapeLength, shapeCoordinatesArray, shapeTypesArray, windingRule, isfill, shouldApplyOffset);
}
public void blitImage(CRenderer renderer, SunGraphics2D sg2d, SurfaceData img, boolean fliph, boolean flipv, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, Color bgColor) {
// System.err.println("--- blitImage sx="+sx+", sy="+sy+", sw="+sw+", sh="+sh+", img="+img);
synchronized (osxsd.getLockObject()) {
// the image itself can have outstanding graphics primitives that might need to be flushed
// 04/06/04 cmc: radr://3612381 Graphics.drawImage ignores bgcolor parameter
}
}
}
public interface CGContextDrawable {
}
public void drawString(CTextPipe renderer, SunGraphics2D sg2d, long nativeStrikePtr, String str, double x, double y) {
// System.err.println("--- drawString str=\""+str+"\"");
// see <rdar://problem/3825795>. We don't want to call anything if the string is empty!
}
public void drawGlyphs(CTextPipe renderer, SunGraphics2D sg2d, long nativeStrikePtr, GlyphVector gv, float x, float y) {
// System.err.println("--- drawGlyphs");
}
public void drawUnicodes(CTextPipe renderer, SunGraphics2D sg2d, long nativeStrikePtr, char unicodes[], int offset, int length, float x, float y) {
// System.err.println("--- drawUnicodes "+(new String(unicodes, offset, length)));
if (length == 1) {
} else {
}
}
// used by copyArea:
// this code is taken from Rectangle.java (modified to put results in r3)
// tx2,ty2 will never overflow (they will never be
// larger than the smallest of the two source w,h)
// they might underflow, though...
}
/**
* Clips the copy area to the heavywieght bounds and returns the cliped rectangle. The tricky part here is the the
* passed arguments x, y are in the coordinate space of the sg2d/lightweight comp. In order to do the clipping we
* translate them to the coordinate space of the surface, and the returned clipped rectangle is in the coordinate
* space of the surface.
*/
// we need to clip against the heavyweight bounds
copyAreaBounds.setBounds(sg2d.devClip.getLoX(), sg2d.devClip.getLoY(), sg2d.devClip.getWidth(), sg2d.devClip.getHeight());
// put src rect into surface coordinate space
// clip src rect
srcCopyAreaRect.setBounds(x, y, w, h);
// src rect outside bounds
return null;
}
// clip dst rect
dstCopyAreaRect.setBounds(srcCopyAreaRect.x + dx, srcCopyAreaRect.y + dy, srcCopyAreaRect.width, srcCopyAreaRect.height);
// dst rect outside clip
return null;
}
x = dstCopyAreaRect.x - dx;
y = dstCopyAreaRect.y - dy;
w = dstCopyAreaRect.width;
h = dstCopyAreaRect.height;
finalCopyAreaRect.setBounds(x, y, w, h);
return finalCopyAreaRect;
}
// <rdar://3785539> We only need to mark dirty on screen surfaces. This method is
// marked as protected and it is intended for subclasses to override if they need to
// be notified when the surface is dirtied. See CPeerSurfaceData.markDirty() for implementation.
// We don't do anything for buffered images.
// do nothing by default
}
// LazyDrawing optimization implementation:
// sg2d.surfaceData.getTransparency() == Transparency.OPAQUE &&
// This last test is a workaround until we fix loop selection
// in the pipe validation
return false; /* for now - in the future we may want to search */
}
return ((c instanceof Color) || (c instanceof SystemColor) || (c instanceof javax.swing.plaf.ColorUIResource));
}
static {
}
}
}