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