55 {
57
64 int lz_dot8 = lz >> 8;
65
67 uint8_t* alpha = mask->
image();
68 uint8_t*
multiply = (uint8_t*)alpha + planeSize;
69 uint8_t* additive =
multiply + planeSize;
70
74
75 int prev_row = 0;
76 for (
int y = 0;
y <= maxy;
y++) {
78
79 for (
int x = 0;
x <= maxx;
x++) {
81 int ny = alpha[
x +
next_row] - alpha[
x - prev_row];
82
83 SkFixed numer = lx * nx + ly * ny + lz_dot_nz;
84 int mul = ambient;
85 int add = 0;
86
87 if (numer > 0) {
91 mul = std::min(mul + dot, 255);
92
93
94
95
96
97
98 int hilite = (2 *
dot - lz_dot8) * lz_dot8 >> 8;
99 if (hilite > 0) {
100
101 hilite = std::min(hilite, 255);
102
103
104
105
106
107 add = hilite;
108 for (int i = specular >> 4; i > 0; --i) {
109 add =
div255(add * hilite);
110 }
111 }
112 }
115 }
116 alpha += rowBytes;
118 additive += rowBytes;
119 prev_row = rowBytes;
120 }
121}
static uint8_t div255(unsigned prod)
static int neq_to_one(int x, int max)
static int nonzero_to_one(int x)
static int neq_to_mask(int x, int max)
#define SkScalarToFixed(x)
static int32_t SkSqrt32(int32_t n)
constexpr uint8_t SkToU8(S x)
Int96 multiply(int64_t a, int32_t b)
SINT T dot(const Vec< N, T > &a, const Vec< N, T > &b)
static void next_row(SkCanvas *canvas)
constexpr int32_t height() const
constexpr int32_t width() const
@ k3D_Format
3 8bit per pixl planes: alpha, mul, add
size_t computeImageSize() const