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

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

Issue 1452943002: cc: Fix overlay damage tracking bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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_processor.h ('k') | cc/output/overlay_strategy_sandwich.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_processor.h" 5 #include "cc/output/overlay_processor.h"
6 6
7 #include "cc/output/output_surface.h" 7 #include "cc/output/output_surface.h"
8 #include "cc/output/overlay_strategy_single_on_top.h" 8 #include "cc/output/overlay_strategy_single_on_top.h"
9 #include "cc/output/overlay_strategy_underlay.h" 9 #include "cc/output/overlay_strategy_underlay.h"
10 #include "cc/quads/draw_quad.h" 10 #include "cc/quads/draw_quad.h"
11 #include "ui/gfx/geometry/rect_conversions.h" 11 #include "ui/gfx/geometry/rect_conversions.h"
12 #include "ui/gfx/transform.h" 12 #include "ui/gfx/transform.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) { 16 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) {
17 } 17 }
18 18
19 void OverlayProcessor::Initialize() { 19 void OverlayProcessor::Initialize() {
20 DCHECK(surface_); 20 DCHECK(surface_);
21 OverlayCandidateValidator* validator = 21 OverlayCandidateValidator* validator =
22 surface_->GetOverlayCandidateValidator(); 22 surface_->GetOverlayCandidateValidator();
23 if (validator) 23 if (validator)
24 validator->GetStrategies(&strategies_); 24 validator->GetStrategies(&strategies_);
25 } 25 }
26 26
27 OverlayProcessor::~OverlayProcessor() {} 27 OverlayProcessor::~OverlayProcessor() {}
28 28
29 gfx::Rect OverlayProcessor::GetAndResetOverlayDamage() {
30 gfx::Rect result = overlay_damage_rect_;
31 overlay_damage_rect_ = gfx::Rect();
32 return result;
33 }
34
29 bool OverlayProcessor::ProcessForCALayers( 35 bool OverlayProcessor::ProcessForCALayers(
30 ResourceProvider* resource_provider, 36 ResourceProvider* resource_provider,
31 RenderPassList* render_passes, 37 RenderPassList* render_passes,
38 OverlayCandidateList* overlay_candidates,
32 CALayerOverlayList* ca_layer_overlays, 39 CALayerOverlayList* ca_layer_overlays,
33 OverlayCandidateList* overlay_candidates) { 40 gfx::Rect* damage_rect) {
34 RenderPass* root_render_pass = render_passes->back().get(); 41 RenderPass* root_render_pass = render_passes->back().get();
35 42
36 OverlayCandidateValidator* overlay_validator = 43 OverlayCandidateValidator* overlay_validator =
37 surface_->GetOverlayCandidateValidator(); 44 surface_->GetOverlayCandidateValidator();
38 if (!overlay_validator || !overlay_validator->AllowCALayerOverlays()) 45 if (!overlay_validator || !overlay_validator->AllowCALayerOverlays())
39 return false; 46 return false;
40 47
41 if (!ProcessForCALayerOverlays( 48 if (!ProcessForCALayerOverlays(
42 resource_provider, gfx::RectF(root_render_pass->output_rect), 49 resource_provider, gfx::RectF(root_render_pass->output_rect),
43 root_render_pass->quad_list, ca_layer_overlays)) 50 root_render_pass->quad_list, ca_layer_overlays))
44 return false; 51 return false;
45 52
46 // CALayer overlays are all-or-nothing. If all quads were replaced with 53 // CALayer overlays are all-or-nothing. If all quads were replaced with
47 // layers then clear the list and remove the backbuffer from the overcandidate 54 // layers then clear the list and remove the backbuffer from the overcandidate
48 // list. 55 // list.
49 overlay_candidates->clear(); 56 overlay_candidates->clear();
50 render_passes->back()->quad_list.clear(); 57 render_passes->back()->quad_list.clear();
58 overlay_damage_rect_ = root_render_pass->output_rect;
59 *damage_rect = gfx::Rect();
51 return true; 60 return true;
52 } 61 }
53 62
54 void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider, 63 void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider,
55 RenderPassList* render_passes, 64 RenderPassList* render_passes,
56 OverlayCandidateList* candidates, 65 OverlayCandidateList* candidates,
66 CALayerOverlayList* ca_layer_overlays,
57 gfx::Rect* damage_rect) { 67 gfx::Rect* damage_rect) {
68 // First attempt to process for CALayers.
69 if (ProcessForCALayers(resource_provider, render_passes, candidates,
kalyank 2015/11/18 21:18:33 What happens on platforms which don't use CALayers
ccameron 2015/11/18 21:22:12 The overlay_validator->AllowCALayerOverlays() call
70 ca_layer_overlays, damage_rect)) {
71 return;
72 }
73
74 // Only if that fails, attempt hardware overlay strategies.
58 for (const auto& strategy : strategies_) { 75 for (const auto& strategy : strategies_) {
59 if (strategy->Attempt(resource_provider, render_passes, candidates, 76 if (!strategy->Attempt(resource_provider, render_passes, candidates))
60 damage_rect)) { 77 continue;
61 return; 78
79 // Subtract on-top overlays from the damage rect, unless the overlays use
80 // the backbuffer as their content (in which case, add their combined rect
81 // back to the damage at the end).
82 gfx::Rect output_surface_overlay_damage_rect;
83 for (const OverlayCandidate& overlay : *candidates) {
84 if (overlay.plane_z_order > 0) {
85 const gfx::Rect overlay_display_rect =
86 ToEnclosedRect(overlay.display_rect);
87 overlay_damage_rect_.Union(overlay_display_rect);
88 damage_rect->Subtract(overlay_display_rect);
89 if (overlay.use_output_surface_for_resource)
90 output_surface_overlay_damage_rect.Union(overlay_display_rect);
91 }
62 } 92 }
93 damage_rect->Union(output_surface_overlay_damage_rect);
94 return;
63 } 95 }
64 } 96 }
65 97
66 } // namespace cc 98 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/overlay_processor.h ('k') | cc/output/overlay_strategy_sandwich.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698