OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/direct_renderer.h" | 5 #include "cc/output/direct_renderer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 "Renderer4.renderPassCount", | 198 "Renderer4.renderPassCount", |
199 base::saturated_cast<int>(render_passes_in_draw_order->size())); | 199 base::saturated_cast<int>(render_passes_in_draw_order->size())); |
200 | 200 |
201 const RenderPass* root_render_pass = | 201 const RenderPass* root_render_pass = |
202 render_passes_in_draw_order->back().get(); | 202 render_passes_in_draw_order->back().get(); |
203 DCHECK(root_render_pass); | 203 DCHECK(root_render_pass); |
204 | 204 |
205 DrawingFrame frame; | 205 DrawingFrame frame; |
206 frame.render_passes_in_draw_order = render_passes_in_draw_order; | 206 frame.render_passes_in_draw_order = render_passes_in_draw_order; |
207 frame.root_render_pass = root_render_pass; | 207 frame.root_render_pass = root_render_pass; |
208 frame.root_damage_rect = root_render_pass->damage_rect; | 208 frame.root_damage_rect = Capabilities().using_partial_swap |
| 209 ? root_render_pass->damage_rect |
| 210 : root_render_pass->output_rect; |
209 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage()); | 211 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage()); |
210 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); | 212 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size())); |
211 frame.device_viewport_rect = device_viewport_rect; | 213 frame.device_viewport_rect = device_viewport_rect; |
212 frame.device_clip_rect = device_clip_rect; | 214 frame.device_clip_rect = device_clip_rect; |
213 frame.disable_picture_quad_image_filtering = | 215 frame.disable_picture_quad_image_filtering = |
214 disable_picture_quad_image_filtering; | 216 disable_picture_quad_image_filtering; |
215 | 217 |
216 EnsureBackbuffer(); | 218 EnsureBackbuffer(); |
217 | 219 |
218 // Only reshape when we know we are going to draw. Otherwise, the reshape | 220 // Only reshape when we know we are going to draw. Otherwise, the reshape |
219 // can leave the window at the wrong size if we never draw and the proper | 221 // can leave the window at the wrong size if we never draw and the proper |
220 // viewport size is never set. | 222 // viewport size is never set. |
221 output_surface_->Reshape(device_viewport_rect.size(), device_scale_factor); | 223 output_surface_->Reshape(device_viewport_rect.size(), device_scale_factor); |
222 | 224 |
223 BeginDrawingFrame(&frame); | 225 BeginDrawingFrame(&frame); |
224 | 226 |
225 if (output_surface_->IsDisplayedAsOverlayPlane()) { | 227 if (output_surface_->IsDisplayedAsOverlayPlane()) { |
226 // Create the overlay candidate for the output surface, and mark it as | 228 // Create the overlay candidate for the output surface, and mark it as |
227 // always handled. | 229 // always |
| 230 // handled. |
228 OverlayCandidate output_surface_plane; | 231 OverlayCandidate output_surface_plane; |
229 output_surface_plane.display_rect = | 232 output_surface_plane.display_rect = |
230 gfx::RectF(root_render_pass->output_rect); | 233 gfx::RectF(root_render_pass->output_rect); |
231 output_surface_plane.quad_rect_in_target_space = | 234 output_surface_plane.quad_rect_in_target_space = |
232 root_render_pass->output_rect; | 235 root_render_pass->output_rect; |
233 output_surface_plane.use_output_surface_for_resource = true; | 236 output_surface_plane.use_output_surface_for_resource = true; |
234 output_surface_plane.overlay_handled = true; | 237 output_surface_plane.overlay_handled = true; |
235 frame.overlay_list.push_back(output_surface_plane); | 238 frame.overlay_list.push_back(output_surface_plane); |
236 } | 239 } |
237 | 240 |
238 // If we have any copy requests, we can't remove any quads for overlays or | 241 // If we have any copy requests, we can't remove any quads for overlays or |
239 // CALayers because the framebuffer would be missing the removed quads' | 242 // CALayers because the framebuffer would be missing the removed quads' |
240 // contents. | 243 // contents. |
241 bool has_copy_requests = false; | 244 bool has_copy_requests = false; |
242 for (const auto& pass : *render_passes_in_draw_order) { | 245 for (const auto& pass : *render_passes_in_draw_order) { |
243 if (!pass->copy_requests.empty()) { | 246 if (!pass->copy_requests.empty()) { |
244 has_copy_requests = true; | 247 has_copy_requests = true; |
245 break; | 248 break; |
246 } | 249 } |
247 } | 250 } |
248 if (!has_copy_requests) { | 251 if (!has_copy_requests) { |
249 overlay_processor_->ProcessForOverlays( | 252 overlay_processor_->ProcessForOverlays( |
250 resource_provider_, render_passes_in_draw_order, &frame.overlay_list, | 253 resource_provider_, render_passes_in_draw_order, &frame.overlay_list, |
251 &frame.ca_layer_overlay_list, &frame.root_damage_rect); | 254 &frame.ca_layer_overlay_list, &frame.root_damage_rect); |
252 } | 255 } |
253 | 256 |
254 // The damage rect might be empty now, but if empty swap isn't allowed we | |
255 // still have to draw. | |
256 bool should_draw = has_copy_requests || !frame.root_damage_rect.IsEmpty() || | |
257 !Capabilities().allow_empty_swap; | |
258 // If we have to draw but don't support partial swap the whole output should | |
259 // be considered damaged. | |
260 if (should_draw && !Capabilities().using_partial_swap) | |
261 frame.root_damage_rect = root_render_pass->output_rect; | |
262 | |
263 // If all damage is being drawn with overlays or CALayers then skip drawing | 257 // If all damage is being drawn with overlays or CALayers then skip drawing |
264 // the render passes. | 258 // the render passes. |
265 if (!should_draw) { | 259 if (frame.root_damage_rect.IsEmpty() && !has_copy_requests) { |
266 BindFramebufferToOutputSurface(&frame); | 260 BindFramebufferToOutputSurface(&frame); |
267 } else { | 261 } else { |
268 for (const auto& pass : *render_passes_in_draw_order) { | 262 for (const auto& pass : *render_passes_in_draw_order) { |
269 DrawRenderPass(&frame, pass.get()); | 263 DrawRenderPass(&frame, pass.get()); |
270 | 264 |
271 bool first_request = true; | 265 bool first_request = true; |
272 for (auto& copy_request : pass->copy_requests) { | 266 for (auto& copy_request : pass->copy_requests) { |
273 // Doing a readback is destructive of our state on Mac, so make sure | 267 // Doing a readback is destructive of our state on Mac, so make sure |
274 // we restore the state between readbacks. http://crbug.com/99393. | 268 // we restore the state between readbacks. http://crbug.com/99393. |
275 if (!first_request) | 269 if (!first_request) |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 ScopedResource* texture = render_pass_textures_.get(id); | 550 ScopedResource* texture = render_pass_textures_.get(id); |
557 return texture && texture->id(); | 551 return texture && texture->id(); |
558 } | 552 } |
559 | 553 |
560 // static | 554 // static |
561 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 555 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
562 return render_pass->output_rect.size(); | 556 return render_pass->output_rect.size(); |
563 } | 557 } |
564 | 558 |
565 } // namespace cc | 559 } // namespace cc |
OLD | NEW |