| 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_SURFACE_DISPLAY_OUTPUT_SURFACE_H_ | 5 #ifndef CC_SURFACES_SURFACE_DISPLAY_OUTPUT_SURFACE_H_ |
| 6 #define CC_SURFACES_SURFACE_DISPLAY_OUTPUT_SURFACE_H_ | 6 #define CC_SURFACES_SURFACE_DISPLAY_OUTPUT_SURFACE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/threading/thread_checker.h" |
| 9 #include "cc/output/output_surface.h" | 10 #include "cc/output/output_surface.h" |
| 11 #include "cc/surfaces/display_client.h" |
| 10 #include "cc/surfaces/surface_factory.h" | 12 #include "cc/surfaces/surface_factory.h" |
| 11 #include "cc/surfaces/surface_factory_client.h" | 13 #include "cc/surfaces/surface_factory_client.h" |
| 12 #include "cc/surfaces/surface_id_allocator.h" | |
| 13 #include "cc/surfaces/surfaces_export.h" | 14 #include "cc/surfaces/surfaces_export.h" |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 class Display; | 17 class Display; |
| 17 class OnscreenDisplayClient; | 18 class OnscreenDisplayClient; |
| 19 class SurfaceIdAllocator; |
| 18 class SurfaceManager; | 20 class SurfaceManager; |
| 19 | 21 |
| 20 // This class is maps a compositor OutputSurface to the surface system's Display | 22 // This class is maps a compositor OutputSurface to the surface system's Display |
| 21 // concept, allowing a compositor client to submit frames for a native root | 23 // concept, allowing a compositor client to submit frames for a native root |
| 22 // window or physical display. | 24 // window or physical display. |
| 23 class CC_SURFACES_EXPORT SurfaceDisplayOutputSurface | 25 class CC_SURFACES_EXPORT SurfaceDisplayOutputSurface |
| 24 : public OutputSurface, | 26 : public OutputSurface, |
| 25 public SurfaceFactoryClient { | 27 public SurfaceFactoryClient, |
| 28 public NON_EXPORTED_BASE(DisplayClient) { |
| 26 public: | 29 public: |
| 27 // The underlying Display and SurfaceManager must outlive this class. | 30 // The underlying Display and SurfaceManager must outlive this class. |
| 28 SurfaceDisplayOutputSurface( | 31 SurfaceDisplayOutputSurface( |
| 29 SurfaceManager* surface_manager, | 32 SurfaceManager* surface_manager, |
| 30 SurfaceIdAllocator* allocator, | 33 SurfaceIdAllocator* allocator, |
| 34 Display* display, |
| 31 scoped_refptr<ContextProvider> context_provider, | 35 scoped_refptr<ContextProvider> context_provider, |
| 32 scoped_refptr<ContextProvider> worker_context_provider); | 36 scoped_refptr<ContextProvider> worker_context_provider); |
| 33 SurfaceDisplayOutputSurface( | 37 SurfaceDisplayOutputSurface( |
| 34 SurfaceManager* surface_manager, | 38 SurfaceManager* surface_manager, |
| 35 SurfaceIdAllocator* allocator, | 39 SurfaceIdAllocator* allocator, |
| 40 Display* display, |
| 36 scoped_refptr<VulkanContextProvider> vulkan_context_provider); | 41 scoped_refptr<VulkanContextProvider> vulkan_context_provider); |
| 37 ~SurfaceDisplayOutputSurface() override; | 42 ~SurfaceDisplayOutputSurface() override; |
| 38 | 43 |
| 39 void set_display_client(OnscreenDisplayClient* display_client) { | |
| 40 DCHECK(!display_client_); | |
| 41 display_client_ = display_client; | |
| 42 } | |
| 43 SurfaceFactory* factory() { return &factory_; } | |
| 44 | |
| 45 // OutputSurface implementation. | 44 // OutputSurface implementation. |
| 46 void SwapBuffers(CompositorFrame* frame) override; | 45 void SwapBuffers(CompositorFrame* frame) override; |
| 47 bool BindToClient(OutputSurfaceClient* client) override; | 46 bool BindToClient(OutputSurfaceClient* client) override; |
| 48 void ForceReclaimResources() override; | 47 void ForceReclaimResources() override; |
| 49 void DetachFromClient() override; | 48 void DetachFromClient() override; |
| 50 | 49 |
| 51 // SurfaceFactoryClient implementation. | 50 // SurfaceFactoryClient implementation. |
| 52 void ReturnResources(const ReturnedResourceArray& resources) override; | 51 void ReturnResources(const ReturnedResourceArray& resources) override; |
| 53 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; | 52 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; |
| 54 | 53 |
| 54 // DisplayClient implementation. |
| 55 void DisplayOutputSurfaceLost() override; |
| 56 void DisplaySetMemoryPolicy(const ManagedMemoryPolicy& policy) override; |
| 57 |
| 55 private: | 58 private: |
| 56 void SwapBuffersComplete(SurfaceDrawStatus drawn); | 59 void SwapBuffersComplete(SurfaceDrawStatus drawn); |
| 57 | 60 |
| 58 OnscreenDisplayClient* display_client_; | 61 // This class is only meant to be used on a single thread. |
| 62 base::ThreadChecker thread_checker_; |
| 63 |
| 64 SurfaceManager* surface_manager_; |
| 65 SurfaceIdAllocator* surface_id_allocator_; |
| 66 Display* display_; |
| 59 SurfaceFactory factory_; | 67 SurfaceFactory factory_; |
| 60 gfx::Size display_size_; | 68 SurfaceId delegated_surface_id_; |
| 61 SurfaceId surface_id_; | 69 gfx::Size last_swap_frame_size_; |
| 62 SurfaceIdAllocator* allocator_; | 70 bool output_surface_lost_ = false; |
| 63 | 71 |
| 64 DISALLOW_COPY_AND_ASSIGN(SurfaceDisplayOutputSurface); | 72 DISALLOW_COPY_AND_ASSIGN(SurfaceDisplayOutputSurface); |
| 65 }; | 73 }; |
| 66 | 74 |
| 67 } // namespace cc | 75 } // namespace cc |
| 68 | 76 |
| 69 #endif // CC_SURFACES_SURFACE_DISPLAY_OUTPUT_SURFACE_H_ | 77 #endif // CC_SURFACES_SURFACE_DISPLAY_OUTPUT_SURFACE_H_ |
| OLD | NEW |