• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #ifndef SkShadowTessellator_DEFINED
9 #define SkShadowTessellator_DEFINED
10 
11 #include "include/core/SkColor.h"
12 #include "include/core/SkPoint.h"
13 #include "include/core/SkRefCnt.h"
14 #include <functional>  // std::function
15 
16 class SkMatrix;
17 class SkPath;
18 struct SkPoint3;
19 class SkVertices;
20 
21 namespace SkShadowTessellator {
22 
23 typedef std::function<SkScalar(SkScalar, SkScalar)> HeightFunc;
24 
25 /**
26  * This function generates an ambient shadow mesh for a path by walking the path, outsetting by
27  * the radius, and setting inner and outer colors to umbraColor and penumbraColor, respectively.
28  * If transparent is true, then the center of the ambient shadow will be filled in.
29  */
30 sk_sp<SkVertices> MakeAmbient(const SkPath& path, const SkMatrix& ctm,
31                               const SkPoint3& zPlane, bool transparent);
32 
33 /**
34  * This function generates a spot shadow mesh for a path by walking the transformed path,
35  * further transforming by the scale and translation, and outsetting and insetting by a radius.
36  * The center will be clipped against the original path unless transparent is true.
37  */
38 sk_sp<SkVertices> MakeSpot(const SkPath& path, const SkMatrix& ctm, const SkPoint3& zPlane,
39                            const SkPoint3& lightPos, SkScalar lightRadius, bool transparent,
40                            bool directional);
41 
42 
43 }  // namespace SkShadowTessellator
44 
45 #endif
46