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

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

Issue 1841833002: Deal gracefully with null {GraphicsContext,SkPictureBuilder}.endRecording() results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't end recording twice in DrawingRecorder. Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/SVGShapePainter.h" 5 #include "core/paint/SVGShapePainter.h"
6 6
7 #include "core/layout/svg/LayoutSVGResourceMarker.h" 7 #include "core/layout/svg/LayoutSVGResourceMarker.h"
8 #include "core/layout/svg/LayoutSVGShape.h" 8 #include "core/layout/svg/LayoutSVGShape.h"
9 #include "core/layout/svg/SVGLayoutSupport.h" 9 #include "core/layout/svg/SVGLayoutSupport.h"
10 #include "core/layout/svg/SVGMarkerData.h" 10 #include "core/layout/svg/SVGMarkerData.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (LayoutSVGResourceMarker* marker = SVGMarkerData::markerForType((*mar kerPositions)[i].type, markerStart, markerMid, markerEnd)) { 197 if (LayoutSVGResourceMarker* marker = SVGMarkerData::markerForType((*mar kerPositions)[i].type, markerStart, markerMid, markerEnd)) {
198 SkPictureBuilder pictureBuilder(boundingBox, nullptr, &paintInfo.con text); 198 SkPictureBuilder pictureBuilder(boundingBox, nullptr, &paintInfo.con text);
199 PaintInfo markerPaintInfo(pictureBuilder.context(), paintInfo); 199 PaintInfo markerPaintInfo(pictureBuilder.context(), paintInfo);
200 200
201 // It's expensive to track the transformed paint cull rect for each 201 // It's expensive to track the transformed paint cull rect for each
202 // marker so just disable culling. The shape paint call will already 202 // marker so just disable culling. The shape paint call will already
203 // be culled if it is outside the paint info cull rect. 203 // be culled if it is outside the paint info cull rect.
204 markerPaintInfo.m_cullRect.m_rect = LayoutRect::infiniteIntRect(); 204 markerPaintInfo.m_cullRect.m_rect = LayoutRect::infiniteIntRect();
205 205
206 paintMarker(markerPaintInfo, *marker, (*markerPositions)[i], strokeW idth); 206 paintMarker(markerPaintInfo, *marker, (*markerPositions)[i], strokeW idth);
207 pictureBuilder.endRecording()->playback(paintInfo.context.canvas()); 207 RefPtr<const SkPicture> recording = pictureBuilder.endRecording();
208 if (recording)
209 recording->playback(paintInfo.context.canvas());
208 } 210 }
209 } 211 }
210 } 212 }
211 213
212 void SVGShapePainter::paintMarker(const PaintInfo& paintInfo, LayoutSVGResourceM arker& marker, const MarkerPosition& position, float strokeWidth) 214 void SVGShapePainter::paintMarker(const PaintInfo& paintInfo, LayoutSVGResourceM arker& marker, const MarkerPosition& position, float strokeWidth)
213 { 215 {
214 // An empty viewBox disables rendering. 216 // An empty viewBox disables rendering.
215 SVGMarkerElement* markerElement = toSVGMarkerElement(marker.element()); 217 SVGMarkerElement* markerElement = toSVGMarkerElement(marker.element());
216 ASSERT(markerElement); 218 ASSERT(markerElement);
217 if (markerElement->hasAttribute(SVGNames::viewBoxAttr) && markerElement->vie wBox()->currentValue()->isValid() && markerElement->viewBox()->currentValue()->v alue().isEmpty()) 219 if (markerElement->hasAttribute(SVGNames::viewBoxAttr) && markerElement->vie wBox()->currentValue()->isValid() && markerElement->viewBox()->currentValue()->v alue().isEmpty())
218 return; 220 return;
219 221
220 TransformRecorder transformRecorder(paintInfo.context, marker, marker.marker Transformation(position.origin, position.angle, strokeWidth)); 222 TransformRecorder transformRecorder(paintInfo.context, marker, marker.marker Transformation(position.origin, position.angle, strokeWidth));
221 Optional<FloatClipRecorder> clipRecorder; 223 Optional<FloatClipRecorder> clipRecorder;
222 if (SVGLayoutSupport::isOverflowHidden(&marker)) 224 if (SVGLayoutSupport::isOverflowHidden(&marker))
223 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, marker. viewport()); 225 clipRecorder.emplace(paintInfo.context, marker, paintInfo.phase, marker. viewport());
224 SVGContainerPainter(marker).paint(paintInfo); 226 SVGContainerPainter(marker).paint(paintInfo);
225 } 227 }
226 228
227 } // namespace blink 229 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698