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

Side by Side Diff: src/core/SkPicture.cpp

Issue 238273012: Staged removal of SkPicture-derived classes (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: have SkPicture only friend SkPictureRecorder once 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
« no previous file with comments | « samplecode/SampleTiling.cpp ('k') | src/core/SkQuadTreePicture.h » ('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 /* 2 /*
3 * Copyright 2007 The Android Open Source Project 3 * Copyright 2007 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkPictureFlat.h" 10 #include "SkPictureFlat.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 int32_t id = sk_atomic_inc(&gNextID); 215 int32_t id = sk_atomic_inc(&gNextID);
216 if (id >= 1 << (8 * sizeof(Domain))) { 216 if (id >= 1 << (8 * sizeof(Domain))) {
217 SK_CRASH(); 217 SK_CRASH();
218 } 218 }
219 219
220 return static_cast<Domain>(id); 220 return static_cast<Domain>(id);
221 } 221 }
222 222
223 /////////////////////////////////////////////////////////////////////////////// 223 ///////////////////////////////////////////////////////////////////////////////
224 224
225 #ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
226
225 SkCanvas* SkPicture::beginRecording(int width, int height, 227 SkCanvas* SkPicture::beginRecording(int width, int height,
226 uint32_t recordingFlags) { 228 uint32_t recordingFlags) {
227 if (fPlayback) { 229 if (fPlayback) {
228 SkDELETE(fPlayback); 230 SkDELETE(fPlayback);
229 fPlayback = NULL; 231 fPlayback = NULL;
230 } 232 }
231 SkSafeUnref(fAccelData); 233 SkSafeUnref(fAccelData);
232 SkSafeSetNull(fRecord); 234 SkSafeSetNull(fRecord);
233 235
234 this->needsNewGenID(); 236 this->needsNewGenID();
(...skipping 10 matching lines...) Expand all
245 fRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordingFlags, tree) ); 247 fRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordingFlags, tree) );
246 tree->unref(); 248 tree->unref();
247 } else { 249 } else {
248 fRecord = SkNEW_ARGS(SkPictureRecord, (size, recordingFlags)); 250 fRecord = SkNEW_ARGS(SkPictureRecord, (size, recordingFlags));
249 } 251 }
250 fRecord->beginRecording(); 252 fRecord->beginRecording();
251 253
252 return fRecord; 254 return fRecord;
253 } 255 }
254 256
257 #endif
258
259 SkCanvas* SkPicture::beginRecording(int width, int height,
260 SkBBHFactory* bbhFactory,
261 uint32_t recordingFlags) {
262 if (fPlayback) {
263 SkDELETE(fPlayback);
264 fPlayback = NULL;
265 }
266 SkSafeUnref(fAccelData);
267 SkSafeSetNull(fRecord);
268
269 this->needsNewGenID();
270
271 fWidth = width;
272 fHeight = height;
273
274 const SkISize size = SkISize::Make(width, height);
275
276 if (NULL != bbhFactory) {
277 SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height));
278 SkASSERT(NULL != tree);
279 fRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (size,
280 recordingFlags|
281 kOptimizeForClippedPlayback _RecordingFlag,
282 tree.get()));
283 } else {
284 fRecord = SkNEW_ARGS(SkPictureRecord, (size, recordingFlags));
285 }
286 fRecord->beginRecording();
287
288 return fRecord;
289 }
290
291
292 #ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
293
255 SkBBoxHierarchy* SkPicture::createBBoxHierarchy() const { 294 SkBBoxHierarchy* SkPicture::createBBoxHierarchy() const {
256 // TODO: this code is now replicated in SkRTreePicture. Once all external 295 // TODO: this code is now replicated in SkRTreePicture. Once all external
257 // clients have been weaned off of kOptimizeForClippedPlayback_RecordingFlag , 296 // clients have been weaned off of kOptimizeForClippedPlayback_RecordingFlag ,
258 // this code can be removed. 297 // this code can be removed.
259 298
260 // These values were empirically determined to produce reasonable 299 // These values were empirically determined to produce reasonable
261 // performance in most cases. 300 // performance in most cases.
262 static const int kRTreeMinChildren = 6; 301 static const int kRTreeMinChildren = 6;
263 static const int kRTreeMaxChildren = 11; 302 static const int kRTreeMaxChildren = 11;
264 303
265 SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(fWidth), 304 SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(fWidth),
266 SkIntToScalar(fHeight)); 305 SkIntToScalar(fHeight));
267 bool sortDraws = false; // Do not sort draw calls when bulk loading. 306 bool sortDraws = false; // Do not sort draw calls when bulk loading.
268 307
269 return SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren, 308 return SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren,
270 aspectRatio, sortDraws); 309 aspectRatio, sortDraws);
271 } 310 }
272 311
312 #endif
313
273 SkCanvas* SkPicture::getRecordingCanvas() const { 314 SkCanvas* SkPicture::getRecordingCanvas() const {
274 // will be null if we are not recording 315 // will be null if we are not recording
275 return fRecord; 316 return fRecord;
276 } 317 }
277 318
278 void SkPicture::endRecording() { 319 void SkPicture::endRecording() {
279 if (NULL == fPlayback) { 320 if (NULL == fPlayback) {
280 if (NULL != fRecord) { 321 if (NULL != fRecord) {
281 fRecord->endRecording(); 322 fRecord->endRecording();
282 SkPictInfo info; 323 SkPictInfo info;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 if (NULL != fRecord) { 559 if (NULL != fRecord) {
519 SkASSERT(NULL == fPlayback); 560 SkASSERT(NULL == fPlayback);
520 return SK_InvalidGenID; 561 return SK_InvalidGenID;
521 } 562 }
522 563
523 if (SK_InvalidGenID == fUniqueID) { 564 if (SK_InvalidGenID == fUniqueID) {
524 fUniqueID = next_picture_generation_id(); 565 fUniqueID = next_picture_generation_id();
525 } 566 }
526 return fUniqueID; 567 return fUniqueID;
527 } 568 }
OLDNEW
« no previous file with comments | « samplecode/SampleTiling.cpp ('k') | src/core/SkQuadTreePicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698