changeset 11135:7e05429623fd

8167068: Fix GLS language errors Reviewed-by: kcr, jvos Contributed-by: dell.green@ideaworks.co.uk
author jvos
date Wed, 19 Dec 2018 09:14:40 +0100
parents e4dc16090ddf
children 94f51e852ad6
files modules/javafx.graphics/src/jslc/java/com/sun/scenario/effect/compiler/backend/hw/ES2Backend.java modules/javafx.graphics/src/jslc/java/com/sun/scenario/effect/compiler/backend/hw/GLSLBackend.java modules/javafx.graphics/src/jslc/java/com/sun/scenario/effect/compiler/backend/hw/SLBackend.java
diffstat 3 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/jslc/java/com/sun/scenario/effect/compiler/backend/hw/ES2Backend.java	Wed Dec 19 12:08:07 2018 +0530
+++ b/modules/javafx.graphics/src/jslc/java/com/sun/scenario/effect/compiler/backend/hw/ES2Backend.java	Wed Dec 19 09:14:40 2018 +0100
@@ -138,9 +138,6 @@
         // at the top of the program, if needed
         if (isPixcoordReferenced) {
             sb.append("uniform vec4 jsl_pixCoordOffset;\n");
-            sb.append("vec2 pixcoord = vec2(\n");
-            sb.append("    gl_FragCoord.x-jsl_pixCoordOffset.x,\n");
-            sb.append("    ((jsl_pixCoordOffset.z-gl_FragCoord.y)*jsl_pixCoordOffset.w)-jsl_pixCoordOffset.y);\n");
         }
 
         return sb.toString();
--- a/modules/javafx.graphics/src/jslc/java/com/sun/scenario/effect/compiler/backend/hw/GLSLBackend.java	Wed Dec 19 12:08:07 2018 +0530
+++ b/modules/javafx.graphics/src/jslc/java/com/sun/scenario/effect/compiler/backend/hw/GLSLBackend.java	Wed Dec 19 09:14:40 2018 +0100
@@ -84,6 +84,14 @@
         funcMap.put("length", "length");
     }
 
+
+    static String PIXCOORD = "vec2 pixcoord = vec2(\n"+
+        "    gl_FragCoord.x-jsl_pixCoordOffset.x,\n" +
+        "    ((jsl_pixCoordOffset.z-gl_FragCoord.y)*jsl_pixCoordOffset.w)-jsl_pixCoordOffset.y);\n";
+
+    static String MAIN = "void main() {\n";
+
+
     @Override
     protected String getType(Type t) {
         return typeMap.get(t.toString());
@@ -131,4 +139,15 @@
 
         return sb.toString();
     }
+
+
+    @Override
+    public String getShader() {
+        String answer = super.getShader();
+        if (isPixcoordReferenced) {
+            answer = answer.replace(MAIN, MAIN + PIXCOORD);
+        }
+        return answer;
+    }
+
 }
--- a/modules/javafx.graphics/src/jslc/java/com/sun/scenario/effect/compiler/backend/hw/SLBackend.java	Wed Dec 19 12:08:07 2018 +0530
+++ b/modules/javafx.graphics/src/jslc/java/com/sun/scenario/effect/compiler/backend/hw/SLBackend.java	Wed Dec 19 09:14:40 2018 +0100
@@ -81,7 +81,8 @@
         sb.append(s);
     }
 
-    public final String getShader() {
+
+    public String getShader() {
         return getHeader() + sb.toString();
     }