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

Side by Side Diff: src/core/SkPictureData.h

Issue 384753004: Cleanup SkPicture* classes a bit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 6 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/SkPicture.cpp ('k') | src/core/SkPictureData.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 2011 Google Inc. 2 * Copyright 2011 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 #ifndef SkPictureData_DEFINED 8 #ifndef SkPictureData_DEFINED
9 #define SkPictureData_DEFINED 9 #define SkPictureData_DEFINED
10 10
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkPathHeap.h" 12 #include "SkPathHeap.h"
13 #include "SkPicture.h" 13 #include "SkPicture.h"
14 #include "SkPictureFlat.h" 14 #include "SkPictureFlat.h"
15 #include "SkPictureStateTree.h"
15 16
16 class SkData; 17 class SkData;
17 class SkPictureRecord; 18 class SkPictureRecord;
18 class SkReader32; 19 class SkReader32;
19 class SkStream; 20 class SkStream;
20 class SkWStream; 21 class SkWStream;
21 class SkBBoxHierarchy; 22 class SkBBoxHierarchy;
22 class SkMatrix; 23 class SkMatrix;
23 class SkPaint; 24 class SkPaint;
24 class SkPath; 25 class SkPath;
25 class SkPictureStateTree; 26 class SkPictureStateTree;
26 class SkReadBuffer; 27 class SkReadBuffer;
27 class SkRegion;
28 28
29 struct SkPictInfo { 29 struct SkPictInfo {
30 enum Flags { 30 enum Flags {
31 kCrossProcess_Flag = 1 << 0, 31 kCrossProcess_Flag = 1 << 0,
32 kScalarIsFloat_Flag = 1 << 1, 32 kScalarIsFloat_Flag = 1 << 1,
33 kPtrIs64Bit_Flag = 1 << 2, 33 kPtrIs64Bit_Flag = 1 << 2,
34 }; 34 };
35 35
36 char fMagic[8]; 36 char fMagic[8];
37 uint32_t fVersion; 37 uint32_t fVersion;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 bool containsBitmaps() const; 153 bool containsBitmaps() const;
154 154
155 const SkData* opData() const { return fOpData; } 155 const SkData* opData() const { return fOpData; }
156 156
157 protected: 157 protected:
158 explicit SkPictureData(const SkPictInfo& info); 158 explicit SkPictureData(const SkPictInfo& info);
159 159
160 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); 160 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc);
161 bool parseBuffer(SkReadBuffer& buffer); 161 bool parseBuffer(SkReadBuffer& buffer);
162 162
163 private: 163 public:
164
165 const SkBitmap& getBitmap(SkReader32* reader) const { 164 const SkBitmap& getBitmap(SkReader32* reader) const {
166 const int index = reader->readInt(); 165 const int index = reader->readInt();
167 if (SkBitmapHeap::INVALID_SLOT == index) { 166 if (SkBitmapHeap::INVALID_SLOT == index) {
168 #ifdef SK_DEBUG 167 #ifdef SK_DEBUG
169 SkDebugf("An invalid bitmap was recorded!\n"); 168 SkDebugf("An invalid bitmap was recorded!\n");
170 #endif 169 #endif
171 return fBadBitmap; 170 return fBadBitmap;
172 } 171 }
173 return (*fBitmaps)[index]; 172 return (*fBitmaps)[index];
174 } 173 }
(...skipping 10 matching lines...) Expand all
185 } 184 }
186 185
187 const SkPaint* getPaint(SkReader32* reader) const { 186 const SkPaint* getPaint(SkReader32* reader) const {
188 int index = reader->readInt(); 187 int index = reader->readInt();
189 if (index == 0) { 188 if (index == 0) {
190 return NULL; 189 return NULL;
191 } 190 }
192 return &(*fPaints)[index - 1]; 191 return &(*fPaints)[index - 1];
193 } 192 }
194 193
195 void init(); 194 void initIterator(SkPictureStateTree::Iterator* iter,
195 const SkTDArray<void*>& draws,
196 SkCanvas* canvas) const {
197 if (NULL != fStateTree) {
198 fStateTree->initIterator(iter, draws, canvas);
199 }
200 }
196 201
197 #ifdef SK_DEBUG_SIZE 202 #ifdef SK_DEBUG_SIZE
198 public:
199 int size(size_t* sizePtr); 203 int size(size_t* sizePtr);
200 int bitmaps(size_t* size); 204 int bitmaps(size_t* size);
201 int paints(size_t* size); 205 int paints(size_t* size);
202 int paths(size_t* size); 206 int paths(size_t* size);
203 #endif 207 #endif
204 208
205 #ifdef SK_DEBUG_DUMP 209 #ifdef SK_DEBUG_DUMP
206 private: 210 private:
207 void dumpBitmap(const SkBitmap& bitmap) const; 211 void dumpBitmap(const SkBitmap& bitmap) const;
208 void dumpMatrix(const SkMatrix& matrix) const; 212 void dumpMatrix(const SkMatrix& matrix) const;
(...skipping 25 matching lines...) Expand all
234 int sampleCount = 0) const; 238 int sampleCount = 0) const;
235 239
236 /** 240 /**
237 * Calls getRecommendedSampleCount with GrPixelConfig and dpi to calculate s ampleCount 241 * Calls getRecommendedSampleCount with GrPixelConfig and dpi to calculate s ampleCount
238 * and then calls the above version of suitableForGpuRasterization 242 * and then calls the above version of suitableForGpuRasterization
239 */ 243 */
240 bool suitableForGpuRasterization(GrContext* context, const char **reason, 244 bool suitableForGpuRasterization(GrContext* context, const char **reason,
241 GrPixelConfig config, SkScalar dpi) const; 245 GrPixelConfig config, SkScalar dpi) const;
242 #endif 246 #endif
243 247
244 private: // these help us with reading/writing 248 private:
249 void init();
250
251 // these help us with reading/writing
245 bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::Insta llPixelRefProc); 252 bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::Insta llPixelRefProc);
246 bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size); 253 bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size);
247 void flattenToBuffer(SkWriteBuffer&) const; 254 void flattenToBuffer(SkWriteBuffer&) const;
248 255
249 private:
250 friend class SkPicture;
251 friend class SkPicturePlayback;
252
253 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty 256 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty
254 // bitmap allows playback to draw nothing and move on. 257 // bitmap allows playback to draw nothing and move on.
255 SkBitmap fBadBitmap; 258 SkBitmap fBadBitmap;
256 259
257 SkAutoTUnref<SkBitmapHeap> fBitmapHeap; 260 SkAutoTUnref<SkBitmapHeap> fBitmapHeap;
258 261
259 SkTRefArray<SkBitmap>* fBitmaps; 262 SkTRefArray<SkBitmap>* fBitmaps;
260 SkTRefArray<SkPaint>* fPaints; 263 SkTRefArray<SkPaint>* fPaints;
261 264
262 SkData* fOpData; // opcodes and parameters 265 SkData* fOpData; // opcodes and parameters
(...skipping 13 matching lines...) Expand all
276 279
277 const SkPictInfo fInfo; 280 const SkPictInfo fInfo;
278 281
279 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); 282 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec);
280 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); 283 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec);
281 284
282 void initForPlayback() const; 285 void initForPlayback() const;
283 }; 286 };
284 287
285 #endif 288 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/core/SkPictureData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698