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 GrBatchFontCache_DEFINED | 8 #ifndef GrBatchFontCache_DEFINED |
9 #define GrBatchFontCache_DEFINED | 9 #define GrBatchFontCache_DEFINED |
10 | 10 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 void setAtlasSizes_ForTesting(const GrBatchAtlasConfig configs[3]); | 173 void setAtlasSizes_ForTesting(const GrBatchAtlasConfig configs[3]); |
174 | 174 |
175 private: | 175 private: |
176 static GrPixelConfig MaskFormatToPixelConfig(GrMaskFormat format) { | 176 static GrPixelConfig MaskFormatToPixelConfig(GrMaskFormat format) { |
177 static const GrPixelConfig kPixelConfigs[] = { | 177 static const GrPixelConfig kPixelConfigs[] = { |
178 kAlpha_8_GrPixelConfig, | 178 kAlpha_8_GrPixelConfig, |
179 kRGB_565_GrPixelConfig, | 179 kRGB_565_GrPixelConfig, |
180 kSkia8888_GrPixelConfig | 180 kSkia8888_GrPixelConfig |
181 }; | 181 }; |
182 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(kPixelConfigs) == kMaskFormatCount, arr
ay_size_mismatch); | 182 static_assert(SK_ARRAY_COUNT(kPixelConfigs) == kMaskFormatCount, "array_
size_mismatch"); |
183 | 183 |
184 return kPixelConfigs[format]; | 184 return kPixelConfigs[format]; |
185 } | 185 } |
186 | 186 |
187 // There is a 1:1 mapping between GrMaskFormats and atlas indices | 187 // There is a 1:1 mapping between GrMaskFormats and atlas indices |
188 static int MaskFormatToAtlasIndex(GrMaskFormat format) { | 188 static int MaskFormatToAtlasIndex(GrMaskFormat format) { |
189 static const int sAtlasIndices[] = { | 189 static const int sAtlasIndices[] = { |
190 kA8_GrMaskFormat, | 190 kA8_GrMaskFormat, |
191 kA565_GrMaskFormat, | 191 kA565_GrMaskFormat, |
192 kARGB_GrMaskFormat, | 192 kARGB_GrMaskFormat, |
193 }; | 193 }; |
194 SK_COMPILE_ASSERT(SK_ARRAY_COUNT(sAtlasIndices) == kMaskFormatCount, arr
ay_size_mismatch); | 194 static_assert(SK_ARRAY_COUNT(sAtlasIndices) == kMaskFormatCount, "array_
size_mismatch"); |
195 | 195 |
196 SkASSERT(sAtlasIndices[format] < kMaskFormatCount); | 196 SkASSERT(sAtlasIndices[format] < kMaskFormatCount); |
197 return sAtlasIndices[format]; | 197 return sAtlasIndices[format]; |
198 } | 198 } |
199 | 199 |
200 bool initAtlas(GrMaskFormat); | 200 bool initAtlas(GrMaskFormat); |
201 | 201 |
202 GrBatchTextStrike* generateStrike(GrFontScaler* scaler) { | 202 GrBatchTextStrike* generateStrike(GrFontScaler* scaler) { |
203 GrBatchTextStrike* strike = SkNEW_ARGS(GrBatchTextStrike, (this, scaler-
>getKey())); | 203 GrBatchTextStrike* strike = SkNEW_ARGS(GrBatchTextStrike, (this, scaler-
>getKey())); |
204 fCache.add(strike); | 204 fCache.add(strike); |
205 return strike; | 205 return strike; |
206 } | 206 } |
207 | 207 |
208 GrBatchAtlas* getAtlas(GrMaskFormat format) const { | 208 GrBatchAtlas* getAtlas(GrMaskFormat format) const { |
209 int atlasIndex = MaskFormatToAtlasIndex(format); | 209 int atlasIndex = MaskFormatToAtlasIndex(format); |
210 SkASSERT(fAtlases[atlasIndex]); | 210 SkASSERT(fAtlases[atlasIndex]); |
211 return fAtlases[atlasIndex]; | 211 return fAtlases[atlasIndex]; |
212 } | 212 } |
213 | 213 |
214 static void HandleEviction(GrBatchAtlas::AtlasID, void*); | 214 static void HandleEviction(GrBatchAtlas::AtlasID, void*); |
215 | 215 |
216 GrContext* fContext; | 216 GrContext* fContext; |
217 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey> fCache; | 217 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey> fCache; |
218 GrBatchAtlas* fAtlases[kMaskFormatCount]; | 218 GrBatchAtlas* fAtlases[kMaskFormatCount]; |
219 GrBatchTextStrike* fPreserveStrike; | 219 GrBatchTextStrike* fPreserveStrike; |
220 GrBatchAtlasConfig fAtlasConfigs[kMaskFormatCount]; | 220 GrBatchAtlasConfig fAtlasConfigs[kMaskFormatCount]; |
221 }; | 221 }; |
222 | 222 |
223 #endif | 223 #endif |
OLD | NEW |