| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 memory_history_(MemoryHistory::Create()), | 239 memory_history_(MemoryHistory::Create()), |
| 240 debug_rect_history_(DebugRectHistory::Create()), | 240 debug_rect_history_(DebugRectHistory::Create()), |
| 241 texture_mailbox_deleter_(new TextureMailboxDeleter( | 241 texture_mailbox_deleter_(new TextureMailboxDeleter( |
| 242 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 242 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
| 243 : proxy_->MainThreadTaskRunner())), | 243 : proxy_->MainThreadTaskRunner())), |
| 244 max_memory_needed_bytes_(0), | 244 max_memory_needed_bytes_(0), |
| 245 zero_budget_(false), | 245 zero_budget_(false), |
| 246 device_scale_factor_(1.f), | 246 device_scale_factor_(1.f), |
| 247 overhang_ui_resource_id_(0), | 247 overhang_ui_resource_id_(0), |
| 248 overdraw_bottom_height_(0.f), | 248 overdraw_bottom_height_(0.f), |
| 249 device_viewport_valid_for_tile_management_(true), | 249 resourceless_software_draw_(false), |
| 250 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 250 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
| 251 animation_registrar_(AnimationRegistrar::Create()), | 251 animation_registrar_(AnimationRegistrar::Create()), |
| 252 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 252 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 253 micro_benchmark_controller_(this), | 253 micro_benchmark_controller_(this), |
| 254 need_to_update_visible_tiles_before_draw_(false), | 254 need_to_update_visible_tiles_before_draw_(false), |
| 255 #if DCHECK_IS_ON | 255 #if DCHECK_IS_ON |
| 256 did_lose_called_(false), | 256 did_lose_called_(false), |
| 257 #endif | 257 #endif |
| 258 shared_bitmap_manager_(manager), | 258 shared_bitmap_manager_(manager), |
| 259 id_(id), | 259 id_(id), |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 } | 562 } |
| 563 return value.PassAs<base::Value>(); | 563 return value.PassAs<base::Value>(); |
| 564 } | 564 } |
| 565 | 565 |
| 566 void LayerTreeHostImpl::FrameData::AppendRenderPass( | 566 void LayerTreeHostImpl::FrameData::AppendRenderPass( |
| 567 scoped_ptr<RenderPass> render_pass) { | 567 scoped_ptr<RenderPass> render_pass) { |
| 568 render_passes_by_id[render_pass->id] = render_pass.get(); | 568 render_passes_by_id[render_pass->id] = render_pass.get(); |
| 569 render_passes.push_back(render_pass.Pass()); | 569 render_passes.push_back(render_pass.Pass()); |
| 570 } | 570 } |
| 571 | 571 |
| 572 static DrawMode GetDrawMode(OutputSurface* output_surface) { | 572 DrawMode LayerTreeHostImpl::GetDrawMode() const { |
| 573 if (output_surface->ForcedDrawToSoftwareDevice()) { | 573 if (resourceless_software_draw_) { |
| 574 return DRAW_MODE_RESOURCELESS_SOFTWARE; | 574 return DRAW_MODE_RESOURCELESS_SOFTWARE; |
| 575 } else if (output_surface->context_provider()) { | 575 } else if (output_surface_->context_provider()) { |
| 576 return DRAW_MODE_HARDWARE; | 576 return DRAW_MODE_HARDWARE; |
| 577 } else { | 577 } else { |
| 578 DCHECK_EQ(!output_surface->software_device(), | 578 DCHECK_EQ(!output_surface_->software_device(), |
| 579 output_surface->capabilities().delegated_rendering && | 579 output_surface_->capabilities().delegated_rendering && |
| 580 !output_surface->capabilities().deferred_gl_initialization) | 580 !output_surface_->capabilities().deferred_gl_initialization) |
| 581 << output_surface->capabilities().delegated_rendering << " " | 581 << output_surface_->capabilities().delegated_rendering << " " |
| 582 << output_surface->capabilities().deferred_gl_initialization; | 582 << output_surface_->capabilities().deferred_gl_initialization; |
| 583 return DRAW_MODE_SOFTWARE; | 583 return DRAW_MODE_SOFTWARE; |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 | 586 |
| 587 static void AppendQuadsForLayer( | 587 static void AppendQuadsForLayer( |
| 588 RenderPass* target_render_pass, | 588 RenderPass* target_render_pass, |
| 589 LayerImpl* layer, | 589 LayerImpl* layer, |
| 590 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 590 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
| 591 AppendQuadsData* append_quads_data) { | 591 AppendQuadsData* append_quads_data) { |
| 592 layer->AppendQuads(target_render_pass, occlusion_tracker, append_quads_data); | 592 layer->AppendQuads(target_render_pass, occlusion_tracker, append_quads_data); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 // still draw the frame. However when the layer being checkerboarded is moving | 791 // still draw the frame. However when the layer being checkerboarded is moving |
| 792 // due to an impl-animation, we drop the frame to avoid flashing due to the | 792 // due to an impl-animation, we drop the frame to avoid flashing due to the |
| 793 // texture suddenly appearing in the future. | 793 // texture suddenly appearing in the future. |
| 794 DrawResult draw_result = DRAW_SUCCESS; | 794 DrawResult draw_result = DRAW_SUCCESS; |
| 795 // When we have a copy request for a layer, we need to draw no matter | 795 // When we have a copy request for a layer, we need to draw no matter |
| 796 // what, as the layer may disappear after this frame. | 796 // what, as the layer may disappear after this frame. |
| 797 bool have_copy_request = false; | 797 bool have_copy_request = false; |
| 798 | 798 |
| 799 int layers_drawn = 0; | 799 int layers_drawn = 0; |
| 800 | 800 |
| 801 const DrawMode draw_mode = GetDrawMode(output_surface_.get()); | 801 const DrawMode draw_mode = GetDrawMode(); |
| 802 | 802 |
| 803 LayerIteratorType end = | 803 LayerIteratorType end = |
| 804 LayerIteratorType::End(frame->render_surface_layer_list); | 804 LayerIteratorType::End(frame->render_surface_layer_list); |
| 805 for (LayerIteratorType it = | 805 for (LayerIteratorType it = |
| 806 LayerIteratorType::Begin(frame->render_surface_layer_list); | 806 LayerIteratorType::Begin(frame->render_surface_layer_list); |
| 807 it != end; | 807 it != end; |
| 808 ++it) { | 808 ++it) { |
| 809 RenderPass::Id target_render_pass_id = | 809 RenderPass::Id target_render_pass_id = |
| 810 it.target_render_surface_layer()->render_surface()->RenderPassId(); | 810 it.target_render_surface_layer()->render_surface()->RenderPassId(); |
| 811 RenderPass* target_render_pass = | 811 RenderPass* target_render_pass = |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); | 928 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); |
| 929 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); | 929 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); |
| 930 } | 930 } |
| 931 for (size_t i = 0; i < requests_to_abort.size(); ++i) | 931 for (size_t i = 0; i < requests_to_abort.size(); ++i) |
| 932 requests_to_abort[i]->SendEmptyResult(); | 932 requests_to_abort[i]->SendEmptyResult(); |
| 933 | 933 |
| 934 // If we're making a frame to draw, it better have at least one render pass. | 934 // If we're making a frame to draw, it better have at least one render pass. |
| 935 DCHECK(!frame->render_passes.empty()); | 935 DCHECK(!frame->render_passes.empty()); |
| 936 | 936 |
| 937 // Should only have one render pass in resourceless software mode. | 937 // Should only have one render pass in resourceless software mode. |
| 938 if (output_surface_->ForcedDrawToSoftwareDevice()) | 938 DCHECK(draw_mode != DRAW_MODE_RESOURCELESS_SOFTWARE || |
| 939 DCHECK_EQ(1u, frame->render_passes.size()); | 939 frame->render_passes.size() == 1u) |
| 940 << frame->render_passes.size(); |
| 940 | 941 |
| 941 return draw_result; | 942 return draw_result; |
| 942 } | 943 } |
| 943 | 944 |
| 944 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { | 945 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { |
| 945 if (input_handler_client_) | 946 if (input_handler_client_) |
| 946 input_handler_client_->MainThreadHasStoppedFlinging(); | 947 input_handler_client_->MainThreadHasStoppedFlinging(); |
| 947 } | 948 } |
| 948 | 949 |
| 949 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( | 950 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 } | 1319 } |
| 1319 | 1320 |
| 1320 if (needs_commit) | 1321 if (needs_commit) |
| 1321 client_->SetNeedsCommitOnImplThread(); | 1322 client_->SetNeedsCommitOnImplThread(); |
| 1322 } | 1323 } |
| 1323 | 1324 |
| 1324 void LayerTreeHostImpl::SetExternalDrawConstraints( | 1325 void LayerTreeHostImpl::SetExternalDrawConstraints( |
| 1325 const gfx::Transform& transform, | 1326 const gfx::Transform& transform, |
| 1326 const gfx::Rect& viewport, | 1327 const gfx::Rect& viewport, |
| 1327 const gfx::Rect& clip, | 1328 const gfx::Rect& clip, |
| 1328 bool valid_for_tile_management) { | 1329 bool resourceless_software_draw) { |
| 1329 if (external_transform_ != transform || external_viewport_ != viewport) { | 1330 if (external_transform_ != transform || external_viewport_ != viewport || |
| 1331 resourceless_software_draw_ != resourceless_software_draw) { |
| 1330 active_tree_->set_needs_update_draw_properties(); | 1332 active_tree_->set_needs_update_draw_properties(); |
| 1331 } | 1333 } |
| 1332 | 1334 |
| 1333 external_transform_ = transform; | 1335 external_transform_ = transform; |
| 1334 external_viewport_ = viewport; | 1336 external_viewport_ = viewport; |
| 1335 external_clip_ = clip; | 1337 external_clip_ = clip; |
| 1336 device_viewport_valid_for_tile_management_ = valid_for_tile_management; | 1338 resourceless_software_draw_ = resourceless_software_draw; |
| 1337 } | 1339 } |
| 1338 | 1340 |
| 1339 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 1341 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
| 1340 if (damage_rect.IsEmpty()) | 1342 if (damage_rect.IsEmpty()) |
| 1341 return; | 1343 return; |
| 1342 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1344 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
| 1343 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1345 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
| 1344 } | 1346 } |
| 1345 | 1347 |
| 1346 void LayerTreeHostImpl::BeginFrame(const BeginFrameArgs& args) { | 1348 void LayerTreeHostImpl::BeginFrame(const BeginFrameArgs& args) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 TRACE_EVENT0("cc", "DrawLayers.FrameViewerTracing"); | 1471 TRACE_EVENT0("cc", "DrawLayers.FrameViewerTracing"); |
| 1470 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 1472 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
| 1471 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," | 1473 TRACE_DISABLED_BY_DEFAULT("cc.debug") "," |
| 1472 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") "," | 1474 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads") "," |
| 1473 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), | 1475 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), |
| 1474 "cc::LayerTreeHostImpl", | 1476 "cc::LayerTreeHostImpl", |
| 1475 id_, | 1477 id_, |
| 1476 TracedValue::FromValue(AsValueWithFrame(frame).release())); | 1478 TracedValue::FromValue(AsValueWithFrame(frame).release())); |
| 1477 } | 1479 } |
| 1478 | 1480 |
| 1481 const DrawMode draw_mode = GetDrawMode(); |
| 1482 |
| 1479 // Because the contents of the HUD depend on everything else in the frame, the | 1483 // Because the contents of the HUD depend on everything else in the frame, the |
| 1480 // contents of its texture are updated as the last thing before the frame is | 1484 // contents of its texture are updated as the last thing before the frame is |
| 1481 // drawn. | 1485 // drawn. |
| 1482 if (active_tree_->hud_layer()) { | 1486 if (active_tree_->hud_layer()) { |
| 1483 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1487 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
| 1484 active_tree_->hud_layer()->UpdateHudTexture( | 1488 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
| 1485 GetDrawMode(output_surface_.get()), resource_provider_.get()); | 1489 resource_provider_.get()); |
| 1486 } | 1490 } |
| 1487 | 1491 |
| 1488 if (output_surface_->ForcedDrawToSoftwareDevice()) { | 1492 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 1489 bool disable_picture_quad_image_filtering = | 1493 bool disable_picture_quad_image_filtering = |
| 1490 IsCurrentlyScrolling() || needs_animate_layers(); | 1494 IsCurrentlyScrolling() || needs_animate_layers(); |
| 1491 | 1495 |
| 1492 scoped_ptr<SoftwareRenderer> temp_software_renderer = | 1496 scoped_ptr<SoftwareRenderer> temp_software_renderer = |
| 1493 SoftwareRenderer::Create(this, &settings_, output_surface_.get(), NULL); | 1497 SoftwareRenderer::Create(this, &settings_, output_surface_.get(), NULL); |
| 1494 temp_software_renderer->DrawFrame(&frame->render_passes, | 1498 temp_software_renderer->DrawFrame(&frame->render_passes, |
| 1495 device_scale_factor_, | 1499 device_scale_factor_, |
| 1496 DeviceViewport(), | 1500 DeviceViewport(), |
| 1497 DeviceClip(), | 1501 DeviceClip(), |
| 1498 disable_picture_quad_image_filtering); | 1502 disable_picture_quad_image_filtering); |
| (...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3242 } | 3246 } |
| 3243 | 3247 |
| 3244 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3248 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3245 std::vector<PictureLayerImpl*>::iterator it = | 3249 std::vector<PictureLayerImpl*>::iterator it = |
| 3246 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3250 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3247 DCHECK(it != picture_layers_.end()); | 3251 DCHECK(it != picture_layers_.end()); |
| 3248 picture_layers_.erase(it); | 3252 picture_layers_.erase(it); |
| 3249 } | 3253 } |
| 3250 | 3254 |
| 3251 } // namespace cc | 3255 } // namespace cc |
| OLD | NEW |