blob: 0de7319ea2ca410ecfbd31afa5589a46c8369368 [file] [log] [blame]
joshualitta751c972015-11-20 13:37:32 -08001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/gpu/ops/GrAtlasTextOp.h"
Robert Phillipse4fda6c2018-02-21 12:10:41 -05009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkPoint3.h"
11#include "include/private/GrRecordingContext.h"
12#include "src/core/SkMathPriv.h"
13#include "src/core/SkMatrixPriv.h"
14#include "src/core/SkStrikeCache.h"
15#include "src/gpu/GrCaps.h"
16#include "src/gpu/GrMemoryPool.h"
17#include "src/gpu/GrOpFlushState.h"
18#include "src/gpu/GrRecordingContextPriv.h"
19#include "src/gpu/GrResourceProvider.h"
20#include "src/gpu/effects/GrBitmapTextGeoProc.h"
21#include "src/gpu/effects/GrDistanceFieldGeoProc.h"
Robert Phillips3968fcb2019-12-05 16:40:31 -050022#include "src/gpu/ops/GrSimpleMeshDrawOpHelper.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050023#include "src/gpu/text/GrAtlasManager.h"
Robert Phillips841c9a52020-03-27 12:41:31 -040024#include "src/gpu/text/GrDistanceFieldAdjustTable.h"
joshualitta751c972015-11-20 13:37:32 -080025
joshualitt60ce86d2015-11-23 13:08:22 -080026///////////////////////////////////////////////////////////////////////////////////////////////////
27
Robert Phillipsb97da532019-02-12 15:24:12 -050028std::unique_ptr<GrAtlasTextOp> GrAtlasTextOp::MakeBitmap(GrRecordingContext* context,
Robert Phillips7c525e62018-06-12 10:11:12 -040029 GrPaint&& paint,
30 GrMaskFormat maskFormat,
31 int glyphCount,
32 bool needsTransform) {
Robert Phillips9da87e02019-02-04 13:26:26 -050033 GrOpMemoryPool* pool = context->priv().opMemoryPool();
Robert Phillipsc994a932018-06-19 13:09:54 -040034
35 std::unique_ptr<GrAtlasTextOp> op = pool->allocate<GrAtlasTextOp>(std::move(paint));
Robert Phillips7c525e62018-06-12 10:11:12 -040036
37 switch (maskFormat) {
38 case kA8_GrMaskFormat:
39 op->fMaskType = kGrayscaleCoverageMask_MaskType;
40 break;
41 case kA565_GrMaskFormat:
42 op->fMaskType = kLCDCoverageMask_MaskType;
43 break;
44 case kARGB_GrMaskFormat:
45 op->fMaskType = kColorBitmapMask_MaskType;
46 break;
47 }
48 op->fNumGlyphs = glyphCount;
49 op->fGeoCount = 1;
50 op->fLuminanceColor = 0;
51 op->fNeedsGlyphTransform = needsTransform;
52 return op;
53 }
54
55std::unique_ptr<GrAtlasTextOp> GrAtlasTextOp::MakeDistanceField(
Robert Phillipsb97da532019-02-12 15:24:12 -050056 GrRecordingContext* context,
Robert Phillips7c525e62018-06-12 10:11:12 -040057 GrPaint&& paint,
58 int glyphCount,
Robert Phillips7c525e62018-06-12 10:11:12 -040059 bool useGammaCorrectDistanceTable,
60 SkColor luminanceColor,
61 const SkSurfaceProps& props,
62 bool isAntiAliased,
63 bool useLCD) {
Robert Phillips9da87e02019-02-04 13:26:26 -050064 GrOpMemoryPool* pool = context->priv().opMemoryPool();
Robert Phillipsc994a932018-06-19 13:09:54 -040065
66 std::unique_ptr<GrAtlasTextOp> op = pool->allocate<GrAtlasTextOp>(std::move(paint));
Robert Phillips7c525e62018-06-12 10:11:12 -040067
68 bool isBGR = SkPixelGeometryIsBGR(props.pixelGeometry());
69 bool isLCD = useLCD && SkPixelGeometryIsH(props.pixelGeometry());
70 op->fMaskType = !isAntiAliased ? kAliasedDistanceField_MaskType
71 : isLCD ? (isBGR ? kLCDBGRDistanceField_MaskType
72 : kLCDDistanceField_MaskType)
73 : kGrayscaleDistanceField_MaskType;
Robert Phillips7c525e62018-06-12 10:11:12 -040074 op->fUseGammaCorrectDistanceTable = useGammaCorrectDistanceTable;
75 op->fLuminanceColor = luminanceColor;
76 op->fNumGlyphs = glyphCount;
77 op->fGeoCount = 1;
78 return op;
79 }
80
joshualitta751c972015-11-20 13:37:32 -080081static const int kDistanceAdjustLumShift = 5;
82
Brian Salomon5c6ac642017-12-19 11:09:32 -050083void GrAtlasTextOp::init() {
84 const Geometry& geo = fGeoData[0];
Brian Salomon5c6ac642017-12-19 11:09:32 -050085 if (this->usesDistanceFields()) {
86 bool isLCD = this->isLCD();
87
Herb Derby1c5be7b2019-12-13 12:03:06 -050088 const SkMatrix& drawMatrix = geo.fDrawMatrix;
Brian Salomon5c6ac642017-12-19 11:09:32 -050089
Herb Derby1c5be7b2019-12-13 12:03:06 -050090 fDFGPFlags = drawMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
91 fDFGPFlags |= drawMatrix.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0;
92 fDFGPFlags |= drawMatrix.hasPerspective() ? kPerspective_DistanceFieldEffectFlag : 0;
Brian Salomon5c6ac642017-12-19 11:09:32 -050093 fDFGPFlags |= fUseGammaCorrectDistanceTable ? kGammaCorrect_DistanceFieldEffectFlag : 0;
94 fDFGPFlags |= (kAliasedDistanceField_MaskType == fMaskType)
95 ? kAliased_DistanceFieldEffectFlag
96 : 0;
97
98 if (isLCD) {
99 fDFGPFlags |= kUseLCD_DistanceFieldEffectFlag;
100 fDFGPFlags |=
101 (kLCDBGRDistanceField_MaskType == fMaskType) ? kBGR_DistanceFieldEffectFlag : 0;
102 }
Jim Van Verthb515ae72018-05-23 16:44:55 -0400103
104 fNeedsGlyphTransform = true;
Brian Salomon5c6ac642017-12-19 11:09:32 -0500105 }
Jim Van Verth70276912018-06-01 13:46:46 -0400106
107 SkRect bounds;
Herb Derby5bf5b042019-12-12 16:37:03 -0500108 geo.fBlob->computeSubRunBounds(
109 &bounds, *geo.fSubRunPtr, geo.fDrawMatrix, geo.fDrawOrigin, fNeedsGlyphTransform);
Jim Van Verth70276912018-06-01 13:46:46 -0400110 // We don't have tight bounds on the glyph paths in device space. For the purposes of bounds
111 // we treat this as a set of non-AA rects rendered with a texture.
Greg Daniel5faf4742019-10-01 15:14:44 -0400112 this->setBounds(bounds, HasAABloat::kNo, IsHairline::kNo);
Brian Salomon5c6ac642017-12-19 11:09:32 -0500113}
114
Chris Dalton1706cbf2019-05-21 19:35:29 -0600115void GrAtlasTextOp::visitProxies(const VisitProxyFunc& func) const {
Robert Phillipse4fda6c2018-02-21 12:10:41 -0500116 fProcessors.visitProxies(func);
Robert Phillipse4fda6c2018-02-21 12:10:41 -0500117}
118
Brian Osman9a390ac2018-11-12 09:47:48 -0500119#ifdef SK_DEBUG
Brian Salomon344ec422016-12-15 10:58:41 -0500120SkString GrAtlasTextOp::dumpInfo() const {
joshualitta751c972015-11-20 13:37:32 -0800121 SkString str;
122
123 for (int i = 0; i < fGeoCount; ++i) {
Herb Derby1b8dcd12019-11-15 15:21:15 -0500124 str.appendf("%d: Color: 0x%08x Trans: %.2f,%.2f\n",
joshualitta751c972015-11-20 13:37:32 -0800125 i,
Brian Osmancf860852018-10-31 14:04:39 -0400126 fGeoData[i].fColor.toBytes_RGBA(),
Herb Derby5bf5b042019-12-12 16:37:03 -0500127 fGeoData[i].fDrawOrigin.x(),
128 fGeoData[i].fDrawOrigin.y());
joshualitta751c972015-11-20 13:37:32 -0800129 }
130
Brian Salomon44acb5b2017-07-18 19:59:24 -0400131 str += fProcessors.dumpProcessors();
132 str += INHERITED::dumpInfo();
joshualitta751c972015-11-20 13:37:32 -0800133 return str;
134}
Brian Osman9a390ac2018-11-12 09:47:48 -0500135#endif
joshualitta751c972015-11-20 13:37:32 -0800136
Brian Salomon44acb5b2017-07-18 19:59:24 -0400137GrDrawOp::FixedFunctionFlags GrAtlasTextOp::fixedFunctionFlags() const {
138 return FixedFunctionFlags::kNone;
139}
140
Chris Dalton6ce447a2019-06-23 18:07:38 -0600141GrProcessorSet::Analysis GrAtlasTextOp::finalize(
142 const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage,
143 GrClampType clampType) {
Brian Salomon44acb5b2017-07-18 19:59:24 -0400144 GrProcessorAnalysisCoverage coverage;
145 GrProcessorAnalysisColor color;
joshualitta751c972015-11-20 13:37:32 -0800146 if (kColorBitmapMask_MaskType == fMaskType) {
Brian Salomon44acb5b2017-07-18 19:59:24 -0400147 color.setToUnknown();
joshualitta751c972015-11-20 13:37:32 -0800148 } else {
Brian Osman09068252018-01-03 09:57:29 -0500149 color.setToConstant(this->color());
joshualitta751c972015-11-20 13:37:32 -0800150 }
joshualitta751c972015-11-20 13:37:32 -0800151 switch (fMaskType) {
joshualitta751c972015-11-20 13:37:32 -0800152 case kGrayscaleCoverageMask_MaskType:
Jim Van Verth90e89b32017-07-06 16:36:55 -0400153 case kAliasedDistanceField_MaskType:
154 case kGrayscaleDistanceField_MaskType:
Brian Salomon44acb5b2017-07-18 19:59:24 -0400155 coverage = GrProcessorAnalysisCoverage::kSingleChannel;
joshualitta751c972015-11-20 13:37:32 -0800156 break;
157 case kLCDCoverageMask_MaskType:
158 case kLCDDistanceField_MaskType:
Jim Van Verth90e89b32017-07-06 16:36:55 -0400159 case kLCDBGRDistanceField_MaskType:
Brian Salomon44acb5b2017-07-18 19:59:24 -0400160 coverage = GrProcessorAnalysisCoverage::kLCD;
joshualitta751c972015-11-20 13:37:32 -0800161 break;
162 case kColorBitmapMask_MaskType:
Brian Salomon44acb5b2017-07-18 19:59:24 -0400163 coverage = GrProcessorAnalysisCoverage::kNone;
Brian Salomonc0b642c2017-03-27 13:09:36 -0400164 break;
joshualitta751c972015-11-20 13:37:32 -0800165 }
Chris Daltonb8fff0d2019-03-05 10:11:58 -0700166 auto analysis = fProcessors.finalize(
Chris Dalton6ce447a2019-06-23 18:07:38 -0600167 color, coverage, clip, &GrUserStencilSettings::kUnused, hasMixedSampledCoverage, caps,
168 clampType, &fGeoData[0].fColor);
Brian Salomon44acb5b2017-07-18 19:59:24 -0400169 fUsesLocalCoords = analysis.usesLocalCoords();
Chris Dalton4b62aed2019-01-15 11:53:00 -0700170 return analysis;
joshualitta751c972015-11-20 13:37:32 -0800171}
172
Brian Salomon18923f92017-11-06 16:26:02 -0500173static void clip_quads(const SkIRect& clipRect, char* currVertex, const char* blobVertices,
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400174 size_t vertexStride, int glyphCount) {
175 for (int i = 0; i < glyphCount; ++i) {
Brian Salomon18923f92017-11-06 16:26:02 -0500176 const SkPoint* blobPositionLT = reinterpret_cast<const SkPoint*>(blobVertices);
177 const SkPoint* blobPositionRB =
178 reinterpret_cast<const SkPoint*>(blobVertices + 3 * vertexStride);
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400179
Jim Van Verth328a33f2017-10-20 12:14:22 -0400180 // positions for bitmap glyphs are pixel boundary aligned
Brian Osman7ca90d22017-11-10 15:31:27 -0500181 SkIRect positionRect = SkIRect::MakeLTRB(SkScalarRoundToInt(blobPositionLT->fX),
182 SkScalarRoundToInt(blobPositionLT->fY),
183 SkScalarRoundToInt(blobPositionRB->fX),
184 SkScalarRoundToInt(blobPositionRB->fY));
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400185 if (clipRect.contains(positionRect)) {
186 memcpy(currVertex, blobVertices, 4 * vertexStride);
187 currVertex += 4 * vertexStride;
188 } else {
189 // Pull out some more data that we'll need.
190 // In the LCD case the color will be garbage, but we'll overwrite it with the texcoords
191 // and it avoids a lot of conditionals.
Brian Salomon18923f92017-11-06 16:26:02 -0500192 auto color = *reinterpret_cast<const SkColor*>(blobVertices + sizeof(SkPoint));
Jim Van Verth2f2c77a2020-01-24 15:48:23 +0000193 size_t coordOffset = vertexStride - 2*sizeof(uint16_t);
194 auto* blobCoordsLT = reinterpret_cast<const uint16_t*>(blobVertices + coordOffset);
195 auto* blobCoordsRB = reinterpret_cast<const uint16_t*>(blobVertices + 3 * vertexStride +
Brian Salomon18923f92017-11-06 16:26:02 -0500196 coordOffset);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400197 // Pull out the texel coordinates and texture index bits
Jim Van Verthfb395102020-02-03 10:11:19 -0500198 uint16_t coordsRectL = blobCoordsLT[0];
199 uint16_t coordsRectT = blobCoordsLT[1];
200 uint16_t coordsRectR = blobCoordsRB[0];
201 uint16_t coordsRectB = blobCoordsRB[1];
202 int index0, index1;
203 std::tie(coordsRectL, coordsRectT, index0) =
204 GrDrawOpAtlas::UnpackIndexFromTexCoords(coordsRectL, coordsRectT);
205 std::tie(coordsRectR, coordsRectB, index1) =
206 GrDrawOpAtlas::UnpackIndexFromTexCoords(coordsRectR, coordsRectB);
207 SkASSERT(index0 == index1);
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400208
Jim Van Verth328a33f2017-10-20 12:14:22 -0400209 int positionRectWidth = positionRect.width();
210 int positionRectHeight = positionRect.height();
211 SkASSERT(positionRectWidth == (coordsRectR - coordsRectL));
212 SkASSERT(positionRectHeight == (coordsRectB - coordsRectT));
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400213
214 // Clip position and texCoords to the clipRect
Jim Van Verth328a33f2017-10-20 12:14:22 -0400215 unsigned int delta;
Brian Osman788b9162020-02-07 10:36:46 -0500216 delta = std::min(std::max(clipRect.fLeft - positionRect.fLeft, 0), positionRectWidth);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400217 coordsRectL += delta;
218 positionRect.fLeft += delta;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400219
Brian Osman788b9162020-02-07 10:36:46 -0500220 delta = std::min(std::max(clipRect.fTop - positionRect.fTop, 0), positionRectHeight);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400221 coordsRectT += delta;
222 positionRect.fTop += delta;
223
Brian Osman788b9162020-02-07 10:36:46 -0500224 delta = std::min(std::max(positionRect.fRight - clipRect.fRight, 0), positionRectWidth);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400225 coordsRectR -= delta;
226 positionRect.fRight -= delta;
227
Brian Osman788b9162020-02-07 10:36:46 -0500228 delta = std::min(std::max(positionRect.fBottom - clipRect.fBottom, 0), positionRectHeight);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400229 coordsRectB -= delta;
230 positionRect.fBottom -= delta;
231
232 // Repack texel coordinates and index
Jim Van Verthfb395102020-02-03 10:11:19 -0500233 std::tie(coordsRectL, coordsRectT) =
234 GrDrawOpAtlas::PackIndexInTexCoords(coordsRectL, coordsRectT, index0);
235 std::tie(coordsRectR, coordsRectB) =
236 GrDrawOpAtlas::PackIndexInTexCoords(coordsRectR, coordsRectB, index1);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400237
238 // Set new positions and coords
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400239 SkPoint* currPosition = reinterpret_cast<SkPoint*>(currVertex);
240 currPosition->fX = positionRect.fLeft;
241 currPosition->fY = positionRect.fTop;
242 *(reinterpret_cast<SkColor*>(currVertex + sizeof(SkPoint))) = color;
Jim Van Verth328a33f2017-10-20 12:14:22 -0400243 uint16_t* currCoords = reinterpret_cast<uint16_t*>(currVertex + coordOffset);
244 currCoords[0] = coordsRectL;
245 currCoords[1] = coordsRectT;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400246 currVertex += vertexStride;
247
248 currPosition = reinterpret_cast<SkPoint*>(currVertex);
249 currPosition->fX = positionRect.fLeft;
250 currPosition->fY = positionRect.fBottom;
251 *(reinterpret_cast<SkColor*>(currVertex + sizeof(SkPoint))) = color;
Jim Van Verth328a33f2017-10-20 12:14:22 -0400252 currCoords = reinterpret_cast<uint16_t*>(currVertex + coordOffset);
253 currCoords[0] = coordsRectL;
254 currCoords[1] = coordsRectB;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400255 currVertex += vertexStride;
256
257 currPosition = reinterpret_cast<SkPoint*>(currVertex);
258 currPosition->fX = positionRect.fRight;
259 currPosition->fY = positionRect.fTop;
260 *(reinterpret_cast<SkColor*>(currVertex + sizeof(SkPoint))) = color;
Jim Van Verth328a33f2017-10-20 12:14:22 -0400261 currCoords = reinterpret_cast<uint16_t*>(currVertex + coordOffset);
262 currCoords[0] = coordsRectR;
263 currCoords[1] = coordsRectT;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400264 currVertex += vertexStride;
265
266 currPosition = reinterpret_cast<SkPoint*>(currVertex);
267 currPosition->fX = positionRect.fRight;
268 currPosition->fY = positionRect.fBottom;
269 *(reinterpret_cast<SkColor*>(currVertex + sizeof(SkPoint))) = color;
Jim Van Verth328a33f2017-10-20 12:14:22 -0400270 currCoords = reinterpret_cast<uint16_t*>(currVertex + coordOffset);
271 currCoords[0] = coordsRectR;
272 currCoords[1] = coordsRectB;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400273 currVertex += vertexStride;
274 }
275
276 blobVertices += 4 * vertexStride;
277 }
278}
279
Brian Salomon91326c32017-08-09 16:02:19 -0400280void GrAtlasTextOp::onPrepareDraws(Target* target) {
Robert Phillips4bc70112018-03-01 10:24:02 -0500281 auto resourceProvider = target->resourceProvider();
282
joshualitta751c972015-11-20 13:37:32 -0800283 // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix.
284 // TODO actually only invert if we don't have RGBA
285 SkMatrix localMatrix;
Herb Derby1c5be7b2019-12-13 12:03:06 -0500286 if (this->usesLocalCoords() && !fGeoData[0].fDrawMatrix.invert(&localMatrix)) {
joshualitta751c972015-11-20 13:37:32 -0800287 return;
288 }
289
Robert Phillips5a66efb2018-03-07 15:13:18 -0500290 GrAtlasManager* atlasManager = target->atlasManager();
Mike Klein99e002f2020-01-16 16:45:03 +0000291
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400292 GrMaskFormat maskFormat = this->maskFormat();
293
Greg Daniel9715b6c2019-12-10 15:03:10 -0500294 unsigned int numActiveViews;
295 const GrSurfaceProxyView* views = atlasManager->getViews(maskFormat, &numActiveViews);
296 if (!views) {
joshualitta751c972015-11-20 13:37:32 -0800297 SkDebugf("Could not allocate backing texture for atlas\n");
298 return;
299 }
Greg Daniel9715b6c2019-12-10 15:03:10 -0500300 SkASSERT(views[0].proxy());
joshualitta751c972015-11-20 13:37:32 -0800301
Brian Salomon7eae3e02018-08-07 14:02:38 +0000302 static constexpr int kMaxTextures = GrBitmapTextGeoProc::kMaxTextures;
Brian Salomon4dea72a2019-12-18 10:43:10 -0500303 static_assert(GrDistanceFieldA8TextGeoProc::kMaxTextures == kMaxTextures);
304 static_assert(GrDistanceFieldLCDTextGeoProc::kMaxTextures == kMaxTextures);
Brian Salomon7eae3e02018-08-07 14:02:38 +0000305
Chris Dalton304e14d2020-03-17 14:29:06 -0600306 auto primProcProxies = target->allocPrimProcProxyPtrs(kMaxTextures);
Greg Daniel9715b6c2019-12-10 15:03:10 -0500307 for (unsigned i = 0; i < numActiveViews; ++i) {
Chris Dalton304e14d2020-03-17 14:29:06 -0600308 primProcProxies[i] = views[i].proxy();
Greg Danielb20d7e52019-09-03 13:54:39 -0400309 // This op does not know its atlas proxies when it is added to a GrOpsTasks, so the proxies
310 // don't get added during the visitProxies call. Thus we add them here.
Greg Daniel9715b6c2019-12-10 15:03:10 -0500311 target->sampledProxyArray()->push_back(views[i].proxy());
Brian Salomon7eae3e02018-08-07 14:02:38 +0000312 }
Brian Salomon49348902018-06-26 09:12:38 -0400313
314 FlushInfo flushInfo;
Chris Dalton304e14d2020-03-17 14:29:06 -0600315 flushInfo.fPrimProcProxies = primProcProxies;
Brian Salomon49348902018-06-26 09:12:38 -0400316
Herb Derby1c5be7b2019-12-13 12:03:06 -0500317 bool vmPerspective = fGeoData[0].fDrawMatrix.hasPerspective();
joshualittd9d30f72015-12-08 10:47:55 -0800318 if (this->usesDistanceFields()) {
Robert Phillips7cd0bfe2019-11-20 16:08:10 -0500319 flushInfo.fGeometryProcessor = this->setupDfProcessor(target->allocator(),
320 *target->caps().shaderCaps(),
Greg Daniel9715b6c2019-12-10 15:03:10 -0500321 views, numActiveViews);
joshualitta751c972015-11-20 13:37:32 -0800322 } else {
Brian Salomonccb61422020-01-09 10:46:36 -0500323 auto filter = fNeedsGlyphTransform ? GrSamplerState::Filter::kBilerp
324 : GrSamplerState::Filter::kNearest;
325 flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
326 target->allocator(), *target->caps().shaderCaps(), this->color(), false, views,
327 numActiveViews, filter, maskFormat, localMatrix, vmPerspective);
joshualitta751c972015-11-20 13:37:32 -0800328 }
329
Herb Derby23f29762020-01-10 16:26:14 -0500330 int vertexStride = (int)flushInfo.fGeometryProcessor->vertexStride();
joshualitta751c972015-11-20 13:37:32 -0800331
Brian Salomon43cbd722020-01-03 22:09:12 -0500332 // Ensure we don't request an insanely large contiguous vertex allocation.
Herb Derby23f29762020-01-10 16:26:14 -0500333 static const int kMaxVertexBytes = GrBufferAllocPool::kDefaultBufferSize;
334 const int quadSize = vertexStride * kVerticesPerGlyph;
335 const int maxQuadsPerBuffer = kMaxVertexBytes / quadSize;
336
337 // Where the quad buffer begins and ends relative to totalGlyphsRegened.
338 int quadBufferBegin = 0;
339 int quadBufferEnd = std::min(this->numGlyphs(), maxQuadsPerBuffer);
340
Robert Phillipsee08d522019-10-28 16:34:44 -0400341 flushInfo.fIndexBuffer = resourceProvider->refNonAAQuadIndexBuffer();
Herb Derby23f29762020-01-10 16:26:14 -0500342 void* vertices = target->makeVertexSpace(
343 vertexStride,
344 kVerticesPerGlyph * (quadBufferEnd - quadBufferBegin),
345 &flushInfo.fVertexBuffer,
346 &flushInfo.fVertexOffset);
joshualitta751c972015-11-20 13:37:32 -0800347 if (!vertices || !flushInfo.fVertexBuffer) {
348 SkDebugf("Could not allocate vertices\n");
349 return;
350 }
351
Herb Derby23f29762020-01-10 16:26:14 -0500352 // totalGlyphsRegened is all the glyphs for the op [0, this->numGlyphs()). The subRun glyph and
353 // quad buffer indices are calculated from this.
354 int totalGlyphsRegened = 0;
joshualitta751c972015-11-20 13:37:32 -0800355 for (int i = 0; i < fGeoCount; i++) {
joshualitt144c3c82015-11-30 12:30:13 -0800356 const Geometry& args = fGeoData[i];
Herb Derby23f29762020-01-10 16:26:14 -0500357 auto subRun = args.fSubRunPtr;
358 SkASSERT((int)subRun->vertexStride() == vertexStride);
359
Robert Phillips297a2192020-04-08 15:26:54 -0400360 subRun->prepareGrGlyphs(target->glyphCache());
Herb Derby62b12fe2020-01-14 17:57:24 -0500361 subRun->updateVerticesColorIfNeeded(args.fColor.toBytes_RGBA());
362 subRun->translateVerticesIfNeeded(args.fDrawMatrix, args.fDrawOrigin);
363
Brian Osman1be2b7c2018-10-29 16:07:15 -0400364 // TODO4F: Preserve float colors
Robert Phillips297a2192020-04-08 15:26:54 -0400365 GrTextBlob::VertexRegenerator regenerator(resourceProvider, subRun,
366 target->deferredUploadTarget(), atlasManager);
Herb Derby23f29762020-01-10 16:26:14 -0500367
368 // Where the subRun begins and ends relative to totalGlyphsRegened.
369 int subRunBegin = totalGlyphsRegened;
Robert Phillips1576e4e2020-04-01 12:49:45 -0400370 int subRunEnd = subRunBegin + subRun->fGlyphs.count();
Herb Derby23f29762020-01-10 16:26:14 -0500371
372 // Draw all the glyphs in the subRun.
373 while (totalGlyphsRegened < subRunEnd) {
374 // drawBegin and drawEnd are indices for the subRun on the
375 // interval [0, subRun->fGlyphs.size()).
376 int drawBegin = totalGlyphsRegened - subRunBegin;
377 // drawEnd is either the end of the subRun or the end of the current quad buffer.
378 int drawEnd = std::min(subRunEnd, quadBufferEnd) - subRunBegin;
379 auto[ok, glyphsRegenerated] = regenerator.regenerate(drawBegin, drawEnd);
380
381 // There was a problem allocating the glyph in the atlas. Bail.
Robert Phillips1576e4e2020-04-01 12:49:45 -0400382 if (!ok) {
383 return;
384 }
Herb Derby23f29762020-01-10 16:26:14 -0500385
386 // Update all the vertices for glyphsRegenerate glyphs.
387 if (glyphsRegenerated > 0) {
388 int quadBufferIndex = totalGlyphsRegened - quadBufferBegin;
389 int subRunIndex = totalGlyphsRegened - subRunBegin;
390 auto regeneratedQuadBuffer =
391 SkTAddOffset<char>(vertices, subRun->quadOffset(quadBufferIndex));
Brian Salomon43cbd722020-01-03 22:09:12 -0500392 if (args.fClipRect.isEmpty()) {
Herb Derby23f29762020-01-10 16:26:14 -0500393 memcpy(regeneratedQuadBuffer,
394 subRun->quadStart(subRunIndex),
395 glyphsRegenerated * quadSize);
Brian Salomon43cbd722020-01-03 22:09:12 -0500396 } else {
397 SkASSERT(!vmPerspective);
Herb Derby23f29762020-01-10 16:26:14 -0500398 clip_quads(args.fClipRect,
399 regeneratedQuadBuffer,
400 subRun->quadStart(subRunIndex),
401 vertexStride,
402 glyphsRegenerated);
Brian Salomon43cbd722020-01-03 22:09:12 -0500403 }
404 if (fNeedsGlyphTransform && !args.fDrawMatrix.isIdentity()) {
405 // We always do the distance field view matrix transformation after copying
406 // rather than during blob vertex generation time in the blob as handling
407 // successive arbitrary transformations would be complicated and accumulate
408 // error.
409 if (args.fDrawMatrix.hasPerspective()) {
Herb Derby23f29762020-01-10 16:26:14 -0500410 auto* pos = reinterpret_cast<SkPoint3*>(regeneratedQuadBuffer);
411 SkMatrixPriv::MapHomogeneousPointsWithStride(
412 args.fDrawMatrix, pos,
413 vertexStride, pos,
414 vertexStride,
415 glyphsRegenerated * kVerticesPerGlyph);
Brian Salomon43cbd722020-01-03 22:09:12 -0500416 } else {
Herb Derby23f29762020-01-10 16:26:14 -0500417 auto* pos = reinterpret_cast<SkPoint*>(regeneratedQuadBuffer);
Brian Salomon43cbd722020-01-03 22:09:12 -0500418 SkMatrixPriv::MapPointsWithStride(args.fDrawMatrix, pos, vertexStride,
Herb Derby23f29762020-01-10 16:26:14 -0500419 glyphsRegenerated * kVerticesPerGlyph);
Brian Salomon43cbd722020-01-03 22:09:12 -0500420 }
421 }
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500422 }
Herb Derby23f29762020-01-10 16:26:14 -0500423
424 totalGlyphsRegened += glyphsRegenerated;
425 flushInfo.fGlyphsToFlush += glyphsRegenerated;
426
427 // regenerate() has stopped part way through a SubRun. This means that either the atlas
428 // or the quad buffer is full or both. There is a case were the flow through
429 // the loop is strange. If we run out of quad buffer space at the same time the
430 // SubRun ends, then this is not triggered which is the right result for the last
431 // SubRun. But, if this is not the last SubRun, then advance to the next SubRun which
432 // will process no glyphs, and return to this point where the quad buffer will be
433 // expanded.
434 if (totalGlyphsRegened != subRunEnd) {
435 // Flush if not all glyphs drawn because either the quad buffer is full or the
436 // atlas is out of space.
Herb Derby4513cdd2020-01-31 13:28:49 -0500437 this->createDrawForGeneratedGlyphs(target, &flushInfo);
Herb Derby23f29762020-01-10 16:26:14 -0500438 if (totalGlyphsRegened == quadBufferEnd) {
439 // Quad buffer is full. Get more buffer.
440 quadBufferBegin = totalGlyphsRegened;
441 int quadBufferSize =
442 std::min(maxQuadsPerBuffer, this->numGlyphs() - totalGlyphsRegened);
443 quadBufferEnd = quadBufferBegin + quadBufferSize;
444
445 vertices = target->makeVertexSpace(
446 vertexStride,
447 kVerticesPerGlyph * quadBufferSize,
448 &flushInfo.fVertexBuffer,
449 &flushInfo.fVertexOffset);
450 if (!vertices || !flushInfo.fVertexBuffer) {
451 SkDebugf("Could not allocate vertices\n");
452 return;
453 }
454 }
455 }
456 }
Herb Derby5f6f8512020-01-10 12:50:35 -0500457 } // for all geometries
Herb Derby4513cdd2020-01-31 13:28:49 -0500458 this->createDrawForGeneratedGlyphs(target, &flushInfo);
joshualitta751c972015-11-20 13:37:32 -0800459}
460
Chris Dalton07cdcfc92019-02-26 11:13:22 -0700461void GrAtlasTextOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
Robert Phillips3968fcb2019-12-05 16:40:31 -0500462 auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
463 std::move(fProcessors),
464 GrPipeline::InputFlags::kNone);
465
466 flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
Chris Dalton07cdcfc92019-02-26 11:13:22 -0700467}
468
Herb Derby4513cdd2020-01-31 13:28:49 -0500469void GrAtlasTextOp::createDrawForGeneratedGlyphs(
470 GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const {
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500471 if (!flushInfo->fGlyphsToFlush) {
472 return;
473 }
474
Robert Phillips5a66efb2018-03-07 15:13:18 -0500475 auto atlasManager = target->atlasManager();
Robert Phillipsc4039ea2018-03-01 11:36:45 -0500476
Robert Phillips7cd0bfe2019-11-20 16:08:10 -0500477 GrGeometryProcessor* gp = flushInfo->fGeometryProcessor;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400478 GrMaskFormat maskFormat = this->maskFormat();
Robert Phillipsf3690dd2018-02-20 15:18:59 -0500479
Greg Daniel9715b6c2019-12-10 15:03:10 -0500480 unsigned int numActiveViews;
481 const GrSurfaceProxyView* views = atlasManager->getViews(maskFormat, &numActiveViews);
482 SkASSERT(views);
Jim Van Verth9f2516f2019-11-22 14:58:37 -0500483 // Something has gone terribly wrong, bail
Greg Daniel9715b6c2019-12-10 15:03:10 -0500484 if (!views || 0 == numActiveViews) {
Jim Van Verth9f2516f2019-11-22 14:58:37 -0500485 return;
486 }
Greg Daniel9715b6c2019-12-10 15:03:10 -0500487 if (gp->numTextureSamplers() != (int) numActiveViews) {
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400488 // During preparation the number of atlas pages has increased.
489 // Update the proxies used in the GP to match.
Greg Daniel9715b6c2019-12-10 15:03:10 -0500490 for (unsigned i = gp->numTextureSamplers(); i < numActiveViews; ++i) {
Chris Dalton304e14d2020-03-17 14:29:06 -0600491 flushInfo->fPrimProcProxies[i] = views[i].proxy();
Greg Danielb20d7e52019-09-03 13:54:39 -0400492 // This op does not know its atlas proxies when it is added to a GrOpsTasks, so the
493 // proxies don't get added during the visitProxies call. Thus we add them here.
Greg Daniel9715b6c2019-12-10 15:03:10 -0500494 target->sampledProxyArray()->push_back(views[i].proxy());
Brian Salomon43cbd722020-01-03 22:09:12 -0500495 // These will get unreffed when the previously recorded draws destruct.
496 for (int d = 0; d < flushInfo->fNumDraws; ++d) {
Chris Dalton304e14d2020-03-17 14:29:06 -0600497 flushInfo->fPrimProcProxies[i]->ref();
Brian Salomon43cbd722020-01-03 22:09:12 -0500498 }
Brian Salomon7eae3e02018-08-07 14:02:38 +0000499 }
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400500 if (this->usesDistanceFields()) {
501 if (this->isLCD()) {
Greg Daniel9715b6c2019-12-10 15:03:10 -0500502 reinterpret_cast<GrDistanceFieldLCDTextGeoProc*>(gp)->addNewViews(
Brian Salomonccb61422020-01-09 10:46:36 -0500503 views, numActiveViews, GrSamplerState::Filter::kBilerp);
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400504 } else {
Greg Daniel9715b6c2019-12-10 15:03:10 -0500505 reinterpret_cast<GrDistanceFieldA8TextGeoProc*>(gp)->addNewViews(
Brian Salomonccb61422020-01-09 10:46:36 -0500506 views, numActiveViews, GrSamplerState::Filter::kBilerp);
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400507 }
508 } else {
Brian Salomonccb61422020-01-09 10:46:36 -0500509 auto filter = fNeedsGlyphTransform ? GrSamplerState::Filter::kBilerp
510 : GrSamplerState::Filter::kNearest;
511 reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewViews(views, numActiveViews, filter);
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400512 }
513 }
Brian Salomondbf70722019-02-07 11:31:24 -0500514 int maxGlyphsPerDraw = static_cast<int>(flushInfo->fIndexBuffer->size() / sizeof(uint16_t) / 6);
Chris Daltoneb694b72020-03-16 09:25:50 -0600515 GrSimpleMesh* mesh = target->allocMesh();
Chris Dalton37c7bdd2020-03-13 09:21:12 -0600516 mesh->setIndexedPatterned(flushInfo->fIndexBuffer, kIndicesPerGlyph, flushInfo->fGlyphsToFlush,
517 maxGlyphsPerDraw, flushInfo->fVertexBuffer, kVerticesPerGlyph,
518 flushInfo->fVertexOffset);
Chris Dalton304e14d2020-03-17 14:29:06 -0600519 target->recordDraw(flushInfo->fGeometryProcessor, mesh, 1, flushInfo->fPrimProcProxies,
Chris Dalton3bf2f3a2020-03-17 11:48:23 -0600520 GrPrimitiveType::kTriangles);
joshualitta751c972015-11-20 13:37:32 -0800521 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
522 flushInfo->fGlyphsToFlush = 0;
Brian Salomon43cbd722020-01-03 22:09:12 -0500523 ++flushInfo->fNumDraws;
joshualitta751c972015-11-20 13:37:32 -0800524}
525
Michael Ludwig28b0c5d2019-12-19 14:51:00 -0500526GrOp::CombineResult GrAtlasTextOp::onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*,
527 const GrCaps& caps) {
Brian Salomon344ec422016-12-15 10:58:41 -0500528 GrAtlasTextOp* that = t->cast<GrAtlasTextOp>();
Brian Salomon44acb5b2017-07-18 19:59:24 -0400529 if (fProcessors != that->fProcessors) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000530 return CombineResult::kCannotCombine;
Brian Salomon44acb5b2017-07-18 19:59:24 -0400531 }
532
joshualitta751c972015-11-20 13:37:32 -0800533 if (fMaskType != that->fMaskType) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000534 return CombineResult::kCannotCombine;
joshualitta751c972015-11-20 13:37:32 -0800535 }
536
Herb Derby1c5be7b2019-12-13 12:03:06 -0500537 const SkMatrix& thisFirstMatrix = fGeoData[0].fDrawMatrix;
538 const SkMatrix& thatFirstMatrix = that->fGeoData[0].fDrawMatrix;
Brian Salomon5c6ac642017-12-19 11:09:32 -0500539
Mike Reed2c383152019-12-18 16:47:47 -0500540 if (this->usesLocalCoords() && !SkMatrixPriv::CheapEqual(thisFirstMatrix, thatFirstMatrix)) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000541 return CombineResult::kCannotCombine;
Brian Salomon5c6ac642017-12-19 11:09:32 -0500542 }
543
Jim Van Verthb515ae72018-05-23 16:44:55 -0400544 if (fNeedsGlyphTransform != that->fNeedsGlyphTransform) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000545 return CombineResult::kCannotCombine;
Jim Van Verthb515ae72018-05-23 16:44:55 -0400546 }
547
548 if (fNeedsGlyphTransform &&
549 (thisFirstMatrix.hasPerspective() != thatFirstMatrix.hasPerspective())) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000550 return CombineResult::kCannotCombine;
Jim Van Verthb515ae72018-05-23 16:44:55 -0400551 }
552
Brian Salomon5c6ac642017-12-19 11:09:32 -0500553 if (this->usesDistanceFields()) {
554 if (fDFGPFlags != that->fDFGPFlags) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000555 return CombineResult::kCannotCombine;
joshualitta751c972015-11-20 13:37:32 -0800556 }
557
Jim Van Verthbc2cdd12017-06-08 11:14:35 -0400558 if (fLuminanceColor != that->fLuminanceColor) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000559 return CombineResult::kCannotCombine;
joshualitta751c972015-11-20 13:37:32 -0800560 }
Brian Salomon5c6ac642017-12-19 11:09:32 -0500561 } else {
562 if (kColorBitmapMask_MaskType == fMaskType && this->color() != that->color()) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000563 return CombineResult::kCannotCombine;
Brian Salomon5c6ac642017-12-19 11:09:32 -0500564 }
joshualitta751c972015-11-20 13:37:32 -0800565 }
566
Brian Salomon344ec422016-12-15 10:58:41 -0500567 fNumGlyphs += that->numGlyphs();
joshualitta751c972015-11-20 13:37:32 -0800568
Jim Van Verth56c37142017-10-31 14:44:25 -0400569 // Reallocate space for geo data if necessary and then import that geo's data.
joshualitta751c972015-11-20 13:37:32 -0800570 int newGeoCount = that->fGeoCount + fGeoCount;
joshualitta751c972015-11-20 13:37:32 -0800571
Jim Van Verthc8a65e32017-10-25 14:25:27 -0400572 // We reallocate at a rate of 1.5x to try to get better total memory usage
573 if (newGeoCount > fGeoDataAllocSize) {
Jim Van Verth56c37142017-10-31 14:44:25 -0400574 int newAllocSize = fGeoDataAllocSize + fGeoDataAllocSize / 2;
Jim Van Verthc8a65e32017-10-25 14:25:27 -0400575 while (newAllocSize < newGeoCount) {
576 newAllocSize += newAllocSize / 2;
577 }
joshualitta751c972015-11-20 13:37:32 -0800578 fGeoData.realloc(newAllocSize);
Jim Van Verthc8a65e32017-10-25 14:25:27 -0400579 fGeoDataAllocSize = newAllocSize;
joshualitta751c972015-11-20 13:37:32 -0800580 }
581
Brian Salomon344ec422016-12-15 10:58:41 -0500582 // We steal the ref on the blobs from the other AtlasTextOp and set its count to 0 so that
joshualitta751c972015-11-20 13:37:32 -0800583 // it doesn't try to unref them.
Brian Salomon344ec422016-12-15 10:58:41 -0500584 memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * sizeof(Geometry));
joshualitta751c972015-11-20 13:37:32 -0800585#ifdef SK_DEBUG
586 for (int i = 0; i < that->fGeoCount; ++i) {
Herb Derbyc514e7d2019-12-11 17:00:31 -0500587 that->fGeoData.get()[i].fBlob = (GrTextBlob*)0x1;
joshualitta751c972015-11-20 13:37:32 -0800588 }
589#endif
590 that->fGeoCount = 0;
591 fGeoCount = newGeoCount;
592
Brian Salomon7eae3e02018-08-07 14:02:38 +0000593 return CombineResult::kMerged;
joshualitta751c972015-11-20 13:37:32 -0800594}
595
joshualitta751c972015-11-20 13:37:32 -0800596// TODO trying to figure out why lcd is so whack
Herb Derby26cbe512018-05-24 14:39:01 -0400597// (see comments in GrTextContext::ComputeCanonicalColor)
Robert Phillips7cd0bfe2019-11-20 16:08:10 -0500598GrGeometryProcessor* GrAtlasTextOp::setupDfProcessor(SkArenaAlloc* arena,
599 const GrShaderCaps& caps,
Greg Daniel9715b6c2019-12-10 15:03:10 -0500600 const GrSurfaceProxyView* views,
601 unsigned int numActiveViews) const {
joshualitta751c972015-11-20 13:37:32 -0800602 bool isLCD = this->isLCD();
Brian Salomon5c6ac642017-12-19 11:09:32 -0500603
604 SkMatrix localMatrix = SkMatrix::I();
605 if (this->usesLocalCoords()) {
606 // If this fails we'll just use I().
Herb Derby1c5be7b2019-12-13 12:03:06 -0500607 bool result = fGeoData[0].fDrawMatrix.invert(&localMatrix);
Brian Salomon5c6ac642017-12-19 11:09:32 -0500608 (void)result;
609 }
joshualitta751c972015-11-20 13:37:32 -0800610
Robert Phillips841c9a52020-03-27 12:41:31 -0400611 auto dfAdjustTable = GrDistanceFieldAdjustTable::Get();
612
joshualitta751c972015-11-20 13:37:32 -0800613 // see if we need to create a new effect
614 if (isLCD) {
Robert Phillips841c9a52020-03-27 12:41:31 -0400615 float redCorrection = dfAdjustTable->getAdjustment(
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400616 SkColorGetR(fLuminanceColor) >> kDistanceAdjustLumShift,
Brian Salomon344ec422016-12-15 10:58:41 -0500617 fUseGammaCorrectDistanceTable);
Robert Phillips841c9a52020-03-27 12:41:31 -0400618 float greenCorrection = dfAdjustTable->getAdjustment(
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400619 SkColorGetG(fLuminanceColor) >> kDistanceAdjustLumShift,
Brian Salomon344ec422016-12-15 10:58:41 -0500620 fUseGammaCorrectDistanceTable);
Robert Phillips841c9a52020-03-27 12:41:31 -0400621 float blueCorrection = dfAdjustTable->getAdjustment(
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400622 SkColorGetB(fLuminanceColor) >> kDistanceAdjustLumShift,
Brian Salomon344ec422016-12-15 10:58:41 -0500623 fUseGammaCorrectDistanceTable);
joshualitta751c972015-11-20 13:37:32 -0800624 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
Brian Salomon344ec422016-12-15 10:58:41 -0500625 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(
626 redCorrection, greenCorrection, blueCorrection);
Greg Daniel9715b6c2019-12-10 15:03:10 -0500627 return GrDistanceFieldLCDTextGeoProc::Make(arena, caps, views, numActiveViews,
Brian Salomonccb61422020-01-09 10:46:36 -0500628 GrSamplerState::Filter::kBilerp, widthAdjust,
Brian Osman09068252018-01-03 09:57:29 -0500629 fDFGPFlags, localMatrix);
joshualitta751c972015-11-20 13:37:32 -0800630 } else {
joshualitta751c972015-11-20 13:37:32 -0800631#ifdef SK_GAMMA_APPLY_TO_A8
Jim Van Verth90e89b32017-07-06 16:36:55 -0400632 float correction = 0;
633 if (kAliasedDistanceField_MaskType != fMaskType) {
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400634 U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT,
635 fLuminanceColor);
Robert Phillips841c9a52020-03-27 12:41:31 -0400636 correction = dfAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift,
637 fUseGammaCorrectDistanceTable);
Jim Van Verth90e89b32017-07-06 16:36:55 -0400638 }
Greg Daniel9715b6c2019-12-10 15:03:10 -0500639 return GrDistanceFieldA8TextGeoProc::Make(arena, caps, views, numActiveViews,
Brian Salomonccb61422020-01-09 10:46:36 -0500640 GrSamplerState::Filter::kBilerp, correction,
641 fDFGPFlags, localMatrix);
joshualitta751c972015-11-20 13:37:32 -0800642#else
Greg Daniel9715b6c2019-12-10 15:03:10 -0500643 return GrDistanceFieldA8TextGeoProc::Make(arena, caps, views, numActiveViews,
Brian Salomonccb61422020-01-09 10:46:36 -0500644 GrSamplerState::Filter::kBilerp,
Brian Salomon5c6ac642017-12-19 11:09:32 -0500645 fDFGPFlags, localMatrix);
joshualitta751c972015-11-20 13:37:32 -0800646#endif
647 }
joshualitta751c972015-11-20 13:37:32 -0800648}
joshualittddd22d82016-02-16 06:47:52 -0800649