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 auto* host_frame_sink_manager = | 78 auto* host_frame_sink_manager = |
77 context_factory_private_->GetHostFrameSinkManager(); | 79 context_factory_private_->GetHostFrameSinkManager(); |
78 host_frame_sink_manager->RegisterFrameSinkId(frame_sink_id_, this); | 80 host_frame_sink_manager->RegisterFrameSinkId(frame_sink_id_, this); |
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 size_ = size_in_pixel; | 329 size_ = size_in_pixel; |
328 host_->SetViewportSize(size_in_pixel); | 330 host_->SetViewportSize(size_in_pixel); |
329 root_web_layer_->SetBounds(size_in_pixel); | 331 root_web_layer_->SetBounds(size_in_pixel); |
330 // TODO(fsamuel): Get rid of ContextFactoryPrivate. | 332 // TODO(fsamuel): Get rid of ContextFactoryPrivate. |
331 if (context_factory_private_) | 333 if (context_factory_private_) |
332 context_factory_private_->ResizeDisplay(this, size_in_pixel); | 334 context_factory_private_->ResizeDisplay(this, size_in_pixel); |
333 } | 335 } |
334 if (device_scale_factor_ != scale) { | 336 if (device_scale_factor_ != scale) { |
335 device_scale_factor_ = scale; | 337 device_scale_factor_ = scale; |
336 host_->SetDeviceScaleFactor(scale); | 338 host_->SetDeviceScaleFactor(scale); |
| 339 if (is_pixel_canvas()) |
| 340 host_->SetRecordingScaleFactor(scale); |
337 if (root_layer_) | 341 if (root_layer_) |
338 root_layer_->OnDeviceScaleFactorChanged(scale); | 342 root_layer_->OnDeviceScaleFactorChanged(scale); |
339 } | 343 } |
340 } | 344 } |
341 | 345 |
342 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { | 346 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { |
343 output_color_space_ = color_space; | 347 output_color_space_ = color_space; |
344 blending_color_space_ = output_color_space_.GetBlendingColorSpace(); | 348 blending_color_space_ = output_color_space_.GetBlendingColorSpace(); |
345 host_->SetRasterColorSpace(output_color_space_.GetRasterColorSpace()); | 349 host_->SetRasterColorSpace(output_color_space_.GetRasterColorSpace()); |
346 // Color space is reset when the output surface is lost, so this must also be | 350 // Color space is reset when the output surface is lost, so this must also be |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 void Compositor::TimeoutLocks() { | 630 void Compositor::TimeoutLocks() { |
627 // Make a copy, we're going to cause |active_locks_| to become | 631 // Make a copy, we're going to cause |active_locks_| to become |
628 // empty. | 632 // empty. |
629 std::vector<CompositorLock*> locks = active_locks_; | 633 std::vector<CompositorLock*> locks = active_locks_; |
630 for (auto* lock : locks) | 634 for (auto* lock : locks) |
631 lock->TimeoutLock(); | 635 lock->TimeoutLock(); |
632 DCHECK(active_locks_.empty()); | 636 DCHECK(active_locks_.empty()); |
633 } | 637 } |
634 | 638 |
635 } // namespace ui | 639 } // namespace ui |
OLD | NEW |