| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SURFACES_DIRECT_COMPOSITOR_FRAME_SINK_H_ | 5 #ifndef CC_SURFACES_DIRECT_COMPOSITOR_FRAME_SINK_H_ |
| 6 #define CC_SURFACES_DIRECT_COMPOSITOR_FRAME_SINK_H_ | 6 #define CC_SURFACES_DIRECT_COMPOSITOR_FRAME_SINK_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
| 10 #include "cc/output/compositor_frame_sink.h" | 10 #include "cc/output/compositor_frame_sink.h" |
| 11 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 12 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
| 11 #include "cc/surfaces/display_client.h" | 13 #include "cc/surfaces/display_client.h" |
| 12 #include "cc/surfaces/surface_factory.h" | 14 #include "cc/surfaces/surface_factory.h" |
| 13 #include "cc/surfaces/surface_factory_client.h" | 15 #include "cc/surfaces/surface_factory_client.h" |
| 14 #include "cc/surfaces/surface_id_allocator.h" | 16 #include "cc/surfaces/surface_id_allocator.h" |
| 15 #include "cc/surfaces/surfaces_export.h" | 17 #include "cc/surfaces/surfaces_export.h" |
| 16 | 18 |
| 17 namespace cc { | 19 namespace cc { |
| 18 class Display; | 20 class Display; |
| 19 class SurfaceIdAllocator; | 21 class SurfaceIdAllocator; |
| 20 class SurfaceManager; | 22 class SurfaceManager; |
| 21 | 23 |
| 22 // This class submits compositor frames to an in-process Display, with the | 24 // This class submits compositor frames to an in-process Display, with the |
| 23 // client's frame being the root surface of the Display. | 25 // client's frame being the root surface of the Display. |
| 24 class CC_SURFACES_EXPORT DirectCompositorFrameSink | 26 class CC_SURFACES_EXPORT DirectCompositorFrameSink |
| 25 : public CompositorFrameSink, | 27 : public CompositorFrameSink, |
| 26 public SurfaceFactoryClient, | 28 public NON_EXPORTED_BASE(DisplayClient), |
| 27 public NON_EXPORTED_BASE(DisplayClient) { | 29 public CompositorFrameSinkSupportClient { |
| 28 public: | 30 public: |
| 29 // The underlying Display, SurfaceManager, and SurfaceIdAllocator must outlive | 31 // The underlying Display, SurfaceManager, and SurfaceIdAllocator must outlive |
| 30 // this class. | 32 // this class. |
| 31 DirectCompositorFrameSink( | 33 DirectCompositorFrameSink( |
| 32 const FrameSinkId& frame_sink_id, | 34 const FrameSinkId& frame_sink_id, |
| 33 SurfaceManager* surface_manager, | 35 SurfaceManager* surface_manager, |
| 34 Display* display, | 36 Display* display, |
| 35 scoped_refptr<ContextProvider> context_provider, | 37 scoped_refptr<ContextProvider> context_provider, |
| 36 scoped_refptr<ContextProvider> worker_context_provider, | 38 scoped_refptr<ContextProvider> worker_context_provider, |
| 37 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 39 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 38 SharedBitmapManager* shared_bitmap_manager); | 40 SharedBitmapManager* shared_bitmap_manager); |
| 39 DirectCompositorFrameSink( | 41 DirectCompositorFrameSink( |
| 40 const FrameSinkId& frame_sink_id, | 42 const FrameSinkId& frame_sink_id, |
| 41 SurfaceManager* surface_manager, | 43 SurfaceManager* surface_manager, |
| 42 Display* display, | 44 Display* display, |
| 43 scoped_refptr<VulkanContextProvider> vulkan_context_provider); | 45 scoped_refptr<VulkanContextProvider> vulkan_context_provider); |
| 44 ~DirectCompositorFrameSink() override; | 46 ~DirectCompositorFrameSink() override; |
| 45 | 47 |
| 46 // CompositorFrameSink implementation. | 48 // CompositorFrameSink implementation. |
| 47 bool BindToClient(CompositorFrameSinkClient* client) override; | 49 bool BindToClient(CompositorFrameSinkClient* client) override; |
| 48 void DetachFromClient() override; | 50 void DetachFromClient() override; |
| 49 void SubmitCompositorFrame(CompositorFrame frame) override; | 51 void SubmitCompositorFrame(CompositorFrame frame) override; |
| 50 void ForceReclaimResources() override; | 52 void ForceReclaimResources() override; |
| 51 | 53 |
| 52 // SurfaceFactoryClient implementation. | |
| 53 void ReturnResources(const ReturnedResourceArray& resources) override; | |
| 54 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; | |
| 55 | |
| 56 // DisplayClient implementation. | 54 // DisplayClient implementation. |
| 57 void DisplayOutputSurfaceLost() override; | 55 void DisplayOutputSurfaceLost() override; |
| 58 void DisplayWillDrawAndSwap(bool will_draw_and_swap, | 56 void DisplayWillDrawAndSwap(bool will_draw_and_swap, |
| 59 const RenderPassList& render_passes) override; | 57 const RenderPassList& render_passes) override; |
| 60 void DisplayDidDrawAndSwap() override; | 58 void DisplayDidDrawAndSwap() override; |
| 61 | 59 |
| 60 // CompositorFrameSinkSupportClient implementation: |
| 61 void DidReceiveCompositorFrameAck() override; |
| 62 void OnBeginFrame(const BeginFrameArgs& args) override; |
| 63 void ReclaimResources(const ReturnedResourceArray& resources) override; |
| 64 void WillDrawSurface() override; |
| 65 |
| 62 private: | 66 private: |
| 63 void DidDrawCallback(); | 67 void DidDrawCallback(); |
| 64 | 68 |
| 65 // This class is only meant to be used on a single thread. | 69 // This class is only meant to be used on a single thread. |
| 66 base::ThreadChecker thread_checker_; | 70 base::ThreadChecker thread_checker_; |
| 67 | 71 |
| 68 const FrameSinkId frame_sink_id_; | 72 const FrameSinkId frame_sink_id_; |
| 69 LocalFrameId delegated_local_frame_id_; | 73 LocalFrameId delegated_local_frame_id_; |
| 70 SurfaceManager* surface_manager_; | 74 SurfaceManager* surface_manager_; |
| 71 SurfaceIdAllocator surface_id_allocator_; | 75 SurfaceIdAllocator surface_id_allocator_; |
| 72 Display* display_; | 76 Display* display_; |
| 73 SurfaceFactory factory_; | |
| 74 gfx::Size last_swap_frame_size_; | 77 gfx::Size last_swap_frame_size_; |
| 75 bool is_lost_ = false; | 78 bool is_lost_ = false; |
| 76 | 79 |
| 80 std::unique_ptr<CompositorFrameSinkSupport> support_; |
| 81 |
| 77 DISALLOW_COPY_AND_ASSIGN(DirectCompositorFrameSink); | 82 DISALLOW_COPY_AND_ASSIGN(DirectCompositorFrameSink); |
| 78 }; | 83 }; |
| 79 | 84 |
| 80 } // namespace cc | 85 } // namespace cc |
| 81 | 86 |
| 82 #endif // CC_SURFACES_DIRECT_COMPOSITOR_FRAME_SINK_H_ | 87 #endif // CC_SURFACES_DIRECT_COMPOSITOR_FRAME_SINK_H_ |
| OLD | NEW |