[Texmap] Rename TextureMapperShaderManager.* TextureMapperShaderProgram.*
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 08:32:08 +0000 (08:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Jan 2013 08:32:08 +0000 (08:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105847

TextureMapperShaderManager contains very little "manager" code.
Moved the map of shaders to TextureMapperGL, and renamed the files containing
the shader implementation TextureMapperShaderProgram.cpp|h.

Patch by No'am Rosenthal <noam@webkit.org> on 2013-01-23
Reviewed by Kenneth Rohde Christiansen.

No new tests - renames/refactors only.

* GNUmakefile.list.am:
* PlatformEfl.cmake:
* Target.pri:
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGLData::SharedGLData::getShaderProgram):
        This function is copied from TextureMapperShaderManager.
(SharedGLData):
(WebCore::TextureMapperGLData::SharedGLData::SharedGLData):
(WebCore::TextureMapperGL::drawBorder):
(WebCore::TextureMapperGL::drawTexture):
(WebCore::TextureMapperGL::drawSolidColor):
(WebCore::optionsForFilterType):
(WebCore::TextureMapperGL::drawFiltered):
(WebCore::TextureMapperGL::beginClip):
* platform/graphics/texmap/TextureMapperShaderProgram.cpp: Renamed from Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp.
(WebCore):
(WebCore::compositingLogEnabled):
(WebCore::TextureMapperShaderProgram::TextureMapperShaderProgram):
(WebCore::TextureMapperShaderProgram::setMatrix):
(WebCore::TextureMapperShaderProgram::getLocation):
(WebCore::TextureMapperShaderProgram::~TextureMapperShaderProgram):
(WebCore::TextureMapperShaderProgram::create):
* platform/graphics/texmap/TextureMapperShaderProgram.h: Renamed from Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h.
(WebCore):
(TextureMapperShaderProgram):
(WebCore::TextureMapperShaderProgram::programID):
(WebCore::TextureMapperShaderProgram::context):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140518 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/PlatformEfl.cmake
Source/WebCore/Target.pri
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp [moved from Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp with 93% similarity]
Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h [moved from Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h with 83% similarity]

index b38cb72..4168b62 100644 (file)
@@ -1,3 +1,44 @@
+2013-01-23  No'am Rosenthal  <noam@webkit.org>
+
+        [Texmap] Rename TextureMapperShaderManager.* TextureMapperShaderProgram.*
+        https://bugs.webkit.org/show_bug.cgi?id=105847
+
+        TextureMapperShaderManager contains very little "manager" code.
+        Moved the map of shaders to TextureMapperGL, and renamed the files containing
+        the shader implementation TextureMapperShaderProgram.cpp|h.
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        No new tests - renames/refactors only.
+
+        * GNUmakefile.list.am:
+        * PlatformEfl.cmake:
+        * Target.pri:
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGLData::SharedGLData::getShaderProgram):
+                This function is copied from TextureMapperShaderManager.
+        (SharedGLData):
+        (WebCore::TextureMapperGLData::SharedGLData::SharedGLData):
+        (WebCore::TextureMapperGL::drawBorder):
+        (WebCore::TextureMapperGL::drawTexture):
+        (WebCore::TextureMapperGL::drawSolidColor):
+        (WebCore::optionsForFilterType):
+        (WebCore::TextureMapperGL::drawFiltered):
+        (WebCore::TextureMapperGL::beginClip):
+        * platform/graphics/texmap/TextureMapperShaderProgram.cpp: Renamed from Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp.
+        (WebCore):
+        (WebCore::compositingLogEnabled):
+        (WebCore::TextureMapperShaderProgram::TextureMapperShaderProgram):
+        (WebCore::TextureMapperShaderProgram::setMatrix):
+        (WebCore::TextureMapperShaderProgram::getLocation):
+        (WebCore::TextureMapperShaderProgram::~TextureMapperShaderProgram):
+        (WebCore::TextureMapperShaderProgram::create):
+        * platform/graphics/texmap/TextureMapperShaderProgram.h: Renamed from Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h.
+        (WebCore):
+        (TextureMapperShaderProgram):
+        (WebCore::TextureMapperShaderProgram::programID):
+        (WebCore::TextureMapperShaderProgram::context):
+
 2013-01-23  Kentaro Hara  <haraken@chromium.org>
 
         [V8] Make an Isolate parameter mandatory in throwError()
