2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
11 static void make_bm(SkBitmap* bm) {
12 bm->allocN32Pixels(60, 60);
22 canvas.drawPath(path, paint);
24 paint.setStyle(SkPaint::kStroke_Style);
25 canvas.drawRect(SkRect::MakeLTRB(0.5f, 0.5f, 59.5f, 59.5f), paint);
28 // This creates a close, but imperfect concatenation of
29 // scaling the image up by its dst-rect
30 // scaling the image down by the matrix' scale
31 // The bug was that for cases like this, we were incorrectly trying to take a
32 // fast-path in the bitmapshader, but ended up drawing the last col of pixels
33 // twice. The fix resulted in (a) not taking the fast-path, but (b) drawing
34 // the image correctly.
36 static void test_bitmaprect(SkCanvas* canvas) {
40 canvas->drawBitmap(bm, 150, 45, NULL);
42 SkScalar scale = 0.472560018f;
44 canvas->scale(scale, scale);
45 canvas->drawBitmapRectToRect(bm, NULL, SkRect::MakeXYWH(100, 100, 128, 128), NULL);
49 canvas->drawBitmap(bm, -310, 45, NULL);
52 class BitmapRectTestGM : public skiagm::GM {
59 SkString onShortName() override {
60 return SkString("bitmaprecttest");
63 SkISize onISize() override {
64 return SkISize::Make(320, 240);
67 void onDraw(SkCanvas* canvas) override {
68 test_bitmaprect(canvas);
72 typedef skiagm::GM INHERITED;
75 //////////////////////////////////////////////////////////////////////////////
77 DEF_GM( return new BitmapRectTestGM; )