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

Unified Diff: gm/xfermodeimagefilter.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
Index: gm/xfermodeimagefilter.cpp
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index 94d60e45eb64e4fc361613c4fc4bf26f1ee8acc6..ef2958a0c3576b01d6d4250f8f895b0b875bba29 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -189,6 +189,41 @@ protected:
SkIntToScalar(fBitmap.height() + 4)));
canvas->drawPaint(paint);
canvas->restore();
+ x += fBitmap.width() + MARGIN;
+ if (x + fBitmap.width() > WIDTH) {
+ x = 0;
+ y += fBitmap.height() + MARGIN;
+ }
+ // Test cropping
Stephen White 2013/09/25 18:11:50 Do you need to expand the HEIGHT to accommodate th
sugoi1 2013/09/25 18:21:27 No, the extra 3 bring the count to 36, so it's a 6
+ static const size_t nbSamples = 3;
+ SkXfermode::Mode sampledModes[nbSamples] = {SkXfermode::kOverlay_Mode,
+ SkXfermode::kSrcOver_Mode,
+ SkXfermode::kPlus_Mode};
+ int offsets[nbSamples][4] = {{ 10, 10, -16, -16},
+ { 10, 10, 10, 10},
+ {-10, -10, -6, -6}};
+ for (size_t i = 0; i < nbSamples; ++i) {
+ SkIRect cropRect = SkIRect::MakeXYWH(x + offsets[i][0],
+ y + offsets[i][1],
+ fBitmap.width() + offsets[i][2],
+ fBitmap.height() + offsets[i][3]);
+ mode.reset(SkXfermode::Create(sampledModes[i]));
+ filter.reset(SkNEW_ARGS(SkXfermodeImageFilter,
+ (mode, offsetBackground, offsetForeground, &cropRect)));
+ paint.setImageFilter(filter);
+ canvas->save();
+ canvas->clipRect(SkRect::MakeXYWH(SkIntToScalar(x),
+ SkIntToScalar(y),
+ SkIntToScalar(fBitmap.width() + 4),
+ SkIntToScalar(fBitmap.height() + 4)));
+ canvas->drawPaint(paint);
+ canvas->restore();
+ x += fBitmap.width() + MARGIN;
+ if (x + fBitmap.width() > WIDTH) {
+ x = 0;
+ y += fBitmap.height() + MARGIN;
+ }
+ }
}
private:
typedef GM INHERITED;
« no previous file with comments | « gm/tileimagefilter.cpp ('k') | gyp/effects.gypi » ('j') | src/effects/SkOffsetImageFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698