diff options
author | Mike Reed <reed@google.com> | 2017-03-10 10:49:45 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-10 16:29:32 +0000 |
commit | 566e53c7003920ff45c72498754060804b657c68 (patch) | |
tree | 01d1f0c6e65010b16f99b140eda9e724e4c8cae6 /src | |
parent | 8da9e940721168143d6296f578b6d7423de55d69 (diff) |
re-guard against negative dimensions on no-draw canvas
We used to (incidentally) guard for this when we used bitmapdevice as our backnig.
Now that we have a (faster) nodrawdevice, we need to explicitly guard for it.
BUG=skia:
Change-Id: I9cbbf064cbfced78f0004a2e5aff60aa3ded6215
Reviewed-on: https://skia-review.googlesource.com/9530
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkCanvas.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 6140bcc400..6ce38eaaad 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -57,9 +57,12 @@ class SkNoPixelsDevice : public SkBaseDevice { public: SkNoPixelsDevice(const SkIRect& bounds, const SkSurfaceProps& props) : SkBaseDevice(SkImageInfo::MakeUnknown(bounds.width(), bounds.height()), props) - {} + { + SkASSERT(bounds.width() >= 0 && bounds.height() >= 0); + } void resetForNextPicture(const SkIRect& bounds) { + SkASSERT(bounds.width() >= 0 && bounds.height() >= 0); this->privateResize(bounds.width(), bounds.height()); } @@ -688,7 +691,7 @@ SkCanvas::SkCanvas(int width, int height, const SkSurfaceProps* props) { inc_canvas(); - this->init(new SkNoPixelsDevice(SkIRect::MakeWH(width, height), fProps), + this->init(new SkNoPixelsDevice(SkIRect::MakeWH(SkTMax(width, 0), SkTMax(height, 0)), fProps), kDefault_InitFlags)->unref(); } @@ -698,7 +701,8 @@ SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags) { inc_canvas(); - this->init(new SkNoPixelsDevice(bounds, fProps), flags)->unref(); + SkIRect r = bounds.isEmpty() ? SkIRect::MakeEmpty() : bounds; + this->init(new SkNoPixelsDevice(r, fProps), flags)->unref(); } SkCanvas::SkCanvas(SkBaseDevice* device) |