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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org>
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. All rights reserved. 5 * Copyright (C) 2009 Google, Inc. All rights reserved.
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 16 matching lines...) Expand all
27 27
28 #include "core/frame/FrameHost.h" 28 #include "core/frame/FrameHost.h"
29 #include "core/rendering/PaintInfo.h" 29 #include "core/rendering/PaintInfo.h"
30 #include "core/rendering/RenderLayer.h" 30 #include "core/rendering/RenderLayer.h"
31 #include "core/rendering/svg/RenderSVGResourceFilter.h" 31 #include "core/rendering/svg/RenderSVGResourceFilter.h"
32 #include "core/rendering/svg/RenderSVGResourceMasker.h" 32 #include "core/rendering/svg/RenderSVGResourceMasker.h"
33 #include "core/rendering/svg/SVGRenderSupport.h" 33 #include "core/rendering/svg/SVGRenderSupport.h"
34 #include "core/rendering/svg/SVGResources.h" 34 #include "core/rendering/svg/SVGResources.h"
35 #include "core/rendering/svg/SVGResourcesCache.h" 35 #include "core/rendering/svg/SVGResourcesCache.h"
36 #include "platform/FloatConversion.h" 36 #include "platform/FloatConversion.h"
37 #include "platform/graphics/paint/DrawingRecorder.h"
38 #include "third_party/skia/include/core/SkPicture.h"
37 39
38 namespace blink { 40 namespace blink {
39 41
40 SVGRenderingContext::~SVGRenderingContext() 42 SVGRenderingContext::~SVGRenderingContext()
41 { 43 {
42 if (m_filter) { 44 if (m_filter) {
43 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object)); 45 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object));
44 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object)->filt er() == m_filter); 46 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object)->filt er() == m_filter);
45 m_filter->finishEffect(m_object, m_paintInfo.context); 47 DrawingRecorder recorder(m_originalPaintInfo->context, m_object->display ItemClient(), DisplayItem::SVGFilter, LayoutRect::infiniteRect());
48 m_filter->finishEffect(m_object, m_originalPaintInfo->context, m_paintIn fo.context);
49
50 // Reset the main context after the filter effect has been completed.
51 m_paintInfo.context = m_originalPaintInfo->context;
46 } 52 }
47 53
48 if (m_masker) { 54 if (m_masker) {
49 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object)); 55 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object));
50 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object)->mask er() == m_masker); 56 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object)->mask er() == m_masker);
51 m_masker->finishEffect(m_object, m_paintInfo.context); 57 m_masker->finishEffect(m_object, m_paintInfo.context);
52 } 58 }
53 59
54 if (m_clipper) { 60 if (m_clipper) {
55 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object)); 61 ASSERT(SVGResourcesCache::cachedResourcesForRenderObject(m_object));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 148 }
143 return true; 149 return true;
144 } 150 }
145 151
146 bool SVGRenderingContext::applyFilterIfNecessary(SVGResources* resources) 152 bool SVGRenderingContext::applyFilterIfNecessary(SVGResources* resources)
147 { 153 {
148 if (!resources) { 154 if (!resources) {
149 if (m_object->style()->svgStyle().hasFilter()) 155 if (m_object->style()->svgStyle().hasFilter())
150 return false; 156 return false;
151 } else if (RenderSVGResourceFilter* filter = resources->filter()) { 157 } else if (RenderSVGResourceFilter* filter = resources->filter()) {
152 if (!filter->prepareEffect(m_object, m_paintInfo.context)) 158 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
159 m_filterContentDisplayItemList = DisplayItemList::create();
160 m_filterContentGraphicsContext = adoptPtr(new GraphicsContext(nullpt r, m_filterContentDisplayItemList.get()));
161 }
162
163 // Instead of drawing into the regular context, we draw into a (sometime s separate)
164 // context just for the contents of the filter.
165 GraphicsContext* filterContents = m_filterContentGraphicsContext ? m_fil terContentGraphicsContext.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
166 if (!filter->prepareEffect(m_object, filterContents))
153 return false; 167 return false;
168
154 m_filter = filter; 169 m_filter = filter;
155 170
171 if (m_filterContentGraphicsContext)
172 m_paintInfo.context = m_filterContentGraphicsContext.get();
173
156 // Because we cache the filter contents and do not invalidate on paint 174 // Because we cache the filter contents and do not invalidate on paint
157 // invalidation rect changes, we need to paint the entire filter region 175 // invalidation rect changes, we need to paint the entire filter region
158 // so elements outside the initial paint (due to scrolling, etc) paint. 176 // so elements outside the initial paint (due to scrolling, etc) paint.
159 m_paintInfo.rect = LayoutRect::infiniteIntRect(); 177 m_paintInfo.rect = LayoutRect::infiniteIntRect();
160 } 178 }
161 return true; 179 return true;
162 } 180 }
163 181
164 bool SVGRenderingContext::isIsolationInstalled() const 182 bool SVGRenderingContext::isIsolationInstalled() const
165 { 183 {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 { 254 {
237 ASSERT(context); 255 ASSERT(context);
238 ASSERT(item); 256 ASSERT(item);
239 ASSERT(!item->needsLayout()); 257 ASSERT(!item->needsLayout());
240 258
241 PaintInfo info(context, LayoutRect::infiniteIntRect(), PaintPhaseForeground, PaintBehaviorNormal); 259 PaintInfo info(context, LayoutRect::infiniteIntRect(), PaintPhaseForeground, PaintBehaviorNormal);
242 item->paint(info, IntPoint()); 260 item->paint(info, IntPoint());
243 } 261 }
244 262
245 } // namespace blink 263 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698