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

Side by Side 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 7 comments Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkNormalSource_DEFINED 8 #ifndef SkNormalSource_DEFINED
9 #define SkNormalSource_DEFINED 9 #define SkNormalSource_DEFINED
10 10
11 #include "SkFlattenable.h" 11 #include "SkFlattenable.h"
12 #include "SkShader.h"
13
14 class SkMatrix;
15 class SkPoint3;
16
17 #if SK_SUPPORT_GPU
18 class GrFragmentProcessor;
19 class GrContext;
20 enum SkFilterQuality;
21 enum SkSourceGammaTreatment;
22 #endif
12 23
13 /** Abstract class that generates or reads in normals for use by SkLightingShade r. 24 /** Abstract class that generates or reads in normals for use by SkLightingShade r.
14 */ 25 */
15 class SK_API SkNormalSource : public SkFlattenable { 26 class SK_API SkNormalSource : public SkFlattenable {
16 public: 27 public:
17 virtual ~SkNormalSource() override; 28 virtual ~SkNormalSource() override;
18 29
19 #if SK_SUPPORT_GPU 30 #if SK_SUPPORT_GPU
20 /** Returns a fragment processor that takes no input and outputs a normal (a lready rotated) 31 /** Returns a fragment processor that takes no input and outputs a normal (a lready rotated)
21 as its output color. To be used as a child fragment processor. 32 as its output color. To be used as a child fragment processor.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 N.normalize(); 73 N.normalize();
63 The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis is 74 The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis is
64 (127, 127, 0). 75 (127, 127, 0).
65 */ 76 */
66 static sk_sp<SkNormalSource> MakeFromNormalMap(sk_sp<SkShader> map, const Sk Matrix& ctm); 77 static sk_sp<SkNormalSource> MakeFromNormalMap(sk_sp<SkShader> map, const Sk Matrix& ctm);
67 78
68 /** Returns a normal source that provides straight-up normals only (0, 0, 1) . 79 /** Returns a normal source that provides straight-up normals only (0, 0, 1) .
69 */ 80 */
70 static sk_sp<SkNormalSource> MakeFlat(); 81 static sk_sp<SkNormalSource> MakeFlat();
71 82
83 /** This enum specifies the shape of the bevel.
84 */
85 enum class BevelType {
egdaniel 2016/07/25 15:48:00 Change this to what we just discussed. Make sure t
dvonbeck 2016/07/25 20:37:14 Done.
86 /* This bevel simulates a surface that is slanted from the shape's edges inwards, linearly.
87 * It generates normals perpendicular to a straight line of slope 'heigh t/width' that goes
88 * from the closest edge of the shape to the point being shaded, as long as that point is
89 * less than 'width' away from the closest edge.
90 */
91 kLinear,
92 /* This bevel simulates a surface that rounds off at the shape's edges, smoothly becoming
93 * perpendicular to the x-y plane, starting 'width' units from the edge and following a
94 * quadratic bezier curve.
95 *
96 * It can be more rigorously defined as the top surface of the volume en closed between the
97 * plane z=0, the plane z='height', and the surface formed by the union of all quadratic
98 * bezier curves defined as follows:
99 * - The start point is the edge of the shape
100 * - The end point is 'width' units from the start point in the x-y plane
101 * - The end point z-coordinate is 'height'.
102 * - The projection of the curve in the x-y plane is perpendicular t o the shape's edge
103 * at the start point.
104 * - The control point is the projection of the start point onto the z='height' plane.
105 */
106 kRoundedOut,
107 /* This bevel simulates a surface that sharply becomes perpendicular to the x-y plane at a
108 * distance of 'width' units from the edge, and then smoothly becomes pa rallel to the x-y
109 * plane following a quadratic bezier curve.
110 *
111 * It can be more rigorously defined as the top surface of the volume en closed between the
112 * plane z=0, the plane z='height', and the surface formed by the union of all quadratic
113 * bezier curves defined as follows:
114 * - The start point is the edge of the shape
115 * - The end point is 'width' units from the start point in the x-y plane
116 * - The end point z-coordinate is 'height'.
117 * - The projection of the curve in the x-y plane is perpendicular t o the shape's edge
118 * at the start point.
119 * - The control point is the projection of the end point onto the z =0 plane.
120 */
121 kRoundedIn
122 };
123 /** Returns a normal source that generates a bevel for the given shape. UNIM PLEMENTED: Will
124 return straight-up normals only.
125
126 @param type the type of bevel to add
127 @param width the width of the bevel, in source space. Must be positive .
128 @param height the height of the plateau, in source space. Can be positi ve, negative,
129 or zero. A negative height means the simulated bevels slo pe downwards.
130 */
131 static sk_sp<SkNormalSource> MakeBevel(BevelType, SkScalar width, SkScalar h eight);
132
72 SK_DEFINE_FLATTENABLE_TYPE(SkNormalSource) 133 SK_DEFINE_FLATTENABLE_TYPE(SkNormalSource)
73 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 134 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
74 }; 135 };
75 136
76 #endif 137 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698