aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/utils/SkNWayCanvas.h2
-rw-r--r--src/core/SkCanvas.cpp12
-rw-r--r--src/utils/SkNWayCanvas.cpp6
-rw-r--r--tests/CanvasTest.cpp3
4 files changed, 20 insertions, 3 deletions
diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h
index 69c1fcf..dbf4a58 100644
--- a/include/utils/SkNWayCanvas.h
+++ b/include/utils/SkNWayCanvas.h
@@ -13,7 +13,7 @@
class SkNWayCanvas : public SkCanvas {
public:
- SkNWayCanvas();
+ SkNWayCanvas(int width, int height);
virtual ~SkNWayCanvas();
void addCanvas(SkCanvas*);
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index aa92dd0..7861636 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -573,6 +573,9 @@ bool SkCanvas::readPixels(SkBitmap* bitmap,
bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
SkDevice* device = this->getDevice();
+ if (!device) {
+ return false;
+ }
SkIRect bounds;
bounds.set(0, 0, device->width(), device->height());
@@ -1058,6 +1061,10 @@ static bool clipPathHelper(const SkCanvas* canvas, SkRasterClip* currClip,
}
} else {
const SkDevice* device = canvas->getDevice();
+ if (!device) {
+ return currClip->setEmpty();
+ }
+
base.setRect(0, 0, device->width(), device->height());
if (SkRegion::kReplace_Op == op) {
@@ -1114,6 +1121,11 @@ bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) {
void SkCanvas::validateClip() const {
// construct clipRgn from the clipstack
const SkDevice* device = this->getDevice();
+ if (!device) {
+ SkASSERT(this->getTotalClip().isEmpty());
+ return;
+ }
+
SkIRect ir;
ir.set(0, 0, device->width(), device->height());
SkRasterClip tmpClip(ir);
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 06cf32d..9f6ebc6 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -7,7 +7,11 @@
*/
#include "SkNWayCanvas.h"
-SkNWayCanvas::SkNWayCanvas() {}
+SkNWayCanvas::SkNWayCanvas(int width, int height) {
+ SkBitmap bm;
+ bm.setConfig(SkBitmap::kNo_Config, width, height);
+ this->setBitmapDevice(bm);
+}
SkNWayCanvas::~SkNWayCanvas() {
this->removeAll();
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 7cafda2..76573ed 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -691,7 +691,8 @@ static void TestNWayCanvasStateConsistency(
SkDevice indirectDevice2(indirectStore2);
SkCanvas indirectCanvas2(&indirectDevice2);
- SkNWayCanvas nWayCanvas;
+ SkISize canvasSize = referenceCanvas.getDeviceSize();
+ SkNWayCanvas nWayCanvas(canvasSize.width(), canvasSize.height());
nWayCanvas.addCanvas(&indirectCanvas1);
nWayCanvas.addCanvas(&indirectCanvas2);