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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGResourcePattern.cpp

Issue 1841833002: Deal gracefully with null {GraphicsContext,SkPictureBuilder}.endRecording() results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 /* 1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * Copyright 2014 The Chromium Authors. All rights reserved. 4 * Copyright 2014 The Chromium Authors. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (attributes.viewBox().isEmpty()) 102 if (attributes.viewBox().isEmpty())
103 return nullptr; 103 return nullptr;
104 tileTransform = SVGFitToViewBox::viewBoxToViewTransform(attributes.viewB ox(), 104 tileTransform = SVGFitToViewBox::viewBoxToViewTransform(attributes.viewB ox(),
105 attributes.preserveAspectRatio(), tileBounds.width(), tileBounds.hei ght()); 105 attributes.preserveAspectRatio(), tileBounds.width(), tileBounds.hei ght());
106 } else { 106 } else {
107 // A viewbox overrides patternContentUnits, per spec. 107 // A viewbox overrides patternContentUnits, per spec.
108 if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJE CTBOUNDINGBOX) 108 if (attributes.patternContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJE CTBOUNDINGBOX)
109 tileTransform.scale(clientBoundingBox.width(), clientBoundingBox.hei ght()); 109 tileTransform.scale(clientBoundingBox.width(), clientBoundingBox.hei ght());
110 } 110 }
111 111
112 RefPtr<SkPicture> recording = asPicture(tileBounds, tileTransform);
113 if (!recording)
114 return nullptr;
chrishtr 2016/03/29 22:42:23 Callsites are robust against this?
wkorman 2016/03/29 22:52:02 Yes.
115
112 OwnPtr<PatternData> patternData = adoptPtr(new PatternData); 116 OwnPtr<PatternData> patternData = adoptPtr(new PatternData);
113 patternData->pattern = Pattern::createPicturePattern(asPicture(tileBounds, t ileTransform)); 117 patternData->pattern = Pattern::createPicturePattern(recording);
114 118
115 // Compute pattern space transformation. 119 // Compute pattern space transformation.
116 patternData->transform.translate(tileBounds.x(), tileBounds.y()); 120 patternData->transform.translate(tileBounds.x(), tileBounds.y());
117 patternData->transform.preMultiply(attributes.patternTransform()); 121 patternData->transform.preMultiply(attributes.patternTransform());
118 122
119 return patternData.release(); 123 return patternData.release();
120 } 124 }
121 125
122 SVGPaintServer LayoutSVGResourcePattern::preparePaintServer(const LayoutObject& object) 126 SVGPaintServer LayoutSVGResourcePattern::preparePaintServer(const LayoutObject& object)
123 { 127 {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 { 203 {
200 TransformRecorder transformRecorder(pictureBuilder.context(), *patternLa youtObject, tileTransform); 204 TransformRecorder transformRecorder(pictureBuilder.context(), *patternLa youtObject, tileTransform);
201 for (LayoutObject* child = patternLayoutObject->firstChild(); child; chi ld = child->nextSibling()) 205 for (LayoutObject* child = patternLayoutObject->firstChild(); child; chi ld = child->nextSibling())
202 SVGPaintContext::paintSubtree(pictureBuilder.context(), child); 206 SVGPaintContext::paintSubtree(pictureBuilder.context(), child);
203 } 207 }
204 208
205 return pictureBuilder.endRecording(); 209 return pictureBuilder.endRecording();
206 } 210 }
207 211
208 } // namespace blink 212 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698