Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: gm/pictureshader.cpp

Issue 1263553002: make pixelsnap textblob* etc gm portable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add more 565 compatibility Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/pathinterior.cpp ('k') | gm/pixelsnap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « gm/pathinterior.cpp ('k') | gm/pixelsnap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698