[CSS Shaders] Create constants for vertex attribute sizes and offsets
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2012 19:48:55 +0000 (19:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2012 19:48:55 +0000 (19:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94755

Patch by Max Vujovic <mvujovic@adobe.com> on 2012-10-09
Reviewed by Dean Jackson.

Factor out the vertex attribute size and offset constants into a new file,
CustomFilterConstants.h. Replace literals in CustomFilterMeshGenerator with the constants.

I could have added the constants to CustomFilterMeshGenerator.h, but this would make
FECustomFilter depend on CustomFilterMeshGenerator.

I also could have added the constants to CustomFilterMesh.h, but this would make
CustomFilterMeshGenerator depend on CustomFilterMesh.

No new tests. No change in behavior.

* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/CustomFilterConstants.h: Added.
(WebCore):
* platform/graphics/filters/CustomFilterMeshGenerator.h:
(WebCore::CustomFilterMeshGenerator::floatsPerVertex):
    Use the new constants instead of literal values.
* platform/graphics/filters/FECustomFilter.cpp:
(WebCore::FECustomFilter::bindProgramAndBuffers):
    Pull the constant definitions out of here.

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

Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/CustomFilterConstants.h [new file with mode: 0644]
Source/WebCore/platform/graphics/filters/CustomFilterMeshGenerator.h
Source/WebCore/platform/graphics/filters/FECustomFilter.cpp

index edaaacd..2b005e9 100644 (file)
@@ -1,3 +1,35 @@
+2012-10-09  Max Vujovic  <mvujovic@adobe.com>
+
+        [CSS Shaders] Create constants for vertex attribute sizes and offsets
+        https://bugs.webkit.org/show_bug.cgi?id=94755
+
+        Reviewed by Dean Jackson.
+
+        Factor out the vertex attribute size and offset constants into a new file,
+        CustomFilterConstants.h. Replace literals in CustomFilterMeshGenerator with the constants.
+
+        I could have added the constants to CustomFilterMeshGenerator.h, but this would make
+        FECustomFilter depend on CustomFilterMeshGenerator.
+
+        I also could have added the constants to CustomFilterMesh.h, but this would make
+        CustomFilterMeshGenerator depend on CustomFilterMesh.
+
+        No new tests. No change in behavior.
+
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/CustomFilterConstants.h: Added.
+        (WebCore):
+        * platform/graphics/filters/CustomFilterMeshGenerator.h:
+        (WebCore::CustomFilterMeshGenerator::floatsPerVertex):
+            Use the new constants instead of literal values.
+        * platform/graphics/filters/FECustomFilter.cpp:
+        (WebCore::FECustomFilter::bindProgramAndBuffers):
+            Pull the constant definitions out of here.
+
 2012-10-09  Michael Saboff  <msaboff@apple.com>
 
         MarkupAccumulator should optimally handle 8 bit Strings
index a82b3c2..4cae0cb 100644 (file)
@@ -4289,6 +4289,7 @@ webcore_sources += \
        Source/WebCore/platform/graphics/cairo/RefPtrCairo.h \
        Source/WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp \
        Source/WebCore/platform/graphics/filters/CustomFilterArrayParameter.h \
+       Source/WebCore/platform/graphics/filters/CustomFilterConstants.h \
        Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.cpp \
        Source/WebCore/platform/graphics/filters/CustomFilterGlobalContext.h \
        Source/WebCore/platform/graphics/filters/CustomFilterMesh.cpp \
index fdf2706..38c0933 100644 (file)
@@ -2060,6 +2060,7 @@ HEADERS += \
     platform/graphics/Color.h \
     platform/graphics/CrossfadeGeneratedImage.h \
     platform/graphics/filters/CustomFilterArrayParameter.h \
+    platform/graphics/filters/CustomFilterConstants.h \
     platform/graphics/filters/CustomFilterGlobalContext.h \
     platform/graphics/filters/CustomFilterMesh.h \
     platform/graphics/filters/CustomFilterMeshGenerator.h \
index 490d214..81ef3a8 100644 (file)
             'platform/graphics/efl/IntPointEfl.cpp',
             'platform/graphics/efl/IntRectEfl.cpp',
             'platform/graphics/filters/CustomFilterArrayParameter.h',
+            'platform/graphics/filters/CustomFilterConstants.h',
             'platform/graphics/filters/CustomFilterGlobalContext.cpp',
             'platform/graphics/filters/CustomFilterGlobalContext.h',
             'platform/graphics/filters/CustomFilterMesh.h',
index 4c99227..53f35a7 100755 (executable)
                                                >
                                        </File>
                                        <File
+                                               RelativePath="..\platform\graphics\filters\CustomFilterConstants.h"
+                                               >
+                                       </File>
+                                       <File
                                                RelativePath="..\platform\graphics\filters\CustomFilterGlobalContext.cpp"
                                                >
                                        </File>
index 10ed59f..c740ad5 100644 (file)
                A1E1154413015C3D0054AC8C /* DistantLightSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1E1154313015C3D0054AC8C /* DistantLightSource.cpp */; };
                A1E1154613015C4E0054AC8C /* PointLightSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1E1154513015C4E0054AC8C /* PointLightSource.cpp */; };
                A1E1154813015C5D0054AC8C /* SpotLightSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1E1154713015C5D0054AC8C /* SpotLightSource.cpp */; };
