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

Unified Diff: src/core/SkDevice.cpp

Issue 1491293002: detect when we can filter bitmaps/images directly, w/o a tmp layer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move include to the top Created 5 years 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 | « src/core/SkCanvas.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDevice.cpp
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 34c171db9071109cb668619964b037dbee95ad21..cf4a279b355523be1a982af8a989e014beaf7938 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -402,6 +402,29 @@ void SkBaseDevice::drawTextOnPath(const SkDraw& draw, const void* text, size_t b
//////////////////////////////////////////////////////////////////////////////////////////
+void SkBaseDevice::drawBitmapAsSprite(const SkDraw& draw, const SkBitmap& bitmap, int x, int y,
+ const SkPaint& paint) {
+ SkImageFilter* filter = paint.getImageFilter();
+ if (filter && !this->canHandleImageFilter(filter)) {
+ SkImageFilter::DeviceProxy proxy(this);
+ SkBitmap dst;
+ SkIPoint offset = SkIPoint::Make(0, 0);
+ SkMatrix matrix = *draw.fMatrix;
+ matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
+ const SkIRect clipBounds = bitmap.bounds();
+ SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache());
+ SkImageFilter::Context ctx(matrix, clipBounds, cache.get(),
+ SkImageFilter::kApprox_SizeConstraint);
+ if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) {
+ SkPaint tmpUnfiltered(paint);
+ tmpUnfiltered.setImageFilter(nullptr);
+ this->drawSprite(draw, dst, x + offset.x(), y + offset.y(), tmpUnfiltered);
+ }
+ } else {
+ this->drawSprite(draw, bitmap, x, y, paint);
+ }
+}
+
uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const {
uint32_t flags = paint.getFlags();
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698