aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-03-09 10:17:41 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-09 10:17:41 -0800
commite6163bf35359900e048acc34551cefa67d88e1eb (patch)
treec9f5adb4e43489ce1e7aff16c0f8f807c30d44bc /src
parentf1255953e2876f43a8a0b5660aa63b42980d0d1d (diff)
Switch SkPaintImageFilter over to new onFilterImage interface
This CL relies on: https://codereview.chromium.org/1762013002/ (Swap over to using SkImageFilter::filterImage instead of filterImageDeprecated) TBR=bsalomon@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1761373002 Review URL: https://codereview.chromium.org/1761373002
Diffstat (limited to 'src')
-rw-r--r--src/effects/SkPaintImageFilter.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/effects/SkPaintImageFilter.cpp b/src/effects/SkPaintImageFilter.cpp
index ed5d9db4d8..6ae62d9112 100644
--- a/src/effects/SkPaintImageFilter.cpp
+++ b/src/effects/SkPaintImageFilter.cpp
@@ -6,10 +6,10 @@
*/
#include "SkPaintImageFilter.h"
-#include "SkBitmap.h"
#include "SkCanvas.h"
-#include "SkDevice.h"
#include "SkReadBuffer.h"
+#include "SkSpecialImage.h"
+#include "SkSpecialSurface.h"
#include "SkWriteBuffer.h"
SkImageFilter* SkPaintImageFilter::Create(const SkPaint& paint, const CropRect* cropRect) {
@@ -33,37 +33,41 @@ void SkPaintImageFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writePaint(fPaint);
}
-bool SkPaintImageFilter::onFilterImageDeprecated(Proxy* proxy,
- const SkBitmap& source,
- const Context& ctx,
- SkBitmap* result,
- SkIPoint* offset) const {
+SkSpecialImage* SkPaintImageFilter::onFilterImage(SkSpecialImage* source,
+ const Context& ctx,
+ SkIPoint* offset) const {
SkIRect bounds;
- if (!this->applyCropRect(ctx, source.bounds(), &bounds)) {
- return false;
+ const SkIRect srcBounds = SkIRect::MakeWH(source->width(), source->height());
+ if (!this->applyCropRect(ctx, srcBounds, &bounds)) {
+ return nullptr;
}
- SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(),
- bounds.height()));
- if (nullptr == device.get()) {
- return false;
+ SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(),
+ kPremul_SkAlphaType);
+
+ SkAutoTUnref<SkSpecialSurface> surf(source->newSurface(info));
+ if (!surf) {
+ return nullptr;
}
- SkCanvas canvas(device.get());
+
+ SkCanvas* canvas = surf->getCanvas();
+ SkASSERT(canvas);
+
+ canvas->clear(0x0);
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
- SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bounds.height()));
+ SkRect rect = SkRect::MakeIWH(bounds.width(), bounds.height());
SkMatrix inverse;
if (matrix.invert(&inverse)) {
inverse.mapRect(&rect);
}
- canvas.setMatrix(matrix);
- canvas.drawRect(rect, fPaint);
+ canvas->setMatrix(matrix);
+ canvas->drawRect(rect, fPaint);
- *result = device.get()->accessBitmap(false);
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
- return true;
+ return surf->newImageSnapshot();
}
bool SkPaintImageFilter::canComputeFastBounds() const {