+               A24A3A9D162499FF00522745 /* CustomFilterConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = A24A3A9C162499FF00522745 /* CustomFilterConstants.h */; };
                A24BF77B15CC3BAF003191F2 /* WebKitCSSMixFunctionValue.h in Headers */ = {isa = PBXBuildFile; fileRef = A24BF77915CC3BAF003191F2 /* WebKitCSSMixFunctionValue.h */; };
                A24BF77C15CC3BAF003191F2 /* WebKitCSSMixFunctionValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A24BF77A15CC3BAF003191F2 /* WebKitCSSMixFunctionValue.cpp */; };
                A29532CF15DD5E1700469EBC /* CustomFilterValidatedProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A29532CD15DD5E1700469EBC /* CustomFilterValidatedProgram.cpp */; };
                A1E1154313015C3D0054AC8C /* DistantLightSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DistantLightSource.cpp; path = filters/DistantLightSource.cpp; sourceTree = "<group>"; };
                A1E1154513015C4E0054AC8C /* PointLightSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PointLightSource.cpp; path = filters/PointLightSource.cpp; sourceTree = "<group>"; };
                A1E1154713015C5D0054AC8C /* SpotLightSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SpotLightSource.cpp; path = filters/SpotLightSource.cpp; sourceTree = "<group>"; };
+               A24A3A9C162499FF00522745 /* CustomFilterConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomFilterConstants.h; sourceTree = "<group>"; };
                A24BF77915CC3BAF003191F2 /* WebKitCSSMixFunctionValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitCSSMixFunctionValue.h; sourceTree = "<group>"; };
                A24BF77A15CC3BAF003191F2 /* WebKitCSSMixFunctionValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitCSSMixFunctionValue.cpp; sourceTree = "<group>"; };
                A29532CD15DD5E1700469EBC /* CustomFilterValidatedProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CustomFilterValidatedProgram.cpp; path = filters/CustomFilterValidatedProgram.cpp; sourceTree = "<group>"; };
                                15B3FC1715FB217800A81BCB /* CustomFilterArrayParameter.h */,
                                50D4060F147D49DE00D30BB5 /* CustomFilterCompiledProgram.cpp */,
                                50D40610147D49DE00D30BB5 /* CustomFilterCompiledProgram.h */,
+                               A24A3A9C162499FF00522745 /* CustomFilterConstants.h */,
                                50987C24157D676D00BDA835 /* CustomFilterGlobalContext.cpp */,
                                50987C25157D676D00BDA835 /* CustomFilterGlobalContext.h */,
                                50D405F7147D31F300D30BB5 /* CustomFilterMesh.cpp */,
                                62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */,
                                15B3FC1915FB217800A81BCB /* CustomFilterArrayParameter.h in Headers */,
                                50D40612147D49DE00D30BB5 /* CustomFilterCompiledProgram.h in Headers */,
