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 11 matching lines...) Expand all Loading... |
22 #include "cc/animation/animation_id_provider.h" | 22 #include "cc/animation/animation_id_provider.h" |
23 #include "cc/animation/animation_timeline.h" | 23 #include "cc/animation/animation_timeline.h" |
24 #include "cc/base/switches.h" | 24 #include "cc/base/switches.h" |
25 #include "cc/input/input_handler.h" | 25 #include "cc/input/input_handler.h" |
26 #include "cc/layers/layer.h" | 26 #include "cc/layers/layer.h" |
27 #include "cc/output/begin_frame_args.h" | 27 #include "cc/output/begin_frame_args.h" |
28 #include "cc/output/context_provider.h" | 28 #include "cc/output/context_provider.h" |
29 #include "cc/output/latency_info_swap_promise.h" | 29 #include "cc/output/latency_info_swap_promise.h" |
30 #include "cc/scheduler/begin_frame_source.h" | 30 #include "cc/scheduler/begin_frame_source.h" |
31 #include "cc/surfaces/surface_id_allocator.h" | 31 #include "cc/surfaces/surface_id_allocator.h" |
| 32 #include "cc/surfaces/surface_manager.h" |
32 #include "cc/trees/layer_tree_host.h" | 33 #include "cc/trees/layer_tree_host.h" |
33 #include "third_party/skia/include/core/SkBitmap.h" | 34 #include "third_party/skia/include/core/SkBitmap.h" |
34 #include "ui/compositor/compositor_observer.h" | 35 #include "ui/compositor/compositor_observer.h" |
35 #include "ui/compositor/compositor_switches.h" | 36 #include "ui/compositor/compositor_switches.h" |
36 #include "ui/compositor/compositor_vsync_manager.h" | 37 #include "ui/compositor/compositor_vsync_manager.h" |
37 #include "ui/compositor/dip_util.h" | 38 #include "ui/compositor/dip_util.h" |
38 #include "ui/compositor/layer.h" | 39 #include "ui/compositor/layer.h" |
39 #include "ui/compositor/layer_animator_collection.h" | 40 #include "ui/compositor/layer_animator_collection.h" |
40 #include "ui/gl/gl_context.h" | 41 #include "ui/gl/gl_context.h" |
41 #include "ui/gl/gl_switches.h" | 42 #include "ui/gl/gl_switches.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 compositor_ = NULL; | 76 compositor_ = NULL; |
76 } | 77 } |
77 | 78 |
78 Compositor::Compositor(ui::ContextFactory* context_factory, | 79 Compositor::Compositor(ui::ContextFactory* context_factory, |
79 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 80 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
80 : context_factory_(context_factory), | 81 : context_factory_(context_factory), |
81 root_layer_(NULL), | 82 root_layer_(NULL), |
82 widget_(gfx::kNullAcceleratedWidget), | 83 widget_(gfx::kNullAcceleratedWidget), |
83 widget_valid_(false), | 84 widget_valid_(false), |
84 output_surface_requested_(false), | 85 output_surface_requested_(false), |
85 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), | 86 surface_id_allocator_(new cc::SurfaceIdAllocator( |
| 87 context_factory->AllocateSurfaceClientId())), |
86 task_runner_(task_runner), | 88 task_runner_(task_runner), |
87 vsync_manager_(new CompositorVSyncManager()), | 89 vsync_manager_(new CompositorVSyncManager()), |
88 device_scale_factor_(0.0f), | 90 device_scale_factor_(0.0f), |
89 locks_will_time_out_(true), | 91 locks_will_time_out_(true), |
90 compositor_lock_(NULL), | 92 compositor_lock_(NULL), |
91 layer_animator_collection_(this), | 93 layer_animator_collection_(this), |
92 weak_ptr_factory_(this) { | 94 weak_ptr_factory_(this) { |
| 95 if (context_factory->GetSurfaceManager()) { |
| 96 context_factory->GetSurfaceManager()->RegisterSurfaceClientId( |
| 97 surface_id_allocator_->client_id()); |
| 98 } |
93 root_web_layer_ = cc::Layer::Create(); | 99 root_web_layer_ = cc::Layer::Create(); |
94 | 100 |
95 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 101 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
96 | 102 |
97 cc::LayerTreeSettings settings; | 103 cc::LayerTreeSettings settings; |
98 | 104 |
99 // This will ensure PictureLayers always can have LCD text, to match the | 105 // This will ensure PictureLayers always can have LCD text, to match the |
100 // previous behaviour with ContentLayers, where LCD-not-allowed notifications | 106 // previous behaviour with ContentLayers, where LCD-not-allowed notifications |
101 // were ignored. | 107 // were ignored. |
102 settings.layers_always_allowed_lcd_text = true; | 108 settings.layers_always_allowed_lcd_text = true; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 root_layer_->ResetCompositor(); | 237 root_layer_->ResetCompositor(); |
232 | 238 |
233 if (animation_timeline_) | 239 if (animation_timeline_) |
234 host_->animation_host()->RemoveAnimationTimeline(animation_timeline_.get()); | 240 host_->animation_host()->RemoveAnimationTimeline(animation_timeline_.get()); |
235 | 241 |
236 // Stop all outstanding draws before telling the ContextFactory to tear | 242 // Stop all outstanding draws before telling the ContextFactory to tear |
237 // down any contexts that the |host_| may rely upon. | 243 // down any contexts that the |host_| may rely upon. |
238 host_.reset(); | 244 host_.reset(); |
239 | 245 |
240 context_factory_->RemoveCompositor(this); | 246 context_factory_->RemoveCompositor(this); |
| 247 if (context_factory_->GetSurfaceManager()) { |
| 248 context_factory_->GetSurfaceManager()->InvalidateSurfaceClientId( |
| 249 surface_id_allocator_->client_id()); |
| 250 } |
241 } | 251 } |
242 | 252 |
243 void Compositor::SetOutputSurface( | 253 void Compositor::SetOutputSurface( |
244 std::unique_ptr<cc::OutputSurface> output_surface) { | 254 std::unique_ptr<cc::OutputSurface> output_surface) { |
245 output_surface_requested_ = false; | 255 output_surface_requested_ = false; |
246 host_->SetOutputSurface(std::move(output_surface)); | 256 host_->SetOutputSurface(std::move(output_surface)); |
247 } | 257 } |
248 | 258 |
249 void Compositor::ScheduleDraw() { | 259 void Compositor::ScheduleDraw() { |
250 host_->SetNeedsCommit(); | 260 host_->SetNeedsCommit(); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 observer_list_, | 510 observer_list_, |
501 OnCompositingLockStateChanged(this)); | 511 OnCompositingLockStateChanged(this)); |
502 } | 512 } |
503 | 513 |
504 void Compositor::CancelCompositorLock() { | 514 void Compositor::CancelCompositorLock() { |
505 if (compositor_lock_) | 515 if (compositor_lock_) |
506 compositor_lock_->CancelLock(); | 516 compositor_lock_->CancelLock(); |
507 } | 517 } |
508 | 518 |
509 } // namespace ui | 519 } // namespace ui |
OLD | NEW |