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

Side by Side Diff: Source/core/layout/svg/LayoutSVGResourceClipper.cpp

Issue 1089293002: Add PictureRecorder for sp/non-sp recording without an existing context (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix endRecording mistake Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/layout/svg/LayoutSVGResourceMasker.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org> 5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org>
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 20 matching lines...) Expand all
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/CompositingRecorder.h" 33 #include "core/paint/CompositingRecorder.h"
34 #include "core/paint/TransformRecorder.h" 34 #include "core/paint/TransformRecorder.h"
35 #include "core/svg/SVGUseElement.h" 35 #include "core/svg/SVGUseElement.h"
36 #include "platform/RuntimeEnabledFeatures.h" 36 #include "platform/RuntimeEnabledFeatures.h"
37 #include "platform/graphics/paint/ClipPathDisplayItem.h" 37 #include "platform/graphics/paint/ClipPathDisplayItem.h"
38 #include "platform/graphics/paint/CompositingDisplayItem.h" 38 #include "platform/graphics/paint/CompositingDisplayItem.h"
39 #include "platform/graphics/paint/DisplayItemList.h" 39 #include "platform/graphics/paint/DisplayItemList.h"
40 #include "platform/graphics/paint/DrawingDisplayItem.h" 40 #include "platform/graphics/paint/DrawingDisplayItem.h"
41 #include "platform/graphics/paint/SkPictureBuilder.h"
41 #include "third_party/skia/include/core/SkPicture.h" 42 #include "third_party/skia/include/core/SkPicture.h"
42 43
43 namespace blink { 44 namespace blink {
44 45
45 LayoutSVGResourceClipper::LayoutSVGResourceClipper(SVGClipPathElement* node) 46 LayoutSVGResourceClipper::LayoutSVGResourceClipper(SVGClipPathElement* node)
46 : LayoutSVGResourceContainer(node) 47 : LayoutSVGResourceContainer(node)
47 , m_inClipExpansion(false) 48 , m_inClipExpansion(false)
48 { 49 {
49 } 50 }
50 51
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (m_clipContentPicture) 148 if (m_clipContentPicture)
148 return m_clipContentPicture; 149 return m_clipContentPicture;
149 150
150 SubtreeContentTransformScope contentTransformScope(contentTransformation); 151 SubtreeContentTransformScope contentTransformScope(contentTransformation);
151 152
152 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat es) to avoid the intersection 153 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat es) to avoid the intersection
153 // with local clips/mask, which may yield incorrect results when mixing obje ctBoundingBox and 154 // with local clips/mask, which may yield incorrect results when mixing obje ctBoundingBox and
154 // userSpaceOnUse units (http://crbug.com/294900). 155 // userSpaceOnUse units (http://crbug.com/294900).
155 FloatRect bounds = strokeBoundingBox(); 156 FloatRect bounds = strokeBoundingBox();
156 157
157 OwnPtr<DisplayItemList> displayItemList; 158 SkPictureBuilder pictureBuilder(bounds);
158 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
159 displayItemList = DisplayItemList::create();
160 GraphicsContext context(displayItemList.get());
161 context.beginRecording(bounds);
162 159
163 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { 160 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) {
164 LayoutObject* layoutObject = childElement->layoutObject(); 161 LayoutObject* layoutObject = childElement->layoutObject();
165 if (!layoutObject) 162 if (!layoutObject)
166 continue; 163 continue;
167 164
168 const ComputedStyle* style = layoutObject->style(); 165 const ComputedStyle* style = layoutObject->style();
169 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) 166 if (!style || style->display() == NONE || style->visibility() != VISIBLE )
170 continue; 167 continue;
171 168
172 bool isUseElement = isSVGUseElement(*childElement); 169 bool isUseElement = isSVGUseElement(*childElement);
173 if (isUseElement) { 170 if (isUseElement) {
174 layoutObject = toSVGUseElement(*childElement).layoutObjectClipChild( ); 171 layoutObject = toSVGUseElement(*childElement).layoutObjectClipChild( );
175 if (!layoutObject) 172 if (!layoutObject)
176 continue; 173 continue;
177 } 174 }
178 175
179 // Only shapes, paths and texts are allowed for clipping. 176 // Only shapes, paths and texts are allowed for clipping.
180 if (!layoutObject->isSVGShape() && !layoutObject->isSVGText()) 177 if (!layoutObject->isSVGShape() && !layoutObject->isSVGText())
181 continue; 178 continue;
182 179
183 if (isUseElement) 180 if (isUseElement)
184 layoutObject = childElement->layoutObject(); 181 layoutObject = childElement->layoutObject();
185 182
186 // Switch to a paint behavior where all children of this <clipPath> will be laid out using special constraints: 183 // Switch to a paint behavior where all children of this <clipPath> will be laid out using special constraints:
187 // - fill-opacity/stroke-opacity/opacity set to 1 184 // - fill-opacity/stroke-opacity/opacity set to 1
188 // - masker/filter not applied when laying out the children 185 // - masker/filter not applied when laying out the children
189 // - fill is set to the initial fill paint server (solid, black) 186 // - fill is set to the initial fill paint server (solid, black)
190 // - stroke is set to the initial stroke paint server (none) 187 // - stroke is set to the initial stroke paint server (none)
191 PaintInfo info(&context, LayoutRect::infiniteIntRect(), PaintPhaseForegr ound, PaintBehaviorRenderingClipPathAsMask); 188 PaintInfo info(&pictureBuilder.context(), LayoutRect::infiniteIntRect(), PaintPhaseForeground, PaintBehaviorRenderingClipPathAsMask);
192 layoutObject->paint(info, IntPoint()); 189 layoutObject->paint(info, IntPoint());
193 } 190 }
194 191
195 if (displayItemList) 192 m_clipContentPicture = pictureBuilder.endRecording();
196 displayItemList->commitNewDisplayItemsAndReplay(context);
197 m_clipContentPicture = context.endRecording();
198 return m_clipContentPicture; 193 return m_clipContentPicture;
199 } 194 }
200 195
201 void LayoutSVGResourceClipper::calculateClipContentPaintInvalidationRect() 196 void LayoutSVGResourceClipper::calculateClipContentPaintInvalidationRect()
202 { 197 {
203 // This is a rough heuristic to appraise the clip size and doesn't consider clip on clip. 198 // This is a rough heuristic to appraise the clip size and doesn't consider clip on clip.
204 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { 199 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) {
205 LayoutObject* layoutObject = childElement->layoutObject(); 200 LayoutObject* layoutObject = childElement->layoutObject();
206 if (!layoutObject) 201 if (!layoutObject)
207 continue; 202 continue;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 AffineTransform transform; 258 AffineTransform transform;
264 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); 259 transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
265 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight()); 260 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight());
266 return transform.mapRect(m_clipBoundaries); 261 return transform.mapRect(m_clipBoundaries);
267 } 262 }
268 263
269 return m_clipBoundaries; 264 return m_clipBoundaries;
270 } 265 }
271 266
272 } 267 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/layout/svg/LayoutSVGResourceMasker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698