OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_COMPOSITOR_FRAME_SINK_H_ | 5 #ifndef CC_TEST_FAKE_COMPOSITOR_FRAME_SINK_H_ |
6 #define CC_TEST_FAKE_COMPOSITOR_FRAME_SINK_H_ | 6 #define CC_TEST_FAKE_COMPOSITOR_FRAME_SINK_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 std::unique_ptr<TestWebGraphicsContext3D> context) { | 41 std::unique_ptr<TestWebGraphicsContext3D> context) { |
42 return base::WrapUnique(new FakeCompositorFrameSink( | 42 return base::WrapUnique(new FakeCompositorFrameSink( |
43 TestContextProvider::Create(std::move(context)), | 43 TestContextProvider::Create(std::move(context)), |
44 TestContextProvider::CreateWorker())); | 44 TestContextProvider::CreateWorker())); |
45 } | 45 } |
46 | 46 |
47 static std::unique_ptr<FakeCompositorFrameSink> CreateSoftware() { | 47 static std::unique_ptr<FakeCompositorFrameSink> CreateSoftware() { |
48 return base::WrapUnique(new FakeCompositorFrameSink(nullptr, nullptr)); | 48 return base::WrapUnique(new FakeCompositorFrameSink(nullptr, nullptr)); |
49 } | 49 } |
50 | 50 |
| 51 // CompositorFrameSink implementation. |
| 52 void SwapBuffers(CompositorFrame frame) override; |
| 53 void DetachFromClient() override; |
| 54 |
51 CompositorFrame* last_sent_frame() { return last_sent_frame_.get(); } | 55 CompositorFrame* last_sent_frame() { return last_sent_frame_.get(); } |
52 size_t num_sent_frames() { return num_sent_frames_; } | 56 size_t num_sent_frames() { return num_sent_frames_; } |
53 | 57 |
54 void SwapBuffers(CompositorFrame frame) override; | |
55 | |
56 CompositorFrameSinkClient* client() { return client_; } | 58 CompositorFrameSinkClient* client() { return client_; } |
57 bool BindToClient(CompositorFrameSinkClient* client) override; | |
58 void DetachFromClient() override; | |
59 | 59 |
60 const TransferableResourceArray& resources_held_by_parent() { | 60 const TransferableResourceArray& resources_held_by_parent() { |
61 return resources_held_by_parent_; | 61 return resources_held_by_parent_; |
62 } | 62 } |
63 | 63 |
64 gfx::Rect last_swap_rect() const { | 64 gfx::Rect last_swap_rect() const { |
65 DCHECK(last_swap_rect_valid_); | 65 DCHECK(last_swap_rect_valid_); |
66 return last_swap_rect_; | 66 return last_swap_rect_; |
67 } | 67 } |
68 | 68 |
69 void ReturnResourcesHeldByParent(); | 69 void ReturnResourcesHeldByParent(); |
70 | 70 |
71 protected: | 71 protected: |
72 FakeCompositorFrameSink( | 72 FakeCompositorFrameSink( |
73 scoped_refptr<ContextProvider> context_provider, | 73 scoped_refptr<ContextProvider> context_provider, |
74 scoped_refptr<ContextProvider> worker_context_provider); | 74 scoped_refptr<ContextProvider> worker_context_provider); |
75 | 75 |
76 CompositorFrameSinkClient* client_ = nullptr; | |
77 std::unique_ptr<CompositorFrame> last_sent_frame_; | 76 std::unique_ptr<CompositorFrame> last_sent_frame_; |
78 size_t num_sent_frames_ = 0; | 77 size_t num_sent_frames_ = 0; |
79 TransferableResourceArray resources_held_by_parent_; | 78 TransferableResourceArray resources_held_by_parent_; |
80 bool last_swap_rect_valid_ = false; | 79 bool last_swap_rect_valid_ = false; |
81 gfx::Rect last_swap_rect_; | 80 gfx::Rect last_swap_rect_; |
82 | 81 |
83 private: | 82 private: |
84 void SwapBuffersAck(); | 83 void SwapBuffersAck(); |
85 | 84 |
86 base::WeakPtrFactory<FakeCompositorFrameSink> weak_ptr_factory_; | 85 base::WeakPtrFactory<FakeCompositorFrameSink> weak_ptr_factory_; |
87 }; | 86 }; |
88 | 87 |
89 } // namespace cc | 88 } // namespace cc |
90 | 89 |
91 #endif // CC_TEST_FAKE_COMPOSITOR_FRAME_SINK_H_ | 90 #endif // CC_TEST_FAKE_COMPOSITOR_FRAME_SINK_H_ |
OLD | NEW |