| 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 // Display properties are reset when the output surface is lost, so update it | 270 // Display properties are reset when the output surface is lost, so update it |
| 271 // to match the Compositor's. | 271 // to match the Compositor's. |
| 272 context_factory_->SetDisplayVisible(this, host_->IsVisible()); | 272 context_factory_->SetDisplayVisible(this, host_->IsVisible()); |
| 273 context_factory_->SetDisplayColorSpace(this, color_space_); | 273 context_factory_->SetDisplayColorSpace(this, color_space_); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void Compositor::ScheduleDraw() { | 276 void Compositor::ScheduleDraw() { |
| 277 host_->SetNeedsCommit(); | 277 host_->SetNeedsCommit(); |
| 278 } | 278 } |
| 279 | 279 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 base::TimeDelta interval) { | 381 base::TimeDelta interval) { |
| 382 context_factory_->SetDisplayVSyncParameters(this, timebase, interval); | 382 context_factory_->SetDisplayVSyncParameters(this, timebase, interval); |
| 383 vsync_manager_->UpdateVSyncParameters(timebase, interval); | 383 vsync_manager_->UpdateVSyncParameters(timebase, interval); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { | 386 void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { |
| 387 // This function should only get called once. | 387 // This function should only get called once. |
| 388 DCHECK(!widget_valid_); | 388 DCHECK(!widget_valid_); |
| 389 widget_ = widget; | 389 widget_ = widget; |
| 390 widget_valid_ = true; | 390 widget_valid_ = true; |
| 391 if (output_surface_requested_) | 391 if (compositor_frame_sink_requested_) |
| 392 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); | 392 context_factory_->CreateCompositorFrameSink(weak_ptr_factory_.GetWeakPtr()); |
| 393 } | 393 } |
| 394 | 394 |
| 395 gfx::AcceleratedWidget Compositor::ReleaseAcceleratedWidget() { | 395 gfx::AcceleratedWidget Compositor::ReleaseAcceleratedWidget() { |
| 396 DCHECK(!IsVisible()); | 396 DCHECK(!IsVisible()); |
| 397 host_->ReleaseOutputSurface(); | 397 host_->ReleaseCompositorFrameSink(); |
| 398 context_factory_->RemoveCompositor(this); | 398 context_factory_->RemoveCompositor(this); |
| 399 widget_valid_ = false; | 399 widget_valid_ = false; |
| 400 gfx::AcceleratedWidget widget = widget_; | 400 gfx::AcceleratedWidget widget = widget_; |
| 401 widget_ = gfx::kNullAcceleratedWidget; | 401 widget_ = gfx::kNullAcceleratedWidget; |
| 402 return widget; | 402 return widget; |
| 403 } | 403 } |
| 404 | 404 |
| 405 gfx::AcceleratedWidget Compositor::widget() const { | 405 gfx::AcceleratedWidget Compositor::widget() const { |
| 406 DCHECK(widget_valid_); | 406 DCHECK(widget_valid_); |
| 407 return widget_; | 407 return widget_; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 for (auto* child : layer->children()) | 465 for (auto* child : layer->children()) |
| 466 SendDamagedRectsRecursive(child); | 466 SendDamagedRectsRecursive(child); |
| 467 } | 467 } |
| 468 | 468 |
| 469 void Compositor::UpdateLayerTreeHost() { | 469 void Compositor::UpdateLayerTreeHost() { |
| 470 if (!root_layer()) | 470 if (!root_layer()) |
| 471 return; | 471 return; |
| 472 SendDamagedRectsRecursive(root_layer()); | 472 SendDamagedRectsRecursive(root_layer()); |
| 473 } | 473 } |
| 474 | 474 |
| 475 void Compositor::RequestNewOutputSurface() { | 475 void Compositor::RequestNewCompositorFrameSink() { |
| 476 DCHECK(!output_surface_requested_); | 476 DCHECK(!compositor_frame_sink_requested_); |
| 477 output_surface_requested_ = true; | 477 compositor_frame_sink_requested_ = true; |
| 478 if (widget_valid_) | 478 if (widget_valid_) |
| 479 context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); | 479 context_factory_->CreateCompositorFrameSink(weak_ptr_factory_.GetWeakPtr()); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void Compositor::DidInitializeOutputSurface() { | 482 void Compositor::DidInitializeCompositorFrameSink() {} |
| 483 } | |
| 484 | 483 |
| 485 void Compositor::DidFailToInitializeOutputSurface() { | 484 void Compositor::DidFailToInitializeCompositorFrameSink() { |
| 486 // The OutputSurface should already be bound/initialized before being given to | 485 // The CompositorFrameSink should already be bound/initialized before being |
| 486 // given to |
| 487 // the Compositor. | 487 // the Compositor. |
| 488 NOTREACHED(); | 488 NOTREACHED(); |
| 489 } | 489 } |
| 490 | 490 |
| 491 void Compositor::DidCommit() { | 491 void Compositor::DidCommit() { |
| 492 DCHECK(!IsLocked()); | 492 DCHECK(!IsLocked()); |
| 493 FOR_EACH_OBSERVER(CompositorObserver, | 493 FOR_EACH_OBSERVER(CompositorObserver, |
| 494 observer_list_, | 494 observer_list_, |
| 495 OnCompositingDidCommit(this)); | 495 OnCompositingDidCommit(this)); |
| 496 } | 496 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 observer_list_, | 551 observer_list_, |
| 552 OnCompositingLockStateChanged(this)); | 552 OnCompositingLockStateChanged(this)); |
| 553 } | 553 } |
| 554 | 554 |
| 555 void Compositor::CancelCompositorLock() { | 555 void Compositor::CancelCompositorLock() { |
| 556 if (compositor_lock_) | 556 if (compositor_lock_) |
| 557 compositor_lock_->CancelLock(); | 557 compositor_lock_->CancelLock(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 } // namespace ui | 560 } // namespace ui |
| OLD | NEW |