| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_all_or_nothing.h" | 5 #include "cc/output/overlay_strategy_all_or_nothing.h" |
| 6 | 6 |
| 7 #include "cc/output/overlay_candidate_validator.h" | 7 #include "cc/output/overlay_candidate_validator.h" |
| 8 #include "cc/quads/draw_quad.h" | 8 #include "cc/quads/draw_quad.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| 11 | 11 |
| 12 OverlayStrategyAllOrNothing::OverlayStrategyAllOrNothing( | 12 OverlayStrategyAllOrNothing::OverlayStrategyAllOrNothing( |
| 13 OverlayCandidateValidator* capability_checker) | 13 OverlayCandidateValidator* capability_checker) |
| 14 : capability_checker_(capability_checker) { | 14 : capability_checker_(capability_checker) { |
| 15 DCHECK(capability_checker); | 15 DCHECK(capability_checker); |
| 16 } | 16 } |
| 17 | 17 |
| 18 OverlayStrategyAllOrNothing::~OverlayStrategyAllOrNothing() {} | 18 OverlayStrategyAllOrNothing::~OverlayStrategyAllOrNothing() {} |
| 19 | 19 |
| 20 bool OverlayStrategyAllOrNothing::Attempt(ResourceProvider* resource_provider, | 20 bool OverlayStrategyAllOrNothing::Attempt(ResourceProvider* resource_provider, |
| 21 RenderPassList* render_passes, | 21 RenderPassList* render_passes, |
| 22 OverlayCandidateList* candidates) { | 22 OverlayCandidateList* candidates) { |
| 23 QuadList& quad_list = render_passes->back()->quad_list; | 23 QuadList& quad_list = render_passes->back()->quad_list; |
| 24 OverlayCandidateList new_candidates; | 24 OverlayCandidateList new_candidates; |
| 25 int next_z_order = -1; | 25 int next_z_order = -1; |
| 26 | 26 |
| 27 for (const DrawQuad* quad : quad_list) { | 27 for (const DrawQuad* quad : quad_list) { |
| 28 OverlayCandidate candidate; | 28 OverlayCandidate candidate; |
| 29 if (!OverlayCandidate::FromDrawQuad(resource_provider, quad, &candidate)) | 29 if (!capability_checker_->IsSupportedQuad(quad) || |
| 30 !OverlayCandidate::FromDrawQuad(resource_provider, quad, &candidate)) { |
| 30 return false; | 31 return false; |
| 32 } |
| 31 candidate.plane_z_order = next_z_order--; | 33 candidate.plane_z_order = next_z_order--; |
| 32 new_candidates.push_back(candidate); | 34 new_candidates.push_back(candidate); |
| 33 } | 35 } |
| 34 | 36 |
| 35 capability_checker_->CheckOverlaySupport(&new_candidates); | 37 capability_checker_->CheckOverlaySupport(&new_candidates); |
| 36 for (const OverlayCandidate& candidate : new_candidates) { | 38 for (const OverlayCandidate& candidate : new_candidates) { |
| 37 if (!candidate.overlay_handled) | 39 if (!candidate.overlay_handled) |
| 38 return false; | 40 return false; |
| 39 } | 41 } |
| 40 | 42 |
| 41 quad_list.clear(); | 43 quad_list.clear(); |
| 42 candidates->swap(new_candidates); | 44 candidates->swap(new_candidates); |
| 43 return true; | 45 return true; |
| 44 } | 46 } |
| 45 | 47 |
| 46 } // namespace cc | 48 } // namespace cc |
| OLD | NEW |