Chromium Code Reviews| 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 resourceless_software_draw_(false), | |
| 247 device_viewport_valid_for_tile_management_(true), | 248 device_viewport_valid_for_tile_management_(true), |
| 248 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 249 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
| 249 animation_registrar_(AnimationRegistrar::Create()), | 250 animation_registrar_(AnimationRegistrar::Create()), |
| 250 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 251 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 251 micro_benchmark_controller_(this), | 252 micro_benchmark_controller_(this), |
| 252 need_to_update_visible_tiles_before_draw_(false), | 253 need_to_update_visible_tiles_before_draw_(false), |
| 253 #if DCHECK_IS_ON | 254 #if DCHECK_IS_ON |
| 254 did_lose_called_(false), | 255 did_lose_called_(false), |
| 255 #endif | 256 #endif |
| 256 shared_bitmap_manager_(manager), | 257 shared_bitmap_manager_(manager), |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 } | 543 } |
| 543 return value.PassAs<base::Value>(); | 544 return value.PassAs<base::Value>(); |
| 544 } | 545 } |
| 545 | 546 |
| 546 void LayerTreeHostImpl::FrameData::AppendRenderPass( | 547 void LayerTreeHostImpl::FrameData::AppendRenderPass( |
| 547 scoped_ptr<RenderPass> render_pass) { | 548 scoped_ptr<RenderPass> render_pass) { |
| 548 render_passes_by_id[render_pass->id] = render_pass.get(); | 549 render_passes_by_id[render_pass->id] = render_pass.get(); |
| 549 render_passes.push_back(render_pass.Pass()); | 550 render_passes.push_back(render_pass.Pass()); |
| 550 } | 551 } |
| 551 | 552 |
| 552 static DrawMode GetDrawMode(OutputSurface* output_surface) { | 553 static DrawMode GetDrawMode(bool resourceless_software, |
|
danakj
2014/07/09 17:21:07
how about making this not static, and stop passing
boliu
2014/07/09 20:59:50
Done.
| |
| 553 if (output_surface->ForcedDrawToSoftwareDevice()) { | 554 OutputSurface* output_surface) { |
| 555 if (resourceless_software) { | |
| 554 return DRAW_MODE_RESOURCELESS_SOFTWARE; | 556 return DRAW_MODE_RESOURCELESS_SOFTWARE; |
| 555 } else if (output_surface->context_provider()) { | 557 } else if (output_surface->context_provider()) { |
| 556 return DRAW_MODE_HARDWARE; | 558 return DRAW_MODE_HARDWARE; |
| 557 } else { | 559 } else { |
| 558 DCHECK_EQ(!output_surface->software_device(), | 560 DCHECK_EQ(!output_surface->software_device(), |
| 559 output_surface->capabilities().delegated_rendering && | 561 output_surface->capabilities().delegated_rendering && |
| 560 !output_surface->capabilities().deferred_gl_initialization) | 562 !output_surface->capabilities().deferred_gl_initialization) |
| 561 << output_surface->capabilities().delegated_rendering << " " | 563 << output_surface->capabilities().delegated_rendering << " " |
| 562 << output_surface->capabilities().deferred_gl_initialization; | 564 << output_surface->capabilities().deferred_gl_initialization; |
| 563 return DRAW_MODE_SOFTWARE; | 565 return DRAW_MODE_SOFTWARE; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 // still draw the frame. However when the layer being checkerboarded is moving | 773 // 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 | 774 // due to an impl-animation, we drop the frame to avoid flashing due to the |
| 773 // texture suddenly appearing in the future. | 775 // texture suddenly appearing in the future. |
| 774 DrawResult draw_result = DRAW_SUCCESS; | 776 DrawResult draw_result = DRAW_SUCCESS; |
| 775 // When we have a copy request for a layer, we need to draw no matter | 777 // 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. | 778 // what, as the layer may disappear after this frame. |
| 777 bool have_copy_request = false; | 779 bool have_copy_request = false; |
| 778 | 780 |
| 779 int layers_drawn = 0; | 781 int layers_drawn = 0; |
| 780 | 782 |
| 781 const DrawMode draw_mode = GetDrawMode(output_surface_.get()); | 783 const DrawMode draw_mode = |
| 784 GetDrawMode(resourceless_software_draw_, output_surface_.get()); | |
| 782 | 785 |
| 783 LayerIteratorType end = | 786 LayerIteratorType end = |
| 784 LayerIteratorType::End(frame->render_surface_layer_list); | 787 LayerIteratorType::End(frame->render_surface_layer_list); |
| 785 for (LayerIteratorType it = | 788 for (LayerIteratorType it = |
| 786 LayerIteratorType::Begin(frame->render_surface_layer_list); | 789 LayerIteratorType::Begin(frame->render_surface_layer_list); |
| 787 it != end; | 790 it != end; |
| 788 ++it) { | 791 ++it) { |
| 789 RenderPass::Id target_render_pass_id = | 792 RenderPass::Id target_render_pass_id = |
| 790 it.target_render_surface_layer()->render_surface()->RenderPassId(); | 793 it.target_render_surface_layer()->render_surface()->RenderPassId(); |
| 791 RenderPass* target_render_pass = | 794 RenderPass* target_render_pass = |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 908 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); | 911 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); |
| 909 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); | 912 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); |
| 910 } | 913 } |
| 911 for (size_t i = 0; i < requests_to_abort.size(); ++i) | 914 for (size_t i = 0; i < requests_to_abort.size(); ++i) |
| 912 requests_to_abort[i]->SendEmptyResult(); | 915 requests_to_abort[i]->SendEmptyResult(); |
| 913 | 916 |
| 914 // If we're making a frame to draw, it better have at least one render pass. | 917 // If we're making a frame to draw, it better have at least one render pass. |
| 915 DCHECK(!frame->render_passes.empty()); | 918 DCHECK(!frame->render_passes.empty()); |
| 916 | 919 |
| 917 // Should only have one render pass in resourceless software mode. | 920 // Should only have one render pass in resourceless software mode. |
| 918 if (output_surface_->ForcedDrawToSoftwareDevice()) | 921 if (resourceless_software_draw_) |
|
danakj
2014/07/09 17:21:07
can you change this to be based on the draw_mode,
boliu
2014/07/09 20:59:50
Done.
| |
| 919 DCHECK_EQ(1u, frame->render_passes.size()); | 922 DCHECK_EQ(1u, frame->render_passes.size()); |
| 920 | 923 |
| 921 return draw_result; | 924 return draw_result; |
| 922 } | 925 } |
| 923 | 926 |
| 924 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { | 927 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { |
| 925 if (input_handler_client_) | 928 if (input_handler_client_) |
| 926 input_handler_client_->MainThreadHasStoppedFlinging(); | 929 input_handler_client_->MainThreadHasStoppedFlinging(); |
| 927 } | 930 } |
| 928 | 931 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1298 } | 1301 } |
| 1299 | 1302 |
| 1300 if (needs_commit) | 1303 if (needs_commit) |
| 1301 client_->SetNeedsCommitOnImplThread(); | 1304 client_->SetNeedsCommitOnImplThread(); |
| 1302 } | 1305 } |
| 1303 | 1306 |
| 1304 void LayerTreeHostImpl::SetExternalDrawConstraints( | 1307 void LayerTreeHostImpl::SetExternalDrawConstraints( |
| 1305 const gfx::Transform& transform, | 1308 const gfx::Transform& transform, |
| 1306 const gfx::Rect& viewport, | 1309 const gfx::Rect& viewport, |
| 1307 const gfx::Rect& clip, | 1310 const gfx::Rect& clip, |
| 1311 bool resourceless_software_draw, | |
| 1308 bool valid_for_tile_management) { | 1312 bool valid_for_tile_management) { |
| 1309 if (external_transform_ != transform || external_viewport_ != viewport) { | 1313 if (external_transform_ != transform || external_viewport_ != viewport || |
| 1314 resourceless_software_draw_ != resourceless_software_draw) { | |
|
brianderson
2014/07/08 21:26:12
Is this the part that fixes the bug?
Was the poin
boliu
2014/07/08 21:31:14
Yes
| |
| 1310 active_tree_->set_needs_update_draw_properties(); | 1315 active_tree_->set_needs_update_draw_properties(); |
| 1311 } | 1316 } |
| 1312 | 1317 |
| 1313 external_transform_ = transform; | 1318 external_transform_ = transform; |
| 1314 external_viewport_ = viewport; | 1319 external_viewport_ = viewport; |
| 1315 external_clip_ = clip; | 1320 external_clip_ = clip; |
| 1321 resourceless_software_draw_ = resourceless_software_draw; | |
| 1316 device_viewport_valid_for_tile_management_ = valid_for_tile_management; | 1322 device_viewport_valid_for_tile_management_ = valid_for_tile_management; |
| 1317 } | 1323 } |
| 1318 | 1324 |
| 1319 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 1325 void LayerTreeHostImpl::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
| 1320 if (damage_rect.IsEmpty()) | 1326 if (damage_rect.IsEmpty()) |
| 1321 return; | 1327 return; |
| 1322 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); | 1328 NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
| 1323 client_->SetNeedsRedrawRectOnImplThread(damage_rect); | 1329 client_->SetNeedsRedrawRectOnImplThread(damage_rect); |
| 1324 } | 1330 } |
| 1325 | 1331 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1455 id_, | 1461 id_, |
| 1456 TracedValue::FromValue(AsValueWithFrame(frame).release())); | 1462 TracedValue::FromValue(AsValueWithFrame(frame).release())); |
| 1457 } | 1463 } |
| 1458 | 1464 |
| 1459 // Because the contents of the HUD depend on everything else in the frame, the | 1465 // 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 | 1466 // contents of its texture are updated as the last thing before the frame is |
| 1461 // drawn. | 1467 // drawn. |
| 1462 if (active_tree_->hud_layer()) { | 1468 if (active_tree_->hud_layer()) { |
| 1463 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1469 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
| 1464 active_tree_->hud_layer()->UpdateHudTexture( | 1470 active_tree_->hud_layer()->UpdateHudTexture( |
| 1465 GetDrawMode(output_surface_.get()), resource_provider_.get()); | 1471 GetDrawMode(resourceless_software_draw_, output_surface_.get()), |
|
danakj
2014/07/09 17:21:07
can you move this GetDrawMode up above the if stat
boliu
2014/07/09 20:59:50
Done.
| |
| 1472 resource_provider_.get()); | |
| 1466 } | 1473 } |
| 1467 | 1474 |
| 1468 if (output_surface_->ForcedDrawToSoftwareDevice()) { | 1475 if (resourceless_software_draw_) { |
| 1469 bool disable_picture_quad_image_filtering = | 1476 bool disable_picture_quad_image_filtering = |
| 1470 IsCurrentlyScrolling() || needs_animate_layers(); | 1477 IsCurrentlyScrolling() || needs_animate_layers(); |
| 1471 | 1478 |
| 1472 scoped_ptr<SoftwareRenderer> temp_software_renderer = | 1479 scoped_ptr<SoftwareRenderer> temp_software_renderer = |
| 1473 SoftwareRenderer::Create(this, &settings_, output_surface_.get(), NULL); | 1480 SoftwareRenderer::Create(this, &settings_, output_surface_.get(), NULL); |
| 1474 temp_software_renderer->DrawFrame(&frame->render_passes, | 1481 temp_software_renderer->DrawFrame(&frame->render_passes, |
| 1475 device_scale_factor_, | 1482 device_scale_factor_, |
| 1476 DeviceViewport(), | 1483 DeviceViewport(), |
| 1477 DeviceClip(), | 1484 DeviceClip(), |
| 1478 disable_picture_quad_image_filtering); | 1485 disable_picture_quad_image_filtering); |
| (...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3152 } | 3159 } |
| 3153 | 3160 |
| 3154 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3161 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3155 std::vector<PictureLayerImpl*>::iterator it = | 3162 std::vector<PictureLayerImpl*>::iterator it = |
| 3156 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3163 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3157 DCHECK(it != picture_layers_.end()); | 3164 DCHECK(it != picture_layers_.end()); |
| 3158 picture_layers_.erase(it); | 3165 picture_layers_.erase(it); |
| 3159 } | 3166 } |
| 3160 | 3167 |
| 3161 } // namespace cc | 3168 } // namespace cc |
| OLD | NEW |