tweak mipmap_srgb gm to use integer coordinates
authorreed <reed@google.com>
Sat, 11 Jun 2016 11:48:12 +0000 (04:48 -0700)
committerCommit bot <commit-bot@chromium.org>
Sat, 11 Jun 2016 11:48:12 +0000 (04:48 -0700)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2061553002

TBR=

Review-Url: https://codereview.chromium.org/2061553002

gm/mipmap.cpp

index 45b4d1512636cc5fbdb6e1e57cb5f930e517be53..7a867d4225bde63fc458c18423faad3a40e9e8d3 100644 (file)
@@ -70,12 +70,13 @@ static void show_mips(SkCanvas* canvas, SkImage* img) {
     SkPaint paint;
     paint.setFilterQuality(kMedium_SkFilterQuality);
 
-    SkRect dst = SkRect::MakeIWH(img->width(), img->height());
+    // Want to ensure we never draw fractional pixels, so we use an IRect
+    SkIRect dst = SkIRect::MakeWH(img->width(), img->height());
     while (dst.width() > 5) {
-        canvas->drawImageRect(img, dst, &paint);
+        canvas->drawImageRect(img, SkRect::Make(dst), &paint);
         dst.offset(dst.width() + 10, 0);
-        dst.fRight = dst.fLeft + SkScalarHalf(dst.width());
-        dst.fBottom = dst.fTop + SkScalarHalf(dst.height());
+        dst.fRight = dst.fLeft + dst.width()/2;
+        dst.fBottom = dst.fTop + dst.height()/2;
     }
 }