OLD | NEW |
---|---|
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 Loading... | |
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. All bevels output <0, 0, 1> as the surface | |
84 * normal for any point more than 'width' away from any edge. | |
85 * | |
86 * Mathematical details: | |
87 * For the purpose of describing the shape of the bevel, we define 'w' to b e the given width of | |
88 * the bevel, and 'h' to be the given height. We will assume the shape is r otated such that the | |
89 * point being shaded as well as the closest point in the shape's edge to t hat point are in the | |
90 * x-axis, and the shape is translated so that the aforementioned point in the edge is at | |
91 * coordinates (w, 0, 0) and the end of the bevel is at (0, 0, h). | |
92 * | |
93 */ | |
94 enum class BevelType { | |
95 /* This bevel simulates a surface that is slanted from the shape's edges inwards, linearly. | |
96 * | |
97 * Mathematical details: | |
98 * This bevel follows a straight line from (w, 0, 0) to (0, 0, h). | |
99 */ | |
100 kLinear, | |
101 /* This bevel simulates a surface that rounds off at the shape's edges, smoothly becoming | |
102 * perpendicular to the x-y plane. | |
103 * | |
104 * Mathematical details: | |
105 * This bevel follows the only quadratic bezier curve whose start point is at (w, 0, 0), | |
106 * control point is at (w, 0, h), and end point is at (0, 0, h). | |
107 */ | |
108 kRoundedOut, | |
109 /* This bevel simulates a surface that sharply becomes perpendicular to the x-y plane when | |
110 * at 'width' units from the nearest edge, and then rounds off towards t he shape's | |
111 * edge, smoothly becoming parallel to the x-y plane. | |
112 * | |
113 * Mathematical details: | |
114 * 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.
| |
115 */ | |
116 kRoundedIn | |
117 }; | |
118 /** Returns a normal source that generates a bevel for the given shape. UNIM PLEMENTED: Will | |
119 return straight-up normals only. | |
120 | |
121 @param type the type of bevel to add | |
122 @param width the width of the bevel, in source space. Must be positive . | |
123 @param height the height of the plateau, in source space. Can be positi ve, negative, | |
124 or zero. A negative height means the simulated bevels slo pe downwards. | |
125 */ | |
126 static sk_sp<SkNormalSource> MakeBevel(BevelType, SkScalar width, SkScalar h eight); | |
127 | |
72 SK_DEFINE_FLATTENABLE_TYPE(SkNormalSource) | 128 SK_DEFINE_FLATTENABLE_TYPE(SkNormalSource) |
73 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 129 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
74 }; | 130 }; |
75 | 131 |
76 #endif | 132 #endif |
OLD | NEW |