changeset 6423:df8841896a28

Fix RT-35058: ES2 texture lock warnings in CanvasTest/Zoomy on ARM Reviewed by: Lisa
author flar <James.Graham@oracle.com>
date Tue, 04 Mar 2014 19:02:46 -0800
parents c896cd34e781
children b6f62f8bd8e6
files modules/graphics/src/main/java/com/sun/scenario/effect/FilterContext.java modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrFilterContext.java modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrRenderer.java modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPSRenderer.java modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPStoPSWDisplacementMapPeer.java
diffstat 5 files changed, 55 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/scenario/effect/FilterContext.java	Tue Mar 04 10:56:16 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/scenario/effect/FilterContext.java	Tue Mar 04 19:02:46 2014 -0800
@@ -44,12 +44,12 @@
     }
 
     @Override
-    public final int hashCode() {
+    public int hashCode() {
         return referent.hashCode();
     }
 
     @Override
-    public final boolean equals(Object o) {
+    public boolean equals(Object o) {
         if (!(o instanceof FilterContext)) {
             return false;
         }
--- a/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrFilterContext.java	Tue Mar 04 10:56:16 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrFilterContext.java	Tue Mar 04 19:02:46 2014 -0800
@@ -45,6 +45,9 @@
         return printerFilterContext;
     }
 
+    private PrFilterContext swinstance;
+    private boolean forceSW;
+
     private PrFilterContext(Object screen) {
         super(screen);
     }
@@ -69,4 +72,37 @@
         }
         return getInstance(defaultScreen);
     }
+
+    // Calledonly from PPSRenderer while making a PPStoPSWDispMapPeer,
+    // assumes original is hw instance.
+    public PrFilterContext getSoftwareInstance() {
+        if (swinstance == null) {
+            if (forceSW) {
+                swinstance = this;
+            } else {
+                swinstance = new PrFilterContext(getReferent());
+                swinstance.forceSW = true;
+            }
+        }
+        return swinstance;
+    }
+
+    public boolean isForceSoftware() {
+        return forceSW;
+    }
+
+    @Override
+    public int hashCode() {
+        return getReferent().hashCode() ^ Boolean.hashCode(forceSW);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof PrFilterContext)) {
+            return false;
+        }
+        PrFilterContext pfctx = (PrFilterContext) o;
+        return (this.getReferent().equals(pfctx.getReferent()) &&
+                this.forceSW == pfctx.forceSW);
+    }
 }
--- a/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrRenderer.java	Tue Mar 04 10:56:16 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrRenderer.java	Tue Mar 04 19:02:46 2014 -0800
@@ -61,15 +61,20 @@
 
     public static Renderer createRenderer(FilterContext fctx) {
         Object ref = fctx.getReferent();
-        GraphicsPipeline pipe = GraphicsPipeline.getPipeline();
-        if (pipe == null || !(ref instanceof Screen)) {
+        if (!(ref instanceof Screen)) {
             return null;
         }
-        return createRenderer(fctx, pipe.supportsShaderModel(ShaderModel.SM3));
-    }
-
-    public static PrRenderer createSoftwareRenderer(FilterContext fctx) {
-        return createRenderer(fctx, false);
+        boolean isHW;
+        if (((PrFilterContext) fctx).isForceSoftware()) {
+            isHW = false;
+        } else {
+            GraphicsPipeline pipe = GraphicsPipeline.getPipeline();
+            if (pipe == null) {
+                return null;
+            }
+            isHW = pipe.supportsShaderModel(ShaderModel.SM3);
+        }
+        return createRenderer(fctx, isHW);
     }
 
     private static PrRenderer createRenderer(FilterContext fctx, boolean isHW) {
--- a/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPSRenderer.java	Tue Mar 04 10:56:16 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPSRenderer.java	Tue Mar 04 19:02:46 2014 -0800
@@ -56,6 +56,7 @@
 import com.sun.scenario.effect.impl.Renderer;
 import com.sun.scenario.effect.impl.hw.ShaderSource;
 import com.sun.scenario.effect.impl.prism.PrDrawable;
+import com.sun.scenario.effect.impl.prism.PrFilterContext;
 import com.sun.scenario.effect.impl.prism.PrImage;
 import com.sun.scenario.effect.impl.prism.PrRenderer;
 import com.sun.scenario.effect.impl.prism.PrTexture;
@@ -271,7 +272,8 @@
             // create an intrinsic peer (one that's handled by Prism)
             return createIntrinsicPeer(fctx, name);
         } else if (needsSWDispMap && name.equals("DisplacementMap")) {
-            return new PPStoPSWDisplacementMapPeer(fctx, this, name);
+            PrFilterContext swctx = ((PrFilterContext) fctx).getSoftwareInstance();
+            return new PPStoPSWDisplacementMapPeer(swctx, this, name);
         } else {
             // try creating a platform-specific peer
             return createPlatformPeer(fctx, name, unrollCount);
--- a/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPStoPSWDisplacementMapPeer.java	Tue Mar 04 10:56:16 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/ps/PPStoPSWDisplacementMapPeer.java	Tue Mar 04 19:02:46 2014 -0800
@@ -44,7 +44,7 @@
 
     public PPStoPSWDisplacementMapPeer(FilterContext fctx, Renderer r, String shaderName) {
         super(fctx, r, shaderName);
-        softwareRenderer = PrRenderer.createSoftwareRenderer(fctx);
+        softwareRenderer = (PrRenderer) Renderer.getRenderer(fctx);
         softwarePeer = softwareRenderer.getPeerInstance(fctx, "DisplacementMap", 0);
     }
 
@@ -60,7 +60,7 @@
         RTTexture srcRT = (RTTexture) srcTex.getTextureObject();
         // The software renderer produces drawables that also implement HeapImage
         PrDrawable srcDrawable = softwareRenderer.createDrawable(srcRT);
-        ImageData heapinput = new ImageData(input.getFilterContext(), srcDrawable,
+        ImageData heapinput = new ImageData(getFilterContext(), srcDrawable,
                                             input.getUntransformedBounds());
         heapinput = heapinput.transform(input.getTransform());