Index: src/core/SkNormalSource.h |
diff --git a/src/core/SkNormalSource.h b/src/core/SkNormalSource.h |
index e46e2dae34cc84d5fdf0e2877f2c21968f1fff13..7ff110f27f5d5d9dd29cc8bc62d140a60e407f7e 100644 |
--- a/src/core/SkNormalSource.h |
+++ b/src/core/SkNormalSource.h |
@@ -9,6 +9,17 @@ |
#define SkNormalSource_DEFINED |
#include "SkFlattenable.h" |
+#include "SkShader.h" |
+ |
+class SkMatrix; |
+class SkPoint3; |
+ |
+#if SK_SUPPORT_GPU |
+class GrFragmentProcessor; |
+class GrContext; |
+enum SkFilterQuality; |
+enum SkSourceGammaTreatment; |
+#endif |
/** Abstract class that generates or reads in normals for use by SkLightingShader. |
*/ |
@@ -69,6 +80,51 @@ public: |
*/ |
static sk_sp<SkNormalSource> MakeFlat(); |
+ /** This enum specifies the shape of the bevel. All bevels output <0, 0, 1> as the surface |
+ * normal for any point more than 'width' away from any edge. |
+ * |
+ * Mathematical details: |
+ * For the purpose of describing the shape of the bevel, we define 'w' to be the given width of |
+ * the bevel, and 'h' to be the given height. We will assume the shape is rotated such that the |
+ * point being shaded as well as the closest point in the shape's edge to that point are in the |
+ * x-axis, and the shape is translated so that the aforementioned point in the edge is at |
+ * coordinates (w, 0, 0) and the end of the bevel is at (0, 0, h). |
+ * |
+ */ |
+ enum class BevelType { |
+ /* This bevel simulates a surface that is slanted from the shape's edges inwards, linearly. |
+ * |
+ * Mathematical details: |
+ * This bevel follows a straight line from (w, 0, 0) to (0, 0, h). |
+ */ |
+ kLinear, |
+ /* This bevel simulates a surface that rounds off at the shape's edges, smoothly becoming |
+ * perpendicular to the x-y plane. |
+ * |
+ * Mathematical details: |
+ * This bevel follows the only quadratic bezier curve whose start point is at (w, 0, 0), |
+ * control point is at (w, 0, h), and end point is at (0, 0, h). |
+ */ |
+ kRoundedOut, |
+ /* This bevel simulates a surface that sharply becomes perpendicular to the x-y plane when |
+ * at 'width' units from the nearest edge, and then rounds off towards the shape's |
+ * edge, smoothly becoming parallel to the x-y plane. |
+ * |
+ * Mathematical details: |
+ * Same as above, but with the control point at (0, 0, 0) instead. |
egdaniel
2016/07/27 17:57:28
Ah I would actually copy the text for RoundOut, bu
dvonbeck
2016/07/27 18:46:36
Hahaha I misinterpreted your comment. Done.
|
+ */ |
+ kRoundedIn |
+ }; |
+ /** Returns a normal source that generates a bevel for the given shape. UNIMPLEMENTED: Will |
+ return straight-up normals only. |
+ |
+ @param type the type of bevel to add |
+ @param width the width of the bevel, in source space. Must be positive. |
+ @param height the height of the plateau, in source space. Can be positive, negative, |
+ or zero. A negative height means the simulated bevels slope downwards. |
+ */ |
+ static sk_sp<SkNormalSource> MakeBevel(BevelType, SkScalar width, SkScalar height); |
+ |
SK_DEFINE_FLATTENABLE_TYPE(SkNormalSource) |
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
}; |