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

Unified Diff: src/effects/SkXfermodeImageFilter.cpp

Issue 24157005: Moving 4 SkImageFilter derived classes from blink to skia (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Added gm tests Created 7 years, 3 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
« src/effects/SkOffsetImageFilter.cpp ('K') | « src/effects/SkTileImageFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkXfermodeImageFilter.cpp
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 898bad11006b51e70f351f89822b592110aa9dac..8491292c2642d8067d64dcd9adec60e87d4851bf 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -7,6 +7,7 @@
#include "SkXfermodeImageFilter.h"
#include "SkCanvas.h"
+#include "SkDevice.h"
#include "SkColorPriv.h"
#include "SkFlattenableBuffers.h"
#include "SkXfermode.h"
@@ -21,8 +22,9 @@
SkXfermodeImageFilter::SkXfermodeImageFilter(SkXfermode* mode,
SkImageFilter* background,
- SkImageFilter* foreground)
- : INHERITED(background, foreground), fMode(mode) {
+ SkImageFilter* foreground,
+ const SkIRect* cropRect)
+ : INHERITED(background, foreground, cropRect), fMode(mode) {
SkSafeRef(fMode);
}
@@ -58,19 +60,29 @@ bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy,
!foregroundInput->filterImage(proxy, src, ctm, &foreground, &foregroundOffset)) {
return false;
}
- dst->setConfig(background.config(), background.width(), background.height());
- dst->allocPixels();
- SkCanvas canvas(*dst);
+
+ SkIRect bounds;
+ background.getBounds(&bounds);
+ if (!applyCropRect(&bounds, ctm)) {
+ return false;
+ }
+ backgroundOffset.fX -= bounds.left();
+ backgroundOffset.fY -= bounds.top();
+ foregroundOffset.fX -= bounds.left();
+ foregroundOffset.fY -= bounds.top();
+
+ SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height()));
+ SkCanvas canvas(device);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- canvas.drawBitmap(background, 0, 0, &paint);
+ canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX),
+ SkIntToScalar(backgroundOffset.fY), &paint);
paint.setXfermode(fMode);
- canvas.drawBitmap(foreground,
- SkIntToScalar(foregroundOffset.fX - backgroundOffset.fX),
- SkIntToScalar(foregroundOffset.fY - backgroundOffset.fY),
- &paint);
- offset->fX += backgroundOffset.fX;
- offset->fY += backgroundOffset.fY;
+ canvas.drawBitmap(foreground, SkIntToScalar(foregroundOffset.fX),
+ SkIntToScalar(foregroundOffset.fY), &paint);
+ *dst = device->accessBitmap(false);
+ offset->fX += bounds.left();
+ offset->fY += bounds.top();
return true;
}
« src/effects/SkOffsetImageFilter.cpp ('K') | « src/effects/SkTileImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698