blob: e749e9400eb7a064c13fcb806975dda34ff0e8cb [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;
Herb Derby53a94382020-04-29 13:04:34 -040076 op->fNeedsGlyphTransform = true;
Robert Phillips7c525e62018-06-12 10:11:12 -040077 op->fNumGlyphs = glyphCount;
78 op->fGeoCount = 1;
79 return op;
80 }
81
joshualitta751c972015-11-20 13:37:32 -080082static const int kDistanceAdjustLumShift = 5;
83
Brian Salomon5c6ac642017-12-19 11:09:32 -050084void GrAtlasTextOp::init() {
85 const Geometry& geo = fGeoData[0];
Brian Salomon5c6ac642017-12-19 11:09:32 -050086 if (this->usesDistanceFields()) {
87 bool isLCD = this->isLCD();
88
Herb Derby1c5be7b2019-12-13 12:03:06 -050089 const SkMatrix& drawMatrix = geo.fDrawMatrix;
Brian Salomon5c6ac642017-12-19 11:09:32 -050090
Herb Derby1c5be7b2019-12-13 12:03:06 -050091 fDFGPFlags = drawMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
92 fDFGPFlags |= drawMatrix.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0;
93 fDFGPFlags |= drawMatrix.hasPerspective() ? kPerspective_DistanceFieldEffectFlag : 0;
Brian Salomon5c6ac642017-12-19 11:09:32 -050094 fDFGPFlags |= fUseGammaCorrectDistanceTable ? kGammaCorrect_DistanceFieldEffectFlag : 0;
95 fDFGPFlags |= (kAliasedDistanceField_MaskType == fMaskType)
96 ? kAliased_DistanceFieldEffectFlag
97 : 0;
98
99 if (isLCD) {
100 fDFGPFlags |= kUseLCD_DistanceFieldEffectFlag;
101 fDFGPFlags |=
102 (kLCDBGRDistanceField_MaskType == fMaskType) ? kBGR_DistanceFieldEffectFlag : 0;
103 }
104 }
Jim Van Verth70276912018-06-01 13:46:46 -0400105
106 SkRect bounds;
Herb Derby5bf5b042019-12-12 16:37:03 -0500107 geo.fBlob->computeSubRunBounds(
108 &bounds, *geo.fSubRunPtr, geo.fDrawMatrix, geo.fDrawOrigin, fNeedsGlyphTransform);
Jim Van Verth70276912018-06-01 13:46:46 -0400109 // We don't have tight bounds on the glyph paths in device space. For the purposes of bounds
110 // we treat this as a set of non-AA rects rendered with a texture.
Greg Daniel5faf4742019-10-01 15:14:44 -0400111 this->setBounds(bounds, HasAABloat::kNo, IsHairline::kNo);
Brian Salomon5c6ac642017-12-19 11:09:32 -0500112}
113
Chris Dalton1706cbf2019-05-21 19:35:29 -0600114void GrAtlasTextOp::visitProxies(const VisitProxyFunc& func) const {
Robert Phillipse4fda6c2018-02-21 12:10:41 -0500115 fProcessors.visitProxies(func);
Robert Phillipse4fda6c2018-02-21 12:10:41 -0500116}
117
Brian Osman9a390ac2018-11-12 09:47:48 -0500118#ifdef SK_DEBUG
Brian Salomon344ec422016-12-15 10:58:41 -0500119SkString GrAtlasTextOp::dumpInfo() const {
joshualitta751c972015-11-20 13:37:32 -0800120 SkString str;
121
122 for (int i = 0; i < fGeoCount; ++i) {
Herb Derby1b8dcd12019-11-15 15:21:15 -0500123 str.appendf("%d: Color: 0x%08x Trans: %.2f,%.2f\n",
joshualitta751c972015-11-20 13:37:32 -0800124 i,
Brian Osmancf860852018-10-31 14:04:39 -0400125 fGeoData[i].fColor.toBytes_RGBA(),
Herb Derby5bf5b042019-12-12 16:37:03 -0500126 fGeoData[i].fDrawOrigin.x(),
127 fGeoData[i].fDrawOrigin.y());
joshualitta751c972015-11-20 13:37:32 -0800128 }
129
Brian Salomon44acb5b2017-07-18 19:59:24 -0400130 str += fProcessors.dumpProcessors();
131 str += INHERITED::dumpInfo();
joshualitta751c972015-11-20 13:37:32 -0800132 return str;
133}
Brian Osman9a390ac2018-11-12 09:47:48 -0500134#endif
joshualitta751c972015-11-20 13:37:32 -0800135
Brian Salomon44acb5b2017-07-18 19:59:24 -0400136GrDrawOp::FixedFunctionFlags GrAtlasTextOp::fixedFunctionFlags() const {
137 return FixedFunctionFlags::kNone;
138}
139
Chris Dalton6ce447a2019-06-23 18:07:38 -0600140GrProcessorSet::Analysis GrAtlasTextOp::finalize(
141 const GrCaps& caps, const GrAppliedClip* clip, bool hasMixedSampledCoverage,
142 GrClampType clampType) {
Brian Salomon44acb5b2017-07-18 19:59:24 -0400143 GrProcessorAnalysisCoverage coverage;
144 GrProcessorAnalysisColor color;
joshualitta751c972015-11-20 13:37:32 -0800145 if (kColorBitmapMask_MaskType == fMaskType) {
Brian Salomon44acb5b2017-07-18 19:59:24 -0400146 color.setToUnknown();
joshualitta751c972015-11-20 13:37:32 -0800147 } else {
Brian Osman09068252018-01-03 09:57:29 -0500148 color.setToConstant(this->color());
joshualitta751c972015-11-20 13:37:32 -0800149 }
joshualitta751c972015-11-20 13:37:32 -0800150 switch (fMaskType) {
joshualitta751c972015-11-20 13:37:32 -0800151 case kGrayscaleCoverageMask_MaskType:
Jim Van Verth90e89b32017-07-06 16:36:55 -0400152 case kAliasedDistanceField_MaskType:
153 case kGrayscaleDistanceField_MaskType:
Brian Salomon44acb5b2017-07-18 19:59:24 -0400154 coverage = GrProcessorAnalysisCoverage::kSingleChannel;
joshualitta751c972015-11-20 13:37:32 -0800155 break;
156 case kLCDCoverageMask_MaskType:
157 case kLCDDistanceField_MaskType:
Jim Van Verth90e89b32017-07-06 16:36:55 -0400158 case kLCDBGRDistanceField_MaskType:
Brian Salomon44acb5b2017-07-18 19:59:24 -0400159 coverage = GrProcessorAnalysisCoverage::kLCD;
joshualitta751c972015-11-20 13:37:32 -0800160 break;
161 case kColorBitmapMask_MaskType:
Brian Salomon44acb5b2017-07-18 19:59:24 -0400162 coverage = GrProcessorAnalysisCoverage::kNone;
Brian Salomonc0b642c2017-03-27 13:09:36 -0400163 break;
joshualitta751c972015-11-20 13:37:32 -0800164 }
Chris Daltonb8fff0d2019-03-05 10:11:58 -0700165 auto analysis = fProcessors.finalize(
Chris Dalton6ce447a2019-06-23 18:07:38 -0600166 color, coverage, clip, &GrUserStencilSettings::kUnused, hasMixedSampledCoverage, caps,
167 clampType, &fGeoData[0].fColor);
Brian Salomon44acb5b2017-07-18 19:59:24 -0400168 fUsesLocalCoords = analysis.usesLocalCoords();
Chris Dalton4b62aed2019-01-15 11:53:00 -0700169 return analysis;
joshualitta751c972015-11-20 13:37:32 -0800170}
171
Brian Salomon18923f92017-11-06 16:26:02 -0500172static void clip_quads(const SkIRect& clipRect, char* currVertex, const char* blobVertices,
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400173 size_t vertexStride, int glyphCount) {
174 for (int i = 0; i < glyphCount; ++i) {
Brian Salomon18923f92017-11-06 16:26:02 -0500175 const SkPoint* blobPositionLT = reinterpret_cast<const SkPoint*>(blobVertices);
176 const SkPoint* blobPositionRB =
177 reinterpret_cast<const SkPoint*>(blobVertices + 3 * vertexStride);
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400178
Jim Van Verth328a33f2017-10-20 12:14:22 -0400179 // positions for bitmap glyphs are pixel boundary aligned
Brian Osman7ca90d22017-11-10 15:31:27 -0500180 SkIRect positionRect = SkIRect::MakeLTRB(SkScalarRoundToInt(blobPositionLT->fX),
181 SkScalarRoundToInt(blobPositionLT->fY),
182 SkScalarRoundToInt(blobPositionRB->fX),
183 SkScalarRoundToInt(blobPositionRB->fY));
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400184 if (clipRect.contains(positionRect)) {
185 memcpy(currVertex, blobVertices, 4 * vertexStride);
186 currVertex += 4 * vertexStride;
187 } else {
188 // Pull out some more data that we'll need.
189 // In the LCD case the color will be garbage, but we'll overwrite it with the texcoords
190 // and it avoids a lot of conditionals.
Brian Salomon18923f92017-11-06 16:26:02 -0500191 auto color = *reinterpret_cast<const SkColor*>(blobVertices + sizeof(SkPoint));
Jim Van Verth2f2c77a2020-01-24 15:48:23 +0000192 size_t coordOffset = vertexStride - 2*sizeof(uint16_t);
193 auto* blobCoordsLT = reinterpret_cast<const uint16_t*>(blobVertices + coordOffset);
194 auto* blobCoordsRB = reinterpret_cast<const uint16_t*>(blobVertices + 3 * vertexStride +
Brian Salomon18923f92017-11-06 16:26:02 -0500195 coordOffset);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400196 // Pull out the texel coordinates and texture index bits
Jim Van Verthfb395102020-02-03 10:11:19 -0500197 uint16_t coordsRectL = blobCoordsLT[0];
198 uint16_t coordsRectT = blobCoordsLT[1];
199 uint16_t coordsRectR = blobCoordsRB[0];
200 uint16_t coordsRectB = blobCoordsRB[1];
201 int index0, index1;
202 std::tie(coordsRectL, coordsRectT, index0) =
203 GrDrawOpAtlas::UnpackIndexFromTexCoords(coordsRectL, coordsRectT);
204 std::tie(coordsRectR, coordsRectB, index1) =
205 GrDrawOpAtlas::UnpackIndexFromTexCoords(coordsRectR, coordsRectB);
206 SkASSERT(index0 == index1);
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400207
Jim Van Verth328a33f2017-10-20 12:14:22 -0400208 int positionRectWidth = positionRect.width();
209 int positionRectHeight = positionRect.height();
210 SkASSERT(positionRectWidth == (coordsRectR - coordsRectL));
211 SkASSERT(positionRectHeight == (coordsRectB - coordsRectT));
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400212
213 // Clip position and texCoords to the clipRect
Jim Van Verth328a33f2017-10-20 12:14:22 -0400214 unsigned int delta;
Brian Osman788b9162020-02-07 10:36:46 -0500215 delta = std::min(std::max(clipRect.fLeft - positionRect.fLeft, 0), positionRectWidth);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400216 coordsRectL += delta;
217 positionRect.fLeft += delta;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400218
Brian Osman788b9162020-02-07 10:36:46 -0500219 delta = std::min(std::max(clipRect.fTop - positionRect.fTop, 0), positionRectHeight);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400220 coordsRectT += delta;
221 positionRect.fTop += delta;
222
Brian Osman788b9162020-02-07 10:36:46 -0500223 delta = std::min(std::max(positionRect.fRight - clipRect.fRight, 0), positionRectWidth);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400224 coordsRectR -= delta;
225 positionRect.fRight -= delta;
226
Brian Osman788b9162020-02-07 10:36:46 -0500227 delta = std::min(std::max(positionRect.fBottom - clipRect.fBottom, 0), positionRectHeight);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400228 coordsRectB -= delta;
229 positionRect.fBottom -= delta;
230
231 // Repack texel coordinates and index
Jim Van Verthfb395102020-02-03 10:11:19 -0500232 std::tie(coordsRectL, coordsRectT) =
233 GrDrawOpAtlas::PackIndexInTexCoords(coordsRectL, coordsRectT, index0);
234 std::tie(coordsRectR, coordsRectB) =
235 GrDrawOpAtlas::PackIndexInTexCoords(coordsRectR, coordsRectB, index1);
Jim Van Verth328a33f2017-10-20 12:14:22 -0400236
237 // Set new positions and coords
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400238 SkPoint* currPosition = reinterpret_cast<SkPoint*>(currVertex);
239 currPosition->fX = positionRect.fLeft;
240 currPosition->fY = positionRect.fTop;
241 *(reinterpret_cast<SkColor*>(currVertex + sizeof(SkPoint))) = color;
Jim Van Verth328a33f2017-10-20 12:14:22 -0400242 uint16_t* currCoords = reinterpret_cast<uint16_t*>(currVertex + coordOffset);
243 currCoords[0] = coordsRectL;
244 currCoords[1] = coordsRectT;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400245 currVertex += vertexStride;
246
247 currPosition = reinterpret_cast<SkPoint*>(currVertex);
248 currPosition->fX = positionRect.fLeft;
249 currPosition->fY = positionRect.fBottom;
250 *(reinterpret_cast<SkColor*>(currVertex + sizeof(SkPoint))) = color;
Jim Van Verth328a33f2017-10-20 12:14:22 -0400251 currCoords = reinterpret_cast<uint16_t*>(currVertex + coordOffset);
252 currCoords[0] = coordsRectL;
253 currCoords[1] = coordsRectB;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400254 currVertex += vertexStride;
255
256 currPosition = reinterpret_cast<SkPoint*>(currVertex);
257 currPosition->fX = positionRect.fRight;
258 currPosition->fY = positionRect.fTop;
259 *(reinterpret_cast<SkColor*>(currVertex + sizeof(SkPoint))) = color;
Jim Van Verth328a33f2017-10-20 12:14:22 -0400260 currCoords = reinterpret_cast<uint16_t*>(currVertex + coordOffset);
261 currCoords[0] = coordsRectR;
262 currCoords[1] = coordsRectT;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400263 currVertex += vertexStride;
264
265 currPosition = reinterpret_cast<SkPoint*>(currVertex);
266 currPosition->fX = positionRect.fRight;
267 currPosition->fY = positionRect.fBottom;
268 *(reinterpret_cast<SkColor*>(currVertex + sizeof(SkPoint))) = color;
Jim Van Verth328a33f2017-10-20 12:14:22 -0400269 currCoords = reinterpret_cast<uint16_t*>(currVertex + coordOffset);
270 currCoords[0] = coordsRectR;
271 currCoords[1] = coordsRectB;
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400272 currVertex += vertexStride;
273 }
274
275 blobVertices += 4 * vertexStride;
276 }
277}
278
Brian Salomon91326c32017-08-09 16:02:19 -0400279void GrAtlasTextOp::onPrepareDraws(Target* target) {
Robert Phillips4bc70112018-03-01 10:24:02 -0500280 auto resourceProvider = target->resourceProvider();
281
joshualitta751c972015-11-20 13:37:32 -0800282 // if we have RGB, then we won't have any SkShaders so no need to use a localmatrix.
283 // TODO actually only invert if we don't have RGBA
284 SkMatrix localMatrix;
Herb Derby1c5be7b2019-12-13 12:03:06 -0500285 if (this->usesLocalCoords() && !fGeoData[0].fDrawMatrix.invert(&localMatrix)) {
joshualitta751c972015-11-20 13:37:32 -0800286 return;
287 }
288
Robert Phillips5a66efb2018-03-07 15:13:18 -0500289 GrAtlasManager* atlasManager = target->atlasManager();
Mike Klein99e002f2020-01-16 16:45:03 +0000290
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400291 GrMaskFormat maskFormat = this->maskFormat();
292
Greg Daniel9715b6c2019-12-10 15:03:10 -0500293 unsigned int numActiveViews;
294 const GrSurfaceProxyView* views = atlasManager->getViews(maskFormat, &numActiveViews);
295 if (!views) {
joshualitta751c972015-11-20 13:37:32 -0800296 SkDebugf("Could not allocate backing texture for atlas\n");
297 return;
298 }
Greg Daniel9715b6c2019-12-10 15:03:10 -0500299 SkASSERT(views[0].proxy());
joshualitta751c972015-11-20 13:37:32 -0800300
Brian Salomon7eae3e02018-08-07 14:02:38 +0000301 static constexpr int kMaxTextures = GrBitmapTextGeoProc::kMaxTextures;
Brian Salomon4dea72a2019-12-18 10:43:10 -0500302 static_assert(GrDistanceFieldA8TextGeoProc::kMaxTextures == kMaxTextures);
303 static_assert(GrDistanceFieldLCDTextGeoProc::kMaxTextures == kMaxTextures);
Brian Salomon7eae3e02018-08-07 14:02:38 +0000304
Chris Dalton304e14d2020-03-17 14:29:06 -0600305 auto primProcProxies = target->allocPrimProcProxyPtrs(kMaxTextures);
Greg Daniel9715b6c2019-12-10 15:03:10 -0500306 for (unsigned i = 0; i < numActiveViews; ++i) {
Chris Dalton304e14d2020-03-17 14:29:06 -0600307 primProcProxies[i] = views[i].proxy();
Greg Danielb20d7e52019-09-03 13:54:39 -0400308 // This op does not know its atlas proxies when it is added to a GrOpsTasks, so the proxies
309 // don't get added during the visitProxies call. Thus we add them here.
Greg Daniel9715b6c2019-12-10 15:03:10 -0500310 target->sampledProxyArray()->push_back(views[i].proxy());
Brian Salomon7eae3e02018-08-07 14:02:38 +0000311 }
Brian Salomon49348902018-06-26 09:12:38 -0400312
313 FlushInfo flushInfo;
Chris Dalton304e14d2020-03-17 14:29:06 -0600314 flushInfo.fPrimProcProxies = primProcProxies;
Brian Salomon49348902018-06-26 09:12:38 -0400315
Herb Derby1c5be7b2019-12-13 12:03:06 -0500316 bool vmPerspective = fGeoData[0].fDrawMatrix.hasPerspective();
joshualittd9d30f72015-12-08 10:47:55 -0800317 if (this->usesDistanceFields()) {
Robert Phillips7cd0bfe2019-11-20 16:08:10 -0500318 flushInfo.fGeometryProcessor = this->setupDfProcessor(target->allocator(),
319 *target->caps().shaderCaps(),
Greg Daniel9715b6c2019-12-10 15:03:10 -0500320 views, numActiveViews);
joshualitta751c972015-11-20 13:37:32 -0800321 } else {
Brian Salomonccb61422020-01-09 10:46:36 -0500322 auto filter = fNeedsGlyphTransform ? GrSamplerState::Filter::kBilerp
323 : GrSamplerState::Filter::kNearest;
324 flushInfo.fGeometryProcessor = GrBitmapTextGeoProc::Make(
325 target->allocator(), *target->caps().shaderCaps(), this->color(), false, views,
326 numActiveViews, filter, maskFormat, localMatrix, vmPerspective);
joshualitta751c972015-11-20 13:37:32 -0800327 }
328
Herb Derby23f29762020-01-10 16:26:14 -0500329 int vertexStride = (int)flushInfo.fGeometryProcessor->vertexStride();
joshualitta751c972015-11-20 13:37:32 -0800330
Brian Salomon43cbd722020-01-03 22:09:12 -0500331 // Ensure we don't request an insanely large contiguous vertex allocation.
Herb Derby23f29762020-01-10 16:26:14 -0500332 static const int kMaxVertexBytes = GrBufferAllocPool::kDefaultBufferSize;
333 const int quadSize = vertexStride * kVerticesPerGlyph;
334 const int maxQuadsPerBuffer = kMaxVertexBytes / quadSize;
335
336 // Where the quad buffer begins and ends relative to totalGlyphsRegened.
337 int quadBufferBegin = 0;
338 int quadBufferEnd = std::min(this->numGlyphs(), maxQuadsPerBuffer);
339
Robert Phillipsee08d522019-10-28 16:34:44 -0400340 flushInfo.fIndexBuffer = resourceProvider->refNonAAQuadIndexBuffer();
Herb Derby23f29762020-01-10 16:26:14 -0500341 void* vertices = target->makeVertexSpace(
342 vertexStride,
343 kVerticesPerGlyph * (quadBufferEnd - quadBufferBegin),
344 &flushInfo.fVertexBuffer,
345 &flushInfo.fVertexOffset);
joshualitta751c972015-11-20 13:37:32 -0800346 if (!vertices || !flushInfo.fVertexBuffer) {
347 SkDebugf("Could not allocate vertices\n");
348 return;
349 }
350
Herb Derby23f29762020-01-10 16:26:14 -0500351 // totalGlyphsRegened is all the glyphs for the op [0, this->numGlyphs()). The subRun glyph and
352 // quad buffer indices are calculated from this.
353 int totalGlyphsRegened = 0;
joshualitta751c972015-11-20 13:37:32 -0800354 for (int i = 0; i < fGeoCount; i++) {
joshualitt144c3c82015-11-30 12:30:13 -0800355 const Geometry& args = fGeoData[i];
Herb Derby23f29762020-01-10 16:26:14 -0500356 auto subRun = args.fSubRunPtr;
357 SkASSERT((int)subRun->vertexStride() == vertexStride);
358
Robert Phillips207d24b2020-04-09 10:23:42 -0400359 subRun->prepareGrGlyphs(target->strikeCache());
Herb Derby62b12fe2020-01-14 17:57:24 -0500360 subRun->updateVerticesColorIfNeeded(args.fColor.toBytes_RGBA());
361 subRun->translateVerticesIfNeeded(args.fDrawMatrix, args.fDrawOrigin);
362
Brian Osman1be2b7c2018-10-29 16:07:15 -0400363 // TODO4F: Preserve float colors
Robert Phillips297a2192020-04-08 15:26:54 -0400364 GrTextBlob::VertexRegenerator regenerator(resourceProvider, subRun,
365 target->deferredUploadTarget(), atlasManager);
Herb Derby23f29762020-01-10 16:26:14 -0500366
367 // Where the subRun begins and ends relative to totalGlyphsRegened.
368 int subRunBegin = totalGlyphsRegened;
Robert Phillips1576e4e2020-04-01 12:49:45 -0400369 int subRunEnd = subRunBegin + subRun->fGlyphs.count();
Herb Derby23f29762020-01-10 16:26:14 -0500370
371 // Draw all the glyphs in the subRun.
372 while (totalGlyphsRegened < subRunEnd) {
373 // drawBegin and drawEnd are indices for the subRun on the
374 // interval [0, subRun->fGlyphs.size()).
375 int drawBegin = totalGlyphsRegened - subRunBegin;
376 // drawEnd is either the end of the subRun or the end of the current quad buffer.
377 int drawEnd = std::min(subRunEnd, quadBufferEnd) - subRunBegin;
378 auto[ok, glyphsRegenerated] = regenerator.regenerate(drawBegin, drawEnd);
379
380 // There was a problem allocating the glyph in the atlas. Bail.
Robert Phillips1576e4e2020-04-01 12:49:45 -0400381 if (!ok) {
382 return;
383 }
Herb Derby23f29762020-01-10 16:26:14 -0500384
385 // Update all the vertices for glyphsRegenerate glyphs.
386 if (glyphsRegenerated > 0) {
387 int quadBufferIndex = totalGlyphsRegened - quadBufferBegin;
388 int subRunIndex = totalGlyphsRegened - subRunBegin;
389 auto regeneratedQuadBuffer =
390 SkTAddOffset<char>(vertices, subRun->quadOffset(quadBufferIndex));
Brian Salomon43cbd722020-01-03 22:09:12 -0500391 if (args.fClipRect.isEmpty()) {
Herb Derby23f29762020-01-10 16:26:14 -0500392 memcpy(regeneratedQuadBuffer,
393 subRun->quadStart(subRunIndex),
394 glyphsRegenerated * quadSize);
Brian Salomon43cbd722020-01-03 22:09:12 -0500395 } else {
396 SkASSERT(!vmPerspective);
Herb Derby23f29762020-01-10 16:26:14 -0500397 clip_quads(args.fClipRect,
398 regeneratedQuadBuffer,
399 subRun->quadStart(subRunIndex),
400 vertexStride,
401 glyphsRegenerated);
Brian Salomon43cbd722020-01-03 22:09:12 -0500402 }
403 if (fNeedsGlyphTransform && !args.fDrawMatrix.isIdentity()) {
404 // We always do the distance field view matrix transformation after copying
405 // rather than during blob vertex generation time in the blob as handling
406 // successive arbitrary transformations would be complicated and accumulate
407 // error.
408 if (args.fDrawMatrix.hasPerspective()) {
Herb Derby23f29762020-01-10 16:26:14 -0500409 auto* pos = reinterpret_cast<SkPoint3*>(regeneratedQuadBuffer);
410 SkMatrixPriv::MapHomogeneousPointsWithStride(
411 args.fDrawMatrix, pos,
412 vertexStride, pos,
413 vertexStride,
414 glyphsRegenerated * kVerticesPerGlyph);
Brian Salomon43cbd722020-01-03 22:09:12 -0500415 } else {
Herb Derby23f29762020-01-10 16:26:14 -0500416 auto* pos = reinterpret_cast<SkPoint*>(regeneratedQuadBuffer);
Brian Salomon43cbd722020-01-03 22:09:12 -0500417 SkMatrixPriv::MapPointsWithStride(args.fDrawMatrix, pos, vertexStride,
Herb Derby23f29762020-01-10 16:26:14 -0500418 glyphsRegenerated * kVerticesPerGlyph);
Brian Salomon43cbd722020-01-03 22:09:12 -0500419 }
420 }
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500421 }
Herb Derby23f29762020-01-10 16:26:14 -0500422
423 totalGlyphsRegened += glyphsRegenerated;
424 flushInfo.fGlyphsToFlush += glyphsRegenerated;
425
426 // regenerate() has stopped part way through a SubRun. This means that either the atlas
427 // or the quad buffer is full or both. There is a case were the flow through
428 // the loop is strange. If we run out of quad buffer space at the same time the
429 // SubRun ends, then this is not triggered which is the right result for the last
430 // SubRun. But, if this is not the last SubRun, then advance to the next SubRun which
431 // will process no glyphs, and return to this point where the quad buffer will be
432 // expanded.
433 if (totalGlyphsRegened != subRunEnd) {
434 // Flush if not all glyphs drawn because either the quad buffer is full or the
435 // atlas is out of space.
Herb Derby4513cdd2020-01-31 13:28:49 -0500436 this->createDrawForGeneratedGlyphs(target, &flushInfo);
Herb Derby23f29762020-01-10 16:26:14 -0500437 if (totalGlyphsRegened == quadBufferEnd) {
438 // Quad buffer is full. Get more buffer.
439 quadBufferBegin = totalGlyphsRegened;
440 int quadBufferSize =
441 std::min(maxQuadsPerBuffer, this->numGlyphs() - totalGlyphsRegened);
442 quadBufferEnd = quadBufferBegin + quadBufferSize;
443
444 vertices = target->makeVertexSpace(
445 vertexStride,
446 kVerticesPerGlyph * quadBufferSize,
447 &flushInfo.fVertexBuffer,
448 &flushInfo.fVertexOffset);
449 if (!vertices || !flushInfo.fVertexBuffer) {
450 SkDebugf("Could not allocate vertices\n");
451 return;
452 }
453 }
454 }
455 }
Herb Derby5f6f8512020-01-10 12:50:35 -0500456 } // for all geometries
Herb Derby4513cdd2020-01-31 13:28:49 -0500457 this->createDrawForGeneratedGlyphs(target, &flushInfo);
joshualitta751c972015-11-20 13:37:32 -0800458}
459
Chris Dalton07cdcfc92019-02-26 11:13:22 -0700460void GrAtlasTextOp::onExecute(GrOpFlushState* flushState, const SkRect& chainBounds) {
Robert Phillips3968fcb2019-12-05 16:40:31 -0500461 auto pipeline = GrSimpleMeshDrawOpHelper::CreatePipeline(flushState,
462 std::move(fProcessors),
463 GrPipeline::InputFlags::kNone);
464
465 flushState->executeDrawsAndUploadsForMeshDrawOp(this, chainBounds, pipeline);
Chris Dalton07cdcfc92019-02-26 11:13:22 -0700466}
467
Herb Derby4513cdd2020-01-31 13:28:49 -0500468void GrAtlasTextOp::createDrawForGeneratedGlyphs(
469 GrMeshDrawOp::Target* target, FlushInfo* flushInfo) const {
Robert Phillipsd2e9f762018-03-07 11:54:37 -0500470 if (!flushInfo->fGlyphsToFlush) {
471 return;
472 }
473
Robert Phillips5a66efb2018-03-07 15:13:18 -0500474 auto atlasManager = target->atlasManager();
Robert Phillipsc4039ea2018-03-01 11:36:45 -0500475
Robert Phillips7cd0bfe2019-11-20 16:08:10 -0500476 GrGeometryProcessor* gp = flushInfo->fGeometryProcessor;
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400477 GrMaskFormat maskFormat = this->maskFormat();
Robert Phillipsf3690dd2018-02-20 15:18:59 -0500478
Greg Daniel9715b6c2019-12-10 15:03:10 -0500479 unsigned int numActiveViews;
480 const GrSurfaceProxyView* views = atlasManager->getViews(maskFormat, &numActiveViews);
481 SkASSERT(views);
Jim Van Verth9f2516f2019-11-22 14:58:37 -0500482 // Something has gone terribly wrong, bail
Greg Daniel9715b6c2019-12-10 15:03:10 -0500483 if (!views || 0 == numActiveViews) {
Jim Van Verth9f2516f2019-11-22 14:58:37 -0500484 return;
485 }
Greg Daniel9715b6c2019-12-10 15:03:10 -0500486 if (gp->numTextureSamplers() != (int) numActiveViews) {
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400487 // During preparation the number of atlas pages has increased.
488 // Update the proxies used in the GP to match.
Greg Daniel9715b6c2019-12-10 15:03:10 -0500489 for (unsigned i = gp->numTextureSamplers(); i < numActiveViews; ++i) {
Chris Dalton304e14d2020-03-17 14:29:06 -0600490 flushInfo->fPrimProcProxies[i] = views[i].proxy();
Greg Danielb20d7e52019-09-03 13:54:39 -0400491 // This op does not know its atlas proxies when it is added to a GrOpsTasks, so the
492 // proxies don't get added during the visitProxies call. Thus we add them here.
Greg Daniel9715b6c2019-12-10 15:03:10 -0500493 target->sampledProxyArray()->push_back(views[i].proxy());
Brian Salomon43cbd722020-01-03 22:09:12 -0500494 // These will get unreffed when the previously recorded draws destruct.
495 for (int d = 0; d < flushInfo->fNumDraws; ++d) {
Chris Dalton304e14d2020-03-17 14:29:06 -0600496 flushInfo->fPrimProcProxies[i]->ref();
Brian Salomon43cbd722020-01-03 22:09:12 -0500497 }
Brian Salomon7eae3e02018-08-07 14:02:38 +0000498 }
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400499 if (this->usesDistanceFields()) {
500 if (this->isLCD()) {
Greg Daniel9715b6c2019-12-10 15:03:10 -0500501 reinterpret_cast<GrDistanceFieldLCDTextGeoProc*>(gp)->addNewViews(
Brian Salomonccb61422020-01-09 10:46:36 -0500502 views, numActiveViews, GrSamplerState::Filter::kBilerp);
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400503 } else {
Greg Daniel9715b6c2019-12-10 15:03:10 -0500504 reinterpret_cast<GrDistanceFieldA8TextGeoProc*>(gp)->addNewViews(
Brian Salomonccb61422020-01-09 10:46:36 -0500505 views, numActiveViews, GrSamplerState::Filter::kBilerp);
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400506 }
507 } else {
Brian Salomonccb61422020-01-09 10:46:36 -0500508 auto filter = fNeedsGlyphTransform ? GrSamplerState::Filter::kBilerp
509 : GrSamplerState::Filter::kNearest;
510 reinterpret_cast<GrBitmapTextGeoProc*>(gp)->addNewViews(views, numActiveViews, filter);
Jim Van Vertheafa64b2017-09-18 10:05:00 -0400511 }
512 }
Brian Salomondbf70722019-02-07 11:31:24 -0500513 int maxGlyphsPerDraw = static_cast<int>(flushInfo->fIndexBuffer->size() / sizeof(uint16_t) / 6);
Chris Daltoneb694b72020-03-16 09:25:50 -0600514 GrSimpleMesh* mesh = target->allocMesh();
Chris Dalton37c7bdd2020-03-13 09:21:12 -0600515 mesh->setIndexedPatterned(flushInfo->fIndexBuffer, kIndicesPerGlyph, flushInfo->fGlyphsToFlush,
516 maxGlyphsPerDraw, flushInfo->fVertexBuffer, kVerticesPerGlyph,
517 flushInfo->fVertexOffset);
Chris Dalton304e14d2020-03-17 14:29:06 -0600518 target->recordDraw(flushInfo->fGeometryProcessor, mesh, 1, flushInfo->fPrimProcProxies,
Chris Dalton3bf2f3a2020-03-17 11:48:23 -0600519 GrPrimitiveType::kTriangles);
joshualitta751c972015-11-20 13:37:32 -0800520 flushInfo->fVertexOffset += kVerticesPerGlyph * flushInfo->fGlyphsToFlush;
521 flushInfo->fGlyphsToFlush = 0;
Brian Salomon43cbd722020-01-03 22:09:12 -0500522 ++flushInfo->fNumDraws;
joshualitta751c972015-11-20 13:37:32 -0800523}
524
Michael Ludwig28b0c5d2019-12-19 14:51:00 -0500525GrOp::CombineResult GrAtlasTextOp::onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*,
526 const GrCaps& caps) {
Brian Salomon344ec422016-12-15 10:58:41 -0500527 GrAtlasTextOp* that = t->cast<GrAtlasTextOp>();
Brian Salomon44acb5b2017-07-18 19:59:24 -0400528 if (fProcessors != that->fProcessors) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000529 return CombineResult::kCannotCombine;
Brian Salomon44acb5b2017-07-18 19:59:24 -0400530 }
531
joshualitta751c972015-11-20 13:37:32 -0800532 if (fMaskType != that->fMaskType) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000533 return CombineResult::kCannotCombine;
joshualitta751c972015-11-20 13:37:32 -0800534 }
535
Herb Derby1c5be7b2019-12-13 12:03:06 -0500536 const SkMatrix& thisFirstMatrix = fGeoData[0].fDrawMatrix;
537 const SkMatrix& thatFirstMatrix = that->fGeoData[0].fDrawMatrix;
Brian Salomon5c6ac642017-12-19 11:09:32 -0500538
Mike Reed2c383152019-12-18 16:47:47 -0500539 if (this->usesLocalCoords() && !SkMatrixPriv::CheapEqual(thisFirstMatrix, thatFirstMatrix)) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000540 return CombineResult::kCannotCombine;
Brian Salomon5c6ac642017-12-19 11:09:32 -0500541 }
542
Jim Van Verthb515ae72018-05-23 16:44:55 -0400543 if (fNeedsGlyphTransform != that->fNeedsGlyphTransform) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000544 return CombineResult::kCannotCombine;
Jim Van Verthb515ae72018-05-23 16:44:55 -0400545 }
546
547 if (fNeedsGlyphTransform &&
548 (thisFirstMatrix.hasPerspective() != thatFirstMatrix.hasPerspective())) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000549 return CombineResult::kCannotCombine;
Jim Van Verthb515ae72018-05-23 16:44:55 -0400550 }
551
Brian Salomon5c6ac642017-12-19 11:09:32 -0500552 if (this->usesDistanceFields()) {
553 if (fDFGPFlags != that->fDFGPFlags) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000554 return CombineResult::kCannotCombine;
joshualitta751c972015-11-20 13:37:32 -0800555 }
556
Jim Van Verthbc2cdd12017-06-08 11:14:35 -0400557 if (fLuminanceColor != that->fLuminanceColor) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000558 return CombineResult::kCannotCombine;
joshualitta751c972015-11-20 13:37:32 -0800559 }
Brian Salomon5c6ac642017-12-19 11:09:32 -0500560 } else {
561 if (kColorBitmapMask_MaskType == fMaskType && this->color() != that->color()) {
Brian Salomon7eae3e02018-08-07 14:02:38 +0000562 return CombineResult::kCannotCombine;
Brian Salomon5c6ac642017-12-19 11:09:32 -0500563 }
joshualitta751c972015-11-20 13:37:32 -0800564 }
565
Brian Salomon344ec422016-12-15 10:58:41 -0500566 fNumGlyphs += that->numGlyphs();
joshualitta751c972015-11-20 13:37:32 -0800567
Jim Van Verth56c37142017-10-31 14:44:25 -0400568 // Reallocate space for geo data if necessary and then import that geo's data.
joshualitta751c972015-11-20 13:37:32 -0800569 int newGeoCount = that->fGeoCount + fGeoCount;
joshualitta751c972015-11-20 13:37:32 -0800570
Jim Van Verthc8a65e32017-10-25 14:25:27 -0400571 // We reallocate at a rate of 1.5x to try to get better total memory usage
572 if (newGeoCount > fGeoDataAllocSize) {
Jim Van Verth56c37142017-10-31 14:44:25 -0400573 int newAllocSize = fGeoDataAllocSize + fGeoDataAllocSize / 2;
Jim Van Verthc8a65e32017-10-25 14:25:27 -0400574 while (newAllocSize < newGeoCount) {
575 newAllocSize += newAllocSize / 2;
576 }
joshualitta751c972015-11-20 13:37:32 -0800577 fGeoData.realloc(newAllocSize);
Jim Van Verthc8a65e32017-10-25 14:25:27 -0400578 fGeoDataAllocSize = newAllocSize;
joshualitta751c972015-11-20 13:37:32 -0800579 }
580
Brian Salomon344ec422016-12-15 10:58:41 -0500581 // 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 -0800582 // it doesn't try to unref them.
Brian Salomon344ec422016-12-15 10:58:41 -0500583 memcpy(&fGeoData[fGeoCount], that->fGeoData.get(), that->fGeoCount * sizeof(Geometry));
joshualitta751c972015-11-20 13:37:32 -0800584#ifdef SK_DEBUG
585 for (int i = 0; i < that->fGeoCount; ++i) {
Herb Derbyc514e7d2019-12-11 17:00:31 -0500586 that->fGeoData.get()[i].fBlob = (GrTextBlob*)0x1;
joshualitta751c972015-11-20 13:37:32 -0800587 }
588#endif
589 that->fGeoCount = 0;
590 fGeoCount = newGeoCount;
591
Brian Salomon7eae3e02018-08-07 14:02:38 +0000592 return CombineResult::kMerged;
joshualitta751c972015-11-20 13:37:32 -0800593}
594
joshualitta751c972015-11-20 13:37:32 -0800595// TODO trying to figure out why lcd is so whack
Herb Derby26cbe512018-05-24 14:39:01 -0400596// (see comments in GrTextContext::ComputeCanonicalColor)
Robert Phillips7cd0bfe2019-11-20 16:08:10 -0500597GrGeometryProcessor* GrAtlasTextOp::setupDfProcessor(SkArenaAlloc* arena,
598 const GrShaderCaps& caps,
Greg Daniel9715b6c2019-12-10 15:03:10 -0500599 const GrSurfaceProxyView* views,
600 unsigned int numActiveViews) const {
joshualitta751c972015-11-20 13:37:32 -0800601 bool isLCD = this->isLCD();
Brian Salomon5c6ac642017-12-19 11:09:32 -0500602
603 SkMatrix localMatrix = SkMatrix::I();
604 if (this->usesLocalCoords()) {
605 // If this fails we'll just use I().
Herb Derby1c5be7b2019-12-13 12:03:06 -0500606 bool result = fGeoData[0].fDrawMatrix.invert(&localMatrix);
Brian Salomon5c6ac642017-12-19 11:09:32 -0500607 (void)result;
608 }
joshualitta751c972015-11-20 13:37:32 -0800609
Robert Phillips841c9a52020-03-27 12:41:31 -0400610 auto dfAdjustTable = GrDistanceFieldAdjustTable::Get();
611
joshualitta751c972015-11-20 13:37:32 -0800612 // see if we need to create a new effect
613 if (isLCD) {
Robert Phillips841c9a52020-03-27 12:41:31 -0400614 float redCorrection = dfAdjustTable->getAdjustment(
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400615 SkColorGetR(fLuminanceColor) >> kDistanceAdjustLumShift,
Brian Salomon344ec422016-12-15 10:58:41 -0500616 fUseGammaCorrectDistanceTable);
Robert Phillips841c9a52020-03-27 12:41:31 -0400617 float greenCorrection = dfAdjustTable->getAdjustment(
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400618 SkColorGetG(fLuminanceColor) >> kDistanceAdjustLumShift,
Brian Salomon344ec422016-12-15 10:58:41 -0500619 fUseGammaCorrectDistanceTable);
Robert Phillips841c9a52020-03-27 12:41:31 -0400620 float blueCorrection = dfAdjustTable->getAdjustment(
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400621 SkColorGetB(fLuminanceColor) >> kDistanceAdjustLumShift,
Brian Salomon344ec422016-12-15 10:58:41 -0500622 fUseGammaCorrectDistanceTable);
joshualitta751c972015-11-20 13:37:32 -0800623 GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
Brian Salomon344ec422016-12-15 10:58:41 -0500624 GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(
625 redCorrection, greenCorrection, blueCorrection);
Greg Daniel9715b6c2019-12-10 15:03:10 -0500626 return GrDistanceFieldLCDTextGeoProc::Make(arena, caps, views, numActiveViews,
Brian Salomonccb61422020-01-09 10:46:36 -0500627 GrSamplerState::Filter::kBilerp, widthAdjust,
Brian Osman09068252018-01-03 09:57:29 -0500628 fDFGPFlags, localMatrix);
joshualitta751c972015-11-20 13:37:32 -0800629 } else {
joshualitta751c972015-11-20 13:37:32 -0800630#ifdef SK_GAMMA_APPLY_TO_A8
Jim Van Verth90e89b32017-07-06 16:36:55 -0400631 float correction = 0;
632 if (kAliasedDistanceField_MaskType != fMaskType) {
Jim Van Verth58c3cce2017-10-19 15:50:24 -0400633 U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT,
634 fLuminanceColor);
Robert Phillips841c9a52020-03-27 12:41:31 -0400635 correction = dfAdjustTable->getAdjustment(lum >> kDistanceAdjustLumShift,
636 fUseGammaCorrectDistanceTable);
Jim Van Verth90e89b32017-07-06 16:36:55 -0400637 }
Greg Daniel9715b6c2019-12-10 15:03:10 -0500638 return GrDistanceFieldA8TextGeoProc::Make(arena, caps, views, numActiveViews,
Brian Salomonccb61422020-01-09 10:46:36 -0500639 GrSamplerState::Filter::kBilerp, correction,
640 fDFGPFlags, localMatrix);
joshualitta751c972015-11-20 13:37:32 -0800641#else
Greg Daniel9715b6c2019-12-10 15:03:10 -0500642 return GrDistanceFieldA8TextGeoProc::Make(arena, caps, views, numActiveViews,
Brian Salomonccb61422020-01-09 10:46:36 -0500643 GrSamplerState::Filter::kBilerp,
Brian Salomon5c6ac642017-12-19 11:09:32 -0500644 fDFGPFlags, localMatrix);
joshualitta751c972015-11-20 13:37:32 -0800645#endif
646 }
joshualitta751c972015-11-20 13:37:32 -0800647}
joshualittddd22d82016-02-16 06:47:52 -0800648