Commit 3cd3ad22 authored by Adrienne Walker's avatar Adrienne Walker Committed by Commit Bot

cc: don't allow transparent quads for opaque layers

This is a DCHECK + workaround for issue 988590.

https://chromium-review.googlesource.com/c/chromium/src/+/1749703
solves root of the problem, and will avoid this DCHECK for
this particular content.

Bug: 988590
Change-Id: I0e66ba388c11bbc3805ead42343d7fe7af7a79da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1752873
Commit-Queue: enne <enne@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689250}
parent 2311fc53
......@@ -128,6 +128,11 @@ int DebugColors::OOMTileBorderWidth(float device_scale_factor) {
return Scale(1, device_scale_factor);
}
// Missing opaque colors are magenta.
SkColor DebugColors::MissingOpaqueTileColor() {
return SK_ColorMAGENTA;
}
// Direct picture borders are chartreuse.
SkColor DebugColors::DirectPictureBorderColor() {
return SkColorSetARGB(255, 127, 255, 0);
......
......@@ -57,6 +57,8 @@ class CC_DEBUG_EXPORT DebugColors {
static SkColor OOMTileBorderColor();
static int OOMTileBorderWidth(float device_scale_factor);
static SkColor MissingOpaqueTileColor();
static SkColor DirectPictureBorderColor();
static int DirectPictureBorderWidth(float device_scale_factor);
......
......@@ -232,11 +232,30 @@ void PictureLayerImpl::AppendQuads(viz::RenderPass* render_pass,
occlusion = draw_properties().occlusion_in_content_space;
}
SkColor color = raster_source_->GetSolidColor();
if (contents_opaque() && SkColorGetA(color) != 255) {
// If we get to this code, then this has been a failure of
// solid color detection on a layer that we think should
// be opaque.
//
// It would be nice to NOTREACHED() this, but too many
// ui/ tests set up transparent-but-opaque layers.
//
// Because this could lead to spoofing between pages, and
// other severe graphical issues due to not clearing the
// backbuffer, also set this color to something known to be
// opaque.
#ifndef NDEBUG
color = DebugColors::MissingOpaqueTileColor();
#else
color = SafeOpaqueBackgroundColor();
#endif
}
EffectNode* effect_node = GetEffectTree().Node(effect_tree_index());
SolidColorLayerImpl::AppendSolidQuads(
render_pass, occlusion, shared_quad_state, scaled_visible_layer_rect,
raster_source_->GetSolidColor(),
!layer_tree_impl()->settings().enable_edge_anti_aliasing,
color, !layer_tree_impl()->settings().enable_edge_anti_aliasing,
effect_node->blend_mode, append_quads_data);
return;
}
......@@ -441,16 +460,34 @@ void PictureLayerImpl::AppendQuads(viz::RenderPass* render_pass,
break;
}
case TileDrawInfo::SOLID_COLOR_MODE: {
float alpha =
(SkColorGetA(draw_info.solid_color()) * (1.0f / 255.0f)) *
shared_quad_state->opacity;
SkColor color = draw_info.solid_color();
if (contents_opaque() && SkColorGetA(color) != 255) {
// If we get to this code, then this has been a failure of
// solid color detection on a layer that we think should
// be opaque.
//
// It would be nice to NOTREACHED() this, but too many
// ui/ tests set up transparent-but-opaque layers.
//
// Because this could lead to spoofing between pages, and
// other severe graphical issues due to not clearing the
// backbuffer, also set this color to something known to be
// opaque.
#ifndef NDEBUG
color = DebugColors::MissingOpaqueTileColor();
#else
color = SafeOpaqueBackgroundColor();
#endif
}
float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) *
shared_quad_state->opacity;
if (mask_type_ != Layer::LayerMaskType::NOT_MASK ||
alpha >= std::numeric_limits<float>::epsilon()) {
auto* quad =
render_pass->CreateAndAppendDrawQuad<viz::SolidColorDrawQuad>();
quad->SetNew(
shared_quad_state, offset_geometry_rect,
offset_visible_geometry_rect, draw_info.solid_color(),
offset_visible_geometry_rect, color,
!layer_tree_impl()->settings().enable_edge_anti_aliasing);
ValidateQuadResources(quad);
}
......
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