Add missing null device checks in SkCanvas
Review URL: https://codereview.appspot.com/6092056 git-svn-id: http://skia.googlecode.com/svn/trunk@3810 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
9d5f76a250
commit
ccfee2a362
@ -604,6 +604,9 @@ bool SkCanvas::readPixels(SkBitmap* bitmap,
|
|||||||
|
|
||||||
bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
|
bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
|
||||||
SkDevice* device = this->getDevice();
|
SkDevice* device = this->getDevice();
|
||||||
|
if (!device) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SkIRect bounds;
|
SkIRect bounds;
|
||||||
bounds.set(0, 0, device->width(), device->height());
|
bounds.set(0, 0, device->width(), device->height());
|
||||||
@ -1129,6 +1132,10 @@ static bool clipPathHelper(const SkCanvas* canvas, SkRasterClip* currClip,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const SkDevice* device = canvas->getDevice();
|
const SkDevice* device = canvas->getDevice();
|
||||||
|
if (!device) {
|
||||||
|
return currClip->setEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
base.setRect(0, 0, device->width(), device->height());
|
base.setRect(0, 0, device->width(), device->height());
|
||||||
|
|
||||||
if (SkRegion::kReplace_Op == op) {
|
if (SkRegion::kReplace_Op == op) {
|
||||||
@ -1185,6 +1192,11 @@ bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) {
|
|||||||
void SkCanvas::validateClip() const {
|
void SkCanvas::validateClip() const {
|
||||||
// construct clipRgn from the clipstack
|
// construct clipRgn from the clipstack
|
||||||
const SkDevice* device = this->getDevice();
|
const SkDevice* device = this->getDevice();
|
||||||
|
if (!device) {
|
||||||
|
SkASSERT(this->getTotalClip().isEmpty());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SkIRect ir;
|
SkIRect ir;
|
||||||
ir.set(0, 0, device->width(), device->height());
|
ir.set(0, 0, device->width(), device->height());
|
||||||
SkRasterClip tmpClip(ir);
|
SkRasterClip tmpClip(ir);
|
||||||
|
Loading…
Reference in New Issue
Block a user