Commit fd7bcf3a authored by rosca's avatar rosca Committed by Commit bot

Prevent division by 0 in set_luminance shader function.

The solution has been approved in skia: https://codereview.chromium.org/666043003/

BUG=

Review URL: https://codereview.chromium.org/639773010

Cr-Commit-Position: refs/heads/master@{#301333}
parent da4b0f2b
...@@ -804,12 +804,12 @@ std::string FragmentTexBlendMode::GetHelperFunctions() const { ...@@ -804,12 +804,12 @@ std::string FragmentTexBlendMode::GetHelperFunctions() const {
float outLum = luminance(outColor); float outLum = luminance(outColor);
float minComp = min(min(outColor.r, outColor.g), outColor.b); float minComp = min(min(outColor.r, outColor.g), outColor.b);
float maxComp = max(max(outColor.r, outColor.g), outColor.b); float maxComp = max(max(outColor.r, outColor.g), outColor.b);
if (minComp < 0.0) { if (minComp < 0.0 && outLum != minComp) {
outColor = outLum + outColor = outLum +
((outColor - vec3(outLum, outLum, outLum)) * outLum) / ((outColor - vec3(outLum, outLum, outLum)) * outLum) /
(outLum - minComp); (outLum - minComp);
} }
if (maxComp > alpha) { if (maxComp > alpha && maxComp != outLum) {
outColor = outColor =
outLum + outLum +
((outColor - vec3(outLum, outLum, outLum)) * (alpha - outLum)) / ((outColor - vec3(outLum, outLum, outLum)) * (alpha - outLum)) /
......
...@@ -233,31 +233,27 @@ class LayerTreeHostBlendingPixelTest : public LayerTreePixelTest { ...@@ -233,31 +233,27 @@ class LayerTreeHostBlendingPixelTest : public LayerTreePixelTest {
if ((flags & kUseAntialiasing) && (type == PIXEL_TEST_GL)) { if ((flags & kUseAntialiasing) && (type == PIXEL_TEST_GL)) {
// Anti aliasing causes differences up to 7 pixels at the edges. // Anti aliasing causes differences up to 7 pixels at the edges.
int large_error_allowed = 7; // Several pixels have 9 units difference on the alpha channel.
int large_error_allowed = (flags & kUseMasks) ? 7 : 9;
// Blending results might differ with one pixel. // Blending results might differ with one pixel.
int small_error_allowed = 1; int small_error_allowed = 1;
// Most of the errors are one pixel errors. // Most of the errors are one pixel errors.
float percentage_pixels_small_error = 12.5f; float percentage_pixels_small_error = (flags & kUseMasks) ? 7.7f : 12.1f;
// Because of anti-aliasing, around 3% of pixels (at the edges) have // Because of anti-aliasing, around 3% of pixels (at the edges) have
// bigger errors (from small_error_allowed + 1 to large_error_allowed). // bigger errors (from small_error_allowed + 1 to large_error_allowed).
float percentage_pixels_error = 15.0f; float percentage_pixels_error = (flags & kUseMasks) ? 12.4f : 15.f;
// The average error is still close to 1. // The average error is still close to 1.
float average_error_allowed_in_bad_pixels = 1.3f; float average_error_allowed_in_bad_pixels =
(flags & kUseMasks) ? 1.3f : 1.f;
// The sepia filter generates more small errors, but the number of large // The sepia filter generates more small errors, but the number of large
// errors remains around 3%. // errors remains around 3%.
if (flags & kUseColorMatrix) { if (flags & kUseColorMatrix) {
percentage_pixels_small_error = 26.f; percentage_pixels_small_error = (flags & kUseMasks) ? 14.0f : 26.f;
percentage_pixels_error = 29.f; percentage_pixels_error = (flags & kUseMasks) ? 18.5f : 29.f;
average_error_allowed_in_bad_pixels = (flags & kUseMasks) ? 0.9f : 0.7f;
} }
// Anti-aliased pixels in combination with non-separable blend modes and
// a white background produces several black pixels (6 for these tests).
// Having a mask will hide the black pixels.
// TODO(rosca): fix this issue for non-separable blend modes.
if (!(flags & kUseMasks))
large_error_allowed = 255;
pixel_comparator_.reset( pixel_comparator_.reset(
new FuzzyPixelComparator(false, // discard_alpha new FuzzyPixelComparator(false, // discard_alpha
percentage_pixels_error, percentage_pixels_error,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment