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_DELEGATING_OUTPUT_SURFACE_H_ | 5 #ifndef CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ |
6 #define CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ | 6 #define CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "cc/output/output_surface.h" | 9 #include "cc/output/output_surface.h" |
10 #include "cc/output/renderer_settings.h" | 10 #include "cc/output/renderer_settings.h" |
11 #include "cc/scheduler/begin_frame_source.h" | 11 #include "cc/scheduler/begin_frame_source.h" |
12 #include "cc/surfaces/display.h" | 12 #include "cc/surfaces/display.h" |
13 #include "cc/surfaces/display_client.h" | 13 #include "cc/surfaces/display_client.h" |
14 #include "cc/surfaces/surface_factory.h" | 14 #include "cc/surfaces/surface_factory.h" |
15 #include "cc/surfaces/surface_factory_client.h" | 15 #include "cc/surfaces/surface_factory_client.h" |
16 #include "cc/surfaces/surface_id_allocator.h" | 16 #include "cc/surfaces/surface_id_allocator.h" |
17 #include "cc/surfaces/surface_manager.h" | 17 #include "cc/surfaces/surface_manager.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 class TestDelegatingOutputSurface : public OutputSurface, | 21 class TestDelegatingOutputSurface : public OutputSurface, |
22 public SurfaceFactoryClient { | 22 public SurfaceFactoryClient, |
| 23 public DisplayClient { |
23 public: | 24 public: |
24 TestDelegatingOutputSurface( | 25 TestDelegatingOutputSurface( |
25 scoped_refptr<ContextProvider> compositor_context_provider, | 26 scoped_refptr<ContextProvider> compositor_context_provider, |
26 scoped_refptr<ContextProvider> worker_context_provider, | 27 scoped_refptr<ContextProvider> worker_context_provider, |
27 std::unique_ptr<Display> display, | 28 std::unique_ptr<OutputSurface> display_output_surface, |
28 bool context_shared_with_compositor, | 29 SharedBitmapManager* shared_bitmap_manager, |
29 bool allow_force_reclaim_resources); | 30 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 31 const RendererSettings& renderer_settings, |
| 32 base::SingleThreadTaskRunner* task_runner, |
| 33 bool synchronous_composite); |
30 ~TestDelegatingOutputSurface() override; | 34 ~TestDelegatingOutputSurface() override; |
31 | 35 |
| 36 Display* display() const { return display_.get(); } |
| 37 |
32 // OutputSurface implementation. | 38 // OutputSurface implementation. |
33 bool BindToClient(OutputSurfaceClient* client) override; | 39 bool BindToClient(OutputSurfaceClient* client) override; |
34 void DetachFromClient() override; | 40 void DetachFromClient() override; |
35 void SwapBuffers(CompositorFrame frame) override; | 41 void SwapBuffers(CompositorFrame frame) override; |
36 void ForceReclaimResources() override; | 42 void ForceReclaimResources() override; |
37 void BindFramebuffer() override; | 43 void BindFramebuffer() override; |
38 uint32_t GetFramebufferCopyTextureFormat() override; | 44 uint32_t GetFramebufferCopyTextureFormat() override; |
39 | 45 |
40 // SurfaceFactoryClient implementation. | 46 // SurfaceFactoryClient implementation. |
41 void ReturnResources(const ReturnedResourceArray& resources) override; | 47 void ReturnResources(const ReturnedResourceArray& resources) override; |
42 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; | 48 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; |
43 | 49 |
| 50 // DisplayClient implementation. |
| 51 void DisplayOutputSurfaceLost() override; |
| 52 void DisplaySetMemoryPolicy(const ManagedMemoryPolicy& policy) override; |
| 53 |
44 private: | 54 private: |
45 void DrawCallback(SurfaceDrawStatus); | 55 void DrawCallback(SurfaceDrawStatus); |
46 | 56 |
47 class PixelTestDisplayClient : public DisplayClient { | |
48 void DisplayOutputSurfaceLost() override {} | |
49 void DisplaySetMemoryPolicy(const ManagedMemoryPolicy& policy) override {} | |
50 }; | |
51 | |
52 // TODO(danakj): These don't to be stored in unique_ptrs when OutputSurface | 57 // TODO(danakj): These don't to be stored in unique_ptrs when OutputSurface |
53 // is owned/destroyed on the compositor thread. | 58 // is owned/destroyed on the compositor thread. |
54 std::unique_ptr<SurfaceManager> surface_manager_; | 59 std::unique_ptr<SurfaceManager> surface_manager_; |
55 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_; | 60 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_; |
56 SurfaceId delegated_surface_id_; | 61 SurfaceId delegated_surface_id_; |
57 | 62 |
58 // Uses surface_manager_. | 63 // Uses surface_manager_. |
59 std::unique_ptr<SurfaceFactory> surface_factory_; | 64 std::unique_ptr<SurfaceFactory> surface_factory_; |
60 | 65 |
61 PixelTestDisplayClient display_client_; | |
62 // Uses surface_manager_. | 66 // Uses surface_manager_. |
63 std::unique_ptr<Display> display_; | 67 std::unique_ptr<Display> display_; |
64 | 68 |
| 69 bool bound_ = false; |
| 70 |
65 base::WeakPtrFactory<TestDelegatingOutputSurface> weak_ptrs_; | 71 base::WeakPtrFactory<TestDelegatingOutputSurface> weak_ptrs_; |
66 }; | 72 }; |
67 | 73 |
68 } // namespace cc | 74 } // namespace cc |
69 | 75 |
70 #endif // CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ | 76 #endif // CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ |
OLD | NEW |