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

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

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

Powered by Google App Engine
This is Rietveld 408576698