1 /*
2  * Copyright 2016 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 #ifndef SkShadowParams_DEFINED
8 #define SkShadowParams_DEFINED
9 
10 #include "SkScalar.h"
11 
12 /** \struct SkShadowParams
13 
14     This struct holds information needed for drawing shadows.
15 
16     fShadowRadius - radius of the shadow blur
17 
18     fBiasingConstant - A constant used in variance shadow mapping to directly
19     0.0 - 1.0          reduce light bleeding. Essentially sets all shadows
20     ~.25               below a certain brightness equal to no light, and does
21                        a linear step on the rest. Essentially makes shadows
22                        darker and more rounded at higher values.
23 
24     fMinVariance - Too low of a variance (near the outer edges of blurry
25     ~512, 1024     shadows) will lead to ugly sharp shadow brightness
26                    distortions. This enforces a minimum amount of variance
27                    in the calculation to smooth out the outside edges of
28                    blurry shadows. However, too high of a value for this will
29                    cause all shadows to be lighter by visibly different
30                    amounts varying on depth.
31 
32     fType - Decides which algorithm to use to draw shadows.
33 */
34 struct SkShadowParams {
35     SkScalar fShadowRadius;
36     SkScalar fBiasingConstant;
37     SkScalar fMinVariance;
38 
39     enum ShadowType {
40         kNoBlur_ShadowType,
41         kVariance_ShadowType,
42 
43         kLast_ShadowType = kVariance_ShadowType
44     };
45     static const int kShadowTypeCount = kLast_ShadowType + 1;
46 
47     ShadowType fType;
48 };
49 
50 #endif
51