blob: c31af4f9743f693d432f92f7b7ffb04019ce5b58 [file] [log] [blame]
Chris Dalton1a325d22017-07-14 15:17:41 -06001/*
2 * Copyright 2017 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 "GrCoverageCountingPathRenderer.h"
9
10#include "GrCaps.h"
11#include "GrClip.h"
Robert Phillips777707b2018-01-17 11:40:14 -050012#include "GrProxyProvider.h"
Chris Dalton1a325d22017-07-14 15:17:41 -060013#include "SkMakeUnique.h"
Chris Daltona039d3b2017-09-28 11:16:36 -060014#include "SkPathOps.h"
Chris Dalton383a2ef2018-01-08 17:21:41 -050015#include "ccpr/GrCCClipProcessor.h"
Chris Daltond7e22272018-05-23 10:17:17 -060016#include "ccpr/GrCCDrawPathsOp.h"
Chris Daltona2b5b642018-06-24 13:08:57 -060017#include "ccpr/GrCCPathCache.h"
Chris Dalton1a325d22017-07-14 15:17:41 -060018
Chris Dalton5ba36ba2018-05-09 01:08:38 -060019using PathInstance = GrCCPathProcessor::Instance;
Chris Daltona32a3c32017-12-05 10:05:21 -070020
Chris Dalton1a325d22017-07-14 15:17:41 -060021bool GrCoverageCountingPathRenderer::IsSupported(const GrCaps& caps) {
22 const GrShaderCaps& shaderCaps = *caps.shaderCaps();
Chris Daltona8fbeba2019-03-30 00:31:23 -060023 if (caps.driverBlacklistCCPR() || !caps.allowCoverageCounting() ||
24 !shaderCaps.integerSupport() || !caps.instanceAttribSupport() ||
25 !shaderCaps.floatIs32Bits() || GrCaps::kNone_MapFlags == caps.mapBufferFlags() ||
26 !caps.isConfigTexturable(kAlpha_half_GrPixelConfig) ||
27 !caps.isConfigRenderable(kAlpha_half_GrPixelConfig) ||
28 !caps.isConfigTexturable(kAlpha_8_GrPixelConfig) ||
29 !caps.isConfigRenderable(kAlpha_8_GrPixelConfig) ||
30 !caps.halfFloatVertexAttributeSupport()) {
31 return false;
32 }
33 return true;
Chris Dalton1a325d22017-07-14 15:17:41 -060034}
35
Chris Dalton383a2ef2018-01-08 17:21:41 -050036sk_sp<GrCoverageCountingPathRenderer> GrCoverageCountingPathRenderer::CreateIfSupported(
Chris Dalton351e80c2019-01-06 22:51:00 -070037 const GrCaps& caps, AllowCaching allowCaching, uint32_t contextUniqueID) {
Chris Dalton9a986cf2018-10-18 15:27:59 -060038 return sk_sp<GrCoverageCountingPathRenderer>((IsSupported(caps))
Chris Dalton351e80c2019-01-06 22:51:00 -070039 ? new GrCoverageCountingPathRenderer(allowCaching, contextUniqueID)
Chris Dalton9a986cf2018-10-18 15:27:59 -060040 : nullptr);
Chris Daltona2b5b642018-06-24 13:08:57 -060041}
42
Chris Dalton351e80c2019-01-06 22:51:00 -070043GrCoverageCountingPathRenderer::GrCoverageCountingPathRenderer(AllowCaching allowCaching,
44 uint32_t contextUniqueID) {
Chris Daltona2b5b642018-06-24 13:08:57 -060045 if (AllowCaching::kYes == allowCaching) {
Chris Dalton351e80c2019-01-06 22:51:00 -070046 fPathCache = skstd::make_unique<GrCCPathCache>(contextUniqueID);
Chris Daltona2b5b642018-06-24 13:08:57 -060047 }
48}
49
Chris Daltond7e22272018-05-23 10:17:17 -060050GrCCPerOpListPaths* GrCoverageCountingPathRenderer::lookupPendingPaths(uint32_t opListID) {
51 auto it = fPendingPaths.find(opListID);
52 if (fPendingPaths.end() == it) {
Robert Phillips774168e2018-05-31 12:43:27 -040053 sk_sp<GrCCPerOpListPaths> paths = sk_make_sp<GrCCPerOpListPaths>();
Chris Daltond7e22272018-05-23 10:17:17 -060054 it = fPendingPaths.insert(std::make_pair(opListID, std::move(paths))).first;
55 }
56 return it->second.get();
Chris Dalton5ba36ba2018-05-09 01:08:38 -060057}
58
Chris Dalton383a2ef2018-01-08 17:21:41 -050059GrPathRenderer::CanDrawPath GrCoverageCountingPathRenderer::onCanDrawPath(
60 const CanDrawPathArgs& args) const {
Chris Dalton09a7bb22018-08-31 19:53:15 +080061 const GrShape& shape = *args.fShape;
Chris Dalton09e56892019-03-13 00:22:01 -060062 if (!(AATypeFlags::kCoverage & args.fAATypeFlags) || shape.style().hasPathEffect() ||
Chris Dalton09a7bb22018-08-31 19:53:15 +080063 args.fViewMatrix->hasPerspective() || shape.inverseFilled()) {
Chris Dalton5ed44232017-09-07 13:22:46 -060064 return CanDrawPath::kNo;
Chris Dalton1a325d22017-07-14 15:17:41 -060065 }
66
67 SkPath path;
Chris Dalton09a7bb22018-08-31 19:53:15 +080068 shape.asPath(&path);
Chris Daltona2b5b642018-06-24 13:08:57 -060069
Chris Dalton82de18f2018-09-12 17:24:09 -060070 const SkStrokeRec& stroke = shape.style().strokeRec();
71 switch (stroke.getStyle()) {
Chris Dalton09a7bb22018-08-31 19:53:15 +080072 case SkStrokeRec::kFill_Style: {
73 SkRect devBounds;
74 args.fViewMatrix->mapRect(&devBounds, path.getBounds());
Chris Daltona2b5b642018-06-24 13:08:57 -060075
Chris Dalton09a7bb22018-08-31 19:53:15 +080076 SkIRect clippedIBounds;
77 devBounds.roundOut(&clippedIBounds);
78 if (!clippedIBounds.intersect(*args.fClipConservativeBounds)) {
79 // The path is completely clipped away. Our code will eventually notice this before
80 // doing any real work.
81 return CanDrawPath::kYes;
82 }
83
84 int64_t numPixels = sk_64_mul(clippedIBounds.height(), clippedIBounds.width());
85 if (path.countVerbs() > 1000 && path.countPoints() > numPixels) {
86 // This is a complicated path that has more vertices than pixels! Let's let the SW
87 // renderer have this one: It will probably be faster and a bitmap will require less
88 // total memory on the GPU than CCPR instance buffers would for the raw path data.
89 return CanDrawPath::kNo;
90 }
91
92 if (numPixels > 256 * 256) {
93 // Large paths can blow up the atlas fast. And they are not ideal for a two-pass
94 // rendering algorithm. Give the simpler direct renderers a chance before we commit
95 // to drawing it.
96 return CanDrawPath::kAsBackup;
97 }
98
99 if (args.fShape->hasUnstyledKey() && path.countVerbs() > 50) {
100 // Complex paths do better cached in an SDF, if the renderer will accept them.
101 return CanDrawPath::kAsBackup;
102 }
103
104 return CanDrawPath::kYes;
105 }
106
107 case SkStrokeRec::kStroke_Style:
108 if (!args.fViewMatrix->isSimilarity()) {
109 // The stroker currently only supports rigid-body transfoms for the stroke lines
110 // themselves. This limitation doesn't affect hairlines since their stroke lines are
111 // defined relative to device space.
112 return CanDrawPath::kNo;
113 }
114 // fallthru
Chris Dalton82de18f2018-09-12 17:24:09 -0600115 case SkStrokeRec::kHairline_Style: {
116 float inflationRadius;
117 GetStrokeDevWidth(*args.fViewMatrix, stroke, &inflationRadius);
118 if (!(inflationRadius <= kMaxBoundsInflationFromStroke)) {
119 // Let extremely wide strokes be converted to fill paths and drawn by the CCPR
120 // filler instead. (Cast the logic negatively in order to also catch r=NaN.)
121 return CanDrawPath::kNo;
122 }
123 SkASSERT(!SkScalarIsNaN(inflationRadius));
124 if (SkPathPriv::ConicWeightCnt(path)) {
125 // The stroker does not support conics yet.
126 return CanDrawPath::kNo;
127 }
128 return CanDrawPath::kYes;
129 }
Chris Dalton09a7bb22018-08-31 19:53:15 +0800130
131 case SkStrokeRec::kStrokeAndFill_Style:
132 return CanDrawPath::kNo;
Chris Daltondb91c6e2017-09-08 16:25:08 -0600133 }
134
Chris Dalton09a7bb22018-08-31 19:53:15 +0800135 SK_ABORT("Invalid stroke style.");
136 return CanDrawPath::kNo;
Chris Dalton1a325d22017-07-14 15:17:41 -0600137}
138
139bool GrCoverageCountingPathRenderer::onDrawPath(const DrawPathArgs& args) {
140 SkASSERT(!fFlushing);
Chris Dalton1a325d22017-07-14 15:17:41 -0600141
Chris Dalton5ba36ba2018-05-09 01:08:38 -0600142 SkIRect clipIBounds;
143 GrRenderTargetContext* rtc = args.fRenderTargetContext;
144 args.fClip->getConservativeBounds(rtc->width(), rtc->height(), &clipIBounds, nullptr);
145
Chris Dalton09a7bb22018-08-31 19:53:15 +0800146 auto op = GrCCDrawPathsOp::Make(args.fContext, clipIBounds, *args.fViewMatrix, *args.fShape,
147 std::move(args.fPaint));
Chris Dalton42c21152018-06-13 15:28:19 -0600148 this->recordOp(std::move(op), args);
Chris Dalton1a325d22017-07-14 15:17:41 -0600149 return true;
150}
151
Brian Salomon348a0372018-10-31 10:42:18 -0400152void GrCoverageCountingPathRenderer::recordOp(std::unique_ptr<GrCCDrawPathsOp> op,
Chris Dalton42c21152018-06-13 15:28:19 -0600153 const DrawPathArgs& args) {
Brian Salomon348a0372018-10-31 10:42:18 -0400154 if (op) {
155 auto addToOwningPerOpListPaths = [this](GrOp* op, uint32_t opListID) {
156 op->cast<GrCCDrawPathsOp>()->addToOwningPerOpListPaths(
157 sk_ref_sp(this->lookupPendingPaths(opListID)));
158 };
159 args.fRenderTargetContext->addDrawOp(*args.fClip, std::move(op), addToOwningPerOpListPaths);
Chris Dalton42c21152018-06-13 15:28:19 -0600160 }
161}
162
Chris Dalton383a2ef2018-01-08 17:21:41 -0500163std::unique_ptr<GrFragmentProcessor> GrCoverageCountingPathRenderer::makeClipProcessor(
Chris Dalton4c458b12018-06-16 17:22:59 -0600164 uint32_t opListID, const SkPath& deviceSpacePath, const SkIRect& accessRect, int rtWidth,
165 int rtHeight, const GrCaps& caps) {
Chris Dalton383a2ef2018-01-08 17:21:41 -0500166 using MustCheckBounds = GrCCClipProcessor::MustCheckBounds;
Chris Daltona32a3c32017-12-05 10:05:21 -0700167
168 SkASSERT(!fFlushing);
Chris Daltona32a3c32017-12-05 10:05:21 -0700169
Chris Dalton5ba36ba2018-05-09 01:08:38 -0600170 GrCCClipPath& clipPath =
Chris Daltond7e22272018-05-23 10:17:17 -0600171 this->lookupPendingPaths(opListID)->fClipPaths[deviceSpacePath.getGenerationID()];
Chris Dalton5ba36ba2018-05-09 01:08:38 -0600172 if (!clipPath.isInitialized()) {
Chris Daltona32a3c32017-12-05 10:05:21 -0700173 // This ClipPath was just created during lookup. Initialize it.
Chris Dalton5ba36ba2018-05-09 01:08:38 -0600174 const SkRect& pathDevBounds = deviceSpacePath.getBounds();
175 if (SkTMax(pathDevBounds.height(), pathDevBounds.width()) > kPathCropThreshold) {
176 // The path is too large. Crop it or analytic AA can run out of fp32 precision.
177 SkPath croppedPath;
Chris Dalton4c458b12018-06-16 17:22:59 -0600178 int maxRTSize = caps.maxRenderTargetSize();
Chris Dalton09a7bb22018-08-31 19:53:15 +0800179 CropPath(deviceSpacePath, SkIRect::MakeWH(maxRTSize, maxRTSize), &croppedPath);
Chris Dalton4c458b12018-06-16 17:22:59 -0600180 clipPath.init(croppedPath, accessRect, rtWidth, rtHeight, caps);
Chris Dalton5ba36ba2018-05-09 01:08:38 -0600181 } else {
Chris Dalton4c458b12018-06-16 17:22:59 -0600182 clipPath.init(deviceSpacePath, accessRect, rtWidth, rtHeight, caps);
Chris Dalton5ba36ba2018-05-09 01:08:38 -0600183 }
Chris Daltona32a3c32017-12-05 10:05:21 -0700184 } else {
185 clipPath.addAccess(accessRect);
186 }
187
188 bool mustCheckBounds = !clipPath.pathDevIBounds().contains(accessRect);
Chris Dalton383a2ef2018-01-08 17:21:41 -0500189 return skstd::make_unique<GrCCClipProcessor>(&clipPath, MustCheckBounds(mustCheckBounds),
190 deviceSpacePath.getFillType());
Chris Daltona32a3c32017-12-05 10:05:21 -0700191}
192
Chris Dalton1a325d22017-07-14 15:17:41 -0600193void GrCoverageCountingPathRenderer::preFlush(GrOnFlushResourceProvider* onFlushRP,
194 const uint32_t* opListIDs, int numOpListIDs,
Chris Dalton9414c962018-06-14 10:14:50 -0600195 SkTArray<sk_sp<GrRenderTargetContext>>* out) {
Chris Dalton351e80c2019-01-06 22:51:00 -0700196 using DoCopiesToA8Coverage = GrCCDrawPathsOp::DoCopiesToA8Coverage;
Chris Daltona32a3c32017-12-05 10:05:21 -0700197 SkASSERT(!fFlushing);
Chris Daltond7e22272018-05-23 10:17:17 -0600198 SkASSERT(fFlushingPaths.empty());
Chris Dalton383a2ef2018-01-08 17:21:41 -0500199 SkDEBUGCODE(fFlushing = true);
Chris Daltona32a3c32017-12-05 10:05:21 -0700200
Chris Dalton351e80c2019-01-06 22:51:00 -0700201 if (fPathCache) {
202 fPathCache->doPreFlushProcessing();
Chris Dalton4da70192018-06-18 09:51:36 -0600203 }
204
Chris Daltond7e22272018-05-23 10:17:17 -0600205 if (fPendingPaths.empty()) {
Chris Dalton383a2ef2018-01-08 17:21:41 -0500206 return; // Nothing to draw.
Chris Daltona32a3c32017-12-05 10:05:21 -0700207 }
Chris Daltonc1e59632017-09-05 00:30:07 -0600208
Chris Dalton4da70192018-06-18 09:51:36 -0600209 GrCCPerFlushResourceSpecs specs;
Chris Dalton42c21152018-06-13 15:28:19 -0600210 int maxPreferredRTSize = onFlushRP->caps()->maxPreferredRenderTargetSize();
Chris Dalton4da70192018-06-18 09:51:36 -0600211 specs.fCopyAtlasSpecs.fMaxPreferredTextureSize = SkTMin(2048, maxPreferredRTSize);
212 SkASSERT(0 == specs.fCopyAtlasSpecs.fMinTextureSize);
213 specs.fRenderedAtlasSpecs.fMaxPreferredTextureSize = maxPreferredRTSize;
Chris Daltona2b5b642018-06-24 13:08:57 -0600214 specs.fRenderedAtlasSpecs.fMinTextureSize = SkTMin(512, maxPreferredRTSize);
Chris Dalton42c21152018-06-13 15:28:19 -0600215
Chris Daltond7e22272018-05-23 10:17:17 -0600216 // Move the per-opList paths that are about to be flushed from fPendingPaths to fFlushingPaths,
Chris Dalton42c21152018-06-13 15:28:19 -0600217 // and count them up so we can preallocate buffers.
Chris Daltond7e22272018-05-23 10:17:17 -0600218 fFlushingPaths.reserve(numOpListIDs);
Chris Dalton1a325d22017-07-14 15:17:41 -0600219 for (int i = 0; i < numOpListIDs; ++i) {
Chris Daltond7e22272018-05-23 10:17:17 -0600220 auto iter = fPendingPaths.find(opListIDs[i]);
221 if (fPendingPaths.end() == iter) {
222 continue; // No paths on this opList.
Chris Dalton1a325d22017-07-14 15:17:41 -0600223 }
Chris Daltona32a3c32017-12-05 10:05:21 -0700224
tzikbdb49562018-05-28 14:58:00 +0900225 fFlushingPaths.push_back(std::move(iter->second));
Chris Daltond7e22272018-05-23 10:17:17 -0600226 fPendingPaths.erase(iter);
227
Chris Dalton4da70192018-06-18 09:51:36 -0600228 for (GrCCDrawPathsOp* op : fFlushingPaths.back()->fDrawOps) {
Chris Dalton351e80c2019-01-06 22:51:00 -0700229 op->accountForOwnPaths(fPathCache.get(), onFlushRP, &specs);
Chris Dalton080baa42017-11-06 14:19:19 -0700230 }
Chris Daltond7e22272018-05-23 10:17:17 -0600231 for (const auto& clipsIter : fFlushingPaths.back()->fClipPaths) {
Chris Dalton4da70192018-06-18 09:51:36 -0600232 clipsIter.second.accountForOwnPath(&specs);
Chris Daltona32a3c32017-12-05 10:05:21 -0700233 }
Chris Dalton1a325d22017-07-14 15:17:41 -0600234 }
235
Chris Dalton4da70192018-06-18 09:51:36 -0600236 if (specs.isEmpty()) {
Chris Dalton383a2ef2018-01-08 17:21:41 -0500237 return; // Nothing to draw.
Chris Dalton1a325d22017-07-14 15:17:41 -0600238 }
239
Chris Dalton4da70192018-06-18 09:51:36 -0600240 // Determine if there are enough reusable paths from last flush for it to be worth our time to
241 // copy them to cached atlas(es).
Chris Dalton09a7bb22018-08-31 19:53:15 +0800242 int numCopies = specs.fNumCopiedPaths[GrCCPerFlushResourceSpecs::kFillIdx] +
243 specs.fNumCopiedPaths[GrCCPerFlushResourceSpecs::kStrokeIdx];
Chris Dalton351e80c2019-01-06 22:51:00 -0700244 auto doCopies = DoCopiesToA8Coverage(numCopies > 100 ||
245 specs.fCopyAtlasSpecs.fApproxNumPixels > 256 * 256);
246 if (numCopies && DoCopiesToA8Coverage::kNo == doCopies) {
247 specs.cancelCopies();
Chris Dalton4da70192018-06-18 09:51:36 -0600248 }
249
250 auto resources = sk_make_sp<GrCCPerFlushResources>(onFlushRP, specs);
Chris Dalton5ba36ba2018-05-09 01:08:38 -0600251 if (!resources->isMapped()) {
252 return; // Some allocation failed.
Chris Dalton1a325d22017-07-14 15:17:41 -0600253 }
254
Chris Dalton4da70192018-06-18 09:51:36 -0600255 // Layout the atlas(es) and parse paths.
Chris Daltond7e22272018-05-23 10:17:17 -0600256 for (const auto& flushingPaths : fFlushingPaths) {
257 for (GrCCDrawPathsOp* op : flushingPaths->fDrawOps) {
Chris Dalton351e80c2019-01-06 22:51:00 -0700258 op->setupResources(fPathCache.get(), onFlushRP, resources.get(), doCopies);
Chris Dalton1a325d22017-07-14 15:17:41 -0600259 }
Chris Daltond7e22272018-05-23 10:17:17 -0600260 for (auto& clipsIter : flushingPaths->fClipPaths) {
Chris Daltondaef06a2018-05-23 17:11:09 -0600261 clipsIter.second.renderPathInAtlas(resources.get(), onFlushRP);
Chris Daltonc1e59632017-09-05 00:30:07 -0600262 }
Chris Dalton1a325d22017-07-14 15:17:41 -0600263 }
264
Chris Dalton351e80c2019-01-06 22:51:00 -0700265 if (fPathCache) {
266 // Purge invalidated textures from previous atlases *before* calling finalize(). That way,
267 // the underlying textures objects can be freed up and reused for the next atlases.
268 fPathCache->purgeInvalidatedAtlasTextures(onFlushRP);
Chris Daltond6fa4542019-01-04 13:23:51 -0700269 }
Chris Dalton1a325d22017-07-14 15:17:41 -0600270
Chris Dalton351e80c2019-01-06 22:51:00 -0700271 // Allocate resources and then render the atlas(es).
272 if (!resources->finalize(onFlushRP, out)) {
273 return;
274 }
Chris Dalton2e825a32019-01-04 22:14:27 +0000275
Chris Daltond7e22272018-05-23 10:17:17 -0600276 // Commit flushing paths to the resources once they are successfully completed.
277 for (auto& flushingPaths : fFlushingPaths) {
Robert Phillips774168e2018-05-31 12:43:27 -0400278 SkASSERT(!flushingPaths->fFlushResources);
Chris Daltond7e22272018-05-23 10:17:17 -0600279 flushingPaths->fFlushResources = resources;
280 }
Chris Dalton1a325d22017-07-14 15:17:41 -0600281}
282
Chris Dalton3968ff92017-11-27 12:26:31 -0700283void GrCoverageCountingPathRenderer::postFlush(GrDeferredUploadToken, const uint32_t* opListIDs,
284 int numOpListIDs) {
Chris Dalton1a325d22017-07-14 15:17:41 -0600285 SkASSERT(fFlushing);
Robert Phillips774168e2018-05-31 12:43:27 -0400286
Chris Dalton4da70192018-06-18 09:51:36 -0600287 if (!fFlushingPaths.empty()) {
Chris Dalton4da70192018-06-18 09:51:36 -0600288 // In DDL mode these aren't guaranteed to be deleted so we must clear out the perFlush
289 // resources manually.
290 for (auto& flushingPaths : fFlushingPaths) {
291 flushingPaths->fFlushResources = nullptr;
292 }
293
294 // We wait to erase these until after flush, once Ops and FPs are done accessing their data.
295 fFlushingPaths.reset();
Robert Phillips774168e2018-05-31 12:43:27 -0400296 }
297
Chris Dalton383a2ef2018-01-08 17:21:41 -0500298 SkDEBUGCODE(fFlushing = false);
Chris Dalton1a325d22017-07-14 15:17:41 -0600299}
Chris Dalton09a7bb22018-08-31 19:53:15 +0800300
Chris Dalton6c3879d2018-11-01 11:13:19 -0600301void GrCoverageCountingPathRenderer::purgeCacheEntriesOlderThan(
Chris Dalton351e80c2019-01-06 22:51:00 -0700302 GrProxyProvider* proxyProvider, const GrStdSteadyClock::time_point& purgeTime) {
Chris Dalton6c3879d2018-11-01 11:13:19 -0600303 if (fPathCache) {
Chris Dalton351e80c2019-01-06 22:51:00 -0700304 fPathCache->purgeEntriesOlderThan(proxyProvider, purgeTime);
Chris Dalton6c3879d2018-11-01 11:13:19 -0600305 }
306}
307
Chris Dalton09a7bb22018-08-31 19:53:15 +0800308void GrCoverageCountingPathRenderer::CropPath(const SkPath& path, const SkIRect& cropbox,
309 SkPath* out) {
310 SkPath cropboxPath;
311 cropboxPath.addRect(SkRect::Make(cropbox));
312 if (!Op(cropboxPath, path, kIntersect_SkPathOp, out)) {
313 // This can fail if the PathOps encounter NaN or infinities.
314 out->reset();
315 }
316 out->setIsVolatile(true);
317}
Chris Dalton82de18f2018-09-12 17:24:09 -0600318
319float GrCoverageCountingPathRenderer::GetStrokeDevWidth(const SkMatrix& m,
320 const SkStrokeRec& stroke,
321 float* inflationRadius) {
322 float strokeDevWidth;
323 if (stroke.isHairlineStyle()) {
324 strokeDevWidth = 1;
325 } else {
326 SkASSERT(SkStrokeRec::kStroke_Style == stroke.getStyle());
327 SkASSERT(m.isSimilarity()); // Otherwise matrixScaleFactor = m.getMaxScale().
328 float matrixScaleFactor = SkVector::Length(m.getScaleX(), m.getSkewY());
329 strokeDevWidth = stroke.getWidth() * matrixScaleFactor;
330 }
331 if (inflationRadius) {
332 // Inflate for a minimum stroke width of 1. In some cases when the stroke is less than 1px
333 // wide, we may inflate it to 1px and instead reduce the opacity.
334 *inflationRadius = SkStrokeRec::GetInflationRadius(
335 stroke.getJoin(), stroke.getMiter(), stroke.getCap(), SkTMax(strokeDevWidth, 1.f));
336 }
337 return strokeDevWidth;
338}