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

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

Issue 1452943002: cc: Fix overlay damage tracking bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add buffer queue update Created 5 years, 1 month 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
« no previous file with comments | « cc/output/overlay_strategy_single_on_top.h ('k') | cc/output/overlay_strategy_underlay.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/output/overlay_candidate_validator.h" 8 #include "cc/output/overlay_candidate_validator.h"
9 #include "cc/quads/draw_quad.h" 9 #include "cc/quads/draw_quad.h"
10 #include "ui/gfx/geometry/rect_conversions.h" 10 #include "ui/gfx/geometry/rect_conversions.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 OverlayStrategySingleOnTop::OverlayStrategySingleOnTop( 14 OverlayStrategySingleOnTop::OverlayStrategySingleOnTop(
15 OverlayCandidateValidator* capability_checker) 15 OverlayCandidateValidator* capability_checker)
16 : capability_checker_(capability_checker) { 16 : capability_checker_(capability_checker) {
17 DCHECK(capability_checker); 17 DCHECK(capability_checker);
18 } 18 }
19 19
20 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {} 20 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {}
21 21
22 bool OverlayStrategySingleOnTop::Attempt(ResourceProvider* resource_provider, 22 bool OverlayStrategySingleOnTop::Attempt(ResourceProvider* resource_provider,
23 RenderPassList* render_passes, 23 RenderPassList* render_passes,
24 OverlayCandidateList* candidate_list, 24 OverlayCandidateList* candidate_list) {
25 gfx::Rect* damage_rect) {
26 QuadList* quad_list = &render_passes->back()->quad_list; 25 QuadList* quad_list = &render_passes->back()->quad_list;
27 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) { 26 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) {
28 OverlayCandidate candidate; 27 OverlayCandidate candidate;
29 if (OverlayCandidate::FromDrawQuad(resource_provider, *it, &candidate) && 28 if (OverlayCandidate::FromDrawQuad(resource_provider, *it, &candidate) &&
30 TryOverlay(quad_list, candidate_list, candidate, it, damage_rect)) { 29 TryOverlay(quad_list, candidate_list, candidate, it)) {
31 return true; 30 return true;
32 } 31 }
33 } 32 }
34 33
35 return false; 34 return false;
36 } 35 }
37 36
38 bool OverlayStrategySingleOnTop::TryOverlay( 37 bool OverlayStrategySingleOnTop::TryOverlay(
39 QuadList* quad_list, 38 QuadList* quad_list,
40 OverlayCandidateList* candidate_list, 39 OverlayCandidateList* candidate_list,
41 const OverlayCandidate& candidate, 40 const OverlayCandidate& candidate,
42 QuadList::Iterator candidate_iterator, 41 QuadList::Iterator candidate_iterator) {
43 gfx::Rect* damage_rect) {
44 // Check that no prior quads overlap it. 42 // Check that no prior quads overlap it.
45 for (auto overlap_iter = quad_list->cbegin(); 43 for (auto overlap_iter = quad_list->cbegin();
46 overlap_iter != candidate_iterator; ++overlap_iter) { 44 overlap_iter != candidate_iterator; ++overlap_iter) {
47 gfx::RectF overlap_rect = MathUtil::MapClippedRect( 45 gfx::RectF overlap_rect = MathUtil::MapClippedRect(
48 overlap_iter->shared_quad_state->quad_to_target_transform, 46 overlap_iter->shared_quad_state->quad_to_target_transform,
49 gfx::RectF(overlap_iter->rect)); 47 gfx::RectF(overlap_iter->rect));
50 if (candidate.display_rect.Intersects(overlap_rect) && 48 if (candidate.display_rect.Intersects(overlap_rect) &&
51 !OverlayCandidate::IsInvisibleQuad(*overlap_iter)) 49 !OverlayCandidate::IsInvisibleQuad(*overlap_iter))
52 return false; 50 return false;
53 } 51 }
54 52
55 // Add the overlay. 53 // Add the overlay.
56 OverlayCandidateList new_candidate_list = *candidate_list; 54 OverlayCandidateList new_candidate_list = *candidate_list;
57 new_candidate_list.push_back(candidate); 55 new_candidate_list.push_back(candidate);
58 new_candidate_list.back().plane_z_order = 1; 56 new_candidate_list.back().plane_z_order = 1;
59 57
60 // Check for support. 58 // Check for support.
61 capability_checker_->CheckOverlaySupport(&new_candidate_list); 59 capability_checker_->CheckOverlaySupport(&new_candidate_list);
62 60
63 const OverlayCandidate& overlay_candidate = new_candidate_list.back(); 61 const OverlayCandidate& overlay_candidate = new_candidate_list.back();
64 // If the candidate can be handled by an overlay, create a pass for it. 62 // If the candidate can be handled by an overlay, create a pass for it.
65 if (overlay_candidate.overlay_handled) { 63 if (overlay_candidate.overlay_handled) {
66 quad_list->EraseAndInvalidateAllPointers(candidate_iterator); 64 quad_list->EraseAndInvalidateAllPointers(candidate_iterator);
67 candidate_list->swap(new_candidate_list); 65 candidate_list->swap(new_candidate_list);
68 damage_rect->Subtract(ToEnclosedRect(overlay_candidate.display_rect));
69 return true; 66 return true;
70 } 67 }
71 68
72 return false; 69 return false;
73 } 70 }
74 71
75 } // namespace cc 72 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/overlay_strategy_single_on_top.h ('k') | cc/output/overlay_strategy_underlay.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698