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

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

Issue 15836005: cc: Emulate BeginFrame in OutputSurfaces that don't support it natively (Closed) Base URL: http://git.chromium.org/chromium/src.git@nofrc
Patch Set: Fix checkerboard; Track pending swaps; 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
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);
44 47
45 // Use the following methods to adjust target frame rate. 48 // Use the following methods to adjust target frame rate.
46 // 49 //
47 // Multiple frames can be in-progress, but for every DidSwapBuffers, a 50 // Multiple frames can be in-progress, but for every DidSwapBuffers, a
48 // DidFinishFrame should be posted. 51 // DidFinishFrame should be posted.
49 // 52 //
50 // If the rendering pipeline crashes, call DidAbortAllPendingFrames. 53 // If the rendering pipeline crashes, call DidAbortAllPendingFrames.
51 void DidSwapBuffers(); 54 void WillSwapBuffers();
52 void DidSwapBuffersComplete(); 55 void DidSwapBuffersComplete();
53 void DidAbortAllPendingFrames(); 56 void DidAbortAllPendingFrames();
nduca 2013/06/04 04:53:59 this makes me think the OutputSurface needs a DidA
54 void SetMaxFramesPending(int max_frames_pending); // 0 for unlimited. 57 void SetMaxFramesPending(int max_frames_pending); // 0 for unlimited.
55 int MaxFramesPending() const { return max_frames_pending_; } 58 int MaxFramesPending() const { return max_frames_pending_; }
56 int NumFramesPendingForTesting() const { return num_frames_pending_; } 59 int NumFramesPendingForTesting() const { return num_frames_pending_; }
57 60
58 // This returns null for unthrottled frame-rate. 61 // This returns null for unthrottled frame-rate.
59 base::TimeTicks NextTickTime(); 62 base::TimeTicks NextTickTime();
60 63
61 // This returns now for unthrottled frame-rate. 64 // This returns now for unthrottled frame-rate.
62 base::TimeTicks LastTickTime(); 65 base::TimeTicks LastTickTime();
63 66
(...skipping 20 matching lines...) Expand all
84 bool is_time_source_throttling_; 87 bool is_time_source_throttling_;
85 base::WeakPtrFactory<FrameRateController> weak_factory_; 88 base::WeakPtrFactory<FrameRateController> weak_factory_;
86 Thread* thread_; 89 Thread* thread_;
87 90
88 DISALLOW_COPY_AND_ASSIGN(FrameRateController); 91 DISALLOW_COPY_AND_ASSIGN(FrameRateController);
89 }; 92 };
90 93
91 } // namespace cc 94 } // namespace cc
92 95
93 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_ 96 #endif // CC_SCHEDULER_FRAME_RATE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698