Title: [115123] trunk
Revision
115123
Author
[email protected]
Date
2012-04-24 15:44:43 -0700 (Tue, 24 Apr 2012)

Log Message

CSS Shaders: Custom filters painting is broken
https://bugs.webkit.org/show_bug.cgi?id=82803

Reviewed by Kenneth Russell.

Source/WebCore:

In this patch I moved CSS Shaders file loading notifications from FilterEffectRenderer to the new RenderLayerFilterInfo.
That's because FilterEffectRenderer is only used when running the filters in the software pipeline
and has a very short lifetime. Due to a recent change FilterEffectRenderer actually
gets deleted if the shader is not loaded, so it doesn't live that much to be notified when the shader
was actually loaded.

Also removed the FilterEffectObserver, that was only used to notify the RenderLayer about the loaded shader.

No new tests. This is making existing CSS Shaders tests pass again.
Cannot un-skip on Mac for now because the feature is compile time disabled.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/filters/CustomFilterOperation.h:
(WebCore::CustomFilterOperation::affectsOpacity):
(WebCore::CustomFilterOperation::movesPixels):
* platform/graphics/filters/FilterOperations.cpp:
(WebCore):
(WebCore::FilterOperations::hasCustomFilter):
* platform/graphics/filters/FilterOperations.h:
(FilterOperations):
* platform/graphics/texmap/TextureMapperImageBuffer.cpp:
(WebCore::BitmapTextureImageBuffer::applyFilters):
* rendering/FilterEffectObserver.h: Removed.
* rendering/FilterEffectRenderer.cpp:
(WebCore::FilterEffectRenderer::FilterEffectRenderer):
(WebCore::FilterEffectRenderer::~FilterEffectRenderer):
(WebCore::FilterEffectRenderer::build):
* rendering/FilterEffectRenderer.h:
(WebCore):
(WebCore::FilterEffectRenderer::create):
(FilterEffectRenderer):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateOrRemoveFilterEffect):
* rendering/RenderLayer.h:
* rendering/RenderLayerFilterInfo.cpp:
(WebCore::RenderLayerFilterInfo::~RenderLayerFilterInfo):
(WebCore::RenderLayerFilterInfo::notifyCustomFilterProgramLoaded):
(WebCore):
(WebCore::RenderLayerFilterInfo::updateCustomFilterClients):
(WebCore::RenderLayerFilterInfo::removeCustomFilterClients):
* rendering/RenderLayerFilterInfo.h:
(WebCore):
(RenderLayerFilterInfo):

LayoutTests:

* platform/chromium/test_expectations.txt: Un-skipping related tests on Chromium.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (115122 => 115123)


--- trunk/LayoutTests/ChangeLog	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/LayoutTests/ChangeLog	2012-04-24 22:44:43 UTC (rev 115123)
@@ -1,3 +1,12 @@
+2012-04-24  Alexandru Chiculita  <[email protected]>
+
+        CSS Shaders: Custom filters painting is broken
+        https://bugs.webkit.org/show_bug.cgi?id=82803
+
+        Reviewed by Kenneth Russell.
+
+        * platform/chromium/test_expectations.txt: Un-skipping related tests on Chromium.
+
 2012-04-24  Rob Buis  <[email protected]>
 
         [SVG] convert use-css-events.svg to be a reftest

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (115122 => 115123)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-04-24 22:44:43 UTC (rev 115123)
@@ -2803,12 +2803,6 @@
 BUGWK82783 SKIP : css3/filters/filter-repaint-sepia.html = FAIL
 BUGWK82783 SKIP : css3/filters/nested-filter.html = FAIL
 
-// Custom filters painting is broken for now: https://bugs.webkit.org/show_bug.cgi?id=82803
-BUGWK82803 SKIP : css3/filters/custom/effect-custom-combined-missing.html = FAIL
-BUGWK82803 SKIP : css3/filters/custom/effect-custom.html = FAIL
-BUGWK82803 SKIP : css3/filters/custom/effect-custom-parameters.html = FAIL
-BUGWK82803 SKIP : css3/filters/custom/custom-filter-shader-cache.html = FAIL
-
 BUGWK84067 : css3/filters/custom/custom-filter-property-computed-style.html = TEXT
 
 // <style scoped> not yet enabled.

