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

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

Issue 17362002: cc: Remove FakeThread, use SingleThreadTaskRunner in scheduling classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm-fakethread: rebase 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 | Annotate | Revision Log
« no previous file with comments | « cc/scheduler/delay_based_time_source_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 base { class SingleThreadTaskRunner; }
15
14 namespace cc { 16 namespace cc {
15 17
16 class Thread;
17 class TimeSource; 18 class TimeSource;
18 class FrameRateController; 19 class FrameRateController;
19 20
20 class CC_EXPORT FrameRateControllerClient { 21 class CC_EXPORT FrameRateControllerClient {
21 protected: 22 protected:
22 virtual ~FrameRateControllerClient() {} 23 virtual ~FrameRateControllerClient() {}
23 24
24 public: 25 public:
25 // Throttled is true when we have a maximum number of frames pending. 26 // Throttled is true when we have a maximum number of frames pending.
26 virtual void FrameRateControllerTick(bool throttled) = 0; 27 virtual void FrameRateControllerTick(bool throttled) = 0;
27 }; 28 };
28 29
29 class FrameRateControllerTimeSourceAdapter; 30 class FrameRateControllerTimeSourceAdapter;
30 31
31 // The FrameRateController is used in cases where we self-tick (i.e. BeginFrame 32 // The FrameRateController is used in cases where we self-tick (i.e. BeginFrame
32 // is not sent by a parent compositor. 33 // is not sent by a parent compositor.
33 class CC_EXPORT FrameRateController { 34 class CC_EXPORT FrameRateController {
34 public: 35 public:
35 enum { 36 enum {
36 DEFAULT_MAX_FRAMES_PENDING = 2 37 DEFAULT_MAX_FRAMES_PENDING = 2
37 }; 38 };
38 39
39 explicit FrameRateController(scoped_refptr<TimeSource> timer); 40 explicit FrameRateController(scoped_refptr<TimeSource> timer);
40 // Alternate form of FrameRateController with unthrottled frame-rate. 41 // Alternate form of FrameRateController with unthrottled frame-rate.
41 explicit FrameRateController(Thread* thread); 42 explicit FrameRateController(base::SingleThreadTaskRunner* task_runner);
42 virtual ~FrameRateController(); 43 virtual ~FrameRateController();
43 44
44 void SetClient(FrameRateControllerClient* client) { client_ = client; } 45 void SetClient(FrameRateControllerClient* client) { client_ = client; }
45 46
46 void SetActive(bool active); 47 void SetActive(bool active);
47 bool IsActive() { return active_; } 48 bool IsActive() { return active_; }
48 49
49 // Use the following methods to adjust target frame rate. 50 // Use the following methods to adjust target frame rate.
50 // 51 //
51 // Multiple frames can be in-progress, but for every DidSwapBuffers, a 52 // Multiple frames can be in-progress, but for every DidSwapBuffers, a
(...skipping 26 matching lines...) Expand all
78 FrameRateControllerClient* client_; 79 FrameRateControllerClient* client_;
79 int num_frames_pending_; 80 int num_frames_pending_;
80 int max_swaps_pending_; 81 int max_swaps_pending_;
81 scoped_refptr<TimeSource> time_source_; 82 scoped_refptr<TimeSource> time_source_;
82 scoped_ptr<FrameRateControllerTimeSourceAdapter> time_source_client_adapter_; 83 scoped_ptr<FrameRateControllerTimeSourceAdapter> time_source_client_adapter_;
83 bool active_; 84 bool active_;
84 85
85 // Members for unthrottled frame-rate. 86 // Members for unthrottled frame-rate.
86 bool is_time_source_throttling_; 87 bool is_time_source_throttling_;
87 base::WeakPtrFactory<FrameRateController> weak_factory_; 88 base::WeakPtrFactory<FrameRateController> weak_factory_;
88 Thread* thread_; 89 base::SingleThreadTaskRunner* task_runner_;
89 90
90 private: 91 private:
91 DISALLOW_COPY_AND_ASSIGN(FrameRateController); 92 DISALLOW_COPY_AND_ASSIGN(FrameRateController);
92 }; 93 };
93 94
94 } // namespace cc 95 } // namespace cc
95 96
96 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ 97 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « cc/scheduler/delay_based_time_source_unittest.cc ('k') | cc/scheduler/frame_rate_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698