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