Fix webgl shader compiling issue.
authorYongGeol Jung <yg48.jung@samsung.com>
Mon, 22 Apr 2013 12:03:59 +0000 (21:03 +0900)
committerYongGeol Jung <yg48.jung@samsung.com>
Mon, 22 Apr 2013 12:23:06 +0000 (21:23 +0900)
[Title] Fix webgl shader compiling issue.
[Issue#] TWEB-1118
[Problem] Fragment shader which contains "Gl_OES_standard_derivatives" is not compiled properly.
[Cause] ANGLE compiler did not enable "Gl_OES_standard_derivatives".
[Solution] Enable "Gl_OES_standard_derivatives".

Change-Id: I78b4a75f3616984ae5f48522283ea5bddcf85ff5

Source/WebCore/platform/graphics/efl/tizen/Extensions3DTizen.cpp
Source/WebCore/platform/graphics/efl/tizen/Extensions3DTizen.h
Source/WebCore/platform/graphics/efl/tizen/GraphicsContext3DInternal.cpp
Source/WebCore/platform/graphics/efl/tizen/GraphicsContext3DInternal.h
Source/WebCore/platform/graphics/efl/tizen/GraphicsContext3DOffscreen.h

index 6169fef..646a11a 100644 (file)
@@ -42,7 +42,8 @@
 
 namespace WebCore {
 
-Extensions3DTizen::Extensions3DTizen()
+Extensions3DTizen::Extensions3DTizen(GraphicsContext3DInternal* context)
+    : m_context(context)
 {
     initialize();
 }
@@ -57,6 +58,32 @@ bool Extensions3DTizen::supports(const String& name)
     return m_availableExtensions.contains(name);
 }
 
+void Extensions3DTizen::ensureEnabled(const String& name)
+{
+#if ENABLE(TIZEN_WEBGL_ANGLE_INTEGRATION)
+    if (name == "GL_OES_standard_derivatives") {
+        // Enable support in ANGLE (if not enabled already)
+        ANGLEWebKitBridge& compiler = m_context->m_compiler;
+        ShBuiltInResources ANGLEResources = compiler.getResources();
+        if (!ANGLEResources.OES_standard_derivatives) {
+            ANGLEResources.OES_standard_derivatives = 1;
+            compiler.setResources(ANGLEResources);
+        }
+    }
+#endif
+}
+
+bool Extensions3DTizen::isEnabled(const String& name)
+{
+#if ENABLE(TIZEN_WEBGL_ANGLE_INTEGRATION)
+    if (name == "GL_OES_standard_derivatives") {
+        ANGLEWebKitBridge& compiler = m_context->m_compiler;
+        return compiler.getResources().OES_standard_derivatives;
+    }
+#endif
+    return supports(name);
+}
+
 void Extensions3DTizen::initialize()
 {
     String extensionsString(reinterpret_cast<const char*>(GL_CMD(glGetString(GL_EXTENSIONS))));
index 8d86e65..f1b3e4b 100644 (file)
 #if ENABLE(TIZEN_ACCELERATED_COMPOSITING)
 
 #include "Extensions3D.h"
-#include "GraphicsContext3D.h"
+#include "GraphicsContext3DInternal.h"
 
 namespace WebCore {
 
 class Extensions3DTizen : public Extensions3D {
 public:
-    Extensions3DTizen();
+    Extensions3DTizen(GraphicsContext3DInternal*);
     virtual ~Extensions3DTizen();
     void initialize();
     virtual bool supports(const String& name) ;
 
-    virtual void ensureEnabled(const String& name) {}
+    virtual void ensureEnabled(const String& name);
 
-    virtual bool isEnabled(const String& name) { return supports(name);}
+    virtual bool isEnabled(const String& name);
 
     virtual int getGraphicsResetStatusARB() { return GraphicsContext3D::NO_ERROR; }
 
@@ -57,7 +57,10 @@ public:
 
     // GL_ANGLE_translated_shader_source
     virtual String getTranslatedShaderSourceANGLE(Platform3DObject) { return String(); }
+
+private:
     HashSet<String> m_availableExtensions;
+    GraphicsContext3DInternal* m_context;
 };
 
 } // namespace WebCore
index 04124bf..0cdd8c4 100755 (executable)
@@ -173,7 +173,7 @@ void GraphicsContext3DInternal::synthesizeGLError(GC3Denum error)
 Extensions3D* GraphicsContext3DInternal::getExtensions()
 {
     if (!m_extensions)
-        m_extensions = adoptPtr(new Extensions3DTizen);
+        m_extensions = adoptPtr(new Extensions3DTizen(this));
     return m_extensions.get();
 }
 
index cb10e5f..9e9edaf 100755 (executable)
@@ -22,6 +22,9 @@
 
 #if ENABLE(TIZEN_ACCELERATED_COMPOSITING)
 
+#if ENABLE(TIZEN_WEBGL_ANGLE_INTEGRATION)
+#include "ANGLEWebKitBridge.h"
+#endif
 #include "GraphicsContext3D.h"
 #if ENABLE(TIZEN_WEBKIT2)
 #include <EGL/egl.h>
@@ -258,6 +261,11 @@ protected:
 
     GraphicsContext3D::RenderStyle m_renderStyle;
 
+#if ENABLE(TIZEN_WEBGL_ANGLE_INTEGRATION)
+    friend class Extensions3DTizen;
+    ANGLEWebKitBridge m_compiler;
+#endif
+
 #if !ENABLE(TIZEN_WEBKIT2)
     Evas_GL* m_evasGL;
     Evas_GL_Context* m_context;
index 648442a..97a9ed9 100755 (executable)
@@ -35,9 +35,6 @@
 #if USE(TIZEN_TEXTURE_MAPPER)
 #include "TextureMapperPlatformLayer.h"
 #endif
-#if ENABLE(TIZEN_WEBGL_ANGLE_INTEGRATION)
-#include "ANGLEWebKitBridge.h"
-#endif
 #if ENABLE(TIZEN_CANVAS_GRAPHICS_SURFACE)
 #include "GraphicsSurface.h"
 #endif
@@ -211,8 +208,6 @@ private:
         bool isValid;
     } ShaderSourceEntry;
     HashMap<Platform3DObject, ShaderSourceEntry> m_shaderSourceMap;
-
-    ANGLEWebKitBridge m_compiler;
 #endif
 //Angle intgration block