| 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 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 is retrieved by: | 61 is retrieved by: |
| 62 N.x = R-127; | 62 N.x = R-127; |
| 63 N.y = G-127; | 63 N.y = G-127; |
| 64 N.z = B-127; | 64 N.z = B-127; |
| 65 N.normalize(); | 65 N.normalize(); |
| 66 The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis
is | 66 The +Z axis is thus encoded in RGB as (127, 127, 255) while the -Z axis
is |
| 67 (127, 127, 0). | 67 (127, 127, 0). |
| 68 */ | 68 */ |
| 69 static sk_sp<SkNormalSource> MakeFromNormalMap(sk_sp<SkShader> map, const Sk
Matrix& ctm); | 69 static sk_sp<SkNormalSource> MakeFromNormalMap(sk_sp<SkShader> map, const Sk
Matrix& ctm); |
| 70 | 70 |
| 71 /** Returns a normal source that provides straight-up normals only (0, 0, 1)
. | 71 /** Returns a normal source that provides straight-up normals only <0, 0, 1>
. |
| 72 */ | 72 */ |
| 73 static sk_sp<SkNormalSource> MakeFlat(); | 73 static sk_sp<SkNormalSource> MakeFlat(); |
| 74 | 74 |
| 75 /** This enum specifies the shape of the bevel. All bevels output <0, 0, 1>
as the surface | 75 /** This enum specifies the shape of the bevel. All bevels output <0, 0, 1>
as the surface |
| 76 * normal for any point more than 'width' away from any edge. | 76 * normal for any point more than 'width' away from any edge. |
| 77 * | 77 * |
| 78 * Mathematical details: | 78 * Mathematical details: |
| 79 * For the purpose of describing the shape of the bevel, we define 'w' to b
e the given width of | 79 * For the purpose of describing the shape of the bevel, we define 'w' to b
e the given width of |
| 80 * the bevel, and 'h' to be the given height. We will assume the shape is r
otated such that the | 80 * the bevel, and 'h' to be the given height. We will assume the shape is r
otated such that the |
| 81 * point being shaded as well as the closest point in the shape's edge to t
hat point are in the | 81 * point being shaded as well as the closest point in the shape's edge to t
hat point are in the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 101 /* This bevel simulates a surface that sharply becomes perpendicular to
the x-y plane when | 101 /* This bevel simulates a surface that sharply becomes perpendicular to
the x-y plane when |
| 102 * at 'width' units from the nearest edge, and then rounds off towards t
he shape's | 102 * at 'width' units from the nearest edge, and then rounds off towards t
he shape's |
| 103 * edge, smoothly becoming parallel to the x-y plane. | 103 * edge, smoothly becoming parallel to the x-y plane. |
| 104 * | 104 * |
| 105 * Mathematical details: | 105 * Mathematical details: |
| 106 * This bevel follows the only quadratic bezier curve whose start point
is at (w, 0, 0), | 106 * This bevel follows the only quadratic bezier curve whose start point
is at (w, 0, 0), |
| 107 * control point is at (0, 0, 0), and end point is at (0, 0, h). | 107 * control point is at (0, 0, 0), and end point is at (0, 0, h). |
| 108 */ | 108 */ |
| 109 kRoundedIn | 109 kRoundedIn |
| 110 }; | 110 }; |
| 111 /** Returns a normal source that generates a bevel for the given shape. UNIM
PLEMENTED: Will | 111 |
| 112 return straight-up normals only. | 112 /** Returns a normal source that generates a bevel for the shape being drawn
. Currently this is |
| 113 not implemented on CPU rendering. On GPU this currently only works for a
nti-aliased circles |
| 114 and rectangles. |
| 113 | 115 |
| 114 @param type the type of bevel to add. | 116 @param type the type of bevel to add. |
| 115 @param width the width of the bevel, in source space. Must be positive
. | 117 @param width the width of the bevel, in source space. Must be positive
. |
| 116 @param height the height of the plateau, in source space. Can be positi
ve, negative, | 118 @param height the height of the plateau, in source space. Can be positi
ve, negative, |
| 117 or zero. A negative height means the simulated bevels slo
pe downwards. | 119 or zero. A negative height means the simulated bevels slo
pe downwards. |
| 118 */ | 120 */ |
| 119 static sk_sp<SkNormalSource> MakeBevel(BevelType, SkScalar width, SkScalar h
eight); | 121 static sk_sp<SkNormalSource> MakeBevel(BevelType, SkScalar width, SkScalar h
eight); |
| 120 | 122 |
| 121 SK_DEFINE_FLATTENABLE_TYPE(SkNormalSource) | 123 SK_DEFINE_FLATTENABLE_TYPE(SkNormalSource) |
| 122 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() | 124 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() |
| 123 }; | 125 }; |
| 124 | 126 |
| 125 #endif | 127 #endif |
| OLD | NEW |