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

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

Issue 1809733002: detach -> release (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: (C) Created 4 years, 9 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 | « src/core/SkPictureData.cpp ('k') | src/core/SkRecorder.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 * 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 "SkBigPicture.h" 8 #include "SkBigPicture.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkDrawable.h" 10 #include "SkDrawable.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 SkRect bbhBound = fBBH->getRootBound(); 85 SkRect bbhBound = fBBH->getRootBound();
86 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound)) 86 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound))
87 || (bbhBound.isEmpty() && fCullRect.isEmpty())); 87 || (bbhBound.isEmpty() && fCullRect.isEmpty()));
88 fCullRect = bbhBound; 88 fCullRect = bbhBound;
89 } 89 }
90 90
91 size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures(); 91 size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures();
92 for (int i = 0; pictList && i < pictList->count(); i++) { 92 for (int i = 0; pictList && i < pictList->count(); i++) {
93 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]); 93 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]);
94 } 94 }
95 return new SkBigPicture(fCullRect, fRecord.detach(), pictList, fBBH.detach() , 95 return new SkBigPicture(fCullRect, fRecord.release(), pictList, fBBH.release (),
96 saveLayerData.detach(), subPictureBytes); 96 saveLayerData.release(), subPictureBytes);
97 } 97 }
98 98
99 SkPicture* SkPictureRecorder::endRecordingAsPicture(const SkRect& cullRect) { 99 SkPicture* SkPictureRecorder::endRecordingAsPicture(const SkRect& cullRect) {
100 fCullRect = cullRect; 100 fCullRect = cullRect;
101 return this->endRecordingAsPicture(); 101 return this->endRecordingAsPicture();
102 } 102 }
103 103
104 104
105 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { 105 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
106 if (nullptr == canvas) { 106 if (nullptr == canvas) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 SkRecordComputeLayers(fBounds, *fRecord, scratchBounds, pictList, sa veLayerData); 166 SkRecordComputeLayers(fBounds, *fRecord, scratchBounds, pictList, sa veLayerData);
167 } 167 }
168 168
169 size_t subPictureBytes = 0; 169 size_t subPictureBytes = 0;
170 for (int i = 0; pictList && i < pictList->count(); i++) { 170 for (int i = 0; pictList && i < pictList->count(); i++) {
171 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->be gin()[i]); 171 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->be gin()[i]);
172 } 172 }
173 // SkBigPicture will take ownership of a ref on both fRecord and fBBH. 173 // SkBigPicture will take ownership of a ref on both fRecord and fBBH.
174 // We're not willing to give up our ownership, so we must ref them for S kPicture. 174 // We're not willing to give up our ownership, so we must ref them for S kPicture.
175 return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeR ef(fBBH.get()), 175 return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeR ef(fBBH.get()),
176 saveLayerData.detach(), subPictureBytes); 176 saveLayerData.release(), subPictureBytes);
177 } 177 }
178 }; 178 };
179 179
180 SkDrawable* SkPictureRecorder::endRecordingAsDrawable() { 180 SkDrawable* SkPictureRecorder::endRecordingAsDrawable() {
181 fActivelyRecording = false; 181 fActivelyRecording = false;
182 fRecorder->flushMiniRecorder(); 182 fRecorder->flushMiniRecorder();
183 fRecorder->restoreToCount(1); // If we were missing any restores, add them now. 183 fRecorder->restoreToCount(1); // If we were missing any restores, add them now.
184 184
185 // TODO: delay as much of this work until just before first playback? 185 // TODO: delay as much of this work until just before first playback?
186 SkRecordOptimize(fRecord); 186 SkRecordOptimize(fRecord);
187 187
188 if (fBBH.get()) { 188 if (fBBH.get()) {
189 SkAutoTMalloc<SkRect> bounds(fRecord->count()); 189 SkAutoTMalloc<SkRect> bounds(fRecord->count());
190 SkRecordFillBounds(fCullRect, *fRecord, bounds); 190 SkRecordFillBounds(fCullRect, *fRecord, bounds);
191 fBBH->insert(bounds, fRecord->count()); 191 fBBH->insert(bounds, fRecord->count());
192 } 192 }
193 193
194 SkDrawable* drawable = 194 SkDrawable* drawable =
195 new SkRecordedDrawable(fRecord, fBBH, fRecorder->detachDrawableList( ), fCullRect, 195 new SkRecordedDrawable(fRecord, fBBH, fRecorder->detachDrawableList( ), fCullRect,
196 SkToBool(fFlags & kComputeSaveLayerInfo_Recor dFlag)); 196 SkToBool(fFlags & kComputeSaveLayerInfo_Recor dFlag));
197 197
198 // release our refs now, so only the drawable will be the owner. 198 // release our refs now, so only the drawable will be the owner.
199 fRecord.reset(nullptr); 199 fRecord.reset(nullptr);
200 fBBH.reset(nullptr); 200 fBBH.reset(nullptr);
201 201
202 return drawable; 202 return drawable;
203 } 203 }
OLDNEW
« no previous file with comments | « src/core/SkPictureData.cpp ('k') | src/core/SkRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698