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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 active_tree_->ResetContentsTexturesPurged(); | 288 active_tree_->ResetContentsTexturesPurged(); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 void LayerTreeHostImpl::BeginCommit() { | 292 void LayerTreeHostImpl::BeginCommit() { |
293 TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); | 293 TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); |
294 | 294 |
295 // Ensure all textures are returned so partial texture updates can happen | 295 // Ensure all textures are returned so partial texture updates can happen |
296 // during the commit. Impl-side-painting doesn't upload during commits, so | 296 // during the commit. Impl-side-painting doesn't upload during commits, so |
297 // is unaffected. | 297 // is unaffected. |
298 if (!settings_.impl_side_painting) | 298 if (!settings_.impl_side_painting && output_surface_) |
299 output_surface_->ForceReclaimResources(); | 299 output_surface_->ForceReclaimResources(); |
300 | 300 |
301 if (UsePendingTreeForSync()) | 301 if (UsePendingTreeForSync()) |
302 CreatePendingTree(); | 302 CreatePendingTree(); |
303 } | 303 } |
304 | 304 |
305 void LayerTreeHostImpl::CommitComplete() { | 305 void LayerTreeHostImpl::CommitComplete() { |
306 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 306 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
307 | 307 |
308 if (pending_tree_) | 308 if (pending_tree_) |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 --surface_index) { | 684 --surface_index) { |
685 LayerImpl* render_surface_layer = | 685 LayerImpl* render_surface_layer = |
686 (*frame->render_surface_layer_list)[surface_index]; | 686 (*frame->render_surface_layer_list)[surface_index]; |
687 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); | 687 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); |
688 | 688 |
689 bool should_draw_into_render_pass = | 689 bool should_draw_into_render_pass = |
690 render_surface_layer->parent() == NULL || | 690 render_surface_layer->parent() == NULL || |
691 render_surface->contributes_to_drawn_surface() || | 691 render_surface->contributes_to_drawn_surface() || |
692 render_surface_layer->HasCopyRequest(); | 692 render_surface_layer->HasCopyRequest(); |
693 if (should_draw_into_render_pass) | 693 if (should_draw_into_render_pass) |
694 render_surface_layer->render_surface()->AppendRenderPasses(frame); | 694 render_surface->AppendRenderPasses(frame); |
695 } | 695 } |
696 | 696 |
697 // When we are displaying the HUD, change the root damage rect to cover the | 697 // When we are displaying the HUD, change the root damage rect to cover the |
698 // entire root surface. This will disable partial-swap/scissor optimizations | 698 // entire root surface. This will disable partial-swap/scissor optimizations |
699 // that would prevent the HUD from updating, since the HUD does not cause | 699 // that would prevent the HUD from updating, since the HUD does not cause |
700 // damage itself, to prevent it from messing with damage visualizations. Since | 700 // damage itself, to prevent it from messing with damage visualizations. Since |
701 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls, | 701 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls, |
702 // changing the RenderPass does not affect them. | 702 // changing the RenderPass does not affect them. |
703 if (active_tree_->hud_layer()) { | 703 if (active_tree_->hud_layer()) { |
704 RenderPass* root_pass = frame->render_passes.back(); | 704 RenderPass* root_pass = frame->render_passes.back(); |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 if (layer->GetTree() == ACTIVE_TREE) { | 1187 if (layer->GetTree() == ACTIVE_TREE) { |
1188 DCHECK_IMPLIES(twin_layer, twin_layer->GetTree() == PENDING_TREE); | 1188 DCHECK_IMPLIES(twin_layer, twin_layer->GetTree() == PENDING_TREE); |
1189 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); | 1189 layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); |
1190 } else if (!twin_layer) { | 1190 } else if (!twin_layer) { |
1191 DCHECK(layer->GetTree() == PENDING_TREE); | 1191 DCHECK(layer->GetTree() == PENDING_TREE); |
1192 layer_pairs->push_back(PictureLayerImpl::Pair(NULL, layer)); | 1192 layer_pairs->push_back(PictureLayerImpl::Pair(NULL, layer)); |
1193 } | 1193 } |
1194 } | 1194 } |
1195 } | 1195 } |
1196 | 1196 |
1197 void LayerTreeHostImpl::BuildRasterQueue(RasterTilePriorityQueue* queue, | 1197 scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( |
1198 TreePriority tree_priority, | 1198 TreePriority tree_priority, |
1199 RasterTilePriorityQueue::Type type) { | 1199 RasterTilePriorityQueue::Type type) { |
1200 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); | 1200 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); |
1201 picture_layer_pairs_.clear(); | 1201 picture_layer_pairs_.clear(); |
1202 GetPictureLayerImplPairs(&picture_layer_pairs_, true); | 1202 GetPictureLayerImplPairs(&picture_layer_pairs_, true); |
1203 queue->Build(picture_layer_pairs_, tree_priority, type); | 1203 scoped_ptr<RasterTilePriorityQueue> queue(RasterTilePriorityQueue::Create( |
| 1204 picture_layer_pairs_, tree_priority, type)); |
1204 | 1205 |
1205 if (!queue->IsEmpty()) { | 1206 if (!queue->IsEmpty()) { |
1206 // Only checking the Top() tile here isn't a definite answer that there is | 1207 // Only checking the Top() tile here isn't a definite answer that there is |
1207 // or isn't something required for draw in this raster queue. It's just a | 1208 // or isn't something required for draw in this raster queue. It's just a |
1208 // heuristic to let us hit the common case and proactively tell the | 1209 // heuristic to let us hit the common case and proactively tell the |
1209 // scheduler that we expect to draw within each vsync until we get all the | 1210 // scheduler that we expect to draw within each vsync until we get all the |
1210 // tiles ready to draw. If we happen to miss a required for draw tile here, | 1211 // tiles ready to draw. If we happen to miss a required for draw tile here, |
1211 // then we will miss telling the scheduler each frame that we intend to draw | 1212 // then we will miss telling the scheduler each frame that we intend to draw |
1212 // so it may make worse scheduling decisions. | 1213 // so it may make worse scheduling decisions. |
1213 required_for_draw_tile_is_top_of_raster_queue_ = | 1214 required_for_draw_tile_is_top_of_raster_queue_ = |
1214 queue->Top()->required_for_draw(); | 1215 queue->Top()->required_for_draw(); |
1215 } else { | 1216 } else { |
1216 required_for_draw_tile_is_top_of_raster_queue_ = false; | 1217 required_for_draw_tile_is_top_of_raster_queue_ = false; |
1217 } | 1218 } |
| 1219 return queue; |
1218 } | 1220 } |
1219 | 1221 |
1220 void LayerTreeHostImpl::BuildEvictionQueue(EvictionTilePriorityQueue* queue, | 1222 scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( |
1221 TreePriority tree_priority) { | 1223 TreePriority tree_priority) { |
1222 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); | 1224 TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); |
| 1225 scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue); |
1223 picture_layer_pairs_.clear(); | 1226 picture_layer_pairs_.clear(); |
1224 GetPictureLayerImplPairs(&picture_layer_pairs_, false); | 1227 GetPictureLayerImplPairs(&picture_layer_pairs_, false); |
1225 queue->Build(picture_layer_pairs_, tree_priority); | 1228 queue->Build(picture_layer_pairs_, tree_priority); |
| 1229 return queue; |
1226 } | 1230 } |
1227 | 1231 |
1228 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() | 1232 const std::vector<PictureLayerImpl*>& LayerTreeHostImpl::GetPictureLayers() |
1229 const { | 1233 const { |
1230 return picture_layers_; | 1234 return picture_layers_; |
1231 } | 1235 } |
1232 | 1236 |
1233 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1237 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1234 client_->NotifyReadyToActivate(); | 1238 client_->NotifyReadyToActivate(); |
1235 } | 1239 } |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1589 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
1586 ResetRequiresHighResToDraw(); | 1590 ResetRequiresHighResToDraw(); |
1587 if (frame.has_no_damage) { | 1591 if (frame.has_no_damage) { |
1588 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); | 1592 active_tree()->BreakSwapPromises(SwapPromise::SWAP_FAILS); |
1589 return false; | 1593 return false; |
1590 } | 1594 } |
1591 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); | 1595 CompositorFrameMetadata metadata = MakeCompositorFrameMetadata(); |
1592 active_tree()->FinishSwapPromises(&metadata); | 1596 active_tree()->FinishSwapPromises(&metadata); |
1593 for (size_t i = 0; i < metadata.latency_info.size(); i++) { | 1597 for (size_t i = 0; i < metadata.latency_info.size(); i++) { |
1594 TRACE_EVENT_FLOW_STEP0( | 1598 TRACE_EVENT_FLOW_STEP0( |
1595 "input", | 1599 "input,benchmark", |
1596 "LatencyInfo.Flow", | 1600 "LatencyInfo.Flow", |
1597 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), | 1601 TRACE_ID_DONT_MANGLE(metadata.latency_info[i].trace_id), |
1598 "SwapBuffers"); | 1602 "SwapBuffers"); |
1599 } | 1603 } |
1600 renderer_->SwapBuffers(metadata); | 1604 renderer_->SwapBuffers(metadata); |
1601 return true; | 1605 return true; |
1602 } | 1606 } |
1603 | 1607 |
1604 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1608 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1605 // Sample the frame time now. This time will be used for updating animations | 1609 // Sample the frame time now. This time will be used for updating animations |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 scoped_ptr<ResourcePool>* resource_pool, | 1966 scoped_ptr<ResourcePool>* resource_pool, |
1963 scoped_ptr<ResourcePool>* staging_resource_pool) { | 1967 scoped_ptr<ResourcePool>* staging_resource_pool) { |
1964 base::SingleThreadTaskRunner* task_runner = | 1968 base::SingleThreadTaskRunner* task_runner = |
1965 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | 1969 proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() |
1966 : proxy_->MainThreadTaskRunner(); | 1970 : proxy_->MainThreadTaskRunner(); |
1967 DCHECK(task_runner); | 1971 DCHECK(task_runner); |
1968 | 1972 |
1969 ContextProvider* context_provider = output_surface_->context_provider(); | 1973 ContextProvider* context_provider = output_surface_->context_provider(); |
1970 if (!context_provider) { | 1974 if (!context_provider) { |
1971 *resource_pool = | 1975 *resource_pool = |
1972 ResourcePool::Create(resource_provider_.get(), | 1976 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); |
1973 GL_TEXTURE_2D, | |
1974 resource_provider_->best_texture_format()); | |
1975 | 1977 |
1976 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( | 1978 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( |
1977 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), | 1979 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), |
1978 resource_provider_.get()); | 1980 resource_provider_.get()); |
1979 return; | 1981 return; |
1980 } | 1982 } |
1981 | 1983 |
1982 if (use_gpu_rasterization_) { | 1984 if (use_gpu_rasterization_) { |
1983 *resource_pool = | 1985 *resource_pool = |
1984 ResourcePool::Create(resource_provider_.get(), | 1986 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); |
1985 GL_TEXTURE_2D, | |
1986 resource_provider_->best_texture_format()); | |
1987 | 1987 |
1988 *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( | 1988 *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( |
1989 task_runner, TileTaskWorkerPool::GetTaskGraphRunner()); | 1989 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), |
| 1990 resource_provider_.get()); |
1990 return; | 1991 return; |
1991 } | 1992 } |
1992 | 1993 |
1993 if (GetRendererCapabilities().using_image) { | 1994 if (GetRendererCapabilities().using_image) { |
1994 unsigned image_target = settings_.use_image_texture_target; | 1995 unsigned image_target = settings_.use_image_texture_target; |
1995 DCHECK_IMPLIES( | 1996 DCHECK_IMPLIES( |
1996 image_target == GL_TEXTURE_RECTANGLE_ARB, | 1997 image_target == GL_TEXTURE_RECTANGLE_ARB, |
1997 context_provider->ContextCapabilities().gpu.texture_rectangle); | 1998 context_provider->ContextCapabilities().gpu.texture_rectangle); |
1998 DCHECK_IMPLIES( | 1999 DCHECK_IMPLIES( |
1999 image_target == GL_TEXTURE_EXTERNAL_OES, | 2000 image_target == GL_TEXTURE_EXTERNAL_OES, |
2000 context_provider->ContextCapabilities().gpu.egl_image_external); | 2001 context_provider->ContextCapabilities().gpu.egl_image_external); |
2001 | 2002 |
2002 if (settings_.use_zero_copy || IsSynchronousSingleThreaded()) { | 2003 if (settings_.use_zero_copy || IsSynchronousSingleThreaded()) { |
2003 *resource_pool = | 2004 *resource_pool = |
2004 ResourcePool::Create(resource_provider_.get(), image_target, | 2005 ResourcePool::Create(resource_provider_.get(), image_target); |
2005 resource_provider_->best_texture_format()); | |
2006 | 2006 |
2007 TaskGraphRunner* task_graph_runner; | 2007 TaskGraphRunner* task_graph_runner; |
2008 if (IsSynchronousSingleThreaded()) { | 2008 if (IsSynchronousSingleThreaded()) { |
2009 DCHECK(!single_thread_synchronous_task_graph_runner_); | 2009 DCHECK(!single_thread_synchronous_task_graph_runner_); |
2010 single_thread_synchronous_task_graph_runner_.reset(new TaskGraphRunner); | 2010 single_thread_synchronous_task_graph_runner_.reset(new TaskGraphRunner); |
2011 task_graph_runner = single_thread_synchronous_task_graph_runner_.get(); | 2011 task_graph_runner = single_thread_synchronous_task_graph_runner_.get(); |
2012 } else { | 2012 } else { |
2013 task_graph_runner = TileTaskWorkerPool::GetTaskGraphRunner(); | 2013 task_graph_runner = TileTaskWorkerPool::GetTaskGraphRunner(); |
2014 } | 2014 } |
2015 | 2015 |
2016 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( | 2016 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( |
2017 task_runner, task_graph_runner, resource_provider_.get()); | 2017 task_runner, task_graph_runner, resource_provider_.get()); |
2018 return; | 2018 return; |
2019 } | 2019 } |
2020 | 2020 |
2021 if (settings_.use_one_copy) { | 2021 if (settings_.use_one_copy) { |
2022 // We need to create a staging resource pool when using copy rasterizer. | 2022 // We need to create a staging resource pool when using copy rasterizer. |
2023 *staging_resource_pool = | 2023 *staging_resource_pool = |
2024 ResourcePool::Create(resource_provider_.get(), image_target, | 2024 ResourcePool::Create(resource_provider_.get(), image_target); |
2025 resource_provider_->best_texture_format()); | |
2026 *resource_pool = | 2025 *resource_pool = |
2027 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D, | 2026 ResourcePool::Create(resource_provider_.get(), GL_TEXTURE_2D); |
2028 resource_provider_->best_texture_format()); | |
2029 | 2027 |
2030 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( | 2028 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( |
2031 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), | 2029 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), |
2032 context_provider, resource_provider_.get(), | 2030 context_provider, resource_provider_.get(), |
2033 staging_resource_pool_.get()); | 2031 staging_resource_pool_.get()); |
2034 return; | 2032 return; |
2035 } | 2033 } |
2036 } | 2034 } |
2037 | 2035 |
2038 *resource_pool = ResourcePool::Create( | 2036 *resource_pool = ResourcePool::Create( |
2039 resource_provider_.get(), GL_TEXTURE_2D, | 2037 resource_provider_.get(), GL_TEXTURE_2D); |
2040 resource_provider_->memory_efficient_texture_format()); | |
2041 | 2038 |
2042 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( | 2039 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( |
2043 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), context_provider, | 2040 task_runner, TileTaskWorkerPool::GetTaskGraphRunner(), context_provider, |
2044 resource_provider_.get(), | 2041 resource_provider_.get(), |
2045 GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(), | 2042 GetMaxTransferBufferUsageBytes(context_provider->ContextCapabilities(), |
2046 settings_.renderer_settings.refresh_rate)); | 2043 settings_.renderer_settings.refresh_rate)); |
2047 } | 2044 } |
2048 | 2045 |
2049 void LayerTreeHostImpl::DestroyTileManager() { | 2046 void LayerTreeHostImpl::DestroyTileManager() { |
2050 tile_manager_ = nullptr; | 2047 tile_manager_ = nullptr; |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3456 } | 3453 } |
3457 | 3454 |
3458 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3455 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3459 std::vector<PictureLayerImpl*>::iterator it = | 3456 std::vector<PictureLayerImpl*>::iterator it = |
3460 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3457 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3461 DCHECK(it != picture_layers_.end()); | 3458 DCHECK(it != picture_layers_.end()); |
3462 picture_layers_.erase(it); | 3459 picture_layers_.erase(it); |
3463 } | 3460 } |
3464 | 3461 |
3465 } // namespace cc | 3462 } // namespace cc |
OLD | NEW |