OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // scaling the image down by the matrix' scale | 31 // scaling the image down by the matrix' scale |
32 // The bug was that for cases like this, we were incorrectly trying to take a | 32 // The bug was that for cases like this, we were incorrectly trying to take a |
33 // fast-path in the bitmapshader, but ended up drawing the last col of pixels | 33 // fast-path in the bitmapshader, but ended up drawing the last col of pixels |
34 // twice. The fix resulted in (a) not taking the fast-path, but (b) drawing | 34 // twice. The fix resulted in (a) not taking the fast-path, but (b) drawing |
35 // the image correctly. | 35 // the image correctly. |
36 // | 36 // |
37 static void test_bitmaprect(SkCanvas* canvas) { | 37 static void test_bitmaprect(SkCanvas* canvas) { |
38 SkBitmap bm; | 38 SkBitmap bm; |
39 make_bm(&bm); | 39 make_bm(&bm); |
40 | 40 |
41 canvas->drawBitmap(bm, 150, 45, NULL); | 41 canvas->drawBitmap(bm, 150, 45, nullptr); |
42 | 42 |
43 SkScalar scale = 0.472560018f; | 43 SkScalar scale = 0.472560018f; |
44 canvas->save(); | 44 canvas->save(); |
45 canvas->scale(scale, scale); | 45 canvas->scale(scale, scale); |
46 canvas->drawBitmapRect(bm, SkRect::MakeXYWH(100, 100, 128, 128), nullptr); | 46 canvas->drawBitmapRect(bm, SkRect::MakeXYWH(100, 100, 128, 128), nullptr); |
47 canvas->restore(); | 47 canvas->restore(); |
48 | 48 |
49 canvas->scale(-1, 1); | 49 canvas->scale(-1, 1); |
50 canvas->drawBitmap(bm, -310, 45, NULL); | 50 canvas->drawBitmap(bm, -310, 45, nullptr); |
51 } | 51 } |
52 | 52 |
53 class BitmapRectTestGM : public skiagm::GM { | 53 class BitmapRectTestGM : public skiagm::GM { |
54 public: | 54 public: |
55 BitmapRectTestGM() { | 55 BitmapRectTestGM() { |
56 | 56 |
57 } | 57 } |
58 | 58 |
59 protected: | 59 protected: |
60 SkString onShortName() override { | 60 SkString onShortName() override { |
61 return SkString("bitmaprecttest"); | 61 return SkString("bitmaprecttest"); |
62 } | 62 } |
63 | 63 |
64 SkISize onISize() override { | 64 SkISize onISize() override { |
65 return SkISize::Make(320, 240); | 65 return SkISize::Make(320, 240); |
66 } | 66 } |
67 | 67 |
68 void onDraw(SkCanvas* canvas) override { | 68 void onDraw(SkCanvas* canvas) override { |
69 test_bitmaprect(canvas); | 69 test_bitmaprect(canvas); |
70 } | 70 } |
71 | 71 |
72 private: | 72 private: |
73 typedef skiagm::GM INHERITED; | 73 typedef skiagm::GM INHERITED; |
74 }; | 74 }; |
75 | 75 |
76 ////////////////////////////////////////////////////////////////////////////// | 76 ////////////////////////////////////////////////////////////////////////////// |
77 | 77 |
78 DEF_GM( return new BitmapRectTestGM; ) | 78 DEF_GM( return new BitmapRectTestGM; ) |
OLD | NEW |