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

Unified Diff: src/core/SkCanvas.cpp

Issue 960783003: Add image as a draw type that can be filtered Base URL: https://skia.googlesource.com/skia.git@skimage-filters-04-snapshot-devices-and-use-snapshots-in-skcanvas
Patch Set: rebase Created 5 years, 9 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 | « include/core/SkDrawFilter.h ('k') | tests/SkImageTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 04ecf139e684c32fa786e151def36ecf75260936..f09d2ab60d742db46a996c68463dcff340c98970 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1849,15 +1849,64 @@ void SkCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
LOOPER_END
}
-void SkCanvas::onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy, const SkPaint* paint) {
+void SkCanvas::onDrawImage(const SkImage* image, SkScalar dx, SkScalar dy,
+ const SkPaint* paint) {
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImage()");
- image->draw(this, dx, dy, paint);
+
+ SkRect bounds = SkRect::MakeXYWH(dx, dy, image->width(), image->height());
+ if (NULL == paint || paint->canComputeFastBounds()) {
+ if (NULL != paint) {
+ paint->computeFastBounds(bounds, &bounds);
+ }
+ if (this->quickReject(bounds)) {
+ return;
+ }
+ }
+
+ SkLazyPaint lazy;
+ if (NULL == paint) {
+ paint = lazy.init();
+ }
+
+ LOOPER_BEGIN(*paint, SkDrawFilter::kImage_Type, &bounds)
+
+ while (iter.next()) {
+ SkPaint p = looper.paint();
+ p.setLooper(NULL);
+ image->draw(this, dx, dy, &p);
+ }
+
+ LOOPER_END
}
void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint) {
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()");
- image->drawRect(this, src, dst, paint);
+ SkRect storage;
+ const SkRect* bounds = &dst;
+ if (NULL == paint || paint->canComputeFastBounds()) {
+ if (NULL != paint) {
+ bounds = &paint->computeFastBounds(dst, &storage);
+ }
+ if (this->quickReject(*bounds)) {
+ return;
+ }
+ }
+
+ SkLazyPaint lazy;
+ if (NULL == paint) {
+ paint = lazy.init();
+ }
+
+ LOOPER_BEGIN(*paint, SkDrawFilter::kImage_Type, bounds)
+
+ while (iter.next()) {
+ SkPaint p = looper.paint();
+ p.setLooper(NULL);
+ image->drawRect(this, src, dst, &p);
+ }
+
+ LOOPER_END
}
void SkCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint* paint) {
« no previous file with comments | « include/core/SkDrawFilter.h ('k') | tests/SkImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698