+                               A24A3A9D162499FF00522745 /* CustomFilterConstants.h in Headers */,
                                50987C27157D676D00BDA835 /* CustomFilterGlobalContext.h in Headers */,
                                50D405FA147D31F300D30BB5 /* CustomFilterMesh.h in Headers */,
                                7E12E90F15FA5D3A005E4126 /* CustomFilterMeshGenerator.h in Headers */,
diff --git a/Source/WebCore/platform/graphics/CustomFilterConstants.h b/Source/WebCore/platform/graphics/CustomFilterConstants.h
new file mode 100644 (file)
index 0000000..6080c38
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials
+ *    provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef CustomFilterConstants_h
+#define CustomFilterConstants_h
+
+namespace WebCore {
+
+enum CustomFilterMeshConstants {
+    // Vertex attribute sizes
+    PositionAttribSize = 4,
+    TexAttribSize = 2,
+    MeshAttribSize = 2,
+    TriangleAttribSize = 3,
+    // Vertex attribute offsets
+    PositionAttribOffset = 0,
+    TexAttribOffset = PositionAttribOffset + PositionAttribSize * sizeof(float),
+    MeshAttribOffset = TexAttribOffset + TexAttribSize * sizeof(float),
+    TriangleAttribOffset = MeshAttribOffset + MeshAttribSize * sizeof(float)
+};
+
+} // namespace WebCore
+
+#endif // CustomFilterConstants_h
index 09f7562..b3a1847 100644 (file)
@@ -32,6 +32,7 @@
 
 #if ENABLE(CSS_SHADERS) && USE(3D_GRAPHICS)
 
+#include "CustomFilterConstants.h"
 #include "CustomFilterOperation.h"
 #include "FloatRect.h"
 
@@ -63,13 +64,8 @@ public:
 
     unsigned floatsPerVertex() const
     {
-        static const unsigned AttachedMeshVertexSize = 4 + // vec4 a_position
-                                                       2 + // vec2 a_texCoord
-                                                       2; // vec2 a_meshCoord
-
-        static const unsigned DetachedMeshVertexSize = AttachedMeshVertexSize +
-                                                       3; // vec3 a_triangleCoord
-
+        static const unsigned AttachedMeshVertexSize = PositionAttribSize + TexAttribSize + MeshAttribSize;
+        static const unsigned DetachedMeshVertexSize = AttachedMeshVertexSize + TriangleAttribSize;
         return m_meshType == CustomFilterOperation::ATTACHED ? AttachedMeshVertexSize : DetachedMeshVertexSize;
     }
 
index 3ceb7fa..d9a3c76 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "CustomFilterArrayParameter.h"
 #include "CustomFilterCompiledProgram.h"
+#include "CustomFilterConstants.h"
 #include "CustomFilterGlobalContext.h"
 #include "CustomFilterMesh.h"
 #include "CustomFilterNumberParameter.h"
@@ -570,18 +571,6 @@ void FECustomFilter::bindProgramAndBuffers(Platform3DObject inputTexture)
     m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_mesh->verticesBufferObject());
     m_context->bindBuffer(GraphicsContext3D::ELEMENT_ARRAY_BUFFER, m_mesh->elementsBufferObject());
 
-    // FIXME: Ideally, these should be public members of CustomFilterMesh.
-    // https://bugs.webkit.org/show_bug.cgi?id=94755
-    static const unsigned PositionAttribSize = 4;
-    static const unsigned TexAttribSize = 2;
-    static const unsigned MeshAttribSize = 2;
-    static const unsigned TriangleAttribSize = 3;
-
-    static const unsigned PositionAttribOffset = 0;
-    static const unsigned TexAttribOffset = PositionAttribOffset + PositionAttribSize * sizeof(float);
-    static const unsigned MeshAttribOffset = TexAttribOffset + TexAttribSize * sizeof(float);
-    static const unsigned TriangleAttribOffset = MeshAttribOffset + MeshAttribSize * sizeof(float);
-
     bindVertexAttribute(m_compiledProgram->positionAttribLocation(), PositionAttribSize, PositionAttribOffset);
     bindVertexAttribute(m_compiledProgram->texAttribLocation(), TexAttribSize, TexAttribOffset);
     // FIXME: Get rid of the internal tex coord attribute "css_a_texCoord".