joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [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 | |
| 8 | #include "GrAtlasTextBatch.h" |
| 9 | |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 10 | #include "GrBatchFlushState.h" |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 11 | #include "GrResourceProvider.h" |
| 12 | |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 13 | #include "SkGlyphCache.h" |
halcanary | 4dbbd04 | 2016-06-07 17:21:10 -0700 | [diff] [blame] | 14 | #include "SkMathPriv.h" |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 15 | |
| 16 | #include "effects/GrBitmapTextGeoProc.h" |
| 17 | #include "effects/GrDistanceFieldGeoProc.h" |
joshualitt | e804292 | 2015-12-11 06:11:21 -0800 | [diff] [blame] | 18 | #include "text/GrBatchFontCache.h" |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 19 | |
joshualitt | 60ce86d | 2015-11-23 13:08:22 -0800 | [diff] [blame] | 20 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 21 | |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 22 | static inline GrColor skcolor_to_grcolor_nopremultiply(SkColor c) { |
| 23 | unsigned r = SkColorGetR(c); |
| 24 | unsigned g = SkColorGetG(c); |
| 25 | unsigned b = SkColorGetB(c); |
| 26 | return GrColorPackRGBA(r, g, b, 0xff); |
| 27 | } |
| 28 | |
| 29 | static const int kDistanceAdjustLumShift = 5; |
| 30 | |
| 31 | SkString GrAtlasTextBatch::dumpInfo() const { |
| 32 | SkString str; |
| 33 | |
| 34 | for (int i = 0; i < fGeoCount; ++i) { |
| 35 | str.appendf("%d: Color: 0x%08x Trans: %.2f,%.2f Runs: %d\n", |
| 36 | i, |
| 37 | fGeoData[i].fColor, |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 38 | fGeoData[i].fX, |
| 39 | fGeoData[i].fY, |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 40 | fGeoData[i].fBlob->runCount()); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 41 | } |
| 42 | |
Brian Salomon | 7c3e718 | 2016-12-01 09:35:30 -0500 | [diff] [blame^] | 43 | str.append(DumpPipelineInfo(*this->pipeline())); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 44 | str.append(INHERITED::dumpInfo()); |
| 45 | return str; |
| 46 | } |
| 47 | |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 48 | void GrAtlasTextBatch::computePipelineOptimizations(GrInitInvariantOutput* color, |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 49 | GrInitInvariantOutput* coverage, |
| 50 | GrBatchToXPOverrides* overrides) const { |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 51 | if (kColorBitmapMask_MaskType == fMaskType) { |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 52 | color->setUnknownFourComponents(); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 53 | } else { |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 54 | color->setKnownFourComponents(fBatch.fColor); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 55 | } |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 56 | switch (fMaskType) { |
| 57 | case kGrayscaleDistanceField_MaskType: |
| 58 | case kGrayscaleCoverageMask_MaskType: |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 59 | coverage->setUnknownSingleComponent(); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 60 | break; |
| 61 | case kLCDCoverageMask_MaskType: |
| 62 | case kLCDDistanceField_MaskType: |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 63 | coverage->setUnknownOpaqueFourComponents(); |
| 64 | coverage->setUsingLCDCoverage(); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 65 | break; |
| 66 | case kColorBitmapMask_MaskType: |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 67 | coverage->setKnownSingleComponent(0xff); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 71 | void GrAtlasTextBatch::initBatchTracker(const GrXPOverridesForBatch& overrides) { |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 72 | // Handle any color overrides |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 73 | if (!overrides.readsColor()) { |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 74 | fGeoData[0].fColor = GrColor_ILLEGAL; |
| 75 | } |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 76 | overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 77 | |
| 78 | // setup batch properties |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 79 | fBatch.fColorIgnored = !overrides.readsColor(); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 80 | fBatch.fColor = fGeoData[0].fColor; |
ethannicholas | ff21032 | 2015-11-24 12:10:10 -0800 | [diff] [blame] | 81 | fBatch.fUsesLocalCoords = overrides.readsLocalCoords(); |
| 82 | fBatch.fCoverageIgnored = !overrides.readsCoverage(); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 83 | } |
| 84 | |
joshualitt | 144c3c8 | 2015-11-30 12:30:13 -0800 | [diff] [blame] | 85 | void GrAtlasTextBatch::onPrepareDraws(Target* target) const { |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 86 | // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix. |
| 87 | // TODO actually only invert if we don't have RGBA |
| 88 | SkMatrix localMatrix; |
| 89 | if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) { |
| 90 | SkDebugf("Cannot invert viewmatrix\n"); |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | GrTexture* texture = fFontCache->getTexture(this->maskFormat()); |
| 95 | if (!texture) { |
| 96 | SkDebugf("Could not allocate backing texture for atlas\n"); |
| 97 | return; |
| 98 | } |
| 99 | |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 100 | GrMaskFormat maskFormat = this->maskFormat(); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 101 | |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 102 | FlushInfo flushInfo; |
joshualitt | d9d30f7 | 2015-12-08 10:47:55 -0800 | [diff] [blame] | 103 | if (this->usesDistanceFields()) { |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 104 | flushInfo.fGeometryProcessor = |
| 105 | this->setupDfProcessor(this->viewMatrix(), fFilteredColor, this->color(), texture); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 106 | } else { |
Brian Salomon | 514baff | 2016-11-17 15:17:07 -0500 | [diff] [blame] | 107 | GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode); |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 108 | flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(this->color(), |
| 109 | texture, |
| 110 | params, |
| 111 | maskFormat, |
| 112 | localMatrix, |
| 113 | this->usesLocalCoords()); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 114 | } |
| 115 | |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 116 | flushInfo.fGlyphsToFlush = 0; |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 117 | size_t vertexStride = flushInfo.fGeometryProcessor->getVertexStride(); |
joshualitt | f528e0d | 2015-12-09 06:42:52 -0800 | [diff] [blame] | 118 | SkASSERT(vertexStride == GrAtlasTextBlob::GetVertexStride(maskFormat)); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 119 | |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 120 | int glyphCount = this->numGlyphs(); |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 121 | const GrBuffer* vertexBuffer; |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 122 | |
| 123 | void* vertices = target->makeVertexSpace(vertexStride, |
| 124 | glyphCount * kVerticesPerGlyph, |
| 125 | &vertexBuffer, |
| 126 | &flushInfo.fVertexOffset); |
| 127 | flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer)); |
| 128 | flushInfo.fIndexBuffer.reset(target->resourceProvider()->refQuadIndexBuffer()); |
| 129 | if (!vertices || !flushInfo.fVertexBuffer) { |
| 130 | SkDebugf("Could not allocate vertices\n"); |
| 131 | return; |
| 132 | } |
| 133 | |
| 134 | unsigned char* currVertex = reinterpret_cast<unsigned char*>(vertices); |
| 135 | |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 136 | GrBlobRegenHelper helper(this, target, &flushInfo); |
bsalomon | d1c71fd | 2016-05-19 12:51:46 -0700 | [diff] [blame] | 137 | SkAutoGlyphCache glyphCache; |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 138 | for (int i = 0; i < fGeoCount; i++) { |
joshualitt | 144c3c8 | 2015-11-30 12:30:13 -0800 | [diff] [blame] | 139 | const Geometry& args = fGeoData[i]; |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 140 | Blob* blob = args.fBlob; |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 141 | size_t byteCount; |
| 142 | void* blobVertices; |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 143 | int subRunGlyphCount; |
bsalomon | d1c71fd | 2016-05-19 12:51:46 -0700 | [diff] [blame] | 144 | blob->regenInBatch(target, fFontCache, &helper, args.fRun, args.fSubRun, &glyphCache, |
| 145 | vertexStride, args.fViewMatrix, args.fX, args.fY, args.fColor, |
| 146 | &blobVertices, &byteCount, &subRunGlyphCount); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 147 | |
| 148 | // now copy all vertices |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 149 | memcpy(currVertex, blobVertices, byteCount); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 150 | |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 151 | #ifdef SK_DEBUG |
| 152 | // bounds sanity check |
| 153 | SkRect rect; |
| 154 | rect.setLargestInverted(); |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 155 | SkPoint* vertex = (SkPoint*) ((char*)blobVertices); |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 156 | rect.growToInclude(vertex, vertexStride, kVerticesPerGlyph * subRunGlyphCount); |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 157 | |
| 158 | if (this->usesDistanceFields()) { |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 159 | args.fViewMatrix.mapRect(&rect); |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 160 | } |
bsalomon | 33b6b8e | 2016-04-13 08:14:22 -0700 | [diff] [blame] | 161 | // Allow for small numerical error in the bounds. |
bsalomon | 88cf17d | 2016-07-08 06:40:56 -0700 | [diff] [blame] | 162 | SkRect bounds = this->bounds(); |
bsalomon | 33b6b8e | 2016-04-13 08:14:22 -0700 | [diff] [blame] | 163 | bounds.outset(0.001f, 0.001f); |
| 164 | SkASSERT(bounds.contains(rect)); |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 165 | #endif |
| 166 | |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 167 | currVertex += byteCount; |
| 168 | } |
joshualitt | 60ce86d | 2015-11-23 13:08:22 -0800 | [diff] [blame] | 169 | |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 170 | this->flush(target, &flushInfo); |
| 171 | } |
| 172 | |
joshualitt | 144c3c8 | 2015-11-30 12:30:13 -0800 | [diff] [blame] | 173 | void GrAtlasTextBatch::flush(GrVertexBatch::Target* target, FlushInfo* flushInfo) const { |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 174 | GrMesh mesh; |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 175 | int maxGlyphsPerDraw = |
| 176 | static_cast<int>(flushInfo->fIndexBuffer->gpuMemorySize() / sizeof(uint16_t) / 6); |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 177 | mesh.initInstanced(kTriangles_GrPrimitiveType, flushInfo->fVertexBuffer.get(), |
| 178 | flushInfo->fIndexBuffer.get(), flushInfo->fVertexOffset, |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 179 | kVerticesPerGlyph, kIndicesPerGlyph, flushInfo->fGlyphsToFlush, |
| 180 | maxGlyphsPerDraw); |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 181 | target->draw(flushInfo->fGeometryProcessor.get(), mesh); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 182 | flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush; |
| 183 | flushInfo->fGlyphsToFlush = 0; |
| 184 | } |
| 185 | |
| 186 | bool GrAtlasTextBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { |
| 187 | GrAtlasTextBatch* that = t->cast<GrAtlasTextBatch>(); |
| 188 | if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(), |
| 189 | that->bounds(), caps)) { |
| 190 | return false; |
| 191 | } |
| 192 | |
| 193 | if (fMaskType != that->fMaskType) { |
| 194 | return false; |
| 195 | } |
| 196 | |
| 197 | if (!this->usesDistanceFields()) { |
joshualitt | d9d30f7 | 2015-12-08 10:47:55 -0800 | [diff] [blame] | 198 | if (kColorBitmapMask_MaskType == fMaskType && this->color() != that->color()) { |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 199 | return false; |
| 200 | } |
| 201 | if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
| 202 | return false; |
| 203 | } |
| 204 | } else { |
| 205 | if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) { |
| 206 | return false; |
| 207 | } |
| 208 | |
| 209 | if (fFilteredColor != that->fFilteredColor) { |
| 210 | return false; |
| 211 | } |
| 212 | |
| 213 | if (fUseBGR != that->fUseBGR) { |
| 214 | return false; |
| 215 | } |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | fBatch.fNumGlyphs += that->numGlyphs(); |
| 219 | |
| 220 | // Reallocate space for geo data if necessary and then import that's geo data. |
| 221 | int newGeoCount = that->fGeoCount + fGeoCount; |
| 222 | // We assume (and here enforce) that the allocation size is the smallest power of two that |
| 223 | // is greater than or equal to the number of geometries (and at least |
| 224 | // kMinGeometryAllocated). |
| 225 | int newAllocSize = GrNextPow2(newGeoCount); |
| 226 | int currAllocSize = SkTMax<int>(kMinGeometryAllocated, GrNextPow2(fGeoCount)); |
| 227 | |
| 228 | if (newGeoCount > currAllocSize) { |
| 229 | fGeoData.realloc(newAllocSize); |
| 230 | } |
| 231 | |
| 232 | memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * sizeof(Geometry)); |
| 233 | // We steal the ref on the blobs from the other TextBatch and set its count to 0 so that |
| 234 | // it doesn't try to unref them. |
| 235 | #ifdef SK_DEBUG |
| 236 | for (int i = 0; i < that->fGeoCount; ++i) { |
| 237 | that->fGeoData.get()[i].fBlob = (Blob*)0x1; |
| 238 | } |
| 239 | #endif |
| 240 | that->fGeoCount = 0; |
| 241 | fGeoCount = newGeoCount; |
| 242 | |
bsalomon | 88cf17d | 2016-07-08 06:40:56 -0700 | [diff] [blame] | 243 | this->joinBounds(*that); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 244 | return true; |
| 245 | } |
| 246 | |
| 247 | // TODO just use class params |
| 248 | // TODO trying to figure out why lcd is so whack |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 249 | sk_sp<GrGeometryProcessor> GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatrix, |
| 250 | SkColor filteredColor, |
| 251 | GrColor color, |
| 252 | GrTexture* texture) const { |
Brian Salomon | 514baff | 2016-11-17 15:17:07 -0500 | [diff] [blame] | 253 | GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kBilerp_FilterMode); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 254 | bool isLCD = this->isLCD(); |
| 255 | // set up any flags |
| 256 | uint32_t flags = viewMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0; |
jvanverth | cf371bb | 2016-03-10 11:10:43 -0800 | [diff] [blame] | 257 | flags |= viewMatrix.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0; |
brianosman | b461d34 | 2016-04-13 13:10:14 -0700 | [diff] [blame] | 258 | flags |= fUseGammaCorrectDistanceTable ? kGammaCorrect_DistanceFieldEffectFlag : 0; |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 259 | |
| 260 | // see if we need to create a new effect |
| 261 | if (isLCD) { |
| 262 | flags |= kUseLCD_DistanceFieldEffectFlag; |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 263 | flags |= fUseBGR ? kBGR_DistanceFieldEffectFlag : 0; |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 264 | |
| 265 | GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor); |
| 266 | |
brianosman | 0586f5c | 2016-04-12 12:48:21 -0700 | [diff] [blame] | 267 | float redCorrection = fDistanceAdjustTable->getAdjustment( |
brianosman | b461d34 | 2016-04-13 13:10:14 -0700 | [diff] [blame] | 268 | GrColorUnpackR(colorNoPreMul) >> kDistanceAdjustLumShift, |
| 269 | fUseGammaCorrectDistanceTable); |
brianosman | 0586f5c | 2016-04-12 12:48:21 -0700 | [diff] [blame] | 270 | float greenCorrection = fDistanceAdjustTable->getAdjustment( |
brianosman | b461d34 | 2016-04-13 13:10:14 -0700 | [diff] [blame] | 271 | GrColorUnpackG(colorNoPreMul) >> kDistanceAdjustLumShift, |
| 272 | fUseGammaCorrectDistanceTable); |
brianosman | 0586f5c | 2016-04-12 12:48:21 -0700 | [diff] [blame] | 273 | float blueCorrection = fDistanceAdjustTable->getAdjustment( |
brianosman | b461d34 | 2016-04-13 13:10:14 -0700 | [diff] [blame] | 274 | GrColorUnpackB(colorNoPreMul) >> kDistanceAdjustLumShift, |
| 275 | fUseGammaCorrectDistanceTable); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 276 | GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust = |
| 277 | GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrection, |
| 278 | greenCorrection, |
| 279 | blueCorrection); |
| 280 | |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 281 | return GrDistanceFieldLCDTextGeoProc::Make(color, |
| 282 | viewMatrix, |
| 283 | texture, |
| 284 | params, |
| 285 | widthAdjust, |
| 286 | flags, |
| 287 | this->usesLocalCoords()); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 288 | } else { |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 289 | #ifdef SK_GAMMA_APPLY_TO_A8 |
| 290 | U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, filteredColor); |
brianosman | 0586f5c | 2016-04-12 12:48:21 -0700 | [diff] [blame] | 291 | float correction = fDistanceAdjustTable->getAdjustment( |
brianosman | b461d34 | 2016-04-13 13:10:14 -0700 | [diff] [blame] | 292 | lum >> kDistanceAdjustLumShift, fUseGammaCorrectDistanceTable); |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 293 | return GrDistanceFieldA8TextGeoProc::Make(color, |
| 294 | viewMatrix, |
| 295 | texture, |
| 296 | params, |
| 297 | correction, |
| 298 | flags, |
| 299 | this->usesLocalCoords()); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 300 | #else |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 301 | return GrDistanceFieldA8TextGeoProc::Make(color, |
| 302 | viewMatrix, |
| 303 | texture, |
| 304 | params, |
| 305 | flags, |
| 306 | this->usesLocalCoords()); |
joshualitt | a751c97 | 2015-11-20 13:37:32 -0800 | [diff] [blame] | 307 | #endif |
| 308 | } |
| 309 | |
| 310 | } |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 311 | |
| 312 | void GrBlobRegenHelper::flush() { |
| 313 | fBatch->flush(fTarget, fFlushInfo); |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 314 | } |