OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkDumpCanvas.h" | 9 #include "SkDumpCanvas.h" |
10 #include "SkView.h" | 10 #include "SkView.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkGradientShader.h" | 12 #include "SkGradientShader.h" |
13 #include "SkGraphics.h" | 13 #include "SkGraphics.h" |
14 #include "SkImageDecoder.h" | 14 #include "SkImageDecoder.h" |
15 #include "SkOSFile.h" | 15 #include "SkOSFile.h" |
16 #include "SkPath.h" | 16 #include "SkPath.h" |
17 #include "SkPicture.h" | 17 #include "SkPicture.h" |
18 #include "SkQuadTreePicture.h" | 18 #include "SkQuadTreePicture.h" |
19 #include "SkRandom.h" | 19 #include "SkRandom.h" |
20 #include "SkRegion.h" | 20 #include "SkRegion.h" |
| 21 #include "SkRTreePicture.h" |
21 #include "SkShader.h" | 22 #include "SkShader.h" |
22 #include "SkTileGridPicture.h" | 23 #include "SkTileGridPicture.h" |
23 #include "SkUtils.h" | 24 #include "SkUtils.h" |
24 #include "SkColorPriv.h" | 25 #include "SkColorPriv.h" |
25 #include "SkColorFilter.h" | 26 #include "SkColorFilter.h" |
26 #include "SkTime.h" | 27 #include "SkTime.h" |
27 #include "SkTypeface.h" | 28 #include "SkTypeface.h" |
28 #include "SkXfermode.h" | 29 #include "SkXfermode.h" |
29 | 30 |
30 #include "SkStream.h" | 31 #include "SkStream.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (NULL == pic) { | 160 if (NULL == pic) { |
160 return NULL; | 161 return NULL; |
161 } | 162 } |
162 | 163 |
163 SkAutoTUnref<SkPictureFactory> factory; | 164 SkAutoTUnref<SkPictureFactory> factory; |
164 switch (bbox) { | 165 switch (bbox) { |
165 case kNo_BBoxType: | 166 case kNo_BBoxType: |
166 // no bbox playback necessary | 167 // no bbox playback necessary |
167 return pic.detach(); | 168 return pic.detach(); |
168 case kRTree_BBoxType: | 169 case kRTree_BBoxType: |
| 170 factory.reset(SkNEW(SkRTreePictureFactory)); |
169 break; | 171 break; |
170 case kQuadTree_BBoxType: | 172 case kQuadTree_BBoxType: |
171 factory.reset(SkNEW(SkQuadTreePictureFactory)); | 173 factory.reset(SkNEW(SkQuadTreePictureFactory)); |
172 break; | 174 break; |
173 case kTileGrid_BBoxType: { | 175 case kTileGrid_BBoxType: { |
174 SkASSERT(!fTileSize.isEmpty()); | 176 SkASSERT(!fTileSize.isEmpty()); |
175 SkTileGridPicture::TileGridInfo gridInfo; | 177 SkTileGridPicture::TileGridInfo gridInfo; |
176 gridInfo.fMargin = SkISize::Make(0, 0); | 178 gridInfo.fMargin = SkISize::Make(0, 0); |
177 gridInfo.fOffset = SkIPoint::Make(0, 0); | 179 gridInfo.fOffset = SkIPoint::Make(0, 0); |
178 gridInfo.fTileInterval = fTileSize.toRound(); | 180 gridInfo.fTileInterval = fTileSize.toRound(); |
179 factory.reset(SkNEW_ARGS(SkTileGridPictureFactory, (gridInfo))); | 181 factory.reset(SkNEW_ARGS(SkTileGridPictureFactory, (gridInfo))); |
180 break; | 182 break; |
181 } | 183 } |
182 default: | 184 default: |
183 SkASSERT(false); | 185 SkASSERT(false); |
184 } | 186 } |
185 | 187 |
186 SkPictureRecorder recorder(factory); | 188 SkPictureRecorder recorder(factory); |
187 pic->draw(recorder.beginRecording(pic->width(), pic->height(), | 189 pic->draw(recorder.beginRecording(pic->width(), pic->height())); |
188 SkPicture::kOptimizeForClippedPlayback
_RecordingFlag)); | |
189 return recorder.endRecording(); | 190 return recorder.endRecording(); |
190 } | 191 } |
191 | 192 |
192 typedef SampleView INHERITED; | 193 typedef SampleView INHERITED; |
193 }; | 194 }; |
194 | 195 |
195 SampleView* CreateSamplePictFileView(const char filename[]); | 196 SampleView* CreateSamplePictFileView(const char filename[]); |
196 SampleView* CreateSamplePictFileView(const char filename[]) { | 197 SampleView* CreateSamplePictFileView(const char filename[]) { |
197 return new PictFileView(filename); | 198 return new PictFileView(filename); |
198 } | 199 } |
199 | 200 |
200 ////////////////////////////////////////////////////////////////////////////// | 201 ////////////////////////////////////////////////////////////////////////////// |
201 | 202 |
202 #if 0 | 203 #if 0 |
203 static SkView* MyFactory() { return new PictFileView; } | 204 static SkView* MyFactory() { return new PictFileView; } |
204 static SkViewRegister reg(MyFactory); | 205 static SkViewRegister reg(MyFactory); |
205 #endif | 206 #endif |
OLD | NEW |