OLD | NEW |
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 GrBatchAtlas_DEFINED | 8 #ifndef GrBatchAtlas_DEFINED |
9 #define GrBatchAtlas_DEFINED | 9 #define GrBatchAtlas_DEFINED |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 private: | 84 private: |
85 bool find(int index) const { | 85 bool find(int index) const { |
86 SkASSERT(index < kMaxPlots); | 86 SkASSERT(index < kMaxPlots); |
87 return (fPlotAlreadyUpdated >> index) & 1; | 87 return (fPlotAlreadyUpdated >> index) & 1; |
88 } | 88 } |
89 | 89 |
90 void set(int index) { | 90 void set(int index) { |
91 SkASSERT(!this->find(index)); | 91 SkASSERT(!this->find(index)); |
92 fPlotAlreadyUpdated = fPlotAlreadyUpdated | (1 << index); | 92 fPlotAlreadyUpdated = fPlotAlreadyUpdated | (1 << index); |
93 if (fCount < fAllocated) { | 93 fPlotsToUpdate.push_back(index); |
94 fPlotsToUpdate[fCount++] = index; | |
95 } else { | |
96 // This case will almost never happen | |
97 fAllocated = fCount << 1; | |
98 fPlotsToUpdate.realloc(fAllocated); | |
99 fPlotsToUpdate[fCount++] = index; | |
100 } | |
101 } | 94 } |
102 | 95 |
103 static const int kMinItems = 4; | 96 static const int kMinItems = 4; |
104 static const int kMaxPlots = 32; | 97 static const int kMaxPlots = 32; |
105 SkAutoSTMalloc<kMinItems, int> fPlotsToUpdate; | 98 SkSTArray<kMinItems, int, true> fPlotsToUpdate; |
106 uint32_t fPlotAlreadyUpdated; | 99 uint32_t fPlotAlreadyUpdated; |
107 int fCount; | 100 int fCount; |
108 int fAllocated; | 101 int fAllocated; |
109 | 102 |
110 friend class GrBatchAtlas; | 103 friend class GrBatchAtlas; |
111 }; | 104 }; |
112 | 105 |
113 void setLastUseTokenBulk(const BulkUseTokenUpdater& reffer, BatchToken); | 106 void setLastUseTokenBulk(const BulkUseTokenUpdater& reffer, BatchToken); |
114 | 107 |
115 static const int kGlyphMaxDim = 256; | 108 static const int kGlyphMaxDim = 256; |
(...skipping 30 matching lines...) Expand all Loading... |
146 }; | 139 }; |
147 | 140 |
148 SkTDArray<EvictionData> fEvictionCallbacks; | 141 SkTDArray<EvictionData> fEvictionCallbacks; |
149 // allocated array of GrBatchPlots | 142 // allocated array of GrBatchPlots |
150 SkAutoTUnref<BatchPlot>* fPlotArray; | 143 SkAutoTUnref<BatchPlot>* fPlotArray; |
151 // LRU list of GrPlots (MRU at head - LRU at tail) | 144 // LRU list of GrPlots (MRU at head - LRU at tail) |
152 GrBatchPlotList fPlotList; | 145 GrBatchPlotList fPlotList; |
153 }; | 146 }; |
154 | 147 |
155 #endif | 148 #endif |
OLD | NEW |