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 24 matching lines...) Expand all Loading... |
35 fPicture.reset(recorder.endRecording()); | 35 fPicture.reset(recorder.endRecording()); |
36 | 36 |
37 // Build a reference bitmap. | 37 // Build a reference bitmap. |
38 fBitmap.allocN32Pixels(SkScalarCeilToInt(tileSize), SkScalarCeilToInt(ti
leSize)); | 38 fBitmap.allocN32Pixels(SkScalarCeilToInt(tileSize), SkScalarCeilToInt(ti
leSize)); |
39 fBitmap.eraseColor(SK_ColorTRANSPARENT); | 39 fBitmap.eraseColor(SK_ColorTRANSPARENT); |
40 SkCanvas bitmapCanvas(fBitmap); | 40 SkCanvas bitmapCanvas(fBitmap); |
41 this->drawTile(&bitmapCanvas); | 41 this->drawTile(&bitmapCanvas); |
42 } | 42 } |
43 | 43 |
44 protected: | 44 protected: |
45 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 45 uint32_t onGetFlags() const SK_OVERRIDE { |
46 return kSkipTiled_Flag; | 46 return kSkipTiled_Flag; |
47 } | 47 } |
48 | 48 |
49 virtual SkString onShortName() SK_OVERRIDE { | 49 SkString onShortName() SK_OVERRIDE { |
50 return SkString("pictureshader"); | 50 return SkString("pictureshader"); |
51 } | 51 } |
52 | 52 |
53 virtual SkISize onISize() SK_OVERRIDE { | 53 SkISize onISize() SK_OVERRIDE { |
54 return SkISize::Make(1400, 1250); | 54 return SkISize::Make(1400, 1250); |
55 } | 55 } |
56 | 56 |
57 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 57 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
58 this->drawSceneColumn(canvas, SkPoint::Make(0, 0), 1, 1, 0); | 58 this->drawSceneColumn(canvas, SkPoint::Make(0, 0), 1, 1, 0); |
59 this->drawSceneColumn(canvas, SkPoint::Make(0, fSceneSize * 6.4f), 1, 2,
0); | 59 this->drawSceneColumn(canvas, SkPoint::Make(0, fSceneSize * 6.4f), 1, 2,
0); |
60 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, 0), 1, 1,
1); | 60 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, 0), 1, 1,
1); |
61 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, fSceneSiz
e * 6.4f), 1, 1, 2); | 61 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 2.4f, fSceneSiz
e * 6.4f), 1, 1, 2); |
62 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 4.8f, 0), 2, 1,
0); | 62 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 4.8f, 0), 2, 1,
0); |
63 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 9.6f, 0), 2, 2,
0); | 63 this->drawSceneColumn(canvas, SkPoint::Make(fSceneSize * 9.6f, 0), 2, 2,
0); |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
67 void drawSceneColumn(SkCanvas* canvas, const SkPoint& pos, SkScalar scale, S
kScalar localScale, | 67 void drawSceneColumn(SkCanvas* canvas, const SkPoint& pos, SkScalar scale, S
kScalar localScale, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 SkScalar fTileSize; | 154 SkScalar fTileSize; |
155 SkScalar fSceneSize; | 155 SkScalar fSceneSize; |
156 | 156 |
157 SkAutoTUnref<SkPicture> fPicture; | 157 SkAutoTUnref<SkPicture> fPicture; |
158 SkBitmap fBitmap; | 158 SkBitmap fBitmap; |
159 | 159 |
160 typedef GM INHERITED; | 160 typedef GM INHERITED; |
161 }; | 161 }; |
162 | 162 |
163 DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); ) | 163 DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); ) |
OLD | NEW |