index aa0ea82..7719e55 100644 (file)
@@ -6419,8 +6419,8 @@ if USE_TEXTURE_MAPPER_CAIRO
 webcore_sources += \
        Source/WebCore//platform/graphics/filters/texmap/CustomFilterValidatedProgramTextureMapper.cpp \
        Source/WebCore//platform/graphics/filters/texmap/TextureMapperPlatformCompiledProgram.h \
-       Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp \
-       Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.h \
+       Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.cpp \
+       Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h \
        Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp \
        Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h \
        Source/WebCore/platform/graphics/GraphicsLayerTransform.cpp \
index a6bba0f..f5179c6 100644 (file)
@@ -317,7 +317,7 @@ if (WTF_USE_3D_GRAPHICS)
         platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp
         platform/graphics/surfaces/glx/X11WindowResources.cpp
         platform/graphics/texmap/TextureMapperGL.cpp
-        platform/graphics/texmap/TextureMapperShaderManager.cpp
+        platform/graphics/texmap/TextureMapperShaderProgram.cpp
     )
 
     if (WTF_USE_EGL)
index 4071362..071bace 100644 (file)
@@ -4042,7 +4042,7 @@ use?(3D_GRAPHICS) {
         platform/graphics/gpu/TilingData.h \
         platform/graphics/opengl/Extensions3DOpenGL.h \
         platform/graphics/texmap/TextureMapperGL.h \
-        platform/graphics/texmap/TextureMapperShaderManager.h
+        platform/graphics/texmap/TextureMapperShaderProgram.h
 
     SOURCES += \
         platform/graphics/ANGLEWebKitBridge.cpp \
@@ -4055,7 +4055,7 @@ use?(3D_GRAPHICS) {
         platform/graphics/opengl/Extensions3DOpenGLCommon.cpp \
         platform/graphics/qt/GraphicsContext3DQt.cpp \
         platform/graphics/texmap/TextureMapperGL.cpp \
-        platform/graphics/texmap/TextureMapperShaderManager.cpp
+        platform/graphics/texmap/TextureMapperShaderProgram.cpp
 
     INCLUDEPATH += $$PWD/platform/graphics/gpu
 
index b82918e..a901188 100644 (file)
@@ -27,7 +27,7 @@
 #include "Image.h"
 #include "LengthFunctions.h"
 #include "NotImplemented.h"
-#include "TextureMapperShaderManager.h"
+#include "TextureMapperShaderProgram.h"
 #include "Timer.h"
 #include <wtf/HashMap.h>
 #include <wtf/OwnArrayPtr.h>
@@ -85,10 +85,22 @@ public:
             return adoptRef(new SharedGLData(context));
         }
 
-        TextureMapperShaderManager textureMapperShaderManager;
+        PassRefPtr<TextureMapperShaderProgram> getShaderProgram(TextureMapperShaderProgram::Options options)
+        {
+            HashMap<TextureMapperShaderProgram::Options, RefPtr<TextureMapperShaderProgram> >::iterator it = m_programs.find(options);
+            if (it != m_programs.end())
+                return it->value;
+
+            RefPtr<TextureMapperShaderProgram> program = TextureMapperShaderProgram::create(m_context, options);
+            m_programs.add(options, program);
+            return program;
+        }
+
+        HashMap<TextureMapperShaderProgram::Options, RefPtr<TextureMapperShaderProgram> > m_programs;
+        RefPtr<GraphicsContext3D> m_context;
 
         explicit SharedGLData(GraphicsContext3D* context)
-            : textureMapperShaderManager(context)
+            : m_context(context)
         {
             glContextDataMap().add(context->platformGraphicsContext3D(), this);
         }
@@ -298,7 +310,7 @@ void TextureMapperGL::drawBorder(const Color& color, float width, const FloatRec
     if (clipStack().current().scissorBox.isEmpty())
         return;
 
-    RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::SolidColor);
+    RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().getShaderProgram(TextureMapperShaderProgram::SolidColor);
     m_context3D->useProgram(program->programID());
 
     float r, g, b, a;
@@ -398,15 +410,15 @@ void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const I
         && exposedEdges == AllEdges
         && !modelViewMatrix.mapQuad(targetRect).isRectilinear();
 
-    TextureMapperShaderManager::Options options = TextureMapperShaderManager::Texture;
+    TextureMapperShaderProgram::Options options = TextureMapperShaderProgram::Texture;
     if (masked)
-        options |= TextureMapperShaderManager::Mask;
+        options |= TextureMapperShaderProgram::Mask;
     if (useRect)
-        options |= TextureMapperShaderManager::Rect;
+        options |= TextureMapperShaderProgram::Rect;
     if (opacity < 1)
-        options |= TextureMapperShaderManager::Opacity;
+        options |= TextureMapperShaderProgram::Opacity;
     if (useAntialiasing) {
-        options |= TextureMapperShaderManager::Antialiasing;
+        options |= TextureMapperShaderProgram::Antialiasing;
         flags |= ShouldAntialias;
     }
 
@@ -414,20 +426,20 @@ void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const I
         flags |= ShouldBlend;
 
     RefPtr<TextureMapperShaderProgram> program;
-    program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(options);
+    program = data().sharedGLData().getShaderProgram(options);
     drawTexturedQuadWithProgram(program.get(), texture, flags, textureSize, targetRect, modelViewMatrix, opacity, maskTexture);
 }
 
 void TextureMapperGL::drawSolidColor(const FloatRect& rect, const TransformationMatrix& matrix, const Color& color)
 {
     Flags flags = 0;
-    TextureMapperShaderManager::Options options = TextureMapperShaderManager::SolidColor;
+    TextureMapperShaderProgram::Options options = TextureMapperShaderProgram::SolidColor;
     if (!matrix.mapQuad(rect).isRectilinear()) {
-        options |= TextureMapperShaderManager::Antialiasing;
+        options |= TextureMapperShaderProgram::Antialiasing;
         flags |= ShouldBlend | ShouldAntialias;
     }
 
-    RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(options);
+    RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().getShaderProgram(options);
     m_context3D->useProgram(program->programID());
 
     float r, g, b, a;
@@ -693,30 +705,30 @@ void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, co
 
 #if ENABLE(CSS_FILTERS)
 
-static TextureMapperShaderManager::Options optionsForFilterType(FilterOperation::OperationType type, unsigned pass)
+static TextureMapperShaderProgram::Options optionsForFilterType(FilterOperation::OperationType type, unsigned pass)
 {
     switch (type) {
     case FilterOperation::GRAYSCALE:
-        return TextureMapperShaderManager::Texture | TextureMapperShaderManager::GrayscaleFilter;
+        return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::GrayscaleFilter;
     case FilterOperation::SEPIA:
-        return TextureMapperShaderManager::Texture | TextureMapperShaderManager::SepiaFilter;
+        return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::SepiaFilter;
     case FilterOperation::SATURATE:
-        return TextureMapperShaderManager::Texture | TextureMapperShaderManager::SaturateFilter;
+        return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::SaturateFilter;
     case FilterOperation::HUE_ROTATE:
-        return TextureMapperShaderManager::Texture | TextureMapperShaderManager::HueRotateFilter;
+        return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::HueRotateFilter;
     case FilterOperation::INVERT:
-        return TextureMapperShaderManager::Texture | TextureMapperShaderManager::InvertFilter;
+        return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::InvertFilter;
     case FilterOperation::BRIGHTNESS:
-        return TextureMapperShaderManager::Texture | TextureMapperShaderManager::BrightnessFilter;
+        return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::BrightnessFilter;
     case FilterOperation::CONTRAST:
-        return TextureMapperShaderManager::Texture | TextureMapperShaderManager::ContrastFilter;
+        return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::ContrastFilter;
     case FilterOperation::OPACITY:
-        return TextureMapperShaderManager::Texture | TextureMapperShaderManager::OpacityFilter;
+        return TextureMapperShaderProgram::Texture | TextureMapperShaderProgram::OpacityFilter;
     case FilterOperation::BLUR:
-        return TextureMapperShaderManager::BlurFilter;
+        return TextureMapperShaderProgram::BlurFilter;
     case FilterOperation::DROP_SHADOW:
-        return TextureMapperShaderManager::AlphaBlur
-            | (pass ? TextureMapperShaderManager::ContentTexture | TextureMapperShaderManager::SolidColor: 0);
+        return TextureMapperShaderProgram::AlphaBlur
+            | (pass ? TextureMapperShaderProgram::ContentTexture | TextureMapperShaderProgram::SolidColor: 0);
     default:
         ASSERT_NOT_REACHED();
         return 0;
@@ -910,8 +922,8 @@ bool TextureMapperGL::drawUsingCustomFilter(BitmapTexture& target, const BitmapT
 void TextureMapperGL::drawFiltered(const BitmapTexture& sampler, const BitmapTexture& contentTexture, const FilterOperation& filter, int pass)
 {
     // For standard filters, we always draw the whole texture without transformations.
-    TextureMapperShaderManager::Options options = optionsForFilterType(filter.getOperationType(), pass);
-    RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(options);
+    TextureMapperShaderProgram::Options options = optionsForFilterType(filter.getOperationType(), pass);
+    RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().getShaderProgram(options);
     ASSERT(program);
 
     prepareFilterProgram(program.get(), filter, pass, sampler.contentSize(), static_cast<const BitmapTextureGL&>(contentTexture).id());
@@ -1110,7 +1122,7 @@ void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, con
 
     data().initializeStencil();
 
-    RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().textureMapperShaderManager.getShaderProgram(TextureMapperShaderManager::SolidColor);
+    RefPtr<TextureMapperShaderProgram> program = data().sharedGLData().getShaderProgram(TextureMapperShaderProgram::SolidColor);
 
     m_context3D->useProgram(program->programID());
     m_context3D->enableVertexAttribArray(program->vertexLocation());
@@ -20,7 +20,7 @@
  */
 
 #include "config.h"
-#include "TextureMapperShaderManager.h"
+#include "TextureMapperShaderProgram.h"
 
 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
 #include "LengthFunctions.h"
@@ -351,14 +351,12 @@ static const char* fragmentTemplate =
         }
     );
 
-
-static void getShaderSpec(TextureMapperShaderManager::Options options, String& vertexSource, String& fragmentSource)
+PassRefPtr<TextureMapperShaderProgram> TextureMapperShaderProgram::create(PassRefPtr<GraphicsContext3D> context, TextureMapperShaderProgram::Options options)
 {
-
     StringBuilder shaderBuilder;
 #define SET_APPLIER_FROM_OPTIONS(Applier) \
     shaderBuilder.append(\
-        (options & TextureMapperShaderManager::Applier) ? ENABLE_APPLIER(Applier) : DISABLE_APPLIER(Applier))
+        (options & TextureMapperShaderProgram::Applier) ? ENABLE_APPLIER(Applier) : DISABLE_APPLIER(Applier))
 
     SET_APPLIER_FROM_OPTIONS(Texture);
     SET_APPLIER_FROM_OPTIONS(Rect);
@@ -381,32 +379,12 @@ static void getShaderSpec(TextureMapperShaderManager::Options options, String& v
     vertexBuilder.append(shaderBuilder.toString());
     vertexBuilder.append(vertexTemplate);
     shaderBuilder.append(fragmentTemplate);
-    vertexSource = vertexBuilder.toString();
-    fragmentSource = shaderBuilder.toString();
-}
 
-TextureMapperShaderManager::TextureMapperShaderManager(GraphicsContext3D* context)
-    : m_context(context)
-{
-}
+    String vertexSource = vertexBuilder.toString();
+    String fragmentSource = shaderBuilder.toString();
 
-TextureMapperShaderManager::~TextureMapperShaderManager()
-{
+    return adoptRef(new TextureMapperShaderProgram(context, vertexSource, fragmentSource));
 }
 
-PassRefPtr<TextureMapperShaderProgram> TextureMapperShaderManager::getShaderProgram(Options options)
-{
-    TextureMapperShaderProgramMap::iterator it = m_programs.find(options);
-    if (it != m_programs.end())
-        return it->value;
-
-    String vertexShader;
-    String fragmentShader;
-    getShaderSpec(options, vertexShader, fragmentShader);
-    RefPtr<TextureMapperShaderProgram> program = TextureMapperShaderProgram::create(m_context, vertexShader, fragmentShader);
-    m_programs.add(options, program);
-    return program;
 }
-};
-
 #endif
@@ -18,8 +18,8 @@
  Boston, MA 02110-1301, USA.
  */
 
-#ifndef TextureMapperShaderManager_h
-#define TextureMapperShaderManager_h
+#ifndef TextureMapperShaderProgram_h
+#define TextureMapperShaderProgram_h
 
 #if USE(TEXTURE_MAPPER)
 #include "GraphicsContext3D.h"
@@ -37,14 +37,32 @@ namespace WebCore {
 
 class TextureMapperShaderProgram : public RefCounted<TextureMapperShaderProgram> {
 public:
-    Platform3DObject programID() const { return m_id; }
-    GraphicsContext3D* context() { return m_context.get(); }
-    static PassRefPtr<TextureMapperShaderProgram> create(PassRefPtr<GraphicsContext3D> context, const String& vertex, const String& fragment)
-    {
-        return adoptRef(new TextureMapperShaderProgram(context, vertex, fragment));
-    }
+    enum Option {
+        Texture          = 1L << 0,
+        Rect             = 1L << 1,
+        SolidColor       = 1L << 2,
+        Opacity          = 1L << 3,
+        Mask             = 1L << 4,
+        Antialiasing     = 1L << 5,
+        GrayscaleFilter  = 1L << 6,
+        SepiaFilter      = 1L << 7,
+        SaturateFilter   = 1L << 8,
+        HueRotateFilter  = 1L << 9,
+        BrightnessFilter = 1L << 10,
+        ContrastFilter   = 1L << 11,
+        InvertFilter     = 1L << 12,
+        OpacityFilter    = 1L << 13,
+        BlurFilter       = 1L << 14,
+        AlphaBlur        = 1L << 15,
+        ContentTexture   = 1L << 16
+    };
 
+    typedef unsigned Options;
+
+    static PassRefPtr<TextureMapperShaderProgram> create(PassRefPtr<GraphicsContext3D>, Options);
     virtual ~TextureMapperShaderProgram();
+    Platform3DObject programID() const { return m_id; }
+    GraphicsContext3D* context() { return m_context.get(); }
 
     TEXMAP_DECLARE_ATTRIBUTE(vertex)
 
@@ -80,43 +98,7 @@ private:
     HashMap<AtomicString, GC3Duint> m_variables;
 };
 
-class TextureMapperShaderManager {
-public:
-    enum Option {
-        Texture          = 1L << 0,
-        Rect             = 1L << 1,
-        SolidColor       = 1L << 2,
-        Opacity          = 1L << 3,
-        Mask             = 1L << 4,
-        Antialiasing     = 1L << 5,
-        GrayscaleFilter  = 1L << 6,
-        SepiaFilter      = 1L << 7,
-        SaturateFilter   = 1L << 8,
-        HueRotateFilter  = 1L << 9,
-        BrightnessFilter = 1L << 10,
-        ContrastFilter   = 1L << 11,
-        InvertFilter     = 1L << 12,
-        OpacityFilter    = 1L << 13,
-        BlurFilter       = 1L << 14,
-        AlphaBlur        = 1L << 15,
-        ContentTexture   = 1L << 16
-    };
-
-    typedef unsigned Options;
-
-    TextureMapperShaderManager() { }
-    explicit TextureMapperShaderManager(GraphicsContext3D*);
-    virtual ~TextureMapperShaderManager();
-
-    PassRefPtr<TextureMapperShaderProgram> getShaderProgram(Options);
-
-private:
-    typedef HashMap<Options, RefPtr<TextureMapperShaderProgram> > TextureMapperShaderProgramMap;
-    TextureMapperShaderProgramMap m_programs;
-    RefPtr<GraphicsContext3D> m_context;
-};
-
 }
 #endif
 
-#endif // TextureMapperShaderManager_h
+#endif // TextureMapperShaderProgram_h