Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1617)

Unified Diff: Source/core/rendering/svg/SVGRenderingContext.cpp

Issue 871983003: [Slimming Paint] Implement deferred SVG filters (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Cleanup Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/svg/SVGRenderingContext.cpp
diff --git a/Source/core/rendering/svg/SVGRenderingContext.cpp b/Source/core/rendering/svg/SVGRenderingContext.cpp
index fade7cdbfc7ac74d9b8230b186e54624e8465a31..03931939eebf6a4683037af246d0d81ba4ef1150 100644
--- a/Source/core/rendering/svg/SVGRenderingContext.cpp
+++ b/Source/core/rendering/svg/SVGRenderingContext.cpp
@@ -34,6 +34,8 @@
#include "core/rendering/svg/SVGResources.h"
#include "core/rendering/svg/SVGResourcesCache.h"
#include "platform/FloatConversion.h"
+#include "platform/graphics/paint/DrawingRecorder.h"
+#include "third_party/skia/include/core/SkPicture.h"
namespace blink {
@@ -42,7 +44,11 @@ SVGRenderingContext::~SVGRenderingContext()
if (m_filter) {
ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object));
ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object)->filter() == m_filter);
- m_filter->finishEffect(m_object, m_paintInfo.context);
+ DrawingRecorder recorder(m_originalPaintInfo->context, m_object->displayItemClient(), DisplayItem::SVGFilter, LayoutRect::infiniteRect());
+ m_filter->finishEffect(m_object, m_originalPaintInfo->context, m_paintInfo.context);
+
+ // Reset the main context after the filter effect has been completed.
+ m_paintInfo.context = m_originalPaintInfo->context;
}
if (m_masker) {
@@ -149,10 +155,22 @@ bool SVGRenderingContext::applyFilterIfNecessary(SVGResources* resources)
if (m_object->style()->svgStyle().hasFilter())
return false;
} else if (RenderSVGResourceFilter* filter = resources->filter()) {
- if (!filter->prepareEffect(m_object, m_paintInfo.context))
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
+ m_filterContentDisplayItemList = DisplayItemList::create();
+ m_filterContentGraphicsContext = adoptPtr(new GraphicsContext(nullptr, m_filterContentDisplayItemList.get()));
+ }
+
+ // Instead of drawing into the regular context, we draw into a (sometimes separate)
+ // context just for the contents of the filter.
+ GraphicsContext* filterContents = m_filterContentGraphicsContext ? m_filterContentGraphicsContext.get() : m_paintInfo.context;
chrishtr 2015/01/24 00:02:02 Declare filterContents before line 158 and init to
pdr. 2015/01/24 01:13:36 Done. Refactored this even further and removed the
+ if (!filter->prepareEffect(m_object, filterContents))
return false;
+
m_filter = filter;
+ if (m_filterContentGraphicsContext)
+ m_paintInfo.context = m_filterContentGraphicsContext.get();
+
// Because we cache the filter contents and do not invalidate on paint
// invalidation rect changes, we need to paint the entire filter region
// so elements outside the initial paint (due to scrolling, etc) paint.

Powered by Google App Engine
This is Rietveld 408576698