OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
| 6 #define CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/scheduler/begin_frame_source.h" |
| 11 #include "cc/surfaces/display.h" |
| 12 #include "cc/surfaces/display_client.h" |
| 13 #include "cc/surfaces/surface_factory.h" |
| 14 #include "cc/surfaces/surface_factory_client.h" |
| 15 #include "cc/surfaces/surfaces_export.h" |
| 16 |
| 17 namespace cc { |
| 18 |
| 19 class CompositorFrameSinkSupportClient; |
| 20 class Display; |
| 21 class SurfaceManager; |
| 22 |
| 23 class CC_SURFACES_EXPORT CompositorFrameSinkSupport |
| 24 : public DisplayClient, |
| 25 public SurfaceFactoryClient, |
| 26 public BeginFrameObserver { |
| 27 public: |
| 28 CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client, |
| 29 SurfaceManager* surface_manager, |
| 30 const FrameSinkId& frame_sink_id, |
| 31 std::unique_ptr<Display> display); |
| 32 |
| 33 ~CompositorFrameSinkSupport() override; |
| 34 |
| 35 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
| 36 |
| 37 void SetNeedsBeginFrame(bool needs_begin_frame); |
| 38 void SubmitCompositorFrame(const LocalFrameId& local_frame_id, |
| 39 CompositorFrame frame); |
| 40 void AddChildFrameSink(const FrameSinkId& child_frame_sink_id); |
| 41 void RemoveChildFrameSink(const FrameSinkId& child_frame_sink_id); |
| 42 |
| 43 private: |
| 44 void DidReceiveCompositorFrameAck(); |
| 45 |
| 46 // DisplayClient implementation. |
| 47 void DisplayOutputSurfaceLost() override; |
| 48 void DisplayWillDrawAndSwap(bool will_draw_and_swap, |
| 49 const RenderPassList& render_passes) override; |
| 50 void DisplayDidDrawAndSwap() override; |
| 51 |
| 52 // SurfaceFactoryClient implementation. |
| 53 void ReturnResources(const ReturnedResourceArray& resources) override; |
| 54 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; |
| 55 |
| 56 // BeginFrameObserver implementation. |
| 57 void OnBeginFrame(const BeginFrameArgs& args) override; |
| 58 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
| 59 void OnBeginFrameSourcePausedChanged(bool paused) override; |
| 60 |
| 61 void UpdateNeedsBeginFramesInternal(); |
| 62 |
| 63 CompositorFrameSinkSupportClient* const client_; |
| 64 |
| 65 SurfaceManager* const surface_manager_; |
| 66 |
| 67 const FrameSinkId frame_sink_id_; |
| 68 |
| 69 // GpuCompositorFrameSink holds a Display if it created with |
| 70 // non-null gpu::SurfaceHandle. In the window server, the display root |
| 71 // window's CompositorFrameSink will have a valid gpu::SurfaceHandle. |
| 72 std::unique_ptr<Display> display_; |
| 73 |
| 74 LocalFrameId local_frame_id_; |
| 75 SurfaceFactory surface_factory_; |
| 76 // Counts the number of CompositorFrames that have been submitted and have not |
| 77 // yet received an ACK. |
| 78 int ack_pending_count_ = 0; |
| 79 ReturnedResourceArray surface_returned_resources_; |
| 80 |
| 81 // The begin frame source being observered. Null if none. |
| 82 BeginFrameSource* begin_frame_source_ = nullptr; |
| 83 |
| 84 // The last begin frame args generated by the begin frame source. |
| 85 BeginFrameArgs last_begin_frame_args_; |
| 86 |
| 87 // Whether a request for begin frames has been issued. |
| 88 bool needs_begin_frame_ = false; |
| 89 |
| 90 // Whether or not a frame observer has been added. |
| 91 bool added_frame_observer_ = false; |
| 92 |
| 93 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; |
| 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); |
| 96 }; |
| 97 |
| 98 } // namespace cc |
| 99 |
| 100 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
OLD | NEW |