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

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

Issue 447753003: SkPicture: try to no-op away clone(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: new flag Created 6 years, 4 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 | « no previous file | no next file » | 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 // fRecord OK 146 // fRecord OK
147 SkPicture::~SkPicture() { 147 SkPicture::~SkPicture() {
148 this->callDeletionListeners(); 148 this->callDeletionListeners();
149 } 149 }
150 150
151 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE 151 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE
152 // fRecord TODO, fix by deleting this method 152 // fRecord TODO, fix by deleting this method
153 SkPicture* SkPicture::clone() const { 153 SkPicture* SkPicture::clone() const {
154 154 #ifdef SK_PICTURE_CLONE_NOOP
155 return SkRef(const_cast<SkPicture*>(this));
156 #else
155 SkAutoTDelete<SkPictureData> newData; 157 SkAutoTDelete<SkPictureData> newData;
156 158
157 if (fData.get()) { 159 if (fData.get()) {
158 SkPictCopyInfo copyInfo; 160 SkPictCopyInfo copyInfo;
159 161
160 int paintCount = SafeCount(fData->fPaints); 162 int paintCount = SafeCount(fData->fPaints);
161 163
162 /* The alternative to doing this is to have a clone method on the paint and have it 164 /* The alternative to doing this is to have a clone method on the paint and have it
163 * make the deep copy of its internal structures as needed. The holdup t o doing 165 * make the deep copy of its internal structures as needed. The holdup t o doing
164 * that is at this point we would need to pass the SkBitmapHeap so that we don't 166 * that is at this point we would need to pass the SkBitmapHeap so that we don't
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 copyInfo.controller.setupPlaybacks(); 199 copyInfo.controller.setupPlaybacks();
198 200
199 newData.reset(SkNEW_ARGS(SkPictureData, (*fData, &copyInfo))); 201 newData.reset(SkNEW_ARGS(SkPictureData, (*fData, &copyInfo)));
200 } 202 }
201 203
202 SkPicture* clone = SkNEW_ARGS(SkPicture, (newData.detach(), fWidth, fHeight) ); 204 SkPicture* clone = SkNEW_ARGS(SkPicture, (newData.detach(), fWidth, fHeight) );
203 clone->fRecordWillPlayBackBitmaps = fRecordWillPlayBackBitmaps; 205 clone->fRecordWillPlayBackBitmaps = fRecordWillPlayBackBitmaps;
204 clone->fUniqueID = this->uniqueID(); // need to call method to ensure != 0 206 clone->fUniqueID = this->uniqueID(); // need to call method to ensure != 0
205 207
206 return clone; 208 return clone;
209 #endif
207 } 210 }
208 #endif//SK_SUPPORT_LEGACY_PICTURE_CLONE 211 #endif//SK_SUPPORT_LEGACY_PICTURE_CLONE
209 212
210 // fRecord OK 213 // fRecord OK
211 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons t { 214 void SkPicture::EXPERIMENTAL_addAccelData(const SkPicture::AccelData* data) cons t {
212 fAccelData.reset(SkRef(data)); 215 fAccelData.reset(SkRef(data));
213 } 216 }
214 217
215 // fRecord OK 218 // fRecord OK
216 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData( 219 const SkPicture::AccelData* SkPicture::EXPERIMENTAL_getAccelData(
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // fRecord OK 492 // fRecord OK
490 SkPicture::SkPicture(int width, int height, SkRecord* record) 493 SkPicture::SkPicture(int width, int height, SkRecord* record)
491 : fWidth(width) 494 : fWidth(width)
492 , fHeight(height) 495 , fHeight(height)
493 , fRecord(record) 496 , fRecord(record)
494 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) { 497 , fRecordWillPlayBackBitmaps(SkRecordWillPlaybackBitmaps(*record)) {
495 this->needsNewGenID(); 498 this->needsNewGenID();
496 } 499 }
497 500
498 // Note that we are assuming that this entry point will only be called from 501 // Note that we are assuming that this entry point will only be called from
499 // one thread. Currently the only client of this method is 502 // one thread. Currently the only client of this method is
500 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single 503 // SkGpuDevice::EXPERIMENTAL_optimize which should be only called from a single
501 // thread. 504 // thread.
502 void SkPicture::addDeletionListener(DeletionListener* listener) const { 505 void SkPicture::addDeletionListener(DeletionListener* listener) const {
503 SkASSERT(NULL != listener); 506 SkASSERT(NULL != listener);
504 507
505 *fDeletionListeners.append() = SkRef(listener); 508 *fDeletionListeners.append() = SkRef(listener);
506 } 509 }
507 510
508 void SkPicture::callDeletionListeners() { 511 void SkPicture::callDeletionListeners() {
509 for (int i = 0; i < fDeletionListeners.count(); ++i) { 512 for (int i = 0; i < fDeletionListeners.count(); ++i) {
510 fDeletionListeners[i]->onDeletion(this->uniqueID()); 513 fDeletionListeners[i]->onDeletion(this->uniqueID());
511 } 514 }
512 515
513 fDeletionListeners.unrefAll(); 516 fDeletionListeners.unrefAll();
514 } 517 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698