aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/bigtileimagefilter.cpp69
-rw-r--r--include/effects/SkTileImageFilter.h1
-rw-r--r--src/effects/SkTileImageFilter.cpp6
3 files changed, 57 insertions, 19 deletions
diff --git a/gm/bigtileimagefilter.cpp b/gm/bigtileimagefilter.cpp
index 97de0d2042..f465fe4d38 100644
--- a/gm/bigtileimagefilter.cpp
+++ b/gm/bigtileimagefilter.cpp
@@ -9,6 +9,19 @@
#include "SkTileImageFilter.h"
#include "gm.h"
+static void create_circle_texture(SkBitmap* bm, SkColor color) {
+ SkCanvas canvas(*bm);
+ canvas.clear(0xFF000000);
+
+ SkPaint paint;
+ paint.setColor(color);
+ paint.setStrokeWidth(3);
+ paint.setStyle(SkPaint::kStroke_Style);
+
+ canvas.drawCircle(SkScalarHalf(bm->width()), SkScalarHalf(bm->height()),
+ SkScalarHalf(bm->width()), paint);
+}
+
namespace skiagm {
class BigTileImageFilterGM : public GM {
@@ -28,35 +41,52 @@ protected:
}
void onOnceBeforeDraw() override {
- fBitmap.allocN32Pixels(kBitmapSize, kBitmapSize);
-
- SkCanvas canvas(fBitmap);
- canvas.clear(0xFF000000);
-
- SkPaint paint;
- paint.setColor(SK_ColorRED);
- paint.setStrokeWidth(3);
- paint.setStyle(SkPaint::kStroke_Style);
+ fRedBitmap.allocN32Pixels(kBitmapSize, kBitmapSize);
+ create_circle_texture(&fRedBitmap, SK_ColorRED);
- canvas.drawCircle(SkScalarHalf(kBitmapSize), SkScalarHalf(kBitmapSize),
- SkScalarHalf(kBitmapSize), paint);
+ fGreenBitmap.allocN32Pixels(kBitmapSize, kBitmapSize);
+ create_circle_texture(&fGreenBitmap, SK_ColorGREEN);
}
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
- SkPaint p;
+ {
+ SkPaint p;
- SkAutoTUnref<SkBitmapSource> bms(SkBitmapSource::Create(fBitmap));
- SkAutoTUnref<SkTileImageFilter> tif(SkTileImageFilter::Create(
+ SkRect bound = SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
+ SkAutoTUnref<SkBitmapSource> bms(SkBitmapSource::Create(fRedBitmap));
+ SkAutoTUnref<SkTileImageFilter> tif(SkTileImageFilter::Create(
SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)),
SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)),
bms));
- p.setImageFilter(tif);
+ p.setImageFilter(tif);
- SkRect bound = SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight));
- canvas->saveLayer(&bound, &p);
- canvas->restore();
+ canvas->saveLayer(&bound, &p);
+ canvas->restore();
+ }
+
+ {
+ SkPaint p2;
+
+ SkRect bound2 = SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize));
+
+ SkAutoTUnref<SkTileImageFilter> tif2(SkTileImageFilter::Create(
+ SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)),
+ SkRect::MakeWH(SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)),
+ NULL));
+ p2.setImageFilter(tif2);
+
+ canvas->translate(320, 320);
+ canvas->saveLayer(&bound2, &p2);
+ canvas->setMatrix(SkMatrix::I());
+
+ SkRect bound3 = SkRect::MakeXYWH(320, 320,
+ SkIntToScalar(kBitmapSize),
+ SkIntToScalar(kBitmapSize));
+ canvas->drawBitmapRectToRect(fGreenBitmap, &bound2, bound3);
+ canvas->restore();
+ }
}
private:
@@ -64,7 +94,8 @@ private:
static const int kHeight = 512;
static const int kBitmapSize = 64;
- SkBitmap fBitmap;
+ SkBitmap fRedBitmap;
+ SkBitmap fGreenBitmap;
typedef GM INHERITED;
};
diff --git a/include/effects/SkTileImageFilter.h b/include/effects/SkTileImageFilter.h
index f695355675..4dccf852be 100644
--- a/include/effects/SkTileImageFilter.h
+++ b/include/effects/SkTileImageFilter.h
@@ -26,6 +26,7 @@ public:
SkBitmap* dst, SkIPoint* offset) const override;
bool onFilterBounds(const SkIRect& src, const SkMatrix&,
SkIRect* dst) const override;
+ void computeFastBounds(const SkRect& src, SkRect* dst) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp
index b2244b9629..2b7ed940d2 100644
--- a/src/effects/SkTileImageFilter.cpp
+++ b/src/effects/SkTileImageFilter.cpp
@@ -93,6 +93,12 @@ bool SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
return true;
}
+void SkTileImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
+ // This is a workaround for skia:3194.
+ *dst = src;
+ dst->join(fDstRect);
+}
+
SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) {
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
SkRect src, dst;