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

Unified Diff: src/effects/SkLayerRasterizer.cpp

Issue 313653006: Return NULL when building empty LayerRasterizer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/effects/SkLayerRasterizer.h ('k') | tests/LayerRasterizerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkLayerRasterizer.cpp
diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp
index 7143a3b40e915839406efb9fa401cd59d7a50ae2..dfbf8b9b209b712a2c074187cce456f74f2cb8cc 100644
--- a/src/effects/SkLayerRasterizer.cpp
+++ b/src/effects/SkLayerRasterizer.cpp
@@ -214,12 +214,21 @@ void SkLayerRasterizer::Builder::addLayer(const SkPaint& paint, SkScalar dx,
}
SkLayerRasterizer* SkLayerRasterizer::Builder::detachRasterizer() {
- SkLayerRasterizer* rasterizer = SkNEW_ARGS(SkLayerRasterizer, (fLayers));
+ SkLayerRasterizer* rasterizer;
+ if (0 == fLayers->count()) {
+ rasterizer = NULL;
+ SkDELETE(fLayers);
+ } else {
+ rasterizer = SkNEW_ARGS(SkLayerRasterizer, (fLayers));
+ }
fLayers = NULL;
return rasterizer;
}
SkLayerRasterizer* SkLayerRasterizer::Builder::snapshotRasterizer() const {
+ if (0 == fLayers->count()) {
+ return NULL;
+ }
SkDeque* layers = SkNEW_ARGS(SkDeque, (sizeof(SkLayerRasterizer_Rec), fLayers->count()));
SkDeque::F2BIter iter(*fLayers);
const SkLayerRasterizer_Rec* recOrig;
« no previous file with comments | « include/effects/SkLayerRasterizer.h ('k') | tests/LayerRasterizerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698