src/solaris/classes/sun/java2d/xr/XRCompositeManager.java

Print this page

        

*** 46,56 **** public class XRCompositeManager { private static boolean enableGradCache = true; private static XRCompositeManager instance; ! XRSurfaceData src; XRSurfaceData texture; XRSurfaceData gradient; int alphaMask = XRUtils.None; XRColor solidColor = new XRColor(); --- 46,61 ---- public class XRCompositeManager { private static boolean enableGradCache = true; private static XRCompositeManager instance; ! private final static int SOLID = 0; ! private final static int TEXTURE = 1; ! private final static int GRADIENT = 2; ! ! int srcType; ! XRSolidSrcPict solidSrc32; XRSurfaceData texture; XRSurfaceData gradient; int alphaMask = XRUtils.None; XRColor solidColor = new XRColor();
*** 82,92 **** return instance; } private XRCompositeManager(XRSurfaceData surface) { con = new XRBackendNative(); - // con = XRBackendJava.getInstance(); String gradProp = AccessController.doPrivileged(new PrivilegedAction<String>() { public String run() { return System.getProperty("sun.java2d.xrgradcache"); --- 87,96 ----
*** 107,124 **** } public void initResources(XRSurfaceData surface) { int parentXid = surface.getXid(); ! int solidPixmap = con.createPixmap(parentXid, 32, 1, 1); ! int solidSrcPictXID = con.createPicture(solidPixmap, ! XRUtils.PictStandardARGB32); ! con.setPictureRepeat(solidSrcPictXID, XRUtils.RepeatNormal); ! con.renderRectangle(solidSrcPictXID, XRUtils.PictOpSrc, ! XRColor.FULL_ALPHA, 0, 0, 1, 1); ! solidSrcPict = new XRSurfaceData.XRInternalSurfaceData(con, ! solidSrcPictXID, null); setForeground(0); int extraAlphaMask = con.createPixmap(parentXid, 8, 1, 1); alphaMaskPict = con.createPicture(extraAlphaMask, XRUtils.PictStandardA8); --- 111,121 ---- } public void initResources(XRSurfaceData surface) { int parentXid = surface.getXid(); ! solidSrc32 = new XRSolidSrcPict(con, parentXid); setForeground(0); int extraAlphaMask = con.createPixmap(parentXid, 8, 1, 1); alphaMaskPict = con.createPicture(extraAlphaMask, XRUtils.PictStandardA8);
*** 133,162 **** XRUtils.PictStandardARGB32); } } public void setForeground(int pixel) { ! solidColor.setColorValues(pixel, false); ! con.renderRectangle(solidSrcPict.picture, XRUtils.PictOpSrc, ! solidColor, 0, 0, 1, 1); } public void setGradientPaint(XRSurfaceData gradient) { if (this.gradient != null) { con.freePicture(this.gradient.picture); } this.gradient = gradient; ! src = gradient; } public void setTexturePaint(XRSurfaceData texture) { this.texture = texture; ! src = texture; } public void XRResetPaint() { ! src = solidSrcPict; } public void validateCompositeState(Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d) { boolean updatePaint = (paint != validatedPaint) || paint == null; --- 130,157 ---- XRUtils.PictStandardARGB32); } } public void setForeground(int pixel) { ! solidColor.setColorValues(pixel, true); } public void setGradientPaint(XRSurfaceData gradient) { if (this.gradient != null) { con.freePicture(this.gradient.picture); } this.gradient = gradient; ! srcType = GRADIENT; } public void setTexturePaint(XRSurfaceData texture) { this.texture = texture; ! this.srcType = TEXTURE; } public void XRResetPaint() { ! srcType = SOLID; } public void validateCompositeState(Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d) { boolean updatePaint = (paint != validatedPaint) || paint == null;
*** 173,183 **** // sure we update the color below updatePaint = true; validatedComp = comp; } ! if (sg2d != null && validatedPixel != sg2d.pixel) { validatedPixel = sg2d.pixel; setForeground(validatedPixel); } // validate paint --- 168,178 ---- // sure we update the color below updatePaint = true; validatedComp = comp; } ! if (sg2d != null && (validatedPixel != sg2d.pixel || updatePaint)) { validatedPixel = sg2d.pixel; setForeground(validatedPixel); } // validate paint
*** 189,206 **** XRResetPaint(); } validatedPaint = paint; } ! if (src != solidSrcPict) { AffineTransform at = (AffineTransform) xform.clone(); try { at.invert(); } catch (NoninvertibleTransformException e) { at.setToIdentity(); } ! src.validateAsSource(at, -1, -1); } } private void setComposite(Composite comp) { if (comp instanceof AlphaComposite) { --- 184,201 ---- XRResetPaint(); } validatedPaint = paint; } ! if (srcType != SOLID) { AffineTransform at = (AffineTransform) xform.clone(); try { at.invert(); } catch (NoninvertibleTransformException e) { at.setToIdentity(); } ! getCurrentSource().validateAsSource(at, -1, -1); } } private void setComposite(Composite comp) { if (comp instanceof AlphaComposite) {
*** 232,248 **** } } public boolean maskRequired() { return (!xorEnabled) ! && ((src != solidSrcPict) ! || (src == solidSrcPict && solidColor.alpha != 0xffff) || (extraAlpha != 1.0f)); } public void XRComposite(int src, int mask, int dst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int width, int height) { ! int cachedSrc = (src == XRUtils.None) ? this.src.picture : src; int cachedX = srcX; int cachedY = srcY; if (enableGradCache && gradient != null && cachedSrc == gradient.picture) { --- 227,243 ---- } } public boolean maskRequired() { return (!xorEnabled) ! && ((srcType != SOLID) ! || (srcType == SOLID && (solidColor.alpha != 0xffff) || (extraAlpha != 1.0f))); } public void XRComposite(int src, int mask, int dst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int width, int height) { ! int cachedSrc = (src == XRUtils.None) ? getCurrentSource().picture : src; int cachedX = srcX; int cachedY = srcY; if (enableGradCache && gradient != null && cachedSrc == gradient.picture) {
*** 274,284 **** renderReferenceX = (int) Math.floor(XRUtils .XFixedToDouble(renderReferenceX)); renderReferenceY = (int) Math.floor(XRUtils .XFixedToDouble(renderReferenceY)); ! con.renderCompositeTrapezoids(compRule, src.picture, XRUtils.PictStandardA8, dst, renderReferenceX, renderReferenceY, trapList); } public void XRRenderRectangles(XRSurfaceData dst, GrowableRectArray rects) { --- 269,279 ---- renderReferenceX = (int) Math.floor(XRUtils .XFixedToDouble(renderReferenceX)); renderReferenceY = (int) Math.floor(XRUtils .XFixedToDouble(renderReferenceY)); ! con.renderCompositeTrapezoids(compRule, getCurrentSource().picture, XRUtils.PictStandardA8, dst, renderReferenceX, renderReferenceY, trapList); } public void XRRenderRectangles(XRSurfaceData dst, GrowableRectArray rects) {
*** 292,310 **** con.renderRectangles(dst.getPicture(), compRule, solidColor, rects); } } } public void compositeBlit(XRSurfaceData src, XRSurfaceData dst, int sx, int sy, int dx, int dy, int w, int h) { con.renderComposite(compRule, src.picture, alphaMask, dst.picture, sx, sy, 0, 0, dx, dy, w, h); } ! public void compositeText(XRSurfaceData dst, int sx, int sy, ! int glyphSet, int maskFormat, GrowableEltArray elts) { ! con.XRenderCompositeText(compRule, src.picture, dst.picture, maskFormat, sx, sy, 0, 0, glyphSet, elts); } public XRColor getMaskColor() { return !isTexturePaintActive() ? XRColor.FULL_ALPHA : getAlphaColor(); --- 287,336 ---- con.renderRectangles(dst.getPicture(), compRule, solidColor, rects); } } } + public void XRCompositeRectangles(XRSurfaceData dst, GrowableRectArray rects) { + int srcPict = getCurrentSource().picture; + + for(int i=0; i < rects.getSize(); i++) { + int x = rects.getX(i); + int y = rects.getY(i); + int width = rects.getWidth(i); + int height = rects.getHeight(i); + + con.renderComposite(compRule, srcPict, XRUtils.None, dst.picture, x, y, 0, 0, x, y, width, height); + } + } + + protected XRSurfaceData getCurrentSource() { + switch(srcType) { + case SOLID: + return solidSrc32.prepareSrcPict(validatedPixel); + case TEXTURE: + return texture; + case GRADIENT: + return gradient; + } + + return null; + } + public void compositeBlit(XRSurfaceData src, XRSurfaceData dst, int sx, int sy, int dx, int dy, int w, int h) { con.renderComposite(compRule, src.picture, alphaMask, dst.picture, sx, sy, 0, 0, dx, dy, w, h); } ! public void compositeText(XRSurfaceData dst, int sx, int sy, int glyphSet, ! int maskFormat, GrowableEltArray elts) { ! /* ! * Try to emulate the SRC blend mode with SRC_OVER. ! * We bail out during pipe validation for cases where this is not possible. ! */ ! byte textCompRule = (compRule != XRUtils.PictOpSrc) ? compRule : XRUtils.PictOpOver; ! con.XRenderCompositeText(textCompRule, getCurrentSource().picture, dst.picture, maskFormat, sx, sy, 0, 0, glyphSet, elts); } public XRColor getMaskColor() { return !isTexturePaintActive() ? XRColor.FULL_ALPHA : getAlphaColor();
*** 313,323 **** public int getExtraAlphaMask() { return alphaMask; } public boolean isTexturePaintActive() { ! return src == texture; } public XRColor getAlphaColor() { return alphaColor; } --- 339,353 ---- public int getExtraAlphaMask() { return alphaMask; } public boolean isTexturePaintActive() { ! return srcType == TEXTURE; ! } ! ! public boolean isSolidPaintActive() { ! return srcType == SOLID; } public XRColor getAlphaColor() { return alphaColor; }