| 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_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ | 5 #ifndef SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ |
| 6 #define SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ | 6 #define SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "cc/ipc/compositor_frame.mojom.h" | 14 #include "cc/ipc/compositor_frame.mojom.h" |
| 15 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" | 15 #include "cc/ipc/mojo_compositor_frame_sink.mojom.h" |
| 16 #include "cc/output/context_provider.h" | |
| 17 #include "cc/output/in_process_context_provider.h" | |
| 18 #include "cc/scheduler/begin_frame_source.h" | 16 #include "cc/scheduler/begin_frame_source.h" |
| 19 #include "cc/surfaces/display.h" | |
| 20 #include "cc/surfaces/display_client.h" | 17 #include "cc/surfaces/display_client.h" |
| 21 #include "cc/surfaces/frame_sink_id.h" | 18 #include "cc/surfaces/frame_sink_id.h" |
| 22 #include "cc/surfaces/surface_factory.h" | 19 #include "cc/surfaces/surface_factory.h" |
| 23 #include "cc/surfaces/surface_factory_client.h" | 20 #include "cc/surfaces/surface_factory_client.h" |
| 24 #include "cc/surfaces/surface_id.h" | 21 #include "cc/surfaces/surface_id.h" |
| 25 #include "cc/surfaces/surface_id_allocator.h" | 22 #include "cc/surfaces/surface_id_allocator.h" |
| 26 #include "mojo/public/cpp/bindings/binding.h" | 23 #include "mojo/public/cpp/bindings/binding.h" |
| 27 | 24 |
| 28 namespace base { | 25 namespace cc { |
| 29 class SingleThreadTaskRunner; | 26 class Display; |
| 30 } | |
| 31 | |
| 32 namespace gpu { | |
| 33 class GpuMemoryBufferManager; | |
| 34 } | 27 } |
| 35 | 28 |
| 36 namespace ui { | 29 namespace ui { |
| 37 | 30 |
| 38 class DisplayCompositor; | 31 class DisplayCompositor; |
| 39 | 32 |
| 40 // Server side representation of a WindowSurface. | 33 // Server side representation of a WindowSurface. |
| 41 class GpuCompositorFrameSink : public cc::mojom::MojoCompositorFrameSink, | 34 class GpuCompositorFrameSink : public cc::mojom::MojoCompositorFrameSink, |
| 42 public cc::DisplayClient, | 35 public cc::DisplayClient, |
| 43 public cc::mojom::MojoCompositorFrameSinkPrivate, | 36 public cc::mojom::MojoCompositorFrameSinkPrivate, |
| 44 public cc::SurfaceFactoryClient, | 37 public cc::SurfaceFactoryClient, |
| 45 public cc::BeginFrameObserver { | 38 public cc::BeginFrameObserver { |
| 46 public: | 39 public: |
| 47 GpuCompositorFrameSink( | 40 GpuCompositorFrameSink( |
| 48 DisplayCompositor* display_compositor, | 41 DisplayCompositor* display_compositor, |
| 49 const cc::FrameSinkId& frame_sink_id, | 42 const cc::FrameSinkId& frame_sink_id, |
| 50 gpu::SurfaceHandle widget, | 43 std::unique_ptr<cc::Display> display, |
| 51 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
| 52 scoped_refptr<cc::InProcessContextProvider> context_provider, | |
| 53 cc::mojom::MojoCompositorFrameSinkRequest request, | 44 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 54 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, | 45 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, |
| 55 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 46 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
| 56 | 47 |
| 57 ~GpuCompositorFrameSink() override; | 48 ~GpuCompositorFrameSink() override; |
| 58 | 49 |
| 59 // cc::mojom::MojoCompositorFrameSink: | 50 // cc::mojom::MojoCompositorFrameSink: |
| 60 void SetNeedsBeginFrame(bool needs_begin_frame) override; | 51 void SetNeedsBeginFrame(bool needs_begin_frame) override; |
| 61 void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id, | 52 void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id, |
| 62 cc::CompositorFrame frame) override; | 53 cc::CompositorFrame frame) override; |
| 63 | 54 |
| 64 // cc::mojom::MojoCompositorFrameSinkPrivate: | 55 // cc::mojom::MojoCompositorFrameSinkPrivate: |
| 65 void AddChildFrameSink(const cc::FrameSinkId& child_frame_sink_id) override; | 56 void AddChildFrameSink(const cc::FrameSinkId& child_frame_sink_id) override; |
| 66 void RemoveChildFrameSink( | 57 void RemoveChildFrameSink( |
| 67 const cc::FrameSinkId& child_frame_sink_id) override; | 58 const cc::FrameSinkId& child_frame_sink_id) override; |
| 68 | 59 |
| 69 private: | 60 private: |
| 70 void InitDisplay( | |
| 71 gpu::SurfaceHandle widget, | |
| 72 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
| 73 scoped_refptr<cc::InProcessContextProvider> context_provider); | |
| 74 | |
| 75 void DidReceiveCompositorFrameAck(); | 61 void DidReceiveCompositorFrameAck(); |
| 76 | 62 |
| 77 // cc::DisplayClient implementation. | 63 // cc::DisplayClient implementation. |
| 78 void DisplayOutputSurfaceLost() override; | 64 void DisplayOutputSurfaceLost() override; |
| 79 void DisplayWillDrawAndSwap(bool will_draw_and_swap, | 65 void DisplayWillDrawAndSwap(bool will_draw_and_swap, |
| 80 const cc::RenderPassList& render_passes) override; | 66 const cc::RenderPassList& render_passes) override; |
| 81 void DisplayDidDrawAndSwap() override; | 67 void DisplayDidDrawAndSwap() override; |
| 82 | 68 |
| 83 // cc::SurfaceFactoryClient implementation. | 69 // cc::SurfaceFactoryClient implementation. |
| 84 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 70 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 85 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 71 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 86 | 72 |
| 87 // cc::BeginFrameObserver implementation. | 73 // cc::BeginFrameObserver implementation. |
| 88 void OnBeginFrame(const cc::BeginFrameArgs& args) override; | 74 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
| 89 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; | 75 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
| 90 void OnBeginFrameSourcePausedChanged(bool paused) override; | 76 void OnBeginFrameSourcePausedChanged(bool paused) override; |
| 91 | 77 |
| 92 void UpdateNeedsBeginFramesInternal(); | 78 void UpdateNeedsBeginFramesInternal(); |
| 93 | 79 |
| 94 void OnClientConnectionLost(); | 80 void OnClientConnectionLost(); |
| 95 void OnPrivateConnectionLost(); | 81 void OnPrivateConnectionLost(); |
| 96 | 82 |
| 97 const cc::FrameSinkId frame_sink_id_; | 83 const cc::FrameSinkId frame_sink_id_; |
| 98 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 99 | 84 |
| 100 DisplayCompositor* display_compositor_; // owns this. | 85 DisplayCompositor* const display_compositor_; // owns this. |
| 101 | 86 |
| 102 // GpuCompositorFrameSink holds a cc::Display if it created with | 87 // GpuCompositorFrameSink holds a cc::Display if it created with |
| 103 // non-null gpu::SurfaceHandle. In the window server, the display root | 88 // non-null gpu::SurfaceHandle. In the window server, the display root |
| 104 // window's CompositorFrameSink will have a valid gpu::SurfaceHandle. | 89 // window's CompositorFrameSink will have a valid gpu::SurfaceHandle. |
| 105 std::unique_ptr<cc::Display> display_; | 90 std::unique_ptr<cc::Display> display_; |
| 106 | 91 |
| 107 cc::LocalFrameId local_frame_id_; | 92 cc::LocalFrameId local_frame_id_; |
| 108 cc::SurfaceFactory surface_factory_; | 93 cc::SurfaceFactory surface_factory_; |
| 109 // Counts the number of CompositorFrames that have been submitted and have not | 94 // Counts the number of CompositorFrames that have been submitted and have not |
| 110 // yet received an ACK. | 95 // yet received an ACK. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 131 mojo::Binding<cc::mojom::MojoCompositorFrameSinkPrivate> private_binding_; | 116 mojo::Binding<cc::mojom::MojoCompositorFrameSinkPrivate> private_binding_; |
| 132 | 117 |
| 133 base::WeakPtrFactory<GpuCompositorFrameSink> weak_factory_; | 118 base::WeakPtrFactory<GpuCompositorFrameSink> weak_factory_; |
| 134 | 119 |
| 135 DISALLOW_COPY_AND_ASSIGN(GpuCompositorFrameSink); | 120 DISALLOW_COPY_AND_ASSIGN(GpuCompositorFrameSink); |
| 136 }; | 121 }; |
| 137 | 122 |
| 138 } // namespace ui | 123 } // namespace ui |
| 139 | 124 |
| 140 #endif // SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ | 125 #endif // SERVICES_UI_SURFACES_GPU_COMPOSITOR_FRAME_SINK_H_ |
| OLD | NEW |