Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "SkPictureRecorder.h" | 11 #include "SkPictureRecorder.h" |
| 12 #include "SkPictureUtils.h" | |
| 12 #include "SkRecord.h" | 13 #include "SkRecord.h" |
| 13 #include "SkRecordDraw.h" | 14 #include "SkRecordDraw.h" |
| 15 #include "SkRecordOpts.h" | |
| 14 #include "SkRecorder.h" | 16 #include "SkRecorder.h" |
| 15 #include "SkRecordOpts.h" | |
| 16 #include "SkTypes.h" | 17 #include "SkTypes.h" |
| 17 | 18 |
| 18 SkPictureRecorder::SkPictureRecorder() { | 19 SkPictureRecorder::SkPictureRecorder() { |
| 19 fActivelyRecording = false; | 20 fActivelyRecording = false; |
| 20 fRecorder.reset(SkNEW_ARGS(SkRecorder, (nullptr, SkRect::MakeWH(0,0)))); | 21 fRecorder.reset(SkNEW_ARGS(SkRecorder, (nullptr, SkRect::MakeWH(0,0)))); |
| 21 } | 22 } |
| 22 | 23 |
| 23 SkPictureRecorder::~SkPictureRecorder() {} | 24 SkPictureRecorder::~SkPictureRecorder() {} |
| 24 | 25 |
| 25 SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect, | 26 SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 SkRecordComputeLayers(fCullRect, *fRecord, pictList, fBBH.get(), sav eLayerData); | 66 SkRecordComputeLayers(fCullRect, *fRecord, pictList, fBBH.get(), sav eLayerData); |
| 66 } else { | 67 } else { |
| 67 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); | 68 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); |
| 68 } | 69 } |
| 69 SkRect bbhBound = fBBH->getRootBound(); | 70 SkRect bbhBound = fBBH->getRootBound(); |
| 70 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound)) | 71 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound)) |
| 71 || (bbhBound.isEmpty() && fCullRect.isEmpty())); | 72 || (bbhBound.isEmpty() && fCullRect.isEmpty())); |
| 72 fCullRect = bbhBound; | 73 fCullRect = bbhBound; |
| 73 } | 74 } |
| 74 | 75 |
| 75 SkPicture* pict = SkNEW_ARGS(SkPicture, (fCullRect, fRecord, pictList, fBBH) ); | 76 size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures(); |
| 77 for (int i = 0; pictList && i < pictList->count(); i++) { | |
| 78 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]); | |
|
reed1
2015/04/21 22:13:04
why call the utils version here?
mtklein
2015/04/21 22:18:31
There is no other version?
Were you expecting a c
| |
| 79 } | |
| 80 SkPicture* pict = | |
| 81 SkNEW_ARGS(SkPicture, (fCullRect, fRecord, pictList, fBBH, subPictureByt es)); | |
| 76 | 82 |
| 77 if (saveLayerData) { | 83 if (saveLayerData) { |
| 78 pict->EXPERIMENTAL_addAccelData(saveLayerData); | 84 pict->EXPERIMENTAL_addAccelData(saveLayerData); |
| 79 } | 85 } |
| 80 | 86 |
| 81 // release our refs now, so only the picture will be the owner. | 87 // release our refs now, so only the picture will be the owner. |
| 82 fRecord.reset(NULL); | 88 fRecord.reset(NULL); |
| 83 fBBH.reset(NULL); | 89 fBBH.reset(NULL); |
| 84 | 90 |
| 85 return pict; | 91 return pict; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); | 152 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); |
| 147 | 153 |
| 148 saveLayerData.reset(SkNEW_ARGS(SkLayerInfo, (key))); | 154 saveLayerData.reset(SkNEW_ARGS(SkLayerInfo, (key))); |
| 149 | 155 |
| 150 SkBBoxHierarchy* bbh = NULL; // we've already computed fBBH (rece ived in constructor) | 156 SkBBoxHierarchy* bbh = NULL; // we've already computed fBBH (rece ived in constructor) |
| 151 // TODO: update saveLayer info computation to reuse the already comp uted | 157 // TODO: update saveLayer info computation to reuse the already comp uted |
| 152 // bounds in 'fBBH' | 158 // bounds in 'fBBH' |
| 153 SkRecordComputeLayers(fBounds, *fRecord, pictList, bbh, saveLayerDat a); | 159 SkRecordComputeLayers(fBounds, *fRecord, pictList, bbh, saveLayerDat a); |
| 154 } | 160 } |
| 155 | 161 |
| 156 SkPicture* pict = SkNEW_ARGS(SkPicture, (fBounds, fRecord, pictList, fBB H)); | 162 size_t subPictureBytes = 0; |
| 163 for (int i = 0; pictList && i < pictList->count(); i++) { | |
| 164 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->be gin()[i]); | |
|
reed1
2015/04/21 22:13:04
... and here?
| |
| 165 } | |
| 166 SkPicture* pict = | |
| 167 SkNEW_ARGS(SkPicture, (fBounds, fRecord, pictList, fBBH, subPictureB ytes)); | |
| 157 | 168 |
| 158 if (saveLayerData) { | 169 if (saveLayerData) { |
| 159 pict->EXPERIMENTAL_addAccelData(saveLayerData); | 170 pict->EXPERIMENTAL_addAccelData(saveLayerData); |
| 160 } | 171 } |
| 161 return pict; | 172 return pict; |
| 162 } | 173 } |
| 163 }; | 174 }; |
| 164 | 175 |
| 165 SkDrawable* SkPictureRecorder::endRecordingAsDrawable() { | 176 SkDrawable* SkPictureRecorder::endRecordingAsDrawable() { |
| 166 fActivelyRecording = false; | 177 fActivelyRecording = false; |
| 167 fRecorder->restoreToCount(1); // If we were missing any restores, add them now. | 178 fRecorder->restoreToCount(1); // If we were missing any restores, add them now. |
| 168 // TODO: delay as much of this work until just before first playback? | 179 // TODO: delay as much of this work until just before first playback? |
| 169 SkRecordOptimize(fRecord); | 180 SkRecordOptimize(fRecord); |
| 170 | 181 |
| 171 if (fBBH.get()) { | 182 if (fBBH.get()) { |
| 172 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); | 183 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); |
| 173 } | 184 } |
| 174 | 185 |
| 175 SkDrawable* drawable = SkNEW_ARGS(SkRecordedDrawable, | 186 SkDrawable* drawable = SkNEW_ARGS(SkRecordedDrawable, |
| 176 (fRecord, fBBH, fRecorder->detachDrawabl eList(), | 187 (fRecord, fBBH, fRecorder->detachDrawabl eList(), |
| 177 fCullRect, | 188 fCullRect, |
| 178 SkToBool(fFlags & kComputeSaveLayerInfo _RecordFlag))); | 189 SkToBool(fFlags & kComputeSaveLayerInfo _RecordFlag))); |
| 179 | 190 |
| 180 // release our refs now, so only the drawable will be the owner. | 191 // release our refs now, so only the drawable will be the owner. |
| 181 fRecord.reset(NULL); | 192 fRecord.reset(NULL); |
| 182 fBBH.reset(NULL); | 193 fBBH.reset(NULL); |
| 183 | 194 |
| 184 return drawable; | 195 return drawable; |
| 185 } | 196 } |
| OLD | NEW |