• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef sktext_gpu_Glyph_DEFINED
9 #define sktext_gpu_Glyph_DEFINED
10 
11 #include "src/core/SkGlyph.h"
12 #include "src/core/SkMask.h"
13 #include "src/gpu/AtlasTypes.h"
14 
15 namespace sktext::gpu {
16 
17 class Glyph {
18 public:
FormatFromSkGlyph(SkMask::Format format)19     static skgpu::MaskFormat FormatFromSkGlyph(SkMask::Format format) {
20         switch (format) {
21             case SkMask::kBW_Format:
22             case SkMask::kSDF_Format:
23                 // fall through to kA8 -- we store BW and SDF glyphs in our 8-bit cache
24             case SkMask::kA8_Format:
25                 return skgpu::MaskFormat::kA8;
26             case SkMask::k3D_Format:
27                 return skgpu::MaskFormat::kA8; // ignore the mul and add planes, just use the mask
28             case SkMask::kLCD16_Format:
29                 return skgpu::MaskFormat::kA565;
30             case SkMask::kARGB32_Format:
31                 return skgpu::MaskFormat::kARGB;
32         }
33 
34         SkUNREACHABLE;
35     }
36 
Glyph(SkPackedGlyphID packedGlyphID)37     Glyph(SkPackedGlyphID packedGlyphID) : fPackedID(packedGlyphID) {}
38 
39     const SkPackedGlyphID       fPackedID;
40     skgpu::AtlasLocator         fAtlasLocator;
41 };
42 
43 }  // namespace sktext::gpu
44 
45 #endif  // sktext_gpu_Glyph_DEFINED
46