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

Unified Diff: src/core/SkMatrixImageFilter.cpp

Issue 1847953003: Switch SkMatrixImageFilter over to new onFilterImage interface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Uninline Create method 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 | « src/core/SkMatrixImageFilter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMatrixImageFilter.cpp
diff --git a/src/core/SkMatrixImageFilter.cpp b/src/core/SkMatrixImageFilter.cpp
index b8f510f91c845098eed6429e6a8a1fb4419c1728..d66772c2447072d88f1ebee201da336f78e5e118 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 {
« no previous file with comments | « src/core/SkMatrixImageFilter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698