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

Side by Side Diff: gm/pictureshader.cpp

Issue 214953003: split SkPictureRecorder out of SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: update to ToT (again) Created 6 years, 8 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 | Annotate | Revision Log
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 13 matching lines...) Expand all
24 }; 24 };
25 25
26 class PictureShaderGM : public GM { 26 class PictureShaderGM : public GM {
27 public: 27 public:
28 28
29 PictureShaderGM(SkScalar tileSize, SkScalar sceneSize) 29 PictureShaderGM(SkScalar tileSize, SkScalar sceneSize)
30 : fTileSize(tileSize) 30 : fTileSize(tileSize)
31 , fSceneSize(sceneSize) { 31 , fSceneSize(sceneSize) {
32 32
33 // Build the picture. 33 // Build the picture.
34 SkAutoTUnref<SkPicture> p(SkNEW(SkPicture)); 34 SkPictureRecorder recorder;
35 SkCanvas* pictureCanvas = p->beginRecording(SkScalarRoundToInt(tileSize) , 35 SkCanvas* pictureCanvas = recorder.beginRecording(SkScalarRoundToInt(til eSize),
36 SkScalarRoundToInt(tileSize) ); 36 SkScalarRoundToInt(til eSize));
37 this->drawTile(pictureCanvas); 37 this->drawTile(pictureCanvas);
38 p->endRecording(); 38 SkAutoTUnref<SkPicture> p(recorder.endRecording());
39 39
40 // Build a reference bitmap. 40 // Build a reference bitmap.
41 SkBitmap bm; 41 SkBitmap bm;
42 bm.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileS ize)); 42 bm.allocN32Pixels(SkScalarRoundToInt(tileSize), SkScalarRoundToInt(tileS ize));
43 bm.eraseColor(SK_ColorTRANSPARENT); 43 bm.eraseColor(SK_ColorTRANSPARENT);
44 SkCanvas bitmapCanvas(bm); 44 SkCanvas bitmapCanvas(bm);
45 this->drawTile(&bitmapCanvas); 45 this->drawTile(&bitmapCanvas);
46 46
47 for (unsigned i = 0; i < SK_ARRAY_COUNT(kTileConfigs); ++i) { 47 for (unsigned i = 0; i < SK_ARRAY_COUNT(kTileConfigs); ++i) {
48 fPictureShaders[i].reset(SkShader::CreatePictureShader(p, 48 fPictureShaders[i].reset(SkShader::CreatePictureShader(p,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 SkScalar fSceneSize; 156 SkScalar fSceneSize;
157 157
158 SkAutoTUnref<SkShader> fPictureShaders[SK_ARRAY_COUNT(kTileConfigs)]; 158 SkAutoTUnref<SkShader> fPictureShaders[SK_ARRAY_COUNT(kTileConfigs)];
159 SkAutoTUnref<SkShader> fBitmapShaders[SK_ARRAY_COUNT(kTileConfigs)]; 159 SkAutoTUnref<SkShader> fBitmapShaders[SK_ARRAY_COUNT(kTileConfigs)];
160 160
161 typedef GM INHERITED; 161 typedef GM INHERITED;
162 }; 162 };
163 163
164 DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); ) 164 DEF_GM( return SkNEW_ARGS(PictureShaderGM, (50, 100)); )
165 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698