diff -r 7d861c8dbe5a javafx-ui-glass/src/com/sun/javafx/tk/glass/PrismPen.java --- a/javafx-ui-glass/src/com/sun/javafx/tk/glass/PrismPen.java Tue Jan 04 10:06:37 2011 -0800 +++ b/javafx-ui-glass/src/com/sun/javafx/tk/glass/PrismPen.java Tue Jan 04 13:40:43 2011 -0500 @@ -71,6 +71,7 @@ setFillPaint(Color.WHITE); if (PrismSettings.dirtyOptsEnabled) { + System.out.println("PrismPen.dirtyOptsEnabled"); tx = new Affine2D(); clip = new RectBounds(); dirtyRect = new Rectangle(); diff -r 7d861c8dbe5a prism-common/src/com/sun/prism/impl/PrismSettings.java --- a/prism-common/src/com/sun/prism/impl/PrismSettings.java Tue Jan 04 10:06:37 2011 -0800 +++ b/prism-common/src/com/sun/prism/impl/PrismSettings.java Tue Jan 04 13:40:43 2011 -0500 @@ -54,7 +54,7 @@ !Boolean.getBoolean("com.sun.scenario.animation.fullspeed"); /* Dirty region optimizations */ - dirtyOptsEnabled = Boolean.getBoolean("prism.dirtyopts"); + dirtyOptsEnabled = true; //Boolean.getBoolean("prism.dirtyopts"); /* Force scene repaint on every frame */ forceRepaint = Boolean.getBoolean("prism.forcerepaint"); diff -r 7d861c8dbe5a prism-d3d/src/com/sun/prism/d3d/D3DContext.java --- a/prism-d3d/src/com/sun/prism/d3d/D3DContext.java Tue Jan 04 10:06:37 2011 -0800 +++ b/prism-d3d/src/com/sun/prism/d3d/D3DContext.java Tue Jan 04 13:40:43 2011 -0500 @@ -167,17 +167,20 @@ } void forceRenderTarget(D3DGraphics g) { - D3DSwapChain swap = (D3DSwapChain)g.getRenderTarget(); + RenderTarget target = g.getRenderTarget(); - if (targetWidth != swap.getPhysicalWidth() || - targetHeight != swap.getPhysicalHeight()) { + if (targetWidth != target.getPhysicalWidth() || + targetHeight != target.getPhysicalHeight()) { return; } - targetWidth = swap.getPhysicalWidth(); - targetHeight = swap.getPhysicalHeight(); + targetWidth = target.getPhysicalWidth(); + targetHeight = target.getPhysicalHeight(); - swap.dispose(); - swap = null; + if (target instanceof D3DResource) { + D3DResource resource = (D3DResource)target; + resource.dispose(); + } + target = null; } @Override diff -r 7d861c8dbe5a prism-d3d/src/com/sun/prism/d3d/D3DGraphics.java --- a/prism-d3d/src/com/sun/prism/d3d/D3DGraphics.java Tue Jan 04 10:06:37 2011 -0800 +++ b/prism-d3d/src/com/sun/prism/d3d/D3DGraphics.java Tue Jan 04 13:40:43 2011 -0500 @@ -1,8 +1,7 @@ package com.sun.prism.d3d; -import com.sun.prism.Graphics; -import com.sun.prism.GraphicsPipeline; import com.sun.prism.RenderTarget; +import com.sun.prism.Texture; import com.sun.prism.impl.ps.BaseShaderGraphics; import com.sun.prism.paint.Color; import com.sun.prism.paint.Paint; @@ -19,7 +18,7 @@ this.context = context; } - static Graphics create(RenderTarget target, D3DContext ctx) { + static D3DGraphics create(RenderTarget target, D3DContext ctx) { if (target == null || target.getNativeDestHandle() == 0L) { // TODO: perhaps return an "empty" graphics here return null; @@ -28,6 +27,23 @@ return ctx.isLost() ? null : new D3DGraphics(ctx, target); } + /* This method is similar in purpose to AlphaComposite.SRC, performing + * a direct copy of the provided texture to the current context + */ + public void copyTexture(Texture src, + float dx1, float dy1, float dx2, float dy2, + float sx1, float sy1, float sx2, float sy2) { + // set the blend mode to CLEAR + context.setBlendEnabled(false, true); + drawTexture(src, + dx1, dy1, dx2, dy2, + sx1, sy1, sx2, sy2); + context.flushVertexBuffer(); + + // restore default blend mode + context.setBlendEnabled(true, false); + } + public void clearQuad(float x1, float y1, float x2, float y2) { // note that unlike clear(), this method does not currently // attempt to clear the depth buffer... diff -r 7d861c8dbe5a prism-d3d/src/com/sun/prism/d3d/D3DSwapChain.java --- a/prism-d3d/src/com/sun/prism/d3d/D3DSwapChain.java Tue Jan 04 10:06:37 2011 -0800 +++ b/prism-d3d/src/com/sun/prism/d3d/D3DSwapChain.java Tue Jan 04 13:40:43 2011 -0500 @@ -4,6 +4,8 @@ import com.sun.prism.Graphics; import com.sun.prism.Presentable; import com.sun.prism.Surface; +import com.sun.prism.RTTexture; +import com.sun.prism.impl.PrismSettings; import com.sun.prism.tkal.Screen; /** @@ -13,21 +15,45 @@ extends D3DResource implements Presentable, D3DContextSource { - private final Surface surface; + private final Surface surface; + private final D3DContext context; + private RTTexture stableBackbuffer; + private boolean copyFullBuffer; + D3DSwapChain(D3DContext context, long pResource) { super(new D3DRecord(context, pResource)); this.surface = null; + this.context = null; } // Glass-Prism bringup D3DSwapChain(D3DContext context, long pResource, Surface surface) { super(new D3DRecord(context, pResource)); this.surface = surface; + this.context = context; } public boolean present(Rectangle clip) { D3DContext context = getContext(); + + if (stableBackbuffer != null) { + D3DGraphics g = D3DGraphics.create(this, context); + // Copy (not blend) the stableBackbuffer into place. + if (clip == null || copyFullBuffer) { + int w = getPhysicalWidth(); + int h = getPhysicalHeight(); + g.copyTexture(stableBackbuffer, 0, 0, w, h, 0, 0, w, h); + copyFullBuffer = false; + } else { + int cwidth = clip.x+clip.width; + int cheight = clip.y+clip.height; + g.copyTexture(stableBackbuffer, + clip.x, clip.y, cwidth, cheight, + clip.x, clip.y, cwidth, cheight); + } + } + context.getVertexBuffer().flush(); long res = nPresent(context.getContextHandle(), d3dResRecord.getResource()); return context.validatePresent(res); @@ -68,7 +94,20 @@ } public Graphics createGraphics() { - return D3DGraphics.create(this, getContext()); + if (PrismSettings.dirtyOptsEnabled) { + copyFullBuffer = true; + + // the stableBackbuffer will be used as the render target + if (stableBackbuffer == null) { + int w = getPhysicalWidth(); + int h = getPhysicalHeight(); + stableBackbuffer = + context.getResourceFactory().createRTTexture(w, h); + } + return D3DGraphics.create(stableBackbuffer, context); + } else { + return D3DGraphics.create(this, getContext()); + } } diff -r 7d861c8dbe5a prism-es2/src/com/sun/prism/es2/ES2Graphics.java --- a/prism-es2/src/com/sun/prism/es2/ES2Graphics.java Tue Jan 04 10:06:37 2011 -0800 +++ b/prism-es2/src/com/sun/prism/es2/ES2Graphics.java Tue Jan 04 13:40:43 2011 -0500 @@ -37,8 +37,8 @@ * a direct copy of the provided texture to the current context */ public void copyTexture(Texture src, - float dx1, float dy1, float dx2, float dy2, - float sx1, float sy1, float sx2, float sy2) { + float dx1, float dy1, float dx2, float dy2, + float sx1, float sy1, float sx2, float sy2) { GL2ES2 gl = context.getGL(); gl.glBlendFunc(GL_ONE, GL_ZERO); //aka AlphaComposite.SRC drawTexture(src, diff -r 7d861c8dbe5a prism-es2/src/com/sun/prism/es2/ES2SwapChain.java --- a/prism-es2/src/com/sun/prism/es2/ES2SwapChain.java Tue Jan 04 10:06:37 2011 -0800 +++ b/prism-es2/src/com/sun/prism/es2/ES2SwapChain.java Tue Jan 04 13:40:43 2011 -0500 @@ -111,9 +111,11 @@ g.copyTexture(stableBackbuffer, 0, 0, w, h, 0, 0, w, h); copyFullBuffer = false; } else { + int cwidth = clip.x+clip.width; + int cheight = clip.y+clip.height; g.copyTexture(stableBackbuffer, - clip.x, clip.y, clip.x+clip.width, clip.y+clip.height, - clip.x, clip.y, clip.x+clip.width, clip.y+clip.height); + clip.x, clip.y, cwidth, cheight, + clip.x, clip.y, cwidth, cheight); } } context.getVertexBuffer().flush();