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

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

Issue 715413002: More cleanup: streamline paths and bitmaps. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 1 month 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/SkPathHeap.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"
13 #include "SkPicture.h" 12 #include "SkPicture.h"
14 #include "SkPictureContentInfo.h" 13 #include "SkPictureContentInfo.h"
15 #include "SkPictureFlat.h" 14 #include "SkPictureFlat.h"
16 15
17 class SkData; 16 class SkData;
18 class SkPictureRecord; 17 class SkPictureRecord;
19 class SkReader32; 18 class SkReader32;
20 class SkStream; 19 class SkStream;
21 class SkWStream; 20 class SkWStream;
22 class SkBBoxHierarchy; 21 class SkBBoxHierarchy;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 77
79 protected: 78 protected:
80 explicit SkPictureData(const SkPictInfo& info); 79 explicit SkPictureData(const SkPictInfo& info);
81 80
82 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc); 81 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc);
83 bool parseBuffer(SkReadBuffer& buffer); 82 bool parseBuffer(SkReadBuffer& buffer);
84 83
85 public: 84 public:
86 const SkBitmap& getBitmap(SkReader32* reader) const { 85 const SkBitmap& getBitmap(SkReader32* reader) const {
87 const int index = reader->readInt(); 86 const int index = reader->readInt();
88 if (SkBitmapHeap::INVALID_SLOT == index) {
89 #ifdef SK_DEBUG
90 SkDebugf("An invalid bitmap was recorded!\n");
91 #endif
92 return fBadBitmap;
93 }
94 return (*fBitmaps)[index]; 87 return (*fBitmaps)[index];
95 } 88 }
96 89
97 const SkPath& getPath(SkReader32* reader) const { 90 const SkPath& getPath(SkReader32* reader) const {
98 int index = reader->readInt() - 1; 91 int index = reader->readInt() - 1;
99 return (*fPathHeap.get())[index]; 92 return (*fPaths)[index];
100 } 93 }
101 94
102 const SkPicture* getPicture(SkReader32* reader) const { 95 const SkPicture* getPicture(SkReader32* reader) const {
103 int index = reader->readInt(); 96 int index = reader->readInt();
104 SkASSERT(index > 0 && index <= fPictureCount); 97 SkASSERT(index > 0 && index <= fPictureCount);
105 return fPictureRefs[index - 1]; 98 return fPictureRefs[index - 1];
106 } 99 }
107 100
108 const SkPaint* getPaint(SkReader32* reader) const { 101 const SkPaint* getPaint(SkReader32* reader) const {
109 int index = reader->readInt(); 102 int index = reader->readInt();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 135
143 // these help us with reading/writing 136 // these help us with reading/writing
144 bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::Insta llPixelRefProc); 137 bool parseStreamTag(SkStream*, uint32_t tag, uint32_t size, SkPicture::Insta llPixelRefProc);
145 bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size); 138 bool parseBufferTag(SkReadBuffer&, uint32_t tag, uint32_t size);
146 void flattenToBuffer(SkWriteBuffer&) const; 139 void flattenToBuffer(SkWriteBuffer&) const;
147 140
148 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty 141 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_ SLOT. This empty
149 // bitmap allows playback to draw nothing and move on. 142 // bitmap allows playback to draw nothing and move on.
150 SkBitmap fBadBitmap; 143 SkBitmap fBadBitmap;
151 144
152 SkAutoTUnref<SkBitmapHeap> fBitmapHeap;
153
154 SkTRefArray<SkBitmap>* fBitmaps; 145 SkTRefArray<SkBitmap>* fBitmaps;
155 SkTRefArray<SkPaint>* fPaints; 146 SkTRefArray<SkPaint>* fPaints;
147 SkTRefArray<SkPath>* fPaths;
156 148
157 SkData* fOpData; // opcodes and parameters 149 SkData* fOpData; // opcodes and parameters
158 150
159 SkAutoTUnref<const SkPathHeap> fPathHeap; // reference counted
160
161 const SkPicture** fPictureRefs; 151 const SkPicture** fPictureRefs;
162 int fPictureCount; 152 int fPictureCount;
163 const SkTextBlob** fTextBlobRefs; 153 const SkTextBlob** fTextBlobRefs;
164 int fTextBlobCount; 154 int fTextBlobCount;
165 155
166 SkPictureContentInfo fContentInfo; 156 SkPictureContentInfo fContentInfo;
167 157
168 SkTypefacePlayback fTFPlayback; 158 SkTypefacePlayback fTFPlayback;
169 SkFactoryPlayback* fFactoryPlayback; 159 SkFactoryPlayback* fFactoryPlayback;
170 160
171 const SkPictInfo fInfo; 161 const SkPictInfo fInfo;
172 162
173 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); 163 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec);
174 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); 164 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec);
175 165
176 void initForPlayback() const; 166 void initForPlayback() const;
177 }; 167 };
178 168
179 #endif 169 #endif
OLDNEW
« no previous file with comments | « src/core/SkPathHeap.cpp ('k') | src/core/SkPictureData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698