OLD | NEW |
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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 cc::OverlayCandidateList* candidates_; | 32 cc::OverlayCandidateList* candidates_; |
33 | 33 |
34 DISALLOW_COPY_AND_ASSIGN(SendPromotionHintsBeforeReturning); | 34 DISALLOW_COPY_AND_ASSIGN(SendPromotionHintsBeforeReturning); |
35 }; | 35 }; |
36 #endif | 36 #endif |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 namespace cc { | 40 namespace cc { |
41 | 41 |
| 42 bool OverlayProcessor::Strategy::GetSwapWithDamageRect(gfx::Rect* rect) { |
| 43 return false; |
| 44 } |
| 45 |
42 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) { | 46 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) { |
43 } | 47 } |
44 | 48 |
45 void OverlayProcessor::Initialize() { | 49 void OverlayProcessor::Initialize() { |
46 DCHECK(surface_); | 50 DCHECK(surface_); |
47 OverlayCandidateValidator* validator = | 51 OverlayCandidateValidator* validator = |
48 surface_->GetOverlayCandidateValidator(); | 52 surface_->GetOverlayCandidateValidator(); |
49 if (validator) | 53 if (validator) |
50 validator->GetStrategies(&strategies_); | 54 validator->GetStrategies(&strategies_); |
51 } | 55 } |
(...skipping 29 matching lines...) Expand all Loading... |
81 overlay_damage_rect_ = render_pass->output_rect; | 85 overlay_damage_rect_ = render_pass->output_rect; |
82 *damage_rect = gfx::Rect(); | 86 *damage_rect = gfx::Rect(); |
83 return true; | 87 return true; |
84 } | 88 } |
85 | 89 |
86 void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider, | 90 void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider, |
87 RenderPass* render_pass, | 91 RenderPass* render_pass, |
88 OverlayCandidateList* candidates, | 92 OverlayCandidateList* candidates, |
89 CALayerOverlayList* ca_layer_overlays, | 93 CALayerOverlayList* ca_layer_overlays, |
90 gfx::Rect* damage_rect) { | 94 gfx::Rect* damage_rect) { |
| 95 have_swap_with_damage_rect_ = false; |
91 #if defined(OS_ANDROID) | 96 #if defined(OS_ANDROID) |
92 // Be sure to send out notifications, regardless of whether we get to | 97 // Be sure to send out notifications, regardless of whether we get to |
93 // processing for overlays or not. If we don't, then we should notify that | 98 // processing for overlays or not. If we don't, then we should notify that |
94 // they are not promotable. | 99 // they are not promotable. |
95 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); | 100 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); |
96 #endif | 101 #endif |
97 | 102 |
98 // If we have any copy requests, we can't remove any quads for overlays or | 103 // If we have any copy requests, we can't remove any quads for overlays or |
99 // CALayers because the framebuffer would be missing the removed quads' | 104 // CALayers because the framebuffer would be missing the removed quads' |
100 // contents. | 105 // contents. |
101 if (!render_pass->copy_requests.empty()) { | 106 if (!render_pass->copy_requests.empty()) { |
102 // If overlay processing was skipped for a frame there's no way to be sure | 107 // If overlay processing was skipped for a frame there's no way to be sure |
103 // of the state of the previous frame, so reset. | 108 // of the state of the previous frame, so reset. |
104 previous_frame_underlay_rect_ = gfx::Rect(); | 109 previous_frame_underlay_rect_ = gfx::Rect(); |
105 return; | 110 return; |
106 } | 111 } |
107 | 112 |
108 // First attempt to process for CALayers. | 113 // First attempt to process for CALayers. |
109 if (ProcessForCALayers(resource_provider, render_pass, candidates, | 114 if (ProcessForCALayers(resource_provider, render_pass, candidates, |
110 ca_layer_overlays, damage_rect)) { | 115 ca_layer_overlays, damage_rect)) { |
111 return; | 116 return; |
112 } | 117 } |
113 | 118 |
114 // Only if that fails, attempt hardware overlay strategies. | 119 // Only if that fails, attempt hardware overlay strategies. |
115 for (const auto& strategy : strategies_) { | 120 for (const auto& strategy : strategies_) { |
116 if (!strategy->Attempt(resource_provider, render_pass, candidates)) | 121 if (!strategy->Attempt(resource_provider, render_pass, candidates)) |
117 continue; | 122 continue; |
118 | 123 |
| 124 have_swap_with_damage_rect_ = |
| 125 strategy->GetSwapWithDamageRect(&swap_with_damage_rect_); |
| 126 |
119 UpdateDamageRect(candidates, damage_rect); | 127 UpdateDamageRect(candidates, damage_rect); |
120 return; | 128 return; |
121 } | 129 } |
122 } | 130 } |
123 | 131 |
| 132 bool OverlayProcessor::GetSwapWithDamageRect(gfx::Rect* damage_rect) { |
| 133 DCHECK(damage_rect); |
| 134 *damage_rect = swap_with_damage_rect_; |
| 135 return have_swap_with_damage_rect_; |
| 136 } |
| 137 |
124 // Subtract on-top overlays from the damage rect, unless the overlays use | 138 // Subtract on-top overlays from the damage rect, unless the overlays use |
125 // the backbuffer as their content (in which case, add their combined rect | 139 // the backbuffer as their content (in which case, add their combined rect |
126 // back to the damage at the end). | 140 // back to the damage at the end). |
127 // Also subtract unoccluded underlays from the damage rect if we know that the | 141 // Also subtract unoccluded underlays from the damage rect if we know that the |
128 // same underlay was scheduled on the previous frame. If the renderer decides | 142 // same underlay was scheduled on the previous frame. If the renderer decides |
129 // not to swap the framebuffer there will still be a transparent hole in the | 143 // not to swap the framebuffer there will still be a transparent hole in the |
130 // previous frame. This only handles the common case of a single underlay quad | 144 // previous frame. This only handles the common case of a single underlay quad |
131 // for fullscreen video. | 145 // for fullscreen video. |
132 void OverlayProcessor::UpdateDamageRect(OverlayCandidateList* candidates, | 146 void OverlayProcessor::UpdateDamageRect(OverlayCandidateList* candidates, |
133 gfx::Rect* damage_rect) { | 147 gfx::Rect* damage_rect) { |
(...skipping 14 matching lines...) Expand all Loading... |
148 } | 162 } |
149 | 163 |
150 if (this_frame_underlay_rect == previous_frame_underlay_rect_) | 164 if (this_frame_underlay_rect == previous_frame_underlay_rect_) |
151 damage_rect->Subtract(this_frame_underlay_rect); | 165 damage_rect->Subtract(this_frame_underlay_rect); |
152 previous_frame_underlay_rect_ = this_frame_underlay_rect; | 166 previous_frame_underlay_rect_ = this_frame_underlay_rect; |
153 | 167 |
154 damage_rect->Union(output_surface_overlay_damage_rect); | 168 damage_rect->Union(output_surface_overlay_damage_rect); |
155 } | 169 } |
156 | 170 |
157 } // namespace cc | 171 } // namespace cc |
OLD | NEW |