| 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_PIXEL_TEST_DELEGATING_OUTPUT_SURFACE_H_ | 5 #ifndef CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ |
| 6 #define CC_TEST_PIXEL_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 PixelTestDelegatingOutputSurface : public OutputSurface, | 21 class TestDelegatingOutputSurface : public OutputSurface, |
| 22 public SurfaceFactoryClient { | 22 public SurfaceFactoryClient { |
| 23 public: | 23 public: |
| 24 PixelTestDelegatingOutputSurface( | 24 TestDelegatingOutputSurface( |
| 25 scoped_refptr<ContextProvider> compositor_context_provider, | 25 scoped_refptr<ContextProvider> compositor_context_provider, |
| 26 scoped_refptr<ContextProvider> worker_context_provider, | 26 scoped_refptr<ContextProvider> worker_context_provider, |
| 27 scoped_refptr<ContextProvider> display_context_provider, | 27 std::unique_ptr<Display> display, |
| 28 const RendererSettings& renderer_settings, | 28 bool context_shared_with_compositor, |
| 29 SharedBitmapManager* shared_bitmap_manager, | 29 bool allow_force_reclaim_resources); |
| 30 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 30 ~TestDelegatingOutputSurface() override; |
| 31 const gfx::Size& surface_expansion_size, | |
| 32 bool allow_force_reclaim_resources, | |
| 33 bool synchronous_composite); | |
| 34 ~PixelTestDelegatingOutputSurface() override; | |
| 35 | 31 |
| 36 // OutputSurface implementation. | 32 // OutputSurface implementation. |
| 37 bool BindToClient(OutputSurfaceClient* client) override; | 33 bool BindToClient(OutputSurfaceClient* client) override; |
| 38 void DetachFromClient() override; | 34 void DetachFromClient() override; |
| 39 void SwapBuffers(CompositorFrame frame) override; | 35 void SwapBuffers(CompositorFrame frame) override; |
| 40 void ForceReclaimResources() override; | 36 void ForceReclaimResources() override; |
| 41 void BindFramebuffer() override; | 37 void BindFramebuffer() override; |
| 42 uint32_t GetFramebufferCopyTextureFormat() override; | 38 uint32_t GetFramebufferCopyTextureFormat() override; |
| 43 | 39 |
| 44 // SurfaceFactoryClient implementation. | 40 // SurfaceFactoryClient implementation. |
| 45 void ReturnResources(const ReturnedResourceArray& resources) override; | 41 void ReturnResources(const ReturnedResourceArray& resources) override; |
| 46 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; | 42 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; |
| 47 | 43 |
| 48 // Allow tests to enlarge the backing texture for a non-root render pass, to | |
| 49 // simulate reusing a larger texture from a previous frame for a new | |
| 50 // render pass. This should be called before the output surface is bound. | |
| 51 void SetEnlargePassTextureAmount(const gfx::Size& amount); | |
| 52 | |
| 53 private: | 44 private: |
| 54 void DrawCallback(SurfaceDrawStatus); | 45 void DrawCallback(SurfaceDrawStatus); |
| 55 | 46 |
| 56 class PixelTestDisplayClient : public DisplayClient { | 47 class PixelTestDisplayClient : public DisplayClient { |
| 57 void DisplayOutputSurfaceLost() override {} | 48 void DisplayOutputSurfaceLost() override {} |
| 58 void DisplaySetMemoryPolicy(const ManagedMemoryPolicy& policy) override {} | 49 void DisplaySetMemoryPolicy(const ManagedMemoryPolicy& policy) override {} |
| 59 }; | 50 }; |
| 60 | 51 |
| 61 SharedBitmapManager* const shared_bitmap_manager_; | |
| 62 gpu::GpuMemoryBufferManager* const gpu_memory_buffer_manager_; | |
| 63 const gfx::Size surface_expansion_size_; | |
| 64 const bool allow_force_reclaim_resources_; | |
| 65 const bool synchronous_composite_; | |
| 66 const RendererSettings renderer_settings_; | |
| 67 | |
| 68 // Passed to the Display. | |
| 69 scoped_refptr<ContextProvider> display_context_provider_; | |
| 70 | |
| 71 gfx::Size enlarge_pass_texture_amount_; | |
| 72 | |
| 73 // TODO(danakj): These don't to be stored in unique_ptrs when OutputSurface | 52 // TODO(danakj): These don't to be stored in unique_ptrs when OutputSurface |
| 74 // is owned/destroyed on the compositor thread. | 53 // is owned/destroyed on the compositor thread. |
| 75 std::unique_ptr<SurfaceManager> surface_manager_; | 54 std::unique_ptr<SurfaceManager> surface_manager_; |
| 76 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_; | 55 std::unique_ptr<SurfaceIdAllocator> surface_id_allocator_; |
| 77 SurfaceId delegated_surface_id_; | 56 SurfaceId delegated_surface_id_; |
| 78 | 57 |
| 79 // Uses surface_manager_. | 58 // Uses surface_manager_. |
| 80 std::unique_ptr<SurfaceFactory> surface_factory_; | 59 std::unique_ptr<SurfaceFactory> surface_factory_; |
| 81 | 60 |
| 82 PixelTestDisplayClient display_client_; | 61 PixelTestDisplayClient display_client_; |
| 83 // Uses surface_manager_. | 62 // Uses surface_manager_. |
| 84 std::unique_ptr<Display> display_; | 63 std::unique_ptr<Display> display_; |
| 85 | 64 |
| 86 base::WeakPtrFactory<PixelTestDelegatingOutputSurface> weak_ptrs_; | 65 base::WeakPtrFactory<TestDelegatingOutputSurface> weak_ptrs_; |
| 87 }; | 66 }; |
| 88 | 67 |
| 89 } // namespace cc | 68 } // namespace cc |
| 90 | 69 |
| 91 #endif // CC_TEST_PIXEL_TEST_DELEGATING_OUTPUT_SURFACE_H_ | 70 #endif // CC_TEST_TEST_DELEGATING_OUTPUT_SURFACE_H_ |
| OLD | NEW |