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 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 namespace cc { | 24 namespace cc { |
25 class CopyOutputRequest; | 25 class CopyOutputRequest; |
26 class OutputSurface; | 26 class OutputSurface; |
27 | 27 |
28 class TestCompositorFrameSinkClient { | 28 class TestCompositorFrameSinkClient { |
29 public: | 29 public: |
30 virtual ~TestCompositorFrameSinkClient() {} | 30 virtual ~TestCompositorFrameSinkClient() {} |
31 | 31 |
| 32 // This passes the ContextProvider being used by LayerTreeHostImpl which |
| 33 // can be used for the OutputSurface optionally. |
| 34 virtual std::unique_ptr<OutputSurface> CreateDisplayOutputSurface( |
| 35 scoped_refptr<ContextProvider> compositor_context_provider) = 0; |
| 36 |
32 virtual void DisplayReceivedCompositorFrame(const CompositorFrame& frame) = 0; | 37 virtual void DisplayReceivedCompositorFrame(const CompositorFrame& frame) = 0; |
33 virtual void DisplayWillDrawAndSwap(bool will_draw_and_swap, | 38 virtual void DisplayWillDrawAndSwap(bool will_draw_and_swap, |
34 const RenderPassList& render_passes) = 0; | 39 const RenderPassList& render_passes) = 0; |
35 virtual void DisplayDidDrawAndSwap() = 0; | 40 virtual void DisplayDidDrawAndSwap() = 0; |
36 }; | 41 }; |
37 | 42 |
38 // CompositorFrameSink that owns and forwards frames to a Display. | 43 // CompositorFrameSink that owns and forwards frames to a Display. |
39 class TestCompositorFrameSink : public CompositorFrameSink, | 44 class TestCompositorFrameSink : public CompositorFrameSink, |
40 public SurfaceFactoryClient, | 45 public SurfaceFactoryClient, |
41 public DisplayClient { | 46 public DisplayClient { |
42 public: | 47 public: |
43 // 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 |
44 // is out-of-process and can't return resources synchronously. | 49 // is out-of-process and can't return resources synchronously. |
45 TestCompositorFrameSink( | 50 TestCompositorFrameSink( |
46 scoped_refptr<ContextProvider> compositor_context_provider, | 51 scoped_refptr<ContextProvider> compositor_context_provider, |
47 scoped_refptr<ContextProvider> worker_context_provider, | 52 scoped_refptr<ContextProvider> worker_context_provider, |
48 std::unique_ptr<OutputSurface> display_output_surface, | |
49 SharedBitmapManager* shared_bitmap_manager, | 53 SharedBitmapManager* shared_bitmap_manager, |
50 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 54 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
51 const RendererSettings& renderer_settings, | 55 const RendererSettings& renderer_settings, |
52 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 56 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
53 bool synchronous_composite, | 57 bool synchronous_composite, |
54 bool force_disable_reclaim_resources); | 58 bool force_disable_reclaim_resources); |
55 ~TestCompositorFrameSink() override; | 59 ~TestCompositorFrameSink() override; |
56 | 60 |
| 61 // This client must be set before BindToClient() happens. |
57 void SetClient(TestCompositorFrameSinkClient* client) { | 62 void SetClient(TestCompositorFrameSinkClient* client) { |
58 test_client_ = client; | 63 test_client_ = client; |
59 } | 64 } |
60 void SetEnlargePassTextureAmount(const gfx::Size& s) { | 65 void SetEnlargePassTextureAmount(const gfx::Size& s) { |
61 enlarge_pass_texture_amount_ = s; | 66 enlarge_pass_texture_amount_ = s; |
62 } | 67 } |
63 | 68 |
64 Display* display() const { return display_.get(); } | 69 Display* display() const { return display_.get(); } |
65 | 70 |
66 // Will be included with the next SubmitCompositorFrame. | 71 // Will be included with the next SubmitCompositorFrame. |
(...skipping 11 matching lines...) Expand all Loading... |
78 | 83 |
79 // DisplayClient implementation. | 84 // DisplayClient implementation. |
80 void DisplayOutputSurfaceLost() override; | 85 void DisplayOutputSurfaceLost() override; |
81 void DisplayWillDrawAndSwap(bool will_draw_and_swap, | 86 void DisplayWillDrawAndSwap(bool will_draw_and_swap, |
82 const RenderPassList& render_passes) override; | 87 const RenderPassList& render_passes) override; |
83 void DisplayDidDrawAndSwap() override; | 88 void DisplayDidDrawAndSwap() override; |
84 | 89 |
85 private: | 90 private: |
86 void DidDrawCallback(); | 91 void DidDrawCallback(); |
87 | 92 |
| 93 const bool synchronous_composite_; |
| 94 const RendererSettings renderer_settings_; |
| 95 SharedBitmapManager* const shared_bitmap_manager_; |
| 96 gpu::GpuMemoryBufferManager* const gpu_memory_buffer_manager_; |
| 97 |
88 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 98 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
89 | 99 |
90 FrameSinkId frame_sink_id_; | 100 FrameSinkId frame_sink_id_; |
91 // TODO(danakj): These don't need to be stored in unique_ptrs when | 101 // TODO(danakj): These don't need to be stored in unique_ptrs when |
92 // CompositorFrameSink is owned/destroyed on the compositor thread. | 102 // CompositorFrameSink is owned/destroyed on the compositor thread. |
93 std::unique_ptr<SurfaceManager> surface_manager_; | 103 std::unique_ptr<SurfaceManager> surface_manager_; |
94 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_; | 104 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_; |
95 LocalFrameId delegated_local_frame_id_; | 105 LocalFrameId delegated_local_frame_id_; |
96 | 106 |
97 // Uses surface_manager_. | 107 // Uses surface_manager_. |
98 std::unique_ptr<SurfaceFactory> surface_factory_; | 108 std::unique_ptr<SurfaceFactory> surface_factory_; |
99 | 109 |
100 // Uses surface_manager_. | 110 // Uses surface_manager_. |
101 std::unique_ptr<Display> display_; | 111 std::unique_ptr<Display> display_; |
102 | 112 |
103 const bool display_context_shared_with_compositor_; | |
104 | |
105 bool bound_ = false; | 113 bool bound_ = false; |
106 TestCompositorFrameSinkClient* test_client_ = nullptr; | 114 TestCompositorFrameSinkClient* test_client_ = nullptr; |
107 gfx::Size enlarge_pass_texture_amount_; | 115 gfx::Size enlarge_pass_texture_amount_; |
108 | 116 |
109 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_; | 117 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_; |
110 | 118 |
111 base::WeakPtrFactory<TestCompositorFrameSink> weak_ptr_factory_; | 119 base::WeakPtrFactory<TestCompositorFrameSink> weak_ptr_factory_; |
112 }; | 120 }; |
113 | 121 |
114 } // namespace cc | 122 } // namespace cc |
115 | 123 |
116 #endif // CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ | 124 #endif // CC_TEST_TEST_COMPOSITOR_FRAME_SINK_H_ |
OLD | NEW |