Title: [125331] trunk/Source/WebCore
Revision
125331
Author
[email protected]
Date
2012-08-10 15:15:52 -0700 (Fri, 10 Aug 2012)

Log Message

[CSS Shaders] Add blend mode and composite op to compiled program cache key
https://bugs.webkit.org/show_bug.cgi?id=93623

Patch by Max Vujovic <[email protected]> on 2012-08-10
Reviewed by Dirk Schulze.

Right now, only the vertex shader string and the fragment shader string are hashed
to create a key for the compiled program. However, in a future patch, WebKit will
rewrite the fragment shader based on the blend mode and composite op specified by
the author. This means that the unique key for a compiled program is (original
vertex shader string, original fragment shader string, blend mode, composite
operator). This patch adds blend mode and composite operator in the hash for the
key.

No new tests. The state of the compiled program cache is not exposed to a web
page. Existing tests should ensure this change doesn't break current
functionality. Additional tests will be added in a future patch that implements
shader rewriting based on blend mode and composite op.

* platform/graphics/filters/CustomFilterProgram.cpp:
(WebCore::CustomFilterProgram::programInfo):
* platform/graphics/filters/CustomFilterProgram.h:
(WebCore):
* platform/graphics/filters/CustomFilterProgramInfo.cpp:
(WebCore::CustomFilterProgramInfo::CustomFilterProgramInfo):
(WebCore::CustomFilterProgramInfo::hash):
(WebCore::CustomFilterProgramInfo::operator==):
* platform/graphics/filters/CustomFilterProgramInfo.h:
(WebCore::CustomFilterProgramMixSettings::CustomFilterProgramMixSettings):
(CustomFilterProgramMixSettings):
(WebCore::CustomFilterProgramMixSettings::operator==):
(WebCore):
(CustomFilterProgramInfo):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125330 => 125331)


--- trunk/Source/WebCore/ChangeLog	2012-08-10 21:48:04 UTC (rev 125330)
+++ trunk/Source/WebCore/ChangeLog	2012-08-10 22:15:52 UTC (rev 125331)
@@ -1,3 +1,38 @@
+2012-08-10  Max Vujovic  <[email protected]>
+
+        [CSS Shaders] Add blend mode and composite op to compiled program cache key
+        https://bugs.webkit.org/show_bug.cgi?id=93623
+
+        Reviewed by Dirk Schulze.
+
+        Right now, only the vertex shader string and the fragment shader string are hashed
+        to create a key for the compiled program. However, in a future patch, WebKit will
+        rewrite the fragment shader based on the blend mode and composite op specified by
+        the author. This means that the unique key for a compiled program is (original
+        vertex shader string, original fragment shader string, blend mode, composite
+        operator). This patch adds blend mode and composite operator in the hash for the
+        key.
+
+        No new tests. The state of the compiled program cache is not exposed to a web
+        page. Existing tests should ensure this change doesn't break current
+        functionality. Additional tests will be added in a future patch that implements
+        shader rewriting based on blend mode and composite op.
+
+        * platform/graphics/filters/CustomFilterProgram.cpp:
+        (WebCore::CustomFilterProgram::programInfo):
+        * platform/graphics/filters/CustomFilterProgram.h:
+        (WebCore):
+        * platform/graphics/filters/CustomFilterProgramInfo.cpp:
+        (WebCore::CustomFilterProgramInfo::CustomFilterProgramInfo):
+        (WebCore::CustomFilterProgramInfo::hash):
+        (WebCore::CustomFilterProgramInfo::operator==):
+        * platform/graphics/filters/CustomFilterProgramInfo.h:
+        (WebCore::CustomFilterProgramMixSettings::CustomFilterProgramMixSettings):
+        (CustomFilterProgramMixSettings):
+        (WebCore::CustomFilterProgramMixSettings::operator==):
+        (WebCore):
+        (CustomFilterProgramInfo):
+
 2012-08-10  Alice Cheng  <[email protected]>
 
         Part 1 of: Extend -webkit-user-select with a new value "all"

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp (125330 => 125331)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp	2012-08-10 21:48:04 UTC (rev 125330)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp	2012-08-10 22:15:52 UTC (rev 125331)
@@ -81,7 +81,7 @@
 CustomFilterProgramInfo CustomFilterProgram::programInfo() const
 {
     ASSERT(isLoaded());
-    return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString());
+    return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString(), m_mixSettings);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h (125330 => 125331)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h	2012-08-10 21:48:04 UTC (rev 125330)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h	2012-08-10 22:15:52 UTC (rev 125331)
@@ -32,7 +32,7 @@
 
 #if ENABLE(CSS_SHADERS)
 
-#include "GraphicsTypes.h"
+#include "CustomFilterProgramInfo.h"
 
 #include <wtf/HashCountedSet.h>
 #include <wtf/RefCounted.h>
@@ -43,21 +43,7 @@
 class GraphicsContext3D;
 class CustomFilterCompiledProgram;
 class CustomFilterProgramClient;
