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

Side by Side Diff: third_party/WebKit/Source/core/paint/SVGPaintContext.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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 14 matching lines...) Expand all
25 #include "core/paint/SVGPaintContext.h" 25 #include "core/paint/SVGPaintContext.h"
26 26
27 #include "core/frame/FrameHost.h" 27 #include "core/frame/FrameHost.h"
28 #include "core/layout/svg/LayoutSVGResourceFilter.h" 28 #include "core/layout/svg/LayoutSVGResourceFilter.h"
29 #include "core/layout/svg/LayoutSVGResourceMasker.h" 29 #include "core/layout/svg/LayoutSVGResourceMasker.h"
30 #include "core/layout/svg/SVGLayoutSupport.h" 30 #include "core/layout/svg/SVGLayoutSupport.h"
31 #include "core/layout/svg/SVGResources.h" 31 #include "core/layout/svg/SVGResources.h"
32 #include "core/layout/svg/SVGResourcesCache.h" 32 #include "core/layout/svg/SVGResourcesCache.h"
33 #include "core/paint/SVGMaskPainter.h" 33 #include "core/paint/SVGMaskPainter.h"
34 #include "platform/FloatConversion.h" 34 #include "platform/FloatConversion.h"
35 #include "wtf/PtrUtil.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 SVGPaintContext::~SVGPaintContext() 39 SVGPaintContext::~SVGPaintContext()
39 { 40 {
40 if (m_filter) { 41 if (m_filter) {
41 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object)); 42 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object));
42 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object)->fil ter() == m_filter); 43 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(&m_object)->fil ter() == m_filter);
43 ASSERT(m_filterRecordingContext); 44 ASSERT(m_filterRecordingContext);
44 SVGFilterPainter(*m_filter).finishEffect(m_object, *m_filterRecordingCon text); 45 SVGFilterPainter(*m_filter).finishEffect(m_object, *m_filterRecordingCon text);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if (!applyClipIfNecessary(resources)) 83 if (!applyClipIfNecessary(resources))
83 return false; 84 return false;
84 85
85 if (!applyMaskIfNecessary(resources)) 86 if (!applyMaskIfNecessary(resources))
86 return false; 87 return false;
87 88
88 if (!applyFilterIfNecessary(resources)) 89 if (!applyFilterIfNecessary(resources))
89 return false; 90 return false;
90 91
91 if (!isIsolationInstalled() && SVGLayoutSupport::isIsolationRequired(&m_obje ct)) 92 if (!isIsolationInstalled() && SVGLayoutSupport::isIsolationRequired(&m_obje ct))
92 m_compositingRecorder = adoptPtr(new CompositingRecorder(paintInfo().con text, m_object, SkXfermode::kSrcOver_Mode, 1)); 93 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c ontext, m_object, SkXfermode::kSrcOver_Mode, 1));
93 94
94 return true; 95 return true;
95 } 96 }
96 97
97 void SVGPaintContext::applyCompositingIfNecessary() 98 void SVGPaintContext::applyCompositingIfNecessary()
98 { 99 {
99 ASSERT(!paintInfo().isRenderingClipPathAsMaskImage()); 100 ASSERT(!paintInfo().isRenderingClipPathAsMaskImage());
100 101
101 // Layer takes care of root opacity and blend mode. 102 // Layer takes care of root opacity and blend mode.
102 if (m_object.isSVGRoot()) 103 if (m_object.isSVGRoot())
103 return; 104 return;
104 105
105 const ComputedStyle& style = m_object.styleRef(); 106 const ComputedStyle& style = m_object.styleRef();
106 float opacity = style.opacity(); 107 float opacity = style.opacity();
107 WebBlendMode blendMode = style.hasBlendMode() && m_object.isBlendingAllowed( ) ? 108 WebBlendMode blendMode = style.hasBlendMode() && m_object.isBlendingAllowed( ) ?
108 style.blendMode() : WebBlendModeNormal; 109 style.blendMode() : WebBlendModeNormal;
109 if (opacity < 1 || blendMode != WebBlendModeNormal) { 110 if (opacity < 1 || blendMode != WebBlendModeNormal) {
110 const FloatRect compositingBounds = m_object.paintInvalidationRectInLoca lSVGCoordinates(); 111 const FloatRect compositingBounds = m_object.paintInvalidationRectInLoca lSVGCoordinates();
111 m_compositingRecorder = adoptPtr(new CompositingRecorder(paintInfo().con text, m_object, 112 m_compositingRecorder = wrapUnique(new CompositingRecorder(paintInfo().c ontext, m_object,
112 WebCoreCompositeToSkiaComposite(CompositeSourceOver, blendMode), opa city, &compositingBounds)); 113 WebCoreCompositeToSkiaComposite(CompositeSourceOver, blendMode), opa city, &compositingBounds));
113 } 114 }
114 } 115 }
115 116
116 bool SVGPaintContext::applyClipIfNecessary(SVGResources* resources) 117 bool SVGPaintContext::applyClipIfNecessary(SVGResources* resources)
117 { 118 {
118 // resources->clipper() corresponds to the non-prefixed 'clip-path' whereas 119 // resources->clipper() corresponds to the non-prefixed 'clip-path' whereas
119 // m_object.style()->clipPath() corresponds to '-webkit-clip-path'. 120 // m_object.style()->clipPath() corresponds to '-webkit-clip-path'.
120 // FIXME: We should unify the clip-path and -webkit-clip-path codepaths. 121 // FIXME: We should unify the clip-path and -webkit-clip-path codepaths.
121 if (LayoutSVGResourceClipper* clipper = resources ? resources->clipper() : n ullptr) { 122 if (LayoutSVGResourceClipper* clipper = resources ? resources->clipper() : n ullptr) {
122 if (!SVGClipPainter(*clipper).prepareEffect(m_object, m_object.objectBou ndingBox(), m_object.paintInvalidationRectInLocalSVGCoordinates(), paintInfo().c ontext, m_clipperState)) 123 if (!SVGClipPainter(*clipper).prepareEffect(m_object, m_object.objectBou ndingBox(), m_object.paintInvalidationRectInLocalSVGCoordinates(), paintInfo().c ontext, m_clipperState))
123 return false; 124 return false;
124 m_clipper = clipper; 125 m_clipper = clipper;
125 } else { 126 } else {
126 ClipPathOperation* clipPathOperation = m_object.style()->clipPath(); 127 ClipPathOperation* clipPathOperation = m_object.style()->clipPath();
127 if (clipPathOperation && clipPathOperation->type() == ClipPathOperation: :SHAPE) { 128 if (clipPathOperation && clipPathOperation->type() == ClipPathOperation: :SHAPE) {
128 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPath Operation); 129 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPath Operation);
129 if (!clipPath->isValid()) 130 if (!clipPath->isValid())
130 return false; 131 return false;
131 m_clipPathRecorder = adoptPtr(new ClipPathRecorder(paintInfo().conte xt, m_object, clipPath->path(m_object.objectBoundingBox()))); 132 m_clipPathRecorder = wrapUnique(new ClipPathRecorder(paintInfo().con text, m_object, clipPath->path(m_object.objectBoundingBox())));
132 } 133 }
133 } 134 }
134 return true; 135 return true;
135 } 136 }
136 137
137 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) 138 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources)
138 { 139 {
139 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null ptr) { 140 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null ptr) {
140 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context )) 141 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context ))
141 return false; 142 return false;
142 m_masker = masker; 143 m_masker = masker;
143 } 144 }
144 return true; 145 return true;
145 } 146 }
146 147
147 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) 148 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources)
148 { 149 {
149 if (!resources) { 150 if (!resources) {
150 if (m_object.style()->svgStyle().hasFilter()) 151 if (m_object.style()->svgStyle().hasFilter())
151 return false; 152 return false;
152 } else if (LayoutSVGResourceFilter* filter = resources->filter()) { 153 } else if (LayoutSVGResourceFilter* filter = resources->filter()) {
153 m_filterRecordingContext = adoptPtr(new SVGFilterRecordingContext(paintI nfo().context)); 154 m_filterRecordingContext = wrapUnique(new SVGFilterRecordingContext(pain tInfo().context));
154 m_filter = filter; 155 m_filter = filter;
155 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect (m_object, *m_filterRecordingContext); 156 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect (m_object, *m_filterRecordingContext);
156 if (!filterContext) 157 if (!filterContext)
157 return false; 158 return false;
158 159
159 // Because the filter needs to cache its contents we replace the context 160 // Because the filter needs to cache its contents we replace the context
160 // during filtering with the filter's context. 161 // during filtering with the filter's context.
161 m_filterPaintInfo = adoptPtr(new PaintInfo(*filterContext, m_paintInfo)) ; 162 m_filterPaintInfo = wrapUnique(new PaintInfo(*filterContext, m_paintInfo ));
162 163
163 // Because we cache the filter contents and do not invalidate on paint 164 // Because we cache the filter contents and do not invalidate on paint
164 // invalidation rect changes, we need to paint the entire filter region 165 // invalidation rect changes, we need to paint the entire filter region
165 // so elements outside the initial paint (due to scrolling, etc) paint. 166 // so elements outside the initial paint (due to scrolling, etc) paint.
166 m_filterPaintInfo->m_cullRect.m_rect = LayoutRect::infiniteIntRect(); 167 m_filterPaintInfo->m_cullRect.m_rect = LayoutRect::infiniteIntRect();
167 } 168 }
168 return true; 169 return true;
169 } 170 }
170 171
171 bool SVGPaintContext::isIsolationInstalled() const 172 bool SVGPaintContext::isIsolationInstalled() const
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // though. 223 // though.
223 // Additionally, it's not really safe/guaranteed to be correct, as 224 // Additionally, it's not really safe/guaranteed to be correct, as
224 // something down the paint pipe may want to farther tweak the color 225 // something down the paint pipe may want to farther tweak the color
225 // filter, which could yield incorrect results. (Consider just using 226 // filter, which could yield incorrect results. (Consider just using
226 // saveLayer() w/ this color filter explicitly instead.) 227 // saveLayer() w/ this color filter explicitly instead.)
227 paint.setColorFilter(sk_ref_sp(paintInfo.context.colorFilter())); 228 paint.setColorFilter(sk_ref_sp(paintInfo.context.colorFilter()));
228 return true; 229 return true;
229 } 230 }
230 231
231 } // namespace blink 232 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/SVGPaintContext.h ('k') | third_party/WebKit/Source/core/paint/TextPainterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698