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

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

Issue 1112833003: Straighten out SkPicture::AccelData APIs. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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/SkPicture.cpp ('k') | 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 * 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 "SkData.h" 8 #include "SkData.h"
9 #include "SkDrawable.h" 9 #include "SkDrawable.h"
10 #include "SkLayerInfo.h" 10 #include "SkLayerInfo.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 SkRect bbhBound = fBBH->getRootBound(); 70 SkRect bbhBound = fBBH->getRootBound();
71 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound)) 71 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound))
72 || (bbhBound.isEmpty() && fCullRect.isEmpty())); 72 || (bbhBound.isEmpty() && fCullRect.isEmpty()));
73 fCullRect = bbhBound; 73 fCullRect = bbhBound;
74 } 74 }
75 75
76 size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures(); 76 size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures();
77 for (int i = 0; pictList && i < pictList->count(); i++) { 77 for (int i = 0; pictList && i < pictList->count(); i++) {
78 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]); 78 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]);
79 } 79 }
80 SkPicture* pict = SkNEW_ARGS(SkPicture, 80 return SkNEW_ARGS(SkPicture, (fCullRect,
81 (fCullRect, fRecord.detach(), pictList, fBBH.detach(), subPictureByt es)); 81 fRecord.detach(),
82 82 pictList,
83 if (saveLayerData) { 83 fBBH.detach(),
84 pict->EXPERIMENTAL_addAccelData(saveLayerData); 84 saveLayerData.detach(),
85 } 85 subPictureBytes));
86
87 return pict;
88 } 86 }
89 87
90 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { 88 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
91 if (NULL == canvas) { 89 if (NULL == canvas) {
92 return; 90 return;
93 } 91 }
94 92
95 int drawableCount = 0; 93 int drawableCount = 0;
96 SkDrawable* const* drawables = NULL; 94 SkDrawable* const* drawables = NULL;
97 SkDrawableList* drawableList = fRecorder->getDrawableList(); 95 SkDrawableList* drawableList = fRecorder->getDrawableList();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // bounds in 'fBBH' 152 // bounds in 'fBBH'
155 SkRecordComputeLayers(fBounds, *fRecord, pictList, bbh, saveLayerDat a); 153 SkRecordComputeLayers(fBounds, *fRecord, pictList, bbh, saveLayerDat a);
156 } 154 }
157 155
158 size_t subPictureBytes = 0; 156 size_t subPictureBytes = 0;
159 for (int i = 0; pictList && i < pictList->count(); i++) { 157 for (int i = 0; pictList && i < pictList->count(); i++) {
160 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->be gin()[i]); 158 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->be gin()[i]);
161 } 159 }
162 // SkPicture will take ownership of a ref on both fRecord and fBBH. 160 // SkPicture will take ownership of a ref on both fRecord and fBBH.
163 // We're not willing to give up our ownership, so we must ref them for S kPicture. 161 // We're not willing to give up our ownership, so we must ref them for S kPicture.
164 SkPicture* pict = SkNEW_ARGS(SkPicture, 162 return SkNEW_ARGS(SkPicture, (fBounds,
165 (fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()), subPictureBytes)); 163 SkRef(fRecord.get()),
166 164 pictList,
167 if (saveLayerData) { 165 SkSafeRef(fBBH.get()),
168 pict->EXPERIMENTAL_addAccelData(saveLayerData); 166 saveLayerData.detach(),
169 } 167 subPictureBytes));
170 return pict;
171 } 168 }
172 }; 169 };
173 170
174 SkDrawable* SkPictureRecorder::endRecordingAsDrawable() { 171 SkDrawable* SkPictureRecorder::endRecordingAsDrawable() {
175 fActivelyRecording = false; 172 fActivelyRecording = false;
176 fRecorder->restoreToCount(1); // If we were missing any restores, add them now. 173 fRecorder->restoreToCount(1); // If we were missing any restores, add them now.
177 // TODO: delay as much of this work until just before first playback? 174 // TODO: delay as much of this work until just before first playback?
178 SkRecordOptimize(fRecord); 175 SkRecordOptimize(fRecord);
179 176
180 if (fBBH.get()) { 177 if (fBBH.get()) {
181 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); 178 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
182 } 179 }
183 180
184 SkDrawable* drawable = SkNEW_ARGS(SkRecordedDrawable, 181 SkDrawable* drawable = SkNEW_ARGS(SkRecordedDrawable,
185 (fRecord, fBBH, fRecorder->detachDrawabl eList(), 182 (fRecord, fBBH, fRecorder->detachDrawabl eList(),
186 fCullRect, 183 fCullRect,
187 SkToBool(fFlags & kComputeSaveLayerInfo _RecordFlag))); 184 SkToBool(fFlags & kComputeSaveLayerInfo _RecordFlag)));
188 185
189 // release our refs now, so only the drawable will be the owner. 186 // release our refs now, so only the drawable will be the owner.
190 fRecord.reset(NULL); 187 fRecord.reset(NULL);
191 fBBH.reset(NULL); 188 fBBH.reset(NULL);
192 189
193 return drawable; 190 return drawable;
194 } 191 }
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698