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

Unified Diff: src/effects/SkRectShaderImageFilter.cpp

Issue 14093008: Adding a bit of rebustness to SkRectShaderImageFilter (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkRectShaderImageFilter.cpp
===================================================================
--- src/effects/SkRectShaderImageFilter.cpp (revision 8729)
+++ src/effects/SkRectShaderImageFilter.cpp (working copy)
@@ -43,16 +43,25 @@
}
bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
- const SkBitmap& source,
- const SkMatrix& matrix,
- SkBitmap* result,
- SkIPoint* loc) {
- SkAutoTUnref<SkDevice> device(proxy->createDevice(SkScalarCeilToInt(fRect.width()),
- SkScalarCeilToInt(fRect.height())));
+ const SkBitmap& source,
+ const SkMatrix&,
+ SkBitmap* result,
+ SkIPoint*) {
+ SkRect rect(fRect);
+ if (rect.isEmpty()) {
+ rect = SkRect::MakeWH(source.width(), source.height());
+ }
+
+ if (rect.isEmpty()) {
+ return false;
+ }
+
+ SkAutoTUnref<SkDevice> device(proxy->createDevice(SkScalarCeilToInt(rect.width()),
+ SkScalarCeilToInt(rect.height())));
SkCanvas canvas(device.get());
SkPaint paint;
paint.setShader(fShader);
- canvas.drawRect(fRect, paint);
+ canvas.drawRect(rect, paint);
*result = device.get()->accessBitmap(false);
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698