Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 "GrAtlasManager.h" |
Herb Derby | 8624059 | 2018-05-24 16:12:31 -0400 | [diff] [blame] | 9 | #include "GrTextBlob.h" |
Herb Derby | c1b482c | 2018-08-09 15:02:27 -0400 | [diff] [blame] | 10 | #include "GrTextTarget.h" |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 11 | #include "SkDistanceFieldGen.h" |
| 12 | #include "SkGlyphCache.h" |
| 13 | #include "ops/GrAtlasTextOp.h" |
| 14 | |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 15 | enum RegenMask { |
| 16 | kNoRegen = 0x0, |
| 17 | kRegenPos = 0x1, |
| 18 | kRegenCol = 0x2, |
| 19 | kRegenTex = 0x4, |
| 20 | kRegenGlyph = 0x8 | kRegenTex, // we have to regenerate the texture coords when we regen glyphs |
| 21 | |
| 22 | // combinations |
| 23 | kRegenPosCol = kRegenPos | kRegenCol, |
| 24 | kRegenPosTex = kRegenPos | kRegenTex, |
| 25 | kRegenPosTexGlyph = kRegenPos | kRegenGlyph, |
| 26 | kRegenPosColTex = kRegenPos | kRegenCol | kRegenTex, |
| 27 | kRegenPosColTexGlyph = kRegenPos | kRegenCol | kRegenGlyph, |
| 28 | kRegenColTex = kRegenCol | kRegenTex, |
| 29 | kRegenColTexGlyph = kRegenCol | kRegenGlyph, |
| 30 | }; |
| 31 | |
| 32 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 33 | // A large template to handle regenerating the vertices of a textblob with as few branches as |
| 34 | // possible |
| 35 | template <bool regenPos, bool regenCol, bool regenTexCoords> |
| 36 | inline void regen_vertices(char* vertex, const GrGlyph* glyph, size_t vertexStride, |
| 37 | bool useDistanceFields, SkScalar transX, SkScalar transY, |
| 38 | GrColor color) { |
| 39 | uint16_t u0, v0, u1, v1; |
Jim Van Verth | fc4f768 | 2018-01-25 16:26:25 -0500 | [diff] [blame] | 40 | #ifdef DISPLAY_PAGE_INDEX |
| 41 | // Enable this to visualize the page from which each glyph is being drawn. |
| 42 | // Green Red Magenta Cyan -> 0 1 2 3; Black -> error |
| 43 | SkColor hackColor; |
| 44 | #endif |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 45 | if (regenTexCoords) { |
| 46 | SkASSERT(glyph); |
| 47 | int width = glyph->fBounds.width(); |
| 48 | int height = glyph->fBounds.height(); |
| 49 | |
| 50 | if (useDistanceFields) { |
| 51 | u0 = glyph->fAtlasLocation.fX + SK_DistanceFieldInset; |
| 52 | v0 = glyph->fAtlasLocation.fY + SK_DistanceFieldInset; |
| 53 | u1 = u0 + width - 2 * SK_DistanceFieldInset; |
| 54 | v1 = v0 + height - 2 * SK_DistanceFieldInset; |
| 55 | } else { |
| 56 | u0 = glyph->fAtlasLocation.fX; |
| 57 | v0 = glyph->fAtlasLocation.fY; |
| 58 | u1 = u0 + width; |
| 59 | v1 = v0 + height; |
| 60 | } |
| 61 | // We pack the 2bit page index in the low bit of the u and v texture coords |
| 62 | uint32_t pageIndex = glyph->pageIndex(); |
| 63 | SkASSERT(pageIndex < 4); |
| 64 | uint16_t uBit = (pageIndex >> 1) & 0x1; |
| 65 | uint16_t vBit = pageIndex & 0x1; |
| 66 | u0 <<= 1; |
| 67 | u0 |= uBit; |
| 68 | v0 <<= 1; |
| 69 | v0 |= vBit; |
| 70 | u1 <<= 1; |
| 71 | u1 |= uBit; |
| 72 | v1 <<= 1; |
| 73 | v1 |= vBit; |
Jim Van Verth | fc4f768 | 2018-01-25 16:26:25 -0500 | [diff] [blame] | 74 | #ifdef DISPLAY_PAGE_INDEX |
| 75 | switch (pageIndex) { |
| 76 | case 0: |
| 77 | hackColor = SK_ColorGREEN; |
| 78 | break; |
| 79 | case 1: |
| 80 | hackColor = SK_ColorRED; |
| 81 | break; |
| 82 | case 2: |
| 83 | hackColor = SK_ColorMAGENTA; |
| 84 | break; |
| 85 | case 3: |
| 86 | hackColor = SK_ColorCYAN; |
| 87 | break; |
| 88 | default: |
| 89 | hackColor = SK_ColorBLACK; |
| 90 | break; |
| 91 | } |
| 92 | #endif |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | // This is a bit wonky, but sometimes we have LCD text, in which case we won't have color |
| 96 | // vertices, hence vertexStride - sizeof(SkIPoint16) |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 97 | intptr_t texCoordOffset = vertexStride - sizeof(SkIPoint16); |
Brian Salomon | 5c6ac64 | 2017-12-19 11:09:32 -0500 | [diff] [blame] | 98 | intptr_t colorOffset = texCoordOffset - sizeof(GrColor); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 99 | |
| 100 | // V0 |
| 101 | if (regenPos) { |
| 102 | SkPoint* point = reinterpret_cast<SkPoint*>(vertex); |
| 103 | point->fX += transX; |
| 104 | point->fY += transY; |
| 105 | } |
| 106 | |
| 107 | if (regenCol) { |
| 108 | SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); |
| 109 | *vcolor = color; |
| 110 | } |
| 111 | |
| 112 | if (regenTexCoords) { |
| 113 | uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); |
| 114 | textureCoords[0] = u0; |
| 115 | textureCoords[1] = v0; |
Jim Van Verth | fc4f768 | 2018-01-25 16:26:25 -0500 | [diff] [blame] | 116 | #ifdef DISPLAY_PAGE_INDEX |
| 117 | SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); |
| 118 | *vcolor = hackColor; |
| 119 | #endif |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 120 | } |
| 121 | vertex += vertexStride; |
| 122 | |
| 123 | // V1 |
| 124 | if (regenPos) { |
| 125 | SkPoint* point = reinterpret_cast<SkPoint*>(vertex); |
| 126 | point->fX += transX; |
| 127 | point->fY += transY; |
| 128 | } |
| 129 | |
| 130 | if (regenCol) { |
| 131 | SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); |
| 132 | *vcolor = color; |
| 133 | } |
| 134 | |
| 135 | if (regenTexCoords) { |
| 136 | uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); |
| 137 | textureCoords[0] = u0; |
| 138 | textureCoords[1] = v1; |
Jim Van Verth | fc4f768 | 2018-01-25 16:26:25 -0500 | [diff] [blame] | 139 | #ifdef DISPLAY_PAGE_INDEX |
| 140 | SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); |
| 141 | *vcolor = hackColor; |
| 142 | #endif |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 143 | } |
| 144 | vertex += vertexStride; |
| 145 | |
| 146 | // V2 |
| 147 | if (regenPos) { |
| 148 | SkPoint* point = reinterpret_cast<SkPoint*>(vertex); |
| 149 | point->fX += transX; |
| 150 | point->fY += transY; |
| 151 | } |
| 152 | |
| 153 | if (regenCol) { |
| 154 | SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); |
| 155 | *vcolor = color; |
| 156 | } |
| 157 | |
| 158 | if (regenTexCoords) { |
| 159 | uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); |
| 160 | textureCoords[0] = u1; |
| 161 | textureCoords[1] = v0; |
Jim Van Verth | fc4f768 | 2018-01-25 16:26:25 -0500 | [diff] [blame] | 162 | #ifdef DISPLAY_PAGE_INDEX |
| 163 | SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); |
| 164 | *vcolor = hackColor; |
| 165 | #endif |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 166 | } |
| 167 | vertex += vertexStride; |
| 168 | |
| 169 | // V3 |
| 170 | if (regenPos) { |
| 171 | SkPoint* point = reinterpret_cast<SkPoint*>(vertex); |
| 172 | point->fX += transX; |
| 173 | point->fY += transY; |
| 174 | } |
| 175 | |
| 176 | if (regenCol) { |
| 177 | SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); |
| 178 | *vcolor = color; |
| 179 | } |
| 180 | |
| 181 | if (regenTexCoords) { |
| 182 | uint16_t* textureCoords = reinterpret_cast<uint16_t*>(vertex + texCoordOffset); |
| 183 | textureCoords[0] = u1; |
| 184 | textureCoords[1] = v1; |
Jim Van Verth | fc4f768 | 2018-01-25 16:26:25 -0500 | [diff] [blame] | 185 | #ifdef DISPLAY_PAGE_INDEX |
| 186 | SkColor* vcolor = reinterpret_cast<SkColor*>(vertex + colorOffset); |
| 187 | *vcolor = hackColor; |
| 188 | #endif |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
Herb Derby | 6dff60e | 2018-11-12 15:45:49 -0500 | [diff] [blame] | 192 | GrTextBlob::VertexRegenerator::VertexRegenerator(GrResourceProvider* resourceProvider, |
| 193 | GrTextBlob* blob, |
| 194 | int runIdx, int subRunIdx, |
| 195 | const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
| 196 | GrColor color, |
| 197 | GrDeferredUploadTarget* uploadTarget, |
| 198 | GrGlyphCache* glyphCache, |
| 199 | GrAtlasManager* fullAtlasManager, |
| 200 | SkExclusiveStrikePtr* lazyCache) |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 201 | : fResourceProvider(resourceProvider) |
| 202 | , fViewMatrix(viewMatrix) |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 203 | , fBlob(blob) |
| 204 | , fUploadTarget(uploadTarget) |
| 205 | , fGlyphCache(glyphCache) |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 206 | , fFullAtlasManager(fullAtlasManager) |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 207 | , fLazyCache(lazyCache) |
| 208 | , fRun(&blob->fRuns[runIdx]) |
| 209 | , fSubRun(&blob->fRuns[runIdx].fSubRunInfo[subRunIdx]) |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 210 | , fColor(color) { |
| 211 | // Compute translation if any |
| 212 | fSubRun->computeTranslation(fViewMatrix, x, y, &fTransX, &fTransY); |
| 213 | |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 214 | // Because the GrGlyphCache may evict the strike a blob depends on using for |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 215 | // generating its texture coords, we have to track whether or not the strike has |
| 216 | // been abandoned. If it hasn't been abandoned, then we can use the GrGlyph*s as is |
| 217 | // otherwise we have to get the new strike, and use that to get the correct glyphs. |
| 218 | // Because we do not have the packed ids, and thus can't look up our glyphs in the |
| 219 | // new strike, we instead keep our ref to the old strike and use the packed ids from |
| 220 | // it. These ids will still be valid as long as we hold the ref. When we are done |
| 221 | // updating our cache of the GrGlyph*s, we drop our ref on the old strike |
| 222 | if (fSubRun->strike()->isAbandoned()) { |
| 223 | fRegenFlags |= kRegenGlyph; |
| 224 | fRegenFlags |= kRegenTex; |
| 225 | } |
| 226 | if (kARGB_GrMaskFormat != fSubRun->maskFormat() && fSubRun->color() != color) { |
| 227 | fRegenFlags |= kRegenCol; |
| 228 | } |
| 229 | if (0.f != fTransX || 0.f != fTransY) { |
| 230 | fRegenFlags |= kRegenPos; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyphs> |
Herb Derby | 6dff60e | 2018-11-12 15:45:49 -0500 | [diff] [blame] | 235 | bool GrTextBlob::VertexRegenerator::doRegen(GrTextBlob::VertexRegenerator::Result* result) { |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 236 | static_assert(!regenGlyphs || regenTexCoords, "must regenTexCoords along regenGlyphs"); |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 237 | sk_sp<GrTextStrike> strike; |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 238 | if (regenTexCoords) { |
| 239 | fSubRun->resetBulkUseToken(); |
| 240 | |
Herb Derby | 317adf7 | 2018-11-16 17:29:29 -0500 | [diff] [blame] | 241 | const SkDescriptor* desc = fSubRun->desc(); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 242 | |
| 243 | if (!*fLazyCache || (*fLazyCache)->getDescriptor() != *desc) { |
| 244 | SkScalerContextEffects effects; |
| 245 | effects.fPathEffect = fRun->fPathEffect.get(); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 246 | effects.fMaskFilter = fRun->fMaskFilter.get(); |
Herb Derby | 8c4cbf4 | 2018-03-09 15:28:04 -0500 | [diff] [blame] | 247 | *fLazyCache = |
Herb Derby | fa99690 | 2018-04-18 11:36:12 -0400 | [diff] [blame] | 248 | SkStrikeCache::FindOrCreateStrikeExclusive(*desc, effects, *fRun->fTypeface); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | if (regenGlyphs) { |
| 252 | strike = fGlyphCache->getStrike(fLazyCache->get()); |
| 253 | } else { |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 254 | strike = fSubRun->refStrike(); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 255 | } |
| 256 | } |
| 257 | |
Brian Salomon | 5c6ac64 | 2017-12-19 11:09:32 -0500 | [diff] [blame] | 258 | bool hasW = fSubRun->hasWCoord(); |
Brian Salomon | 5c6ac64 | 2017-12-19 11:09:32 -0500 | [diff] [blame] | 259 | auto vertexStride = GetVertexStride(fSubRun->maskFormat(), hasW); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 260 | char* currVertex = fBlob->fVertices + fSubRun->vertexStartIndex() + |
Brian Salomon | deb53cc | 2017-11-08 13:50:53 -0500 | [diff] [blame] | 261 | fCurrGlyph * kVerticesPerGlyph * vertexStride; |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 262 | result->fFirstVertex = currVertex; |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 263 | |
| 264 | for (int glyphIdx = fCurrGlyph; glyphIdx < (int)fSubRun->glyphCount(); glyphIdx++) { |
| 265 | GrGlyph* glyph = nullptr; |
| 266 | if (regenTexCoords) { |
| 267 | size_t glyphOffset = glyphIdx + fSubRun->glyphStartIndex(); |
| 268 | |
| 269 | if (regenGlyphs) { |
| 270 | // Get the id from the old glyph, and use the new strike to lookup |
| 271 | // the glyph. |
| 272 | GrGlyph::PackedID id = fBlob->fGlyphs[glyphOffset]->fPackedID; |
| 273 | fBlob->fGlyphs[glyphOffset] = |
| 274 | strike->getGlyph(id, fSubRun->maskFormat(), fLazyCache->get()); |
| 275 | SkASSERT(id == fBlob->fGlyphs[glyphOffset]->fPackedID); |
| 276 | } |
| 277 | glyph = fBlob->fGlyphs[glyphOffset]; |
| 278 | SkASSERT(glyph && glyph->fMaskFormat == fSubRun->maskFormat()); |
| 279 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 280 | if (!fFullAtlasManager->hasGlyph(glyph)) { |
| 281 | GrDrawOpAtlas::ErrorCode code; |
| 282 | code = strike->addGlyphToAtlas(fResourceProvider, fUploadTarget, fGlyphCache, |
| 283 | fFullAtlasManager, glyph, |
| 284 | fLazyCache->get(), fSubRun->maskFormat(), |
Jim Van Verth | b515ae7 | 2018-05-23 16:44:55 -0400 | [diff] [blame] | 285 | fSubRun->needsTransform()); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 286 | if (GrDrawOpAtlas::ErrorCode::kError == code) { |
| 287 | // Something horrible has happened - drop the op |
| 288 | return false; |
| 289 | } |
| 290 | else if (GrDrawOpAtlas::ErrorCode::kTryAgain == code) { |
| 291 | fBrokenRun = glyphIdx > 0; |
| 292 | result->fFinished = false; |
| 293 | return true; |
| 294 | } |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 295 | } |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 296 | auto tokenTracker = fUploadTarget->tokenTracker(); |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 297 | fFullAtlasManager->addGlyphToBulkAndSetUseToken(fSubRun->bulkUseToken(), glyph, |
| 298 | tokenTracker->nextDrawToken()); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 299 | } |
| 300 | |
Brian Salomon | deb53cc | 2017-11-08 13:50:53 -0500 | [diff] [blame] | 301 | regen_vertices<regenPos, regenCol, regenTexCoords>(currVertex, glyph, vertexStride, |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 302 | fSubRun->drawAsDistanceFields(), fTransX, |
| 303 | fTransY, fColor); |
Brian Salomon | deb53cc | 2017-11-08 13:50:53 -0500 | [diff] [blame] | 304 | currVertex += vertexStride * GrAtlasTextOp::kVerticesPerGlyph; |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 305 | ++result->fGlyphsRegenerated; |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 306 | ++fCurrGlyph; |
| 307 | } |
| 308 | |
| 309 | // We may have changed the color so update it here |
| 310 | fSubRun->setColor(fColor); |
| 311 | if (regenTexCoords) { |
| 312 | if (regenGlyphs) { |
Robert Phillips | caf1ebb | 2018-03-01 14:28:44 -0500 | [diff] [blame] | 313 | fSubRun->setStrike(std::move(strike)); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 314 | } |
| 315 | fSubRun->setAtlasGeneration(fBrokenRun |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 316 | ? GrDrawOpAtlas::kInvalidAtlasGeneration |
| 317 | : fFullAtlasManager->atlasGeneration(fSubRun->maskFormat())); |
Jim Van Verth | ba98b7d | 2018-12-05 12:33:43 -0500 | [diff] [blame] | 318 | } else { |
| 319 | // For the non-texCoords case we need to ensure that we update the associated use tokens |
| 320 | fFullAtlasManager->setUseTokenBulk(*fSubRun->bulkUseToken(), |
| 321 | fUploadTarget->tokenTracker()->nextDrawToken(), |
| 322 | fSubRun->maskFormat()); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 323 | } |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 324 | return true; |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 325 | } |
| 326 | |
Herb Derby | 6dff60e | 2018-11-12 15:45:49 -0500 | [diff] [blame] | 327 | bool GrTextBlob::VertexRegenerator::regenerate(GrTextBlob::VertexRegenerator::Result* result) { |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 328 | uint64_t currentAtlasGen = fFullAtlasManager->atlasGeneration(fSubRun->maskFormat()); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 329 | // If regenerate() is called multiple times then the atlas gen may have changed. So we check |
| 330 | // this each time. |
| 331 | if (fSubRun->atlasGeneration() != currentAtlasGen) { |
| 332 | fRegenFlags |= kRegenTex; |
| 333 | } |
| 334 | |
| 335 | switch (static_cast<RegenMask>(fRegenFlags)) { |
| 336 | case kRegenPos: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 337 | return this->doRegen<true, false, false, false>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 338 | case kRegenCol: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 339 | return this->doRegen<false, true, false, false>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 340 | case kRegenTex: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 341 | return this->doRegen<false, false, true, false>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 342 | case kRegenGlyph: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 343 | return this->doRegen<false, false, true, true>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 344 | |
| 345 | // combinations |
| 346 | case kRegenPosCol: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 347 | return this->doRegen<true, true, false, false>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 348 | case kRegenPosTex: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 349 | return this->doRegen<true, false, true, false>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 350 | case kRegenPosTexGlyph: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 351 | return this->doRegen<true, false, true, true>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 352 | case kRegenPosColTex: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 353 | return this->doRegen<true, true, true, false>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 354 | case kRegenPosColTexGlyph: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 355 | return this->doRegen<true, true, true, true>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 356 | case kRegenColTex: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 357 | return this->doRegen<false, true, true, false>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 358 | case kRegenColTexGlyph: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 359 | return this->doRegen<false, true, true, true>(result); |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 360 | case kNoRegen: { |
Brian Salomon | 5c6ac64 | 2017-12-19 11:09:32 -0500 | [diff] [blame] | 361 | bool hasW = fSubRun->hasWCoord(); |
| 362 | auto vertexStride = GetVertexStride(fSubRun->maskFormat(), hasW); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 363 | result->fFinished = true; |
| 364 | result->fGlyphsRegenerated = fSubRun->glyphCount() - fCurrGlyph; |
| 365 | result->fFirstVertex = fBlob->fVertices + fSubRun->vertexStartIndex() + |
| 366 | fCurrGlyph * kVerticesPerGlyph * vertexStride; |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 367 | fCurrGlyph = fSubRun->glyphCount(); |
| 368 | |
| 369 | // set use tokens for all of the glyphs in our subrun. This is only valid if we |
| 370 | // have a valid atlas generation |
Robert Phillips | c4039ea | 2018-03-01 11:36:45 -0500 | [diff] [blame] | 371 | fFullAtlasManager->setUseTokenBulk(*fSubRun->bulkUseToken(), |
| 372 | fUploadTarget->tokenTracker()->nextDrawToken(), |
| 373 | fSubRun->maskFormat()); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 374 | return true; |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 375 | } |
| 376 | } |
| 377 | SK_ABORT("Should not get here"); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 378 | return false; |
Brian Salomon | 18923f9 | 2017-11-06 16:26:02 -0500 | [diff] [blame] | 379 | } |