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/dc_layer_overlay.h" |
7 #include "cc/output/output_surface.h" | 8 #include "cc/output/output_surface.h" |
8 #include "cc/output/overlay_strategy_single_on_top.h" | 9 #include "cc/output/overlay_strategy_single_on_top.h" |
9 #include "cc/output/overlay_strategy_underlay.h" | 10 #include "cc/output/overlay_strategy_underlay.h" |
10 #include "cc/quads/draw_quad.h" | 11 #include "cc/quads/draw_quad.h" |
11 #include "cc/resources/resource_provider.h" | 12 #include "cc/resources/resource_provider.h" |
12 #include "ui/gfx/geometry/rect_conversions.h" | 13 #include "ui/gfx/geometry/rect_conversions.h" |
13 #include "ui/gfx/transform.h" | 14 #include "ui/gfx/transform.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 80 |
80 // CALayer overlays are all-or-nothing. If all quads were replaced with | 81 // CALayer overlays are all-or-nothing. If all quads were replaced with |
81 // layers then clear the list and remove the backbuffer from the overcandidate | 82 // layers then clear the list and remove the backbuffer from the overcandidate |
82 // list. | 83 // list. |
83 overlay_candidates->clear(); | 84 overlay_candidates->clear(); |
84 overlay_damage_rect_ = render_pass->output_rect; | 85 overlay_damage_rect_ = render_pass->output_rect; |
85 *damage_rect = gfx::Rect(); | 86 *damage_rect = gfx::Rect(); |
86 return true; | 87 return true; |
87 } | 88 } |
88 | 89 |
| 90 bool OverlayProcessor::ProcessForDCLayers( |
| 91 ResourceProvider* resource_provider, |
| 92 RenderPass* render_pass, |
| 93 const RenderPassFilterList& render_pass_filters, |
| 94 const RenderPassFilterList& render_pass_background_filters, |
| 95 OverlayCandidateList* overlay_candidates, |
| 96 DCLayerOverlayList* dc_layer_overlays, |
| 97 gfx::Rect* damage_rect) { |
| 98 OverlayCandidateValidator* overlay_validator = |
| 99 surface_->GetOverlayCandidateValidator(); |
| 100 if (!overlay_validator || !overlay_validator->AllowDCLayerOverlays()) |
| 101 return false; |
| 102 |
| 103 dc_processor_.Process(resource_provider, gfx::RectF(render_pass->output_rect), |
| 104 &render_pass->quad_list, &overlay_damage_rect_, |
| 105 damage_rect, dc_layer_overlays); |
| 106 |
| 107 DCHECK(overlay_candidates->empty()); |
| 108 return true; |
| 109 } |
| 110 |
89 void OverlayProcessor::ProcessForOverlays( | 111 void OverlayProcessor::ProcessForOverlays( |
90 ResourceProvider* resource_provider, | 112 ResourceProvider* resource_provider, |
91 RenderPass* render_pass, | 113 RenderPass* render_pass, |
92 const RenderPassFilterList& render_pass_filters, | 114 const RenderPassFilterList& render_pass_filters, |
93 const RenderPassFilterList& render_pass_background_filters, | 115 const RenderPassFilterList& render_pass_background_filters, |
94 OverlayCandidateList* candidates, | 116 OverlayCandidateList* candidates, |
95 CALayerOverlayList* ca_layer_overlays, | 117 CALayerOverlayList* ca_layer_overlays, |
| 118 DCLayerOverlayList* dc_layer_overlays, |
96 gfx::Rect* damage_rect, | 119 gfx::Rect* damage_rect, |
97 std::vector<gfx::Rect>* content_bounds) { | 120 std::vector<gfx::Rect>* content_bounds) { |
98 #if defined(OS_ANDROID) | 121 #if defined(OS_ANDROID) |
99 // Be sure to send out notifications, regardless of whether we get to | 122 // Be sure to send out notifications, regardless of whether we get to |
100 // processing for overlays or not. If we don't, then we should notify that | 123 // processing for overlays or not. If we don't, then we should notify that |
101 // they are not promotable. | 124 // they are not promotable. |
102 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); | 125 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); |
103 #endif | 126 #endif |
104 | 127 |
105 // If we have any copy requests, we can't remove any quads for overlays or | 128 // If we have any copy requests, we can't remove any quads for overlays or |
106 // CALayers because the framebuffer would be missing the removed quads' | 129 // CALayers because the framebuffer would be missing the removed quads' |
107 // contents. | 130 // contents. |
108 if (!render_pass->copy_requests.empty()) { | 131 if (!render_pass->copy_requests.empty()) { |
| 132 dc_processor_.ClearOverlayState(); |
109 // If overlay processing was skipped for a frame there's no way to be sure | 133 // If overlay processing was skipped for a frame there's no way to be sure |
110 // of the state of the previous frame, so reset. | 134 // of the state of the previous frame, so reset. |
111 previous_frame_underlay_rect_ = gfx::Rect(); | 135 previous_frame_underlay_rect_ = gfx::Rect(); |
112 return; | 136 return; |
113 } | 137 } |
114 | 138 |
115 // First attempt to process for CALayers. | 139 // First attempt to process for CALayers. |
116 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, | 140 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, |
117 render_pass_background_filters, candidates, | 141 render_pass_background_filters, candidates, |
118 ca_layer_overlays, damage_rect)) { | 142 ca_layer_overlays, damage_rect)) { |
119 return; | 143 return; |
120 } | 144 } |
121 | 145 |
| 146 if (ProcessForDCLayers(resource_provider, render_pass, render_pass_filters, |
| 147 render_pass_background_filters, candidates, |
| 148 dc_layer_overlays, damage_rect)) { |
| 149 return; |
| 150 } |
| 151 |
122 // Only if that fails, attempt hardware overlay strategies. | 152 // Only if that fails, attempt hardware overlay strategies. |
123 for (const auto& strategy : strategies_) { | 153 for (const auto& strategy : strategies_) { |
124 if (!strategy->Attempt(resource_provider, render_pass, candidates, | 154 if (!strategy->Attempt(resource_provider, render_pass, candidates, |
125 content_bounds)) | 155 content_bounds)) |
126 continue; | 156 continue; |
127 | 157 |
128 UpdateDamageRect(candidates, damage_rect); | 158 UpdateDamageRect(candidates, damage_rect); |
129 return; | 159 return; |
130 } | 160 } |
131 } | 161 } |
(...skipping 25 matching lines...) Expand all Loading... |
157 } | 187 } |
158 | 188 |
159 if (this_frame_underlay_rect == previous_frame_underlay_rect_) | 189 if (this_frame_underlay_rect == previous_frame_underlay_rect_) |
160 damage_rect->Subtract(this_frame_underlay_rect); | 190 damage_rect->Subtract(this_frame_underlay_rect); |
161 previous_frame_underlay_rect_ = this_frame_underlay_rect; | 191 previous_frame_underlay_rect_ = this_frame_underlay_rect; |
162 | 192 |
163 damage_rect->Union(output_surface_overlay_damage_rect); | 193 damage_rect->Union(output_surface_overlay_damage_rect); |
164 } | 194 } |
165 | 195 |
166 } // namespace cc | 196 } // namespace cc |
OLD | NEW |