Chromium Code Reviews| Index: cc/output/overlay_strategy_sandwich.cc |
| diff --git a/cc/output/overlay_strategy_sandwich.cc b/cc/output/overlay_strategy_sandwich.cc |
| index bdcaf29d05039147320e23682f2694046aeb3061..8258cc9148b76ecb08d3ba7f099cc83a5b383c3f 100644 |
| --- a/cc/output/overlay_strategy_sandwich.cc |
| +++ b/cc/output/overlay_strategy_sandwich.cc |
| @@ -31,7 +31,7 @@ namespace cc { |
| OverlayStrategySandwich::~OverlayStrategySandwich() {} |
| -bool OverlayStrategySandwich::TryOverlay( |
| +QuadList::Iterator OverlayStrategySandwich::TryOverlay( |
| OverlayCandidateValidator* capability_checker, |
| RenderPassList* render_passes_in_draw_order, |
| OverlayCandidateList* output_candidate_list, |
| @@ -47,21 +47,21 @@ bool OverlayStrategySandwich::TryOverlay( |
| candidate_quad->shared_quad_state->quad_to_target_transform; |
| gfx::Transform candidate_inverse_transform; |
| if (!candidate_transform.GetInverse(&candidate_inverse_transform)) |
| - return false; |
| + return ++candidate_iter_in_quad_list; |
| // Compute the candidate's rect in display space (pixels on the screen). The |
| // rect needs to be DIP-aligned, or we cannot use it. |
| gfx::RectF candidate_pixel_rect_float = candidate_quad->rect; |
| candidate_transform.TransformRect(&candidate_pixel_rect_float); |
| - gfx::Rect candidate_pixel_rect; |
| - candidate_pixel_rect = gfx::ToEnclosingRect(candidate_pixel_rect_float); |
| - if (candidate_pixel_rect != candidate_pixel_rect_float) |
| - return false; |
| - if (!IsPixelRectAlignedToDIP(device_scale_factor, candidate_pixel_rect)) |
| - return false; |
| - |
| - // Iterate through the quads in front of |potential_candidate|, and compute |
| - // the region of |potential_candidate| that is covered. |
| + const gfx::Rect candidate_pixel_rect = |
| + gfx::ToEnclosingRect(candidate_pixel_rect_float); |
| + if (candidate_pixel_rect != candidate_pixel_rect_float || |
| + !IsPixelRectAlignedToDIP(device_scale_factor, candidate_pixel_rect)) { |
| + return ++candidate_iter_in_quad_list; |
| + } |
| + |
| + // Iterate through the quads in front of |candidate|, and compute the region |
| + // of |candidate| that is covered. |
| Region pixel_covered_region; |
| for (auto overlap_iter = quad_list.cbegin(); |
| overlap_iter != candidate_iter_in_quad_list; ++overlap_iter) { |
| @@ -81,14 +81,9 @@ bool OverlayStrategySandwich::TryOverlay( |
| pixel_covered_region.Union(pixel_covered_rect); |
|
ccameron
2015/09/02 21:41:55
We should only promote to an overlay layer here if
Andre
2015/09/02 21:54:51
Got it.
|
| } |
| - // Add our primary surface. |
| - OverlayCandidateList new_candidate_list; |
| - OverlayCandidate main_image; |
| - main_image.display_rect = pixel_bounds; |
| - new_candidate_list.push_back(main_image); |
| - |
| // Add the candidate's overlay. |
| DCHECK(candidate.resource_id); |
| + OverlayCandidateList new_candidate_list; |
| new_candidate_list.push_back(candidate); |
| new_candidate_list.back().plane_z_order = 1; |
| @@ -114,14 +109,15 @@ bool OverlayStrategySandwich::TryOverlay( |
| // Check for support. |
| capability_checker->CheckOverlaySupport(&new_candidate_list); |
| for (const OverlayCandidate& candidate : new_candidate_list) { |
| - if (candidate.plane_z_order > 0 && !candidate.overlay_handled) |
| - return false; |
| + if (!candidate.overlay_handled) |
| + return ++candidate_iter_in_quad_list; |
| } |
| // Remove the quad for the overlay quad. Replace it with a transparent quad |
| // if we're putting a new overlay on top. |
| if (pixel_covered_rects.empty()) { |
| - quad_list.EraseAndInvalidateAllPointers(candidate_iter_in_quad_list); |
| + candidate_iter_in_quad_list = |
| + quad_list.EraseAndInvalidateAllPointers(candidate_iter_in_quad_list); |
| } else { |
| // Cache the information from the candidate quad that we'll need to |
| // construct the solid color quads. |
| @@ -154,8 +150,17 @@ bool OverlayStrategySandwich::TryOverlay( |
| } |
| } |
| - output_candidate_list->swap(new_candidate_list); |
| - return true; |
| + if (output_candidate_list->empty()) { |
| + // Add our primary surface. |
| + OverlayCandidate main_image; |
| + main_image.display_rect = pixel_bounds; |
| + output_candidate_list->push_back(main_image); |
| + } |
| + |
| + output_candidate_list->insert(output_candidate_list->end(), |
| + new_candidate_list.begin(), |
| + new_candidate_list.end()); |
| + return candidate_iter_in_quad_list; |
| } |
| } // namespace cc |