| 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 class CopyOutputRequest; | 21 class CopyOutputRequest; |
| 21 | 22 |
| 22 class TestDelegatingOutputSurfaceClient { | |
| 23 public: | |
| 24 virtual ~TestDelegatingOutputSurfaceClient() {} | |
| 25 | |
| 26 virtual void DisplayReceivedCompositorFrame(const CompositorFrame& frame) = 0; | |
| 27 virtual void DisplayWillDrawAndSwap(bool will_draw_and_swap, | |
| 28 const RenderPassList& render_passes) = 0; | |
| 29 virtual void DisplayDidDrawAndSwap() = 0; | |
| 30 }; | |
| 31 | |
| 32 class TestDelegatingOutputSurface : public OutputSurface, | 23 class TestDelegatingOutputSurface : public OutputSurface, |
| 33 public SurfaceFactoryClient, | 24 public SurfaceFactoryClient, |
| 34 public DisplayClient { | 25 public DisplayClient { |
| 35 public: | 26 public: |
| 36 // Pass true for |force_disable_reclaim_resources| to act like the Display | |
| 37 // is out-of-process and can't return resources synchronously. | |
| 38 TestDelegatingOutputSurface( | 27 TestDelegatingOutputSurface( |
| 39 scoped_refptr<ContextProvider> compositor_context_provider, | 28 scoped_refptr<ContextProvider> compositor_context_provider, |
| 40 scoped_refptr<ContextProvider> worker_context_provider, | 29 scoped_refptr<ContextProvider> worker_context_provider, |
| 41 std::unique_ptr<OutputSurface> display_output_surface, | 30 std::unique_ptr<OutputSurface> display_output_surface, |
| 42 SharedBitmapManager* shared_bitmap_manager, | 31 SharedBitmapManager* shared_bitmap_manager, |
| 43 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 32 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 44 const RendererSettings& renderer_settings, | 33 const RendererSettings& renderer_settings, |
| 45 base::SingleThreadTaskRunner* task_runner, | 34 base::SingleThreadTaskRunner* task_runner, |
| 46 bool synchronous_composite, | 35 bool synchronous_composite); |
| 47 bool force_disable_reclaim_resources); | |
| 48 ~TestDelegatingOutputSurface() override; | 36 ~TestDelegatingOutputSurface() override; |
| 49 | 37 |
| 50 void SetClient(TestDelegatingOutputSurfaceClient* client) { | |
| 51 test_client_ = client; | |
| 52 } | |
| 53 | |
| 54 Display* display() const { return display_.get(); } | 38 Display* display() const { return display_.get(); } |
| 55 | 39 |
| 56 // Will be submitted with the next SwapBuffers. | 40 // Will be submitted with the next SwapBuffers. |
| 57 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request); | 41 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request); |
| 58 | 42 |
| 59 // OutputSurface implementation. | 43 // OutputSurface implementation. |
| 60 bool BindToClient(OutputSurfaceClient* client) override; | 44 bool BindToClient(OutputSurfaceClient* client) override; |
| 61 void DetachFromClient() override; | 45 void DetachFromClient() override; |
| 62 void SwapBuffers(CompositorFrame frame) override; | 46 void SwapBuffers(CompositorFrame frame) override; |
| 63 void ForceReclaimResources() override; | 47 void ForceReclaimResources() override; |
| 64 void BindFramebuffer() override; | 48 void BindFramebuffer() override; |
| 65 uint32_t GetFramebufferCopyTextureFormat() override; | 49 uint32_t GetFramebufferCopyTextureFormat() override; |
| 66 | 50 |
| 67 // SurfaceFactoryClient implementation. | 51 // SurfaceFactoryClient implementation. |
| 68 void ReturnResources(const ReturnedResourceArray& resources) override; | 52 void ReturnResources(const ReturnedResourceArray& resources) override; |
| 69 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; | 53 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; |
| 70 | 54 |
| 71 // DisplayClient implementation. | 55 // DisplayClient implementation. |
| 72 void DisplayOutputSurfaceLost() override; | 56 void DisplayOutputSurfaceLost() override; |
| 73 void DisplaySetMemoryPolicy(const ManagedMemoryPolicy& policy) override; | 57 void DisplaySetMemoryPolicy(const ManagedMemoryPolicy& policy) override; |
| 74 void DisplayWillDrawAndSwap(bool will_draw_and_swap, | |
| 75 const RenderPassList& render_passes) override; | |
| 76 void DisplayDidDrawAndSwap() override; | |
| 77 | 58 |
| 78 private: | 59 private: |
| 79 void DidDrawCallback(bool synchronous); | 60 void DrawCallback(bool synchronous); |
| 80 | 61 |
| 81 // TODO(danakj): These don't to be stored in unique_ptrs when OutputSurface | 62 // TODO(danakj): These don't to be stored in unique_ptrs when OutputSurface |
| 82 // is owned/destroyed on the compositor thread. | 63 // is owned/destroyed on the compositor thread. |
| 83 std::unique_ptr<SurfaceManager> surface_manager_; | 64 std::unique_ptr<SurfaceManager> surface_manager_; |
| 84 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_; | 65 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_; |
| 85 SurfaceId delegated_surface_id_; | 66 SurfaceId delegated_surface_id_; |
| 86 | 67 |
| 87 // Uses surface_manager_. | 68 // Uses surface_manager_. |
| 88 std::unique_ptr<SurfaceFactory> surface_factory_; | 69 std::unique_ptr<SurfaceFactory> surface_factory_; |
| 89 | 70 |
| 90 // Uses surface_manager_. | 71 // Uses surface_manager_. |
| 91 std::unique_ptr<Display> display_; | 72 std::unique_ptr<Display> display_; |
| 92 | 73 |
| 93 bool bound_ = false; | 74 bool bound_ = false; |
| 94 TestDelegatingOutputSurfaceClient* test_client_ = nullptr; | |
| 95 | 75 |
| 96 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_; | 76 std::vector<std::unique_ptr<CopyOutputRequest>> copy_requests_; |
| 97 | 77 |
| 98 base::WeakPtrFactory<TestDelegatingOutputSurface> weak_ptrs_; | 78 base::WeakPtrFactory<TestDelegatingOutputSurface> weak_ptrs_; |
| 99 }; | 79 }; |
| 100 | 80 |
| 101 } // namespace cc | 81 } // namespace cc |
| 102 | 82 |
| 103 #endif // CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ | 83 #endif // CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ |
| OLD | NEW |