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

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: 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 unified diff | Download patch
« no previous file with comments | « sky/shell/ui/animator.h ('k') | sky/shell/ui/engine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 engine_requested_frame_(false),
17 frame_in_progress_(false),
18 weak_factory_(this) {
19 }
20
21 Animator::~Animator() {
22 }
23
24 void Animator::RequestFrame() {
25 if (engine_requested_frame_)
26 return;
27 engine_requested_frame_ = true;
28
29 if (!frame_in_progress_) {
30 frame_in_progress_ = 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_in_progress_);
39 DCHECK(engine_requested_frame_);
40 engine_requested_frame_ = 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_in_progress_);
51 frame_in_progress_ = false;
52 if (engine_requested_frame_) {
53 frame_in_progress_ = true;
54 BeginFrame();
55 }
56 }
57
58 } // namespace shell
59 } // namespace sky
OLDNEW
« 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