Modified: trunk/Source/WebCore/ChangeLog (115122 => 115123)


--- trunk/Source/WebCore/ChangeLog	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/ChangeLog	2012-04-24 22:44:43 UTC (rev 115123)
@@ -1,3 +1,54 @@
+2012-04-24  Alexandru Chiculita  <[email protected]>
+
+        CSS Shaders: Custom filters painting is broken
+        https://bugs.webkit.org/show_bug.cgi?id=82803
+
+        Reviewed by Kenneth Russell.
+
+        In this patch I moved CSS Shaders file loading notifications from FilterEffectRenderer to the new RenderLayerFilterInfo.
+        That's because FilterEffectRenderer is only used when running the filters in the software pipeline
+        and has a very short lifetime. Due to a recent change FilterEffectRenderer actually
+        gets deleted if the shader is not loaded, so it doesn't live that much to be notified when the shader
+        was actually loaded.
+
+        Also removed the FilterEffectObserver, that was only used to notify the RenderLayer about the loaded shader.
+
+        No new tests. This is making existing CSS Shaders tests pass again.
+        Cannot un-skip on Mac for now because the feature is compile time disabled.
+        
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/filters/CustomFilterOperation.h:
+        (WebCore::CustomFilterOperation::affectsOpacity):
+        (WebCore::CustomFilterOperation::movesPixels):
+        * platform/graphics/filters/FilterOperations.cpp:
+        (WebCore):
+        (WebCore::FilterOperations::hasCustomFilter):
+        * platform/graphics/filters/FilterOperations.h:
+        (FilterOperations):
+        * platform/graphics/texmap/TextureMapperImageBuffer.cpp:
+        (WebCore::BitmapTextureImageBuffer::applyFilters):
+        * rendering/FilterEffectObserver.h: Removed.
+        * rendering/FilterEffectRenderer.cpp:
+        (WebCore::FilterEffectRenderer::FilterEffectRenderer):
+        (WebCore::FilterEffectRenderer::~FilterEffectRenderer):
+        (WebCore::FilterEffectRenderer::build):
+        * rendering/FilterEffectRenderer.h:
+        (WebCore):
+        (WebCore::FilterEffectRenderer::create):
+        (FilterEffectRenderer):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateOrRemoveFilterEffect):
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerFilterInfo.cpp:
+        (WebCore::RenderLayerFilterInfo::~RenderLayerFilterInfo):
+        (WebCore::RenderLayerFilterInfo::notifyCustomFilterProgramLoaded):
+        (WebCore):
+        (WebCore::RenderLayerFilterInfo::updateCustomFilterClients):
+        (WebCore::RenderLayerFilterInfo::removeCustomFilterClients):
+        * rendering/RenderLayerFilterInfo.h:
+        (WebCore):
+        (RenderLayerFilterInfo):
+
 2012-04-24  Antti Koivisto  <[email protected]>
 
         Another build fix.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (115122 => 115123)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2012-04-24 22:44:43 UTC (rev 115123)
@@ -1441,7 +1441,7 @@
 		5038BE411472AD980095E0D1 /* CachedShader.h in Headers */ = {isa = PBXBuildFile; fileRef = 5038BE3F1472AD980095E0D1 /* CachedShader.h */; };
 		503D0CAA14B5B08700F32F57 /* CustomFilterProgram.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 503D0CA714B5B08700F32F57 /* CustomFilterProgram.cpp */; };
 		503D0CAB14B5B08700F32F57 /* CustomFilterProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D0CA814B5B08700F32F57 /* CustomFilterProgram.h */; settings = {ATTRIBUTES = (); }; };
