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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "ui/gfx/switches.h" | 53 #include "ui/gfx/switches.h" |
54 #include "ui/gl/gl_switches.h" | 54 #include "ui/gl/gl_switches.h" |
55 | 55 |
56 namespace ui { | 56 namespace ui { |
57 | 57 |
58 Compositor::Compositor(const viz::FrameSinkId& frame_sink_id, | 58 Compositor::Compositor(const viz::FrameSinkId& frame_sink_id, |
59 ui::ContextFactory* context_factory, | 59 ui::ContextFactory* context_factory, |
60 ui::ContextFactoryPrivate* context_factory_private, | 60 ui::ContextFactoryPrivate* context_factory_private, |
61 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 61 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
62 bool enable_surface_synchronization, | 62 bool enable_surface_synchronization, |
| 63 bool enable_pixel_canvas, |
63 bool external_begin_frames_enabled) | 64 bool external_begin_frames_enabled) |
64 : context_factory_(context_factory), | 65 : context_factory_(context_factory), |
65 context_factory_private_(context_factory_private), | 66 context_factory_private_(context_factory_private), |
66 frame_sink_id_(frame_sink_id), | 67 frame_sink_id_(frame_sink_id), |
67 task_runner_(task_runner), | 68 task_runner_(task_runner), |
68 vsync_manager_(new CompositorVSyncManager()), | 69 vsync_manager_(new CompositorVSyncManager()), |
69 external_begin_frames_enabled_(external_begin_frames_enabled), | 70 external_begin_frames_enabled_(external_begin_frames_enabled), |
70 layer_animator_collection_(this), | 71 layer_animator_collection_(this), |
71 scheduled_timeout_(base::TimeTicks()), | 72 scheduled_timeout_(base::TimeTicks()), |
72 allow_locks_to_extend_timeout_(false), | 73 allow_locks_to_extend_timeout_(false), |
| 74 is_pixel_canvas_(enable_pixel_canvas), |
73 weak_ptr_factory_(this), | 75 weak_ptr_factory_(this), |
74 lock_timeout_weak_ptr_factory_(this) { | 76 lock_timeout_weak_ptr_factory_(this) { |
75 if (context_factory_private) { | 77 if (context_factory_private) { |
76 context_factory_private->GetFrameSinkManager() | 78 context_factory_private->GetFrameSinkManager() |
77 ->surface_manager() | 79 ->surface_manager() |
78 ->RegisterFrameSinkId(frame_sink_id_); | 80 ->RegisterFrameSinkId(frame_sink_id_); |
79 } | 81 } |
80 root_web_layer_ = cc::Layer::Create(); | 82 root_web_layer_ = cc::Layer::Create(); |
81 | 83 |
82 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 84 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 size_ = size_in_pixel; | 331 size_ = size_in_pixel; |
330 host_->SetViewportSize(size_in_pixel); | 332 host_->SetViewportSize(size_in_pixel); |
331 root_web_layer_->SetBounds(size_in_pixel); | 333 root_web_layer_->SetBounds(size_in_pixel); |
332 // TODO(fsamuel): Get rid of ContextFactoryPrivate. | 334 // TODO(fsamuel): Get rid of ContextFactoryPrivate. |
333 if (context_factory_private_) | 335 if (context_factory_private_) |
334 context_factory_private_->ResizeDisplay(this, size_in_pixel); | 336 context_factory_private_->ResizeDisplay(this, size_in_pixel); |
335 } | 337 } |
336 if (device_scale_factor_ != scale) { | 338 if (device_scale_factor_ != scale) { |
337 device_scale_factor_ = scale; | 339 device_scale_factor_ = scale; |
338 host_->SetDeviceScaleFactor(scale); | 340 host_->SetDeviceScaleFactor(scale); |
| 341 if (is_pixel_canvas()) |
| 342 host_->SetRecordingScaleFactor(scale); |
339 if (root_layer_) | 343 if (root_layer_) |
340 root_layer_->OnDeviceScaleFactorChanged(scale); | 344 root_layer_->OnDeviceScaleFactorChanged(scale); |
341 } | 345 } |
342 } | 346 } |
343 | 347 |
344 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { | 348 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { |
345 blending_color_space_ = color_space; | 349 blending_color_space_ = color_space; |
346 output_color_space_ = blending_color_space_; | 350 output_color_space_ = blending_color_space_; |
347 if (base::FeatureList::IsEnabled(features::kHighDynamicRange)) { | 351 if (base::FeatureList::IsEnabled(features::kHighDynamicRange)) { |
348 blending_color_space_ = gfx::ColorSpace::CreateExtendedSRGB(); | 352 blending_color_space_ = gfx::ColorSpace::CreateExtendedSRGB(); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 void Compositor::TimeoutLocks() { | 631 void Compositor::TimeoutLocks() { |
628 // Make a copy, we're going to cause |active_locks_| to become | 632 // Make a copy, we're going to cause |active_locks_| to become |
629 // empty. | 633 // empty. |
630 std::vector<CompositorLock*> locks = active_locks_; | 634 std::vector<CompositorLock*> locks = active_locks_; |
631 for (auto* lock : locks) | 635 for (auto* lock : locks) |
632 lock->TimeoutLock(); | 636 lock->TimeoutLock(); |
633 DCHECK(active_locks_.empty()); | 637 DCHECK(active_locks_.empty()); |
634 } | 638 } |
635 | 639 |
636 } // namespace ui | 640 } // namespace ui |
OLD | NEW |