/* * Copyright 2006 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/
int rowBytes = mask->fRowBytes; int maxy = mask->fBounds.height() - 1; int maxx = mask->fBounds.width() - 1;
int prev_row = 0; for (int y = 0; y <= maxy; y++) { int next_row = neq_to_mask(y, maxy) & rowBytes;
for (int x = 0; x <= maxx; x++) { int nx = alpha[x + neq_to_one(x, maxx)] - alpha[x - nonzero_to_one(x)]; int ny = alpha[x + next_row] - alpha[x - prev_row];
SkFixed numer = lx * nx + ly * ny + lz_dot_nz; int mul = ambient; int add = 0;
if (numer > 0) { // preflight when numer/denom will be <= 0 int denom = SkSqrt32(nx * nx + ny * ny + kDelta*kDelta);
SkFixed dot = numer / denom;
dot >>= 8; // now dot is 2^8 instead of 2^16
mul = std::min(mul + dot, 255);
// now for the reflection
// R = 2 (Light * Normal) Normal - Light // hilite = R * Eye(0, 0, 1)
int hilite = (2 * dot - lz_dot8) * lz_dot8 >> 8; if (hilite > 0) { // pin hilite to 255, since our fast math is also a little sloppy
hilite = std::min(hilite, 255);
// specular is 4.4 // would really like to compute the fractional part of this // and then possibly cache a 256 table for a given specular // value in the light, and just pass that in to this function.
add = hilite; for (int i = specular >> 4; i > 0; --i) {
add = div255(add * hilite);
}
}
}
multiply[x] = SkToU8(mul);
additive[x] = SkToU8(add);
}
alpha += rowBytes;
multiply += rowBytes;
additive += rowBytes;
prev_row = rowBytes;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.