Commit 21fe8132 authored by dcastagna's avatar dcastagna Committed by Commit bot

cc: Enable non-opaque harware overlays.

This CL enables alpha-blended HW overlays.

Additionally, it clears up the way overlay candidates might or might not
be considered based on buffer format and alpha blending requested:

- An opacity on the quad different than 1 will cause the candidate to
  always be rejected since we can't modulate the alpha of an overlay plane.

- We support only kSrc (no blending) and kSrcOver (blend) blending modes.

- For fullscreen overlays we can allow both blending modes as long as the
  opaque rect is as big as the buffer (ShouldDrawWithBlending() true).
  An opaque FD will always be used in this case (crrev.com/2743403005).

- For non-fullscreen overlays, we can't allow kSrc if the buffer has a
  format with an alpha channel, since the alpha channel might not be
  initialized and we don't disable blending when scanning out yet.

BUG=695296
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2749783006
Cr-Commit-Position: refs/heads/master@{#457528}
parent 4576d3a0
......@@ -195,9 +195,12 @@ OverlayCandidate::~OverlayCandidate() {}
bool OverlayCandidate::FromDrawQuad(ResourceProvider* resource_provider,
const DrawQuad* quad,
OverlayCandidate* candidate) {
if (quad->ShouldDrawWithBlending() ||
quad->shared_quad_state->opacity != 1.f ||
quad->shared_quad_state->blend_mode != SkBlendMode::kSrcOver)
// We don't support an opacity value different than one for an overlay plane.
if (quad->shared_quad_state->opacity != 1.f)
return false;
// We support only kSrc (no blending) and kSrcOver (blending with premul).
if (!(quad->shared_quad_state->blend_mode == SkBlendMode::kSrc ||
quad->shared_quad_state->blend_mode == SkBlendMode::kSrcOver))
return false;
auto& transform = quad->shared_quad_state->quad_to_target_transform;
......
......@@ -39,9 +39,7 @@ bool OverlayStrategyFullscreen::Attempt(
return false;
const DrawQuad* quad = *front;
if (quad->ShouldDrawWithBlending() ||
quad->shared_quad_state->opacity != 1.f ||
quad->shared_quad_state->blend_mode != SkBlendMode::kSrcOver)
if (quad->ShouldDrawWithBlending())
return false;
OverlayCandidate candidate;
......
......@@ -7,9 +7,15 @@
#include "cc/base/math_util.h"
#include "cc/output/overlay_candidate_validator.h"
#include "cc/quads/draw_quad.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/rect_conversions.h"
namespace cc {
namespace {
const gfx::BufferFormat kOverlayFormatsWithAlpha[] = {
gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888};
}
OverlayStrategySingleOnTop::OverlayStrategySingleOnTop(
OverlayCandidateValidator* capability_checker)
......@@ -34,6 +40,17 @@ bool OverlayStrategySingleOnTop::Attempt(
// TODO(dcastagna): Remove this once drm platform supports transforms.
candidate.transform == gfx::OVERLAY_TRANSFORM_NONE &&
!OverlayCandidate::IsOccluded(candidate, quad_list->cbegin(), it)) {
// We currently reject quads with alpha that do not request alpha blending
// since the alpha channel might not be set to 1 and we're not disabling
// blending when scanning out.
// TODO(dcastagna): We should support alpha formats without blending using
// the opaque FB at scanout.
if (std::find(std::begin(kOverlayFormatsWithAlpha),
std::end(kOverlayFormatsWithAlpha),
candidate.format) != std::end(kOverlayFormatsWithAlpha) &&
it->shared_quad_state->blend_mode == SkBlendMode::kSrc)
continue;
if (candidate.display_rect.size().GetArea() >
best_candidate.display_rect.size().GetArea()) {
best_candidate = candidate;
......
......@@ -835,13 +835,14 @@ TEST_F(SingleOverlayOnTopTest, MultipleRenderPasses) {
EXPECT_EQ(1U, candidate_list.size());
}
TEST_F(SingleOverlayOnTopTest, RejectBlending) {
TEST_F(SingleOverlayOnTopTest, AcceptBlending) {
std::unique_ptr<RenderPass> pass = CreateRenderPass();
TextureDrawQuad* quad =
CreateFullscreenCandidateQuad(resource_provider_.get(),
pass->shared_quad_state_list.back(),
pass.get());
quad->needs_blending = true;
quad->opaque_rect = gfx::Rect(0, 0, 0, 0);
OverlayCandidateList candidate_list;
RenderPassFilterList render_pass_filters;
......@@ -850,7 +851,7 @@ TEST_F(SingleOverlayOnTopTest, RejectBlending) {
resource_provider_.get(), pass.get(), render_pass_filters,
render_pass_background_filters, &candidate_list, nullptr, nullptr,
&damage_rect_, &content_bounds_);
EXPECT_EQ(0U, candidate_list.size());
EXPECT_EQ(1U, candidate_list.size());
}
TEST_F(SingleOverlayOnTopTest, RejectBackgroundColor) {
......
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