aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkCanvas.cpp
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2015-03-05 00:39:45 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-05 00:39:45 -0800
commitfa77eb1e51b9317ff993d1be504ada173b561e5f (patch)
tree91f53f601ba234900d87c3444ef43a405cb5d7f3 /src/core/SkCanvas.cpp
parentc877a71b35bd27c46cb525c597b9a1aa006af182 (diff)
Add image as a draw type that can be filtered
Add image as a draw type that can be filtered. This is needed when SkImage is added as an object to be drawn so that the draw is forwarded to SkBaseDevice. This would be used in making filters use SkImages. BUG=skia:3388 Review URL: https://codereview.chromium.org/960783003
Diffstat (limited to 'src/core/SkCanvas.cpp')
-rw-r--r--src/core/SkCanvas.cpp55
1 files changed, 52 insertions, 3 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index a47bd89c05..c0c6f8af3e 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1848,15 +1848,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) {