Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: ui/compositor/compositor.cc

Issue 1533643003: CC Animations: Port UI Browser Compositor to use compositor animation timelines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eventobserver
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
17 #include "cc/animation/animation_host.h"
18 #include "cc/animation/animation_id_provider.h"
19 #include "cc/animation/animation_timeline.h"
17 #include "cc/base/switches.h" 20 #include "cc/base/switches.h"
18 #include "cc/input/input_handler.h" 21 #include "cc/input/input_handler.h"
19 #include "cc/layers/layer.h" 22 #include "cc/layers/layer.h"
20 #include "cc/output/begin_frame_args.h" 23 #include "cc/output/begin_frame_args.h"
21 #include "cc/output/context_provider.h" 24 #include "cc/output/context_provider.h"
22 #include "cc/output/latency_info_swap_promise.h" 25 #include "cc/output/latency_info_swap_promise.h"
23 #include "cc/scheduler/begin_frame_source.h" 26 #include "cc/scheduler/begin_frame_source.h"
24 #include "cc/surfaces/surface_id_allocator.h" 27 #include "cc/surfaces/surface_id_allocator.h"
25 #include "cc/trees/layer_tree_host.h" 28 #include "cc/trees/layer_tree_host.h"
26 #include "third_party/skia/include/core/SkBitmap.h" 29 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 params.client = this; 185 params.client = this;
183 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager(); 186 params.shared_bitmap_manager = context_factory_->GetSharedBitmapManager();
184 params.gpu_memory_buffer_manager = 187 params.gpu_memory_buffer_manager =
185 context_factory_->GetGpuMemoryBufferManager(); 188 context_factory_->GetGpuMemoryBufferManager();
186 params.task_graph_runner = context_factory_->GetTaskGraphRunner(); 189 params.task_graph_runner = context_factory_->GetTaskGraphRunner();
187 params.settings = &settings; 190 params.settings = &settings;
188 params.main_task_runner = task_runner_; 191 params.main_task_runner = task_runner_;
189 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params); 192 host_ = cc::LayerTreeHost::CreateSingleThreaded(this, &params);
190 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", 193 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor",
191 base::TimeTicks::Now() - before_create); 194 base::TimeTicks::Now() - before_create);
195
196 if (settings.use_compositor_animation_timelines) {
197 animation_timeline_ = cc::AnimationTimeline::Create(
198 cc::AnimationIdProvider::NextTimelineId());
199 host_->animation_host()->AddAnimationTimeline(animation_timeline_.get());
200 }
192 host_->SetRootLayer(root_web_layer_); 201 host_->SetRootLayer(root_web_layer_);
193 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); 202 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace());
194 host_->SetVisible(true); 203 host_->SetVisible(true);
195 } 204 }
196 205
197 Compositor::~Compositor() { 206 Compositor::~Compositor() {
198 TRACE_EVENT0("shutdown", "Compositor::destructor"); 207 TRACE_EVENT0("shutdown", "Compositor::destructor");
199 208
200 CancelCompositorLock(); 209 CancelCompositorLock();
201 DCHECK(!compositor_lock_); 210 DCHECK(!compositor_lock_);
202 211
203 FOR_EACH_OBSERVER(CompositorObserver, observer_list_, 212 FOR_EACH_OBSERVER(CompositorObserver, observer_list_,
204 OnCompositingShuttingDown(this)); 213 OnCompositingShuttingDown(this));
205 214
206 FOR_EACH_OBSERVER(CompositorAnimationObserver, animation_observer_list_, 215 FOR_EACH_OBSERVER(CompositorAnimationObserver, animation_observer_list_,
207 OnCompositingShuttingDown(this)); 216 OnCompositingShuttingDown(this));
208 217
209 if (root_layer_) 218 if (root_layer_)
210 root_layer_->ResetCompositor(); 219 root_layer_->ResetCompositor();
211 220
221 if (animation_timeline_)
222 host_->animation_host()->RemoveAnimationTimeline(animation_timeline_.get());
223
212 // Stop all outstanding draws before telling the ContextFactory to tear 224 // Stop all outstanding draws before telling the ContextFactory to tear
213 // down any contexts that the |host_| may rely upon. 225 // down any contexts that the |host_| may rely upon.
214 host_.reset(); 226 host_.reset();
215 227
216 context_factory_->RemoveCompositor(this); 228 context_factory_->RemoveCompositor(this);
217 } 229 }
218 230
219 void Compositor::SetOutputSurface( 231 void Compositor::SetOutputSurface(
220 scoped_ptr<cc::OutputSurface> output_surface) { 232 scoped_ptr<cc::OutputSurface> output_surface) {
221 output_surface_requested_ = false; 233 output_surface_requested_ = false;
222 host_->SetOutputSurface(output_surface.Pass()); 234 host_->SetOutputSurface(output_surface.Pass());
223 } 235 }
224 236
225 void Compositor::ScheduleDraw() { 237 void Compositor::ScheduleDraw() {
226 host_->SetNeedsCommit(); 238 host_->SetNeedsCommit();
227 } 239 }
228 240
229 void Compositor::SetRootLayer(Layer* root_layer) { 241 void Compositor::SetRootLayer(Layer* root_layer) {
230 if (root_layer_ == root_layer) 242 if (root_layer_ == root_layer)
231 return; 243 return;
232 if (root_layer_) 244 if (root_layer_)
233 root_layer_->ResetCompositor(); 245 root_layer_->ResetCompositor();
234 root_layer_ = root_layer; 246 root_layer_ = root_layer;
235 root_web_layer_->RemoveAllChildren(); 247 root_web_layer_->RemoveAllChildren();
236 if (root_layer_) 248 if (root_layer_)
237 root_layer_->SetCompositor(this, root_web_layer_); 249 root_layer_->SetCompositor(this, root_web_layer_);
238 } 250 }
239 251
252 cc::AnimationTimeline* Compositor::GetAnimationTimeline() const {
253 return animation_timeline_.get();
254 }
255
240 void Compositor::SetHostHasTransparentBackground( 256 void Compositor::SetHostHasTransparentBackground(
241 bool host_has_transparent_background) { 257 bool host_has_transparent_background) {
242 host_->set_has_transparent_background(host_has_transparent_background); 258 host_->set_has_transparent_background(host_has_transparent_background);
243 } 259 }
244 260
245 void Compositor::ScheduleFullRedraw() { 261 void Compositor::ScheduleFullRedraw() {
246 // TODO(enne): Some callers (mac) call this function expecting that it 262 // TODO(enne): Some callers (mac) call this function expecting that it
247 // will also commit. This should probably just redraw the screen 263 // will also commit. This should probably just redraw the screen
248 // from damage and not commit. ScheduleDraw/ScheduleRedraw need 264 // from damage and not commit. ScheduleDraw/ScheduleRedraw need
249 // better names. 265 // better names.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 observer_list_, 518 observer_list_,
503 OnCompositingLockStateChanged(this)); 519 OnCompositingLockStateChanged(this));
504 } 520 }
505 521
506 void Compositor::CancelCompositorLock() { 522 void Compositor::CancelCompositorLock() {
507 if (compositor_lock_) 523 if (compositor_lock_)
508 compositor_lock_->CancelLock(); 524 compositor_lock_->CancelLock();
509 } 525 }
510 526
511 } // namespace ui 527 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698