aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private
diff options
context:
space:
mode:
authorGravatar vjiaoblack <vjiaoblack@google.com>2016-08-25 06:30:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-25 06:30:23 -0700
commite6f5d5623160a69e1585f5121a3695092327dfe0 (patch)
tree44a73f37db340157c73e005841207e52210e78d0 /include/private
parent199a2ea665a088dafb2fd364f3aa6a642bfa2fef (diff)
Made shadows blurry (thru implementing variance mapping)
Diffstat (limited to 'include/private')
-rw-r--r--include/private/SkRecords.h3
-rw-r--r--include/private/SkShadowParams.h48
2 files changed, 50 insertions, 1 deletions
diff --git a/include/private/SkRecords.h b/include/private/SkRecords.h
index 14b653190a..637a2ef68c 100644
--- a/include/private/SkRecords.h
+++ b/include/private/SkRecords.h
@@ -268,7 +268,8 @@ RECORD(DrawPicture, kDraw_Tag|kHasPaint_Tag,
RECORD(DrawShadowedPicture, kDraw_Tag|kHasPaint_Tag,
Optional<SkPaint> paint;
sk_sp<const SkPicture> picture;
- TypedMatrix matrix);
+ TypedMatrix matrix;
+ const SkShadowParams& params);
RECORD(DrawPoints, kDraw_Tag|kHasPaint_Tag,
SkPaint paint;
SkCanvas::PointMode mode;
diff --git a/include/private/SkShadowParams.h b/include/private/SkShadowParams.h
new file mode 100644
index 0000000000..3df0a44279
--- /dev/null
+++ b/include/private/SkShadowParams.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkShadowParams_DEFINED
+#define SkShadowParams_DEFINED
+
+/** \struct SkShadowParams
+
+ This struct holds information needed for drawing shadows.
+
+ fShadowRadius - radius of the shadow blur
+
+ fBiasingConstant - A constant used in variance shadow mapping to directly
+ 0.0 - 1.0 reduce light bleeding. Essentially sets all shadows
+ ~.25 below a certain brightness equal to no light, and does
+ a linear step on the rest. Essentially makes shadows
+ darker and more rounded at higher values.
+
+ fMinVariance - Too low of a variance (near the outer edges of blurry
+ ~512, 1024 shadows) will lead to ugly sharp shadow brightness
+ distortions. This enforces a minimum amount of variance
+ in the calculation to smooth out the outside edges of
+ blurry shadows. However, too high of a value for this will
+ cause all shadows to be lighter by visibly different
+ amounts varying on depth.
+
+ fType - Decides which algorithm to use to draw shadows.
+*/
+struct SkShadowParams {
+ SkScalar fShadowRadius;
+ SkScalar fBiasingConstant;
+ SkScalar fMinVariance;
+
+ enum ShadowType {
+ kNoBlur_ShadowType,
+ kVariance_ShadowType,
+
+ kLast_ShadowType = kVariance_ShadowType
+ };
+ static const int kShadowTypeCount = kLast_ShadowType + 1;
+
+ ShadowType fType;
+};
+
+#endif