changeset 7479:66866f7568a5

Fix RT-30107: NGCanvas should take advantage of new 1-step clipping support Reviewed by: Felipe
author flar <James.Graham@oracle.com>
date Mon, 14 Jul 2014 15:47:49 -0700
parents 18b6955caf3f
children 87c8bb33d62d
files modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGCanvas.java
diffstat 1 files changed, 27 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGCanvas.java	Mon Jul 14 15:14:03 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGCanvas.java	Mon Jul 14 15:47:49 2014 -0700
@@ -53,6 +53,7 @@
 import com.sun.prism.Graphics;
 import com.sun.prism.GraphicsPipeline;
 import com.sun.prism.Image;
+import com.sun.prism.MaskTextureGraphics;
 import com.sun.prism.PrinterGraphics;
 import com.sun.prism.RTTexture;
 import com.sun.prism.ResourceFactory;
@@ -673,9 +674,15 @@
                     renderClip(new RoundRectangle2D(clipRect.x, clipRect.y,
                                                     clipRect.width, clipRect.height,
                                                     0, 0));
-                    clipRect = null;
                 }
             }
+            shapebounds(clippath, TEMP_RECTBOUNDS, BaseTransform.IDENTITY_TRANSFORM);
+            TEMP_RECT.setBounds(TEMP_RECTBOUNDS);
+            if (clipRect == null) {
+                clipRect = new Rectangle(TEMP_RECT);
+            } else {
+                clipRect.intersectWith(TEMP_RECT);
+            }
             renderClip(clippath);
         }
         if (clipValidated && clipIsRect) {
@@ -1018,12 +1025,11 @@
                         tempvalidated = true;
                         dest = temp;
                     } else if (blendmode != Blend.Mode.SRC_OVER) {
-                        clipvalidated = false;
                         temp.validate(cv.g, tw, th);
                         tempvalidated = true;
                         dest = temp;
                     } else {
-                        clipvalidated = tempvalidated = false;
+                        tempvalidated = false;
                         dest = cv;
                     }
                     if (effect != null) {
@@ -1076,8 +1082,24 @@
                             // assert: dest == temp;
                             compmode = CompositeMode.SRC;
                         }
-                        blendAthruBintoC(temp, Mode.SRC_IN, clip,
-                                         TEMP_RECTBOUNDS, compmode, dest);
+                        if (clipRect != null) {
+                            TEMP_RECTBOUNDS.intersectWith(clipRect);
+                        }
+                        if (!TEMP_RECTBOUNDS.isEmpty()) {
+                            if (dest == cv && cv.g instanceof MaskTextureGraphics) {
+                                MaskTextureGraphics mtg = (MaskTextureGraphics) cv.g;
+                                int dx = (int) Math.floor(TEMP_RECTBOUNDS.getMinX());
+                                int dy = (int) Math.floor(TEMP_RECTBOUNDS.getMinY());
+                                int dw = (int) Math.ceil(TEMP_RECTBOUNDS.getMaxX()) - dx;
+                                int dh = (int) Math.ceil(TEMP_RECTBOUNDS.getMaxY()) - dy;
+                                mtg.drawPixelsMasked(temp.tex, clip.tex,
+                                                     dx, dy, dw, dh,
+                                                     dx, dy, dx, dy);
+                            } else {
+                                blendAthruBintoC(temp, Mode.SRC_IN, clip,
+                                                 TEMP_RECTBOUNDS, compmode, dest);
+                            }
+                        }
                     }
                     if (blendmode != Blend.Mode.SRC_OVER) {
                         // We always use SRC mode here because the results of