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