| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_H_ | 5 #ifndef SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_H_ |
| 6 #define SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_H_ | 6 #define SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "cc/ipc/compositor_frame.mojom.h" | 11 #include "cc/ipc/compositor_frame.mojom.h" |
| 12 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" | 12 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
| 13 #include "cc/output/context_provider.h" |
| 14 #include "cc/surfaces/display.h" |
| 15 #include "cc/surfaces/display_client.h" |
| 13 #include "cc/surfaces/frame_sink_id.h" | 16 #include "cc/surfaces/frame_sink_id.h" |
| 14 #include "cc/surfaces/surface_factory.h" | 17 #include "cc/surfaces/surface_factory.h" |
| 15 #include "cc/surfaces/surface_factory_client.h" | 18 #include "cc/surfaces/surface_factory_client.h" |
| 16 #include "cc/surfaces/surface_id.h" | 19 #include "cc/surfaces/surface_id.h" |
| 17 #include "cc/surfaces/surface_id_allocator.h" | 20 #include "cc/surfaces/surface_id_allocator.h" |
| 18 #include "mojo/public/cpp/bindings/binding.h" | 21 #include "mojo/public/cpp/bindings/binding.h" |
| 19 #include "services/ui/public/interfaces/window_tree.mojom.h" | 22 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 20 #include "services/ui/ws/ids.h" | 23 #include "services/ui/ws/ids.h" |
| 21 | 24 |
| 25 namespace gpu { |
| 26 class GpuMemoryBufferManager; |
| 27 } |
| 28 |
| 22 namespace ui { | 29 namespace ui { |
| 23 | 30 |
| 24 class DisplayCompositor; | 31 class DisplayCompositor; |
| 25 | 32 |
| 26 namespace ws { | 33 namespace ws { |
| 27 | 34 |
| 28 class ServerWindow; | 35 class ServerWindow; |
| 29 class ServerWindowCompositorFrameSinkManager; | 36 class ServerWindowCompositorFrameSinkManager; |
| 30 | 37 |
| 31 // Server side representation of a WindowSurface. | 38 // Server side representation of a WindowSurface. |
| 32 class ServerWindowCompositorFrameSink | 39 class ServerWindowCompositorFrameSink |
| 33 : public cc::mojom::MojoCompositorFrameSink, | 40 : public cc::mojom::MojoCompositorFrameSink, |
| 41 public cc::DisplayClient, |
| 34 public cc::SurfaceFactoryClient { | 42 public cc::SurfaceFactoryClient { |
| 35 public: | 43 public: |
| 36 ServerWindowCompositorFrameSink( | 44 ServerWindowCompositorFrameSink( |
| 37 ServerWindowCompositorFrameSinkManager* manager, | 45 ServerWindowCompositorFrameSinkManager* manager, |
| 38 const cc::FrameSinkId& frame_sink_id, | 46 const cc::FrameSinkId& frame_sink_id, |
| 47 gfx::AcceleratedWidget widget, |
| 48 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 49 scoped_refptr<cc::ContextProvider> context_provider, |
| 39 cc::mojom::MojoCompositorFrameSinkRequest request, | 50 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 40 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 51 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
| 41 | 52 |
| 42 ~ServerWindowCompositorFrameSink() override; | 53 ~ServerWindowCompositorFrameSink() override; |
| 43 | 54 |
| 44 // cc::mojom::MojoCompositorFrameSink: | 55 // cc::mojom::MojoCompositorFrameSink: |
| 45 void SetNeedsBeginFrame(bool needs_begin_frame) override; | 56 void SetNeedsBeginFrame(bool needs_begin_frame) override; |
| 46 void SubmitCompositorFrame(cc::CompositorFrame frame) override; | 57 void SubmitCompositorFrame(cc::CompositorFrame frame) override; |
| 47 | 58 |
| 48 private: | 59 private: |
| 60 void InitDisplay(gfx::AcceleratedWidget widget, |
| 61 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 62 scoped_refptr<cc::ContextProvider> context_provider); |
| 63 |
| 49 void DidReceiveCompositorFrameAck(); | 64 void DidReceiveCompositorFrameAck(); |
| 50 | 65 |
| 66 // DisplayClient implementation. |
| 67 void DisplayOutputSurfaceLost() override; |
| 68 void DisplayWillDrawAndSwap(bool will_draw_and_swap, |
| 69 const cc::RenderPassList& render_passes) override; |
| 70 void DisplayDidDrawAndSwap() override; |
| 71 |
| 51 // SurfaceFactoryClient implementation. | 72 // SurfaceFactoryClient implementation. |
| 52 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 73 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 53 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 74 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 54 | 75 |
| 55 const cc::FrameSinkId frame_sink_id_; | 76 const cc::FrameSinkId frame_sink_id_; |
| 77 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 56 | 78 |
| 57 ServerWindowCompositorFrameSinkManager* manager_; // Owns this. | 79 ServerWindowCompositorFrameSinkManager* manager_; // Owns this. |
| 58 | 80 |
| 59 gfx::Size last_submitted_frame_size_; | 81 gfx::Size last_submitted_frame_size_; |
| 82 std::unique_ptr<cc::Display> display_; |
| 60 | 83 |
| 61 cc::LocalFrameId local_frame_id_; | 84 cc::LocalFrameId local_frame_id_; |
| 62 cc::SurfaceIdAllocator surface_id_allocator_; | 85 cc::SurfaceIdAllocator surface_id_allocator_; |
| 63 cc::SurfaceFactory surface_factory_; | 86 cc::SurfaceFactory surface_factory_; |
| 64 | 87 |
| 65 cc::mojom::MojoCompositorFrameSinkClientPtr client_; | 88 cc::mojom::MojoCompositorFrameSinkClientPtr client_; |
| 66 mojo::Binding<MojoCompositorFrameSink> binding_; | 89 mojo::Binding<MojoCompositorFrameSink> binding_; |
| 67 | 90 |
| 68 DISALLOW_COPY_AND_ASSIGN(ServerWindowCompositorFrameSink); | 91 DISALLOW_COPY_AND_ASSIGN(ServerWindowCompositorFrameSink); |
| 69 }; | 92 }; |
| 70 | 93 |
| 71 } // namespace ws | 94 } // namespace ws |
| 72 | 95 |
| 73 } // namespace ui | 96 } // namespace ui |
| 74 | 97 |
| 75 #endif // SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_H_ | 98 #endif // SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_H_ |
| OLD | NEW |