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 <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 CancelLock(); | 56 CancelLock(); |
57 } | 57 } |
58 | 58 |
59 void CompositorLock::CancelLock() { | 59 void CompositorLock::CancelLock() { |
60 if (!compositor_) | 60 if (!compositor_) |
61 return; | 61 return; |
62 compositor_->UnlockCompositor(); | 62 compositor_->UnlockCompositor(); |
63 compositor_ = NULL; | 63 compositor_ = NULL; |
64 } | 64 } |
65 | 65 |
66 Compositor::Compositor(gfx::AcceleratedWidget widget, | 66 Compositor::Compositor(ui::ContextFactory* context_factory, |
67 ui::ContextFactory* context_factory, | |
68 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 67 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
69 : context_factory_(context_factory), | 68 : context_factory_(context_factory), |
70 root_layer_(NULL), | 69 root_layer_(NULL), |
71 widget_(widget), | 70 widget_(gfx::kNullAcceleratedWidget), |
72 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), | 71 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), |
73 task_runner_(task_runner), | 72 task_runner_(task_runner), |
74 vsync_manager_(new CompositorVSyncManager()), | 73 vsync_manager_(new CompositorVSyncManager()), |
75 device_scale_factor_(0.0f), | 74 device_scale_factor_(0.0f), |
76 last_started_frame_(0), | 75 last_started_frame_(0), |
77 last_ended_frame_(0), | 76 last_ended_frame_(0), |
78 locks_will_time_out_(true), | 77 locks_will_time_out_(true), |
79 compositor_lock_(NULL), | 78 compositor_lock_(NULL), |
80 layer_animator_collection_(this), | 79 layer_animator_collection_(this), |
81 weak_ptr_factory_(this) { | 80 weak_ptr_factory_(this) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 params.gpu_memory_buffer_manager = | 166 params.gpu_memory_buffer_manager = |
168 context_factory_->GetGpuMemoryBufferManager(); | 167 context_factory_->GetGpuMemoryBufferManager(); |
169 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); | 168 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); |
170 params.settings = &settings; | 169 params.settings = &settings; |
171 params.main_task_runner = task_runner_; | 170 params.main_task_runner = task_runner_; |
172 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); | 171 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, ¶ms); |
173 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", | 172 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", |
174 base::TimeTicks::Now() - before_create); | 173 base::TimeTicks::Now() - before_create); |
175 host_->SetRootLayer(root_web_layer_); | 174 host_->SetRootLayer(root_web_layer_); |
176 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); | 175 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); |
| 176 } |
| 177 |
| 178 void Compositor::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) { |
| 179 // This function should only get called once. |
| 180 DCHECK_EQ(gfx::kNullAcceleratedWidget, widget_); |
| 181 widget_ = widget; |
177 host_->SetLayerTreeHostClientReady(); | 182 host_->SetLayerTreeHostClientReady(); |
178 } | 183 } |
179 | 184 |
180 Compositor::~Compositor() { | 185 Compositor::~Compositor() { |
181 TRACE_EVENT0("shutdown", "Compositor::destructor"); | 186 TRACE_EVENT0("shutdown", "Compositor::destructor"); |
182 | 187 |
183 CancelCompositorLock(); | 188 CancelCompositorLock(); |
184 DCHECK(!compositor_lock_); | 189 DCHECK(!compositor_lock_); |
185 | 190 |
186 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, | 191 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 observer_list_, | 462 observer_list_, |
458 OnCompositingLockStateChanged(this)); | 463 OnCompositingLockStateChanged(this)); |
459 } | 464 } |
460 | 465 |
461 void Compositor::CancelCompositorLock() { | 466 void Compositor::CancelCompositorLock() { |
462 if (compositor_lock_) | 467 if (compositor_lock_) |
463 compositor_lock_->CancelLock(); | 468 compositor_lock_->CancelLock(); |
464 } | 469 } |
465 | 470 |
466 } // namespace ui | 471 } // namespace ui |
OLD | NEW |