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

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

Issue 2877483003: Implements core logic for Pixel Canvas (Closed)
Patch Set: Resolving comments and sync with ToT Created 3 years, 4 months 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <deque> 10 #include <deque>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "ui/gfx/icc_profile.h" 51 #include "ui/gfx/icc_profile.h"
52 #include "ui/gfx/switches.h" 52 #include "ui/gfx/switches.h"
53 #include "ui/gl/gl_switches.h" 53 #include "ui/gl/gl_switches.h"
54 54
55 namespace ui { 55 namespace ui {
56 56
57 Compositor::Compositor(const viz::FrameSinkId& frame_sink_id, 57 Compositor::Compositor(const viz::FrameSinkId& frame_sink_id,
58 ui::ContextFactory* context_factory, 58 ui::ContextFactory* context_factory,
59 ui::ContextFactoryPrivate* context_factory_private, 59 ui::ContextFactoryPrivate* context_factory_private,
60 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 60 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
61 bool enable_surface_synchronization) 61 bool enable_surface_synchronization,
62 bool enable_pixel_canvas)
62 : context_factory_(context_factory), 63 : context_factory_(context_factory),
63 context_factory_private_(context_factory_private), 64 context_factory_private_(context_factory_private),
64 frame_sink_id_(frame_sink_id), 65 frame_sink_id_(frame_sink_id),
65 task_runner_(task_runner), 66 task_runner_(task_runner),
66 vsync_manager_(new CompositorVSyncManager()), 67 vsync_manager_(new CompositorVSyncManager()),
67 layer_animator_collection_(this), 68 layer_animator_collection_(this),
68 scheduled_timeout_(base::TimeTicks()), 69 scheduled_timeout_(base::TimeTicks()),
69 allow_locks_to_extend_timeout_(false), 70 allow_locks_to_extend_timeout_(false),
71 is_pixel_canvas_(enable_pixel_canvas),
70 weak_ptr_factory_(this), 72 weak_ptr_factory_(this),
71 lock_timeout_weak_ptr_factory_(this) { 73 lock_timeout_weak_ptr_factory_(this) {
72 if (context_factory_private) { 74 if (context_factory_private) {
73 context_factory_private->GetFrameSinkManager() 75 context_factory_private->GetFrameSinkManager()
74 ->surface_manager() 76 ->surface_manager()
75 ->RegisterFrameSinkId(frame_sink_id_); 77 ->RegisterFrameSinkId(frame_sink_id_);
76 } 78 }
77 root_web_layer_ = cc::Layer::Create(); 79 root_web_layer_ = cc::Layer::Create();
78 80
79 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 81 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 size_ = size_in_pixel; 325 size_ = size_in_pixel;
324 host_->SetViewportSize(size_in_pixel); 326 host_->SetViewportSize(size_in_pixel);
325 root_web_layer_->SetBounds(size_in_pixel); 327 root_web_layer_->SetBounds(size_in_pixel);
326 // TODO(fsamuel): Get rid of ContextFactoryPrivate. 328 // TODO(fsamuel): Get rid of ContextFactoryPrivate.
327 if (context_factory_private_) 329 if (context_factory_private_)
328 context_factory_private_->ResizeDisplay(this, size_in_pixel); 330 context_factory_private_->ResizeDisplay(this, size_in_pixel);
329 } 331 }
330 if (device_scale_factor_ != scale) { 332 if (device_scale_factor_ != scale) {
331 device_scale_factor_ = scale; 333 device_scale_factor_ = scale;
332 host_->SetDeviceScaleFactor(scale); 334 host_->SetDeviceScaleFactor(scale);
335 if (is_pixel_canvas())
336 host_->SetRecordingScaleFactor(scale);
333 if (root_layer_) 337 if (root_layer_)
334 root_layer_->OnDeviceScaleFactorChanged(scale); 338 root_layer_->OnDeviceScaleFactorChanged(scale);
335 } 339 }
336 } 340 }
337 341
338 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) { 342 void Compositor::SetDisplayColorSpace(const gfx::ColorSpace& color_space) {
339 blending_color_space_ = color_space; 343 blending_color_space_ = color_space;
340 output_color_space_ = blending_color_space_; 344 output_color_space_ = blending_color_space_;
341 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR)) { 345 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR)) {
342 blending_color_space_ = gfx::ColorSpace::CreateExtendedSRGB(); 346 blending_color_space_ = gfx::ColorSpace::CreateExtendedSRGB();
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 void Compositor::TimeoutLocks() { 596 void Compositor::TimeoutLocks() {
593 // Make a copy, we're going to cause |active_locks_| to become 597 // Make a copy, we're going to cause |active_locks_| to become
594 // empty. 598 // empty.
595 std::vector<CompositorLock*> locks = active_locks_; 599 std::vector<CompositorLock*> locks = active_locks_;
596 for (auto* lock : locks) 600 for (auto* lock : locks)
597 lock->TimeoutLock(); 601 lock->TimeoutLock();
598 DCHECK(active_locks_.empty()); 602 DCHECK(active_locks_.empty());
599 } 603 }
600 604
601 } // namespace ui 605 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698