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

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

Issue 1950523002: Remove GrLayerHoister (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Forgot to remove some files Created 4 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 | « src/core/SkMultiPictureDraw.cpp ('k') | src/core/SkRecordDraw.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 * 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"
11 #include "SkLayerInfo.h"
12 #include "SkPictureRecorder.h" 11 #include "SkPictureRecorder.h"
13 #include "SkPictureUtils.h" 12 #include "SkPictureUtils.h"
14 #include "SkRecord.h" 13 #include "SkRecord.h"
15 #include "SkRecordDraw.h" 14 #include "SkRecordDraw.h"
16 #include "SkRecordOpts.h" 15 #include "SkRecordOpts.h"
17 #include "SkRecordedDrawable.h" 16 #include "SkRecordedDrawable.h"
18 #include "SkRecorder.h" 17 #include "SkRecorder.h"
19 #include "SkTypes.h" 18 #include "SkTypes.h"
20 19
21 SkPictureRecorder::SkPictureRecorder() { 20 SkPictureRecorder::SkPictureRecorder() {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 63
65 // TODO: delay as much of this work until just before first playback? 64 // TODO: delay as much of this work until just before first playback?
66 SkRecordOptimize(fRecord); 65 SkRecordOptimize(fRecord);
67 66
68 if (fRecord->count() == 0) { 67 if (fRecord->count() == 0) {
69 if (finishFlags & kReturnNullForEmpty_FinishFlag) { 68 if (finishFlags & kReturnNullForEmpty_FinishFlag) {
70 return nullptr; 69 return nullptr;
71 } 70 }
72 } 71 }
73 72
74 SkAutoTUnref<SkLayerInfo> saveLayerData;
75
76 if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) {
77 saveLayerData.reset(new SkLayerInfo);
78 }
79
80 SkDrawableList* drawableList = fRecorder->getDrawableList(); 73 SkDrawableList* drawableList = fRecorder->getDrawableList();
81 SkBigPicture::SnapshotArray* pictList = 74 SkBigPicture::SnapshotArray* pictList =
82 drawableList ? drawableList->newDrawableSnapshot() : nullptr; 75 drawableList ? drawableList->newDrawableSnapshot() : nullptr;
83 76
84 if (fBBH.get()) { 77 if (fBBH.get()) {
85 SkAutoTMalloc<SkRect> bounds(fRecord->count()); 78 SkAutoTMalloc<SkRect> bounds(fRecord->count());
86 if (saveLayerData) { 79 SkRecordFillBounds(fCullRect, *fRecord, bounds);
87 SkRecordComputeLayers(fCullRect, *fRecord, bounds, pictList, saveLay erData);
88 } else {
89 SkRecordFillBounds(fCullRect, *fRecord, bounds);
90 }
91 fBBH->insert(bounds, fRecord->count()); 80 fBBH->insert(bounds, fRecord->count());
92 81
93 // Now that we've calculated content bounds, we can update fCullRect, of ten trimming it. 82 // Now that we've calculated content bounds, we can update fCullRect, of ten trimming it.
94 // TODO: get updated fCullRect from bounds instead of forcing the BBH to return it? 83 // TODO: get updated fCullRect from bounds instead of forcing the BBH to return it?
95 SkRect bbhBound = fBBH->getRootBound(); 84 SkRect bbhBound = fBBH->getRootBound();
96 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound)) 85 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound))
97 || (bbhBound.isEmpty() && fCullRect.isEmpty())); 86 || (bbhBound.isEmpty() && fCullRect.isEmpty()));
98 fCullRect = bbhBound; 87 fCullRect = bbhBound;
99 } 88 }
100 89
101 size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures(); 90 size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures();
102 for (int i = 0; pictList && i < pictList->count(); i++) { 91 for (int i = 0; pictList && i < pictList->count(); i++) {
103 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]); 92 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]);
104 } 93 }
105 return sk_make_sp<SkBigPicture>(fCullRect, fRecord.release(), pictList, fBBH .release(), 94 return sk_make_sp<SkBigPicture>(fCullRect, fRecord.release(), pictList, fBBH .release(),
106 saveLayerData.release(), subPictureBytes); 95 subPictureBytes);
107 } 96 }
108 97
109 sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPictureWithCull(const SkRec t& cullRect, 98 sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPictureWithCull(const SkRec t& cullRect,
110 uint32_t fi nishFlags) { 99 uint32_t fi nishFlags) {
111 fCullRect = cullRect; 100 fCullRect = cullRect;
112 return this->finishRecordingAsPicture(finishFlags); 101 return this->finishRecordingAsPicture(finishFlags);
113 } 102 }
114 103
115 104
116 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { 105 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
(...skipping 24 matching lines...) Expand all
141 } 130 }
142 } 131 }
143 132
144 if (fBBH.get()) { 133 if (fBBH.get()) {
145 SkAutoTMalloc<SkRect> bounds(fRecord->count()); 134 SkAutoTMalloc<SkRect> bounds(fRecord->count());
146 SkRecordFillBounds(fCullRect, *fRecord, bounds); 135 SkRecordFillBounds(fCullRect, *fRecord, bounds);
147 fBBH->insert(bounds, fRecord->count()); 136 fBBH->insert(bounds, fRecord->count());
148 } 137 }
149 138
150 sk_sp<SkDrawable> drawable = 139 sk_sp<SkDrawable> drawable =
151 sk_make_sp<SkRecordedDrawable>(fRecord, fBBH, fRecorder->detachDrawab leList(), fCullRect, 140 sk_make_sp<SkRecordedDrawable>(fRecord, fBBH, fRecorder->detachDrawable List(), fCullRect);
152 SkToBool(fFlags & kComputeSaveLayerInfo_Recor dFlag));
153 141
154 // release our refs now, so only the drawable will be the owner. 142 // release our refs now, so only the drawable will be the owner.
155 fRecord.reset(nullptr); 143 fRecord.reset(nullptr);
156 fBBH.reset(nullptr); 144 fBBH.reset(nullptr);
157 145
158 return drawable; 146 return drawable;
159 } 147 }
OLDNEW
« no previous file with comments | « src/core/SkMultiPictureDraw.cpp ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698