Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Unified Diff: gm/bitmaprect.cpp

Issue 766333002: add gm to test rounding between clips and drawBitmapRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: drawRect may be simpler to understand, and shows the same bug Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/bitmaprect.cpp
diff --git a/gm/bitmaprect.cpp b/gm/bitmaprect.cpp
index badffb9a939060c0e4bdd04c5a29bab3f559cae4..53a855e7782e1e6c7f5cb4cb16f1468c0a21c515 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; )
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698