| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/compositor/compositor.h" | 5 #include "ui/compositor/compositor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 Compositor::Compositor(ui::ContextFactory* context_factory, | 73 Compositor::Compositor(ui::ContextFactory* context_factory, |
| 74 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 74 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 75 : context_factory_(context_factory), | 75 : context_factory_(context_factory), |
| 76 root_layer_(NULL), | 76 root_layer_(NULL), |
| 77 widget_(gfx::kNullAcceleratedWidget), | 77 widget_(gfx::kNullAcceleratedWidget), |
| 78 #if defined(USE_AURA) | 78 #if defined(USE_AURA) |
| 79 window_(nullptr), | 79 window_(nullptr), |
| 80 #endif | 80 #endif |
| 81 widget_valid_(false), | 81 widget_valid_(false), |
| 82 output_surface_requested_(false), | 82 compositor_frame_sink_requested_(false), |
| 83 surface_id_allocator_(new cc::SurfaceIdAllocator( | 83 surface_id_allocator_(new cc::SurfaceIdAllocator( |
| 84 context_factory->AllocateSurfaceClientId())), | 84 context_factory->AllocateSurfaceClientId())), |
| 85 task_runner_(task_runner), | 85 task_runner_(task_runner), |
| 86 vsync_manager_(new CompositorVSyncManager()), | 86 vsync_manager_(new CompositorVSyncManager()), |
| 87 device_scale_factor_(0.0f), | 87 device_scale_factor_(0.0f), |
| 88 locks_will_time_out_(true), | 88 locks_will_time_out_(true), |
| 89 compositor_lock_(NULL), | 89 compositor_lock_(NULL), |
| 90 layer_animator_collection_(this), | 90 layer_animator_collection_(this), |
| 91 weak_ptr_factory_(this) { | 91 weak_ptr_factory_(this) { |
| 92 context_factory->GetSurfaceManager()->RegisterSurfaceClientId( | 92 context_factory->GetSurfaceManager()->RegisterSurfaceClientId( |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 settings.renderer_settings.buffer_to_texture_target_map.insert( | 177 settings.renderer_settings.buffer_to_texture_target_map.insert( |
| 178 cc::BufferToTextureTargetMap::value_type( | 178 cc::BufferToTextureTargetMap::value_type( |
| 179 cc::BufferToTextureTargetKey(usage, format), target)); | 179 cc::BufferToTextureTargetKey(usage, format), target)); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 // Note: Only enable image decode tasks if we have more than one worker | 183 // Note: Only enable image decode tasks if we have more than one worker |
| 184 // thread. | 184 // thread. |
| 185 settings.image_decode_tasks_enabled = false; | 185 settings.image_decode_tasks_enabled = false; |
| 186 | 186 |
| 187 settings.use_output_surface_begin_frame_source = true; | 187 settings.use_compositor_frame_sink_begin_frame_source = true; |
| 188 | 188 |
| 189 settings.gpu_memory_policy.bytes_limit_when_visible = 512 * 1024 * 1024; | 189 settings.gpu_memory_policy.bytes_limit_when_visible = 512 * 1024 * 1024; |
| 190 settings.gpu_memory_policy.priority_cutoff_when_visible = | 190 settings.gpu_memory_policy.priority_cutoff_when_visible = |
| 191 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 191 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 192 | 192 |
| 193 base::TimeTicks before_create = base::TimeTicks::Now(); | 193 base::TimeTicks before_create = base::TimeTicks::Now(); |
| 194 | 194 |
| 195 cc::LayerTreeHost::InitParams params; | 195 cc::LayerTreeHost::InitParams params; |
| 196 params.client = this; | 196 params.client = this; |
| 197 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); | 197 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 256 |
| 257 void Compositor::RemoveSurfaceClient(uint32_t client_id) { | 257 void Compositor::RemoveSurfaceClient(uint32_t client_id) { |
| 258 auto it = surface_clients_.find(client_id); | 258 auto it = surface_clients_.find(client_id); |
| 259 DCHECK(it != surface_clients_.end()); | 259 DCHECK(it != surface_clients_.end()); |
| 260 DCHECK(it->second); | 260 DCHECK(it->second); |
| 261 context_factory_->GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy( | 261 context_factory_->GetSurfaceManager()->UnregisterSurfaceNamespaceHierarchy( |
| 262 it->second, it->first); | 262 it->second, it->first); |
| 263 surface_clients_.erase(it); | 263 surface_clients_.erase(it); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void Compositor::SetOutputSurface( | 266 void Compositor::SetCompositorFrameSink( |
| 267 std::unique_ptr<cc::OutputSurface> output_surface) { | 267 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink) { |
| 268 output_surface_requested_ = false; | 268 compositor_frame_sink_requested_ = false; |
| 269 host_->SetOutputSurface(std::move(output_surface)); | 269 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 270 // Visibility is reset when the output surface is lost, so update it to match | 270 // Visibility is reset when the output surface is lost, so update it to match |
| 271 // the Compositor's. | 271 // the Compositor's. |
| 272 context_factory_->SetDisplayVisible(this, host_->IsVisible()); | 272 context_factory_->SetDisplayVisible(this, host_->IsVisible()); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void Compositor::ScheduleDraw() { | 275 void Compositor::ScheduleDraw() { |
| 276 host_->SetNeedsCommit(); | 276 host_->SetNeedsCommit(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void Compositor::SetRootLayer(Layer* root_layer) { | 279 void Compositor::SetRootLayer(Layer* root_layer) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 base::TimeDelta interval) { | 377 base::TimeDelta interval) { |
| 378 context_factory_->SetDisplayVSyncParameters(this, timebase, interval); | 378 context_factory_->SetDisplayVSyncParameters(this, timebase, interval); |
| 379 vsync_manager_->UpdateVSyncParameters(timebase, interval); | 379 vsync_manager_->UpdateVSyncParameters(timebase, interval); |
| 380 } | 380 } |
| 381 | 381 |
| 382 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { | 382 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { |
| 383 // This function should only get called once. | 383 // This function should only get called once. |
| 384 DCHECK(!widget_valid_); | 384 DCHECK(!widget_valid_); |
| 385 widget_ = widget; | 385 widget_ = widget; |
| 386 widget_valid_ = true; | 386 widget_valid_ = true; |
| 387 if (output_surface_requested_) | 387 if (compositor_frame_sink_requested_) |
| 388 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); | 388 context_factory_->CreateCompositorFrameSink(weak_ptr_factory_.GetWeakPtr()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 gfx::AcceleratedWidget Compositor::ReleaseAcceleratedWidget() { | 391 gfx::AcceleratedWidget Compositor::ReleaseAcceleratedWidget() { |
| 392 DCHECK(!IsVisible()); | 392 DCHECK(!IsVisible()); |
| 393 host_->ReleaseOutputSurface(); | 393 host_->ReleaseCompositorFrameSink(); |
| 394 context_factory_->RemoveCompositor(this); | 394 context_factory_->RemoveCompositor(this); |
| 395 widget_valid_ = false; | 395 widget_valid_ = false; |
| 396 gfx::AcceleratedWidget widget = widget_; | 396 gfx::AcceleratedWidget widget = widget_; |
| 397 widget_ = gfx::kNullAcceleratedWidget; | 397 widget_ = gfx::kNullAcceleratedWidget; |
| 398 return widget; | 398 return widget; |
| 399 } | 399 } |
| 400 | 400 |
| 401 gfx::AcceleratedWidget Compositor::widget() const { | 401 gfx::AcceleratedWidget Compositor::widget() const { |
| 402 DCHECK(widget_valid_); | 402 DCHECK(widget_valid_); |
| 403 return widget_; | 403 return widget_; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 for (auto* child : layer->children()) | 461 for (auto* child : layer->children()) |
| 462 SendDamagedRectsRecursive(child); | 462 SendDamagedRectsRecursive(child); |
| 463 } | 463 } |
| 464 | 464 |
| 465 void Compositor::UpdateLayerTreeHost() { | 465 void Compositor::UpdateLayerTreeHost() { |
| 466 if (!root_layer()) | 466 if (!root_layer()) |
| 467 return; | 467 return; |
| 468 SendDamagedRectsRecursive(root_layer()); | 468 SendDamagedRectsRecursive(root_layer()); |
| 469 } | 469 } |
| 470 | 470 |
| 471 void Compositor::RequestNewOutputSurface() { | 471 void Compositor::RequestNewCompositorFrameSink() { |
| 472 DCHECK(!output_surface_requested_); | 472 DCHECK(!compositor_frame_sink_requested_); |
| 473 output_surface_requested_ = true; | 473 compositor_frame_sink_requested_ = true; |
| 474 if (widget_valid_) | 474 if (widget_valid_) |
| 475 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); | 475 context_factory_->CreateCompositorFrameSink(weak_ptr_factory_.GetWeakPtr()); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void Compositor::DidInitializeOutputSurface() { | 478 void Compositor::DidInitializeCompositorFrameSink() {} |
| 479 } | |
| 480 | 479 |
| 481 void Compositor::DidFailToInitializeOutputSurface() { | 480 void Compositor::DidFailToInitializeCompositorFrameSink() { |
| 482 // The OutputSurface should already be bound/initialized before being given to | 481 // The CompositorFrameSink should already be bound/initialized before being |
| 482 // given to |
| 483 // the Compositor. | 483 // the Compositor. |
| 484 NOTREACHED(); | 484 NOTREACHED(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void Compositor::DidCommit() { | 487 void Compositor::DidCommit() { |
| 488 DCHECK(!IsLocked()); | 488 DCHECK(!IsLocked()); |
| 489 FOR_EACH_OBSERVER(CompositorObserver, | 489 FOR_EACH_OBSERVER(CompositorObserver, |
| 490 observer_list_, | 490 observer_list_, |
| 491 OnCompositingDidCommit(this)); | 491 OnCompositingDidCommit(this)); |
| 492 } | 492 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 observer_list_, | 547 observer_list_, |
| 548 OnCompositingLockStateChanged(this)); | 548 OnCompositingLockStateChanged(this)); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void Compositor::CancelCompositorLock() { | 551 void Compositor::CancelCompositorLock() { |
| 552 if (compositor_lock_) | 552 if (compositor_lock_) |
| 553 compositor_lock_->CancelLock(); | 553 compositor_lock_->CancelLock(); |
| 554 } | 554 } |
| 555 | 555 |
| 556 } // namespace ui | 556 } // namespace ui |
| OLD | NEW |