Apply the CTM to the offset in the slow SkOffsetImageFilter path.
This was being done in the fast path, but not the slow path. Since I had to rebaseline the offsetimagefilter GM anyway (to accomodate the new test case), I added a red border around the intersection of the (transformed) crop rect and clip rect in each sample, beyond which no pixels should be drawn. Chrome bug: https://code.google.com/p/chromium/issues/detail?id=346362 BUG=skia: R=sugoi@google.com Review URL: https://codereview.chromium.org/186643003 git-svn-id: http://skia.googlecode.com/svn/trunk@13656 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
707bd60203
commit
e09244d463
@ -41,3 +41,7 @@ inverse_paths
|
||||
# senorblanco will rebaseline.
|
||||
imagefiltersclipped
|
||||
imagefiltersscaled
|
||||
|
||||
# Added as part of https://codereview.chromium.org/186643003/.
|
||||
# senorblanco will rebaseline.
|
||||
offsetimagefilter
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "SkOffsetImageFilter.h"
|
||||
#include "SkBitmapSource.h"
|
||||
|
||||
#define WIDTH 400
|
||||
#define WIDTH 600
|
||||
#define HEIGHT 100
|
||||
#define MARGIN 12
|
||||
|
||||
@ -63,14 +63,26 @@ protected:
|
||||
return make_isize(WIDTH, HEIGHT);
|
||||
}
|
||||
|
||||
void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPaint& paint,
|
||||
SkScalar x, SkScalar y) {
|
||||
void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPaint& paint, SkScalar scale, const SkIRect& cropRect) {
|
||||
canvas->save();
|
||||
canvas->translate(x, y);
|
||||
canvas->clipRect(SkRect::MakeXYWH(0, 0,
|
||||
SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())));
|
||||
SkRect clipRect = SkRect::MakeWH(
|
||||
SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()));
|
||||
canvas->clipRect(clipRect);
|
||||
canvas->scale(scale, scale);
|
||||
canvas->drawBitmap(bitmap, 0, 0, &paint);
|
||||
canvas->restore();
|
||||
SkPaint strokePaint;
|
||||
strokePaint.setStyle(SkPaint::kStroke_Style);
|
||||
strokePaint.setColor(SK_ColorRED);
|
||||
|
||||
// Draw a boundary rect around the intersection of the clip rect
|
||||
// and crop rect.
|
||||
SkMatrix scaleMatrix;
|
||||
scaleMatrix.setScale(scale, scale);
|
||||
SkRect cropRectFloat;
|
||||
scaleMatrix.mapRect(&cropRectFloat, SkRect::Make(cropRect));
|
||||
clipRect.intersect(cropRectFloat);
|
||||
canvas->drawRect(clipRect, strokePaint);
|
||||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* canvas) {
|
||||
@ -82,7 +94,6 @@ protected:
|
||||
canvas->clear(0x00000000);
|
||||
SkPaint paint;
|
||||
|
||||
int x = 0, y = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap;
|
||||
SkIRect cropRect = SkIRect::MakeXYWH(i * 12,
|
||||
@ -96,13 +107,16 @@ protected:
|
||||
SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS(
|
||||
SkOffsetImageFilter, (dx, dy, tileInput, &rect)));
|
||||
paint.setImageFilter(filter);
|
||||
drawClippedBitmap(canvas, *bitmap, paint, SkIntToScalar(x), SkIntToScalar(y));
|
||||
x += bitmap->width() + MARGIN;
|
||||
if (x + bitmap->width() > WIDTH) {
|
||||
x = 0;
|
||||
y += bitmap->height() + MARGIN;
|
||||
}
|
||||
drawClippedBitmap(canvas, *bitmap, paint, SK_Scalar1, cropRect);
|
||||
canvas->translate(SkIntToScalar(bitmap->width() + MARGIN), 0);
|
||||
}
|
||||
|
||||
SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100);
|
||||
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
|
||||
SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS(
|
||||
SkOffsetImageFilter, (SkIntToScalar(-5), SkIntToScalar(-10), NULL, &rect)));
|
||||
paint.setImageFilter(filter);
|
||||
drawClippedBitmap(canvas, fBitmap, paint, SkIntToScalar(2), cropRect);
|
||||
}
|
||||
private:
|
||||
typedef GM INHERITED;
|
||||
|
@ -58,7 +58,9 @@ bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft),
|
||||
SkIntToScalar(srcOffset.fY - bounds.fTop));
|
||||
canvas.drawBitmap(src, fOffset.x(), fOffset.y(), &paint);
|
||||
SkVector vec;
|
||||
matrix.mapVectors(&vec, &fOffset, 1);
|
||||
canvas.drawBitmap(src, vec.x(), vec.y(), &paint);
|
||||
*result = device->accessBitmap(false);
|
||||
offset->fX = bounds.fLeft;
|
||||
offset->fY = bounds.fTop;
|
||||
|
Loading…
Reference in New Issue
Block a user