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

Side by Side Diff: gm/pictureshader.cpp

Issue 1790353002: Revert of more shader-->sp conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/pictureimagegenerator.cpp ('k') | gm/pictureshadertile.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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 SkPaint paint; 144 SkPaint paint;
145 paint.setStyle(SkPaint::kFill_Style); 145 paint.setStyle(SkPaint::kFill_Style);
146 paint.setColor(sk_tool_utils::color_to_565(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 paint.setShader(SkShader::MakePictureShader(fPicture, kTileConfigs[tileM ode].tmx, 153 SkAutoTUnref<SkShader> pictureShader(
154 kTileConfigs[tileMode].tmy, &localMatrix, 154 SkShader::CreatePictureShader(fPicture, kTileConfigs[tileMode].t mx,
155 nullptr)); 155 kTileConfigs[tileMode].tmy, &local Matrix, nullptr));
156 paint.setShader(pictureShader.get());
156 canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint); 157 canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
157 158
158 canvas->translate(fSceneSize * 1.1f, 0); 159 canvas->translate(fSceneSize * 1.1f, 0);
159 160
160 paint.setShader(SkShader::MakeBitmapShader(fBitmap, 161 SkAutoTUnref<SkShader> bitmapShader(SkShader::CreateBitmapShader(
161 kTileConfigs[tileMode].tmx, 162 fBitmap,
162 kTileConfigs[tileMode].tmy, 163 kTileConfigs[tileMode].tmx,
163 &localMatrix)); 164 kTileConfigs[tileMode].tmy,
165 &localMatrix));
166 paint.setShader(bitmapShader.get());
164 canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint); 167 canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
165 168
166 canvas->restore(); 169 canvas->restore();
167 } 170 }
168 171
169 SkScalar fTileSize; 172 SkScalar fTileSize;
170 SkScalar fSceneSize; 173 SkScalar fSceneSize;
171 174
172 sk_sp<SkPicture> fPicture; 175 SkAutoTUnref<SkPicture> fPicture;
173 SkBitmap fBitmap; 176 SkBitmap fBitmap;
174 177
175 typedef GM INHERITED; 178 typedef GM INHERITED;
176 }; 179 };
177 180
178 DEF_GM(return new PictureShaderGM(50, 100);) 181 DEF_GM(return new PictureShaderGM(50, 100);)
179 182
180 DEF_SIMPLE_GM(tiled_picture_shader, canvas, 400, 400) { 183 DEF_SIMPLE_GM(tiled_picture_shader, canvas, 400, 400) {
181 // https://code.google.com/p/skia/issues/detail?id=3398 184 // https://code.google.com/p/skia/issues/detail?id=3398
182 SkRect tile = SkRect::MakeWH(100, 100); 185 SkRect tile = SkRect::MakeWH(100, 100);
183 186
184 SkPictureRecorder recorder; 187 SkPictureRecorder recorder;
185 SkCanvas* c = recorder.beginRecording(tile); 188 SkCanvas* c = recorder.beginRecording(tile);
186 189
187 SkRect r = tile; 190 SkRect r = tile;
188 r.inset(4, 4); 191 r.inset(4, 4);
189 SkPaint p; 192 SkPaint p;
190 p.setColor(sk_tool_utils::color_to_565(0xFF303F9F)); // dark blue 193 p.setColor(sk_tool_utils::color_to_565(0xFF303F9F)); // dark blue
191 c->drawRect(r, p); 194 c->drawRect(r, p);
192 p.setColor(sk_tool_utils::color_to_565(0xFFC5CAE9)); // light blue 195 p.setColor(sk_tool_utils::color_to_565(0xFFC5CAE9)); // light blue
193 p.setStrokeWidth(10); 196 p.setStrokeWidth(10);
194 c->drawLine(20, 20, 80, 80, p); 197 c->drawLine(20, 20, 80, 80, p);
195 198
196 sk_sp<SkPicture> picture(recorder.endRecording()); 199 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
197 sk_sp<SkShader> shader(SkShader::MakePictureShader(picture, SkShader::kRepea t_TileMode, 200 SkAutoTUnref<SkShader> shader(
198 SkShader::kRepeat_TileMod e, 201 SkShader::CreatePictureShader(picture.get(), SkShader::kRepeat_TileM ode,
199 nullptr, nullptr)); 202 SkShader::kRepeat_TileMode, nullptr, n ullptr));
200 203
201 p.setColor(sk_tool_utils::color_to_565(0xFF8BC34A)); // green 204 p.setColor(sk_tool_utils::color_to_565(0xFF8BC34A)); // green
202 canvas->drawPaint(p); 205 canvas->drawPaint(p);
203 206
204 canvas->clipRect(SkRect::MakeXYWH(0, 0, 400, 350)); 207 canvas->clipRect(SkRect::MakeXYWH(0, 0, 400, 350));
205 p.setColor(sk_tool_utils::color_to_565(0xFFB6B6B6)); // gray 208 p.setColor(sk_tool_utils::color_to_565(0xFFB6B6B6)); // gray
206 canvas->drawPaint(p); 209 canvas->drawPaint(p);
207 p.setShader(shader.get()); 210 p.setShader(shader.get());
208 211
209 canvas->drawPaint(p); 212 canvas->drawPaint(p);
210 } 213 }
OLDNEW
« no previous file with comments | « gm/pictureimagegenerator.cpp ('k') | gm/pictureshadertile.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698