joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 8 | #include "GrGlyphCache.h" |
Khushal | fa8ff09 | 2018-06-06 17:46:38 -0700 | [diff] [blame] | 9 | #include "GrAtlasManager.h" |
| 10 | #include "GrCaps.h" |
Timothy Liang | 91e260f | 2018-06-15 13:28:35 -0400 | [diff] [blame] | 11 | #include "GrColor.h" |
Khushal | fa8ff09 | 2018-06-06 17:46:38 -0700 | [diff] [blame] | 12 | #include "GrDistanceFieldGenFromVector.h" |
Robert Phillips | f95b175 | 2017-08-31 08:56:07 -0400 | [diff] [blame] | 13 | |
Hal Canary | 95e3c05 | 2017-01-11 12:44:43 -0500 | [diff] [blame] | 14 | #include "SkAutoMalloc.h" |
Robert Phillips | f95b175 | 2017-08-31 08:56:07 -0400 | [diff] [blame] | 15 | #include "SkDistanceFieldGen.h" |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 16 | |
Khushal | fa8ff09 | 2018-06-06 17:46:38 -0700 | [diff] [blame] | 17 | GrGlyphCache::GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes) |
Timothy Liang | 91e260f | 2018-06-15 13:28:35 -0400 | [diff] [blame] | 18 | : fPreserveStrike(nullptr) |
Timothy Liang | 91e260f | 2018-06-15 13:28:35 -0400 | [diff] [blame] | 19 | , f565Masks(SkMasks::CreateMasks({0xF800, 0x07E0, 0x001F, 0}, |
Herb Derby | 96519f2 | 2018-09-12 17:15:26 -0400 | [diff] [blame^] | 20 | GrMaskFormatBytesPerPixel(kA565_GrMaskFormat) * 8)) { } |
joshualitt | 62db8ba | 2015-04-09 08:22:37 -0700 | [diff] [blame] | 21 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 22 | GrGlyphCache::~GrGlyphCache() { |
bsalomon | c5fd5c4 | 2016-05-17 11:58:24 -0700 | [diff] [blame] | 23 | StrikeHash::Iter iter(&fCache); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 24 | while (!iter.done()) { |
joshualitt | a5f1d5a | 2015-05-22 13:09:57 -0700 | [diff] [blame] | 25 | (*iter).fIsAbandoned = true; |
joshualitt | ae32c10 | 2015-04-21 09:37:57 -0700 | [diff] [blame] | 26 | (*iter).unref(); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 27 | ++iter; |
| 28 | } |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 31 | void GrGlyphCache::freeAll() { |
bsalomon | c5fd5c4 | 2016-05-17 11:58:24 -0700 | [diff] [blame] | 32 | StrikeHash::Iter iter(&fCache); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 33 | while (!iter.done()) { |
joshualitt | a5f1d5a | 2015-05-22 13:09:57 -0700 | [diff] [blame] | 34 | (*iter).fIsAbandoned = true; |
joshualitt | ae32c10 | 2015-04-21 09:37:57 -0700 | [diff] [blame] | 35 | (*iter).unref(); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 36 | ++iter; |
| 37 | } |
| 38 | fCache.rewind(); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 41 | void GrGlyphCache::HandleEviction(GrDrawOpAtlas::AtlasID id, void* ptr) { |
| 42 | GrGlyphCache* glyphCache = reinterpret_cast<GrGlyphCache*>(ptr); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 43 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 44 | StrikeHash::Iter iter(&glyphCache->fCache); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 45 | for (; !iter.done(); ++iter) { |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 46 | GrTextStrike* strike = &*iter; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 47 | strike->removeID(id); |
| 48 | |
| 49 | // clear out any empty strikes. We will preserve the strike whose call to addToAtlas |
| 50 | // triggered the eviction |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 51 | if (strike != glyphCache->fPreserveStrike && 0 == strike->fAtlasedGlyphs) { |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 52 | glyphCache->fCache.remove(GrTextStrike::GetKey(*strike)); |
joshualitt | ae32c10 | 2015-04-21 09:37:57 -0700 | [diff] [blame] | 53 | strike->fIsAbandoned = true; |
| 54 | strike->unref(); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 59 | static inline GrMaskFormat get_packed_glyph_mask_format(const SkGlyph& glyph) { |
| 60 | SkMask::Format format = static_cast<SkMask::Format>(glyph.fMaskFormat); |
| 61 | switch (format) { |
| 62 | case SkMask::kBW_Format: |
Jim Van Verth | d401da6 | 2018-05-03 10:40:30 -0400 | [diff] [blame] | 63 | case SkMask::kSDF_Format: |
| 64 | // fall through to kA8 -- we store BW and SDF glyphs in our 8-bit cache |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 65 | case SkMask::kA8_Format: |
| 66 | return kA8_GrMaskFormat; |
Ben Wagner | 339b84e | 2017-11-10 16:24:50 -0500 | [diff] [blame] | 67 | case SkMask::k3D_Format: |
| 68 | return kA8_GrMaskFormat; // ignore the mul and add planes, just use the mask |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 69 | case SkMask::kLCD16_Format: |
| 70 | return kA565_GrMaskFormat; |
| 71 | case SkMask::kARGB32_Format: |
| 72 | return kARGB_GrMaskFormat; |
| 73 | default: |
| 74 | SkDEBUGFAIL("unsupported SkMask::Format"); |
| 75 | return kA8_GrMaskFormat; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | static inline bool get_packed_glyph_bounds(SkGlyphCache* cache, const SkGlyph& glyph, |
| 80 | SkIRect* bounds) { |
| 81 | #if 1 |
| 82 | // crbug:510931 |
| 83 | // Retrieving the image from the cache can actually change the mask format. |
| 84 | cache->findImage(glyph); |
| 85 | #endif |
| 86 | bounds->setXYWH(glyph.fLeft, glyph.fTop, glyph.fWidth, glyph.fHeight); |
| 87 | |
| 88 | return true; |
| 89 | } |
| 90 | |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 91 | // expands each bit in a bitmask to 0 or ~0 of type INT_TYPE. Used to expand a BW glyph mask to |
| 92 | // A8, RGB565, or RGBA8888. |
| 93 | template <typename INT_TYPE> |
| 94 | static void expand_bits(INT_TYPE* dst, |
| 95 | const uint8_t* src, |
| 96 | int width, |
| 97 | int height, |
| 98 | int dstRowBytes, |
| 99 | int srcRowBytes) { |
| 100 | for (int i = 0; i < height; ++i) { |
| 101 | int rowWritesLeft = width; |
| 102 | const uint8_t* s = src; |
| 103 | INT_TYPE* d = dst; |
| 104 | while (rowWritesLeft > 0) { |
| 105 | unsigned mask = *s++; |
| 106 | for (int i = 7; i >= 0 && rowWritesLeft; --i, --rowWritesLeft) { |
| 107 | *d++ = (mask & (1 << i)) ? (INT_TYPE)(~0UL) : 0; |
| 108 | } |
| 109 | } |
| 110 | dst = reinterpret_cast<INT_TYPE*>(reinterpret_cast<intptr_t>(dst) + dstRowBytes); |
| 111 | src += srcRowBytes; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | static bool get_packed_glyph_image(SkGlyphCache* cache, const SkGlyph& glyph, int width, |
| 116 | int height, int dstRB, GrMaskFormat expectedMaskFormat, |
Timothy Liang | 91e260f | 2018-06-15 13:28:35 -0400 | [diff] [blame] | 117 | void* dst, const SkMasks& masks) { |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 118 | SkASSERT(glyph.fWidth == width); |
| 119 | SkASSERT(glyph.fHeight == height); |
| 120 | const void* src = cache->findImage(glyph); |
| 121 | if (nullptr == src) { |
| 122 | return false; |
| 123 | } |
| 124 | |
Timothy Liang | 91e260f | 2018-06-15 13:28:35 -0400 | [diff] [blame] | 125 | // Convert if the glyph uses a 565 mask format since it is using LCD text rendering but the |
| 126 | // expected format is 8888 (will happen on macOS with Metal since that combination does not |
| 127 | // support 565). |
| 128 | if (kA565_GrMaskFormat == get_packed_glyph_mask_format(glyph) && |
| 129 | kARGB_GrMaskFormat == expectedMaskFormat) { |
| 130 | const int a565Bpp = GrMaskFormatBytesPerPixel(kA565_GrMaskFormat); |
| 131 | const int argbBpp = GrMaskFormatBytesPerPixel(kARGB_GrMaskFormat); |
| 132 | for (int y = 0; y < height; y++) { |
| 133 | for (int x = 0; x < width; x++) { |
| 134 | uint16_t color565 = 0; |
| 135 | memcpy(&color565, src, a565Bpp); |
| 136 | uint32_t colorRGBA = GrColorPackRGBA(masks.getRed(color565), |
| 137 | masks.getGreen(color565), |
| 138 | masks.getBlue(color565), |
| 139 | 0xFF); |
| 140 | memcpy(dst, &colorRGBA, argbBpp); |
| 141 | src = (char*)src + a565Bpp; |
| 142 | dst = (char*)dst + argbBpp; |
| 143 | } |
| 144 | } |
| 145 | return true; |
| 146 | } |
| 147 | |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 148 | // crbug:510931 |
| 149 | // Retrieving the image from the cache can actually change the mask format. This case is very |
| 150 | // uncommon so for now we just draw a clear box for these glyphs. |
| 151 | if (get_packed_glyph_mask_format(glyph) != expectedMaskFormat) { |
| 152 | const int bpp = GrMaskFormatBytesPerPixel(expectedMaskFormat); |
| 153 | for (int y = 0; y < height; y++) { |
| 154 | sk_bzero(dst, width * bpp); |
| 155 | dst = (char*)dst + dstRB; |
| 156 | } |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | int srcRB = glyph.rowBytes(); |
| 161 | // The windows font host sometimes has BW glyphs in a non-BW strike. So it is important here to |
| 162 | // check the glyph's format, not the strike's format, and to be able to convert to any of the |
| 163 | // GrMaskFormats. |
| 164 | if (SkMask::kBW_Format == glyph.fMaskFormat) { |
| 165 | // expand bits to our mask type |
| 166 | const uint8_t* bits = reinterpret_cast<const uint8_t*>(src); |
| 167 | switch (expectedMaskFormat) { |
| 168 | case kA8_GrMaskFormat:{ |
| 169 | uint8_t* bytes = reinterpret_cast<uint8_t*>(dst); |
| 170 | expand_bits(bytes, bits, width, height, dstRB, srcRB); |
| 171 | break; |
| 172 | } |
| 173 | case kA565_GrMaskFormat: { |
| 174 | uint16_t* rgb565 = reinterpret_cast<uint16_t*>(dst); |
| 175 | expand_bits(rgb565, bits, width, height, dstRB, srcRB); |
| 176 | break; |
| 177 | } |
| 178 | default: |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 179 | SK_ABORT("Invalid GrMaskFormat"); |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 180 | } |
| 181 | } else if (srcRB == dstRB) { |
| 182 | memcpy(dst, src, dstRB * height); |
| 183 | } else { |
| 184 | const int bbp = GrMaskFormatBytesPerPixel(expectedMaskFormat); |
| 185 | for (int y = 0; y < height; y++) { |
| 186 | memcpy(dst, src, width * bbp); |
| 187 | src = (const char*)src + srcRB; |
| 188 | dst = (char*)dst + dstRB; |
| 189 | } |
| 190 | } |
| 191 | return true; |
| 192 | } |
| 193 | |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 194 | /////////////////////////////////////////////////////////////////////////////// |
| 195 | |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 196 | /* |
| 197 | The text strike is specific to a given font/style/matrix setup, which is |
| 198 | represented by the GrHostFontScaler object we are given in getGlyph(). |
| 199 | |
| 200 | We map a 32bit glyphID to a GrGlyph record, which in turn points to a |
| 201 | atlas and a position within that texture. |
| 202 | */ |
| 203 | |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 204 | GrTextStrike::GrTextStrike(const SkDescriptor& key) |
bsalomon | c5fd5c4 | 2016-05-17 11:58:24 -0700 | [diff] [blame] | 205 | : fFontScalerKey(key) |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 206 | , fPool(9/*start allocations at 512 bytes*/) |
joshualitt | ae32c10 | 2015-04-21 09:37:57 -0700 | [diff] [blame] | 207 | , fAtlasedGlyphs(0) |
bsalomon | c5fd5c4 | 2016-05-17 11:58:24 -0700 | [diff] [blame] | 208 | , fIsAbandoned(false) {} |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 209 | |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 210 | GrTextStrike::~GrTextStrike() { |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 211 | SkTDynamicHash<GrGlyph, GrGlyph::PackedID>::Iter iter(&fCache); |
| 212 | while (!iter.done()) { |
mtklein | 852f15d | 2016-03-17 10:51:27 -0700 | [diff] [blame] | 213 | (*iter).reset(); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 214 | ++iter; |
| 215 | } |
| 216 | } |
| 217 | |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 218 | GrGlyph* GrTextStrike::generateGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed, |
| 219 | SkGlyphCache* cache) { |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 220 | SkIRect bounds; |
Jim Van Verth | d401da6 | 2018-05-03 10:40:30 -0400 | [diff] [blame] | 221 | if (!get_packed_glyph_bounds(cache, skGlyph, &bounds)) { |
| 222 | return nullptr; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 223 | } |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 224 | GrMaskFormat format = get_packed_glyph_mask_format(skGlyph); |
joshualitt | 6c2c2b0 | 2015-07-24 10:37:00 -0700 | [diff] [blame] | 225 | |
Herb Derby | 9428a37 | 2017-04-10 11:25:30 -0400 | [diff] [blame] | 226 | GrGlyph* glyph = fPool.make<GrGlyph>(); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 227 | glyph->init(packed, bounds, format); |
| 228 | fCache.add(glyph); |
| 229 | return glyph; |
| 230 | } |
| 231 | |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 232 | void GrTextStrike::removeID(GrDrawOpAtlas::AtlasID id) { |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 233 | SkTDynamicHash<GrGlyph, GrGlyph::PackedID>::Iter iter(&fCache); |
| 234 | while (!iter.done()) { |
| 235 | if (id == (*iter).fID) { |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 236 | (*iter).fID = GrDrawOpAtlas::kInvalidAtlasID; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 237 | fAtlasedGlyphs--; |
| 238 | SkASSERT(fAtlasedGlyphs >= 0); |
| 239 | } |
| 240 | ++iter; |
| 241 | } |
| 242 | } |
| 243 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 244 | GrDrawOpAtlas::ErrorCode GrTextStrike::addGlyphToAtlas( |
| 245 | GrResourceProvider* resourceProvider, |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 246 | GrDeferredUploadTarget* target, |
| 247 | GrGlyphCache* glyphCache, |
| 248 | GrAtlasManager* fullAtlasManager, |
| 249 | GrGlyph* glyph, |
| 250 | SkGlyphCache* cache, |
Jim Van Verth | cf838c7 | 2018-03-05 14:40:36 -0500 | [diff] [blame] | 251 | GrMaskFormat expectedMaskFormat, |
| 252 | bool isScaledGlyph) { |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 253 | SkASSERT(glyph); |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 254 | SkASSERT(cache); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 255 | SkASSERT(fCache.find(glyph->fPackedID)); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 256 | |
Timothy Liang | 91e260f | 2018-06-15 13:28:35 -0400 | [diff] [blame] | 257 | expectedMaskFormat = fullAtlasManager->resolveMaskFormat(expectedMaskFormat); |
joshualitt | 4f19ca3 | 2015-07-30 07:59:20 -0700 | [diff] [blame] | 258 | int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat); |
Jim Van Verth | cf838c7 | 2018-03-05 14:40:36 -0500 | [diff] [blame] | 259 | int width = glyph->width(); |
| 260 | int height = glyph->height(); |
| 261 | int rowBytes = width * bytesPerPixel; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 262 | |
| 263 | size_t size = glyph->fBounds.area() * bytesPerPixel; |
Jim Van Verth | cf838c7 | 2018-03-05 14:40:36 -0500 | [diff] [blame] | 264 | bool isSDFGlyph = GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedID); |
| 265 | bool addPad = isScaledGlyph && !isSDFGlyph; |
| 266 | if (addPad) { |
| 267 | width += 2; |
| 268 | rowBytes += 2*bytesPerPixel; |
| 269 | size += 2 * rowBytes; |
| 270 | height += 2; |
| 271 | size += 2 * (height + 2) * bytesPerPixel; |
| 272 | } |
joshualitt | 29f8679 | 2015-05-29 08:06:48 -0700 | [diff] [blame] | 273 | SkAutoSMalloc<1024> storage(size); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 274 | |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 275 | const SkGlyph& skGlyph = GrToSkGlyph(cache, glyph->fPackedID); |
Jim Van Verth | d401da6 | 2018-05-03 10:40:30 -0400 | [diff] [blame] | 276 | void* dataPtr = storage.get(); |
| 277 | if (addPad) { |
| 278 | sk_bzero(dataPtr, size); |
| 279 | dataPtr = (char*)(dataPtr) + rowBytes + bytesPerPixel; |
| 280 | } |
| 281 | if (!get_packed_glyph_image(cache, skGlyph, glyph->width(), glyph->height(), |
| 282 | rowBytes, expectedMaskFormat, |
Timothy Liang | 91e260f | 2018-06-15 13:28:35 -0400 | [diff] [blame] | 283 | dataPtr, glyphCache->getMasks())) { |
Jim Van Verth | d401da6 | 2018-05-03 10:40:30 -0400 | [diff] [blame] | 284 | return GrDrawOpAtlas::ErrorCode::kError; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 287 | GrDrawOpAtlas::ErrorCode result = fullAtlasManager->addToAtlas( |
| 288 | resourceProvider, glyphCache, this, |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 289 | &glyph->fID, target, expectedMaskFormat, |
Jim Van Verth | cf838c7 | 2018-03-05 14:40:36 -0500 | [diff] [blame] | 290 | width, height, |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 291 | storage.get(), &glyph->fAtlasLocation); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 292 | if (GrDrawOpAtlas::ErrorCode::kSucceeded == result) { |
Jim Van Verth | cf838c7 | 2018-03-05 14:40:36 -0500 | [diff] [blame] | 293 | if (addPad) { |
| 294 | glyph->fAtlasLocation.fX += 1; |
| 295 | glyph->fAtlasLocation.fY += 1; |
| 296 | } |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 297 | SkASSERT(GrDrawOpAtlas::kInvalidAtlasID != glyph->fID); |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 298 | fAtlasedGlyphs++; |
| 299 | } |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 300 | return result; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 301 | } |