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

Side by Side Diff: sky/shell/ui/animator.cc

Issue 1025073003: Add more tracing to Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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/engine/core/script/dart_loader.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "sky/shell/ui/animator.h" 5 #include "sky/shell/ui/animator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/trace_event/trace_event.h"
9 10
10 namespace sky { 11 namespace sky {
11 namespace shell { 12 namespace shell {
12 13
13 Animator::Animator(const Engine::Config& config, Engine* engine) 14 Animator::Animator(const Engine::Config& config, Engine* engine)
14 : config_(config), 15 : config_(config),
15 engine_(engine), 16 engine_(engine),
16 engine_requested_frame_(false), 17 engine_requested_frame_(false),
17 frame_in_progress_(false), 18 frame_in_progress_(false),
18 weak_factory_(this) { 19 weak_factory_(this) {
19 } 20 }
20 21
21 Animator::~Animator() { 22 Animator::~Animator() {
22 } 23 }
23 24
24 void Animator::RequestFrame() { 25 void Animator::RequestFrame() {
25 if (engine_requested_frame_) 26 if (engine_requested_frame_)
26 return; 27 return;
28
29 TRACE_EVENT_ASYNC_BEGIN0("sky", "Frame request pending", this);
27 engine_requested_frame_ = true; 30 engine_requested_frame_ = true;
28 31
29 if (!frame_in_progress_) { 32 if (!frame_in_progress_) {
30 frame_in_progress_ = true; 33 frame_in_progress_ = true;
31 base::MessageLoop::current()->PostTask( 34 base::MessageLoop::current()->PostTask(
32 FROM_HERE, 35 FROM_HERE,
33 base::Bind(&Animator::BeginFrame, weak_factory_.GetWeakPtr())); 36 base::Bind(&Animator::BeginFrame, weak_factory_.GetWeakPtr()));
34 } 37 }
35 } 38 }
36 39
37 void Animator::CancelFrameRequest() { 40 void Animator::CancelFrameRequest() {
38 engine_requested_frame_ = false; 41 engine_requested_frame_ = false;
39 } 42 }
40 43
41 void Animator::BeginFrame() { 44 void Animator::BeginFrame() {
42 DCHECK(frame_in_progress_); 45 DCHECK(frame_in_progress_);
43 // There could be a request in the message loop at time of cancel. 46 // There could be a request in the message loop at time of cancel.
44 if (!engine_requested_frame_) { 47 if (!engine_requested_frame_) {
45 frame_in_progress_ = false; 48 frame_in_progress_ = false;
46 return; 49 return;
47 } 50 }
51
48 engine_requested_frame_ = false; 52 engine_requested_frame_ = false;
53 TRACE_EVENT_ASYNC_END0("sky", "Frame request pending", this);
49 54
50 engine_->BeginFrame(base::TimeTicks::Now()); 55 engine_->BeginFrame(base::TimeTicks::Now());
51 config_.gpu_task_runner->PostTaskAndReply( 56 config_.gpu_task_runner->PostTaskAndReply(
52 FROM_HERE, 57 FROM_HERE,
53 base::Bind(&GPUDelegate::Draw, config_.gpu_delegate, engine_->Paint()), 58 base::Bind(&GPUDelegate::Draw, config_.gpu_delegate, engine_->Paint()),
54 base::Bind(&Animator::OnFrameComplete, weak_factory_.GetWeakPtr())); 59 base::Bind(&Animator::OnFrameComplete, weak_factory_.GetWeakPtr()));
55 } 60 }
56 61
57 void Animator::OnFrameComplete() { 62 void Animator::OnFrameComplete() {
58 DCHECK(frame_in_progress_); 63 DCHECK(frame_in_progress_);
59 frame_in_progress_ = false; 64 frame_in_progress_ = false;
60 if (engine_requested_frame_) { 65 if (engine_requested_frame_) {
61 frame_in_progress_ = true; 66 frame_in_progress_ = true;
62 BeginFrame(); 67 BeginFrame();
63 } 68 }
64 } 69 }
65 70
66 } // namespace shell 71 } // namespace shell
67 } // namespace sky 72 } // namespace sky
OLDNEW
« no previous file with comments | « sky/engine/core/script/dart_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698