aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/xfermodeimagefilter.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-06 17:44:15 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-06 17:44:15 +0000
commit40757703bdfac89ff1399443cd39a48fd39913b4 (patch)
treeb4c23563a2148996f99eaca44d6685f057e01aff /gm/xfermodeimagefilter.cpp
parent86b82767bd9bcd3739086b381745842ae10f50f4 (diff)
Reverting 12528 & 12533 (Implement srcRect and dstRect functionality in SkBitmapSource) due to image differences on N4
Diffstat (limited to 'gm/xfermodeimagefilter.cpp')
-rw-r--r--gm/xfermodeimagefilter.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index d2f7806555..01bfe0ad61 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -72,19 +72,9 @@ protected:
void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPaint& paint,
SkScalar x, SkScalar y) {
canvas->save();
- canvas->translate(x, y);
- canvas->clipRect(SkRect::MakeXYWH(0, 0,
+ canvas->clipRect(SkRect::MakeXYWH(x, y,
SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())));
- canvas->drawBitmap(bitmap, 0, 0, &paint);
- canvas->restore();
- }
-
- void drawClippedPaint(SkCanvas* canvas, const SkRect& rect, const SkPaint& paint,
- SkScalar x, SkScalar y) {
- canvas->save();
- canvas->translate(x, y);
- canvas->clipRect(rect);
- canvas->drawPaint(paint);
+ canvas->drawBitmap(bitmap, x, y, &paint);
canvas->restore();
}
@@ -166,8 +156,6 @@ protected:
x = 0;
y += fBitmap.height() + MARGIN;
}
- SkRect clipRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width() + 4),
- SkIntToScalar(fBitmap.height() + 4));
// Test offsets on SrcMode (uses fixed-function blend)
SkAutoTUnref<SkImageFilter> foreground(SkNEW_ARGS(SkBitmapSource, (fBitmap)));
SkAutoTUnref<SkImageFilter> offsetForeground(SkNEW_ARGS(SkOffsetImageFilter,
@@ -178,8 +166,13 @@ protected:
filter.reset(SkNEW_ARGS(SkXfermodeImageFilter,
(mode, offsetBackground, offsetForeground)));
paint.setImageFilter(filter);
- drawClippedPaint(canvas, clipRect, paint,
- SkIntToScalar(x), SkIntToScalar(y));
+ 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;
@@ -189,8 +182,13 @@ protected:
mode.reset(SkXfermode::Create(SkXfermode::kDarken_Mode));
filter.reset(SkNEW_ARGS(SkXfermodeImageFilter, (mode, offsetBackground, offsetForeground)));
paint.setImageFilter(filter);
- drawClippedPaint(canvas, clipRect, paint,
- SkIntToScalar(x), SkIntToScalar(y));
+ 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;
@@ -205,8 +203,8 @@ protected:
{ 10, 10, 10, 10},
{-10, -10, -6, -6}};
for (size_t i = 0; i < nbSamples; ++i) {
- SkIRect cropRect = SkIRect::MakeXYWH(offsets[i][0],
- offsets[i][1],
+ SkIRect cropRect = SkIRect::MakeXYWH(x + offsets[i][0],
+ y + offsets[i][1],
fBitmap.width() + offsets[i][2],
fBitmap.height() + offsets[i][3]);
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
@@ -214,8 +212,13 @@ protected:
filter.reset(SkNEW_ARGS(SkXfermodeImageFilter,
(mode, offsetBackground, offsetForeground, &rect)));
paint.setImageFilter(filter);
- drawClippedPaint(canvas, clipRect, paint,
- SkIntToScalar(x), SkIntToScalar(y));
+ 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;