aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMatrixImageFilter.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-04-01 07:13:42 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-01 07:13:42 -0700
commit08541d5340a9cadcca60b2f04b1f2dde73be2587 (patch)
treef1a54877852c5a7473b415e676a38c1b65c05c3d /src/core/SkMatrixImageFilter.cpp
parentdaa9da4937b6dfc9e1047239b4afd41b1c5474d5 (diff)
Switch SkMatrixImageFilter over to new onFilterImage interface
Diffstat (limited to 'src/core/SkMatrixImageFilter.cpp')
-rw-r--r--src/core/SkMatrixImageFilter.cpp71
1 files changed, 37 insertions, 34 deletions
diff --git a/src/core/SkMatrixImageFilter.cpp b/src/core/SkMatrixImageFilter.cpp
index b8f510f91c..d66772c244 100644
--- a/src/core/SkMatrixImageFilter.cpp
+++ b/src/core/SkMatrixImageFilter.cpp
@@ -6,21 +6,20 @@
*/
#include "SkMatrixImageFilter.h"
-#include "SkBitmap.h"
+
#include "SkCanvas.h"
-#include "SkDevice.h"
-#include "SkColorPriv.h"
#include "SkReadBuffer.h"
+#include "SkSpecialImage.h"
+#include "SkSpecialSurface.h"
#include "SkWriteBuffer.h"
-#include "SkMatrix.h"
#include "SkRect.h"
SkMatrixImageFilter::SkMatrixImageFilter(const SkMatrix& transform,
SkFilterQuality filterQuality,
SkImageFilter* input)
- : INHERITED(1, &input),
- fTransform(transform),
- fFilterQuality(filterQuality) {
+ : INHERITED(1, &input)
+ , fTransform(transform)
+ , fFilterQuality(filterQuality) {
}
SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform,
@@ -43,52 +42,56 @@ void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writeInt(fFilterQuality);
}
-SkMatrixImageFilter::~SkMatrixImageFilter() {
-}
+sk_sp<SkSpecialImage> SkMatrixImageFilter::onFilterImage(SkSpecialImage* source,
+ const Context& ctx,
+ SkIPoint* offset) const {
-bool SkMatrixImageFilter::onFilterImageDeprecated(Proxy* proxy,
- const SkBitmap& source,
- const Context& ctx,
- SkBitmap* result,
- SkIPoint* offset) const {
- SkBitmap src = source;
- SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (!this->filterInputDeprecated(0, proxy, source, ctx, &src, &srcOffset)) {
- return false;
+ SkIPoint inputOffset = SkIPoint::Make(0, 0);
+ sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
+ if (!input) {
+ return nullptr;
}
- SkRect dstRect;
- SkIRect srcBounds, dstBounds;
- src.getBounds(&srcBounds);
- srcBounds.offset(srcOffset);
- SkRect srcRect = SkRect::Make(srcBounds);
SkMatrix matrix;
if (!ctx.ctm().invert(&matrix)) {
- return false;
+ return nullptr;
}
matrix.postConcat(fTransform);
matrix.postConcat(ctx.ctm());
+
+ const SkIRect srcBounds = SkIRect::MakeXYWH(inputOffset.x(), inputOffset.y(),
+ input->width(), input->height());
+ const SkRect srcRect = SkRect::Make(srcBounds);
+
+ SkRect dstRect;
matrix.mapRect(&dstRect, srcRect);
+ SkIRect dstBounds;
dstRect.roundOut(&dstBounds);
- SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dstBounds.height()));
- if (nullptr == device.get()) {
- return false;
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(dstBounds.width(), dstBounds.height());
+
+ sk_sp<SkSpecialSurface> surf(input->makeSurface(info));
+ if (!surf) {
+ return nullptr;
}
- SkCanvas canvas(device.get());
- canvas.translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y()));
- canvas.concat(matrix);
- SkPaint paint;
+ SkCanvas* canvas = surf->getCanvas();
+ SkASSERT(canvas);
+
+ canvas->clear(0x0);
+ canvas->translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y()));
+ canvas->concat(matrix);
+
+ SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setFilterQuality(fFilterQuality);
- canvas.drawBitmap(src, srcRect.x(), srcRect.y(), &paint);
- *result = device.get()->accessBitmap(false);
+ input->draw(canvas, srcRect.x(), srcRect.y(), &paint);
+
offset->fX = dstBounds.fLeft;
offset->fY = dstBounds.fTop;
- return true;
+ return surf->makeImageSnapshot();
}
SkRect SkMatrixImageFilter::computeFastBounds(const SkRect& src) const {