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 CALayerOverlayList* ca_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, ca_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, |
96 gfx::Rect* damage_rect, | 118 gfx::Rect* damage_rect, |
97 std::vector<gfx::Rect>* content_bounds) { | 119 std::vector<gfx::Rect>* content_bounds) { |
98 #if defined(OS_ANDROID) | 120 #if defined(OS_ANDROID) |
99 // Be sure to send out notifications, regardless of whether we get to | 121 // 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 | 122 // processing for overlays or not. If we don't, then we should notify that |
101 // they are not promotable. | 123 // they are not promotable. |
102 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); | 124 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates); |
103 #endif | 125 #endif |
104 | 126 |
105 // If we have any copy requests, we can't remove any quads for overlays or | 127 // 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' | 128 // CALayers because the framebuffer would be missing the removed quads' |
107 // contents. | 129 // contents. |
108 if (!render_pass->copy_requests.empty()) { | 130 if (!render_pass->copy_requests.empty()) { |
131 dc_processor_.ClearOverlayState(); | |
109 // If overlay processing was skipped for a frame there's no way to be sure | 132 // 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. | 133 // of the state of the previous frame, so reset. |
111 previous_frame_underlay_rect_ = gfx::Rect(); | 134 previous_frame_underlay_rect_ = gfx::Rect(); |
112 return; | 135 return; |
113 } | 136 } |
114 | 137 |
115 // First attempt to process for CALayers. | 138 // First attempt to process for CALayers. |
116 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, | 139 if (ProcessForCALayers(resource_provider, render_pass, render_pass_filters, |
117 render_pass_background_filters, candidates, | 140 render_pass_background_filters, candidates, |
118 ca_layer_overlays, damage_rect)) { | 141 ca_layer_overlays, damage_rect)) { |
119 return; | 142 return; |
120 } | 143 } |
121 | 144 |
145 if (ProcessForDCLayers(resource_provider, render_pass, render_pass_filters, | |
146 render_pass_background_filters, candidates, | |
147 ca_layer_overlays, damage_rect)) { | |
ccameron
2017/03/08 01:02:39
Would it be possible to share UpdateDamageRect ins
| |
148 return; | |
149 } | |
150 | |
122 // Only if that fails, attempt hardware overlay strategies. | 151 // Only if that fails, attempt hardware overlay strategies. |
123 for (const auto& strategy : strategies_) { | 152 for (const auto& strategy : strategies_) { |
124 if (!strategy->Attempt(resource_provider, render_pass, candidates, | 153 if (!strategy->Attempt(resource_provider, render_pass, candidates, |
125 content_bounds)) | 154 content_bounds)) |
126 continue; | 155 continue; |
127 | 156 |
128 UpdateDamageRect(candidates, damage_rect); | 157 UpdateDamageRect(candidates, damage_rect); |
129 return; | 158 return; |
130 } | 159 } |
131 } | 160 } |
(...skipping 25 matching lines...) Expand all Loading... | |
157 } | 186 } |
158 | 187 |
159 if (this_frame_underlay_rect == previous_frame_underlay_rect_) | 188 if (this_frame_underlay_rect == previous_frame_underlay_rect_) |
160 damage_rect->Subtract(this_frame_underlay_rect); | 189 damage_rect->Subtract(this_frame_underlay_rect); |
161 previous_frame_underlay_rect_ = this_frame_underlay_rect; | 190 previous_frame_underlay_rect_ = this_frame_underlay_rect; |
162 | 191 |
163 damage_rect->Union(output_surface_overlay_damage_rect); | 192 damage_rect->Union(output_surface_overlay_damage_rect); |
164 } | 193 } |
165 | 194 |
166 } // namespace cc | 195 } // namespace cc |
OLD | NEW |