aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/bitmaprect.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-12-01 13:54:01 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-01 13:54:01 -0800
commitf786901ff03f78c86962a2a1ed227f1533d16d2b (patch)
tree654dec76dc9132d02abe24a7a3094c4f9243095d /gm/bitmaprect.cpp
parent05d611574ac7dd07c055c9a7426199b804e6061f (diff)
add gm to test rounding between clips and drawBitmapRect
Diffstat (limited to 'gm/bitmaprect.cpp')
-rw-r--r--gm/bitmaprect.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/gm/bitmaprect.cpp b/gm/bitmaprect.cpp
index badffb9a93..53a855e778 100644
--- a/gm/bitmaprect.cpp
+++ b/gm/bitmaprect.cpp
@@ -233,6 +233,49 @@ private:
typedef skiagm::GM INHERITED;
};
+class BitmapRectRounding : public skiagm::GM {
+ SkBitmap fBM;
+
+public:
+ BitmapRectRounding() {}
+
+protected:
+ SkString onShortName() SK_OVERRIDE {
+ SkString str;
+ str.printf("bitmaprect_rounding");
+ return str;
+ }
+
+ SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(640, 480);
+ }
+
+ void onOnceBeforeDraw() SK_OVERRIDE {
+ fBM.allocN32Pixels(10, 10);
+ fBM.eraseColor(SK_ColorBLUE);
+ }
+
+ // This choice of coordinates and matrix land the bottom edge of the clip (and bitmap dst)
+ // at exactly 1/2 pixel boundary. However, drawBitmapRect may lose precision along the way.
+ // If it does, we may see a red-line at the bottom, instead of the bitmap exactly matching
+ // the clip (in which case we should see all blue).
+ // The correct image should be all blue.
+ void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
+ paint.setColor(SK_ColorRED);
+
+ const SkRect r = SkRect::MakeXYWH(1, 1, 110, 114);
+ canvas->scale(0.9f, 0.9f);
+
+ // the drawRect shows the same problem as clipRect(r) followed by drawcolor(red)
+ canvas->drawRect(r, paint);
+ canvas->drawBitmapRect(fBM, NULL, r, NULL);
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+
//////////////////////////////////////////////////////////////////////////////
static skiagm::GM* MyFactory0(void*) { return new DrawBitmapRect2(false); }
@@ -254,3 +297,5 @@ static skiagm::GMRegistry reg2(MyFactory2);
static skiagm::GMRegistry reg3(MyFactory3);
static skiagm::GMRegistry reg4(MyFactory4);
#endif
+
+DEF_GM( return new BitmapRectRounding; )