< prev index next >
src/java.desktop/unix/classes/sun/java2d/xr/XRCompositeManager.java
Print this page
rev 48925 : Xrender: Rename MaskTil(eManager) to RectTile(Manager) to avoid confusion later
rev 48926 : Xrender: Remove gradient cache, doesn't make sense with current drivers
rev 48927 : Xrender: make aa tile mask handling a responsibility of the backend implementation
rev 48928 : Xrender: Introduction of the deferred backend, allows for accumulated AA mask upload.
*** 26,38 ****
package sun.java2d.xr;
import java.awt.*;
import java.awt.geom.*;
- import java.security.AccessController;
- import java.security.PrivilegedAction;
-
import sun.font.*;
import sun.java2d.*;
import sun.java2d.loops.*;
/**
--- 26,35 ----
*** 42,52 ****
*
* @author Clemens Eisserer
*/
public class XRCompositeManager {
- private static boolean enableGradCache = true;
private static XRCompositeManager instance;
private static final int SOLID = 0;
private static final int TEXTURE = 1;
private static final int GRADIENT = 2;
--- 39,48 ----
*** 62,82 ****
byte compRule = XRUtils.PictOpOver;
XRColor alphaColor = new XRColor();
XRSurfaceData solidSrcPict;
int alphaMaskPict;
- int gradCachePixmap;
- int gradCachePicture;
boolean xorEnabled = false;
int validatedPixel = 0;
Composite validatedComp;
Paint validatedPaint;
float validatedExtraAlpha = 1.0f;
XRBackend con;
! MaskTileManager maskBuffer;
XRTextRenderer textRenderer;
XRMaskImage maskImage;
public static synchronized XRCompositeManager getInstance(
XRSurfaceData surface) {
--- 58,76 ----
byte compRule = XRUtils.PictOpOver;
XRColor alphaColor = new XRColor();
XRSurfaceData solidSrcPict;
int alphaMaskPict;
boolean xorEnabled = false;
int validatedPixel = 0;
Composite validatedComp;
Paint validatedPaint;
float validatedExtraAlpha = 1.0f;
XRBackend con;
! RectTileManager maskBuffer;
XRTextRenderer textRenderer;
XRMaskImage maskImage;
public static synchronized XRCompositeManager getInstance(
XRSurfaceData surface) {
*** 85,112 ****
}
return instance;
}
private XRCompositeManager(XRSurfaceData surface) {
con = new XRBackendNative();
! String gradProp =
! AccessController.doPrivileged(new PrivilegedAction<String>() {
! public String run() {
! return System.getProperty("sun.java2d.xrgradcache");
! }
! });
!
! enableGradCache = gradProp == null ||
! !(gradProp.equalsIgnoreCase("false") ||
! gradProp.equalsIgnoreCase("f"));
XRPaints.register(this);
initResources(surface);
! maskBuffer = new MaskTileManager(this, surface.getXid());
textRenderer = new XRTextRenderer(this);
maskImage = new XRMaskImage(this, surface.getXid());
}
public void initResources(XRSurfaceData surface) {
--- 79,104 ----
}
return instance;
}
private XRCompositeManager(XRSurfaceData surface) {
+ String defProp = System.getProperty("sun.java2d.xr.deferred");
+
+ if(defProp != null && defProp.length() > 0
+ && Character.toLowerCase(defProp.charAt(0)) == 't') {
+ con = new XRBackendDeferred();
+ } else {
con = new XRBackendNative();
+ }
! con.initResources(surface.getXid());
XRPaints.register(this);
initResources(surface);
! maskBuffer = new RectTileManager(this, surface.getXid());
textRenderer = new XRTextRenderer(this);
maskImage = new XRMaskImage(this, surface.getXid());
}
public void initResources(XRSurfaceData surface) {
*** 119,135 ****
alphaMaskPict = con.createPicture(extraAlphaMask,
XRUtils.PictStandardA8);
con.setPictureRepeat(alphaMaskPict, XRUtils.RepeatNormal);
con.renderRectangle(alphaMaskPict, XRUtils.PictOpClear,
XRColor.NO_ALPHA, 0, 0, 1, 1);
-
- if (enableGradCache) {
- gradCachePixmap = con.createPixmap(parentXid, 32,
- MaskTileManager.MASK_SIZE, MaskTileManager.MASK_SIZE);
- gradCachePicture = con.createPicture(gradCachePixmap,
- XRUtils.PictStandardARGB32);
- }
}
public void setForeground(int pixel) {
solidColor.setColorValues(pixel);
}
--- 111,120 ----
*** 233,257 ****
}
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) {
! con.renderComposite(XRUtils.PictOpSrc, gradient.picture,
! XRUtils.None, gradCachePicture, srcX, srcY, 0, 0, 0, 0,
! width, height);
! cachedX = 0;
! cachedY = 0;
! cachedSrc = gradCachePicture;
}
! con.renderComposite(compRule, cachedSrc, mask, dst, cachedX, cachedY,
! maskX, maskY, dstX, dstY, width, height);
}
public void XRRenderRectangles(XRSurfaceData dst, GrowableRectArray rects) {
if (xorEnabled) {
con.GCRectangles(dst.getXid(), dst.getGC(), rects);
--- 218,250 ----
}
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;
! con.renderComposite(compRule, cachedSrc, mask, dst, srcX, srcY,
! maskX, maskY, dstX, dstY, width, height);
}
! public void XRMaskedComposite(int src, int dst,
! int srcX, int srcY, int dstX, int dstY, int width,
! int height, int maskScan, int maskOff, byte[] mask) {
!
! src = (src == XRUtils.None) ? getCurrentSource().picture : src;
!
! float maskAlpha = 1.0f;
! int maskXid = XRUtils.None;
!
! if (mask != null) {
! maskAlpha = isTexturePaintActive() ? getExtraAlpha() : 1.0f;
! } else if (isTexturePaintActive()) {
! maskXid = getExtraAlphaMask();
! }
!
! con.maskedComposite(compRule, src, maskXid, dst,
! srcX, srcY, dstX, dstY, width,
! height, maskScan, maskOff, mask, maskAlpha);
}
public void XRRenderRectangles(XRSurfaceData dst, GrowableRectArray rects) {
if (xorEnabled) {
con.GCRectangles(dst.getXid(), dst.getGC(), rects);
*** 342,352 ****
public XRTextRenderer getTextRenderer() {
return textRenderer;
}
! public MaskTileManager getMaskBuffer() {
return maskBuffer;
}
public XRMaskImage getMaskImage() {
return maskImage;
--- 335,345 ----
public XRTextRenderer getTextRenderer() {
return textRenderer;
}
! public RectTileManager getMaskBuffer() {
return maskBuffer;
}
public XRMaskImage getMaskImage() {
return maskImage;
< prev index next >