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