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

Side by Side Diff: cc/scheduler/frame_rate_controller.h

Issue 16833003: cc: Emulate BeginFrame in OutputSurfaces that don't support it natively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 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 | « cc/output/output_surface_unittest.cc ('k') | cc/scheduler/frame_rate_controller.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ 5 #ifndef CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_
6 #define CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ 6 #define CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "cc/base/cc_export.h" 12 #include "cc/base/cc_export.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 class Thread; 16 class Thread;
17 class TimeSource; 17 class TimeSource;
18 class FrameRateController;
18 19
19 class CC_EXPORT FrameRateControllerClient { 20 class CC_EXPORT FrameRateControllerClient {
21 protected:
22 virtual ~FrameRateControllerClient() {}
23
20 public: 24 public:
21 // Throttled is true when we have a maximum number of frames pending. 25 // Throttled is true when we have a maximum number of frames pending.
22 virtual void BeginFrame(bool throttled) = 0; 26 virtual void FrameRateControllerTick(bool throttled) = 0;
23
24 protected:
25 virtual ~FrameRateControllerClient() {}
26 }; 27 };
27 28
28 class FrameRateControllerTimeSourceAdapter; 29 class FrameRateControllerTimeSourceAdapter;
29 30
31 // The FrameRateController is used in cases where we self-tick (i.e. BeginFrame
32 // is not sent by a parent compositor.
30 class CC_EXPORT FrameRateController { 33 class CC_EXPORT FrameRateController {
31 public: 34 public:
32 enum { 35 enum {
33 DEFAULT_MAX_FRAMES_PENDING = 2 36 DEFAULT_MAX_FRAMES_PENDING = 2
34 }; 37 };
35 38
36 explicit FrameRateController(scoped_refptr<TimeSource> timer); 39 explicit FrameRateController(scoped_refptr<TimeSource> timer);
37 // Alternate form of FrameRateController with unthrottled frame-rate. 40 // Alternate form of FrameRateController with unthrottled frame-rate.
38 explicit FrameRateController(Thread* thread); 41 explicit FrameRateController(Thread* thread);
39 virtual ~FrameRateController(); 42 virtual ~FrameRateController();
40 43
41 void SetClient(FrameRateControllerClient* client) { client_ = client; } 44 void SetClient(FrameRateControllerClient* client) { client_ = client; }
42 45
43 void SetActive(bool active); 46 void SetActive(bool active);
47 bool IsActive() { return active_; }
44 48
45 // Use the following methods to adjust target frame rate. 49 // Use the following methods to adjust target frame rate.
46 // 50 //
47 // Multiple frames can be in-progress, but for every DidSwapBuffers, a 51 // Multiple frames can be in-progress, but for every DidSwapBuffers, a
48 // DidFinishFrame should be posted. 52 // DidFinishFrame should be posted.
49 // 53 //
50 // If the rendering pipeline crashes, call DidAbortAllPendingFrames. 54 // If the rendering pipeline crashes, call DidAbortAllPendingFrames.
51 void DidSwapBuffers(); 55 void DidSwapBuffers();
52 void DidSwapBuffersComplete(); 56 void DidSwapBuffersComplete();
53 void DidAbortAllPendingFrames(); 57 void DidAbortAllPendingFrames();
54 void SetMaxFramesPending(int max_frames_pending); // 0 for unlimited. 58 void SetMaxSwapsPending(int max_swaps_pending); // 0 for unlimited.
55 int MaxFramesPending() const { return max_frames_pending_; } 59 int MaxSwapsPending() const { return max_swaps_pending_; }
56 int NumFramesPendingForTesting() const { return num_frames_pending_; } 60 int NumSwapsPendingForTesting() const { return num_frames_pending_; }
57 61
58 // This returns null for unthrottled frame-rate. 62 // This returns null for unthrottled frame-rate.
59 base::TimeTicks NextTickTime(); 63 base::TimeTicks NextTickTime();
60 64
61 // This returns now for unthrottled frame-rate. 65 // This returns now for unthrottled frame-rate.
62 base::TimeTicks LastTickTime(); 66 base::TimeTicks LastTickTime();
63 67
64 void SetTimebaseAndInterval(base::TimeTicks timebase, 68 void SetTimebaseAndInterval(base::TimeTicks timebase,
65 base::TimeDelta interval); 69 base::TimeDelta interval);
66 70
67 protected: 71 protected:
68 friend class FrameRateControllerTimeSourceAdapter; 72 friend class FrameRateControllerTimeSourceAdapter;
69 void OnTimerTick(); 73 void OnTimerTick();
70 74
71 void PostManualTick(); 75 void PostManualTick();
72 void ManualTick(); 76 void ManualTick();
73 77
74 FrameRateControllerClient* client_; 78 FrameRateControllerClient* client_;
75 int num_frames_pending_; 79 int num_frames_pending_;
76 int max_frames_pending_; 80 int max_swaps_pending_;
77 scoped_refptr<TimeSource> time_source_; 81 scoped_refptr<TimeSource> time_source_;
78 scoped_ptr<FrameRateControllerTimeSourceAdapter> time_source_client_adapter_; 82 scoped_ptr<FrameRateControllerTimeSourceAdapter> time_source_client_adapter_;
79 bool active_; 83 bool active_;
80 84
81 // Members for unthrottled frame-rate. 85 // Members for unthrottled frame-rate.
82 bool is_time_source_throttling_; 86 bool is_time_source_throttling_;
83 base::WeakPtrFactory<FrameRateController> weak_factory_; 87 base::WeakPtrFactory<FrameRateController> weak_factory_;
84 Thread* thread_; 88 Thread* thread_;
85 89
90 private:
86 DISALLOW_COPY_AND_ASSIGN(FrameRateController); 91 DISALLOW_COPY_AND_ASSIGN(FrameRateController);
87 }; 92 };
88 93
89 } // namespace cc 94 } // namespace cc
90 95
91 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ 96 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « cc/output/output_surface_unittest.cc ('k') | cc/scheduler/frame_rate_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698