44 */ 45 private static final Set<String> intrinsicPeerNames; 46 static { 47 intrinsicPeerNames = new HashSet<String>(4); 48 intrinsicPeerNames.add("Crop"); 49 intrinsicPeerNames.add("Flood"); 50 intrinsicPeerNames.add("Merge"); 51 intrinsicPeerNames.add("Reflection"); 52 } 53 54 /** 55 * Private constructor to prevent instantiation. 56 */ 57 protected PrRenderer() { 58 } 59 60 public abstract PrDrawable createDrawable(RTTexture rtt); 61 62 public static Renderer createRenderer(FilterContext fctx) { 63 Object ref = fctx.getReferent(); 64 GraphicsPipeline pipe = GraphicsPipeline.getPipeline(); 65 if (pipe == null || !(ref instanceof Screen)) { 66 return null; 67 } 68 return createRenderer(fctx, pipe.supportsShaderModel(ShaderModel.SM3)); 69 } 70 71 public static PrRenderer createSoftwareRenderer(FilterContext fctx) { 72 return createRenderer(fctx, false); 73 } 74 75 private static PrRenderer createRenderer(FilterContext fctx, boolean isHW) { 76 String klassName = isHW ? 77 Renderer.rootPkg + ".impl.prism.ps.PPSRenderer" : 78 Renderer.rootPkg + ".impl.prism.sw.PSWRenderer"; 79 try { 80 Class klass = Class.forName(klassName); 81 Method m = klass.getMethod("createRenderer", new Class[] { FilterContext.class }); 82 return (PrRenderer)m.invoke(null, new Object[] { fctx }); 83 } catch (Throwable e) {} 84 return null; 85 } 86 87 public static boolean isIntrinsicPeer(String name) { 88 return intrinsicPeerNames.contains(name); 89 } 90 } | 44 */ 45 private static final Set<String> intrinsicPeerNames; 46 static { 47 intrinsicPeerNames = new HashSet<String>(4); 48 intrinsicPeerNames.add("Crop"); 49 intrinsicPeerNames.add("Flood"); 50 intrinsicPeerNames.add("Merge"); 51 intrinsicPeerNames.add("Reflection"); 52 } 53 54 /** 55 * Private constructor to prevent instantiation. 56 */ 57 protected PrRenderer() { 58 } 59 60 public abstract PrDrawable createDrawable(RTTexture rtt); 61 62 public static Renderer createRenderer(FilterContext fctx) { 63 Object ref = fctx.getReferent(); 64 if (!(ref instanceof Screen)) { 65 return null; 66 } 67 boolean isHW; 68 if (((PrFilterContext) fctx).isForceSoftware()) { 69 isHW = false; 70 } else { 71 GraphicsPipeline pipe = GraphicsPipeline.getPipeline(); 72 if (pipe == null) { 73 return null; 74 } 75 isHW = pipe.supportsShaderModel(ShaderModel.SM3); 76 } 77 return createRenderer(fctx, isHW); 78 } 79 80 private static PrRenderer createRenderer(FilterContext fctx, boolean isHW) { 81 String klassName = isHW ? 82 Renderer.rootPkg + ".impl.prism.ps.PPSRenderer" : 83 Renderer.rootPkg + ".impl.prism.sw.PSWRenderer"; 84 try { 85 Class klass = Class.forName(klassName); 86 Method m = klass.getMethod("createRenderer", new Class[] { FilterContext.class }); 87 return (PrRenderer)m.invoke(null, new Object[] { fctx }); 88 } catch (Throwable e) {} 89 return null; 90 } 91 92 public static boolean isIntrinsicPeer(String name) { 93 return intrinsicPeerNames.contains(name); 94 } 95 } |