reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 8 | #ifndef GrGlyph_DEFINED |
| 9 | #define GrGlyph_DEFINED |
| 10 | |
Robert Phillips | 51b3e60 | 2020-04-09 12:48:50 -0400 | [diff] [blame] | 11 | #include "include/private/GrTypesPriv.h" |
| 12 | #include "src/core/SkGlyph.h" |
| 13 | #include "src/core/SkMask.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "src/gpu/GrDrawOpAtlas.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | |
Robert Phillips | 5fa68b4 | 2020-03-31 08:34:22 -0400 | [diff] [blame] | 16 | class GrGlyph { |
| 17 | public: |
Herb Derby | a4eecd8 | 2019-06-25 15:05:30 -0400 | [diff] [blame] | 18 | static GrMaskFormat FormatFromSkGlyph(SkMask::Format format) { |
| 19 | switch (format) { |
Herb Derby | 5a3fdee | 2018-12-20 14:47:03 -0500 | [diff] [blame] | 20 | case SkMask::kBW_Format: |
| 21 | case SkMask::kSDF_Format: |
| 22 | // fall through to kA8 -- we store BW and SDF glyphs in our 8-bit cache |
| 23 | case SkMask::kA8_Format: |
| 24 | return kA8_GrMaskFormat; |
| 25 | case SkMask::k3D_Format: |
| 26 | return kA8_GrMaskFormat; // ignore the mul and add planes, just use the mask |
| 27 | case SkMask::kLCD16_Format: |
| 28 | return kA565_GrMaskFormat; |
| 29 | case SkMask::kARGB32_Format: |
| 30 | return kARGB_GrMaskFormat; |
Herb Derby | 5a3fdee | 2018-12-20 14:47:03 -0500 | [diff] [blame] | 31 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 32 | |
Robert Phillips | 5fa68b4 | 2020-03-31 08:34:22 -0400 | [diff] [blame] | 33 | SkUNREACHABLE; |
Herb Derby | 5a3fdee | 2018-12-20 14:47:03 -0500 | [diff] [blame] | 34 | } |
| 35 | |
Robert Phillips | 297a219 | 2020-04-08 15:26:54 -0400 | [diff] [blame] | 36 | GrGlyph(SkPackedGlyphID packedGlyphID) : fPackedID(packedGlyphID) {} |
Herb Derby | 438ea54 | 2018-12-19 18:25:11 -0500 | [diff] [blame] | 37 | |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 38 | const SkPackedGlyphID fPackedID; |
| 39 | GrDrawOpAtlas::AtlasLocator fAtlasLocator; |
jvanverth | dd6d227 | 2014-07-22 13:25:26 -0700 | [diff] [blame] | 40 | }; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 41 | |
| 42 | #endif |