OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 SkISize onISize() override { | 102 SkISize onISize() override { |
103 return SkISize::Make(1160, 860); | 103 return SkISize::Make(1160, 860); |
104 } | 104 } |
105 | 105 |
106 void onOnceBeforeDraw() override { | 106 void onOnceBeforeDraw() override { |
107 const SkRect rect = SkRect::MakeWH(kPictureWidth, kPictureHeight); | 107 const SkRect rect = SkRect::MakeWH(kPictureWidth, kPictureHeight); |
108 SkPictureRecorder recorder; | 108 SkPictureRecorder recorder; |
109 SkCanvas* canvas = recorder.beginRecording(rect); | 109 SkCanvas* canvas = recorder.beginRecording(rect); |
110 draw_vector_logo(canvas, rect); | 110 draw_vector_logo(canvas, rect); |
111 fPicture.reset(recorder.endRecording()); | 111 fPicture = recorder.finishRecordingAsPicture(); |
112 } | 112 } |
113 | 113 |
114 void onDraw(SkCanvas* canvas) override { | 114 void onDraw(SkCanvas* canvas) override { |
115 const struct { | 115 const struct { |
116 SkISize size; | 116 SkISize size; |
117 SkScalar scaleX, scaleY; | 117 SkScalar scaleX, scaleY; |
118 SkScalar opacity; | 118 SkScalar opacity; |
119 } configs[] = { | 119 } configs[] = { |
120 { SkISize::Make(200, 100), 1, 1, 1 }, | 120 { SkISize::Make(200, 100), 1, 1, 1 }, |
121 { SkISize::Make(200, 200), 1, 1, 1 }, | 121 { SkISize::Make(200, 200), 1, 1, 1 }, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 p.setColor(0xfff0f0f0); | 164 p.setColor(0xfff0f0f0); |
165 p.setAlpha(255); | 165 p.setAlpha(255); |
166 canvas->drawRect(SkRect::MakeXYWH(x, y, | 166 canvas->drawRect(SkRect::MakeXYWH(x, y, |
167 SkIntToScalar(bm.width()), | 167 SkIntToScalar(bm.width()), |
168 SkIntToScalar(bm.height())), p); | 168 SkIntToScalar(bm.height())), p); |
169 canvas->drawBitmap(bm, x, y); | 169 canvas->drawBitmap(bm, x, y); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 private: | 173 private: |
174 SkAutoTUnref<SkPicture> fPicture; | 174 sk_sp<SkPicture> fPicture; |
175 | 175 |
176 const SkScalar kPictureWidth = 200; | 176 const SkScalar kPictureWidth = 200; |
177 const SkScalar kPictureHeight = 100; | 177 const SkScalar kPictureHeight = 100; |
178 | 178 |
179 typedef skiagm::GM INHERITED; | 179 typedef skiagm::GM INHERITED; |
180 }; | 180 }; |
181 | 181 |
182 DEF_GM(return new PictureGeneratorGM;) | 182 DEF_GM(return new PictureGeneratorGM;) |
OLD | NEW |