| 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/layer_tree_host.h" | 5 #include "cc/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 contents_texture_manager_->updateBackingsInDrawingImplTree(); | 260 contents_texture_manager_->updateBackingsInDrawingImplTree(); |
| 261 | 261 |
| 262 // In impl-side painting, synchronize to the pending tree so that it has | 262 // In impl-side painting, synchronize to the pending tree so that it has |
| 263 // time to raster before being displayed. If no pending tree is needed, | 263 // time to raster before being displayed. If no pending tree is needed, |
| 264 // synchronization can happen directly to the active tree and | 264 // synchronization can happen directly to the active tree and |
| 265 // unlinked contents resources can be reclaimed immediately. | 265 // unlinked contents resources can be reclaimed immediately. |
| 266 LayerTreeImpl* sync_tree; | 266 LayerTreeImpl* sync_tree; |
| 267 if (settings_.implSidePainting) { | 267 if (settings_.implSidePainting) { |
| 268 // Commits should not occur while there is already a pending tree. | 268 // Commits should not occur while there is already a pending tree. |
| 269 DCHECK(!host_impl->pendingTree()); | 269 DCHECK(!host_impl->pending_tree()); |
| 270 host_impl->createPendingTree(); | 270 host_impl->CreatePendingTree(); |
| 271 sync_tree = host_impl->pendingTree(); | 271 sync_tree = host_impl->pending_tree(); |
| 272 } else { | 272 } else { |
| 273 contents_texture_manager_->reduceMemory(host_impl->resourceProvider()); | 273 contents_texture_manager_->reduceMemory(host_impl->resource_provider()); |
| 274 sync_tree = host_impl->activeTree(); | 274 sync_tree = host_impl->active_tree(); |
| 275 } | 275 } |
| 276 | 276 |
| 277 if (needs_full_tree_sync_) | 277 if (needs_full_tree_sync_) |
| 278 sync_tree->SetRootLayer(TreeSynchronizer::synchronizeTrees( | 278 sync_tree->SetRootLayer(TreeSynchronizer::synchronizeTrees( |
| 279 root_layer(), sync_tree->DetachLayerTree(), sync_tree)); { | 279 root_layer(), sync_tree->DetachLayerTree(), sync_tree)); { |
| 280 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 280 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
| 281 TreeSynchronizer::pushProperties(root_layer(), sync_tree->RootLayer()); | 281 TreeSynchronizer::pushProperties(root_layer(), sync_tree->root_layer()); |
| 282 } | 282 } |
| 283 | 283 |
| 284 sync_tree->set_needs_full_tree_sync(needs_full_tree_sync_); | 284 sync_tree->set_needs_full_tree_sync(needs_full_tree_sync_); |
| 285 needs_full_tree_sync_ = false; | 285 needs_full_tree_sync_ = false; |
| 286 | 286 |
| 287 if (root_layer_ && hud_layer_) { | 287 if (root_layer_ && hud_layer_) { |
| 288 LayerImpl* hud_impl = LayerTreeHostCommon::findLayerInSubtree( | 288 LayerImpl* hud_impl = LayerTreeHostCommon::findLayerInSubtree( |
| 289 sync_tree->RootLayer(), hud_layer_->id()); | 289 sync_tree->root_layer(), hud_layer_->id()); |
| 290 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); | 290 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); |
| 291 } else { | 291 } else { |
| 292 sync_tree->set_hud_layer(NULL); | 292 sync_tree->set_hud_layer(NULL); |
| 293 } | 293 } |
| 294 | 294 |
| 295 sync_tree->set_source_frame_number(commit_number()); | 295 sync_tree->set_source_frame_number(commit_number()); |
| 296 sync_tree->set_background_color(background_color_); | 296 sync_tree->set_background_color(background_color_); |
| 297 sync_tree->set_has_transparent_background(has_transparent_background_); | 297 sync_tree->set_has_transparent_background(has_transparent_background_); |
| 298 | 298 |
| 299 sync_tree->FindRootScrollLayer(); | 299 sync_tree->FindRootScrollLayer(); |
| 300 | 300 |
| 301 float page_scale_delta, sent_page_scale_delta; | 301 float page_scale_delta, sent_page_scale_delta; |
| 302 if (settings_.implSidePainting) { | 302 if (settings_.implSidePainting) { |
| 303 // Update the delta from the active tree, which may have | 303 // Update the delta from the active tree, which may have |
| 304 // adjusted its delta prior to the pending tree being created. | 304 // adjusted its delta prior to the pending tree being created. |
| 305 // This code is equivalent to that in LayerTreeImpl::SetPageScaleDelta. | 305 // This code is equivalent to that in LayerTreeImpl::SetPageScaleDelta. |
| 306 DCHECK_EQ(1.f, sync_tree->sent_page_scale_delta()); | 306 DCHECK_EQ(1.f, sync_tree->sent_page_scale_delta()); |
| 307 page_scale_delta = host_impl->activeTree()->page_scale_delta(); | 307 page_scale_delta = host_impl->active_tree()->page_scale_delta(); |
| 308 sent_page_scale_delta = host_impl->activeTree()->sent_page_scale_delta(); | 308 sent_page_scale_delta = host_impl->active_tree()->sent_page_scale_delta(); |
| 309 } else { | 309 } else { |
| 310 page_scale_delta = sync_tree->page_scale_delta(); | 310 page_scale_delta = sync_tree->page_scale_delta(); |
| 311 sent_page_scale_delta = sync_tree->sent_page_scale_delta(); | 311 sent_page_scale_delta = sync_tree->sent_page_scale_delta(); |
| 312 sync_tree->set_sent_page_scale_delta(1.f); | 312 sync_tree->set_sent_page_scale_delta(1.f); |
| 313 } | 313 } |
| 314 | 314 |
| 315 sync_tree->SetPageScaleFactorAndLimits(page_scale_factor_, | 315 sync_tree->SetPageScaleFactorAndLimits(page_scale_factor_, |
| 316 min_page_scale_factor_, | 316 min_page_scale_factor_, |
| 317 max_page_scale_factor_); | 317 max_page_scale_factor_); |
| 318 sync_tree->SetPageScaleDelta(page_scale_delta / sent_page_scale_delta); | 318 sync_tree->SetPageScaleDelta(page_scale_delta / sent_page_scale_delta); |
| 319 | 319 |
| 320 host_impl->setViewportSize(layout_viewport_size_, device_viewport_size_); | 320 host_impl->SetViewportSize(layout_viewport_size_, device_viewport_size_); |
| 321 host_impl->setDeviceScaleFactor(device_scale_factor_); | 321 host_impl->SetDeviceScaleFactor(device_scale_factor_); |
| 322 host_impl->setDebugState(debug_state_); | 322 host_impl->SetDebugState(debug_state_); |
| 323 | 323 |
| 324 DCHECK(!sync_tree->ViewportSizeInvalid()); | 324 DCHECK(!sync_tree->ViewportSizeInvalid()); |
| 325 | 325 |
| 326 if (new_impl_tree_has_no_evicted_resources) { | 326 if (new_impl_tree_has_no_evicted_resources) { |
| 327 if (sync_tree->ContentsTexturesPurged()) | 327 if (sync_tree->ContentsTexturesPurged()) |
| 328 sync_tree->ResetContentsTexturesPurged(); | 328 sync_tree->ResetContentsTexturesPurged(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 if (!settings_.implSidePainting) { | 331 if (!settings_.implSidePainting) { |
| 332 // If we're not in impl-side painting, the tree is immediately | 332 // If we're not in impl-side painting, the tree is immediately |
| 333 // considered active. | 333 // considered active. |
| 334 sync_tree->DidBecomeActive(); | 334 sync_tree->DidBecomeActive(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 if (debug_state_.continuousPainting) | 337 if (debug_state_.continuousPainting) |
| 338 host_impl->savePaintTime(rendering_stats_.totalPaintTime, commit_number()); | 338 host_impl->SavePaintTime(rendering_stats_.totalPaintTime, commit_number()); |
| 339 | 339 |
| 340 commit_number_++; | 340 commit_number_++; |
| 341 } | 341 } |
| 342 | 342 |
| 343 void LayerTreeHost::WillCommit() { | 343 void LayerTreeHost::WillCommit() { |
| 344 client_->willCommit(); | 344 client_->willCommit(); |
| 345 } | 345 } |
| 346 | 346 |
| 347 void LayerTreeHost::UpdateHudLayer() { | 347 void LayerTreeHost::UpdateHudLayer() { |
| 348 if (debug_state_.showHudInfo()) { | 348 if (debug_state_.showHudInfo()) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 366 } | 366 } |
| 367 | 367 |
| 368 scoped_ptr<InputHandler> LayerTreeHost::CreateInputHandler() { | 368 scoped_ptr<InputHandler> LayerTreeHost::CreateInputHandler() { |
| 369 return client_->createInputHandler(); | 369 return client_->createInputHandler(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( | 372 scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
| 373 LayerTreeHostImplClient* client) { | 373 LayerTreeHostImplClient* client) { |
| 374 DCHECK(proxy_->IsImplThread()); | 374 DCHECK(proxy_->IsImplThread()); |
| 375 scoped_ptr<LayerTreeHostImpl> host_impl = | 375 scoped_ptr<LayerTreeHostImpl> host_impl = |
| 376 LayerTreeHostImpl::create(settings_, client, proxy_.get()); | 376 LayerTreeHostImpl::Create(settings_, client, proxy_.get()); |
| 377 if (settings_.calculateTopControlsPosition && | 377 if (settings_.calculateTopControlsPosition && |
| 378 host_impl->topControlsManager()) { | 378 host_impl->top_controls_manager()) { |
| 379 top_controls_manager_weak_ptr_ = | 379 top_controls_manager_weak_ptr_ = |
| 380 host_impl->topControlsManager()->AsWeakPtr(); | 380 host_impl->top_controls_manager()->AsWeakPtr(); |
| 381 } | 381 } |
| 382 return host_impl.Pass(); | 382 return host_impl.Pass(); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void LayerTreeHost::DidLoseOutputSurface() { | 385 void LayerTreeHost::DidLoseOutputSurface() { |
| 386 TRACE_EVENT0("cc", "LayerTreeHost::DidLoseOutputSurface"); | 386 TRACE_EVENT0("cc", "LayerTreeHost::DidLoseOutputSurface"); |
| 387 DCHECK(proxy_->IsMainThread()); | 387 DCHECK(proxy_->IsMainThread()); |
| 388 output_surface_lost_ = true; | 388 output_surface_lost_ = true; |
| 389 num_failed_recreate_attempts_ = 0; | 389 num_failed_recreate_attempts_ = 0; |
| 390 SetNeedsCommit(); | 390 SetNeedsCommit(); |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 SetAnimationEventsRecursive(events, | 939 SetAnimationEventsRecursive(events, |
| 940 layer->children()[child_index].get(), | 940 layer->children()[child_index].get(), |
| 941 wall_clock_time); | 941 wall_clock_time); |
| 942 } | 942 } |
| 943 | 943 |
| 944 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { | 944 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { |
| 945 return proxy_->CapturePicture(); | 945 return proxy_->CapturePicture(); |
| 946 } | 946 } |
| 947 | 947 |
| 948 } // namespace cc | 948 } // namespace cc |
| OLD | NEW |