OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 }; | 23 }; |
24 | 24 |
25 class PictureShaderGM : public skiagm::GM { | 25 class PictureShaderGM : public skiagm::GM { |
26 public: | 26 public: |
27 PictureShaderGM(SkScalar tileSize, SkScalar sceneSize) | 27 PictureShaderGM(SkScalar tileSize, SkScalar sceneSize) |
28 : fTileSize(tileSize) | 28 : fTileSize(tileSize) |
29 , fSceneSize(sceneSize) { | 29 , fSceneSize(sceneSize) { |
30 } | 30 } |
31 | 31 |
32 protected: | 32 protected: |
33 void onOnceBeforeDraw() SK_OVERRIDE { | 33 void onOnceBeforeDraw() override { |
34 // Build the picture. | 34 // Build the picture. |
35 SkPictureRecorder recorder; | 35 SkPictureRecorder recorder; |
36 SkCanvas* pictureCanvas = recorder.beginRecording(fTileSize, fTileSize,
NULL, 0); | 36 SkCanvas* pictureCanvas = recorder.beginRecording(fTileSize, fTileSize,
NULL, 0); |
37 this->drawTile(pictureCanvas); | 37 this->drawTile(pictureCanvas); |
38 fPicture.reset(recorder.endRecording()); | 38 fPicture.reset(recorder.endRecording()); |
39 | 39 |
40 // Build a reference bitmap. | 40 // Build a reference bitmap. |
41 fBitmap.allocN32Pixels(SkScalarCeilToInt(fTileSize), SkScalarCeilToInt(f
TileSize)); | 41 fBitmap.allocN32Pixels(SkScalarCeilToInt(fTileSize), SkScalarCeilToInt(f
TileSize)); |
42 fBitmap.eraseColor(SK_ColorTRANSPARENT); | 42 fBitmap.eraseColor(SK_ColorTRANSPARENT); |
43 SkCanvas bitmapCanvas(fBitmap); | 43 SkCanvas bitmapCanvas(fBitmap); |
44 this->drawTile(&bitmapCanvas); | 44 this->drawTile(&bitmapCanvas); |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 SkString onShortName() SK_OVERRIDE { | 48 SkString onShortName() override { |
49 return SkString("pictureshader"); | 49 return SkString("pictureshader"); |
50 } | 50 } |
51 | 51 |
52 SkISize onISize() SK_OVERRIDE { | 52 SkISize onISize() override { |
53 return SkISize::Make(1400, 1450); | 53 return SkISize::Make(1400, 1450); |
54 } | 54 } |
55 | 55 |
56 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 56 void onDraw(SkCanvas* canvas) override { |
57 this->drawSceneColumn(canvas, SkPoint::Make(0, 0), 1, 1, 0); | 57 this->drawSceneColumn(canvas, SkPoint::Make(0, 0), 1, 1, 0); |
58 this->drawSceneColumn(canvas, SkPoint::Make(0, fSceneSize * 6.4f), 1, 2,
0); | 58 this->drawSceneColumn(canvas, SkPoint::Make(0, fSceneSize * 6.4f), 1, 2,
0); |
59 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, 0), 1, 1,
1); | 59 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, 0), 1, 1,
1); |
60 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, fSceneSiz
e * 6.4f), 1, 1, 2); | 60 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, fSceneSiz
e * 6.4f), 1, 1, 2); |
61 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 4.8f, 0), 2, 1,
0); | 61 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 4.8f, 0), 2, 1,
0); |
62 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 9.6f, 0), 2, 2,
0); | 62 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 9.6f, 0), 2, 2,
0); |
63 | 63 |
64 // One last custom row to exercise negative scaling | 64 // One last custom row to exercise negative scaling |
65 SkMatrix ctm, localMatrix; | 65 SkMatrix ctm, localMatrix; |
66 ctm.setTranslate(fSceneSize * 2.1f, fSceneSize * 13.8f); | 66 ctm.setTranslate(fSceneSize * 2.1f, fSceneSize * 13.8f); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 p.setColor(0xFF8BC34A); // green | 210 p.setColor(0xFF8BC34A); // green |
211 canvas->drawPaint(p); | 211 canvas->drawPaint(p); |
212 | 212 |
213 canvas->clipRect(SkRect::MakeXYWH(0, 0, 400, 350)); | 213 canvas->clipRect(SkRect::MakeXYWH(0, 0, 400, 350)); |
214 p.setColor(0xFFB6B6B6); // gray | 214 p.setColor(0xFFB6B6B6); // gray |
215 canvas->drawPaint(p); | 215 canvas->drawPaint(p); |
216 p.setShader(shader.get()); | 216 p.setShader(shader.get()); |
217 | 217 |
218 canvas->drawPaint(p); | 218 canvas->drawPaint(p); |
219 } | 219 } |
OLD | NEW |