Skip to content

Commit

Permalink
Let OverlayStrategySingleOnTop select non-topmost quad
Browse files Browse the repository at this point in the history
Old code was too restrictive, and did not properly select the correct quad.
New code chooses the topmost overlayable plane that does not intersect any
rects above it.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288049 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
achaulk@chromium.org committed Aug 7, 2014
1 parent 51470c5 commit 2906d8e
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 98 deletions.
40 changes: 32 additions & 8 deletions cc/output/overlay_strategy_single_on_top.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,38 @@ bool OverlayStrategySingleOnTop::Attempt(
DCHECK(root_render_pass);

QuadList& quad_list = root_render_pass->quad_list;
const DrawQuad* candidate_quad = quad_list.front();
if (candidate_quad->material != DrawQuad::TEXTURE_CONTENT)
return false;

const TextureDrawQuad& quad = *TextureDrawQuad::MaterialCast(candidate_quad);
if (!resource_provider_->AllowOverlay(quad.resource_id))
QuadList::iterator candidate_iterator = quad_list.end();
for (QuadList::iterator it = quad_list.begin(); it != quad_list.end(); ++it) {
const DrawQuad* draw_quad = *it;
if (draw_quad->material == DrawQuad::TEXTURE_CONTENT) {
const TextureDrawQuad& quad = *TextureDrawQuad::MaterialCast(draw_quad);
if (!resource_provider_->AllowOverlay(quad.resource_id)) {
continue;
}
// Check that no prior quads overlap it.
bool intersects = false;
gfx::RectF rect = draw_quad->rect;
draw_quad->quadTransform().TransformRect(&rect);
for (QuadList::iterator overlap_iter = quad_list.begin();
overlap_iter != it;
++overlap_iter) {
gfx::RectF overlap_rect = (*overlap_iter)->rect;
(*overlap_iter)->quadTransform().TransformRect(&overlap_rect);
if (rect.Intersects(overlap_rect)) {
intersects = true;
break;
}
}
if (intersects)
continue;
candidate_iterator = it;
break;
}
}
if (candidate_iterator == quad_list.end())
return false;
const TextureDrawQuad& quad =
*TextureDrawQuad::MaterialCast(*candidate_iterator);

// Simple quads only.
gfx::OverlayTransform overlay_transform =
Expand Down Expand Up @@ -69,8 +94,7 @@ bool OverlayStrategySingleOnTop::Attempt(

// If the candidate can be handled by an overlay, create a pass for it.
if (candidates[1].overlay_handled) {
scoped_ptr<DrawQuad> overlay_quad = quad_list.take(quad_list.begin());
quad_list.erase(quad_list.begin());
quad_list.erase(candidate_iterator);
candidate_list->swap(candidates);
return true;
}
Expand Down
Loading

0 comments on commit 2906d8e

Please sign in to comment.