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

Unified Diff: sky/shell/ui/animator.cc

Issue 936883002: Connect Sky and Ganesh in SkyShell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address review comments Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/shell/ui/animator.h ('k') | sky/shell/ui/engine.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/shell/ui/animator.cc
diff --git a/sky/shell/ui/animator.cc b/sky/shell/ui/animator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e7f299b97c99012a5404526bb52bdf3233ff049d
--- /dev/null
+++ b/sky/shell/ui/animator.cc
@@ -0,0 +1,59 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sky/shell/ui/animator.h"
+
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+
+namespace sky {
+namespace shell {
+
+Animator::Animator(const Engine::Config& config, Engine* engine)
+ : config_(config),
+ engine_(engine),
+ engine_requested_frame_(false),
+ frame_in_progress_(false),
+ weak_factory_(this) {
+}
+
+Animator::~Animator() {
+}
+
+void Animator::RequestFrame() {
+ if (engine_requested_frame_)
+ return;
+ engine_requested_frame_ = true;
+
+ if (!frame_in_progress_) {
+ frame_in_progress_ = true;
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&Animator::BeginFrame, weak_factory_.GetWeakPtr()));
+ }
+}
+
+void Animator::BeginFrame() {
+ DCHECK(frame_in_progress_);
+ DCHECK(engine_requested_frame_);
+ engine_requested_frame_ = false;
+
+ engine_->BeginFrame(base::TimeTicks::Now());
+ config_.gpu_task_runner->PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&GPUDelegate::Draw, config_.gpu_delegate, engine_->Paint()),
+ base::Bind(&Animator::OnFrameComplete, weak_factory_.GetWeakPtr()));
+}
+
+void Animator::OnFrameComplete() {
+ DCHECK(frame_in_progress_);
+ frame_in_progress_ = false;
+ if (engine_requested_frame_) {
+ frame_in_progress_ = true;
+ BeginFrame();
+ }
+}
+
+} // namespace shell
+} // namespace sky
« no previous file with comments | « sky/shell/ui/animator.h ('k') | sky/shell/ui/engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698