| 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 <unordered_map> | 9 #include <unordered_map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 overlay_processor_->GetAndResetOverlayDamage()); | 261 overlay_processor_->GetAndResetOverlayDamage()); |
| 262 current_frame()->root_damage_rect.Intersect(gfx::Rect(device_viewport_size)); | 262 current_frame()->root_damage_rect.Intersect(gfx::Rect(device_viewport_size)); |
| 263 current_frame()->device_viewport_size = device_viewport_size; | 263 current_frame()->device_viewport_size = device_viewport_size; |
| 264 | 264 |
| 265 // Only reshape when we know we are going to draw. Otherwise, the reshape | 265 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 266 // can leave the window at the wrong size if we never draw and the proper | 266 // can leave the window at the wrong size if we never draw and the proper |
| 267 // viewport size is never set. | 267 // viewport size is never set. |
| 268 bool frame_has_alpha = | 268 bool frame_has_alpha = |
| 269 current_frame()->root_render_pass->has_transparent_background; | 269 current_frame()->root_render_pass->has_transparent_background; |
| 270 bool use_stencil = overdraw_feedback_; | 270 bool use_stencil = overdraw_feedback_; |
| 271 bool did_reshape = false; |
| 271 if (device_viewport_size != reshape_surface_size_ || | 272 if (device_viewport_size != reshape_surface_size_ || |
| 272 device_scale_factor != reshape_device_scale_factor_ || | 273 device_scale_factor != reshape_device_scale_factor_ || |
| 273 root_render_pass->color_space != reshape_device_color_space_ || | 274 root_render_pass->color_space != reshape_device_color_space_ || |
| 274 frame_has_alpha != reshape_has_alpha_ || | 275 frame_has_alpha != reshape_has_alpha_ || |
| 275 use_stencil != reshape_use_stencil_) { | 276 use_stencil != reshape_use_stencil_) { |
| 276 reshape_surface_size_ = device_viewport_size; | 277 reshape_surface_size_ = device_viewport_size; |
| 277 reshape_device_scale_factor_ = device_scale_factor; | 278 reshape_device_scale_factor_ = device_scale_factor; |
| 278 reshape_device_color_space_ = root_render_pass->color_space; | 279 reshape_device_color_space_ = root_render_pass->color_space; |
| 279 reshape_has_alpha_ = | 280 reshape_has_alpha_ = |
| 280 current_frame()->root_render_pass->has_transparent_background; | 281 current_frame()->root_render_pass->has_transparent_background; |
| 281 reshape_use_stencil_ = overdraw_feedback_; | 282 reshape_use_stencil_ = overdraw_feedback_; |
| 282 output_surface_->Reshape( | 283 output_surface_->Reshape( |
| 283 reshape_surface_size_, reshape_device_scale_factor_, | 284 reshape_surface_size_, reshape_device_scale_factor_, |
| 284 reshape_device_color_space_, reshape_has_alpha_, reshape_use_stencil_); | 285 reshape_device_color_space_, reshape_has_alpha_, reshape_use_stencil_); |
| 286 did_reshape = true; |
| 285 } | 287 } |
| 286 | 288 |
| 287 BeginDrawingFrame(); | 289 BeginDrawingFrame(); |
| 288 | 290 |
| 289 for (const auto& pass : *render_passes_in_draw_order) { | 291 for (const auto& pass : *render_passes_in_draw_order) { |
| 290 if (!pass->filters.IsEmpty()) | 292 if (!pass->filters.IsEmpty()) |
| 291 render_pass_filters_.push_back(std::make_pair(pass->id, &pass->filters)); | 293 render_pass_filters_.push_back(std::make_pair(pass->id, &pass->filters)); |
| 292 if (!pass->background_filters.IsEmpty()) { | 294 if (!pass->background_filters.IsEmpty()) { |
| 293 render_pass_background_filters_.push_back( | 295 render_pass_background_filters_.push_back( |
| 294 std::make_pair(pass->id, &pass->background_filters)); | 296 std::make_pair(pass->id, &pass->background_filters)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 ¤t_frame()->root_content_bounds); | 331 ¤t_frame()->root_content_bounds); |
| 330 bool was_using_dc_layers = using_dc_layers_; | 332 bool was_using_dc_layers = using_dc_layers_; |
| 331 if (!current_frame()->dc_layer_overlay_list.empty()) { | 333 if (!current_frame()->dc_layer_overlay_list.empty()) { |
| 332 DCHECK(supports_dc_layers_); | 334 DCHECK(supports_dc_layers_); |
| 333 using_dc_layers_ = true; | 335 using_dc_layers_ = true; |
| 334 frames_since_using_dc_layers_ = 0; | 336 frames_since_using_dc_layers_ = 0; |
| 335 } else if (++frames_since_using_dc_layers_ >= | 337 } else if (++frames_since_using_dc_layers_ >= |
| 336 kNumberOfFramesBeforeDisablingDCLayers) { | 338 kNumberOfFramesBeforeDisablingDCLayers) { |
| 337 using_dc_layers_ = false; | 339 using_dc_layers_ = false; |
| 338 } | 340 } |
| 339 if (was_using_dc_layers != using_dc_layers_) { | 341 if (supports_dc_layers_ && |
| 342 (did_reshape || (was_using_dc_layers != using_dc_layers_))) { |
| 343 // The entire surface has to be redrawn if it was reshaped or if switching |
| 344 // from or to DirectComposition layers, because the previous contents are |
| 345 // discarded and some contents would otherwise be undefined. |
| 340 current_frame()->root_damage_rect = | 346 current_frame()->root_damage_rect = |
| 341 current_frame()->root_render_pass->output_rect; | 347 current_frame()->root_render_pass->output_rect; |
| 342 } | 348 } |
| 343 | 349 |
| 344 // We can skip all drawing if the damage rect is now empty. | 350 // We can skip all drawing if the damage rect is now empty. |
| 345 bool skip_drawing_root_render_pass = | 351 bool skip_drawing_root_render_pass = |
| 346 current_frame()->root_damage_rect.IsEmpty() && allow_empty_swap_; | 352 current_frame()->root_damage_rect.IsEmpty() && allow_empty_swap_; |
| 347 | 353 |
| 348 // If we have to draw but don't support partial swap, the whole output should | 354 // If we have to draw but don't support partial swap, the whole output should |
| 349 // be considered damaged. | 355 // be considered damaged. |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 662 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 657 return render_pass->output_rect.size(); | 663 return render_pass->output_rect.size(); |
| 658 } | 664 } |
| 659 | 665 |
| 660 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { | 666 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { |
| 661 current_frame_valid_ = true; | 667 current_frame_valid_ = true; |
| 662 current_frame_ = frame; | 668 current_frame_ = frame; |
| 663 } | 669 } |
| 664 | 670 |
| 665 } // namespace cc | 671 } // namespace cc |
| OLD | NEW |