| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 overlay_processor_->GetAndResetOverlayDamage()); | 260 overlay_processor_->GetAndResetOverlayDamage()); |
| 261 current_frame()->root_damage_rect.Intersect(gfx::Rect(device_viewport_size)); | 261 current_frame()->root_damage_rect.Intersect(gfx::Rect(device_viewport_size)); |
| 262 current_frame()->device_viewport_size = device_viewport_size; | 262 current_frame()->device_viewport_size = device_viewport_size; |
| 263 | 263 |
| 264 // Only reshape when we know we are going to draw. Otherwise, the reshape | 264 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 265 // can leave the window at the wrong size if we never draw and the proper | 265 // can leave the window at the wrong size if we never draw and the proper |
| 266 // viewport size is never set. | 266 // viewport size is never set. |
| 267 bool frame_has_alpha = | 267 bool frame_has_alpha = |
| 268 current_frame()->root_render_pass->has_transparent_background; | 268 current_frame()->root_render_pass->has_transparent_background; |
| 269 bool use_stencil = overdraw_feedback_; | 269 bool use_stencil = overdraw_feedback_; |
| 270 bool did_reshape = false; |
| 270 if (device_viewport_size != reshape_surface_size_ || | 271 if (device_viewport_size != reshape_surface_size_ || |
| 271 device_scale_factor != reshape_device_scale_factor_ || | 272 device_scale_factor != reshape_device_scale_factor_ || |
| 272 root_render_pass->color_space != reshape_device_color_space_ || | 273 root_render_pass->color_space != reshape_device_color_space_ || |
| 273 frame_has_alpha != reshape_has_alpha_ || | 274 frame_has_alpha != reshape_has_alpha_ || |
| 274 use_stencil != reshape_use_stencil_) { | 275 use_stencil != reshape_use_stencil_) { |
| 275 reshape_surface_size_ = device_viewport_size; | 276 reshape_surface_size_ = device_viewport_size; |
| 276 reshape_device_scale_factor_ = device_scale_factor; | 277 reshape_device_scale_factor_ = device_scale_factor; |
| 277 reshape_device_color_space_ = root_render_pass->color_space; | 278 reshape_device_color_space_ = root_render_pass->color_space; |
| 278 reshape_has_alpha_ = | 279 reshape_has_alpha_ = |
| 279 current_frame()->root_render_pass->has_transparent_background; | 280 current_frame()->root_render_pass->has_transparent_background; |
| 280 reshape_use_stencil_ = overdraw_feedback_; | 281 reshape_use_stencil_ = overdraw_feedback_; |
| 281 output_surface_->Reshape( | 282 output_surface_->Reshape( |
| 282 reshape_surface_size_, reshape_device_scale_factor_, | 283 reshape_surface_size_, reshape_device_scale_factor_, |
| 283 reshape_device_color_space_, reshape_has_alpha_, reshape_use_stencil_); | 284 reshape_device_color_space_, reshape_has_alpha_, reshape_use_stencil_); |
| 285 did_reshape = true; |
| 284 } | 286 } |
| 285 | 287 |
| 286 BeginDrawingFrame(); | 288 BeginDrawingFrame(); |
| 287 | 289 |
| 288 for (const auto& pass : *render_passes_in_draw_order) { | 290 for (const auto& pass : *render_passes_in_draw_order) { |
| 289 if (!pass->filters.IsEmpty()) | 291 if (!pass->filters.IsEmpty()) |
| 290 render_pass_filters_[pass->id] = &pass->filters; | 292 render_pass_filters_[pass->id] = &pass->filters; |
| 291 if (!pass->background_filters.IsEmpty()) | 293 if (!pass->background_filters.IsEmpty()) |
| 292 render_pass_background_filters_[pass->id] = &pass->background_filters; | 294 render_pass_background_filters_[pass->id] = &pass->background_filters; |
| 293 } | 295 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 323 ¤t_frame()->root_content_bounds); | 325 ¤t_frame()->root_content_bounds); |
| 324 bool was_using_dc_layers = using_dc_layers_; | 326 bool was_using_dc_layers = using_dc_layers_; |
| 325 if (!current_frame()->dc_layer_overlay_list.empty()) { | 327 if (!current_frame()->dc_layer_overlay_list.empty()) { |
| 326 DCHECK(supports_dc_layers_); | 328 DCHECK(supports_dc_layers_); |
| 327 using_dc_layers_ = true; | 329 using_dc_layers_ = true; |
| 328 frames_since_using_dc_layers_ = 0; | 330 frames_since_using_dc_layers_ = 0; |
| 329 } else if (++frames_since_using_dc_layers_ >= | 331 } else if (++frames_since_using_dc_layers_ >= |
| 330 kNumberOfFramesBeforeDisablingDCLayers) { | 332 kNumberOfFramesBeforeDisablingDCLayers) { |
| 331 using_dc_layers_ = false; | 333 using_dc_layers_ = false; |
| 332 } | 334 } |
| 333 if (was_using_dc_layers != using_dc_layers_) { | 335 if (supports_dc_layers_ && |
| 336 (did_reshape || (was_using_dc_layers != using_dc_layers_))) { |
| 337 // The entire surface has to be redrawn if it was reshaped or if switching |
| 338 // from or to DirectComposition layers, because the previous contents are |
| 339 // discarded and some contents would otherwise be undefined. |
| 334 current_frame()->root_damage_rect = | 340 current_frame()->root_damage_rect = |
| 335 current_frame()->root_render_pass->output_rect; | 341 current_frame()->root_render_pass->output_rect; |
| 336 } | 342 } |
| 337 | 343 |
| 338 // We can skip all drawing if the damage rect is now empty. | 344 // We can skip all drawing if the damage rect is now empty. |
| 339 bool skip_drawing_root_render_pass = | 345 bool skip_drawing_root_render_pass = |
| 340 current_frame()->root_damage_rect.IsEmpty() && allow_empty_swap_; | 346 current_frame()->root_damage_rect.IsEmpty() && allow_empty_swap_; |
| 341 | 347 |
| 342 // If we have to draw but don't support partial swap, the whole output should | 348 // If we have to draw but don't support partial swap, the whole output should |
| 343 // be considered damaged. | 349 // be considered damaged. |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 646 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 641 return render_pass->output_rect.size(); | 647 return render_pass->output_rect.size(); |
| 642 } | 648 } |
| 643 | 649 |
| 644 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { | 650 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { |
| 645 current_frame_valid_ = true; | 651 current_frame_valid_ = true; |
| 646 current_frame_ = frame; | 652 current_frame_ = frame; |
| 647 } | 653 } |
| 648 | 654 |
| 649 } // namespace cc | 655 } // namespace cc |
| OLD | NEW |