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

Side by Side Diff: mojo/ui/choreographer.h

Issue 1943153002: Mozart: Move frame lag compensation to new class. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 7 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 | « mojo/ui/BUILD.gn ('k') | mojo/ui/choreographer.cc » ('j') | 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 #ifndef MOJO_UI_CHOREOGRAPHER_H_ 5 #ifndef MOJO_UI_CHOREOGRAPHER_H_
6 #define MOJO_UI_CHOREOGRAPHER_H_ 6 #define MOJO_UI_CHOREOGRAPHER_H_
7 7
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "mojo/public/cpp/system/macros.h" 9 #include "mojo/public/cpp/system/macros.h"
10 #include "mojo/services/gfx/composition/cpp/frame_tracker.h"
10 #include "mojo/services/gfx/composition/interfaces/scenes.mojom.h" 11 #include "mojo/services/gfx/composition/interfaces/scenes.mojom.h"
11 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h" 12 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h"
12 13
13 namespace mojo { 14 namespace mojo {
14 namespace ui { 15 namespace ui {
15 16
16 class ChoreographerDelegate; 17 class ChoreographerDelegate;
17 18
18 // Coordinates drawing a frame of a scene. 19 // Coordinates drawing a frame of a scene.
19 // 20 //
20 // This class is intended to be included as a member of a View that wants to 21 // This class is intended to be included as a member of a View that wants to
21 // schedule drawing using the following pattern. 22 // schedule drawing using the following pattern.
22 // 23 //
23 // class MyView : public mojo::ui::BaseView, 24 // class MyView : public mojo::ui::BaseView,
24 // public mojo::ui::ChoreographerDelegate { 25 // public mojo::ui::ChoreographerDelegate {
25 // public: 26 // public:
26 // MyView(mojo::ApplicationImpl* app_impl, 27 // MyView(mojo::ApplicationImpl* app_impl,
27 // const mojo::ui::ViewProvider::CreateViewCallback& 28 // const mojo::ui::ViewProvider::CreateViewCallback&
28 // create_view_callback) 29 // create_view_callback)
29 // : BaseView(app_impl, "MyView", create_view_callback), 30 // : BaseView(app_impl, "MyView", create_view_callback),
30 // choreographer_(scene_scheduler(), this) {} 31 // choreographer_(scene(), this) {}
31 // ~MyView() override {} 32 // ~MyView() override {}
32 // 33 //
33 // private: 34 // private:
34 // // |ChoreographerDelegate|: 35 // // |ChoreographerDelegate|:
35 // void OnDraw(const mojo::gfx::composition::FrameInfo& frame_info) override; 36 // void OnDraw(const mojo::gfx::composition::FrameInfo& frame_info) override;
36 // 37 //
37 // mojo::ui::Choreographer choreographer_; 38 // mojo::ui::Choreographer choreographer_;
38 // 39 //
39 // MOJO_DISALLOW_COPY_AND_ASSIGN(MyView); 40 // MOJO_DISALLOW_COPY_AND_ASSIGN(MyView);
40 // }; 41 // };
41 class Choreographer { 42 class Choreographer {
42 public: 43 public:
43 Choreographer(mojo::gfx::composition::Scene* scene, 44 Choreographer(mojo::gfx::composition::Scene* scene,
44 ChoreographerDelegate* delegate); 45 ChoreographerDelegate* delegate);
45 Choreographer(mojo::gfx::composition::SceneSchedulerPtr scene_scheduler, 46 Choreographer(mojo::gfx::composition::SceneSchedulerPtr scene_scheduler,
46 ChoreographerDelegate* delegate); 47 ChoreographerDelegate* delegate);
47 ~Choreographer(); 48 ~Choreographer();
48 49
49 // Gets the scene scheduler. 50 // Gets the scene scheduler.
50 mojo::gfx::composition::SceneScheduler* scene_scheduler() { 51 mojo::gfx::composition::SceneScheduler* scene_scheduler() {
51 return scene_scheduler_.get(); 52 return scene_scheduler_.get();
52 } 53 }
53 54
54 // Gets the most recent frame info, or null if none. 55 // Gets the frame tracker.
55 mojo::gfx::composition::FrameInfo* last_frame_info() { 56 mojo::gfx::composition::FrameTracker& frame_tracker() {
56 return last_frame_info_.get(); 57 return frame_tracker_;
57 } 58 }
58 59
59 // Schedules a call to the delegate's |OnDraw| using the scene scheduler. 60 // Schedules a call to the delegate's |OnDraw| using the scene scheduler.
60 void ScheduleDraw(); 61 void ScheduleDraw();
61 62
62 private: 63 private:
63 mojo::gfx::composition::SceneSchedulerPtr scene_scheduler_; 64 mojo::gfx::composition::SceneSchedulerPtr scene_scheduler_;
64 ChoreographerDelegate* delegate_; 65 ChoreographerDelegate* delegate_;
65 mojo::gfx::composition::FrameInfoPtr last_frame_info_; 66 mojo::gfx::composition::FrameTracker frame_tracker_;
66 67
67 void ScheduleFrame(); 68 void ScheduleFrame();
68 void DoFrame(mojo::gfx::composition::FrameInfoPtr frame_info); 69 void DoFrame(mojo::gfx::composition::FrameInfoPtr frame_info);
69 70
70 bool draw_scheduled_ = false; 71 bool draw_scheduled_ = false;
71 bool frame_scheduled_ = false; 72 bool frame_scheduled_ = false;
72 73
73 MOJO_DISALLOW_COPY_AND_ASSIGN(Choreographer); 74 MOJO_DISALLOW_COPY_AND_ASSIGN(Choreographer);
74 }; 75 };
75 76
(...skipping 13 matching lines...) Expand all
89 const base::TimeDelta& time_delta) = 0; 90 const base::TimeDelta& time_delta) = 0;
90 91
91 private: 92 private:
92 MOJO_DISALLOW_COPY_AND_ASSIGN(ChoreographerDelegate); 93 MOJO_DISALLOW_COPY_AND_ASSIGN(ChoreographerDelegate);
93 }; 94 };
94 95
95 } // namespace ui 96 } // namespace ui
96 } // namespace mojo 97 } // namespace mojo
97 98
98 #endif // MOJO_UI_CHOREOGRAPHER_H_ 99 #endif // MOJO_UI_CHOREOGRAPHER_H_
OLDNEW
« no previous file with comments | « mojo/ui/BUILD.gn ('k') | mojo/ui/choreographer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698