blob: dfd5ba4886429a83c7624b94ebf534db8844fddf [file] [log] [blame]
Jim Van Verth43475ad2017-01-13 14:37:37 -05001/*
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 "SkShadowUtils.h"
Mike Reed8e03f692018-03-09 16:18:56 -05009#include "SkBlurMask.h"
Jim Van Verth43475ad2017-01-13 14:37:37 -050010#include "SkCanvas.h"
Jim Van Verthefe3ded2017-01-30 13:11:45 -050011#include "SkColorFilter.h"
Cary Clarka4083c92017-09-15 11:59:23 -040012#include "SkColorData.h"
Mike Reed4204da22017-05-17 08:53:36 -040013#include "SkDevice.h"
Jim Van Verth1af03d42017-07-31 09:34:58 -040014#include "SkDrawShadowInfo.h"
Cary Clark4dc5a452018-05-21 11:56:57 -040015#include "SkFlattenablePriv.h"
Mike Reed18e75562018-03-12 14:03:47 -040016#include "SkMaskFilter.h"
Jim Van Verthefe3ded2017-01-30 13:11:45 -050017#include "SkPath.h"
Mike Reedb9641bd2017-05-04 10:57:40 -040018#include "SkPM4f.h"
Brian Salomond1ac9822017-02-03 14:25:02 -050019#include "SkRandom.h"
Mike Reed65331592017-05-24 16:45:34 -040020#include "SkRasterPipeline.h"
Brian Salomon5e689522017-02-01 12:07:17 -050021#include "SkResourceCache.h"
Jim Van Verthefe3ded2017-01-30 13:11:45 -050022#include "SkShadowTessellator.h"
Ben Wagner4d1955c2017-03-10 13:08:15 -050023#include "SkString.h"
Brian Salomon5e689522017-02-01 12:07:17 -050024#include "SkTLazy.h"
Brian Salomonaff27a22017-02-06 15:47:44 -050025#include "SkVertices.h"
Brian Salomon5e689522017-02-01 12:07:17 -050026#if SK_SUPPORT_GPU
27#include "GrShape.h"
28#include "effects/GrBlurredEdgeFragmentProcessor.h"
Mike Reed4204da22017-05-17 08:53:36 -040029#endif
Jim Van Verthefe3ded2017-01-30 13:11:45 -050030
31/**
32* Gaussian color filter -- produces a Gaussian ramp based on the color's B value,
33* then blends with the color's G value.
34* Final result is black with alpha of Gaussian(B)*G.
35* The assumption is that the original color's alpha is 1.
36*/
Mike Reed57c2b8b2017-12-31 15:23:54 -050037class SkGaussianColorFilter : public SkColorFilter {
Jim Van Verthefe3ded2017-01-30 13:11:45 -050038public:
39 static sk_sp<SkColorFilter> Make() {
40 return sk_sp<SkColorFilter>(new SkGaussianColorFilter);
41 }
42
Jim Van Verthefe3ded2017-01-30 13:11:45 -050043#if SK_SUPPORT_GPU
Brian Salomon4cbb6e62017-10-25 15:12:19 -040044 std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
45 GrContext*, const GrColorSpaceInfo&) const override;
Jim Van Verthefe3ded2017-01-30 13:11:45 -050046#endif
47
Cary Clark32a49102018-05-20 23:15:43 +000048 void toString(SkString* str) const override;
Jim Van Verthefe3ded2017-01-30 13:11:45 -050049 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkGaussianColorFilter)
50
51protected:
52 void flatten(SkWriteBuffer&) const override {}
Mike Reed65331592017-05-24 16:45:34 -040053 void onAppendStages(SkRasterPipeline* pipeline, SkColorSpace* dstCS, SkArenaAlloc* alloc,
54 bool shaderIsOpaque) const override {
55 pipeline->append(SkRasterPipeline::gauss_a_to_rgba);
56 }
Jim Van Verthefe3ded2017-01-30 13:11:45 -050057private:
58 SkGaussianColorFilter() : INHERITED() {}
59
60 typedef SkColorFilter INHERITED;
61};
62
Jim Van Verthefe3ded2017-01-30 13:11:45 -050063sk_sp<SkFlattenable> SkGaussianColorFilter::CreateProc(SkReadBuffer&) {
64 return Make();
65}
66
Cary Clark32a49102018-05-20 23:15:43 +000067void SkGaussianColorFilter::toString(SkString* str) const {
68 str->append("SkGaussianColorFilter ");
69}
70
Jim Van Verthefe3ded2017-01-30 13:11:45 -050071#if SK_SUPPORT_GPU
Jim Van Verthefe3ded2017-01-30 13:11:45 -050072
Brian Salomonaff329b2017-08-11 09:40:37 -040073std::unique_ptr<GrFragmentProcessor> SkGaussianColorFilter::asFragmentProcessor(
Brian Salomon4cbb6e62017-10-25 15:12:19 -040074 GrContext*, const GrColorSpaceInfo&) const {
Ethan Nicholasaae47c82017-11-10 15:34:03 -050075 return GrBlurredEdgeFragmentProcessor::Make(GrBlurredEdgeFragmentProcessor::Mode::kGaussian);
Jim Van Verthefe3ded2017-01-30 13:11:45 -050076}
77#endif
78
79///////////////////////////////////////////////////////////////////////////////////////////////////
Brian Salomon5e689522017-02-01 12:07:17 -050080
81namespace {
82
Brian Salomonbc9956d2017-02-22 13:49:09 -050083uint64_t resource_cache_shared_id() {
84 return 0x2020776f64616873llu; // 'shadow '
85}
86
Brian Salomond1ac9822017-02-03 14:25:02 -050087/** Factory for an ambient shadow mesh with particular shadow properties. */
Brian Salomon5e689522017-02-01 12:07:17 -050088struct AmbientVerticesFactory {
Jim Van Verthb4366552017-03-27 14:25:29 -040089 SkScalar fOccluderHeight = SK_ScalarNaN; // NaN so that isCompatible will fail until init'ed.
Brian Salomon5e689522017-02-01 12:07:17 -050090 bool fTransparent;
Jim Van Verth8793e382017-05-22 15:52:21 -040091 SkVector fOffset;
Brian Salomon5e689522017-02-01 12:07:17 -050092
Brian Salomond1ac9822017-02-03 14:25:02 -050093 bool isCompatible(const AmbientVerticesFactory& that, SkVector* translate) const {
Jim Van Verth060d9822017-05-04 09:58:17 -040094 if (fOccluderHeight != that.fOccluderHeight || fTransparent != that.fTransparent) {
Brian Salomond1ac9822017-02-03 14:25:02 -050095 return false;
96 }
Jim Van Verth8793e382017-05-22 15:52:21 -040097 *translate = that.fOffset;
Brian Salomond1ac9822017-02-03 14:25:02 -050098 return true;
Brian Salomon5e689522017-02-01 12:07:17 -050099 }
Brian Salomon5e689522017-02-01 12:07:17 -0500100
Jim Van Verth8793e382017-05-22 15:52:21 -0400101 sk_sp<SkVertices> makeVertices(const SkPath& path, const SkMatrix& ctm,
102 SkVector* translate) const {
Jim Van Verthe308a122017-05-08 14:19:30 -0400103 SkPoint3 zParams = SkPoint3::Make(0, 0, fOccluderHeight);
Jim Van Verth8793e382017-05-22 15:52:21 -0400104 // pick a canonical place to generate shadow
105 SkMatrix noTrans(ctm);
106 if (!ctm.hasPerspective()) {
107 noTrans[SkMatrix::kMTransX] = 0;
108 noTrans[SkMatrix::kMTransY] = 0;
109 }
110 *translate = fOffset;
111 return SkShadowTessellator::MakeAmbient(path, noTrans, zParams, fTransparent);
Brian Salomon5e689522017-02-01 12:07:17 -0500112 }
113};
114
Brian Salomond1ac9822017-02-03 14:25:02 -0500115/** Factory for an spot shadow mesh with particular shadow properties. */
Brian Salomon5e689522017-02-01 12:07:17 -0500116struct SpotVerticesFactory {
Brian Salomond1ac9822017-02-03 14:25:02 -0500117 enum class OccluderType {
Jim Van Verth8793e382017-05-22 15:52:21 -0400118 // The umbra cannot be dropped out because either the occluder is not opaque,
119 // or the center of the umbra is visible.
Brian Salomond1ac9822017-02-03 14:25:02 -0500120 kTransparent,
121 // The umbra can be dropped where it is occluded.
Jim Van Verth78c8f302017-05-15 10:44:22 -0400122 kOpaquePartialUmbra,
Brian Salomond1ac9822017-02-03 14:25:02 -0500123 // It is known that the entire umbra is occluded.
Jim Van Verth78c8f302017-05-15 10:44:22 -0400124 kOpaqueNoUmbra
Brian Salomond1ac9822017-02-03 14:25:02 -0500125 };
126
Brian Salomon5e689522017-02-01 12:07:17 -0500127 SkVector fOffset;
Jim Van Verth8793e382017-05-22 15:52:21 -0400128 SkPoint fLocalCenter;
Jim Van Verthb4366552017-03-27 14:25:29 -0400129 SkScalar fOccluderHeight = SK_ScalarNaN; // NaN so that isCompatible will fail until init'ed.
130 SkPoint3 fDevLightPos;
131 SkScalar fLightRadius;
Brian Salomond1ac9822017-02-03 14:25:02 -0500132 OccluderType fOccluderType;
Brian Salomon5e689522017-02-01 12:07:17 -0500133
Brian Salomond1ac9822017-02-03 14:25:02 -0500134 bool isCompatible(const SpotVerticesFactory& that, SkVector* translate) const {
Jim Van Verthb4366552017-03-27 14:25:29 -0400135 if (fOccluderHeight != that.fOccluderHeight || fDevLightPos.fZ != that.fDevLightPos.fZ ||
Jim Van Verth060d9822017-05-04 09:58:17 -0400136 fLightRadius != that.fLightRadius || fOccluderType != that.fOccluderType) {
Brian Salomond1ac9822017-02-03 14:25:02 -0500137 return false;
138 }
139 switch (fOccluderType) {
140 case OccluderType::kTransparent:
Jim Van Verth78c8f302017-05-15 10:44:22 -0400141 case OccluderType::kOpaqueNoUmbra:
Brian Salomond1ac9822017-02-03 14:25:02 -0500142 // 'this' and 'that' will either both have no umbra removed or both have all the
143 // umbra removed.
Jim Van Verth8793e382017-05-22 15:52:21 -0400144 *translate = that.fOffset;
Brian Salomond1ac9822017-02-03 14:25:02 -0500145 return true;
Jim Van Verth78c8f302017-05-15 10:44:22 -0400146 case OccluderType::kOpaquePartialUmbra:
Brian Salomond1ac9822017-02-03 14:25:02 -0500147 // In this case we partially remove the umbra differently for 'this' and 'that'
148 // if the offsets don't match.
149 if (fOffset == that.fOffset) {
150 translate->set(0, 0);
151 return true;
152 }
153 return false;
154 }
Ben Wagnerb4aab9a2017-08-16 10:53:04 -0400155 SK_ABORT("Uninitialized occluder type?");
Brian Salomond1ac9822017-02-03 14:25:02 -0500156 return false;
Brian Salomon5e689522017-02-01 12:07:17 -0500157 }
Brian Salomon5e689522017-02-01 12:07:17 -0500158
Jim Van Verth8793e382017-05-22 15:52:21 -0400159 sk_sp<SkVertices> makeVertices(const SkPath& path, const SkMatrix& ctm,
160 SkVector* translate) const {
Brian Salomond1ac9822017-02-03 14:25:02 -0500161 bool transparent = OccluderType::kTransparent == fOccluderType;
Jim Van Verthe308a122017-05-08 14:19:30 -0400162 SkPoint3 zParams = SkPoint3::Make(0, 0, fOccluderHeight);
Jim Van Verth8793e382017-05-22 15:52:21 -0400163 if (ctm.hasPerspective() || OccluderType::kOpaquePartialUmbra == fOccluderType) {
164 translate->set(0, 0);
165 return SkShadowTessellator::MakeSpot(path, ctm, zParams,
166 fDevLightPos, fLightRadius, transparent);
167 } else {
168 // pick a canonical place to generate shadow, with light centered over path
169 SkMatrix noTrans(ctm);
170 noTrans[SkMatrix::kMTransX] = 0;
171 noTrans[SkMatrix::kMTransY] = 0;
172 SkPoint devCenter(fLocalCenter);
173 noTrans.mapPoints(&devCenter, 1);
174 SkPoint3 centerLightPos = SkPoint3::Make(devCenter.fX, devCenter.fY, fDevLightPos.fZ);
175 *translate = fOffset;
176 return SkShadowTessellator::MakeSpot(path, noTrans, zParams,
177 centerLightPos, fLightRadius, transparent);
178 }
Brian Salomon5e689522017-02-01 12:07:17 -0500179 }
180};
181
182/**
Brian Salomond1ac9822017-02-03 14:25:02 -0500183 * This manages a set of tessellations for a given shape in the cache. Because SkResourceCache
184 * records are immutable this is not itself a Rec. When we need to update it we return this on
Jim Van Vertheb63eb72017-05-23 09:40:02 -0400185 * the FindVisitor and let the cache destroy the Rec. We'll update the tessellations and then add
Brian Salomond1ac9822017-02-03 14:25:02 -0500186 * a new Rec with an adjusted size for any deletions/additions.
Brian Salomon5e689522017-02-01 12:07:17 -0500187 */
Brian Salomond1ac9822017-02-03 14:25:02 -0500188class CachedTessellations : public SkRefCnt {
Brian Salomon5e689522017-02-01 12:07:17 -0500189public:
Brian Salomond1ac9822017-02-03 14:25:02 -0500190 size_t size() const { return fAmbientSet.size() + fSpotSet.size(); }
191
Brian Salomonaff27a22017-02-06 15:47:44 -0500192 sk_sp<SkVertices> find(const AmbientVerticesFactory& ambient, const SkMatrix& matrix,
193 SkVector* translate) const {
Brian Salomond1ac9822017-02-03 14:25:02 -0500194 return fAmbientSet.find(ambient, matrix, translate);
195 }
196
Brian Salomonaff27a22017-02-06 15:47:44 -0500197 sk_sp<SkVertices> add(const SkPath& devPath, const AmbientVerticesFactory& ambient,
Jim Van Verth8793e382017-05-22 15:52:21 -0400198 const SkMatrix& matrix, SkVector* translate) {
199 return fAmbientSet.add(devPath, ambient, matrix, translate);
Brian Salomond1ac9822017-02-03 14:25:02 -0500200 }
201
Brian Salomonaff27a22017-02-06 15:47:44 -0500202 sk_sp<SkVertices> find(const SpotVerticesFactory& spot, const SkMatrix& matrix,
203 SkVector* translate) const {
Brian Salomond1ac9822017-02-03 14:25:02 -0500204 return fSpotSet.find(spot, matrix, translate);
205 }
206
Brian Salomonaff27a22017-02-06 15:47:44 -0500207 sk_sp<SkVertices> add(const SkPath& devPath, const SpotVerticesFactory& spot,
Jim Van Verth8793e382017-05-22 15:52:21 -0400208 const SkMatrix& matrix, SkVector* translate) {
209 return fSpotSet.add(devPath, spot, matrix, translate);
Brian Salomond1ac9822017-02-03 14:25:02 -0500210 }
211
212private:
213 template <typename FACTORY, int MAX_ENTRIES>
214 class Set {
215 public:
216 size_t size() const { return fSize; }
217
Brian Salomonaff27a22017-02-06 15:47:44 -0500218 sk_sp<SkVertices> find(const FACTORY& factory, const SkMatrix& matrix,
219 SkVector* translate) const {
Brian Salomond1ac9822017-02-03 14:25:02 -0500220 for (int i = 0; i < MAX_ENTRIES; ++i) {
221 if (fEntries[i].fFactory.isCompatible(factory, translate)) {
222 const SkMatrix& m = fEntries[i].fMatrix;
223 if (matrix.hasPerspective() || m.hasPerspective()) {
224 if (matrix != fEntries[i].fMatrix) {
225 continue;
226 }
227 } else if (matrix.getScaleX() != m.getScaleX() ||
228 matrix.getSkewX() != m.getSkewX() ||
229 matrix.getScaleY() != m.getScaleY() ||
230 matrix.getSkewY() != m.getSkewY()) {
231 continue;
232 }
Brian Salomond1ac9822017-02-03 14:25:02 -0500233 return fEntries[i].fVertices;
234 }
235 }
236 return nullptr;
237 }
238
Jim Van Verth8793e382017-05-22 15:52:21 -0400239 sk_sp<SkVertices> add(const SkPath& path, const FACTORY& factory, const SkMatrix& matrix,
240 SkVector* translate) {
241 sk_sp<SkVertices> vertices = factory.makeVertices(path, matrix, translate);
Brian Salomond1ac9822017-02-03 14:25:02 -0500242 if (!vertices) {
243 return nullptr;
244 }
245 int i;
246 if (fCount < MAX_ENTRIES) {
247 i = fCount++;
248 } else {
Jim Van Vertheb63eb72017-05-23 09:40:02 -0400249 i = fRandom.nextULessThan(MAX_ENTRIES);
Mike Reedaa9e3322017-03-16 14:38:48 -0400250 fSize -= fEntries[i].fVertices->approximateSize();
Brian Salomond1ac9822017-02-03 14:25:02 -0500251 }
252 fEntries[i].fFactory = factory;
253 fEntries[i].fVertices = vertices;
254 fEntries[i].fMatrix = matrix;
Mike Reedaa9e3322017-03-16 14:38:48 -0400255 fSize += vertices->approximateSize();
Brian Salomond1ac9822017-02-03 14:25:02 -0500256 return vertices;
257 }
258
259 private:
260 struct Entry {
261 FACTORY fFactory;
Brian Salomonaff27a22017-02-06 15:47:44 -0500262 sk_sp<SkVertices> fVertices;
Brian Salomond1ac9822017-02-03 14:25:02 -0500263 SkMatrix fMatrix;
264 };
265 Entry fEntries[MAX_ENTRIES];
266 int fCount = 0;
267 size_t fSize = 0;
Jim Van Vertheb63eb72017-05-23 09:40:02 -0400268 SkRandom fRandom;
Brian Salomond1ac9822017-02-03 14:25:02 -0500269 };
270
271 Set<AmbientVerticesFactory, 4> fAmbientSet;
272 Set<SpotVerticesFactory, 4> fSpotSet;
Brian Salomond1ac9822017-02-03 14:25:02 -0500273};
274
Brian Salomond1ac9822017-02-03 14:25:02 -0500275/**
276 * A record of shadow vertices stored in SkResourceCache of CachedTessellations for a particular
277 * path. The key represents the path's geometry and not any shadow params.
278 */
279class CachedTessellationsRec : public SkResourceCache::Rec {
280public:
281 CachedTessellationsRec(const SkResourceCache::Key& key,
282 sk_sp<CachedTessellations> tessellations)
283 : fTessellations(std::move(tessellations)) {
Brian Salomon5e689522017-02-01 12:07:17 -0500284 fKey.reset(new uint8_t[key.size()]);
285 memcpy(fKey.get(), &key, key.size());
286 }
287
288 const Key& getKey() const override {
289 return *reinterpret_cast<SkResourceCache::Key*>(fKey.get());
290 }
Brian Salomon5e689522017-02-01 12:07:17 -0500291
Brian Salomond1ac9822017-02-03 14:25:02 -0500292 size_t bytesUsed() const override { return fTessellations->size(); }
Brian Salomon5e689522017-02-01 12:07:17 -0500293
Brian Salomond1ac9822017-02-03 14:25:02 -0500294 const char* getCategory() const override { return "tessellated shadow masks"; }
Brian Salomon5e689522017-02-01 12:07:17 -0500295
Brian Salomond1ac9822017-02-03 14:25:02 -0500296 sk_sp<CachedTessellations> refTessellations() const { return fTessellations; }
Brian Salomon5e689522017-02-01 12:07:17 -0500297
Brian Salomond1ac9822017-02-03 14:25:02 -0500298 template <typename FACTORY>
Brian Salomonaff27a22017-02-06 15:47:44 -0500299 sk_sp<SkVertices> find(const FACTORY& factory, const SkMatrix& matrix,
300 SkVector* translate) const {
Brian Salomond1ac9822017-02-03 14:25:02 -0500301 return fTessellations->find(factory, matrix, translate);
302 }
Brian Salomon5e689522017-02-01 12:07:17 -0500303
304private:
305 std::unique_ptr<uint8_t[]> fKey;
Brian Salomond1ac9822017-02-03 14:25:02 -0500306 sk_sp<CachedTessellations> fTessellations;
Brian Salomon5e689522017-02-01 12:07:17 -0500307};
308
309/**
310 * Used by FindVisitor to determine whether a cache entry can be reused and if so returns the
Brian Salomond1ac9822017-02-03 14:25:02 -0500311 * vertices and a translation vector. If the CachedTessellations does not contain a suitable
312 * mesh then we inform SkResourceCache to destroy the Rec and we return the CachedTessellations
313 * to the caller. The caller will update it and reinsert it back into the cache.
Brian Salomon5e689522017-02-01 12:07:17 -0500314 */
315template <typename FACTORY>
316struct FindContext {
317 FindContext(const SkMatrix* viewMatrix, const FACTORY* factory)
318 : fViewMatrix(viewMatrix), fFactory(factory) {}
Brian Salomond1ac9822017-02-03 14:25:02 -0500319 const SkMatrix* const fViewMatrix;
320 // If this is valid after Find is called then we found the vertices and they should be drawn
321 // with fTranslate applied.
Brian Salomonaff27a22017-02-06 15:47:44 -0500322 sk_sp<SkVertices> fVertices;
Brian Salomond1ac9822017-02-03 14:25:02 -0500323 SkVector fTranslate = {0, 0};
324
325 // If this is valid after Find then the caller should add the vertices to the tessellation set
326 // and create a new CachedTessellationsRec and insert it into SkResourceCache.
327 sk_sp<CachedTessellations> fTessellationsOnFailure;
328
Brian Salomon5e689522017-02-01 12:07:17 -0500329 const FACTORY* fFactory;
330};
331
332/**
333 * Function called by SkResourceCache when a matching cache key is found. The FACTORY and matrix of
334 * the FindContext are used to determine if the vertices are reusable. If so the vertices and
335 * necessary translation vector are set on the FindContext.
336 */
337template <typename FACTORY>
338bool FindVisitor(const SkResourceCache::Rec& baseRec, void* ctx) {
339 FindContext<FACTORY>* findContext = (FindContext<FACTORY>*)ctx;
Brian Salomond1ac9822017-02-03 14:25:02 -0500340 const CachedTessellationsRec& rec = static_cast<const CachedTessellationsRec&>(baseRec);
341 findContext->fVertices =
342 rec.find(*findContext->fFactory, *findContext->fViewMatrix, &findContext->fTranslate);
343 if (findContext->fVertices) {
344 return true;
Brian Salomon5e689522017-02-01 12:07:17 -0500345 }
Brian Salomond1ac9822017-02-03 14:25:02 -0500346 // We ref the tessellations and let the cache destroy the Rec. Once the tessellations have been
347 // manipulated we will add a new Rec.
348 findContext->fTessellationsOnFailure = rec.refTessellations();
349 return false;
Brian Salomon5e689522017-02-01 12:07:17 -0500350}
351
352class ShadowedPath {
353public:
354 ShadowedPath(const SkPath* path, const SkMatrix* viewMatrix)
Jim Van Vertha84898d2017-02-06 13:38:23 -0500355 : fPath(path)
Brian Salomon5e689522017-02-01 12:07:17 -0500356 , fViewMatrix(viewMatrix)
357#if SK_SUPPORT_GPU
358 , fShapeForKey(*path, GrStyle::SimpleFill())
359#endif
360 {}
361
Jim Van Vertha84898d2017-02-06 13:38:23 -0500362 const SkPath& path() const { return *fPath; }
Brian Salomon5e689522017-02-01 12:07:17 -0500363 const SkMatrix& viewMatrix() const { return *fViewMatrix; }
364#if SK_SUPPORT_GPU
365 /** Negative means the vertices should not be cached for this path. */
366 int keyBytes() const { return fShapeForKey.unstyledKeySize() * sizeof(uint32_t); }
367 void writeKey(void* key) const {
368 fShapeForKey.writeUnstyledKey(reinterpret_cast<uint32_t*>(key));
369 }
Brian Salomond1ac9822017-02-03 14:25:02 -0500370 bool isRRect(SkRRect* rrect) { return fShapeForKey.asRRect(rrect, nullptr, nullptr, nullptr); }
Brian Salomon5e689522017-02-01 12:07:17 -0500371#else
372 int keyBytes() const { return -1; }
Ben Wagnerb4aab9a2017-08-16 10:53:04 -0400373 void writeKey(void* key) const { SK_ABORT("Should never be called"); }
Brian Salomond1ac9822017-02-03 14:25:02 -0500374 bool isRRect(SkRRect* rrect) { return false; }
Brian Salomon5e689522017-02-01 12:07:17 -0500375#endif
376
377private:
Jim Van Vertha84898d2017-02-06 13:38:23 -0500378 const SkPath* fPath;
Brian Salomon5e689522017-02-01 12:07:17 -0500379 const SkMatrix* fViewMatrix;
380#if SK_SUPPORT_GPU
381 GrShape fShapeForKey;
382#endif
Brian Salomon5e689522017-02-01 12:07:17 -0500383};
384
Brian Salomond1ac9822017-02-03 14:25:02 -0500385// This creates a domain of keys in SkResourceCache used by this file.
386static void* kNamespace;
387
Brian Salomon5e689522017-02-01 12:07:17 -0500388/**
389 * Draws a shadow to 'canvas'. The vertices used to draw the shadow are created by 'factory' unless
390 * they are first found in SkResourceCache.
391 */
392template <typename FACTORY>
Jim Van Verth22526362018-02-28 14:51:19 -0500393bool draw_shadow(const FACTORY& factory,
394 std::function<void(const SkVertices*, SkBlendMode, const SkPaint&,
395 SkScalar tx, SkScalar ty)> drawProc, ShadowedPath& path, SkColor color) {
Brian Salomon5e689522017-02-01 12:07:17 -0500396 FindContext<FACTORY> context(&path.viewMatrix(), &factory);
Brian Salomon5e689522017-02-01 12:07:17 -0500397
398 SkResourceCache::Key* key = nullptr;
399 SkAutoSTArray<32 * 4, uint8_t> keyStorage;
400 int keyDataBytes = path.keyBytes();
401 if (keyDataBytes >= 0) {
402 keyStorage.reset(keyDataBytes + sizeof(SkResourceCache::Key));
403 key = new (keyStorage.begin()) SkResourceCache::Key();
404 path.writeKey((uint32_t*)(keyStorage.begin() + sizeof(*key)));
Brian Salomonbc9956d2017-02-22 13:49:09 -0500405 key->init(&kNamespace, resource_cache_shared_id(), keyDataBytes);
Jim Van Verth37c5a962017-05-10 14:13:24 -0400406 SkResourceCache::Find(*key, FindVisitor<FACTORY>, &context);
Brian Salomon5e689522017-02-01 12:07:17 -0500407 }
408
Brian Salomonaff27a22017-02-06 15:47:44 -0500409 sk_sp<SkVertices> vertices;
Brian Salomon5e689522017-02-01 12:07:17 -0500410 bool foundInCache = SkToBool(context.fVertices);
411 if (foundInCache) {
412 vertices = std::move(context.fVertices);
Brian Salomon5e689522017-02-01 12:07:17 -0500413 } else {
414 // TODO: handle transforming the path as part of the tessellator
Brian Salomond1ac9822017-02-03 14:25:02 -0500415 if (key) {
416 // Update or initialize a tessellation set and add it to the cache.
417 sk_sp<CachedTessellations> tessellations;
418 if (context.fTessellationsOnFailure) {
419 tessellations = std::move(context.fTessellationsOnFailure);
420 } else {
421 tessellations.reset(new CachedTessellations());
422 }
Jim Van Verth8793e382017-05-22 15:52:21 -0400423 vertices = tessellations->add(path.path(), factory, path.viewMatrix(),
424 &context.fTranslate);
Brian Salomond1ac9822017-02-03 14:25:02 -0500425 if (!vertices) {
Jim Van Verth22526362018-02-28 14:51:19 -0500426 return false;
Brian Salomond1ac9822017-02-03 14:25:02 -0500427 }
Brian Salomon804e0912017-02-23 09:34:03 -0500428 auto rec = new CachedTessellationsRec(*key, std::move(tessellations));
Jim Van Verth37c5a962017-05-10 14:13:24 -0400429 SkResourceCache::Add(rec);
Brian Salomond1ac9822017-02-03 14:25:02 -0500430 } else {
Jim Van Verth8793e382017-05-22 15:52:21 -0400431 vertices = factory.makeVertices(path.path(), path.viewMatrix(),
432 &context.fTranslate);
Brian Salomond1ac9822017-02-03 14:25:02 -0500433 if (!vertices) {
Jim Van Verth22526362018-02-28 14:51:19 -0500434 return false;
Brian Salomond1ac9822017-02-03 14:25:02 -0500435 }
Brian Salomon0dda9cb2017-02-03 10:33:25 -0500436 }
Brian Salomon5e689522017-02-01 12:07:17 -0500437 }
438
439 SkPaint paint;
Brian Salomon0bd699e2017-02-01 12:23:25 -0500440 // Run the vertex color through a GaussianColorFilter and then modulate the grayscale result of
441 // that against our 'color' param.
Mike Reed19d7bd62018-02-19 14:10:57 -0500442 paint.setColorFilter(
443 SkColorFilter::MakeModeFilter(color, SkBlendMode::kModulate)->makeComposed(
444 SkGaussianColorFilter::Make()));
Mike Reed4204da22017-05-17 08:53:36 -0400445
Jim Van Verth8793e382017-05-22 15:52:21 -0400446 drawProc(vertices.get(), SkBlendMode::kModulate, paint,
447 context.fTranslate.fX, context.fTranslate.fY);
Jim Van Verth22526362018-02-28 14:51:19 -0500448
449 return true;
Brian Salomon5e689522017-02-01 12:07:17 -0500450}
451}
452
Mike Reed4204da22017-05-17 08:53:36 -0400453static bool tilted(const SkPoint3& zPlaneParams) {
454 return !SkScalarNearlyZero(zPlaneParams.fX) || !SkScalarNearlyZero(zPlaneParams.fY);
455}
Jim Van Verthe7e1d9d2017-05-01 16:06:48 -0400456
Mike Reed4204da22017-05-17 08:53:36 -0400457static SkPoint3 map(const SkMatrix& m, const SkPoint3& pt) {
458 SkPoint3 result;
459 m.mapXY(pt.fX, pt.fY, (SkPoint*)&result.fX);
460 result.fZ = pt.fZ;
461 return result;
462}
463
Jim Van Verthb1b80f72018-01-18 15:19:13 -0500464void SkShadowUtils::ComputeTonalColors(SkColor inAmbientColor, SkColor inSpotColor,
465 SkColor* outAmbientColor, SkColor* outSpotColor) {
466 // For tonal color we only compute color values for the spot shadow.
467 // The ambient shadow is greyscale only.
Jim Van Verth34d6e4b2017-06-09 11:09:03 -0400468
Jim Van Verthb1b80f72018-01-18 15:19:13 -0500469 // Ambient
470 *outAmbientColor = SkColorSetARGB(SkColorGetA(inAmbientColor), 0, 0, 0);
Jim Van Verth34d6e4b2017-06-09 11:09:03 -0400471
Jim Van Verthb1b80f72018-01-18 15:19:13 -0500472 // Spot
473 int spotR = SkColorGetR(inSpotColor);
474 int spotG = SkColorGetG(inSpotColor);
475 int spotB = SkColorGetB(inSpotColor);
476 int max = SkTMax(SkTMax(spotR, spotG), spotB);
477 int min = SkTMin(SkTMin(spotR, spotG), spotB);
478 SkScalar luminance = 0.5f*(max + min)/255.f;
479 SkScalar origA = SkColorGetA(inSpotColor)/255.f;
480
481 // We compute a color alpha value based on the luminance of the color, scaled by an
482 // adjusted alpha value. We want the following properties to match the UX examples
483 // (assuming a = 0.25) and to ensure that we have reasonable results when the color
484 // is black and/or the alpha is 0:
485 // f(0, a) = 0
486 // f(luminance, 0) = 0
487 // f(1, 0.25) = .5
488 // f(0.5, 0.25) = .4
489 // f(1, 1) = 1
490 // The following functions match this as closely as possible.
491 SkScalar alphaAdjust = (2.6f + (-2.66667f + 1.06667f*origA)*origA)*origA;
492 SkScalar colorAlpha = (3.544762f + (-4.891428f + 2.3466f*luminance)*luminance)*luminance;
493 colorAlpha = SkTPin(alphaAdjust*colorAlpha, 0.0f, 1.0f);
494
495 // Similarly, we set the greyscale alpha based on luminance and alpha so that
496 // f(0, a) = a
497 // f(luminance, 0) = 0
498 // f(1, 0.25) = 0.15
499 SkScalar greyscaleAlpha = SkTPin(origA*(1 - 0.4f*luminance), 0.0f, 1.0f);
500
501 // The final color we want to emulate is generated by rendering a color shadow (C_rgb) using an
502 // alpha computed from the color's luminance (C_a), and then a black shadow with alpha (S_a)
503 // which is an adjusted value of 'a'. Assuming SrcOver, a background color of B_rgb, and
504 // ignoring edge falloff, this becomes
505 //
506 // (C_a - S_a*C_a)*C_rgb + (1 - (S_a + C_a - S_a*C_a))*B_rgb
507 //
508 // Assuming premultiplied alpha, this means we scale the color by (C_a - S_a*C_a) and
509 // set the alpha to (S_a + C_a - S_a*C_a).
510 SkScalar colorScale = colorAlpha*(SK_Scalar1 - greyscaleAlpha);
511 SkScalar tonalAlpha = colorScale + greyscaleAlpha;
512 SkScalar unPremulScale = colorScale / tonalAlpha;
513 *outSpotColor = SkColorSetARGB(tonalAlpha*255.999f,
514 unPremulScale*spotR,
515 unPremulScale*spotG,
516 unPremulScale*spotB);
Jim Van Verth060d9822017-05-04 09:58:17 -0400517}
518
Jim Van Verth43475ad2017-01-13 14:37:37 -0500519// Draw an offset spot shadow and outlining ambient shadow for the given path.
Jim Van Verth37c5a962017-05-10 14:13:24 -0400520void SkShadowUtils::DrawShadow(SkCanvas* canvas, const SkPath& path, const SkPoint3& zPlaneParams,
Brian Salomon0bd699e2017-02-01 12:23:25 -0500521 const SkPoint3& devLightPos, SkScalar lightRadius,
Jim Van Verthb1b80f72018-01-18 15:19:13 -0500522 SkColor ambientColor, SkColor spotColor,
Jim Van Verth37c5a962017-05-10 14:13:24 -0400523 uint32_t flags) {
Mike Reed4204da22017-05-17 08:53:36 -0400524 SkMatrix inverse;
525 if (!canvas->getTotalMatrix().invert(&inverse)) {
Jim Van Verthcf40e302017-03-02 11:28:43 -0500526 return;
527 }
Mike Reed4204da22017-05-17 08:53:36 -0400528 SkPoint pt = inverse.mapXY(devLightPos.fX, devLightPos.fY);
Jim Van Verthcf40e302017-03-02 11:28:43 -0500529
Mike Reed4204da22017-05-17 08:53:36 -0400530 SkDrawShadowRec rec;
531 rec.fZPlaneParams = zPlaneParams;
532 rec.fLightPos = { pt.fX, pt.fY, devLightPos.fZ };
533 rec.fLightRadius = lightRadius;
Jim Van Verthb1b80f72018-01-18 15:19:13 -0500534 rec.fAmbientColor = ambientColor;
535 rec.fSpotColor = spotColor;
Mike Reed4204da22017-05-17 08:53:36 -0400536 rec.fFlags = flags;
537
538 canvas->private_draw_shadow_rec(path, rec);
539}
540
Jim Van Vertha947e292018-02-26 13:54:34 -0500541static bool validate_rec(const SkDrawShadowRec& rec) {
542 return rec.fLightPos.isFinite() && rec.fZPlaneParams.isFinite() &&
543 SkScalarIsFinite(rec.fLightRadius);
544}
545
Mike Reed4204da22017-05-17 08:53:36 -0400546void SkBaseDevice::drawShadow(const SkPath& path, const SkDrawShadowRec& rec) {
547 auto drawVertsProc = [this](const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint,
548 SkScalar tx, SkScalar ty) {
549 SkAutoDeviceCTMRestore adr(this, SkMatrix::Concat(this->ctm(),
550 SkMatrix::MakeTrans(tx, ty)));
551 this->drawVertices(vertices, mode, paint);
552 };
553
Jim Van Vertha947e292018-02-26 13:54:34 -0500554 if (!validate_rec(rec)) {
555 return;
556 }
557
Mike Reed4204da22017-05-17 08:53:36 -0400558 SkMatrix viewMatrix = this->ctm();
559 SkAutoDeviceCTMRestore adr(this, SkMatrix::I());
Jim Van Verthefe3ded2017-01-30 13:11:45 -0500560
Brian Salomon5e689522017-02-01 12:07:17 -0500561 ShadowedPath shadowedPath(&path, &viewMatrix);
562
Mike Reed4204da22017-05-17 08:53:36 -0400563 bool tiltZPlane = tilted(rec.fZPlaneParams);
564 bool transparent = SkToBool(rec.fFlags & SkShadowFlags::kTransparentOccluder_ShadowFlag);
Jim Van Verth4c9b8932017-05-15 13:49:21 -0400565 bool uncached = tiltZPlane || path.isVolatile();
Brian Salomon958fbc42017-01-30 17:01:28 -0500566
Mike Reed4204da22017-05-17 08:53:36 -0400567 SkPoint3 zPlaneParams = rec.fZPlaneParams;
568 SkPoint3 devLightPos = map(viewMatrix, rec.fLightPos);
569 float lightRadius = rec.fLightRadius;
570
Jim Van Verthb1b80f72018-01-18 15:19:13 -0500571 if (SkColorGetA(rec.fAmbientColor) > 0) {
Jim Van Verth22526362018-02-28 14:51:19 -0500572 bool success = false;
Jim Van Verth37c5a962017-05-10 14:13:24 -0400573 if (uncached) {
574 sk_sp<SkVertices> vertices = SkShadowTessellator::MakeAmbient(path, viewMatrix,
575 zPlaneParams,
576 transparent);
Jim Van Verth7d8955e2017-07-13 15:13:52 -0400577 if (vertices) {
578 SkPaint paint;
579 // Run the vertex color through a GaussianColorFilter and then modulate the
580 // grayscale result of that against our 'color' param.
Mike Reed19d7bd62018-02-19 14:10:57 -0500581 paint.setColorFilter(
582 SkColorFilter::MakeModeFilter(rec.fAmbientColor,
583 SkBlendMode::kModulate)->makeComposed(
584 SkGaussianColorFilter::Make()));
Jim Van Verth7d8955e2017-07-13 15:13:52 -0400585 this->drawVertices(vertices.get(), SkBlendMode::kModulate, paint);
Jim Van Verth22526362018-02-28 14:51:19 -0500586 success = true;
Jim Van Verth7d8955e2017-07-13 15:13:52 -0400587 }
Jim Van Verth22526362018-02-28 14:51:19 -0500588 }
589
590 if (!success) {
Jim Van Verth37c5a962017-05-10 14:13:24 -0400591 AmbientVerticesFactory factory;
592 factory.fOccluderHeight = zPlaneParams.fZ;
593 factory.fTransparent = transparent;
Jim Van Verth8793e382017-05-22 15:52:21 -0400594 if (viewMatrix.hasPerspective()) {
595 factory.fOffset.set(0, 0);
596 } else {
597 factory.fOffset.fX = viewMatrix.getTranslateX();
598 factory.fOffset.fY = viewMatrix.getTranslateY();
599 }
Jim Van Verth37c5a962017-05-10 14:13:24 -0400600
Jim Van Verth22526362018-02-28 14:51:19 -0500601 if (!draw_shadow(factory, drawVertsProc, shadowedPath, rec.fAmbientColor)) {
602 // Pretransform the path to avoid transforming the stroke, below.
603 SkPath devSpacePath;
604 path.transform(viewMatrix, &devSpacePath);
605
606 // The tesselator outsets by AmbientBlurRadius (or 'r') to get the outer ring of
607 // the tesselation, uses the original path as the inner ring, and sets the alpha
608 // of the inner ring to 1/AmbientRecipAlpha (or 'a').
609 //
610 // We want to emulate this with a blur. The full blur width (2*blurRadius or 'f')
611 // can be calculated by interpolating:
612 //
613 // original edge outer edge
614 // | |<---------- r ------>|
615 // |<------|--- f -------------->|
616 // | | |
617 // alpha = 1 alpha = a alpha = 0
618 //
619 // Taking ratios, f/1 = r/a, so f = r/a and blurRadius = f/2.
620 //
621 // We now need to outset the path to place the new edge in the center of the
622 // blur region:
623 //
624 // original new
625 // | |<------|--- r ------>|
626 // |<------|--- f -|------------>|
627 // | |<- o ->|<--- f/2 --->|
628 //
629 // r = o + f/2, so o = r - f/2
630 //
631 // We outset by using the stroker, so the strokeWidth is o/2.
632 //
633 SkScalar devSpaceOutset = SkDrawShadowMetrics::AmbientBlurRadius(zPlaneParams.fZ);
634 SkScalar oneOverA = SkDrawShadowMetrics::AmbientRecipAlpha(zPlaneParams.fZ);
635 SkScalar blurRadius = 0.5f*devSpaceOutset*oneOverA;
636 SkScalar strokeWidth = 0.5f*(devSpaceOutset - blurRadius);
637
638 // Now draw with blur
639 SkPaint paint;
640 paint.setColor(rec.fAmbientColor);
641 paint.setStrokeWidth(strokeWidth);
642 paint.setStyle(SkPaint::kStrokeAndFill_Style);
Mike Reed8e03f692018-03-09 16:18:56 -0500643 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(blurRadius);
Mike Reed18e75562018-03-12 14:03:47 -0400644 bool respectCTM = false;
645 paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma, respectCTM));
Jim Van Verth22526362018-02-28 14:51:19 -0500646 this->drawPath(devSpacePath, paint);
647 }
Brian Salomond1ac9822017-02-03 14:25:02 -0500648 }
Jim Van Verthb4366552017-03-27 14:25:29 -0400649 }
650
Jim Van Verthb1b80f72018-01-18 15:19:13 -0500651 if (SkColorGetA(rec.fSpotColor) > 0) {
Jim Van Verth22526362018-02-28 14:51:19 -0500652 bool success = false;
Jim Van Verth37c5a962017-05-10 14:13:24 -0400653 if (uncached) {
654 sk_sp<SkVertices> vertices = SkShadowTessellator::MakeSpot(path, viewMatrix,
655 zPlaneParams,
656 devLightPos, lightRadius,
657 transparent);
Jim Van Verth7d8955e2017-07-13 15:13:52 -0400658 if (vertices) {
659 SkPaint paint;
660 // Run the vertex color through a GaussianColorFilter and then modulate the
661 // grayscale result of that against our 'color' param.
Mike Reed19d7bd62018-02-19 14:10:57 -0500662 paint.setColorFilter(
663 SkColorFilter::MakeModeFilter(rec.fSpotColor,
664 SkBlendMode::kModulate)->makeComposed(
Jim Van Verth22526362018-02-28 14:51:19 -0500665 SkGaussianColorFilter::Make()));
Jim Van Verth7d8955e2017-07-13 15:13:52 -0400666 this->drawVertices(vertices.get(), SkBlendMode::kModulate, paint);
Jim Van Verth22526362018-02-28 14:51:19 -0500667 success = true;
Jim Van Verth7d8955e2017-07-13 15:13:52 -0400668 }
Jim Van Verth22526362018-02-28 14:51:19 -0500669 }
Jim Van Vertha783c362017-05-11 17:05:28 -0400670
Jim Van Verth22526362018-02-28 14:51:19 -0500671 if (!success) {
672 SpotVerticesFactory factory;
673 factory.fOccluderHeight = zPlaneParams.fZ;
674 factory.fDevLightPos = devLightPos;
675 factory.fLightRadius = lightRadius;
676
Jim Van Verth37c5a962017-05-10 14:13:24 -0400677 SkPoint center = SkPoint::Make(path.getBounds().centerX(), path.getBounds().centerY());
Jim Van Verth8793e382017-05-22 15:52:21 -0400678 factory.fLocalCenter = center;
Jim Van Verth37c5a962017-05-10 14:13:24 -0400679 viewMatrix.mapPoints(&center, 1);
Jim Van Verth22526362018-02-28 14:51:19 -0500680 SkScalar radius, scale;
681 SkDrawShadowMetrics::GetSpotParams(zPlaneParams.fZ, devLightPos.fX - center.fX,
682 devLightPos.fY - center.fY, devLightPos.fZ,
683 lightRadius, &radius, &scale, &factory.fOffset);
Jim Van Vertha783c362017-05-11 17:05:28 -0400684 SkRect devBounds;
685 viewMatrix.mapRect(&devBounds, path.getBounds());
Jim Van Verth8793e382017-05-22 15:52:21 -0400686 if (transparent ||
687 SkTAbs(factory.fOffset.fX) > 0.5f*devBounds.width() ||
688 SkTAbs(factory.fOffset.fY) > 0.5f*devBounds.height()) {
Jim Van Verth78c8f302017-05-15 10:44:22 -0400689 // if the translation of the shadow is big enough we're going to end up
690 // filling the entire umbra, so we can treat these as all the same
Jim Van Verth8793e382017-05-22 15:52:21 -0400691 factory.fOccluderType = SpotVerticesFactory::OccluderType::kTransparent;
Jim Van Verth78c8f302017-05-15 10:44:22 -0400692 } else if (factory.fOffset.length()*scale + scale < radius) {
Jim Van Vertha783c362017-05-11 17:05:28 -0400693 // if we don't translate more than the blur distance, can assume umbra is covered
Jim Van Verth78c8f302017-05-15 10:44:22 -0400694 factory.fOccluderType = SpotVerticesFactory::OccluderType::kOpaqueNoUmbra;
Jim Van Vertha783c362017-05-11 17:05:28 -0400695 } else {
Jim Van Verth78c8f302017-05-15 10:44:22 -0400696 factory.fOccluderType = SpotVerticesFactory::OccluderType::kOpaquePartialUmbra;
Jim Van Vertha783c362017-05-11 17:05:28 -0400697 }
Jim Van Verth8793e382017-05-22 15:52:21 -0400698 // need to add this after we classify the shadow
699 factory.fOffset.fX += viewMatrix.getTranslateX();
700 factory.fOffset.fY += viewMatrix.getTranslateY();
Jim Van Verth22526362018-02-28 14:51:19 -0500701
702 SkColor color = rec.fSpotColor;
Jim Van Vertha783c362017-05-11 17:05:28 -0400703#ifdef DEBUG_SHADOW_CHECKS
704 switch (factory.fOccluderType) {
705 case SpotVerticesFactory::OccluderType::kTransparent:
706 color = 0xFFD2B48C; // tan for transparent
707 break;
Jim Van Verth78c8f302017-05-15 10:44:22 -0400708 case SpotVerticesFactory::OccluderType::kOpaquePartialUmbra:
Jim Van Vertha783c362017-05-11 17:05:28 -0400709 color = 0xFFFFA500; // orange for opaque
710 break;
Jim Van Verth78c8f302017-05-15 10:44:22 -0400711 case SpotVerticesFactory::OccluderType::kOpaqueNoUmbra:
712 color = 0xFFE5E500; // corn yellow for covered
Jim Van Vertha783c362017-05-11 17:05:28 -0400713 break;
714 }
715#endif
Jim Van Verth22526362018-02-28 14:51:19 -0500716 if (!draw_shadow(factory, drawVertsProc, shadowedPath, color)) {
717 // draw with blur
718 SkVector translate;
719 SkDrawShadowMetrics::GetSpotParams(zPlaneParams.fZ, devLightPos.fX,
720 devLightPos.fY, devLightPos.fZ,
721 lightRadius, &radius, &scale, &translate);
722 SkMatrix shadowMatrix;
723 shadowMatrix.setScaleTranslate(scale, scale, translate.fX, translate.fY);
724 SkAutoDeviceCTMRestore adr(this, SkMatrix::Concat(shadowMatrix, viewMatrix));
725
726 SkPaint paint;
727 paint.setColor(rec.fSpotColor);
Mike Reed8e03f692018-03-09 16:18:56 -0500728 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(radius);
Mike Reed18e75562018-03-12 14:03:47 -0400729 bool respectCTM = false;
730 paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma, respectCTM));
Jim Van Verth22526362018-02-28 14:51:19 -0500731 this->drawPath(path, paint);
732 }
Jim Van Verth37c5a962017-05-10 14:13:24 -0400733 }
Jim Van Verthb4366552017-03-27 14:25:29 -0400734 }
735}