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