Diff
Modified: trunk/Source/WebCore/ChangeLog (131356 => 131357)
--- trunk/Source/WebCore/ChangeLog 2012-10-15 21:22:08 UTC (rev 131356)
+++ trunk/Source/WebCore/ChangeLog 2012-10-15 21:23:53 UTC (rev 131357)
@@ -1,3 +1,49 @@
+2012-10-15 Michelangelo De Simone <michelang...@webkit.org>
+
+ [CSS Shaders] Add CustomFilterProgramType to CustomFilterProgramInfo
+ https://bugs.webkit.org/show_bug.cgi?id=96448
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ CustomFilterProgramInfo has been refactored to decouple the CustomFilterProgramType from
+ the CustomFilterProgramMixSetting: m_mixSettings.enabled was redundant in light of the fact
+ that m_programType encoded the very same information. Dependencies have been updated to reflect
+ this change.
+
+ Current tests already cover this code.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::CSSComputedStyleDeclaration::valueForFilter): The check for mixSettings.enabled has been replaced
+ by an explicit check for PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE program type.
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::createCustomFilterOperation): Setting the program type explicitly while creating a
+ new filter program.
+ * platform/graphics/filters/CustomFilterProgram.cpp:
+ (WebCore::CustomFilterProgram::CustomFilterProgram): CustomFilterProgram's constructor has been updated to
+ reflect the need of setting the program type explicitly.
+ (WebCore::CustomFilterProgram::programInfo): Updated to create new CustomFilterProgramInfo setting the program
+ type explicitly.
+ * platform/graphics/filters/CustomFilterProgram.h:
+ * platform/graphics/filters/CustomFilterProgramInfo.cpp:
+ (WebCore::CustomFilterProgramInfo::CustomFilterProgramInfo): Added m_programType and udpated the related getter.
+ (WebCore::CustomFilterProgramInfo::hash): ditto
+ (WebCore::CustomFilterProgramInfo::operator==): MixSettings' equality check is being performed only whether
+ the CustomFilterProgramInfo's program type is PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE.
+ * platform/graphics/filters/CustomFilterProgramInfo.h:
+ (WebCore::CustomFilterProgramMixSettings::CustomFilterProgramMixSettings): Got rid of the redundant enabled flag.
+ (WebCore::CustomFilterProgramMixSettings::operator==): ditto
+ (CustomFilterProgramInfo):
+ (WebCore::CustomFilterProgramInfo::programType):
+ * platform/graphics/filters/CustomFilterValidatedProgram.cpp: The right shader validator is now being
+ created according to the program type.
+ (WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram):
+ (WebCore::CustomFilterValidatedProgram::rewriteMixVertexShader): The reference to MixSettings' enabled flag
+ has been replaced with a check for the program type.
+ (WebCore::CustomFilterValidatedProgram::rewriteMixFragmentShader): ditto
+ * rendering/style/StyleCustomFilterProgram.h:
+ (WebCore::StyleCustomFilterProgram::create): Updated to be aware of the program type.
+ (WebCore::StyleCustomFilterProgram::StyleCustomFilterProgram): ditto
+
2012-10-15 Joshua Bell <jsb...@chromium.org>
IndexedDB: Key paths should support non-ASCII identifiers
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (131356 => 131357)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2012-10-15 21:22:08 UTC (rev 131356)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2012-10-15 21:23:53 UTC (rev 131357)
@@ -921,7 +921,7 @@
shadersList->append(cssValuePool().createIdentifierValue(CSSValueNone));
const CustomFilterProgramMixSettings mixSettings = program->mixSettings();
- if (mixSettings.enabled) {
+ if (program->programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) {
RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create();
mixFunction->append(program->fragmentShader()->cssValue());
mixFunction->append(cssValuePool().createValue(mixSettings.blendMode));
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (131356 => 131357)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2012-10-15 21:22:08 UTC (rev 131356)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2012-10-15 21:23:53 UTC (rev 131357)
@@ -4800,11 +4800,12 @@
RefPtr<StyleShader> vertexShader = styleShader(shadersList->itemWithoutBoundsCheck(0));
RefPtr<StyleShader> fragmentShader;
+ CustomFilterProgramType programType = PROGRAM_TYPE_NO_ELEMENT_TEXTURE;
CustomFilterProgramMixSettings mixSettings;
if (shadersList->length() > 1) {
CSSValue* fragmentShaderOrMixFunction = shadersList->itemWithoutBoundsCheck(1);
if (fragmentShaderOrMixFunction->isWebKitCSSMixFunctionValue()) {
- mixSettings.enabled = true;
+ programType = PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE;
WebKitCSSMixFunctionValue* mixFunction = static_cast<WebKitCSSMixFunctionValue*>(fragmentShaderOrMixFunction);
CSSValueListIterator iterator(mixFunction);
@@ -4894,7 +4895,7 @@
if (parametersValue && !parseCustomFilterParameterList(parametersValue, parameterList))
return 0;
- RefPtr<StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), mixSettings);
+ RefPtr<StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), programType, mixSettings);
return CustomFilterOperation::create(program.release(), parameterList, meshRows, meshColumns, meshBoxType, meshType);
}
#endif
Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp (131356 => 131357)
--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp 2012-10-15 21:22:08 UTC (rev 131356)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp 2012-10-15 21:23:53 UTC (rev 131357)
@@ -38,8 +38,9 @@
namespace WebCore {
-CustomFilterProgram::CustomFilterProgram(CustomFilterProgramMixSettings mixSettings)
- : m_mixSettings(mixSettings)
+CustomFilterProgram::CustomFilterProgram(CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings)
+ : m_programType(programType)
+ , m_mixSettings(mixSettings)
{
// Keep the constructor protected to prevent creating this object directly.
}
@@ -81,7 +82,7 @@
CustomFilterProgramInfo CustomFilterProgram::programInfo() const
{
ASSERT(isLoaded());
- return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString(), m_mixSettings);
+ return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString(), m_programType, m_mixSettings);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h (131356 => 131357)
--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h 2012-10-15 21:22:08 UTC (rev 131356)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h 2012-10-15 21:23:53 UTC (rev 131357)
@@ -58,6 +58,7 @@
void removeClient(CustomFilterProgramClient*);
CustomFilterProgramInfo programInfo() const;
+ CustomFilterProgramType programType() const { return m_programType; }
// StyleCustomFilterProgram has the only implementation for the following method. That means, it casts to StyleCustomFilterProgram
// withouth checking the type. If you add another implementation, also add a mechanism to check for the correct type.
@@ -75,11 +76,12 @@
virtual void didRemoveLastClient() = 0;
// Keep the constructor protected to prevent creating this object directly.
- CustomFilterProgram(CustomFilterProgramMixSettings);
+ CustomFilterProgram(CustomFilterProgramType, const CustomFilterProgramMixSettings&);
private:
typedef HashCountedSet<CustomFilterProgramClient*> CustomFilterProgramClientList;
CustomFilterProgramClientList m_clients;
+ CustomFilterProgramType m_programType;
CustomFilterProgramMixSettings m_mixSettings;
};
Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp (131356 => 131357)
--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp 2012-10-15 21:22:08 UTC (rev 131356)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp 2012-10-15 21:23:53 UTC (rev 131357)
@@ -64,9 +64,10 @@
&& m_fragmentShaderString.isHashTableDeletedValue();
}
-CustomFilterProgramInfo::CustomFilterProgramInfo(const String& vertexShader, const String& fragmentShader, const CustomFilterProgramMixSettings& mixSettings)
+CustomFilterProgramInfo::CustomFilterProgramInfo(const String& vertexShader, const String& fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings)
: m_vertexShaderString(vertexShader)
, m_fragmentShaderString(fragmentShader)
+ , m_programType(programType)
, m_mixSettings(mixSettings)
{
// At least one of the shaders needs to be non-null.
@@ -80,9 +81,9 @@
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
+ m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE,
+ m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE ? m_mixSettings.blendMode : 0,
+ m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE ? m_mixSettings.compositeOperator : 0
};
return StringHasher::hashMemory<sizeof(hashCodes)>(&hashCodes);
}
@@ -91,9 +92,16 @@
{
ASSERT(!isHashTableDeletedValue());
ASSERT(!o.isHashTableDeletedValue());
+
+ if (m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE)
+ return m_vertexShaderString == o.m_vertexShaderString
+ && m_fragmentShaderString == o.m_fragmentShaderString
+ && m_programType == o.m_programType
+ && m_mixSettings == o.m_mixSettings;
+
return m_vertexShaderString == o.m_vertexShaderString
&& m_fragmentShaderString == o.m_fragmentShaderString
- && m_mixSettings == o.m_mixSettings;
+ && m_programType == o.m_programType;
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.h (131356 => 131357)
--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.h 2012-10-15 21:22:08 UTC (rev 131356)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.h 2012-10-15 21:23:53 UTC (rev 131357)
@@ -45,19 +45,16 @@
struct CustomFilterProgramMixSettings {
CustomFilterProgramMixSettings()
- : enabled(false)
- , blendMode(BlendModeNormal)
+ : blendMode(BlendModeNormal)
, compositeOperator(CompositeSourceOver)
{
}
bool operator==(const CustomFilterProgramMixSettings& o) const
{
- return (!enabled && !o.enabled)
- || (blendMode == o.blendMode && compositeOperator == o.compositeOperator);
+ return blendMode == o.blendMode && compositeOperator == o.compositeOperator;
}
- bool enabled;
BlendMode blendMode;
CompositeOperator compositeOperator;
};
@@ -67,7 +64,7 @@
// Null strings are placeholders for the default shader.
class CustomFilterProgramInfo {
public:
- CustomFilterProgramInfo(const String&, const String&, const CustomFilterProgramMixSettings&);
+ CustomFilterProgramInfo(const String&, const String&, CustomFilterProgramType, const CustomFilterProgramMixSettings&);
CustomFilterProgramInfo();
bool isEmptyValue() const;
@@ -80,13 +77,12 @@
const String& vertexShaderString() const { return m_vertexShaderString; }
const String& fragmentShaderString() const { return m_fragmentShaderString; }
- // FIXME: We should add CustomFilterProgramType to CustomFilterProgramInfo and remove mixSettings.enabled.
- // https://bugs.webkit.org/show_bug.cgi?id=96448
- CustomFilterProgramType programType() const { return m_mixSettings.enabled ? PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE : PROGRAM_TYPE_NO_ELEMENT_TEXTURE; }
+ CustomFilterProgramType programType() const { return m_programType; }
const CustomFilterProgramMixSettings& mixSettings() const { return m_mixSettings; }
private:
String m_vertexShaderString;
String m_fragmentShaderString;
+ CustomFilterProgramType m_programType;
CustomFilterProgramMixSettings m_mixSettings;
};
Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp (131356 => 131357)
--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp 2012-10-15 21:22:08 UTC (rev 131356)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp 2012-10-15 21:23:53 UTC (rev 131357)
@@ -83,7 +83,8 @@
originalFragmentShader = defaultFragmentShaderString();
// Shaders referenced from the CSS mix function use a different validator than regular WebGL shaders. See CustomFilterGlobalContext.h for more details.
- ANGLEWebKitBridge* validator = programInfo.mixSettings().enabled ? m_globalContext->mixShaderValidator() : m_globalContext->webglShaderValidator();
+ bool blendsElementTexture = (programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE);
+ ANGLEWebKitBridge* validator = blendsElementTexture ? m_globalContext->mixShaderValidator() : m_globalContext->webglShaderValidator();
String vertexShaderLog, fragmentShaderLog;
Vector<ANGLEShaderSymbol> symbols;
bool vertexShaderValid = validator->compileShaderSource(originalVertexShader.utf8().data(), SHADER_TYPE_VERTEX, m_validatedVertexShader, vertexShaderLog, symbols);
@@ -107,7 +108,7 @@
}
// We need to add texture access, blending, and compositing code to shaders that are referenced from the CSS mix function.
- if (programInfo.mixSettings().enabled) {
+ if (blendsElementTexture) {
rewriteMixVertexShader();
rewriteMixFragmentShader();
}
@@ -125,7 +126,7 @@
void CustomFilterValidatedProgram::rewriteMixVertexShader()
{
- ASSERT(m_programInfo.mixSettings().enabled);
+ ASSERT(m_programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE);
// During validation, ANGLE renamed the author's "main" function to "css_main".
// We write our own "main" function and call "css_main" from it.
@@ -144,7 +145,7 @@
void CustomFilterValidatedProgram::rewriteMixFragmentShader()
{
- ASSERT(m_programInfo.mixSettings().enabled);
+ ASSERT(m_programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE);
StringBuilder builder;
// ANGLE considered these symbols as built-ins during validation under the SH_CSS_SHADERS_SPEC flag.
Modified: trunk/Source/WebCore/rendering/style/StyleCustomFilterProgram.h (131356 => 131357)
--- trunk/Source/WebCore/rendering/style/StyleCustomFilterProgram.h 2012-10-15 21:22:08 UTC (rev 131356)
+++ trunk/Source/WebCore/rendering/style/StyleCustomFilterProgram.h 2012-10-15 21:23:53 UTC (rev 131357)
@@ -45,9 +45,9 @@
class StyleCustomFilterProgram : public CustomFilterProgram, public CachedResourceClient {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassRefPtr<StyleCustomFilterProgram> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramMixSettings mixSettings)
+ static PassRefPtr<StyleCustomFilterProgram> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings)
{
- return adoptRef(new StyleCustomFilterProgram(vertexShader, fragmentShader, mixSettings));
+ return adoptRef(new StyleCustomFilterProgram(vertexShader, fragmentShader, programType, mixSettings));
}
void setVertexShader(PassRefPtr<StyleShader> shader) { m_vertexShader = shader; }
@@ -126,8 +126,8 @@
}
private:
- StyleCustomFilterProgram(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramMixSettings mixSettings)
- : CustomFilterProgram(mixSettings)
+ StyleCustomFilterProgram(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings)
+ : CustomFilterProgram(programType, mixSettings)
, m_vertexShader(vertexShader)
, m_fragmentShader(fragmentShader)
, m_isVertexShaderLoaded(false)