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

Side by Side Diff: src/gpu/GrAtlasTextContext.h

Issue 1083703002: Convert BitmapTextBlob from using STArray to AutoSTMalloc (Closed) Base URL: https://skia.googlesource.com/skia.git@atcolorslots
Patch Set: fix Created 5 years, 8 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 | « no previous file | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 GrAtlasTextContext_DEFINED 8 #ifndef GrAtlasTextContext_DEFINED
9 #define GrAtlasTextContext_DEFINED 9 #define GrAtlasTextContext_DEFINED
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 * handle, we have a bit to mark the run as flusahable via rendering as paths. It is worth 79 * handle, we have a bit to mark the run as flusahable via rendering as paths. It is worth
80 * pointing. It would be a bit expensive to figure out ahead of time whe ther or not a run 80 * pointing. It would be a bit expensive to figure out ahead of time whe ther or not a run
81 * can flush in this manner, so we always allocate vertices for the run, regardless of 81 * can flush in this manner, so we always allocate vertices for the run, regardless of
82 * whether or not it is too large. The benefit of this strategy is that we can always reuse 82 * whether or not it is too large. The benefit of this strategy is that we can always reuse
83 * a blob allocation regardless of viewmatrix changes. We could store p ositions for these 83 * a blob allocation regardless of viewmatrix changes. We could store p ositions for these
84 * glyphs. However, its not clear if this is a win because we'd still h ave to either go the 84 * glyphs. However, its not clear if this is a win because we'd still h ave to either go the
85 * glyph cache to get the path at flush time, or hold onto the path in t he cache, which 85 * glyph cache to get the path at flush time, or hold onto the path in t he cache, which
86 * would greatly increase the memory of these cached items. 86 * would greatly increase the memory of these cached items.
87 */ 87 */
88 struct Run { 88 struct Run {
89 Run() : fColor(GrColor_ILLEGAL), fInitialized(false), fDrawAsPaths(f alse) { 89 Run()
90 : fColor(GrColor_ILLEGAL)
91 , fInitialized(false)
92 , fDrawAsPaths(false) {
90 fVertexBounds.setLargestInverted(); 93 fVertexBounds.setLargestInverted();
91 // We insert the first subrun to gurantee a run always has atlea st one subrun.
92 // We do this to simplify things when we 'hand off' data from on e subrun to the
93 // next
94 fSubRunInfo.push_back();
95 } 94 }
96 struct SubRunInfo { 95 struct SubRunInfo {
97 SubRunInfo() 96 SubRunInfo()
98 : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration) 97 : fAtlasGeneration(GrBatchAtlas::kInvalidAtlasGeneration)
99 , fGlyphStartIndex(0) 98 , fGlyphStartIndex(0)
100 , fGlyphEndIndex(0) 99 , fGlyphEndIndex(0)
101 , fVertexStartIndex(0) 100 , fVertexStartIndex(0)
102 , fVertexEndIndex(0) {} 101 , fVertexEndIndex(0) {}
103 GrMaskFormat fMaskFormat; 102 GrMaskFormat fMaskFormat;
104 uint64_t fAtlasGeneration; 103 uint64_t fAtlasGeneration;
105 uint32_t fGlyphStartIndex; 104 uint32_t fGlyphStartIndex;
106 uint32_t fGlyphEndIndex; 105 uint32_t fGlyphEndIndex;
107 size_t fVertexStartIndex; 106 size_t fVertexStartIndex;
108 size_t fVertexEndIndex; 107 size_t fVertexEndIndex;
109 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; 108 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken;
110 }; 109 };
111 SkSTArray<1, SubRunInfo, true> fSubRunInfo; 110
111 class SubRunInfoArray {
112 public:
113 SubRunInfoArray()
114 : fSubRunCount(0)
115 , fSubRunAllocation(kMinSubRuns) {
116 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get());
117 this->push_back();
118 }
119
120 int count() const { return fSubRunCount; }
121 SubRunInfo& back() { return fPtr[fSubRunCount - 1]; }
122 SubRunInfo& push_back() {
123 if (fSubRunCount >= fSubRunAllocation) {
124 fSubRunAllocation = fSubRunAllocation << 1;
125 fSubRunStorage.realloc(fSubRunAllocation * sizeof(SubRun Info));
126 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get( ));
127 }
128 SkNEW_PLACEMENT(&fPtr[fSubRunCount], SubRunInfo);
129 return fPtr[fSubRunCount++];
130 }
131 SubRunInfo& operator[](int index) {
132 return fPtr[index];
133 }
134 const SubRunInfo& operator[](int index) const {
135 return fPtr[index];
136 }
137
138 private:
139 static const int kMinSubRuns = 1;
140 static const int kMinSubRunStorage = kMinSubRuns * sizeof(SubRun Info);
141 SkAutoSTMalloc<kMinSubRunStorage, unsigned char> fSubRunStorage;
142 int fSubRunCount;
143 int fSubRunAllocation;
144 SubRunInfo* fPtr;
145 };
146 SubRunInfoArray fSubRunInfo;
112 SkAutoDescriptor fDescriptor; 147 SkAutoDescriptor fDescriptor;
113 SkAutoTUnref<SkTypeface> fTypeface; 148 SkAutoTUnref<SkTypeface> fTypeface;
114 SkRect fVertexBounds; 149 SkRect fVertexBounds;
115 GrColor fColor; 150 GrColor fColor;
116 bool fInitialized; 151 bool fInitialized;
117 bool fDrawAsPaths; 152 bool fDrawAsPaths;
118 }; 153 };
119 154
120 struct BigGlyph { 155 struct BigGlyph {
121 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx), fVy(vy) {} 156 BigGlyph(const SkPath& path, int vx, int vy) : fPath(path), fVx(vx), fVy(vy) {}
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 GrBatchTextStrike* fCurrStrike; 272 GrBatchTextStrike* fCurrStrike;
238 GrTextBlobCache* fCache; 273 GrTextBlobCache* fCache;
239 274
240 friend class GrTextBlobCache; 275 friend class GrTextBlobCache;
241 friend class BitmapTextBatch; 276 friend class BitmapTextBatch;
242 277
243 typedef GrTextContext INHERITED; 278 typedef GrTextContext INHERITED;
244 }; 279 };
245 280
246 #endif 281 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698