| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 | 1027 |
| 1028 if (!active_tree_->has_transparent_background()) { | 1028 if (!active_tree_->has_transparent_background()) { |
| 1029 frame->render_passes.back()->has_transparent_background = false; | 1029 frame->render_passes.back()->has_transparent_background = false; |
| 1030 AppendQuadsToFillScreen( | 1030 AppendQuadsToFillScreen( |
| 1031 active_tree_->RootScrollLayerDeviceViewportBounds(), | 1031 active_tree_->RootScrollLayerDeviceViewportBounds(), |
| 1032 frame->render_passes.back().get(), active_tree_->RootRenderSurface(), | 1032 frame->render_passes.back().get(), active_tree_->RootRenderSurface(), |
| 1033 active_tree_->background_color(), unoccluded_screen_space_region); | 1033 active_tree_->background_color(), unoccluded_screen_space_region); |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 RemoveRenderPasses(frame); | 1036 RemoveRenderPasses(frame); |
| 1037 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); | 1037 // If we're making a frame to draw, it better have at least one render pass. |
| 1038 DCHECK(!frame->render_passes.empty()); |
| 1038 | 1039 |
| 1039 if (have_copy_request) { | 1040 if (have_copy_request) { |
| 1040 // Any copy requests left in the tree are not going to get serviced, and | 1041 // Any copy requests left in the tree are not going to get serviced, and |
| 1041 // should be aborted. | 1042 // should be aborted. |
| 1042 active_tree()->property_trees()->effect_tree.ClearCopyRequests(); | 1043 active_tree()->property_trees()->effect_tree.ClearCopyRequests(); |
| 1043 | 1044 |
| 1044 // Draw properties depend on copy requests. | 1045 // Draw properties depend on copy requests. |
| 1045 active_tree()->set_needs_update_draw_properties(); | 1046 active_tree()->set_needs_update_draw_properties(); |
| 1046 } | 1047 } |
| 1047 | 1048 |
| 1048 // If we're making a frame to draw, it better have at least one render pass. | |
| 1049 DCHECK(!frame->render_passes.empty()); | |
| 1050 | |
| 1051 if (active_tree_->has_ever_been_drawn()) { | 1049 if (active_tree_->has_ever_been_drawn()) { |
| 1052 UMA_HISTOGRAM_COUNTS_100( | 1050 UMA_HISTOGRAM_COUNTS_100( |
| 1053 "Compositing.RenderPass.AppendQuadData.NumMissingTiles", | 1051 "Compositing.RenderPass.AppendQuadData.NumMissingTiles", |
| 1054 num_missing_tiles); | 1052 num_missing_tiles); |
| 1055 UMA_HISTOGRAM_COUNTS_100( | 1053 UMA_HISTOGRAM_COUNTS_100( |
| 1056 "Compositing.RenderPass.AppendQuadData.NumIncompleteTiles", | 1054 "Compositing.RenderPass.AppendQuadData.NumIncompleteTiles", |
| 1057 num_incomplete_tiles); | 1055 num_incomplete_tiles); |
| 1058 UMA_HISTOGRAM_COUNTS( | 1056 UMA_HISTOGRAM_COUNTS( |
| 1059 "Compositing.RenderPass.AppendQuadData." | 1057 "Compositing.RenderPass.AppendQuadData." |
| 1060 "CheckerboardedNoRecordingContentArea", | 1058 "CheckerboardedNoRecordingContentArea", |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 | 1533 |
| 1536 void LayerTreeHostImpl::DidReceiveTextureInUseResponses( | 1534 void LayerTreeHostImpl::DidReceiveTextureInUseResponses( |
| 1537 const gpu::TextureInUseResponses& responses) { | 1535 const gpu::TextureInUseResponses& responses) { |
| 1538 NOTREACHED(); | 1536 NOTREACHED(); |
| 1539 } | 1537 } |
| 1540 | 1538 |
| 1541 void LayerTreeHostImpl::ReclaimResources( | 1539 void LayerTreeHostImpl::ReclaimResources( |
| 1542 const ReturnedResourceArray& resources) { | 1540 const ReturnedResourceArray& resources) { |
| 1543 // TODO(piman): We may need to do some validation on this ack before | 1541 // TODO(piman): We may need to do some validation on this ack before |
| 1544 // processing it. | 1542 // processing it. |
| 1545 if (renderer_) | 1543 if (resource_provider_) |
| 1546 renderer_->ReclaimResources(resources); | 1544 resource_provider_->ReceiveReturnsFromParent(resources); |
| 1547 | 1545 |
| 1548 // In OOM, we now might be able to release more resources that were held | 1546 // In OOM, we now might be able to release more resources that were held |
| 1549 // because they were exported. | 1547 // because they were exported. |
| 1550 if (resource_pool_) { | 1548 if (resource_pool_) { |
| 1551 if (resource_pool_->memory_usage_bytes()) { | 1549 if (resource_pool_->memory_usage_bytes()) { |
| 1552 const size_t kMegabyte = 1024 * 1024; | 1550 const size_t kMegabyte = 1024 * 1024; |
| 1553 | 1551 |
| 1554 // This is a good time to log memory usage. A chunk of work has just | 1552 // This is a good time to log memory usage. A chunk of work has just |
| 1555 // completed but none of the memory used for that work has likely been | 1553 // completed but none of the memory used for that work has likely been |
| 1556 // freed. | 1554 // freed. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 | 1710 |
| 1713 // Because the contents of the HUD depend on everything else in the frame, the | 1711 // Because the contents of the HUD depend on everything else in the frame, the |
| 1714 // contents of its texture are updated as the last thing before the frame is | 1712 // contents of its texture are updated as the last thing before the frame is |
| 1715 // drawn. | 1713 // drawn. |
| 1716 if (active_tree_->hud_layer()) { | 1714 if (active_tree_->hud_layer()) { |
| 1717 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1715 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
| 1718 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, | 1716 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
| 1719 resource_provider_.get()); | 1717 resource_provider_.get()); |
| 1720 } | 1718 } |
| 1721 | 1719 |
| 1722 renderer_->DrawFrame(&frame->render_passes, | 1720 renderer_->DrawFrame(&frame->render_passes); |
| 1723 active_tree_->device_scale_factor(), gfx::ColorSpace(), | |
| 1724 DeviceViewport(), DeviceViewport()); | |
| 1725 // The render passes should be consumed by the renderer. | 1721 // The render passes should be consumed by the renderer. |
| 1726 DCHECK(frame->render_passes.empty()); | 1722 DCHECK(frame->render_passes.empty()); |
| 1727 | 1723 |
| 1728 // The next frame should start by assuming nothing has changed, and changes | 1724 // The next frame should start by assuming nothing has changed, and changes |
| 1729 // are noted as they occur. | 1725 // are noted as they occur. |
| 1730 // TODO(boliu): If we did a temporary software renderer frame, propogate the | 1726 // TODO(boliu): If we did a temporary software renderer frame, propogate the |
| 1731 // damage forward to the next frame. | 1727 // damage forward to the next frame. |
| 1732 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { | 1728 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { |
| 1733 (*frame->render_surface_layer_list)[i] | 1729 (*frame->render_surface_layer_list)[i] |
| 1734 ->render_surface() | 1730 ->render_surface() |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 if (recycle_tree_) | 2147 if (recycle_tree_) |
| 2152 recycle_tree_->RecreateResources(); | 2148 recycle_tree_->RecreateResources(); |
| 2153 } | 2149 } |
| 2154 | 2150 |
| 2155 void LayerTreeHostImpl::CreateAndSetRenderer() { | 2151 void LayerTreeHostImpl::CreateAndSetRenderer() { |
| 2156 DCHECK(!renderer_); | 2152 DCHECK(!renderer_); |
| 2157 DCHECK(output_surface_); | 2153 DCHECK(output_surface_); |
| 2158 DCHECK(resource_provider_); | 2154 DCHECK(resource_provider_); |
| 2159 | 2155 |
| 2160 DCHECK(output_surface_->capabilities().delegated_rendering); | 2156 DCHECK(output_surface_->capabilities().delegated_rendering); |
| 2161 renderer_ = base::MakeUnique<DelegatingRenderer>( | 2157 renderer_ = base::MakeUnique<DelegatingRenderer>(output_surface_, |
| 2162 &settings_.renderer_settings, output_surface_, resource_provider_.get()); | 2158 resource_provider_.get()); |
| 2163 renderer_->SetVisible(visible_); | |
| 2164 SetFullViewportDamage(); | 2159 SetFullViewportDamage(); |
| 2165 | 2160 |
| 2166 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be | 2161 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs to be |
| 2167 // initialized to get max texture size. Also, after releasing resources, | 2162 // initialized to get max texture size. Also, after releasing resources, |
| 2168 // trees need another update to generate new ones. | 2163 // trees need another update to generate new ones. |
| 2169 active_tree_->set_needs_update_draw_properties(); | 2164 active_tree_->set_needs_update_draw_properties(); |
| 2170 if (pending_tree_) | 2165 if (pending_tree_) |
| 2171 pending_tree_->set_needs_update_draw_properties(); | 2166 pending_tree_->set_needs_update_draw_properties(); |
| 2172 client_->UpdateRendererCapabilitiesOnImplThread(); | 2167 client_->UpdateRendererCapabilitiesOnImplThread(); |
| 2173 } | 2168 } |
| (...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4063 return task_runner_provider_->HasImplThread(); | 4058 return task_runner_provider_->HasImplThread(); |
| 4064 } | 4059 } |
| 4065 | 4060 |
| 4066 bool LayerTreeHostImpl::CommitToActiveTree() const { | 4061 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 4067 // In single threaded mode we skip the pending tree and commit directly to the | 4062 // In single threaded mode we skip the pending tree and commit directly to the |
| 4068 // active tree. | 4063 // active tree. |
| 4069 return !task_runner_provider_->HasImplThread(); | 4064 return !task_runner_provider_->HasImplThread(); |
| 4070 } | 4065 } |
| 4071 | 4066 |
| 4072 } // namespace cc | 4067 } // namespace cc |
| OLD | NEW |