-		503D0CAC14B5B08700F32F57 /* CustomFilterProgramClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D0CA914B5B08700F32F57 /* CustomFilterProgramClient.h */; };
+		503D0CAC14B5B08700F32F57 /* CustomFilterProgramClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D0CA914B5B08700F32F57 /* CustomFilterProgramClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		503D0CAE14B5B0BA00F32F57 /* StyleCustomFilterProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D0CAD14B5B0BA00F32F57 /* StyleCustomFilterProgram.h */; settings = {ATTRIBUTES = (); }; };
 		508CCA4F13CF106B003151F3 /* RenderFlowThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 508CCA4D13CF106B003151F3 /* RenderFlowThread.h */; };
 		508CCA5013CF106B003151F3 /* RenderFlowThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 508CCA4E13CF106B003151F3 /* RenderFlowThread.cpp */; };
@@ -1457,7 +1457,6 @@
 		50D405FA147D31F300D30BB5 /* CustomFilterMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 50D405F8147D31F300D30BB5 /* CustomFilterMesh.h */; };
 		50D40611147D49DE00D30BB5 /* CustomFilterShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50D4060F147D49DE00D30BB5 /* CustomFilterShader.cpp */; };
 		50D40612147D49DE00D30BB5 /* CustomFilterShader.h in Headers */ = {isa = PBXBuildFile; fileRef = 50D40610147D49DE00D30BB5 /* CustomFilterShader.h */; };
-		50D4067D147E40D800D30BB5 /* FilterEffectObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 50D4067C147E40D800D30BB5 /* FilterEffectObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		50E566D6139E38C500214433 /* CSSWrapShapes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 501BAAB11395114B00F7ACEB /* CSSWrapShapes.cpp */; };
 		510184690B08602A004A825F /* CachedPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 510184670B08602A004A825F /* CachedPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		5101846A0B08602A004A825F /* CachedPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510184680B08602A004A825F /* CachedPage.cpp */; };
@@ -8449,7 +8448,6 @@
 		50D405F8147D31F300D30BB5 /* CustomFilterMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterMesh.h; path = filters/CustomFilterMesh.h; sourceTree = "<group>"; };
 		50D4060F147D49DE00D30BB5 /* CustomFilterShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CustomFilterShader.cpp; path = filters/CustomFilterShader.cpp; sourceTree = "<group>"; };
 		50D40610147D49DE00D30BB5 /* CustomFilterShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomFilterShader.h; path = filters/CustomFilterShader.h; sourceTree = "<group>"; };
-		50D4067C147E40D800D30BB5 /* FilterEffectObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterEffectObserver.h; sourceTree = "<group>"; };
 		510184670B08602A004A825F /* CachedPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedPage.h; sourceTree = "<group>"; };
 		510184680B08602A004A825F /* CachedPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedPage.cpp; sourceTree = "<group>"; };
 		510D4A2D103165EE0049EA54 /* SocketStreamErrorBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamErrorBase.cpp; sourceTree = "<group>"; };
@@ -20748,7 +20746,6 @@
 				9392F14B0AD1861B00691BD4 /* CounterNode.h */,
 				A8CFF6CA0A1561CD000A4234 /* EllipsisBox.cpp */,
 				A8CFF6BD0A156118000A4234 /* EllipsisBox.h */,
-				50D4067C147E40D800D30BB5 /* FilterEffectObserver.h */,
 				31313F631443B35E006E2A90 /* FilterEffectRenderer.cpp */,
 				31313F641443B35E006E2A90 /* FilterEffectRenderer.h */,
 				A8CFF0480A154F09000A4234 /* FixedTableLayout.cpp */,
@@ -22751,7 +22748,6 @@
 				BC5EB69F0E81DAEB00B25965 /* FillLayer.h in Headers */,
 				845E72F80FD261EE00A87D79 /* Filter.h in Headers */,
 				08C9251A0FCC7C4A00480DEC /* FilterEffect.h in Headers */,
-				50D4067D147E40D800D30BB5 /* FilterEffectObserver.h in Headers */,
 				31313F661443B35F006E2A90 /* FilterEffectRenderer.h in Headers */,
 				49ECEB6E1499790D00CDD3A4 /* FilterOperation.h in Headers */,
 				49ECEB701499790D00CDD3A4 /* FilterOperations.h in Headers */,

