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

Unified Diff: src/effects/SkPaintImageFilter.cpp

Issue 1761373002: Switch SkPaintImageFilter over to new onFilterImage interface (Closed) Base URL: https://skia.googlesource.com/skia.git@if-follow-on
Patch Set: Updated to match naming convention 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/effects/SkPaintImageFilter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkPaintImageFilter.cpp
diff --git a/src/effects/SkPaintImageFilter.cpp b/src/effects/SkPaintImageFilter.cpp
index ed5d9db4d8a9f83fd971610d00611ff84591e715..6ae62d9112dd443065459cc9eac2e103ef14b4da 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 {
« no previous file with comments | « include/effects/SkPaintImageFilter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698