| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 memory_history_(MemoryHistory::Create()), | 237 memory_history_(MemoryHistory::Create()), |
| 238 debug_rect_history_(DebugRectHistory::Create()), | 238 debug_rect_history_(DebugRectHistory::Create()), |
| 239 texture_mailbox_deleter_(new TextureMailboxDeleter( | 239 texture_mailbox_deleter_(new TextureMailboxDeleter( |
| 240 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 240 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
| 241 : proxy_->MainThreadTaskRunner())), | 241 : proxy_->MainThreadTaskRunner())), |
| 242 max_memory_needed_bytes_(0), | 242 max_memory_needed_bytes_(0), |
| 243 zero_budget_(false), | 243 zero_budget_(false), |
| 244 device_scale_factor_(1.f), | 244 device_scale_factor_(1.f), |
| 245 overhang_ui_resource_id_(0), | 245 overhang_ui_resource_id_(0), |
| 246 overdraw_bottom_height_(0.f), | 246 overdraw_bottom_height_(0.f), |
| 247 device_viewport_valid_for_tile_management_(true), | 247 resourceless_software_draw_(false), |
| 248 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 248 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
| 249 animation_registrar_(AnimationRegistrar::Create()), | 249 animation_registrar_(AnimationRegistrar::Create()), |
| 250 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 250 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 251 micro_benchmark_controller_(this), | 251 micro_benchmark_controller_(this), |
| 252 need_to_update_visible_tiles_before_draw_(false), | 252 need_to_update_visible_tiles_before_draw_(false), |
| 253 #if DCHECK_IS_ON | 253 #if DCHECK_IS_ON |
| 254 did_lose_called_(false), | 254 did_lose_called_(false), |
| 255 #endif | 255 #endif |
| 256 shared_bitmap_manager_(manager), | 256 shared_bitmap_manager_(manager), |
| 257 id_(id), | 257 id_(id), |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 } | 542 } |
| 543 return value.PassAs<base::Value>(); | 543 return value.PassAs<base::Value>(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 void LayerTreeHostImpl::FrameData::AppendRenderPass( | 546 void LayerTreeHostImpl::FrameData::AppendRenderPass( |
| 547 scoped_ptr<RenderPass> render_pass) { | 547 scoped_ptr<RenderPass> render_pass) { |
| 548 render_passes_by_id[render_pass->id] = render_pass.get(); | 548 render_passes_by_id[render_pass->id] = render_pass.get(); |
| 549 render_passes.push_back(render_pass.Pass()); | 549 render_passes.push_back(render_pass.Pass()); |
| 550 } | 550 } |
| 551 | 551 |
| 552 static DrawMode GetDrawMode(OutputSurface* output_surface) { | 552 DrawMode LayerTreeHostImpl::GetDrawMode() const { |
| 553 if (output_surface->ForcedDrawToSoftwareDevice()) { | 553 if (resourceless_software_draw_) { |
| 554 return DRAW_MODE_RESOURCELESS_SOFTWARE; | 554 return DRAW_MODE_RESOURCELESS_SOFTWARE; |
| 555 } else if (output_surface->context_provider()) { | 555 } else if (output_surface_->context_provider()) { |
| 556 return DRAW_MODE_HARDWARE; | 556 return DRAW_MODE_HARDWARE; |
| 557 } else { | 557 } else { |
| 558 DCHECK_EQ(!output_surface->software_device(), | 558 DCHECK_EQ(!output_surface_->software_device(), |
| 559 output_surface->capabilities().delegated_rendering && | 559 output_surface_->capabilities().delegated_rendering && |
| 560 !output_surface->capabilities().deferred_gl_initialization) | 560 !output_surface_->capabilities().deferred_gl_initialization) |
| 561 << output_surface->capabilities().delegated_rendering << " " | 561 << output_surface_->capabilities().delegated_rendering << " " |
| 562 << output_surface->capabilities().deferred_gl_initialization; | 562 << output_surface_->capabilities().deferred_gl_initialization; |
| 563 return DRAW_MODE_SOFTWARE; | 563 return DRAW_MODE_SOFTWARE; |
| 564 } | 564 } |
| 565 } | 565 } |
| 566 | 566 |
| 567 static void AppendQuadsForLayer( | 567 static void AppendQuadsForLayer( |
| 568 RenderPass* target_render_pass, | 568 RenderPass* target_render_pass, |
| 569 LayerImpl* layer, | 569 LayerImpl* layer, |
| 570 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 570 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 571 AppendQuadsData* append_quads_data) { | 571 AppendQuadsData* append_quads_data) { |
| 572 layer->AppendQuads(target_render_pass, occlusion_tracker, append_quads_data); | 572 layer->AppendQuads(target_render_pass, occlusion_tracker, append_quads_data); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 // still draw the frame. However when the layer being checkerboarded is moving | 771 // still draw the frame. However when the layer being checkerboarded is moving |
| 772 // due to an impl-animation, we drop the frame to avoid flashing due to the | 772 // due to an impl-animation, we drop the frame to avoid flashing due to the |
| 773 // texture suddenly appearing in the future. | 773 // texture suddenly appearing in the future. |
| 774 DrawResult draw_result = DRAW_SUCCESS; | 774 DrawResult draw_result = DRAW_SUCCESS; |
| 775 // When we have a copy request for a layer, we need to draw no matter | 775 // When we have a copy request for a layer, we need to draw no matter |
| 776 // what, as the layer may disappear after this frame. | 776 // what, as the layer may disappear after this frame. |
| 777 bool have_copy_request = false; | 777 bool have_copy_request = false; |
| 778 | 778 |
| 779 int layers_drawn = 0; | 779 int layers_drawn = 0; |
| 780 | 780 |
| 781 const DrawMode draw_mode = GetDrawMode(output_surface_.get()); | 781 const DrawMode draw_mode = GetDrawMode(); |
| 782 | 782 |
| 783 LayerIteratorType end = | 783 LayerIteratorType end = |
| 784 LayerIteratorType::End(frame->render_surface_layer_list); | 784 LayerIteratorType::End(frame->render_surface_layer_list); |
| 785 for (LayerIteratorType it = | 785 for (LayerIteratorType it = |
| 786 LayerIteratorType::Begin(frame->render_surface_layer_list); | 786 LayerIteratorType::Begin(frame->render_surface_layer_list); |
| 787 it != end; | 787 it != end; |
| 788 ++it) { | 788 ++it) { |
| 789 RenderPass::Id target_render_pass_id = | 789 RenderPass::Id target_render_pass_id = |
| 790 it.target_render_surface_layer()->render_surface()->RenderPassId(); | 790 it.target_render_surface_layer()->render_surface()->RenderPassId(); |
| 791 RenderPass* target_render_pass = | 791 RenderPass* target_render_pass = |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); | 908 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); |
| 909 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); | 909 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); |
| 910 } | 910 } |
| 911 for (size_t i = 0; i < requests_to_abort.size(); ++i) | 911 for (size_t i = 0; i < requests_to_abort.size(); ++i) |
| 912 requests_to_abort[i]->SendEmptyResult(); | 912 requests_to_abort[i]->SendEmptyResult(); |
| 913 | 913 |
| 914 // If we're making a frame to draw, it better have at least one render pass. | 914 // If we're making a frame to draw, it better have at least one render pass. |
| 915 DCHECK(!frame->render_passes.empty()); | 915 DCHECK(!frame->render_passes.empty()); |
| 916 | 916 |
| 917 // Should only have one render pass in resourceless software mode. | 917 // Should only have one render pass in resourceless software mode. |
| 918 if (output_surface_->ForcedDrawToSoftwareDevice()) | 918 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE || |
| 919 DCHECK_EQ(1u, frame->render_passes.size()); | 919 frame->render_passes.size() == 1u) |
| 920 << frame->render_passes.size(); |
| 920 | 921 |
| 921 return draw_result; | 922 return draw_result; |
| 922 } | 923 } |
| 923 | 924 |
| 924 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { | 925 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { |
| 925 if (input_handler_client_) | 926 if (input_handler_client_) |
| 926 input_handler_client_->MainThreadHasStoppedFlinging(); | 927 input_handler_client_->MainThreadHasStoppedFlinging(); |
| 927 } | 928 } |
| 928 | 929 |
| 929 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( | 930 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 } | 1299 } |
| 1299 | 1300 |
| 1300 if (needs_commit) | 1301 if (needs_commit) |
| 1301 client_->SetNeedsCommitOnImplThread(); | 1302 client_->SetNeedsCommitOnImplThread(); |
| 1302 } | 1303 } |
| 1303 | 1304 |
| 1304 void LayerTreeHostImpl::SetExternalDrawConstraints( | 1305 void LayerTreeHostImpl::SetExternalDrawConstraints( |
| 1305 const gfx::Transform& transform, | 1306 const gfx::Transform& transform, |
| 1306 const gfx::Rect& viewport, | 1307 const gfx::Rect& viewport, |
| 1307 const gfx::Rect& clip, | 1308 const gfx::Rect& clip, |
| 1308 bool valid_for_tile_management) { | 1309 bool resourceless_software_draw) { |
| 1309 if (external_transform_ != transform || external_viewport_ != viewport) { | 1310 if (external_transform_ != transform || external_viewport_ != viewport || |
| 1311 resourceless_software_draw_ != resourceless_software_draw) { |
| 1310 active_tree_->set_needs_update_draw_properties(); | 1312 active_tree_->set_needs_update_draw_properties(); |
| 1311 } | 1313 } |
| 1312 | 1314 |
| 1313 external_transform_ = transform; | 1315 external_transform_ = transform; |
| 1314 external_viewport_ = viewport; | 1316 external_viewport_ = viewport; |
| 1315 external_clip_ = clip; | 1317 external_clip_ = clip; |
| 1316 device_viewport_valid_for_tile_management_ = valid_for_tile_management; | 1318 resourceless_software_draw_ = resourceless_software_draw; |
| 1317 } | 1319 } |
| 1318 | 1320 |
| 1319 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 1321 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
| 1320 if (damage_rect.IsEmpty()) | 1322 if (damage_rect.IsEmpty()) |
| 1321 return; | 1323 return; |
| 1322 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1324 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
| 1323 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1325 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
| 1324 } | 1326 } |
| 1325 | 1327 |
| 1326 void LayerTreeHostImpl::BeginFrame(const BeginFrameArgs& args) { | 1328 void LayerTreeHostImpl::BeginFrame(const BeginFrameArgs& args) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 TRACE_EVENT0("cc", "DrawLayers.FrameViewerTracing"); | 1451 TRACE_EVENT0("cc", "DrawLayers.FrameViewerTracing"); |
| 1450 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 1452 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
| 1451 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," | 1453 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," |
| 1452 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") "," | 1454 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") "," |
| 1453 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), | 1455 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), |
| 1454 "cc::LayerTreeHostImpl", | 1456 "cc::LayerTreeHostImpl", |
| 1455 id_, | 1457 id_, |
| 1456 TracedValue::FromValue(AsValueWithFrame(frame).release())); | 1458 TracedValue::FromValue(AsValueWithFrame(frame).release())); |
| 1457 } | 1459 } |
| 1458 | 1460 |
| 1461 const DrawMode draw_mode = GetDrawMode(); |
| 1462 |
| 1459 // Because the contents of the HUD depend on everything else in the frame, the | 1463 // Because the contents of the HUD depend on everything else in the frame, the |
| 1460 // contents of its texture are updated as the last thing before the frame is | 1464 // contents of its texture are updated as the last thing before the frame is |
| 1461 // drawn. | 1465 // drawn. |
| 1462 if (active_tree_->hud_layer()) { | 1466 if (active_tree_->hud_layer()) { |
| 1463 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1467 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
| 1464 active_tree_->hud_layer()->UpdateHudTexture( | 1468 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
| 1465 GetDrawMode(output_surface_.get()), resource_provider_.get()); | 1469 resource_provider_.get()); |
| 1466 } | 1470 } |
| 1467 | 1471 |
| 1468 if (output_surface_->ForcedDrawToSoftwareDevice()) { | 1472 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 1469 bool disable_picture_quad_image_filtering = | 1473 bool disable_picture_quad_image_filtering = |
| 1470 IsCurrentlyScrolling() || needs_animate_layers(); | 1474 IsCurrentlyScrolling() || needs_animate_layers(); |
| 1471 | 1475 |
| 1472 scoped_ptr<SoftwareRenderer> temp_software_renderer = | 1476 scoped_ptr<SoftwareRenderer> temp_software_renderer = |
| 1473 SoftwareRenderer::Create(this, &settings_, output_surface_.get(), NULL); | 1477 SoftwareRenderer::Create(this, &settings_, output_surface_.get(), NULL); |
| 1474 temp_software_renderer->DrawFrame(&frame->render_passes, | 1478 temp_software_renderer->DrawFrame(&frame->render_passes, |
| 1475 device_scale_factor_, | 1479 device_scale_factor_, |
| 1476 DeviceViewport(), | 1480 DeviceViewport(), |
| 1477 DeviceClip(), | 1481 DeviceClip(), |
| 1478 disable_picture_quad_image_filtering); | 1482 disable_picture_quad_image_filtering); |
| (...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3152 } | 3156 } |
| 3153 | 3157 |
| 3154 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3158 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3155 std::vector<PictureLayerImpl*>::iterator it = | 3159 std::vector<PictureLayerImpl*>::iterator it = |
| 3156 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3160 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3157 DCHECK(it != picture_layers_.end()); | 3161 DCHECK(it != picture_layers_.end()); |
| 3158 picture_layers_.erase(it); | 3162 picture_layers_.erase(it); |
| 3159 } | 3163 } |
| 3160 | 3164 |
| 3161 } // namespace cc | 3165 } // namespace cc |
| OLD | NEW |