aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/tileimagefilter.cpp
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2016-01-11 14:09:09 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-11 14:09:09 -0800
commita9fbd1676cf8bd0078c5be1f1c4abd4c76ea60ad (patch)
tree1b596c1acd49d4a1201f9ebacc8934e07b52ea9d /gm/tileimagefilter.cpp
parentbad23dc9ed2e00f2a066db01ab88e4c4adcecfc6 (diff)
Fix SkTileImageFilter when srcRect is a superset of bitmap bounds.
If the input bitmap passed to SkTileImageFilter does not fill the srcRect, we were tiling this incorrectly (see the first sample from tileimage filter -- it draws from a srcRect of 12,12 50x50 to a dstRect of 0,0 50x50. There should be no tiling at all in this case!) In order to fix this, we need to pad the bitmap out to srcRect, and tile with that. In order to tile correctly in the GPU case, we need to request a tileable texture. NOTE: this will change the results of the tileimagefilter GM (correctness, and added src / dest rects). BUG=skia:4774 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1570133003 Review URL: https://codereview.chromium.org/1570133003
Diffstat (limited to 'gm/tileimagefilter.cpp')
-rw-r--r--gm/tileimagefilter.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp
index 10086c9c17..eb0ad09f4b 100644
--- a/gm/tileimagefilter.cpp
+++ b/gm/tileimagefilter.cpp
@@ -47,6 +47,12 @@ protected:
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
+ SkPaint red;
+ red.setColor(SK_ColorRED);
+ red.setStyle(SkPaint::kStroke_Style);
+ SkPaint blue;
+ blue.setColor(SK_ColorBLUE);
+ blue.setStyle(SkPaint::kStroke_Style);
int x = 0, y = 0;
for (size_t i = 0; i < 4; i++) {
@@ -67,6 +73,8 @@ protected:
SkPaint paint;
paint.setImageFilter(filter);
canvas->drawImage(fBitmap, 0, 0, &paint);
+ canvas->drawRect(srcRect, red);
+ canvas->drawRect(dstRect, blue);
canvas->restore();
x += image->width() + MARGIN;
if (x + image->width() > WIDTH) {
@@ -96,6 +104,8 @@ protected:
canvas->saveLayer(&dstRect, &paint);
canvas->drawImage(fBitmap, 0, 0);
canvas->restore();
+ canvas->drawRect(srcRect, red);
+ canvas->drawRect(dstRect, blue);
canvas->restore();
}
private: