OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_TEST_COMPOSITOR_FRAME_SINK_H_ | 5 #ifndef CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ |
6 #define CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ | 6 #define CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "cc/output/compositor_frame_sink.h" | 10 #include "cc/output/compositor_frame_sink.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 public: | 47 public: |
48 // Pass true for |force_disable_reclaim_resources| to act like the Display | 48 // Pass true for |force_disable_reclaim_resources| to act like the Display |
49 // is out-of-process and can't return resources synchronously. | 49 // is out-of-process and can't return resources synchronously. |
50 TestCompositorFrameSink( | 50 TestCompositorFrameSink( |
51 scoped_refptr<ContextProvider> compositor_context_provider, | 51 scoped_refptr<ContextProvider> compositor_context_provider, |
52 scoped_refptr<ContextProvider> worker_context_provider, | 52 scoped_refptr<ContextProvider> worker_context_provider, |
53 SharedBitmapManager* shared_bitmap_manager, | 53 SharedBitmapManager* shared_bitmap_manager, |
54 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 54 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
55 const RendererSettings& renderer_settings, | 55 const RendererSettings& renderer_settings, |
56 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 56 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
57 bool synchronous_composite, | 57 bool synchronous_composite); |
58 bool force_disable_reclaim_resources); | |
59 ~TestCompositorFrameSink() override; | 58 ~TestCompositorFrameSink() override; |
60 | 59 |
61 // This client must be set before BindToClient() happens. | 60 // This client must be set before BindToClient() happens. |
62 void SetClient(TestCompositorFrameSinkClient* client) { | 61 void SetClient(TestCompositorFrameSinkClient* client) { |
63 test_client_ = client; | 62 test_client_ = client; |
64 } | 63 } |
65 void SetEnlargePassTextureAmount(const gfx::Size& s) { | 64 void SetEnlargePassTextureAmount(const gfx::Size& s) { |
66 enlarge_pass_texture_amount_ = s; | 65 enlarge_pass_texture_amount_ = s; |
67 } | 66 } |
| 67 void SetForceReclaimResourcesAfterSwap() { |
| 68 force_reclaim_resources_after_swap_ = true; |
| 69 } |
68 | 70 |
69 Display* display() const { return display_.get(); } | 71 Display* display() const { return display_.get(); } |
70 | 72 |
71 // Will be included with the next SubmitCompositorFrame. | 73 // Will be included with the next SubmitCompositorFrame. |
72 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request); | 74 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request); |
73 | 75 |
74 // CompositorFrameSink implementation. | 76 // CompositorFrameSink implementation. |
75 bool BindToClient(CompositorFrameSinkClient* client) override; | 77 bool BindToClient(CompositorFrameSinkClient* client) override; |
76 void DetachFromClient() override; | 78 void DetachFromClient() override; |
77 void SubmitCompositorFrame(CompositorFrame frame) override; | 79 void SubmitCompositorFrame(CompositorFrame frame) override; |
78 void ForceReclaimResources() override; | |
79 | 80 |
80 // SurfaceFactoryClient implementation. | 81 // SurfaceFactoryClient implementation. |
81 void ReturnResources(const ReturnedResourceArray& resources) override; | 82 void ReturnResources(const ReturnedResourceArray& resources) override; |
82 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; | 83 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; |
83 | 84 |
84 // DisplayClient implementation. | 85 // DisplayClient implementation. |
85 void DisplayOutputSurfaceLost() override; | 86 void DisplayOutputSurfaceLost() override; |
86 void DisplayWillDrawAndSwap(bool will_draw_and_swap, | 87 void DisplayWillDrawAndSwap(bool will_draw_and_swap, |
87 const RenderPassList& render_passes) override; | 88 const RenderPassList& render_passes) override; |
88 void DisplayDidDrawAndSwap() override; | 89 void DisplayDidDrawAndSwap() override; |
(...skipping 20 matching lines...) Expand all Loading... |
109 | 110 |
110 // Uses surface_manager_ and begin_frame_source_. | 111 // Uses surface_manager_ and begin_frame_source_. |
111 std::unique_ptr<Display> display_; | 112 std::unique_ptr<Display> display_; |
112 | 113 |
113 bool bound_ = false; | 114 bool bound_ = false; |
114 TestCompositorFrameSinkClient* test_client_ = nullptr; | 115 TestCompositorFrameSinkClient* test_client_ = nullptr; |
115 gfx::Size enlarge_pass_texture_amount_; | 116 gfx::Size enlarge_pass_texture_amount_; |
116 | 117 |
117 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_; | 118 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_; |
118 | 119 |
| 120 // If true, we will attempt to reclaim resources after each swap. |
| 121 bool force_reclaim_resources_after_swap_ = false; |
| 122 |
119 base::WeakPtrFactory<TestCompositorFrameSink> weak_ptr_factory_; | 123 base::WeakPtrFactory<TestCompositorFrameSink> weak_ptr_factory_; |
120 }; | 124 }; |
121 | 125 |
122 } // namespace cc | 126 } // namespace cc |
123 | 127 |
124 #endif // CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ | 128 #endif // CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ |
OLD | NEW |