Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: src/core/SkNormalSource.h

Issue 2080993002: Added API for Bevel NormalSource. (Closed) Base URL: https://skia.googlesource.com/skia@dvonbeck-diffuse-api-change
Patch Set: Addressed patch 8 comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkNormalSource.h
diff --git a/src/core/SkNormalSource.h b/src/core/SkNormalSource.h
index e46e2dae34cc84d5fdf0e2877f2c21968f1fff13..a17c4f671a1efcbf697f24e0df602a5b2442758c 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,54 @@ 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 aformentioned 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) and
+ * has a perpendicular normal vector of <1,0,0>, and whose end point is at (0, 0, h) and has
+ * a perpendicular normal vector of <0,0,1>.
egdaniel 2016/07/26 19:54:41 What changes if h is negative, is confusing cause
dvonbeck 2016/07/27 17:44:57 Done.
+ */
+ 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 paralel to the x-y plane.
+ *
+ * Mathematical details:
+ * This bevel follows the only quadratic bezier curve whose start point is at (w, 0, 0) and
+ * has a perpendicular normal vector of <0,0,1>, and whose end point is at (0, 0, h) and has
+ * a perpendicular normal vector of <1,0,0>.
egdaniel 2016/07/26 19:54:41 Same as above, but control point will be at (0,0,0
dvonbeck 2016/07/27 17:44:57 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()
};

Powered by Google App Engine
This is Rietveld 408576698