modules/graphics/src/main/java/com/sun/scenario/effect/impl/prism/PrFilterContext.java

Print this page

        

@@ -43,10 +43,13 @@
             printerFilterContext = new PrFilterContext(resourceFactory);
         }
         return printerFilterContext;
     }
 
+    private PrFilterContext swinstance;
+    private boolean forceSW;
+
     private PrFilterContext(Object screen) {
         super(screen);
     }
 
     public static PrFilterContext getInstance(Screen screen) {

@@ -67,6 +70,39 @@
             // changes
             defaultScreen = Screen.getMainScreen();
         }
         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);
+    }
 }