Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: cc/output/overlay_strategy_single_on_top.cc

Issue 1372103005: Refactor OverlayStrategySandwich and OverlayStrategyCommon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SolidColor
Patch Set: Delete OverlayStrategyCommon Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/overlay_strategy_single_on_top.h" 5 #include "cc/output/overlay_strategy_single_on_top.h"
6 6
7 #include <limits>
8
9 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
10 #include "cc/output/overlay_candidate_validator.h" 8 #include "cc/output/overlay_candidate_validator.h"
11 #include "cc/quads/draw_quad.h" 9 #include "cc/quads/draw_quad.h"
12 10
13 namespace cc { 11 namespace cc {
14 12
13 OverlayStrategySingleOnTop::OverlayStrategySingleOnTop(
14 OverlayCandidateValidator* capability_checker)
15 : capability_checker_(capability_checker) {
16 DCHECK(capability_checker);
17 }
18
15 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {} 19 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {}
16 20
17 OverlayResult OverlayStrategySingleOnTop::TryOverlay( 21 bool OverlayStrategySingleOnTop::Attempt(RenderPassList* render_passes,
18 OverlayCandidateValidator* capability_checker, 22 OverlayCandidateList* candidate_list) {
19 RenderPassList* render_passes_in_draw_order, 23 QuadList& quad_list = render_passes->back()->quad_list;
ccameron 2015/10/05 19:28:29 Just out of curiosity, any reason you didn't inlin
Andre 2015/10/05 20:24:20 To inline, the "return false" in line 48 needs to
24 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) {
25 OverlayCandidate candidate;
26 if (OverlayCandidate::FromDrawQuad(*it, &candidate) &&
27 TryOverlay(quad_list, candidate_list, candidate, it)) {
28 return true;
29 }
30 }
31
32 return false;
33 }
34
35 bool OverlayStrategySingleOnTop::TryOverlay(
36 QuadList& quad_list,
20 OverlayCandidateList* candidate_list, 37 OverlayCandidateList* candidate_list,
21 const OverlayCandidate& candidate, 38 const OverlayCandidate& candidate,
22 QuadList::Iterator* candidate_iterator, 39 QuadList::Iterator candidate_iterator) {
23 float device_scale_factor) {
24 RenderPass* root_render_pass = render_passes_in_draw_order->back();
25 QuadList& quad_list = root_render_pass->quad_list;
26 // Check that no prior quads overlap it. 40 // Check that no prior quads overlap it.
27 for (auto overlap_iter = quad_list.cbegin(); 41 for (auto overlap_iter = quad_list.cbegin();
28 overlap_iter != *candidate_iterator; ++overlap_iter) { 42 overlap_iter != candidate_iterator; ++overlap_iter) {
29 gfx::RectF overlap_rect = MathUtil::MapClippedRect( 43 gfx::RectF overlap_rect = MathUtil::MapClippedRect(
30 overlap_iter->shared_quad_state->quad_to_target_transform, 44 overlap_iter->shared_quad_state->quad_to_target_transform,
31 gfx::RectF(overlap_iter->rect)); 45 gfx::RectF(overlap_iter->rect));
32 if (candidate.display_rect.Intersects(overlap_rect) && 46 if (candidate.display_rect.Intersects(overlap_rect) &&
33 !OverlayStrategyCommon::IsInvisibleQuad(*overlap_iter)) 47 !OverlayCandidate::IsInvisibleQuad(*overlap_iter))
34 return DID_NOT_CREATE_OVERLAY; 48 return false;
35 } 49 }
36 50
37 // Add the overlay. 51 // Add the overlay.
38 OverlayCandidateList new_candidate_list = *candidate_list; 52 OverlayCandidateList new_candidate_list = *candidate_list;
39 new_candidate_list.push_back(candidate); 53 new_candidate_list.push_back(candidate);
40 new_candidate_list.back().plane_z_order = 1; 54 new_candidate_list.back().plane_z_order = 1;
41 55
42 // Check for support. 56 // Check for support.
43 capability_checker->CheckOverlaySupport(&new_candidate_list); 57 capability_checker_->CheckOverlaySupport(&new_candidate_list);
44 58
45 // If the candidate can be handled by an overlay, create a pass for it. 59 // If the candidate can be handled by an overlay, create a pass for it.
46 if (new_candidate_list.back().overlay_handled) { 60 if (new_candidate_list.back().overlay_handled) {
47 quad_list.EraseAndInvalidateAllPointers(*candidate_iterator); 61 quad_list.EraseAndInvalidateAllPointers(candidate_iterator);
48 candidate_list->swap(new_candidate_list); 62 candidate_list->swap(new_candidate_list);
49 return CREATED_OVERLAY_STOP_LOOKING; 63 return true;
50 } 64 }
51 65
52 return DID_NOT_CREATE_OVERLAY; 66 return false;
53 } 67 }
54 68
55 } // namespace cc 69 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698