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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 canvas->drawLine(fTileSize * 1 / 3, fTileSize / 2, | 136 canvas->drawLine(fTileSize * 1 / 3, fTileSize / 2, |
137 fTileSize * 2 / 3, fTileSize / 2, paint); | 137 fTileSize * 2 / 3, fTileSize / 2, paint); |
138 } | 138 } |
139 | 139 |
140 void drawScene(SkCanvas* canvas, const SkMatrix& matrix, const SkMatrix& loc
alMatrix, | 140 void drawScene(SkCanvas* canvas, const SkMatrix& matrix, const SkMatrix& loc
alMatrix, |
141 unsigned tileMode) { | 141 unsigned tileMode) { |
142 SkASSERT(tileMode < SK_ARRAY_COUNT(kTileConfigs)); | 142 SkASSERT(tileMode < SK_ARRAY_COUNT(kTileConfigs)); |
143 | 143 |
144 SkPaint paint; | 144 SkPaint paint; |
145 paint.setStyle(SkPaint::kFill_Style); | 145 paint.setStyle(SkPaint::kFill_Style); |
146 paint.setColor(SK_ColorLTGRAY); | 146 paint.setColor(sk_tool_utils::color_to_565(SK_ColorLTGRAY)); |
147 | 147 |
148 canvas->save(); | 148 canvas->save(); |
149 canvas->concat(matrix); | 149 canvas->concat(matrix); |
150 canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint); | 150 canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint); |
151 canvas->drawRect(SkRect::MakeXYWH(fSceneSize * 1.1f, 0, fSceneSize, fSce
neSize), paint); | 151 canvas->drawRect(SkRect::MakeXYWH(fSceneSize * 1.1f, 0, fSceneSize, fSce
neSize), paint); |
152 | 152 |
153 SkAutoTUnref<SkShader> pictureShader(SkShader::CreatePictureShader( | 153 SkAutoTUnref<SkShader> pictureShader(SkShader::CreatePictureShader( |
154 fPicture, | 154 fPicture, |
155 kTileConfigs[tileMode].tmx, | 155 kTileConfigs[tileMode].tmx, |
156 kTileConfigs[tileMode].tmy, | 156 kTileConfigs[tileMode].tmy, |
(...skipping 29 matching lines...) Expand all Loading... |
186 DEF_SIMPLE_GM(tiled_picture_shader, canvas, 400, 400) { | 186 DEF_SIMPLE_GM(tiled_picture_shader, canvas, 400, 400) { |
187 // https://code.google.com/p/skia/issues/detail?id=3398 | 187 // https://code.google.com/p/skia/issues/detail?id=3398 |
188 SkRect tile = SkRect::MakeWH(100, 100); | 188 SkRect tile = SkRect::MakeWH(100, 100); |
189 | 189 |
190 SkPictureRecorder recorder; | 190 SkPictureRecorder recorder; |
191 SkCanvas* c = recorder.beginRecording(tile); | 191 SkCanvas* c = recorder.beginRecording(tile); |
192 | 192 |
193 SkRect r = tile; | 193 SkRect r = tile; |
194 r.inset(4, 4); | 194 r.inset(4, 4); |
195 SkPaint p; | 195 SkPaint p; |
196 p.setColor(0xFF303F9F); // dark blue | 196 p.setColor(sk_tool_utils::color_to_565(0xFF303F9F)); // dark blue |
197 c->drawRect(r, p); | 197 c->drawRect(r, p); |
198 p.setColor(0xFFC5CAE9); // light blue | 198 p.setColor(sk_tool_utils::color_to_565(0xFFC5CAE9)); // light blue |
199 p.setStrokeWidth(10); | 199 p.setStrokeWidth(10); |
200 c->drawLine(20, 20, 80, 80, p); | 200 c->drawLine(20, 20, 80, 80, p); |
201 | 201 |
202 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 202 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
203 SkAutoTUnref<SkShader> shader(SkShader::CreatePictureShader( | 203 SkAutoTUnref<SkShader> shader(SkShader::CreatePictureShader( |
204 picture.get(), | 204 picture.get(), |
205 SkShader::kRepeat_TileMode, | 205 SkShader::kRepeat_TileMode, |
206 SkShader::kRepeat_TileMode, | 206 SkShader::kRepeat_TileMode, |
207 NULL, | 207 NULL, |
208 NULL)); | 208 NULL)); |
209 | 209 |
210 p.setColor(0xFF8BC34A); // green | 210 p.setColor(sk_tool_utils::color_to_565(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(sk_tool_utils::color_to_565(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 |