Title: [111986] trunk/Source/WebCore
Revision
111986
Author
[email protected]
Date
2012-03-24 01:37:51 -0700 (Sat, 24 Mar 2012)

Log Message

[Qt][WK2] Make TextureMapperShaderManager::getShaderProgram() not be a template.
https://bugs.webkit.org/show_bug.cgi?id=82049

Change the getShaderProgram() function to not be a template.
This is a workaround for a compiler bug that leads to an assert
when compiling in debug mode on mac.

Reviewed by Noam Rosenthal.

* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawTexture):
(WebCore::TextureMapperGL::beginClip):
* platform/graphics/texmap/TextureMapperShaderManager.h:
(TextureMapperShaderProgram):
(WebCore::TextureMapperShaderManager::getShaderProgram):
(TextureMapperShaderManager):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111985 => 111986)


--- trunk/Source/WebCore/ChangeLog	2012-03-24 08:36:12 UTC (rev 111985)
+++ trunk/Source/WebCore/ChangeLog	2012-03-24 08:37:51 UTC (rev 111986)
@@ -1,3 +1,22 @@
+2012-03-24  Zeno Albisser  <[email protected]>
+
+        [Qt][WK2] Make TextureMapperShaderManager::getShaderProgram() not be a template.
+        https://bugs.webkit.org/show_bug.cgi?id=82049
+
+        Change the getShaderProgram() function to not be a template.
+        This is a workaround for a compiler bug that leads to an assert
+        when compiling in debug mode on mac.
+
+        Reviewed by Noam Rosenthal.
+
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::drawTexture):
+        (WebCore::TextureMapperGL::beginClip):
+        * platform/graphics/texmap/TextureMapperShaderManager.h:
+        (TextureMapperShaderProgram):
+        (WebCore::TextureMapperShaderManager::getShaderProgram):
+        (TextureMapperShaderManager):
+
 2012-03-23  Shawn Singh  <[email protected]>
 
         [chromium] Incorrect replica originTransform used in CCDamageTracker

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (111985 => 111986)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-03-24 08:36:12 UTC (rev 111985)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp	2012-03-24 08:37:51 UTC (rev 111986)
@@ -319,9 +319,9 @@
 {
     RefPtr<TextureMapperShaderProgram> shaderInfo;
     if (maskTexture)
-        shaderInfo = data().sharedGLData().textureMapperShaderManager.getShaderProgram<TextureMapperShaderProgramOpacityAndMask>();
+        shaderInfo = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::OpacityAndMask);
     else
-        shaderInfo = data().sharedGLData().textureMapperShaderManager.getShaderProgram<TextureMapperShaderProgramSimple>();
+        shaderInfo = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Simple);
 
     GL_CMD(glUseProgram(shaderInfo->id()))
     GL_CMD(glEnableVertexAttribArray(shaderInfo->vertexAttrib()))
@@ -624,7 +624,7 @@
 
     data().initializeStencil();
 
-    RefPtr<TextureMapperShaderProgramSimple> shaderInfo = data().sharedGLData().textureMapperShaderManager.getShaderProgram<TextureMapperShaderProgramSimple>();
+    RefPtr<TextureMapperShaderProgram> shaderInfo = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::Simple);
 
     GL_CMD(glUseProgram(shaderInfo->id()))
     GL_CMD(glEnableVertexAttribArray(shaderInfo->vertexAttrib()))

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h (111985 => 111986)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h	2012-03-24 08:36:12 UTC (rev 111985)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h	2012-03-24 08:37:51 UTC (rev 111986)
@@ -33,8 +33,6 @@
 
 namespace WebCore {
 
-typedef void* ShaderType;
-
 class BitmapTexture;
 class TextureMapperShaderManager;
 
@@ -45,13 +43,6 @@
 
     virtual ~TextureMapperShaderProgram();
 
-    template<class T>
-    static ShaderType shaderType()
-    {
-        static int type = 0;
-        return &type;
-    }
-
     virtual void prepare(float opacity, const BitmapTexture*) { }
     GLint matrixVariable() const { return m_matrixVariable; }
     GLint sourceMatrixVariable() const { return m_sourceMatrixVariable; }
@@ -101,24 +92,36 @@
 
 class TextureMapperShaderManager {
 public:
+    enum ShaderType {
+        Invalid = 0, // HashMaps do not like 0 as a key.
+        Simple,
+        OpacityAndMask
+    };
+
     TextureMapperShaderManager();
     virtual ~TextureMapperShaderManager();
 
-    template<class T>
-    PassRefPtr<T> getShaderProgram()
+    PassRefPtr<TextureMapperShaderProgram> getShaderProgram(ShaderType shaderType)
     {
-        ShaderType shaderType = TextureMapperShaderProgram::shaderType<T>();
+        RefPtr<TextureMapperShaderProgram> program;
+        if (shaderType == Invalid)
+            return program;
+
         TextureMapperShaderProgramMap::iterator it = m_textureMapperShaderProgramMap.find(shaderType);
-        if (it != m_textureMapperShaderProgramMap.end())
-            return static_cast<T*>(it->second.get());
-
-        RefPtr<T> t = T::create();
-        m_textureMapperShaderProgramMap.add(shaderType, t);
-        return t;
+        switch (shaderType) {
+        case Simple:
+            program = TextureMapperShaderProgramSimple::create();
+            break;
+        case OpacityAndMask:
+            program = TextureMapperShaderProgramOpacityAndMask::create();
+            break;
+        }
+        m_textureMapperShaderProgramMap.add(shaderType, program);
+        return program;
     }
 
 private:
-    typedef HashMap<ShaderType, RefPtr<TextureMapperShaderProgram> > TextureMapperShaderProgramMap;
+    typedef HashMap<ShaderType, RefPtr<TextureMapperShaderProgram>, DefaultHash<int>::Hash, HashTraits<int> > TextureMapperShaderProgramMap;
     TextureMapperShaderProgramMap m_textureMapperShaderProgramMap;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to