| 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 context_factory->GetSurfaceManager()->RegisterSurfaceClientId( |
| 96 surface_id_allocator_->client_id()); |
| 93 root_web_layer_ = cc::Layer::Create(); | 97 root_web_layer_ = cc::Layer::Create(); |
| 94 | 98 |
| 95 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 99 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 96 | 100 |
| 97 cc::LayerTreeSettings settings; | 101 cc::LayerTreeSettings settings; |
| 98 | 102 |
| 99 // This will ensure PictureLayers always can have LCD text, to match the | 103 // This will ensure PictureLayers always can have LCD text, to match the |
| 100 // previous behaviour with ContentLayers, where LCD-not-allowed notifications | 104 // previous behaviour with ContentLayers, where LCD-not-allowed notifications |
| 101 // were ignored. | 105 // were ignored. |
| 102 settings.layers_always_allowed_lcd_text = true; | 106 settings.layers_always_allowed_lcd_text = true; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 root_layer_->ResetCompositor(); | 235 root_layer_->ResetCompositor(); |
| 232 | 236 |
| 233 if (animation_timeline_) | 237 if (animation_timeline_) |
| 234 host_->animation_host()->RemoveAnimationTimeline(animation_timeline_.get()); | 238 host_->animation_host()->RemoveAnimationTimeline(animation_timeline_.get()); |
| 235 | 239 |
| 236 // Stop all outstanding draws before telling the ContextFactory to tear | 240 // Stop all outstanding draws before telling the ContextFactory to tear |
| 237 // down any contexts that the |host_| may rely upon. | 241 // down any contexts that the |host_| may rely upon. |
| 238 host_.reset(); | 242 host_.reset(); |
| 239 | 243 |
| 240 context_factory_->RemoveCompositor(this); | 244 context_factory_->RemoveCompositor(this); |
| 245 context_factory_->GetSurfaceManager()->InvalidateSurfaceClientId( |
| 246 surface_id_allocator_->client_id()); |
| 241 } | 247 } |
| 242 | 248 |
| 243 void Compositor::SetOutputSurface( | 249 void Compositor::SetOutputSurface( |
| 244 std::unique_ptr<cc::OutputSurface> output_surface) { | 250 std::unique_ptr<cc::OutputSurface> output_surface) { |
| 245 output_surface_requested_ = false; | 251 output_surface_requested_ = false; |
| 246 host_->SetOutputSurface(std::move(output_surface)); | 252 host_->SetOutputSurface(std::move(output_surface)); |
| 247 } | 253 } |
| 248 | 254 |
| 249 void Compositor::ScheduleDraw() { | 255 void Compositor::ScheduleDraw() { |
| 250 host_->SetNeedsCommit(); | 256 host_->SetNeedsCommit(); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 observer_list_, | 506 observer_list_, |
| 501 OnCompositingLockStateChanged(this)); | 507 OnCompositingLockStateChanged(this)); |
| 502 } | 508 } |
| 503 | 509 |
| 504 void Compositor::CancelCompositorLock() { | 510 void Compositor::CancelCompositorLock() { |
| 505 if (compositor_lock_) | 511 if (compositor_lock_) |
| 506 compositor_lock_->CancelLock(); | 512 compositor_lock_->CancelLock(); |
| 507 } | 513 } |
| 508 | 514 |
| 509 } // namespace ui | 515 } // namespace ui |
| OLD | NEW |