Changeset 146529 in webkit
- Timestamp:
- Mar 21, 2013 3:17:44 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 17 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r146525 r146529 1 2013-03-21 Alexandru Chiculita <achicu@adobe.com> 2 3 [CSS Shaders] Implement a StyleCustomFilterProgram cache 4 https://bugs.webkit.org/show_bug.cgi?id=112602 5 6 Reviewed by Dean Jackson. 7 8 Added a new test to check for the case when the style is recalculated but the 9 filter property is not changed. All the other cases for the new StyleCustomFilterProgramCache 10 class should be tested by existing tests. 11 12 * css3/filters/custom/custom-filter-reload-expected.txt: Added. 13 * css3/filters/custom/custom-filter-reload.html: Added. 14 1 15 2013-03-21 Jochen Eisinger <jochen@chromium.org> 2 16 -
trunk/Source/WebCore/ChangeLog
r146527 r146529 1 2013-03-21 Alexandru Chiculita <achicu@adobe.com> 2 3 [CSS Shaders] Implement a StyleCustomFilterProgram cache 4 https://bugs.webkit.org/show_bug.cgi?id=112602 5 6 Reviewed by Dean Jackson. 7 8 When the style is recalculated, the new computed RenderStyle is saved as the m_style of the 9 RenderObject, even if the style was not different. 10 11 In the case of Custom Filters, a new StyleCustomFilterProgram was created at all times, but the 12 actual equality check was done by comparing the pair of cached shaders from inside the StyleCustomFilterProgram. 13 14 Because of that the RenderLayer::styleChanged was not called when the new StyleCustomFilterProgram was created, so it 15 will end up still knowing only about the previous StyleCustomFilterProgram. 16 17 The RenderLayer sets itself as a client of the StyleCustomFilterProgram, so that it can repaint itself 18 when the program is loaded, but because RenderLayer::styleChanged is not called, it will not add itself as a client of the new 19 StyleCustomFilterProgram. 20 21 StyleCustomFilterProgram waits until the first client to load the programs, so in this case it will just remain unloaded. 22 23 There was no crash, but just an assert in debug mode. Also, as a visible side-effect some frames were rendered using blank shaders, 24 resulting in a pass-through filter. 25 26 The fix would be to actually make the RenderStyle::diff detect the change of the StyleCustomFilterProgram 27 using the pointer value and not the values. However, that will always invalidate the "filter" property because 28 of the StyleCustomFilterProgram that always gets created during the recalculation time. 29 30 I've added StyleCustomFilterProgramCache to cache all the instances of the StyleCustomFilterPrograms that a 31 StyleResolver allocates. This way, next time it will try to reuse previously allocated StyleCustomFilterPrograms. 32 The key of the cache is the CustomFilterProgramInfo, that combines the URLs to the shaders and a couple of other program settings. 33 34 StyleCustomFilterProgramCache is owned by the StyleResovler and StyleCustomFilterPrograms are responsible with 35 removing themselves from the cache when the last reference goes away. 36 37 This change makes the previous "platform level" program cache obsolete and I will remove that in a future patch. 38 https://bugs.webkit.org/show_bug.cgi?id=112844 39 40 Test: css3/filters/custom/custom-filter-reload.html 41 42 * GNUmakefile.list.am: 43 * Target.pri: 44 * WebCore.gypi: 45 * WebCore.vcproj/WebCore.vcproj: 46 * WebCore.xcodeproj/project.pbxproj: 47 * css/StyleResolver.cpp: 48 (WebCore::StyleResolver::lookupCustomFilterProgram): Lookup any similar programs in the cache. It will create a new pending 49 StyleCustomFilterProgram if there is no pre-cached version of the program. 50 if no program is found. loadPendingShaders is responsible for adding the program in the cache if it is actually going to be used. 51 (WebCore::StyleResolver::loadPendingShaders): At this point the program is final, so it's safe to add it to the cache. 52 (WebCore::StyleResolver::createCustomFilterOperationWithInlineSyntax): 53 * css/StyleResolver.h: 54 (StyleResolver): 55 * css/WebKitCSSShaderValue.cpp: 56 (WebCore::WebKitCSSShaderValue::completeURL): Factored out the function to compute the complete URL of the resource. 57 (WebCore::WebKitCSSShaderValue::cachedShader): 58 * css/WebKitCSSShaderValue.h: 59 (WebCore::toWebKitCSSShaderValue): 60 (WebKitCSSShaderValue): 61 * platform/graphics/filters/CustomFilterOperation.cpp: 62 (WebCore::CustomFilterOperation::blend): 63 * platform/graphics/filters/CustomFilterOperation.h: 64 (WebCore::CustomFilterOperation::operator==): Removed. Programs should now compare by pointer. Kept it as 65 private to catch any potential use of it. 66 * rendering/style/StyleCustomFilterProgram.cpp: Copied from Source/WebCore/css/WebKitCSSShaderValue.h. 67 (WebCore::StyleCustomFilterProgram::~StyleCustomFilterProgram): Destructor removes the program from the cache. 68 * rendering/style/StyleCustomFilterProgram.h: 69 (WebCore::StyleCustomFilterProgram::setVertexShader): Added an assert to check that the shader is not in the 70 cache while the mutation happens. Otherwise the cache might have the wrong key. 71 (WebCore::StyleCustomFilterProgram::setFragmentShader): Ditto. 72 (WebCore::StyleCustomFilterProgram::isLoaded): Added more asserts to catch cases when the program is used with no clients. 73 (StyleCustomFilterProgram): 74 (WebCore::StyleCustomFilterProgram::hasPendingShaders): 75 (WebCore::StyleCustomFilterProgram::inCache): 76 (WebCore::StyleCustomFilterProgram::setCache): Function called when a program is added to / removed from the cache. 77 (WebCore::StyleCustomFilterProgram::vertexShaderURL): Added methods to store the KURL that we used as keys in the cache. 78 The same KURLs will be used to lookup and remove the filter at the end. 79 (WebCore::StyleCustomFilterProgram::setVertexShaderURL): 80 (WebCore::StyleCustomFilterProgram::fragmentShaderURL): 81 (WebCore::StyleCustomFilterProgram::setFragmentShaderURL): 82 (WebCore::StyleCustomFilterProgram::StyleCustomFilterProgram): 83 * rendering/style/StyleCustomFilterProgramCache.cpp: Added. 84 (WebCore::StyleCustomFilterProgramCache::programCacheKey): 85 (WebCore::StyleCustomFilterProgramCache::StyleCustomFilterProgramCache): 86 (WebCore::StyleCustomFilterProgramCache::~StyleCustomFilterProgramCache): Destructor removes itself from all the 87 referenced StyleCustomFilterPrograms. This is to avoid issues with different destruction orders. 88 (WebCore::StyleCustomFilterProgramCache::lookup): 89 (WebCore::StyleCustomFilterProgramCache::add): 90 (WebCore::StyleCustomFilterProgramCache::remove): 91 * rendering/style/StyleCustomFilterProgramCache.h: 92 (StyleCustomFilterProgramCache): 93 * platform/graphics/texmap/coordinated/CoordinatedCustomFilterProgram.h: 94 (WebCore::CoordinatedCustomFilterProgram::operator==: Removed. Programs should now compare by pointer. 95 1 96 2013-03-21 Joshua Bell <jsbell@chromium.org> 2 97 -
trunk/Source/WebCore/GNUmakefile.list.am
r146508 r146529 4664 4664 Source/WebCore/rendering/style/StyleCachedShader.cpp \ 4665 4665 Source/WebCore/rendering/style/StyleCachedShader.h \ 4666 Source/WebCore/rendering/style/StyleCustomFilterProgram.cpp \ 4666 4667 Source/WebCore/rendering/style/StyleCustomFilterProgram.h \ 4668 Source/WebCore/rendering/style/StyleCustomFilterProgramCache.cpp \ 4669 Source/WebCore/rendering/style/StyleCustomFilterProgramCache.h \ 4667 4670 Source/WebCore/rendering/style/StyleDashboardRegion.h \ 4668 4671 Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp \ -
trunk/Source/WebCore/Target.pri
r146508 r146529 1287 1287 rendering/style/StyleCachedImageSet.cpp \ 1288 1288 rendering/style/StyleCachedShader.cpp \ 1289 rendering/style/StyleCustomFilterProgram.cpp \ 1290 rendering/style/StyleCustomFilterProgramCache.cpp \ 1289 1291 rendering/style/StyleDeprecatedFlexibleBoxData.cpp \ 1290 1292 rendering/style/StyleFilterData.cpp \ … … 2584 2586 rendering/style/StyleCachedShader.h \ 2585 2587 rendering/style/StyleCustomFilterProgram.h \ 2588 rendering/style/StyleCustomFilterProgramCache.h \ 2586 2589 rendering/style/StyleDeprecatedFlexibleBoxData.h \ 2587 2590 rendering/style/StyleFilterData.h \ -
trunk/Source/WebCore/WebCore.gypi
r146508 r146529 2657 2657 'rendering/style/StyleCachedShader.h', 2658 2658 'rendering/style/StyleCachedShader.cpp', 2659 'rendering/style/StyleCustomFilterProgramCache.cpp', 2660 'rendering/style/StyleCustomFilterProgramCache.h', 2661 'rendering/style/StyleCustomFilterProgram.cpp', 2659 2662 'rendering/style/StyleCustomFilterProgram.h', 2660 2663 'rendering/style/StyleDeprecatedFlexibleBoxData.cpp', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r146508 r146529 46969 46969 </File> 46970 46970 <File 46971 RelativePath="..\rendering\style\StyleCustomFilterProgram.cpp" 46972 > 46973 </File> 46974 <File 46975 RelativePath="..\rendering\style\StyleCustomFilterProgramCache.h" 46976 > 46977 </File> 46978 <File 46979 RelativePath="..\rendering\style\StyleCustomFilterProgramCache.cpp" 46980 > 46981 </File> 46982 <File 46971 46983 RelativePath="..\rendering\style\StyleDeprecatedFlexibleBoxData.cpp" 46972 46984 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r146508 r146529 1572 1572 50D88CB515BDFDAA001809F4 /* CustomFilterProgramInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D88CB315BDFDAA001809F4 /* CustomFilterProgramInfo.cpp */; }; 1573 1573 50D88CB615BDFDAA001809F4 /* CustomFilterProgramInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 50D88CB415BDFDAA001809F4 /* CustomFilterProgramInfo.h */; }; 1574 50E18CD816F9285800C65486 /* StyleCustomFilterProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E18CD516F9285800C65486 /* StyleCustomFilterProgram.cpp */; }; 1575 50E18CD916F9285800C65486 /* StyleCustomFilterProgramCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50E18CD616F9285800C65486 /* StyleCustomFilterProgramCache.cpp */; }; 1576 50E18CDA16F9285800C65486 /* StyleCustomFilterProgramCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 50E18CD716F9285800C65486 /* StyleCustomFilterProgramCache.h */; }; 1574 1577 510184690B08602A004A825F /* CachedPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 510184670B08602A004A825F /* CachedPage.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1575 1578 5101846A0B08602A004A825F /* CachedPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510184680B08602A004A825F /* CachedPage.cpp */; }; … … 9045 9048 50D88CB315BDFDAA001809F4 /* CustomFilterProgramInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CustomFilterProgramInfo.cpp; path = filters/CustomFilterProgramInfo.cpp; sourceTree = "<group>"; }; 9046 9049 50D88CB415BDFDAA001809F4 /* CustomFilterProgramInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterProgramInfo.h; path = filters/CustomFilterProgramInfo.h; sourceTree = "<group>"; }; 9050 50E18CD516F9285800C65486 /* StyleCustomFilterProgram.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleCustomFilterProgram.cpp; path = style/StyleCustomFilterProgram.cpp; sourceTree = "<group>"; }; 9051 50E18CD616F9285800C65486 /* StyleCustomFilterProgramCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleCustomFilterProgramCache.cpp; path = style/StyleCustomFilterProgramCache.cpp; sourceTree = "<group>"; }; 9052 50E18CD716F9285800C65486 /* StyleCustomFilterProgramCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleCustomFilterProgramCache.h; path = style/StyleCustomFilterProgramCache.h; sourceTree = "<group>"; }; 9047 9053 510184670B08602A004A825F /* CachedPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedPage.h; sourceTree = "<group>"; }; 9048 9054 510184680B08602A004A825F /* CachedPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedPage.cpp; sourceTree = "<group>"; }; … … 21389 21395 5038BE2D1472AD230095E0D1 /* StyleCachedShader.cpp */, 21390 21396 5038BE2E1472AD230095E0D1 /* StyleCachedShader.h */, 21397 50E18CD616F9285800C65486 /* StyleCustomFilterProgramCache.cpp */, 21398 50E18CD716F9285800C65486 /* StyleCustomFilterProgramCache.h */, 21399 50E18CD516F9285800C65486 /* StyleCustomFilterProgram.cpp */, 21391 21400 503D0CAD14B5B0BA00F32F57 /* StyleCustomFilterProgram.h */, 21392 21401 BC5EB67E0E81D4A700B25965 /* StyleDashboardRegion.h */, … … 26758 26767 DAED203116F244480070EC0F /* PageConsole.h in Headers */, 26759 26768 2D5BC42716F882EE007048D0 /* SecurityPolicyViolationEvent.h in Headers */, 26769 50E18CDA16F9285800C65486 /* StyleCustomFilterProgramCache.h in Headers */, 26760 26770 ); 26761 26771 runOnlyForDeploymentPostprocessing = 0; … … 29964 29974 DAED203016F2442B0070EC0F /* PageConsole.cpp in Sources */, 29965 29975 E1BA003116FB92AC00BA7A35 /* ResourceHandleClient.cpp in Sources */, 29976 50E18CD816F9285800C65486 /* StyleCustomFilterProgram.cpp in Sources */, 29977 50E18CD916F9285800C65486 /* StyleCustomFilterProgramCache.cpp in Sources */, 29966 29978 ); 29967 29979 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/css/StyleResolver.cpp
r146274 r146529 165 165 #include "CustomFilterOperation.h" 166 166 #include "CustomFilterParameter.h" 167 #include "CustomFilterProgramInfo.h" 167 168 #include "CustomFilterTransformParameter.h" 168 169 #include "StyleCachedShader.h" 169 170 #include "StyleCustomFilterProgram.h" 171 #include "StyleCustomFilterProgramCache.h" 170 172 #include "StylePendingShader.h" 171 173 #include "StyleShader.h" … … 3942 3944 } 3943 3945 3946 PassRefPtr<CustomFilterProgram> StyleResolver::lookupCustomFilterProgram(WebKitCSSShaderValue* vertexShader, WebKitCSSShaderValue* fragmentShader, 3947 CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings, CustomFilterMeshType meshType) 3948 { 3949 CachedResourceLoader* cachedResourceLoader = m_state.document()->cachedResourceLoader(); 3950 KURL vertexShaderURL = vertexShader ? vertexShader->completeURL(cachedResourceLoader) : KURL(); 3951 KURL fragmentShaderURL = fragmentShader ? fragmentShader->completeURL(cachedResourceLoader) : KURL(); 3952 RefPtr<StyleCustomFilterProgram> program; 3953 if (m_customFilterProgramCache) 3954 program = m_customFilterProgramCache->lookup(CustomFilterProgramInfo(vertexShaderURL, fragmentShaderURL, programType, mixSettings, meshType)); 3955 if (!program) { 3956 // Create a new StyleCustomFilterProgram that will be resolved during the loadPendingShaders and added to the cache. 3957 program = StyleCustomFilterProgram::create(vertexShaderURL, vertexShader ? styleShader(vertexShader) : 0, 3958 fragmentShaderURL, fragmentShader ? styleShader(fragmentShader) : 0, programType, mixSettings, meshType); 3959 } 3960 return program.release(); 3961 } 3962 3944 3963 void StyleResolver::loadPendingShaders() 3945 3964 { … … 3956 3975 ASSERT(customFilter->program()); 3957 3976 StyleCustomFilterProgram* program = static_cast<StyleCustomFilterProgram*>(customFilter->program()); 3958 if (program->vertexShader() && program->vertexShader()->isPendingShader()) { 3959 WebKitCSSShaderValue* shaderValue = static_cast<StylePendingShader*>(program->vertexShader())->cssShaderValue(); 3960 program->setVertexShader(shaderValue->cachedShader(cachedResourceLoader)); 3961 } 3962 if (program->fragmentShader() && program->fragmentShader()->isPendingShader()) { 3963 WebKitCSSShaderValue* shaderValue = static_cast<StylePendingShader*>(program->fragmentShader())->cssShaderValue(); 3964 program->setFragmentShader(shaderValue->cachedShader(cachedResourceLoader)); 3977 // Note that the StylePendingShaders could be already resolved to StyleCachedShaders. That's because the rule was matched before. 3978 // However, the StyleCustomFilterProgram that was initially created could have been removed from the cache in the meanwhile, 3979 // meaning that we get a new StyleCustomFilterProgram here that is not yet in the cache, but already has loaded StyleShaders. 3980 if (!program->hasPendingShaders() && program->inCache()) 3981 continue; 3982 if (!m_customFilterProgramCache) 3983 m_customFilterProgramCache = adoptPtr(new StyleCustomFilterProgramCache()); 3984 RefPtr<StyleCustomFilterProgram> styleProgram = m_customFilterProgramCache->lookup(program); 3985 if (styleProgram.get()) 3986 customFilter->setProgram(styleProgram.release()); 3987 else { 3988 if (program->vertexShader() && program->vertexShader()->isPendingShader()) { 3989 WebKitCSSShaderValue* shaderValue = static_cast<StylePendingShader*>(program->vertexShader())->cssShaderValue(); 3990 program->setVertexShader(shaderValue->cachedShader(cachedResourceLoader)); 3991 } 3992 if (program->fragmentShader() && program->fragmentShader()->isPendingShader()) { 3993 WebKitCSSShaderValue* shaderValue = static_cast<StylePendingShader*>(program->fragmentShader())->cssShaderValue(); 3994 program->setFragmentShader(shaderValue->cachedShader(cachedResourceLoader)); 3995 } 3996 m_customFilterProgramCache->add(program); 3965 3997 } 3966 3998 } … … 4106 4138 ASSERT(shadersListLength); 4107 4139 4108 RefPtr<StyleShader> vertexShader = styleShader(shadersList->itemWithoutBoundsCheck(0));4109 RefPtr<StyleShader> fragmentShader;4140 WebKitCSSShaderValue* vertexShader = toWebKitCSSShaderValue(shadersList->itemWithoutBoundsCheck(0)); 4141 WebKitCSSShaderValue* fragmentShader = 0; 4110 4142 CustomFilterProgramType programType = PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE; 4111 4143 CustomFilterProgramMixSettings mixSettings; … … 4113 4145 if (shadersListLength > 1) { 4114 4146 CSSValue* fragmentShaderOrMixFunction = shadersList->itemWithoutBoundsCheck(1); 4115 4116 4147 if (fragmentShaderOrMixFunction->isWebKitCSSMixFunctionValue()) { 4117 4148 WebKitCSSMixFunctionValue* mixFunction = static_cast<WebKitCSSMixFunctionValue*>(fragmentShaderOrMixFunction); … … 4119 4150 4120 4151 ASSERT(mixFunction->length()); 4121 fragmentShader = styleShader(iterator.value());4152 fragmentShader = toWebKitCSSShaderValue(iterator.value()); 4122 4153 iterator.advance(); 4123 4154 … … 4135 4166 } else { 4136 4167 programType = PROGRAM_TYPE_NO_ELEMENT_TEXTURE; 4137 fragmentShader = styleShader(fragmentShaderOrMixFunction); 4138 } 4139 } 4168 fragmentShader = toWebKitCSSShaderValue(fragmentShaderOrMixFunction); 4169 } 4170 } 4171 4172 if (!vertexShader && !fragmentShader) 4173 return 0; 4140 4174 4141 4175 unsigned meshRows = 1; … … 4193 4227 if (parametersValue && !parseCustomFilterParameterList(parametersValue, parameterList)) 4194 4228 return 0; 4195 4196 RefPtr< StyleCustomFilterProgram> program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), programType, mixSettings, meshType);4229 4230 RefPtr<CustomFilterProgram> program = lookupCustomFilterProgram(vertexShader, fragmentShader, programType, mixSettings, meshType); 4197 4231 return CustomFilterOperation::create(program.release(), parameterList, meshRows, meshColumns, meshType); 4198 4232 } -
trunk/Source/WebCore/css/StyleResolver.h
r145885 r146529 44 44 #include "WebKitCSSSVGDocumentValue.h" 45 45 #endif 46 #if ENABLE(CSS_SHADERS) 47 #include "CustomFilterConstants.h" 48 #endif 46 49 #include <wtf/HashMap.h> 47 50 #include <wtf/HashSet.h> … … 73 76 class CustomFilterParameter; 74 77 class CustomFilterParameterList; 78 class CustomFilterProgram; 79 struct CustomFilterProgramMixSettings; 75 80 class Document; 76 81 class Element; … … 88 93 class Settings; 89 94 class StaticCSSRuleList; 95 class StyleCustomFilterProgramCache; 90 96 class StyleBuilder; 91 97 class StyleScopeResolver; … … 318 324 PassRefPtr<CustomFilterOperation> createCustomFilterOperation(WebKitCSSFilterValue*); 319 325 void loadPendingShaders(); 326 PassRefPtr<CustomFilterProgram> lookupCustomFilterProgram(WebKitCSSShaderValue* vertexShader, WebKitCSSShaderValue* fragmentShader, 327 CustomFilterProgramType, const CustomFilterProgramMixSettings&, CustomFilterMeshType); 320 328 #endif 321 329 #if ENABLE(SVG) … … 632 640 State m_state; 633 641 642 #if ENABLE(CSS_SHADERS) 643 OwnPtr<StyleCustomFilterProgramCache> m_customFilterProgramCache; 644 #endif 645 634 646 friend class StyleBuilder; 635 647 friend bool operator==(const MatchedProperties&, const MatchedProperties&); -
trunk/Source/WebCore/css/WebKitCSSShaderValue.cpp
r143028 r146529 38 38 #include "CachedResourceRequestInitiators.h" 39 39 #include "Document.h" 40 #include "KURL.h" 40 41 #include "StyleCachedShader.h" 41 42 #include "StylePendingShader.h" … … 55 56 } 56 57 58 KURL WebKitCSSShaderValue::completeURL(CachedResourceLoader* loader) const 59 { 60 return loader->document()->completeURL(m_url); 61 } 62 57 63 StyleCachedShader* WebKitCSSShaderValue::cachedShader(CachedResourceLoader* loader) 58 64 { … … 62 68 m_accessedShader = true; 63 69 64 CachedResourceRequest request(ResourceRequest( loader->document()->completeURL(m_url)));70 CachedResourceRequest request(ResourceRequest(completeURL(loader))); 65 71 request.setInitiator(cachedResourceRequestInitiators().css); 66 72 if (CachedResourceHandle<CachedShader> cachedShader = loader->requestShader(request)) -
trunk/Source/WebCore/css/WebKitCSSShaderValue.h
r143028 r146529 38 38 39 39 class CachedResourceLoader; 40 class KURL; 40 41 class StyleCachedShader; 41 42 class StyleShader; … … 49 50 void setFormat(const String& format) { m_format = format; } 50 51 52 KURL completeURL(CachedResourceLoader*) const; 51 53 StyleCachedShader* cachedShader(CachedResourceLoader*); 52 54 StyleShader* cachedOrPendingShader(); … … 67 69 }; 68 70 71 // This will catch anyone doing an unnecessary cast. 72 WebKitCSSShaderValue* toWebKitCSSShaderValue(const WebKitCSSShaderValue*); 73 74 inline WebKitCSSShaderValue* toWebKitCSSShaderValue(CSSValue* value) 75 { 76 return value->isWebKitCSSShaderValue() ? static_cast<WebKitCSSShaderValue*>(value) : 0; 77 } 78 69 79 } // namespace WebCore 70 80 -
trunk/Source/WebCore/platform/graphics/filters/CustomFilterOperation.cpp
r137754 r146529 64 64 65 65 const CustomFilterOperation* fromOp = static_cast<const CustomFilterOperation*>(from); 66 if ( *m_program.get() != *fromOp->m_program.get()66 if (m_program.get() != fromOp->m_program.get() 67 67 || m_meshRows != fromOp->m_meshRows 68 68 || m_meshColumns != fromOp->m_meshColumns -
trunk/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h
r137754 r146529 77 77 78 78 const CustomFilterOperation* other = static_cast<const CustomFilterOperation*>(&o); 79 return *m_program.get() == *other->m_program.get()79 return m_program.get() == other->m_program.get() 80 80 && m_meshRows == other->m_meshRows 81 81 && m_meshColumns == other->m_meshColumns -
trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.cpp
r132903 r146529 87 87 } 88 88 89 bool CustomFilterProgram::operator==(const CustomFilterProgram& o) const90 {91 return m_programType == o.m_programType92 && (m_programType != PROGRAM_TYPE_BLENDS_ELEMENT_TEXTURE || m_mixSettings == o.m_mixSettings)93 && m_meshType == o.m_meshType;94 }95 96 89 } // namespace WebCore 97 90 #endif // ENABLE(CSS_SHADERS) -
trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h
r132903 r146529 64 64 CustomFilterMeshType meshType() const { return m_meshType; } 65 65 66 virtual bool operator==(const CustomFilterProgram&) const;67 bool operator!=(const CustomFilterProgram& o) const { return !(*this == o); }68 66 protected: 69 67 // StyleCustomFilterProgram can notify the clients that the cached resources are … … 78 76 79 77 private: 78 // CustomFilterPrograms are unique combinations of shaders and can be 79 // compared using just the pointer value instead. 80 // These will catch anyone doing a value equal comparison. 81 bool operator==(const CustomFilterProgram&) const; 82 bool operator!=(const CustomFilterProgram&) const; 83 80 84 typedef HashCountedSet<CustomFilterProgramClient*> CustomFilterProgramClientList; 81 85 CustomFilterProgramClientList m_clients; -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedCustomFilterProgram.h
r141543 r146529 42 42 virtual bool isLoaded() const OVERRIDE { return true; } 43 43 44 virtual bool operator==(const CustomFilterProgram& o) const OVERRIDE45 {46 // We don't use the != operator because that would recursively call this method.47 if (!CustomFilterProgram::operator==(o))48 return false;49 50 // The following cast is ugly, but CoordinatedCustomFilterProgram is the single implementation of CustomFilterProgram on UI Process.51 const CoordinatedCustomFilterProgram* other = static_cast<const CoordinatedCustomFilterProgram*>(&o);52 return m_vertexShaderString == other->vertexShaderString() && m_fragmentShaderString == other->fragmentShaderString();53 }54 55 44 protected: 56 45 virtual String vertexShaderString() const OVERRIDE { return m_vertexShaderString; } -
trunk/Source/WebCore/rendering/style/StyleCustomFilterProgram.cpp
r146528 r146529 1 1 /* 2 * Copyright (C) 201 1Adobe Systems Incorporated. All rights reserved.2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 */ 29 29 30 #ifndef WebKitCSSShaderValue_h 31 #define WebKitCSSShaderValue_h 30 #include "config.h" 32 31 33 32 #if ENABLE(CSS_SHADERS) 34 33 35 #include "CSSValue.h" 34 #include "StyleCustomFilterProgram.h" 35 36 #include "StyleCustomFilterProgramCache.h" 36 37 37 38 namespace WebCore { 38 39 39 class CachedResourceLoader; 40 class StyleCachedShader; 41 class StyleShader; 42 43 class WebKitCSSShaderValue : public CSSValue { 44 public: 45 static PassRefPtr<WebKitCSSShaderValue> create(const String& url) { return adoptRef(new WebKitCSSShaderValue(url)); } 46 ~WebKitCSSShaderValue(); 47 48 const String& format() const { return m_format; } 49 void setFormat(const String& format) { m_format = format; } 50 51 StyleCachedShader* cachedShader(CachedResourceLoader*); 52 StyleShader* cachedOrPendingShader(); 53 54 String customCssText() const; 55 56 bool equals(const WebKitCSSShaderValue&) const; 57 58 void reportDescendantMemoryUsage(MemoryObjectInfo*) const; 59 60 private: 61 WebKitCSSShaderValue(const String& url); 62 63 String m_url; 64 String m_format; 65 RefPtr<StyleShader> m_shader; 66 bool m_accessedShader; 67 }; 40 StyleCustomFilterProgram::~StyleCustomFilterProgram() 41 { 42 if (m_cache) 43 m_cache->remove(this); 44 } 68 45 69 46 } // namespace WebCore … … 71 48 #endif // ENABLE(CSS_SHADERS) 72 49 73 #endif // WebKitCSSShaderValue_h -
trunk/Source/WebCore/rendering/style/StyleCustomFilterProgram.h
r144565 r146529 36 36 #include "CachedShader.h" 37 37 #include "CustomFilterProgram.h" 38 #include "KURL.h" 38 39 #include "StyleShader.h" 39 40 #include <wtf/FastAllocBase.h> … … 43 44 // CSS Shaders 44 45 46 class StyleCustomFilterProgramCache; 47 45 48 class StyleCustomFilterProgram : public CustomFilterProgram, public CachedResourceClient { 46 49 WTF_MAKE_FAST_ALLOCATED; 47 50 public: 48 static PassRefPtr<StyleCustomFilterProgram> create(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings, CustomFilterMeshType meshType) 51 static PassRefPtr<StyleCustomFilterProgram> create(KURL vertexShaderURL, PassRefPtr<StyleShader> vertexShader, 52 KURL fragmentShaderURL, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, 53 const CustomFilterProgramMixSettings& mixSettings, CustomFilterMeshType meshType) 49 54 { 50 return adoptRef(new StyleCustomFilterProgram(vertexShader , fragmentShader, programType, mixSettings, meshType));55 return adoptRef(new StyleCustomFilterProgram(vertexShaderURL, vertexShader, fragmentShaderURL, fragmentShader, programType, mixSettings, meshType)); 51 56 } 52 57 53 void setVertexShader(PassRefPtr<StyleShader> shader) { m_vertexShader = shader; } 58 void setVertexShader(PassRefPtr<StyleShader> shader) 59 { 60 // The shader is immutable while in the cache. 61 ASSERT(!m_cache); 62 m_vertexShader = shader; 63 } 54 64 StyleShader* vertexShader() const { return m_vertexShader.get(); } 55 65 56 void setFragmentShader(PassRefPtr<StyleShader> shader) { m_fragmentShader = shader; } 66 void setFragmentShader(PassRefPtr<StyleShader> shader) 67 { 68 // The shader is immutable while in the cache. 69 ASSERT(!m_cache); 70 m_fragmentShader = shader; 71 } 57 72 StyleShader* fragmentShader() const { return m_fragmentShader.get(); } 58 73 … … 73 88 // Do not use the CachedResource:isLoaded method here, because it actually means !isLoading(), 74 89 // so missing and canceled resources will have isLoaded set to true, even if they are not loaded yet. 90 ASSERT(!m_vertexShader || m_vertexShader->isCachedShader()); 91 ASSERT(!m_fragmentShader || m_fragmentShader->isCachedShader()); 92 ASSERT(m_cachedVertexShader.get() || m_cachedFragmentShader.get()); 75 93 return (!m_cachedVertexShader.get() || m_isVertexShaderLoaded) 76 94 && (!m_cachedFragmentShader.get() || m_isFragmentShaderLoaded); … … 115 133 notifyClients(); 116 134 } 117 118 CachedShader* cachedVertexShader() const { return m_vertexShader ? m_vertexShader->cachedShader() : 0; } 119 CachedShader* cachedFragmentShader() const { return m_fragmentShader ? m_fragmentShader->cachedShader() : 0; } 120 121 virtual bool operator==(const CustomFilterProgram& o) const 135 136 bool hasPendingShaders() const 122 137 { 123 // We don't use the != operator because that would recursively call this method. 124 if (!CustomFilterProgram::operator==(o)) 125 return false; 126 127 // The following cast is ugly, but StyleCustomFilterProgram is the single implementation of CustomFilterProgram. 128 const StyleCustomFilterProgram* other = static_cast<const StyleCustomFilterProgram*>(&o); 129 return cachedVertexShader() == other->cachedVertexShader() && cachedFragmentShader() == other->cachedFragmentShader(); 138 return (m_vertexShader && m_vertexShader->isPendingShader()) 139 || (m_fragmentShader && m_fragmentShader->isPendingShader()); 130 140 } 131 141 142 // StyleCustomFilterProgramCache is responsible with updating the reference to the cache. 143 void setCache(StyleCustomFilterProgramCache* cache) { m_cache = cache; } 144 bool inCache() const { return m_cache; } 145 146 KURL vertexShaderURL() const { return m_vertexShaderURL; } 147 KURL fragmentShaderURL() const { return m_fragmentShaderURL; } 148 132 149 private: 133 StyleCustomFilterProgram(PassRefPtr<StyleShader> vertexShader, PassRefPtr<StyleShader> fragmentShader, CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings, CustomFilterMeshType meshType) 150 StyleCustomFilterProgram(KURL vertexShaderURL, PassRefPtr<StyleShader> vertexShader, KURL fragmentShaderURL, PassRefPtr<StyleShader> fragmentShader, 151 CustomFilterProgramType programType, const CustomFilterProgramMixSettings& mixSettings, CustomFilterMeshType meshType) 134 152 : CustomFilterProgram(programType, mixSettings, meshType) 135 153 , m_vertexShader(vertexShader) 136 154 , m_fragmentShader(fragmentShader) 155 , m_vertexShaderURL(vertexShaderURL) 156 , m_fragmentShaderURL(fragmentShaderURL) 157 , m_cache(0) 137 158 , m_isVertexShaderLoaded(false) 138 159 , m_isFragmentShaderLoaded(false) 139 160 { 140 161 } 162 163 ~StyleCustomFilterProgram(); 141 164 142 165 RefPtr<StyleShader> m_vertexShader; 143 166 RefPtr<StyleShader> m_fragmentShader; 144 167 145 168 CachedResourceHandle<CachedShader> m_cachedVertexShader; 146 169 CachedResourceHandle<CachedShader> m_cachedFragmentShader; 170 171 // The URLs form the key of the StyleCustomFilterProgram in the cache and are used 172 // to lookup the StyleCustomFilterProgram when it's removed from the cache. 173 KURL m_vertexShaderURL; 174 KURL m_fragmentShaderURL; 175 176 // The Cache is responsible of invalidating this reference. 177 StyleCustomFilterProgramCache* m_cache; 147 178 148 179 bool m_isVertexShaderLoaded; -
trunk/Source/WebCore/rendering/style/StyleCustomFilterProgramCache.h
r146528 r146529 1 1 /* 2 * Copyright (C) 201 1Adobe Systems Incorporated. All rights reserved.2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 */ 29 29 30 #ifndef WebKitCSSShaderValue_h31 #define WebKitCSSShaderValue_h30 #ifndef StyleCustomFilterProgramCache_h 31 #define StyleCustomFilterProgramCache_h 32 32 33 33 #if ENABLE(CSS_SHADERS) 34 35 #include "CSSValue.h" 34 #include "CustomFilterProgramInfo.h" 35 #include <wtf/FastAllocBase.h> 36 #include <wtf/HashMap.h> 36 37 37 38 namespace WebCore { 38 39 39 class CachedResourceLoader; 40 class StyleCachedShader; 41 class StyleShader; 40 class StyleCustomFilterProgram; 41 class CustomFilterProgramInfo; 42 42 43 class WebKitCSSShaderValue : public CSSValue { 43 class StyleCustomFilterProgramCache { 44 WTF_MAKE_FAST_ALLOCATED; 44 45 public: 45 static PassRefPtr<WebKitCSSShaderValue> create(const String& url) { return adoptRef(new WebKitCSSShaderValue(url)); }46 ~ WebKitCSSShaderValue();46 StyleCustomFilterProgramCache(); 47 ~StyleCustomFilterProgramCache(); 47 48 48 const String& format() const { return m_format; } 49 void setFormat(const String& format) { m_format = format; } 49 // Lookups a StyleCustomFilterProgram that has similar parameters with the specified program. 50 StyleCustomFilterProgram* lookup(StyleCustomFilterProgram*) const; 51 StyleCustomFilterProgram* lookup(const CustomFilterProgramInfo&) const; 50 52 51 StyleCachedShader* cachedShader(CachedResourceLoader*); 52 StyleShader* cachedOrPendingShader(); 53 54 String customCssText() const; 55 56 bool equals(const WebKitCSSShaderValue&) const; 57 58 void reportDescendantMemoryUsage(MemoryObjectInfo*) const; 53 void add(StyleCustomFilterProgram*); 54 void remove(StyleCustomFilterProgram*); 59 55 60 56 private: 61 WebKitCSSShaderValue(const String& url); 62 63 String m_url; 64 String m_format; 65 RefPtr<StyleShader> m_shader; 66 bool m_accessedShader; 57 typedef HashMap<CustomFilterProgramInfo, StyleCustomFilterProgram*> CacheMap; 58 CacheMap m_cache; 67 59 }; 68 60 … … 71 63 #endif // ENABLE(CSS_SHADERS) 72 64 73 #endif // WebKitCSSShaderValue_h65 #endif // StyleCustomFilterProgramCache_h
Note: See TracChangeset
for help on using the changeset viewer.