Changeset 131357 in webkit
- Timestamp:
- Oct 15, 2012 2:23:53 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r131356 r131357 1 2012-10-15 Michelangelo De Simone <michelangelo@webkit.org> 2 3 [CSS Shaders] Add CustomFilterProgramType to CustomFilterProgramInfo 4 https://bugs.webkit.org/show_bug.cgi?id=96448 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 CustomFilterProgramInfo has been refactored to decouple the CustomFilterProgramType from 9 the CustomFilterProgramMixSetting: m_mixSettings.enabled was redundant in light of the fact 10 that m_programType encoded the very same information. Dependencies have been updated to reflect 11 this change. 12 13 Current tests already cover this code. 14 15 * css/CSSComputedStyleDeclaration.cpp: 16 (WebCore::CSSComputedStyleDeclaration::valueForFilter): The check for mixSettings.enabled has been replaced 17 by an explicit check for PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE program type. 18 * css/StyleResolver.cpp: 19 (WebCore::StyleResolver::createCustomFilterOperation): Setting the program type explicitly while creating a 20 new filter program. 21 * platform/graphics/filters/CustomFilterProgram.cpp: 22 (WebCore::CustomFilterProgram::CustomFilterProgram): CustomFilterProgram's constructor has been updated to 23 reflect the need of setting the program type explicitly. 24 (WebCore::CustomFilterProgram::programInfo): Updated to create new CustomFilterProgramInfo setting the program 25 type explicitly. 26 * platform/graphics/filters/CustomFilterProgram.h: 27 * platform/graphics/filters/CustomFilterProgramInfo.cpp: 28 (WebCore::CustomFilterProgramInfo::CustomFilterProgramInfo): Added m_programType and udpated the related getter. 29 (WebCore::CustomFilterProgramInfo::hash): ditto 30 (WebCore::CustomFilterProgramInfo::operator==): MixSettings' equality check is being performed only whether 31 the CustomFilterProgramInfo's program type is PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE. 32 * platform/graphics/filters/CustomFilterProgramInfo.h: 33 (WebCore::CustomFilterProgramMixSettings::CustomFilterProgramMixSettings): Got rid of the redundant enabled flag. 34 (WebCore::CustomFilterProgramMixSettings::operator==): ditto 35 (CustomFilterProgramInfo): 36 (WebCore::CustomFilterProgramInfo::programType): 37 * platform/graphics/filters/CustomFilterValidatedProgram.cpp: The right shader validator is now being 38 created according to the program type. 39 (WebCore::CustomFilterValidatedProgram::CustomFilterValidatedProgram): 40 (WebCore::CustomFilterValidatedProgram::rewriteMixVertexShader): The reference to MixSettings' enabled flag 41 has been replaced with a check for the program type. 42 (WebCore::CustomFilterValidatedProgram::rewriteMixFragmentShader): ditto 43 * rendering/style/StyleCustomFilterProgram.h: 44 (WebCore::StyleCustomFilterProgram::create): Updated to be aware of the program type. 45 (WebCore::StyleCustomFilterProgram::StyleCustomFilterProgram): ditto 46 1 47 2012-10-15 Joshua Bell <jsbell@chromium.org> 2 48 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r130829 r131357 922 922 923 923 const CustomFilterProgramMixSettings mixSettings = program->mixSettings(); 924 if ( mixSettings.enabled) {924 if (program->programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) { 925 925 RefPtr<WebKitCSSMixFunctionValue> mixFunction = WebKitCSSMixFunctionValue::create(); 926 926 mixFunction->append(program->fragmentShader()->cssValue()); -
trunk/Source/WebCore/css/StyleResolver.cpp
r131136 r131357 4801 4801 4802 4802 RefPtr<StyleShader> fragmentShader; 4803 CustomFilterProgramType programType = PROGRAM_TYPE_NO_ELEMENT_TEXTURE; 4803 4804 CustomFilterProgramMixSettings mixSettings; 4804 4805 if (shadersList->length() > 1) { 4805 4806 CSSValue* fragmentShaderOrMixFunction = shadersList->itemWithoutBoundsCheck(1); 4806 4807 if (fragmentShaderOrMixFunction->isWebKitCSSMixFunctionValue()) { 4807 mixSettings.enabled = true;4808 programType = PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE; 4808 4809 WebKitCSSMixFunctionValue* mixFunction = static_cast<WebKitCSSMixFunctionValue*>(fragmentShaderOrMixFunction); 4809 4810 CSSValueListIterator iterator(mixFunction); … … 4895 4896 return 0; 4896 4897 4897 RefPtr<StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), mixSettings);4898 RefPtr<StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), programType, mixSettings); 4898 4899 return CustomFilterOperation::create(program.release(), parameterList, meshRows, meshColumns, meshBoxType, meshType); 4899 4900 } -
trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp
r130612 r131357 39 39 namespace WebCore { 40 40 41 CustomFilterProgram::CustomFilterProgram(CustomFilterProgramMixSettings mixSettings) 42 : m_mixSettings(mixSettings) 41 CustomFilterProgram::CustomFilterProgram(CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings) 42 : m_programType(programType) 43 , m_mixSettings(mixSettings) 43 44 { 44 45 // Keep the constructor protected to prevent creating this object directly. … … 82 83 { 83 84 ASSERT(isLoaded()); 84 return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString(), m_ mixSettings);85 return CustomFilterProgramInfo(vertexShaderString(), fragmentShaderString(), m_programType, m_mixSettings); 85 86 } 86 87 -
trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h
r125331 r131357 59 59 60 60 CustomFilterProgramInfo programInfo() const; 61 CustomFilterProgramType programType() const { return m_programType; } 61 62 62 63 // StyleCustomFilterProgram has the only implementation for the following method. That means, it casts to StyleCustomFilterProgram … … 76 77 77 78 // Keep the constructor protected to prevent creating this object directly. 78 CustomFilterProgram(CustomFilterProgram MixSettings);79 CustomFilterProgram(CustomFilterProgramType, const CustomFilterProgramMixSettings&); 79 80 80 81 private: 81 82 typedef HashCountedSet<CustomFilterProgramClient*> CustomFilterProgramClientList; 82 83 CustomFilterProgramClientList m_clients; 84 CustomFilterProgramType m_programType; 83 85 CustomFilterProgramMixSettings m_mixSettings; 84 86 }; -
trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.cpp
r125331 r131357 65 65 } 66 66 67 CustomFilterProgramInfo::CustomFilterProgramInfo(const String& vertexShader, const String& fragmentShader, const CustomFilterProgramMixSettings& mixSettings)67 CustomFilterProgramInfo::CustomFilterProgramInfo(const String& vertexShader, const String& fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings) 68 68 : m_vertexShaderString(vertexShader) 69 69 , m_fragmentShaderString(fragmentShader) 70 , m_programType(programType) 70 71 , m_mixSettings(mixSettings) 71 72 { … … 81 82 hashPossiblyNullString(m_vertexShaderString), 82 83 hashPossiblyNullString(m_fragmentShaderString), 83 m_ mixSettings.enabled,84 m_ mixSettings.enabled? m_mixSettings.blendMode : 0,85 m_ mixSettings.enabled? m_mixSettings.compositeOperator : 084 m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE, 85 m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE ? m_mixSettings.blendMode : 0, 86 m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE ? m_mixSettings.compositeOperator : 0 86 87 }; 87 88 return StringHasher::hashMemory<sizeof(hashCodes)>(&hashCodes); … … 92 93 ASSERT(!isHashTableDeletedValue()); 93 94 ASSERT(!o.isHashTableDeletedValue()); 95 96 if (m_programType == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE) 97 return m_vertexShaderString == o.m_vertexShaderString 98 && m_fragmentShaderString == o.m_fragmentShaderString 99 && m_programType == o.m_programType 100 && m_mixSettings == o.m_mixSettings; 101 94 102 return m_vertexShaderString == o.m_vertexShaderString 95 103 && m_fragmentShaderString == o.m_fragmentShaderString 96 && m_ mixSettings == o.m_mixSettings;104 && m_programType == o.m_programType; 97 105 } 98 106 -
trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgramInfo.h
r128334 r131357 46 46 struct CustomFilterProgramMixSettings { 47 47 CustomFilterProgramMixSettings() 48 : enabled(false) 49 , blendMode(BlendModeNormal) 48 : blendMode(BlendModeNormal) 50 49 , compositeOperator(CompositeSourceOver) 51 50 { … … 54 53 bool operator==(const CustomFilterProgramMixSettings& o) const 55 54 { 56 return (!enabled && !o.enabled) 57 || (blendMode == o.blendMode && compositeOperator == o.compositeOperator); 55 return blendMode == o.blendMode && compositeOperator == o.compositeOperator; 58 56 } 59 57 60 bool enabled;61 58 BlendMode blendMode; 62 59 CompositeOperator compositeOperator; … … 68 65 class CustomFilterProgramInfo { 69 66 public: 70 CustomFilterProgramInfo(const String&, const String&, const CustomFilterProgramMixSettings&);67 CustomFilterProgramInfo(const String&, const String&, CustomFilterProgramType, const CustomFilterProgramMixSettings&); 71 68 72 69 CustomFilterProgramInfo(); … … 81 78 const String& vertexShaderString() const { return m_vertexShaderString; } 82 79 const String& fragmentShaderString() const { return m_fragmentShaderString; } 83 // FIXME: We should add CustomFilterProgramType to CustomFilterProgramInfo and remove mixSettings.enabled. 84 // https://bugs.webkit.org/show_bug.cgi?id=96448 85 CustomFilterProgramType programType() const { return m_mixSettings.enabled ? PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE : PROGRAM_TYPE_NO_ELEMENT_TEXTURE; } 80 CustomFilterProgramType programType() const { return m_programType; } 86 81 const CustomFilterProgramMixSettings& mixSettings() const { return m_mixSettings; } 87 82 private: 88 83 String m_vertexShaderString; 89 84 String m_fragmentShaderString; 85 CustomFilterProgramType m_programType; 90 86 CustomFilterProgramMixSettings m_mixSettings; 91 87 }; -
trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.cpp
r131128 r131357 84 84 85 85 // Shaders referenced from the CSS mix function use a different validator than regular WebGL shaders. See CustomFilterGlobalContext.h for more details. 86 ANGLEWebKitBridge* validator = programInfo.mixSettings().enabled ? m_globalContext->mixShaderValidator() : m_globalContext->webglShaderValidator(); 86 bool blendsElementTexture = (programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE); 87 ANGLEWebKitBridge* validator = blendsElementTexture ? m_globalContext->mixShaderValidator() : m_globalContext->webglShaderValidator(); 87 88 String vertexShaderLog, fragmentShaderLog; 88 89 Vector<ANGLEShaderSymbol> symbols; … … 108 109 109 110 // We need to add texture access, blending, and compositing code to shaders that are referenced from the CSS mix function. 110 if ( programInfo.mixSettings().enabled) {111 if (blendsElementTexture) { 111 112 rewriteMixVertexShader(); 112 113 rewriteMixFragmentShader(); … … 126 127 void CustomFilterValidatedProgram::rewriteMixVertexShader() 127 128 { 128 ASSERT(m_programInfo. mixSettings().enabled);129 ASSERT(m_programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE); 129 130 130 131 // During validation, ANGLE renamed the author's "main" function to "css_main". … … 145 146 void CustomFilterValidatedProgram::rewriteMixFragmentShader() 146 147 { 147 ASSERT(m_programInfo. mixSettings().enabled);148 ASSERT(m_programInfo.programType() == PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE); 148 149 149 150 StringBuilder builder; -
trunk/Source/WebCore/rendering/style/StyleCustomFilterProgram.h
r125128 r131357 46 46 WTF_MAKE_FAST_ALLOCATED; 47 47 public: 48 static PassRefPtr<StyleCustomFilterProgram> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgram MixSettingsmixSettings)48 static PassRefPtr<StyleCustomFilterProgram> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings) 49 49 { 50 return adoptRef(new StyleCustomFilterProgram(vertexShader, fragmentShader, mixSettings));50 return adoptRef(new StyleCustomFilterProgram(vertexShader, fragmentShader, programType, mixSettings)); 51 51 } 52 52 … … 127 127 128 128 private: 129 StyleCustomFilterProgram(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgram MixSettingsmixSettings)130 : CustomFilterProgram( mixSettings)129 StyleCustomFilterProgram(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings) 130 : CustomFilterProgram(programType, mixSettings) 131 131 , m_vertexShader(vertexShader) 132 132 , m_fragmentShader(fragmentShader)
Note: See TracChangeset
for help on using the changeset viewer.