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

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

Issue 666163006: Allow layers to signal that additional sequences are needed before surface destruction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 CancelLock(); 56 CancelLock();
57 } 57 }
58 58
59 void CompositorLock::CancelLock() { 59 void CompositorLock::CancelLock() {
60 if (!compositor_) 60 if (!compositor_)
61 return; 61 return;
62 compositor_->UnlockCompositor(); 62 compositor_->UnlockCompositor();
63 compositor_ = NULL; 63 compositor_ = NULL;
64 } 64 }
65 65
66 } // namespace ui
67
68 namespace {} // namespace
69
70 namespace ui {
71
72 class SatisfySwapPromise : public cc::SwapPromise {
73 public:
74 explicit SatisfySwapPromise(uint32_t id) : id_(id) {}
75
76 private:
77 void DidSwap(cc::CompositorFrameMetadata* metadata) override {
78 metadata->satisfies_sequences.push_back(id_);
79 }
80
81 void DidNotSwap(DidNotSwapReason reason) override {
82 // TODO(jbauman): Send to the SurfaceManager immediately.
83 DCHECK(false);
84 }
85 int64 TraceId() const override { return 0; }
86 uint32_t id_;
87 };
88
89 Compositor::Compositor(gfx::AcceleratedWidget widget, 66 Compositor::Compositor(gfx::AcceleratedWidget widget,
90 ui::ContextFactory* context_factory, 67 ui::ContextFactory* context_factory,
91 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 68 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
92 : context_factory_(context_factory), 69 : context_factory_(context_factory),
93 root_layer_(NULL), 70 root_layer_(NULL),
94 widget_(widget), 71 widget_(widget),
95 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), 72 surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()),
96 surface_sequence_number_(0),
97 compositor_thread_loop_(context_factory->GetCompositorMessageLoop()), 73 compositor_thread_loop_(context_factory->GetCompositorMessageLoop()),
98 task_runner_(task_runner), 74 task_runner_(task_runner),
99 vsync_manager_(new CompositorVSyncManager()), 75 vsync_manager_(new CompositorVSyncManager()),
100 device_scale_factor_(0.0f), 76 device_scale_factor_(0.0f),
101 last_started_frame_(0), 77 last_started_frame_(0),
102 last_ended_frame_(0), 78 last_ended_frame_(0),
103 disable_schedule_composite_(false), 79 disable_schedule_composite_(false),
104 compositor_lock_(NULL), 80 compositor_lock_(NULL),
105 defer_draw_scheduling_(false), 81 defer_draw_scheduling_(false),
106 waiting_on_compositing_end_(false), 82 waiting_on_compositing_end_(false),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 this, 150 this,
175 this, 151 this,
176 context_factory_->GetSharedBitmapManager(), 152 context_factory_->GetSharedBitmapManager(),
177 context_factory_->GetGpuMemoryBufferManager(), 153 context_factory_->GetGpuMemoryBufferManager(),
178 settings, 154 settings,
179 task_runner_); 155 task_runner_);
180 } 156 }
181 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor", 157 UMA_HISTOGRAM_TIMES("GPU.CreateBrowserCompositor",
182 base::TimeTicks::Now() - before_create); 158 base::TimeTicks::Now() - before_create);
183 host_->SetRootLayer(root_web_layer_); 159 host_->SetRootLayer(root_web_layer_);
160 host_->set_surface_id_namespace(surface_id_allocator_->id_namespace());
184 host_->SetLayerTreeHostClientReady(); 161 host_->SetLayerTreeHostClientReady();
185 } 162 }
186 163
187 Compositor::~Compositor() { 164 Compositor::~Compositor() {
188 TRACE_EVENT0("shutdown", "Compositor::destructor"); 165 TRACE_EVENT0("shutdown", "Compositor::destructor");
189 166
190 CancelCompositorLock(); 167 CancelCompositorLock();
191 DCHECK(!compositor_lock_); 168 DCHECK(!compositor_lock_);
192 169
193 if (root_layer_) 170 if (root_layer_)
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 406
430 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const { 407 const cc::LayerTreeDebugState& Compositor::GetLayerTreeDebugState() const {
431 return host_->debug_state(); 408 return host_->debug_state();
432 } 409 }
433 410
434 void Compositor::SetLayerTreeDebugState( 411 void Compositor::SetLayerTreeDebugState(
435 const cc::LayerTreeDebugState& debug_state) { 412 const cc::LayerTreeDebugState& debug_state) {
436 host_->SetDebugState(debug_state); 413 host_->SetDebugState(debug_state);
437 } 414 }
438 415
439 cc::SurfaceSequence Compositor::InsertSurfaceSequenceForNextFrame() {
440 cc::SurfaceSequence sequence;
441 sequence.id_namespace = surface_id_allocator_->id_namespace();
442 sequence.sequence = ++surface_sequence_number_;
443 scoped_ptr<cc::SwapPromise> promise(
444 new SatisfySwapPromise(surface_sequence_number_));
445 host_->QueueSwapPromise(promise.Pass());
446 return sequence;
447 }
448
449 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() { 416 scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
450 if (!compositor_lock_) { 417 if (!compositor_lock_) {
451 compositor_lock_ = new CompositorLock(this); 418 compositor_lock_ = new CompositorLock(this);
452 if (compositor_thread_loop_.get()) 419 if (compositor_thread_loop_.get())
453 host_->SetDeferCommits(true); 420 host_->SetDeferCommits(true);
454 FOR_EACH_OBSERVER(CompositorObserver, 421 FOR_EACH_OBSERVER(CompositorObserver,
455 observer_list_, 422 observer_list_,
456 OnCompositingLockStateChanged(this)); 423 OnCompositingLockStateChanged(this));
457 } 424 }
458 return compositor_lock_; 425 return compositor_lock_;
(...skipping 24 matching lines...) Expand all
483 // Call ScheduleDraw() instead of Draw() in order to allow other 450 // Call ScheduleDraw() instead of Draw() in order to allow other
484 // CompositorObservers to be notified before starting another 451 // CompositorObservers to be notified before starting another
485 // draw cycle. 452 // draw cycle.
486 ScheduleDraw(); 453 ScheduleDraw();
487 } 454 }
488 FOR_EACH_OBSERVER( 455 FOR_EACH_OBSERVER(
489 CompositorObserver, observer_list_, OnCompositingEnded(this)); 456 CompositorObserver, observer_list_, OnCompositingEnded(this));
490 } 457 }
491 458
492 } // namespace ui 459 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698