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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/SkPictureRecord.cpp ('k') | src/core/SkPictureShader.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" 11 #include "SkLayerInfo.h"
12 #include "SkPictureRecorder.h" 12 #include "SkPictureRecorder.h"
13 #include "SkPictureUtils.h" 13 #include "SkPictureUtils.h"
14 #include "SkRecord.h" 14 #include "SkRecord.h"
15 #include "SkRecordDraw.h" 15 #include "SkRecordDraw.h"
16 #include "SkRecordOpts.h" 16 #include "SkRecordOpts.h"
17 #include "SkRecorder.h" 17 #include "SkRecorder.h"
18 #include "SkTypes.h" 18 #include "SkTypes.h"
19 19
20 SkPictureRecorder::SkPictureRecorder() { 20 SkPictureRecorder::SkPictureRecorder() {
21 fActivelyRecording = false; 21 fActivelyRecording = false;
22 fRecorder.reset(new SkRecorder(nullptr, SkRect::MakeWH(0, 0), &fMiniRecorder )); 22 fRecorder.reset(new SkRecorder(nullptr, SkRect::MakeWH(0, 0), &fMiniRecorder ));
23 } 23 }
24 24
25 SkPictureRecorder::~SkPictureRecorder() {} 25 SkPictureRecorder::~SkPictureRecorder() {}
26 26
27 SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect, 27 SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect,
28 SkBBHFactory* bbhFactory /* = NULL * /, 28 SkBBHFactory* bbhFactory /* = nullpt r */,
29 uint32_t recordFlags /* = 0 */) { 29 uint32_t recordFlags /* = 0 */) {
30 fCullRect = cullRect; 30 fCullRect = cullRect;
31 fFlags = recordFlags; 31 fFlags = recordFlags;
32 32
33 if (bbhFactory) { 33 if (bbhFactory) {
34 fBBH.reset((*bbhFactory)(cullRect)); 34 fBBH.reset((*bbhFactory)(cullRect));
35 SkASSERT(fBBH.get()); 35 SkASSERT(fBBH.get());
36 } 36 }
37 37
38 if (!fRecord) { 38 if (!fRecord) {
(...skipping 23 matching lines...) Expand all
62 SkRecordOptimize(fRecord); 62 SkRecordOptimize(fRecord);
63 63
64 SkAutoTUnref<SkLayerInfo> saveLayerData; 64 SkAutoTUnref<SkLayerInfo> saveLayerData;
65 65
66 if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) { 66 if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) {
67 saveLayerData.reset(new SkLayerInfo); 67 saveLayerData.reset(new SkLayerInfo);
68 } 68 }
69 69
70 SkDrawableList* drawableList = fRecorder->getDrawableList(); 70 SkDrawableList* drawableList = fRecorder->getDrawableList();
71 SkBigPicture::SnapshotArray* pictList = 71 SkBigPicture::SnapshotArray* pictList =
72 drawableList ? drawableList->newDrawableSnapshot() : NULL; 72 drawableList ? drawableList->newDrawableSnapshot() : nullptr;
73 73
74 if (fBBH.get()) { 74 if (fBBH.get()) {
75 if (saveLayerData) { 75 if (saveLayerData) {
76 SkRecordComputeLayers(fCullRect, *fRecord, pictList, fBBH.get(), sav eLayerData); 76 SkRecordComputeLayers(fCullRect, *fRecord, pictList, fBBH.get(), sav eLayerData);
77 } else { 77 } else {
78 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); 78 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
79 } 79 }
80 SkRect bbhBound = fBBH->getRootBound(); 80 SkRect bbhBound = fBBH->getRootBound();
81 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound)) 81 SkASSERT((bbhBound.isEmpty() || fCullRect.contains(bbhBound))
82 || (bbhBound.isEmpty() && fCullRect.isEmpty())); 82 || (bbhBound.isEmpty() && fCullRect.isEmpty()));
83 fCullRect = bbhBound; 83 fCullRect = bbhBound;
84 } 84 }
85 85
86 size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures(); 86 size_t subPictureBytes = fRecorder->approxBytesUsedBySubPictures();
87 for (int i = 0; pictList && i < pictList->count(); i++) { 87 for (int i = 0; pictList && i < pictList->count(); i++) {
88 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]); 88 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]);
89 } 89 }
90 return new SkBigPicture(fCullRect, fRecord.detach(), pictList, fBBH.detach() , 90 return new SkBigPicture(fCullRect, fRecord.detach(), pictList, fBBH.detach() ,
91 saveLayerData.detach(), subPictureBytes); 91 saveLayerData.detach(), subPictureBytes);
92 } 92 }
93 93
94 SkPicture* SkPictureRecorder::endRecordingAsPicture(const SkRect& cullRect) { 94 SkPicture* SkPictureRecorder::endRecordingAsPicture(const SkRect& cullRect) {
95 fCullRect = cullRect; 95 fCullRect = cullRect;
96 return this->endRecordingAsPicture(); 96 return this->endRecordingAsPicture();
97 } 97 }
98 98
99 99
100 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { 100 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
101 if (NULL == canvas) { 101 if (nullptr == canvas) {
102 return; 102 return;
103 } 103 }
104 104
105 int drawableCount = 0; 105 int drawableCount = 0;
106 SkDrawable* const* drawables = NULL; 106 SkDrawable* const* drawables = nullptr;
107 SkDrawableList* drawableList = fRecorder->getDrawableList(); 107 SkDrawableList* drawableList = fRecorder->getDrawableList();
108 if (drawableList) { 108 if (drawableList) {
109 drawableCount = drawableList->count(); 109 drawableCount = drawableList->count();
110 drawables = drawableList->begin(); 110 drawables = drawableList->begin();
111 } 111 }
112 SkRecordDraw(*fRecord, canvas, NULL, drawables, drawableCount, NULL/*bbh*/, NULL/*callback*/); 112 SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, nullptr/*b bh*/, nullptr/*callback*/);
113 } 113 }
114 114
115 //////////////////////////////////////////////////////////////////////////////// /////////////////// 115 //////////////////////////////////////////////////////////////////////////////// ///////////////////
116 116
117 class SkRecordedDrawable : public SkDrawable { 117 class SkRecordedDrawable : public SkDrawable {
118 SkAutoTUnref<SkRecord> fRecord; 118 SkAutoTUnref<SkRecord> fRecord;
119 SkAutoTUnref<SkBBoxHierarchy> fBBH; 119 SkAutoTUnref<SkBBoxHierarchy> fBBH;
120 SkAutoTDelete<SkDrawableList> fDrawableList; 120 SkAutoTDelete<SkDrawableList> fDrawableList;
121 const SkRect fBounds; 121 const SkRect fBounds;
122 const bool fDoSaveLayerInfo; 122 const bool fDoSaveLayerInfo;
123 123
124 public: 124 public:
125 SkRecordedDrawable(SkRecord* record, SkBBoxHierarchy* bbh, SkDrawableList* d rawableList, 125 SkRecordedDrawable(SkRecord* record, SkBBoxHierarchy* bbh, SkDrawableList* d rawableList,
126 const SkRect& bounds, bool doSaveLayerInfo) 126 const SkRect& bounds, bool doSaveLayerInfo)
127 : fRecord(SkRef(record)) 127 : fRecord(SkRef(record))
128 , fBBH(SkSafeRef(bbh)) 128 , fBBH(SkSafeRef(bbh))
129 , fDrawableList(drawableList) // we take ownership 129 , fDrawableList(drawableList) // we take ownership
130 , fBounds(bounds) 130 , fBounds(bounds)
131 , fDoSaveLayerInfo(doSaveLayerInfo) 131 , fDoSaveLayerInfo(doSaveLayerInfo)
132 {} 132 {}
133 133
134 protected: 134 protected:
135 SkRect onGetBounds() override { return fBounds; } 135 SkRect onGetBounds() override { return fBounds; }
136 136
137 void onDraw(SkCanvas* canvas) override { 137 void onDraw(SkCanvas* canvas) override {
138 SkDrawable* const* drawables = NULL; 138 SkDrawable* const* drawables = nullptr;
139 int drawableCount = 0; 139 int drawableCount = 0;
140 if (fDrawableList) { 140 if (fDrawableList) {
141 drawables = fDrawableList->begin(); 141 drawables = fDrawableList->begin();
142 drawableCount = fDrawableList->count(); 142 drawableCount = fDrawableList->count();
143 } 143 }
144 SkRecordDraw(*fRecord, canvas, NULL, drawables, drawableCount, fBBH, NUL L/*callback*/); 144 SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, fBBH, nullptr/*callback*/);
145 } 145 }
146 146
147 SkPicture* onNewPictureSnapshot() override { 147 SkPicture* onNewPictureSnapshot() override {
148 SkBigPicture::SnapshotArray* pictList = NULL; 148 SkBigPicture::SnapshotArray* pictList = nullptr;
149 if (fDrawableList) { 149 if (fDrawableList) {
150 // TODO: should we plumb-down the BBHFactory and recordFlags from ou r host 150 // TODO: should we plumb-down the BBHFactory and recordFlags from ou r host
151 // PictureRecorder? 151 // PictureRecorder?
152 pictList = fDrawableList->newDrawableSnapshot(); 152 pictList = fDrawableList->newDrawableSnapshot();
153 } 153 }
154 154
155 SkAutoTUnref<SkLayerInfo> saveLayerData; 155 SkAutoTUnref<SkLayerInfo> saveLayerData;
156 156
157 if (fBBH && fDoSaveLayerInfo) { 157 if (fBBH && fDoSaveLayerInfo) {
158 saveLayerData.reset(new SkLayerInfo); 158 saveLayerData.reset(new SkLayerInfo);
159 159
160 SkBBoxHierarchy* bbh = NULL; // we've already computed fBBH (rece ived in constructor) 160 SkBBoxHierarchy* bbh = nullptr; // we've already computed fBBH (r eceived in constructor)
161 // TODO: update saveLayer info computation to reuse the already comp uted 161 // TODO: update saveLayer info computation to reuse the already comp uted
162 // bounds in 'fBBH' 162 // bounds in 'fBBH'
163 SkRecordComputeLayers(fBounds, *fRecord, pictList, bbh, saveLayerDat a); 163 SkRecordComputeLayers(fBounds, *fRecord, pictList, bbh, saveLayerDat a);
164 } 164 }
165 165
166 size_t subPictureBytes = 0; 166 size_t subPictureBytes = 0;
167 for (int i = 0; pictList && i < pictList->count(); i++) { 167 for (int i = 0; pictList && i < pictList->count(); i++) {
168 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->be gin()[i]); 168 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->be gin()[i]);
169 } 169 }
170 // SkBigPicture will take ownership of a ref on both fRecord and fBBH. 170 // SkBigPicture will take ownership of a ref on both fRecord and fBBH.
(...skipping 13 matching lines...) Expand all
184 184
185 if (fBBH.get()) { 185 if (fBBH.get()) {
186 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); 186 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
187 } 187 }
188 188
189 SkDrawable* drawable = 189 SkDrawable* drawable =
190 new SkRecordedDrawable(fRecord, fBBH, fRecorder->detachDrawableList( ), fCullRect, 190 new SkRecordedDrawable(fRecord, fBBH, fRecorder->detachDrawableList( ), fCullRect,
191 SkToBool(fFlags & kComputeSaveLayerInfo_Recor dFlag)); 191 SkToBool(fFlags & kComputeSaveLayerInfo_Recor dFlag));
192 192
193 // release our refs now, so only the drawable will be the owner. 193 // release our refs now, so only the drawable will be the owner.
194 fRecord.reset(NULL); 194 fRecord.reset(nullptr);
195 fBBH.reset(NULL); 195 fBBH.reset(nullptr);
196 196
197 return drawable; 197 return drawable;
198 } 198 }
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/core/SkPictureShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698