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

Side by Side 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: sort includes 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sky/shell/ui/animator.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
9
10 namespace sky {
11 namespace shell {
12
13 Animator::Animator(const Engine::Config& config, Engine* engine)
14 : config_(config),
15 engine_(engine),
16 frame_requested_(false),
17 frame_pending_(false),
18 weak_factory_(this) {
19 }
20
21 Animator::~Animator() {
22 }
23
24 void Animator::RequestFrame() {
25 if (frame_requested_)
26 return;
27 frame_requested_ = true;
28
29 if (!frame_pending_) {
30 frame_pending_ = true;
31 base::MessageLoop::current()->PostTask(
32 FROM_HERE,
33 base::Bind(&Animator::BeginFrame, weak_factory_.GetWeakPtr()));
34 }
35 }
36
37 void Animator::BeginFrame() {
38 DCHECK(frame_pending_);
39 DCHECK(frame_requested_);
40 frame_requested_ = false;
41
42 engine_->BeginFrame(base::TimeTicks::Now());
43 config_.gpu_task_runner->PostTaskAndReply(
44 FROM_HERE,
45 base::Bind(&GPUDelegate::Draw, config_.gpu_delegate, engine_->Paint()),
46 base::Bind(&Animator::OnFrameComplete, weak_factory_.GetWeakPtr()));
47 }
48
49 void Animator::OnFrameComplete() {
50 DCHECK(frame_pending_);
51 frame_pending_ = false;
52 if (frame_requested_) {
53 frame_pending_ = true;
54 BeginFrame();
55 }
56 }
57
58 } // namespace shell
59 } // namespace sky
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698