/*
* 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.
*/
public class CompositeCRenderer extends CRenderer implements PixelDrawPipe, PixelFillPipe, ShapeDrawPipe, DrawImagePipe, TextPipe {
// create shape corresponding to this primitive
}
// create shape corresponding to this primitive
}
public synchronized void drawRoundRect(SunGraphics2D sg2d, int x, int y, int width, int height, int arcWidth, int arcHeight) {
// create shape corresponding to this primitive
}
// create shape corresponding to this primitive
}
public synchronized void drawArc(SunGraphics2D sg2d, int x, int y, int width, int height, int startAngle, int arcAngle) {
// create shape corresponding to this primitive
}
public synchronized void drawPolyline(SunGraphics2D sg2d, int xpoints[], int ypoints[], int npoints) {
}
public synchronized void drawPolygon(SunGraphics2D sg2d, int xpoints[], int ypoints[], int npoints) {
}
// create shape corresponding to this primitive
}
public synchronized void fillRoundRect(SunGraphics2D sg2d, int x, int y, int width, int height, int arcWidth, int arcHeight) {
// create shape corresponding to this primitive
}
// create shape corresponding to this primitive
}
public synchronized void fillArc(SunGraphics2D sg2d, int x, int y, int width, int height, int startAngle, int arcAngle) {
// create shape corresponding to this primitive
}
public synchronized void fillPolygon(SunGraphics2D sg2d, int xpoints[], int ypoints[], int npoints) {
}
public synchronized void doPolygon(SunGraphics2D sg2d, int xpoints[], int ypoints[], int npoints, boolean ispolygon, boolean isfill) {
for (int i = 1; i < npoints; i++) {
}
if (ispolygon) {
// according to the specs (only applies to polygons, not polylines)
}
}
}
}
}
// We don't want to draw with negative width and height (CRender doesn't do it and Windows doesn't do it either)
// Drawing with negative w and h, can cause CG problems down the line <rdar://3960579> (vm)
// get final destination compositing bounds (after all transformations if needed)
// constrain the bounds to be within surface bounds
// if the compositing region is empty we skip all remaining compositing work:
if (compositingBounds.isEmpty() == false) {
// create a matching surface into which we'll render the primitive to be composited
// with the desired dimension
(int) (compositingBounds.getHeight()));
// sync up graphics state
g.setTransform(ShapeTM);
// render the primitive to be composited
if (isfill) {
} else {
}
g.dispose();
}
}
}
public synchronized void drawChars(SunGraphics2D sg2d, char data[], int offset, int length, int x, int y) {
}
public synchronized void drawGlyphVector(SunGraphics2D sg2d, GlyphVector glyphVector, double x, double y) {
}
public synchronized void drawGlyphVector(SunGraphics2D sg2d, GlyphVector glyphVector, float x, float y) {
// get final destination compositing bounds (after all transformations if needed)
// constrain the bounds to be within surface bounds
// if the compositing region is empty we skip all remaining compositing work:
if (compositingBounds.isEmpty() == false) {
{
// create matching image into which we'll render the primitive to be composited
srcPixels = surfaceData.getCompositingSrcImage((int) compositingBounds.getWidth(), (int) compositingBounds.getHeight());
// sync up graphics state
g.setTransform(ShapeTM);
// render the primitive to be composited
g.drawGlyphVector(glyphVector, x, y);
g.dispose();
}
}
}
protected boolean blitImage(SunGraphics2D sg2d, Image img, boolean fliph, boolean flipv, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, Color bgColor) {
// get final destination compositing bounds (after all transformations if needed)
if (complexTransform == false) {
} else {
}
// constrain the bounds to be within surface bounds
// if the compositing region is empty we skip all remaining compositing work:
if (compositingBounds.isEmpty() == false) {
{
// create matching image into which we'll render the primitive to be composited
srcPixels = surfaceData.getCompositingSrcImage((int) compositingBounds.getWidth(), (int) compositingBounds.getHeight());
// sync up graphics state
g.setTransform(ShapeTM);
g.dispose();
}
}
return true;
}
int paddingHalf = fPaddingHalf;
paddingHalf += widthHalf;
} else {
}
}
bounds.setRect(bounds.getX() - paddingHalf, bounds.getY() - paddingHalf, bounds.getWidth() + padding, bounds.getHeight() + padding);
return bounds;
}
/*
* System.err.println("clipBounds"); System.err.println(" transform="+sg2d.transform);
* System.err.println(" getTransform()="+sg2d.getTransform());
* System.err.println(" complexTransform="+(sg2d.transformState > SunGraphics2D.TRANSFORM_TRANSLATESCALE));
* System.err.println(" transX="+sg2d.transX+" transY="+sg2d.transX);
* System.err.println(" sg2d.constrainClip="+sg2d.constrainClip); if (sg2d.constrainClip != null) {
* System.err
* .println(" constrainClip: x="+sg2d.constrainClip.getLoX()+" y="+sg2d.constrainClip.getLoY()+" w="
* +sg2d.constrainClip.getWidth()+" h="+sg2d.constrainClip.getHeight());}
* System.err.println(" constrainX="+sg2d.constrainX+" constrainY="+sg2d.constrainY);
* System.err.println(" usrClip="+sg2d.usrClip);
* System.err.println(" devClip: x="+sg2d.devClip.getLoX()+" y="
* +sg2d.devClip.getLoY()+" w="+sg2d.devClip.getWidth()+" h="+sg2d.devClip.getHeight());
*/
Region intersection = sg2d.clipRegion.getIntersectionXYWH((int) bounds.getX(), (int) bounds.getY(), (int) bounds.getWidth(), (int) bounds.getHeight());
bounds.setRect(intersection.getLoX(), intersection.getLoY(), intersection.getWidth(), intersection.getHeight());
}
BufferedImage getSurfacePixels(SunGraphics2D sg2d, OSXSurfaceData surfaceData, int x, int y, int w, int h) {
// create an image to copy the surface pixels into
// get the pixels from the dst surface
}
void composite(SunGraphics2D sg2d, OSXSurfaceData surfaceData, BufferedImage srcPixels, Rectangle2D compositingBounds) {
// Thread.dumpStack();
// System.err.println("composite");
// System.err.println(" compositingBounds="+compositingBounds);
int x = (int) compositingBounds.getX();
int y = (int) compositingBounds.getY();
int w = (int) compositingBounds.getWidth();
int h = (int) compositingBounds.getHeight();
boolean succeded = false;
if (composite instanceof XORComposite) {
// 1st native XOR try
// we try to perform XOR using surface pixels directly
try {
succeded = surfaceData.xorSurfacePixels(sg2d, srcPixels, x, y, w, h, ((XORComposite) composite).getXorColor().getRGB());
} catch (Exception e) {
succeded = false;
}
}
if (succeded == false) {
// create image with the original pixels of surface
if (composite instanceof XORComposite) {
// 2nd native XOR try
// we try to perform XOR on image's pixels (which were copied from surface first)
try {
succeded = osxsd.xorSurfacePixels(sg2d, srcPixels, 0, 0, w, h, ((XORComposite) composite).getXorColor().getRGB());
} catch (Exception e) {
succeded = false;
}
}
// either 2nd native XOR failed OR we have a case of custom compositing
if (succeded == false) {
// create an image into which we'll composite result: we MUST use a different destination (compositing
// is NOT "in place" operation)
// prepare rasters for compositing
CompositeContext compositeContext = composite.createContext(srcPixels.getColorModel(), dstOutPixels.getColorModel(), sg2d.getRenderingHints());
// gznote: radar bug number
// "cut out" the shape we're interested in
// applyMask(BufImgSurfaceData.createData(dstOutPixels), BufImgSurfaceData.createData(srcPixels), w, h);
}
// blit the results back to the dst surface
{
// all the compositing is done in the coordinate space of the component. the x and the y are the
// position of that component in the surface
// so we need to set the sg2d.transform to identity and we must set the contrainX/Y to 0 for the
// setTransform() to not be constrained
}
}
}
}