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

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

Issue 349973008: Tick off some TODOs: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: robert Created 6 years, 5 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 | « include/core/SkPicture.h ('k') | src/core/SkPicturePlayback.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 /* 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"
11 #include "SkPicturePlayback.h" 11 #include "SkPicturePlayback.h"
12 #include "SkPictureRecord.h" 12 #include "SkPictureRecord.h"
13 13
14 #include "SkBBHFactory.h" 14 #include "SkBBHFactory.h"
15 #include "SkBitmapDevice.h" 15 #include "SkBitmapDevice.h"
16 #include "SkCanvas.h" 16 #include "SkCanvas.h"
17 #include "SkChunkAlloc.h" 17 #include "SkChunkAlloc.h"
18 #include "SkDrawPictureCallback.h"
18 #include "SkPaintPriv.h" 19 #include "SkPaintPriv.h"
19 #include "SkPicture.h" 20 #include "SkPicture.h"
20 #include "SkRegion.h" 21 #include "SkRegion.h"
21 #include "SkStream.h" 22 #include "SkStream.h"
22 #include "SkTDArray.h" 23 #include "SkTDArray.h"
23 #include "SkTSearch.h" 24 #include "SkTSearch.h"
24 #include "SkTime.h" 25 #include "SkTime.h"
25 26
26 #include "SkReader32.h" 27 #include "SkReader32.h"
27 #include "SkWriter32.h" 28 #include "SkWriter32.h"
28 #include "SkRTree.h" 29 #include "SkRTree.h"
29 #include "SkBBoxHierarchyRecord.h" 30 #include "SkBBoxHierarchyRecord.h"
30 31
31 #if SK_SUPPORT_GPU 32 #if SK_SUPPORT_GPU
32 #include "GrContext.h" 33 #include "GrContext.h"
33 #endif 34 #endif
34 35
35 #include "SkRecord.h" 36 #include "SkRecord.h"
36 #include "SkRecordDraw.h" 37 #include "SkRecordDraw.h"
38 #include "SkRecorder.h"
37 39
38 template <typename T> int SafeCount(const T* obj) { 40 template <typename T> int SafeCount(const T* obj) {
39 return obj ? obj->count() : 0; 41 return obj ? obj->count() : 0;
40 } 42 }
41 43
42 #define DUMP_BUFFER_SIZE 65536 44 #define DUMP_BUFFER_SIZE 65536
43 45
44 //#define ENABLE_TIME_DRAW // dumps milliseconds for each draw 46 //#define ENABLE_TIME_DRAW // dumps milliseconds for each draw
45 47
46 48
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 bool deepCopyOps) 141 bool deepCopyOps)
140 : fWidth(width) 142 : fWidth(width)
141 , fHeight(height) { 143 , fHeight(height) {
142 this->needsNewGenID(); 144 this->needsNewGenID();
143 145
144 SkPictInfo info; 146 SkPictInfo info;
145 this->createHeader(&info); 147 this->createHeader(&info);
146 fPlayback.reset(SkNEW_ARGS(SkPicturePlayback, (record, info, deepCopyOps))); 148 fPlayback.reset(SkNEW_ARGS(SkPicturePlayback, (record, info, deepCopyOps)));
147 } 149 }
148 150
149 // fRecord TODO 151 // The simplest / safest way to copy an SkRecord is to replay it into a new one.
152 static SkRecord* copy(const SkRecord& src, int width, int height) {
153 SkRecord* dst = SkNEW(SkRecord);
154 SkRecorder recorder(dst, width, height);
155 SkRecordDraw(src, &recorder);
156 return dst;
157 }
158
159 // fRecord OK
150 SkPicture::SkPicture(const SkPicture& src) : INHERITED() { 160 SkPicture::SkPicture(const SkPicture& src) : INHERITED() {
151 this->needsNewGenID(); 161 this->needsNewGenID();
152 fWidth = src.fWidth; 162 fWidth = src.fWidth;
153 fHeight = src.fHeight; 163 fHeight = src.fHeight;
154 164
155 if (src.fPlayback.get()) { 165 if (NULL != src.fPlayback.get()) {
156 fPlayback.reset(SkNEW_ARGS(SkPicturePlayback, (*src.fPlayback))); 166 fPlayback.reset(SkNEW_ARGS(SkPicturePlayback, (*src.fPlayback)));
157 fUniqueID = src.uniqueID(); // need to call method to ensure != 0 167 fUniqueID = src.uniqueID(); // need to call method to ensure != 0
168 }
169
170 if (NULL != src.fRecord.get()) {
171 fRecord.reset(copy(*src.fRecord, fWidth, fHeight));
172 fUniqueID = src.uniqueID(); // need to call method to ensure != 0
158 } 173 }
159 } 174 }
160 175
161 // fRecord OK 176 // fRecord OK
162 SkPicture::~SkPicture() {} 177 SkPicture::~SkPicture() {}
163 178
164 // fRecord TODO 179 // fRecord TODO, fix by deleting this method
165 SkPicture* SkPicture::clone() const { 180 SkPicture* SkPicture::clone() const {
166 SkPicture* clonedPicture = SkNEW(SkPicture); 181 SkPicture* clonedPicture = SkNEW(SkPicture);
167 this->clone(clonedPicture, 1); 182 this->clone(clonedPicture, 1);
168 return clonedPicture; 183 return clonedPicture;
169 } 184 }
170 185
171 // fRecord TODO 186 // fRecord TODO, fix by deleting this method
172 void SkPicture::clone(SkPicture* pictures, int count) const { 187 void SkPicture::clone(SkPicture* pictures, int count) const {
173 SkPictCopyInfo copyInfo; 188 SkPictCopyInfo copyInfo;
174 189
175 for (int i = 0; i < count; i++) { 190 for (int i = 0; i < count; i++) {
176 SkPicture* clone = &pictures[i]; 191 SkPicture* clone = &pictures[i];
177 192
178 clone->needsNewGenID(); 193 clone->needsNewGenID();
179 clone->fWidth = fWidth; 194 clone->fWidth = fWidth;
180 clone->fHeight = fHeight; 195 clone->fHeight = fHeight;
181 clone->fPlayback.reset(NULL); 196 clone->fPlayback.reset(NULL);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 301
287 // fRecord OK 302 // fRecord OK
288 void SkPicture::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) const { 303 void SkPicture::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) const {
289 SkASSERT(NULL != canvas); 304 SkASSERT(NULL != canvas);
290 SkASSERT(NULL != fPlayback.get() || NULL != fRecord.get()); 305 SkASSERT(NULL != fPlayback.get() || NULL != fRecord.get());
291 306
292 if (NULL != fPlayback.get()) { 307 if (NULL != fPlayback.get()) {
293 fPlayback->draw(*canvas, callback); 308 fPlayback->draw(*canvas, callback);
294 } 309 }
295 if (NULL != fRecord.get()) { 310 if (NULL != fRecord.get()) {
296 // TODO: support SkDrawPictureCallback 311 SkRecordDraw(*fRecord, canvas, callback);
297 SkRecordDraw(*fRecord, canvas);
298 } 312 }
299 } 313 }
300 314
301 /////////////////////////////////////////////////////////////////////////////// 315 ///////////////////////////////////////////////////////////////////////////////
302 316
303 #include "SkStream.h" 317 #include "SkStream.h"
304 318
305 static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' }; 319 static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' };
306 320
307 // fRecord OK 321 // fRecord OK
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 502
489 // fRecord TODO 503 // fRecord TODO
490 bool SkPicture::willPlayBackBitmaps() const { 504 bool SkPicture::willPlayBackBitmaps() const {
491 if (!fPlayback.get()) { 505 if (!fPlayback.get()) {
492 return false; 506 return false;
493 } 507 }
494 return fPlayback->containsBitmaps(); 508 return fPlayback->containsBitmaps();
495 } 509 }
496 510
497 #ifdef SK_BUILD_FOR_ANDROID 511 #ifdef SK_BUILD_FOR_ANDROID
498 // fRecord TODO 512 // fRecord TODO, fix by switching Android to SkDrawPictureCallback, then deletin g this method
499 void SkPicture::abortPlayback() { 513 void SkPicture::abortPlayback() {
500 if (NULL == fPlayback.get()) { 514 if (NULL == fPlayback.get()) {
501 return; 515 return;
502 } 516 }
503 fPlayback->abort(); 517 fPlayback->abort();
504 } 518 }
505 #endif 519 #endif
506 520
507 // fRecord OK 521 // fRecord OK
508 static int32_t next_picture_generation_id() { 522 static int32_t next_picture_generation_id() {
(...skipping 15 matching lines...) Expand all
524 return fUniqueID; 538 return fUniqueID;
525 } 539 }
526 540
527 // fRecord OK 541 // fRecord OK
528 SkPicture::SkPicture(int width, int height, SkRecord* record) 542 SkPicture::SkPicture(int width, int height, SkRecord* record)
529 : fWidth(width) 543 : fWidth(width)
530 , fHeight(height) 544 , fHeight(height)
531 , fRecord(record) { 545 , fRecord(record) {
532 this->needsNewGenID(); 546 this->needsNewGenID();
533 } 547 }
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPicturePlayback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698