| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 for (auto& pass : render_passes_in_draw_order) { | 203 for (auto& pass : render_passes_in_draw_order) { |
| 204 auto& resource = render_pass_textures_[pass->id]; | 204 auto& resource = render_pass_textures_[pass->id]; |
| 205 if (!resource) | 205 if (!resource) |
| 206 resource = ScopedResource::Create(resource_provider_); | 206 resource = ScopedResource::Create(resource_provider_); |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, | 210 void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, |
| 211 float device_scale_factor, | 211 float device_scale_factor, |
| 212 const gfx::ColorSpace& device_color_space, | |
| 213 const gfx::Size& device_viewport_size) { | 212 const gfx::Size& device_viewport_size) { |
| 214 DCHECK(visible_); | 213 DCHECK(visible_); |
| 215 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); | 214 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); |
| 216 UMA_HISTOGRAM_COUNTS( | 215 UMA_HISTOGRAM_COUNTS( |
| 217 "Renderer4.renderPassCount", | 216 "Renderer4.renderPassCount", |
| 218 base::saturated_cast<int>(render_passes_in_draw_order->size())); | 217 base::saturated_cast<int>(render_passes_in_draw_order->size())); |
| 219 | 218 |
| 220 RenderPass* root_render_pass = render_passes_in_draw_order->back().get(); | 219 RenderPass* root_render_pass = render_passes_in_draw_order->back().get(); |
| 221 DCHECK(root_render_pass); | 220 DCHECK(root_render_pass); |
| 222 | 221 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 239 | 238 |
| 240 current_frame_valid_ = true; | 239 current_frame_valid_ = true; |
| 241 current_frame_ = DrawingFrame(); | 240 current_frame_ = DrawingFrame(); |
| 242 current_frame()->render_passes_in_draw_order = render_passes_in_draw_order; | 241 current_frame()->render_passes_in_draw_order = render_passes_in_draw_order; |
| 243 current_frame()->root_render_pass = root_render_pass; | 242 current_frame()->root_render_pass = root_render_pass; |
| 244 current_frame()->root_damage_rect = root_render_pass->damage_rect; | 243 current_frame()->root_damage_rect = root_render_pass->damage_rect; |
| 245 current_frame()->root_damage_rect.Union( | 244 current_frame()->root_damage_rect.Union( |
| 246 overlay_processor_->GetAndResetOverlayDamage()); | 245 overlay_processor_->GetAndResetOverlayDamage()); |
| 247 current_frame()->root_damage_rect.Intersect(gfx::Rect(device_viewport_size)); | 246 current_frame()->root_damage_rect.Intersect(gfx::Rect(device_viewport_size)); |
| 248 current_frame()->device_viewport_size = device_viewport_size; | 247 current_frame()->device_viewport_size = device_viewport_size; |
| 249 current_frame()->device_color_space = device_color_space; | |
| 250 | 248 |
| 251 // Only reshape when we know we are going to draw. Otherwise, the reshape | 249 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 252 // can leave the window at the wrong size if we never draw and the proper | 250 // can leave the window at the wrong size if we never draw and the proper |
| 253 // viewport size is never set. | 251 // viewport size is never set. |
| 254 bool frame_has_alpha = | 252 bool frame_has_alpha = |
| 255 current_frame()->root_render_pass->has_transparent_background; | 253 current_frame()->root_render_pass->has_transparent_background; |
| 256 bool use_stencil = overdraw_feedback_; | 254 bool use_stencil = overdraw_feedback_; |
| 257 if (device_viewport_size != reshape_surface_size_ || | 255 if (device_viewport_size != reshape_surface_size_ || |
| 258 device_scale_factor != reshape_device_scale_factor_ || | 256 device_scale_factor != reshape_device_scale_factor_ || |
| 259 device_color_space != reshape_device_color_space_ || | 257 root_render_pass->color_space != reshape_device_color_space_ || |
| 260 frame_has_alpha != reshape_has_alpha_ || | 258 frame_has_alpha != reshape_has_alpha_ || |
| 261 use_stencil != reshape_use_stencil_) { | 259 use_stencil != reshape_use_stencil_) { |
| 262 reshape_surface_size_ = device_viewport_size; | 260 reshape_surface_size_ = device_viewport_size; |
| 263 reshape_device_scale_factor_ = device_scale_factor; | 261 reshape_device_scale_factor_ = device_scale_factor; |
| 264 reshape_device_color_space_ = device_color_space; | 262 reshape_device_color_space_ = root_render_pass->color_space; |
| 265 reshape_has_alpha_ = | 263 reshape_has_alpha_ = |
| 266 current_frame()->root_render_pass->has_transparent_background; | 264 current_frame()->root_render_pass->has_transparent_background; |
| 267 reshape_use_stencil_ = overdraw_feedback_; | 265 reshape_use_stencil_ = overdraw_feedback_; |
| 268 output_surface_->Reshape( | 266 output_surface_->Reshape( |
| 269 reshape_surface_size_, reshape_device_scale_factor_, | 267 reshape_surface_size_, reshape_device_scale_factor_, |
| 270 reshape_device_color_space_, reshape_has_alpha_, reshape_use_stencil_); | 268 reshape_device_color_space_, reshape_has_alpha_, reshape_use_stencil_); |
| 271 } | 269 } |
| 272 | 270 |
| 273 BeginDrawingFrame(); | 271 BeginDrawingFrame(); |
| 274 | 272 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 return true; | 591 return true; |
| 594 } | 592 } |
| 595 | 593 |
| 596 ScopedResource* texture = render_pass_textures_[render_pass->id].get(); | 594 ScopedResource* texture = render_pass_textures_[render_pass->id].get(); |
| 597 DCHECK(texture); | 595 DCHECK(texture); |
| 598 | 596 |
| 599 gfx::Size size = RenderPassTextureSize(render_pass); | 597 gfx::Size size = RenderPassTextureSize(render_pass); |
| 600 size.Enlarge(enlarge_pass_texture_amount_.width(), | 598 size.Enlarge(enlarge_pass_texture_amount_.width(), |
| 601 enlarge_pass_texture_amount_.height()); | 599 enlarge_pass_texture_amount_.height()); |
| 602 if (!texture->id()) { | 600 if (!texture->id()) { |
| 603 texture->Allocate(size, | 601 texture->Allocate( |
| 604 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, | 602 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, |
| 605 BackbufferFormat(), current_frame()->device_color_space); | 603 BackbufferFormat(), current_frame()->current_render_pass->color_space); |
| 606 } | 604 } |
| 607 DCHECK(texture->id()); | 605 DCHECK(texture->id()); |
| 608 | 606 |
| 609 if (BindFramebufferToTexture(texture)) { | 607 if (BindFramebufferToTexture(texture)) { |
| 610 InitializeViewport(current_frame(), render_pass->output_rect, | 608 InitializeViewport(current_frame(), render_pass->output_rect, |
| 611 gfx::Rect(render_pass->output_rect.size()), | 609 gfx::Rect(render_pass->output_rect.size()), |
| 612 texture->size()); | 610 texture->size()); |
| 613 return true; | 611 return true; |
| 614 } | 612 } |
| 615 | 613 |
| 616 return false; | 614 return false; |
| 617 } | 615 } |
| 618 | 616 |
| 619 bool DirectRenderer::HasAllocatedResourcesForTesting(int render_pass_id) const { | 617 bool DirectRenderer::HasAllocatedResourcesForTesting(int render_pass_id) const { |
| 620 auto iter = render_pass_textures_.find(render_pass_id); | 618 auto iter = render_pass_textures_.find(render_pass_id); |
| 621 return iter != render_pass_textures_.end() && iter->second->id(); | 619 return iter != render_pass_textures_.end() && iter->second->id(); |
| 622 } | 620 } |
| 623 | 621 |
| 624 // static | 622 // static |
| 625 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 623 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 626 return render_pass->output_rect.size(); | 624 return render_pass->output_rect.size(); |
| 627 } | 625 } |
| 628 | 626 |
| 629 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { | 627 void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { |
| 630 current_frame_valid_ = true; | 628 current_frame_valid_ = true; |
| 631 current_frame_ = frame; | 629 current_frame_ = frame; |
| 632 } | 630 } |
| 633 | 631 |
| 634 } // namespace cc | 632 } // namespace cc |
| OLD | NEW |