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

Unified Diff: src/core/SkCanvas.cpp

Issue 1762013002: Swap over to using SkImageFilter::filterImage instead of filterImageDeprecated (Closed) Base URL: https://skia.googlesource.com/skia.git@if-fragment
Patch Set: Fix no-GPU build Created 4 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/SkImageFilter.h ('k') | src/core/SkDevice.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 f3f38386bd1556e36e5a1f54ba352cf4acc16edf..35710fb3171514d4dd560009a941f3b54ef411b5 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -28,6 +28,7 @@
#include "SkReadPixelsRec.h"
#include "SkRRect.h"
#include "SkSmallAllocator.h"
+#include "SkSpecialImage.h"
#include "SkSurface_Base.h"
#include "SkTextBlob.h"
#include "SkTextFormatParams.h"
@@ -1392,19 +1393,29 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y,
SkIPoint pos = { x - iter.getX(), y - iter.getY() };
if (filter && !dstDev->canHandleImageFilter(filter)) {
SkImageFilter::DeviceProxy proxy(dstDev);
- SkBitmap dst;
SkIPoint offset = SkIPoint::Make(0, 0);
- const SkBitmap& src = srcDev->accessBitmap(false);
+ const SkBitmap& srcBM = srcDev->accessBitmap(false);
SkMatrix matrix = *iter.fMatrix;
matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()));
- SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x(), -pos.y());
+ const SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x(), -pos.y());
SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
- if (filter->filterImageDeprecated(&proxy, src, ctx, &dst, &offset)) {
+
+ SkAutoTUnref<SkSpecialImage> srcImg(SkSpecialImage::internal_fromBM(&proxy, srcBM));
+ if (!srcImg) {
+ continue; // something disastrous happened
+ }
+
+ SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset));
+ if (resultImg) {
SkPaint tmpUnfiltered(*paint);
tmpUnfiltered.setImageFilter(nullptr);
- dstDev->drawSprite(iter, dst, pos.x() + offset.x(), pos.y() + offset.y(),
- tmpUnfiltered);
+ SkBitmap resultBM;
+ if (resultImg->internal_getBM(&resultBM)) {
+ // TODO: add drawSprite(SkSpecialImage) to SkDevice? (see skbug.com/5073)
+ dstDev->drawSprite(iter, resultBM, pos.x() + offset.x(), pos.y() + offset.y(),
+ tmpUnfiltered);
+ }
}
} else if (deviceIsBitmapDevice) {
const SkBitmap& src = static_cast<SkBitmapDevice*>(srcDev)->fBitmap;
« no previous file with comments | « include/core/SkImageFilter.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698