Modified: trunk/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h (115122 => 115123)


--- trunk/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h	2012-04-24 22:44:43 UTC (rev 115123)
@@ -81,6 +81,8 @@
     
     virtual ~CustomFilterOperation();
     
+    virtual bool affectsOpacity() const { return true; }
+    virtual bool movesPixels() const { return true; }
 private:
     virtual bool operator==(const FilterOperation& o) const
     {

Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp (115122 => 115123)


--- trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterOperations.cpp	2012-04-24 22:44:43 UTC (rev 115123)
@@ -87,6 +87,17 @@
     return true;
 }
 
+#if ENABLE(CSS_SHADERS)
+bool FilterOperations::hasCustomFilter() const
+{
+    for (size_t i = 0; i < m_operations.size(); ++i) {
+        if (m_operations.at(i)->getOperationType() == FilterOperation::CUSTOM)
+            return true;
+    }
+    return false;
+}
+#endif
+
 bool FilterOperations::hasOutsets() const
 {
     for (size_t i = 0; i < m_operations.size(); ++i) {

Modified: trunk/Source/WebCore/platform/graphics/filters/FilterOperations.h (115122 => 115123)


--- trunk/Source/WebCore/platform/graphics/filters/FilterOperations.h	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterOperations.h	2012-04-24 22:44:43 UTC (rev 115123)
@@ -69,6 +69,9 @@
     bool hasFilterThatAffectsOpacity() const;
     bool hasFilterThatMovesPixels() const;
 
+#if ENABLE(CSS_SHADERS)
+    bool hasCustomFilter() const;
+#endif
 private:
     Vector<RefPtr<FilterOperation> > m_operations;
 };

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp (115122 => 115123)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp	2012-04-24 22:44:43 UTC (rev 115123)
@@ -112,7 +112,7 @@
 #if ENABLE(CSS_FILTERS)
 void BitmapTextureImageBuffer::applyFilters(const BitmapTexture& contentTexture, const FilterOperations& filters)
 {
-    RefPtr<FilterEffectRenderer> renderer = FilterEffectRenderer::create(0);
+    RefPtr<FilterEffectRenderer> renderer = FilterEffectRenderer::create();
     renderer->setSourceImageRect(FloatRect(FloatPoint::zero(), contentTexture.size()));
 
     // The document parameter is only needed for CSS shaders.

Deleted: trunk/Source/WebCore/rendering/FilterEffectObserver.h (115122 => 115123)


--- trunk/Source/WebCore/rendering/FilterEffectObserver.h	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/rendering/FilterEffectObserver.h	2012-04-24 22:44:43 UTC (rev 115123)
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 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 FilterEffectObserver_h
-#define FilterEffectObserver_h
-
-#if ENABLE(CSS_FILTERS)
-
-namespace WebCore {
-
-class FilterEffectObserver {
-public:
-    virtual ~FilterEffectObserver() { }
-    virtual void filterNeedsRepaint() = 0;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(CSS_FILTERS)
-
-#endif // FilterEffectObserver_h

Modified: trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp (115122 => 115123)


--- trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp	2012-04-24 22:44:43 UTC (rev 115123)
@@ -35,7 +35,6 @@
 #include "FEDropShadow.h"
 #include "FEGaussianBlur.h"
 #include "FEMerge.h"
-#include "FilterEffectObserver.h"
 #include "FloatConversion.h"
 #include "RenderLayer.h"
 
@@ -84,9 +83,8 @@
 }
 #endif
 
-FilterEffectRenderer::FilterEffectRenderer(FilterEffectObserver* observer)
-    : m_observer(observer)
-    , m_topOutset(0)
+FilterEffectRenderer::FilterEffectRenderer()
+    : m_topOutset(0)
     , m_rightOutset(0)
     , m_bottomOutset(0)
     , m_leftOutset(0)
@@ -99,9 +97,6 @@
 
 FilterEffectRenderer::~FilterEffectRenderer()
 {
-#if ENABLE(CSS_SHADERS)
-    removeCustomFilterClients();
-#endif
 }
 
 GraphicsContext* FilterEffectRenderer::inputContext()
@@ -113,8 +108,6 @@
 {
 #if !ENABLE(CSS_SHADERS) || !ENABLE(WEBGL)
     UNUSED_PARAM(document);
-#else
-    CustomFilterProgramList cachedCustomFilterPrograms;
 #endif
 
     m_hasFilterThatMovesPixels = operations.hasFilterThatMovesPixels();
@@ -271,8 +264,6 @@
             
             CustomFilterOperation* customFilterOperation = static_cast<CustomFilterOperation*>(filterOperation);
             RefPtr<CustomFilterProgram> program = customFilterOperation->program();
-            cachedCustomFilterPrograms.append(program);
-            program->addClient(this);
             if (program->isLoaded()) {
                 effect = FECustomFilter::create(this, document->view()->root()->hostWindow(), program, customFilterOperation->parameters(),
                                                 customFilterOperation->meshRows(), customFilterOperation->meshColumns(),
@@ -297,11 +288,6 @@
         }
     }
 
-#if ENABLE(CSS_SHADERS) && ENABLE(WEBGL)
-    removeCustomFilterClients();
-    m_cachedCustomFilterPrograms.swap(cachedCustomFilterPrograms);
-#endif
-
     // If we didn't make any effects, tell our caller we are not valid
     if (!previousEffect)
         return false;
@@ -324,19 +310,6 @@
     return false;
 }
 
-#if ENABLE(CSS_SHADERS)
-void FilterEffectRenderer::notifyCustomFilterProgramLoaded(CustomFilterProgram*)
-{
-    m_observer->filterNeedsRepaint();
-}
-
-void FilterEffectRenderer::removeCustomFilterClients()
-{
-    for (CustomFilterProgramList::iterator iter = m_cachedCustomFilterPrograms.begin(), end = m_cachedCustomFilterPrograms.end(); iter != end; ++iter)
-        iter->get()->removeClient(this);
-}
-#endif
-
 void FilterEffectRenderer::allocateBackingStoreIfNeeded()
 {
     // At this point the effect chain has been built, and the

Modified: trunk/Source/WebCore/rendering/FilterEffectRenderer.h (115122 => 115123)


--- trunk/Source/WebCore/rendering/FilterEffectRenderer.h	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/rendering/FilterEffectRenderer.h	2012-04-24 22:44:43 UTC (rev 115123)
@@ -41,17 +41,12 @@
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
-#if ENABLE(CSS_SHADERS)
-#include "CustomFilterProgramClient.h"
-#endif
-
 namespace WebCore {
 
 typedef Vector<RefPtr<FilterEffect> > FilterEffectList;
 class CachedShader;
 class CustomFilterProgram;
 class Document;
-class FilterEffectObserver;
 class GraphicsContext;
 class RenderLayer;
 
@@ -81,15 +76,12 @@
 };
 
 class FilterEffectRenderer : public Filter
-#if ENABLE(CSS_SHADERS)
-    , public CustomFilterProgramClient
-#endif
 {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassRefPtr<FilterEffectRenderer> create(FilterEffectObserver* observer)
+    static PassRefPtr<FilterEffectRenderer> create()
     {
-        return adoptRef(new FilterEffectRenderer(observer));
+        return adoptRef(new FilterEffectRenderer());
     }
 
     virtual void setSourceImageRect(const FloatRect& sourceImageRect)
@@ -119,13 +111,6 @@
     LayoutRect computeSourceImageRectForDirtyRect(const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect);
 
 private:
-#if ENABLE(CSS_SHADERS)
-    // Implementation of the CustomFilterProgramClient interface.
-    virtual void notifyCustomFilterProgramLoaded(CustomFilterProgram*);
-    
-    void removeCustomFilterClients();
-#endif
-
     void setMaxEffectRects(const FloatRect& effectRect)
     {
         for (size_t i = 0; i < m_effects.size(); ++i) {
@@ -140,7 +125,7 @@
         return 0;
     }
 
-    FilterEffectRenderer(FilterEffectObserver*);
+    FilterEffectRenderer();
     virtual ~FilterEffectRenderer();
     
     FloatRect m_sourceDrawingRegion;
@@ -148,13 +133,7 @@
     
     FilterEffectList m_effects;
     RefPtr<SourceGraphic> m_sourceGraphic;
-    FilterEffectObserver* m_observer; // No need for a strong references here. It owns us.
     
-#if ENABLE(CSS_SHADERS) && ENABLE(WEBGL)
-    typedef Vector<RefPtr<CustomFilterProgram> > CustomFilterProgramList;
-    CustomFilterProgramList m_cachedCustomFilterPrograms;
-#endif
-    
     int m_topOutset;
     int m_rightOutset;
     int m_bottomOutset;

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (115122 => 115123)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-04-24 22:44:43 UTC (rev 115123)
@@ -4873,6 +4873,13 @@
         removeFilterInfoIfNeeded();
         return;
     }
+
+#if ENABLE(CSS_SHADERS)
+    if (renderer()->style()->filter().hasCustomFilter())
+        ensureFilterInfo()->updateCustomFilterClients(renderer()->style()->filter());
+    else if (hasFilterInfo())
+        filterInfo()->removeCustomFilterClients();
+#endif
     
     if (!paintsWithFilters()) {
         // Don't delete the whole filter info here, because we might use it
@@ -4884,7 +4891,7 @@
     
     RenderLayerFilterInfo* filterInfo = ensureFilterInfo();
     if (!filterInfo->renderer()) {
-        RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::create(this);
+        RefPtr<FilterEffectRenderer> filterRenderer = FilterEffectRenderer::create();
         RenderingMode renderingMode = renderer()->frame()->page()->settings()->acceleratedFiltersEnabled() ? Accelerated : Unaccelerated;
         filterRenderer->setRenderingMode(renderingMode);
         filterInfo->setRenderer(filterRenderer.release());

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (115122 => 115123)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2012-04-24 22:44:43 UTC (rev 115123)
@@ -50,7 +50,6 @@
 #include <wtf/OwnPtr.h>
 
 #if ENABLE(CSS_FILTERS)
-#include "FilterEffectObserver.h"
 #include "RenderLayerFilterInfo.h"
 #endif
 
@@ -212,11 +211,7 @@
     bool m_fixed : 1;
 };
 
-class RenderLayer : public ScrollableArea
-#if ENABLE(CSS_FILTERS)
-    , public FilterEffectObserver
-#endif
-{
+class RenderLayer : public ScrollableArea {
 public:
     friend class RenderReplica;
 

Modified: trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp (115122 => 115123)


--- trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/rendering/RenderLayerFilterInfo.cpp	2012-04-24 22:44:43 UTC (rev 115123)
@@ -35,6 +35,11 @@
 #include "FilterEffectRenderer.h"
 #include "RenderLayer.h"
 
+#if ENABLE(CSS_SHADERS)
+#include "CustomFilterOperation.h"
+#include "CustomFilterProgram.h"
+#endif
+
 namespace WebCore {
 
 RenderLayerFilterInfoMap* RenderLayerFilterInfo::s_filterMap = 0;
@@ -88,7 +93,9 @@
 
 RenderLayerFilterInfo::~RenderLayerFilterInfo()
 {
-    // Keeping the destructor here because there's a ref to FilterEffectRenderer that might get deleted.
+#if ENABLE(CSS_SHADERS)
+    removeCustomFilterClients();
+#endif
 }
 
 void RenderLayerFilterInfo::setRenderer(PassRefPtr<FilterEffectRenderer> renderer)
@@ -96,6 +103,43 @@
     m_renderer = renderer; 
 }
 
+#if ENABLE(CSS_SHADERS)
+void RenderLayerFilterInfo::notifyCustomFilterProgramLoaded(CustomFilterProgram*)
+{
+    RenderObject* renderer = m_layer->renderer();
+    renderer->node()->setNeedsStyleRecalc(SyntheticStyleChange);
+    renderer->repaint();
+}
+
+void RenderLayerFilterInfo::updateCustomFilterClients(const FilterOperations& operations)
+{
+    if (!operations.size()) {
+        removeCustomFilterClients();
+        return;
+    }
+    CustomFilterProgramList cachedCustomFilterPrograms;
+    for (size_t i = 0; i < operations.size(); ++i) {
+        const FilterOperation* filterOperation = operations.at(i);
+        if (filterOperation->getOperationType() != FilterOperation::CUSTOM)
+            continue;
+        const CustomFilterOperation* customFilterOperation = static_cast<const CustomFilterOperation*>(filterOperation);
+        RefPtr<CustomFilterProgram> program = customFilterOperation->program();
+        cachedCustomFilterPrograms.append(program);
+        program->addClient(this);
+    }
+    // Remove the old clients here, after we've added the new ones, so that we don't flicker if some shaders are unchanged.
+    removeCustomFilterClients();
+    m_cachedCustomFilterPrograms.swap(cachedCustomFilterPrograms);
+}
+
+void RenderLayerFilterInfo::removeCustomFilterClients()
+{
+    for (size_t i = 0; i < m_cachedCustomFilterPrograms.size(); ++i)
+        m_cachedCustomFilterPrograms.at(i)->removeClient(this);
+    m_cachedCustomFilterPrograms.clear();
+}
+#endif
+
 } // namespace WebCore
 
 #endif // ENABLE(CSS_FILTERS)

Modified: trunk/Source/WebCore/rendering/RenderLayerFilterInfo.h (115122 => 115123)


--- trunk/Source/WebCore/rendering/RenderLayerFilterInfo.h	2012-04-24 22:30:41 UTC (rev 115122)
+++ trunk/Source/WebCore/rendering/RenderLayerFilterInfo.h	2012-04-24 22:44:43 UTC (rev 115123)
@@ -37,15 +37,24 @@
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
+#if ENABLE(CSS_SHADERS)
+#include "CustomFilterProgramClient.h"
+#endif
+
 namespace WebCore {
 
 class FilterEffectRenderer;
+class FilterOperations;
 class RenderLayer;
 class RenderLayerFilterInfo;
 
 typedef HashMap<const RenderLayer*, RenderLayerFilterInfo*> RenderLayerFilterInfoMap;
     
-class RenderLayerFilterInfo {
+class RenderLayerFilterInfo
+#if ENABLE(CSS_SHADERS)
+    : public CustomFilterProgramClient
+#endif
+{
 public:
     static RenderLayerFilterInfo* filterInfoForRenderLayer(const RenderLayer*);
     static RenderLayerFilterInfo* createFilterInfoForRenderLayerIfNeeded(RenderLayer*);
@@ -57,6 +66,16 @@
     
     FilterEffectRenderer* renderer() const { return m_renderer.get(); }
     void setRenderer(PassRefPtr<FilterEffectRenderer>);
+    
+#if ENABLE(CSS_SHADERS)
+    // Implementation of the CustomFilterProgramClient interface.
+    virtual void notifyCustomFilterProgramLoaded(CustomFilterProgram*);
+
+    void updateCustomFilterClients(const FilterOperations&);
+    void removeCustomFilterClients();
+#endif
+
+    
 private:
     RenderLayerFilterInfo(RenderLayer*);
     ~RenderLayerFilterInfo();
@@ -66,6 +85,11 @@
     RefPtr<FilterEffectRenderer> m_renderer;
     LayoutRect m_dirtySourceRect;
     
+#if ENABLE(CSS_SHADERS)
+    typedef Vector<RefPtr<CustomFilterProgram> > CustomFilterProgramList;
+    CustomFilterProgramList m_cachedCustomFilterPrograms;
+#endif
+    
     static RenderLayerFilterInfoMap* s_filterMap;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to