Commit a41ecf3a authored by Weiliang Chen's avatar Weiliang Chen Committed by Commit Bot

cc: Add function to replace quad with solid color to reduce duplication

Add a function to replace existing quad with a solid color draw quad to
reduce duplicate code in overlay.

R=danakj@chromium.org

Bug: 739429
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I6ea4df426dde50122b73923d970ea3e6429dd8aa
Reviewed-on: https://chromium-review.googlesource.com/596647
Commit-Queue: weiliangc <weiliangc@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarJohn Bauman <jbauman@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491153}
parent 4d941711
......@@ -239,12 +239,7 @@ bool DCLayerOverlayProcessor::ProcessForUnderlay(
*this_frame_underlay_rect = quad_rectangle;
}
dc_layer->shared_state->z_order = -1;
const SharedQuadState* shared_quad_state = it->shared_quad_state;
gfx::Rect rect = it->visible_rect;
SolidColorDrawQuad* replacement =
render_pass->quad_list.ReplaceExistingElement<SolidColorDrawQuad>(it);
replacement->SetAll(shared_quad_state, rect, rect, rect, false,
SK_ColorTRANSPARENT, true);
render_pass->quad_list.ReplaceExistingQuadWithOpaqueTransparentSolidColor(it);
if (*this_frame_underlay_rect == previous_frame_underlay_rect_ && is_root) {
// If this underlay rect is the same as for last frame, subtract its
......
......@@ -41,12 +41,7 @@ bool OverlayStrategyUnderlay::Attempt(ResourceProvider* resource_provider,
if (new_candidate_list.back().overlay_handled) {
new_candidate_list.back().is_unoccluded =
!OverlayCandidate::IsOccluded(candidate, quad_list.cbegin(), it);
const SharedQuadState* shared_quad_state = it->shared_quad_state;
gfx::Rect rect = it->visible_rect;
SolidColorDrawQuad* replacement =
quad_list.ReplaceExistingElement<SolidColorDrawQuad>(it);
replacement->SetAll(shared_quad_state, rect, rect, rect, false,
SK_ColorTRANSPARENT, true);
quad_list.ReplaceExistingQuadWithOpaqueTransparentSolidColor(it);
candidate_list->swap(new_candidate_list);
// This quad will be promoted. We clear the promotable hints here, since
......
......@@ -1380,6 +1380,12 @@ TEST_F(UnderlayTest, OverlayLayerUnderMainLayer) {
EXPECT_EQ(2U, main_pass->quad_list.size());
// The overlay quad should have changed to a SOLID_COLOR quad.
EXPECT_EQ(main_pass->quad_list.back()->material, DrawQuad::SOLID_COLOR);
SolidColorDrawQuad* quad =
static_cast<SolidColorDrawQuad*>(main_pass->quad_list.back());
EXPECT_EQ(quad->rect, quad->opaque_rect);
EXPECT_EQ(quad->rect, quad->visible_rect);
EXPECT_EQ(false, quad->needs_blending);
EXPECT_EQ(SK_ColorTRANSPARENT, quad->color);
}
TEST_F(UnderlayTest, AllowOnTop) {
......@@ -1405,6 +1411,12 @@ TEST_F(UnderlayTest, AllowOnTop) {
EXPECT_EQ(-1, candidate_list[0].plane_z_order);
// The overlay quad should have changed to a SOLID_COLOR quad.
EXPECT_EQ(main_pass->quad_list.front()->material, DrawQuad::SOLID_COLOR);
SolidColorDrawQuad* quad =
static_cast<SolidColorDrawQuad*>(main_pass->quad_list.front());
EXPECT_EQ(quad->rect, quad->opaque_rect);
EXPECT_EQ(quad->rect, quad->visible_rect);
EXPECT_EQ(false, quad->needs_blending);
EXPECT_EQ(SK_ColorTRANSPARENT, quad->color);
}
// The first time an underlay is scheduled its damage must not be subtracted.
......
......@@ -46,6 +46,23 @@ QuadList::QuadList(size_t default_size_to_reserve)
LargestDrawQuadSize(),
default_size_to_reserve) {}
void QuadList::ReplaceExistingQuadWithOpaqueTransparentSolidColor(Iterator at) {
// In order to fill the backbuffer with transparent black, the replacement
// solid color quad needs to set |needs_blending| to false, and set both
// |visible_rect| and |opaque_rect| to its quad rect so it is drawn and
// ShouldDrawWithBlending() returns false so it is drawn without blending.
const gfx::Rect& rect = at->rect;
const gfx::Rect& opaque_rect = at->rect;
const gfx::Rect& visible_rect = at->rect;
bool needs_blending = false;
const SharedQuadState* shared_quad_state = at->shared_quad_state;
SolidColorDrawQuad* replacement =
QuadList::ReplaceExistingElement<SolidColorDrawQuad>(at);
replacement->SetAll(shared_quad_state, rect, opaque_rect, visible_rect,
needs_blending, SK_ColorTRANSPARENT, true);
}
std::unique_ptr<RenderPass> RenderPass::Create() {
return base::WrapUnique(new RenderPass());
}
......
......@@ -52,6 +52,10 @@ class CC_EXPORT QuadList : public ListContainer<DrawQuad> {
inline BackToFrontIterator BackToFrontEnd() { return rend(); }
inline ConstBackToFrontIterator BackToFrontBegin() const { return rbegin(); }
inline ConstBackToFrontIterator BackToFrontEnd() const { return rend(); }
// This function is used by overlay algorithm to fill the backbuffer with
// transparent black.
void ReplaceExistingQuadWithOpaqueTransparentSolidColor(Iterator at);
};
typedef ListContainer<SharedQuadState> SharedQuadStateList;
......
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