OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_ | 5 #ifndef CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
6 #define CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_ | 6 #define CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
7 | 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/cancelable_callback.h" |
8 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
9 #include "cc/scheduler/begin_frame_source.h" | 12 #include "cc/scheduler/begin_frame_source.h" |
10 | 13 |
11 namespace cc { | 14 namespace cc { |
12 | 15 |
13 class FakeExternalBeginFrameSource | 16 class FakeExternalBeginFrameSource |
14 : public BeginFrameSourceBase, | 17 : public BeginFrameSource, |
15 public NON_EXPORTED_BASE(base::NonThreadSafe) { | 18 public NON_EXPORTED_BASE(base::NonThreadSafe) { |
16 public: | 19 public: |
17 explicit FakeExternalBeginFrameSource(double refresh_rate); | 20 class Client { |
| 21 public: |
| 22 virtual void OnAddObserver(BeginFrameObserver* obs) = 0; |
| 23 virtual void OnRemoveObserver(BeginFrameObserver* obs) = 0; |
| 24 }; |
| 25 |
| 26 explicit FakeExternalBeginFrameSource(double refresh_rate, |
| 27 bool tick_automatically); |
18 ~FakeExternalBeginFrameSource() override; | 28 ~FakeExternalBeginFrameSource() override; |
19 | 29 |
20 // BeginFrameSourceBase overrides. | 30 void SetClient(Client* client) { client_ = client; } |
21 void OnNeedsBeginFramesChanged(bool needs_begin_frames) override; | 31 void SetPaused(bool paused); |
22 | 32 |
23 void TestOnBeginFrame(); | 33 // BeginFrameSource implementation. |
| 34 void AddObserver(BeginFrameObserver* obs) override; |
| 35 void RemoveObserver(BeginFrameObserver* obs) override; |
| 36 void DidFinishFrame(BeginFrameObserver* obs, |
| 37 size_t remaining_frames) override {} |
| 38 |
| 39 void TestOnBeginFrame(const BeginFrameArgs& args); |
| 40 |
| 41 private: |
24 void PostTestOnBeginFrame(); | 42 void PostTestOnBeginFrame(); |
25 | 43 |
26 private: | 44 const bool tick_automatically_; |
27 double milliseconds_per_frame_; | 45 const double milliseconds_per_frame_; |
28 base::CancelableClosure begin_frame_task_; | 46 Client* client_ = nullptr; |
| 47 bool paused_ = false; |
| 48 std::set<BeginFrameObserver*> observers_; |
| 49 base::CancelableCallback<void(const BeginFrameArgs&)> begin_frame_task_; |
29 base::WeakPtrFactory<FakeExternalBeginFrameSource> weak_ptr_factory_; | 50 base::WeakPtrFactory<FakeExternalBeginFrameSource> weak_ptr_factory_; |
30 }; | 51 }; |
31 | 52 |
32 } // namespace cc | 53 } // namespace cc |
33 | 54 |
34 #endif // CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_ | 55 #endif // CC_TEST_FAKE_EXTERNAL_BEGIN_FRAME_SOURCE_H_ |
OLD | NEW |