aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2014-06-03 13:12:51 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-03 13:12:51 -0700
commit65044bfe021e9c0023d78080583e9acb3bdb5ce7 (patch)
tree79345f8bd3f3933cd1944745396558caa7b043a5 /src/effects
parent99ffe24200d8940ceba20f6fbf8c460f994d3cd1 (diff)
Return NULL when building empty LayerRasterizer.
In SkLayerRasterizer::snapshotRasterizer() and ::detachRasterizer(), if no layers have been added, do not attempt to create an SkLayerRasterizer. Instead, return NULL. This fixes an error when running tests on Android. Update dox to state that NULL may be returned. Add tests. R=reed@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/313653006
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkLayerRasterizer.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/effects/SkLayerRasterizer.cpp b/src/effects/SkLayerRasterizer.cpp
index ca611d5385..90fd59b585 100644
--- a/src/effects/SkLayerRasterizer.cpp
+++ b/src/effects/SkLayerRasterizer.cpp
@@ -213,12 +213,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;