summaryrefslogtreecommitdiffstats
path: root/ui/compositor/compositor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/compositor/compositor.cc')
-rw-r--r--ui/compositor/compositor.cc127
1 files changed, 24 insertions, 103 deletions
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 1b6f342..19cf689 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -62,12 +62,6 @@ void CompositorLock::CancelLock() {
compositor_ = NULL;
}
-} // namespace ui
-
-namespace {} // namespace
-
-namespace ui {
-
Compositor::Compositor(gfx::AcceleratedWidget widget,
ui::ContextFactory* context_factory,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
@@ -78,16 +72,9 @@ Compositor::Compositor(gfx::AcceleratedWidget widget,
task_runner_(task_runner),
vsync_manager_(new CompositorVSyncManager()),
device_scale_factor_(0.0f),
- last_started_frame_(0),
- last_ended_frame_(0),
disable_schedule_composite_(false),
compositor_lock_(NULL),
- defer_draw_scheduling_(false),
- waiting_on_compositing_end_(false),
- draw_on_compositing_end_(false),
- swap_state_(SWAP_NONE),
- layer_animator_collection_(this),
- schedule_draw_factory_(this) {
+ layer_animator_collection_(this) {
root_web_layer_ = cc::Layer::Create();
CommandLine* command_line = CommandLine::ForCurrentProcess();
@@ -135,7 +122,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget,
settings.impl_side_painting = IsUIImplSidePaintingEnabled();
settings.use_zero_copy = IsUIZeroCopyEnabled();
- settings.single_thread_proxy_scheduler = false;
base::TimeTicks before_create = base::TimeTicks::Now();
if (compositor_thread_loop_.get()) {
@@ -176,14 +162,7 @@ Compositor::~Compositor() {
}
void Compositor::ScheduleDraw() {
- if (compositor_thread_loop_.get()) {
- host_->SetNeedsCommit();
- } else if (!defer_draw_scheduling_) {
- defer_draw_scheduling_ = true;
- task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr()));
- }
+ host_->SetNeedsCommit();
}
void Compositor::SetRootLayer(Layer* root_layer) {
@@ -204,44 +183,19 @@ void Compositor::SetHostHasTransparentBackground(
host_->set_has_transparent_background(host_has_transparent_background);
}
-void Compositor::Draw() {
- DCHECK(!compositor_thread_loop_.get());
-
- defer_draw_scheduling_ = false;
- if (waiting_on_compositing_end_) {
- draw_on_compositing_end_ = true;
- return;
- }
- if (!root_layer_)
- return;
-
- TRACE_EVENT_ASYNC_BEGIN0("ui", "Compositor::Draw", last_started_frame_ + 1);
-
- DCHECK_NE(swap_state_, SWAP_POSTED);
- swap_state_ = SWAP_NONE;
-
- waiting_on_compositing_end_ = true;
- last_started_frame_++;
- if (!IsLocked()) {
- // TODO(nduca): Temporary while compositor calls
- // compositeImmediately() directly.
- cc::BeginFrameArgs args =
- cc::BeginFrameArgs::Create(gfx::FrameTime::Now(),
- base::TimeTicks(),
- cc::BeginFrameArgs::DefaultInterval());
- BeginMainFrame(args);
- host_->Composite(args.frame_time);
- }
- if (swap_state_ == SWAP_NONE)
- NotifyEnd();
-}
-
void Compositor::ScheduleFullRedraw() {
+ // TODO(enne): Some callers (mac) call this function expecting that it
+ // will also commit. This should probably just redraw the screen
+ // from damage and not commit. ScheduleDraw/ScheduleRedraw need
+ // better names.
host_->SetNeedsRedraw();
+ host_->SetNeedsCommit();
}
void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) {
+ // TODO(enne): Make this not commit. See ScheduleFullRedraw.
host_->SetNeedsRedrawRect(damage_rect);
+ host_->SetNeedsCommit();
}
void Compositor::FinishAllRendering() {
@@ -353,45 +307,30 @@ void Compositor::DidCommit() {
}
void Compositor::DidCommitAndDrawFrame() {
- base::TimeTicks start_time = gfx::FrameTime::Now();
- FOR_EACH_OBSERVER(CompositorObserver,
- observer_list_,
- OnCompositingStarted(this, start_time));
}
void Compositor::DidCompleteSwapBuffers() {
+ // DidPostSwapBuffers is a SingleThreadProxy-only feature. Synthetically
+ // generate OnCompositingStarted messages for the threaded case so that
+ // OnCompositingStarted/OnCompositingEnded messages match.
if (compositor_thread_loop_.get()) {
- NotifyEnd();
- } else {
- DCHECK_EQ(swap_state_, SWAP_POSTED);
- NotifyEnd();
- swap_state_ = SWAP_COMPLETED;
+ base::TimeTicks start_time = gfx::FrameTime::Now();
+ FOR_EACH_OBSERVER(CompositorObserver,
+ observer_list_,
+ OnCompositingStarted(this, start_time));
}
-}
-
-void Compositor::ScheduleComposite() {
- if (!disable_schedule_composite_)
- ScheduleDraw();
-}
-
-void Compositor::ScheduleAnimation() {
- ScheduleComposite();
+ FOR_EACH_OBSERVER(
+ CompositorObserver, observer_list_, OnCompositingEnded(this));
}
void Compositor::DidPostSwapBuffers() {
- DCHECK(!compositor_thread_loop_.get());
- DCHECK_EQ(swap_state_, SWAP_NONE);
- swap_state_ = SWAP_POSTED;
+ base::TimeTicks start_time = gfx::FrameTime::Now();
+ FOR_EACH_OBSERVER(CompositorObserver,
+ observer_list_,
+ OnCompositingStarted(this, start_time));
}
void Compositor::DidAbortSwapBuffers() {
- if (!compositor_thread_loop_.get()) {
- if (swap_state_ == SWAP_POSTED) {
- NotifyEnd();
- swap_state_ = SWAP_COMPLETED;
- }
- }
-
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingAborted(this));
@@ -409,8 +348,7 @@ void Compositor::SetLayerTreeDebugState(
scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
if (!compositor_lock_) {
compositor_lock_ = new CompositorLock(this);
- if (compositor_thread_loop_.get())
- host_->SetDeferCommits(true);
+ host_->SetDeferCommits(true);
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingLockStateChanged(this));
@@ -421,8 +359,7 @@ scoped_refptr<CompositorLock> Compositor::GetCompositorLock() {
void Compositor::UnlockCompositor() {
DCHECK(compositor_lock_);
compositor_lock_ = NULL;
- if (compositor_thread_loop_.get())
- host_->SetDeferCommits(false);
+ host_->SetDeferCommits(false);
FOR_EACH_OBSERVER(CompositorObserver,
observer_list_,
OnCompositingLockStateChanged(this));
@@ -433,20 +370,4 @@ void Compositor::CancelCompositorLock() {
compositor_lock_->CancelLock();
}
-void Compositor::NotifyEnd() {
- last_ended_frame_++;
- TRACE_EVENT_ASYNC_END0("ui", "Compositor::Draw", last_ended_frame_);
- waiting_on_compositing_end_ = false;
- if (draw_on_compositing_end_) {
- draw_on_compositing_end_ = false;
-
- // Call ScheduleDraw() instead of Draw() in order to allow other
- // CompositorObservers to be notified before starting another
- // draw cycle.
- ScheduleDraw();
- }
- FOR_EACH_OBSERVER(
- CompositorObserver, observer_list_, OnCompositingEnded(this));
-}
-
} // namespace ui