-class CustomFilterProgramInfo;
 
-typedef struct CustomFilterProgramMixSettings {
-    CustomFilterProgramMixSettings()
-        : enabled(false)
-        , blendMode(BlendModeNormal)
-        , compositeOperator(CompositeSourceOver)
-    {
-    }
-    
-    bool enabled;
-    BlendMode blendMode;
-    CompositeOperator compositeOperator;
-} CustomFilterProgramMixSettings;
-
 // This is the base class for the StyleCustomFilterProgram class which knows how to keep
 // references to the cached shaders.
 class CustomFilterProgram: public RefCounted<CustomFilterProgram> {

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp (125330 => 125331)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp	2012-08-10 21:48:04 UTC (rev 125330)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp	2012-08-10 22:15:52 UTC (rev 125331)
@@ -64,19 +64,27 @@
         && m_fragmentShaderString.isHashTableDeletedValue();
 }
 
-CustomFilterProgramInfo::CustomFilterProgramInfo(const String& vertexShader, const String& fragmentShader)
+CustomFilterProgramInfo::CustomFilterProgramInfo(const String& vertexShader, const String& fragmentShader, const CustomFilterProgramMixSettings& mixSettings)
     : m_vertexShaderString(vertexShader)
     , m_fragmentShaderString(fragmentShader)
+    , m_mixSettings(mixSettings)
 {
     // At least one of the shaders needs to be non-null.
     ASSERT(!m_vertexShaderString.isNull() || !m_fragmentShaderString.isNull());
 }
 
-unsigned CustomFilterProgramInfo::hash() const 
+unsigned CustomFilterProgramInfo::hash() const
 {
     // At least one of the shaders needs to be non-null.
     ASSERT(!m_vertexShaderString.isNull() || !m_fragmentShaderString.isNull());
-    return WTF::intHash((static_cast<uint64_t>(hashPossiblyNullString(m_vertexShaderString)) << 32 | hashPossiblyNullString(m_fragmentShaderString)));
+    uintptr_t hashCodes[5] = {
+        hashPossiblyNullString(m_vertexShaderString),
+        hashPossiblyNullString(m_fragmentShaderString),
+        m_mixSettings.enabled,
+        m_mixSettings.enabled ? m_mixSettings.blendMode : 0,
+        m_mixSettings.enabled ? m_mixSettings.compositeOperator : 0
+    };
+    return StringHasher::hashMemory<sizeof(hashCodes)>(&hashCodes);
 }
 
 bool CustomFilterProgramInfo::operator==(const CustomFilterProgramInfo& o) const 
@@ -84,7 +92,8 @@
     ASSERT(!isHashTableDeletedValue());
     ASSERT(!o.isHashTableDeletedValue());
     return m_vertexShaderString == o.m_vertexShaderString
-        && m_fragmentShaderString == o.m_fragmentShaderString;
+        && m_fragmentShaderString == o.m_fragmentShaderString
+        && m_mixSettings == o.m_mixSettings;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.h (125330 => 125331)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.h	2012-08-10 21:48:04 UTC (rev 125330)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.h	2012-08-10 22:15:52 UTC (rev 125331)
@@ -31,17 +31,38 @@
 #define CustomFilterProgramInfo_h
 
 #if ENABLE(CSS_SHADERS)
+#include "GraphicsTypes.h"
+
 #include <wtf/HashTraits.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
+struct CustomFilterProgramMixSettings {
+    CustomFilterProgramMixSettings()
+        : enabled(false)
+        , blendMode(BlendModeNormal)
+        , compositeOperator(CompositeSourceOver)
+    {
+    }
+    
+    bool operator==(const CustomFilterProgramMixSettings& o) const
+    {
+        return (!enabled && !o.enabled)
+            || (blendMode == o.blendMode && compositeOperator == o.compositeOperator);
+    }
+    
+    bool enabled;
+    BlendMode blendMode;
+    CompositeOperator compositeOperator;
+};
+
 // CustomFilterProgramInfo is the key used to link CustomFilterProgram with CustomFilterCompiledProgram.
 // It can be used as a key in a HashMap, with the note that at least one of Strings needs to be non-null. 
 // Null strings are placeholders for the default shader.
 class CustomFilterProgramInfo {
 public:
-    CustomFilterProgramInfo(const String&, const String&);
+    CustomFilterProgramInfo(const String&, const String&, const CustomFilterProgramMixSettings&);
 
     CustomFilterProgramInfo();
     bool isEmptyValue() const;
@@ -57,9 +78,7 @@
 private:
     String m_vertexShaderString;
     String m_fragmentShaderString;
-
-    // FIXME: Alpha compositing and blending will come here after mix() function parsing will land.
-    // https://bugs.webkit.org/show_bug.cgi?id=90101
+    CustomFilterProgramMixSettings m_mixSettings;
 };
 
 struct CustomFilterProgramInfoHash {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to