Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_COMPOSITOR_FRAME_SINK_SUPPORT_H_ | 5 #ifndef CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
| 6 #define CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ | 6 #define CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <unordered_set> | 9 #include <unordered_set> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "cc/output/compositor_frame.h" | 13 #include "cc/output/compositor_frame.h" |
| 14 #include "cc/scheduler/begin_frame_source.h" | 14 #include "cc/scheduler/begin_frame_source.h" |
| 15 #include "cc/surfaces/display.h" | |
| 16 #include "cc/surfaces/display_client.h" | |
| 17 #include "cc/surfaces/referenced_surface_tracker.h" | 15 #include "cc/surfaces/referenced_surface_tracker.h" |
| 18 #include "cc/surfaces/surface_factory.h" | 16 #include "cc/surfaces/surface_factory.h" |
| 19 #include "cc/surfaces/surface_factory_client.h" | 17 #include "cc/surfaces/surface_factory_client.h" |
| 20 #include "cc/surfaces/surface_id.h" | 18 #include "cc/surfaces/surface_id.h" |
| 21 #include "cc/surfaces/surfaces_export.h" | 19 #include "cc/surfaces/surfaces_export.h" |
| 22 | 20 |
| 23 namespace cc { | 21 namespace cc { |
| 24 | 22 |
| 25 class CompositorFrameSinkSupportClient; | 23 class CompositorFrameSinkSupportClient; |
| 26 class Display; | |
| 27 class SurfaceManager; | 24 class SurfaceManager; |
| 28 | 25 |
| 29 class CC_SURFACES_EXPORT CompositorFrameSinkSupport | 26 class CC_SURFACES_EXPORT CompositorFrameSinkSupport |
| 30 : public NON_EXPORTED_BASE(DisplayClient), | 27 : public SurfaceFactoryClient, |
| 31 public SurfaceFactoryClient, | |
| 32 public BeginFrameObserver { | 28 public BeginFrameObserver { |
| 33 public: | 29 public: |
| 34 // |display| is nullptr if the CompositorFrameSinkSupport submits | |
| 35 // CompositorFrames to a offscreen texutre/bitmap instead of a | |
| 36 // DisplayCompositor. e.g. OffscreenCanvasCompositorFrameSink and | |
| 37 // GpuOffscreenCompositorFrameSink. | |
| 38 CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client, | 30 CompositorFrameSinkSupport(CompositorFrameSinkSupportClient* client, |
| 39 SurfaceManager* surface_manager, | 31 SurfaceManager* surface_manager, |
| 40 const FrameSinkId& frame_sink_id, | 32 const FrameSinkId& frame_sink_id, |
| 41 Display* display, | |
| 42 bool handles_frame_sink_id_invalidation, | 33 bool handles_frame_sink_id_invalidation, |
| 43 bool needs_sync_points); | 34 bool needs_sync_points, |
| 35 bool submits_to_display_compositor); | |
| 44 | 36 |
| 45 ~CompositorFrameSinkSupport() override; | 37 ~CompositorFrameSinkSupport() override; |
| 46 | 38 |
| 47 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } | 39 const FrameSinkId& frame_sink_id() const { return frame_sink_id_; } |
| 48 | 40 |
| 49 void EvictFrame(); | 41 void EvictFrame(); |
| 50 void SetNeedsBeginFrame(bool needs_begin_frame); | 42 void SetNeedsBeginFrame(bool needs_begin_frame); |
| 51 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, | 43 void SubmitCompositorFrame(const LocalSurfaceId& local_surface_id, |
| 52 CompositorFrame frame); | 44 CompositorFrame frame); |
| 53 void Require(const LocalSurfaceId& local_surface_id, | 45 void Require(const LocalSurfaceId& local_surface_id, |
| 54 const SurfaceSequence& sequence); | 46 const SurfaceSequence& sequence); |
| 55 void Satisfy(const SurfaceSequence& sequence); | 47 void Satisfy(const SurfaceSequence& sequence); |
| 56 void AddChildFrameSink(const FrameSinkId& child_frame_sink_id); | 48 void AddChildFrameSink(const FrameSinkId& child_frame_sink_id); |
| 57 void RemoveChildFrameSink(const FrameSinkId& child_frame_sink_id); | 49 void RemoveChildFrameSink(const FrameSinkId& child_frame_sink_id); |
| 58 void ForceReclaimResources(); | 50 void ForceReclaimResources(); |
| 59 | 51 |
| 60 Display* display() { return display_; } | |
| 61 | |
| 62 private: | 52 private: |
| 63 // Update surface references with SurfaceManager for current CompositorFrame | 53 // Update surface references with SurfaceManager for current CompositorFrame |
| 64 // that has |local_surface_id|. UpdateReferences() must be called on | 54 // that has |local_surface_id|. UpdateReferences() must be called on |
| 65 // |reference_tracker_| before calling this. Will add and remove top-level | 55 // |reference_tracker_| before calling this. Will add and remove top-level |
| 66 // root references if |display_| is not null. | 56 // root references if |display_| is not null. |
| 67 void UpdateSurfaceReferences(const SurfaceId& last_surface_id, | 57 void UpdateSurfaceReferences(const SurfaceId& last_surface_id, |
| 68 const LocalSurfaceId& local_surface_id); | 58 const LocalSurfaceId& local_surface_id); |
| 69 | 59 |
| 70 void AddTopLevelRootReference(const SurfaceId& surface_id); | 60 void AddTopLevelRootReference(const SurfaceId& surface_id); |
| 71 void RemoveTopLevelRootReference(const SurfaceId& surface_id); | 61 void RemoveTopLevelRootReference(const SurfaceId& surface_id); |
| 72 | 62 |
| 73 void DidReceiveCompositorFrameAck(); | 63 void DidReceiveCompositorFrameAck(); |
| 74 | 64 |
| 75 // DisplayClient implementation. | |
| 76 void DisplayOutputSurfaceLost() override; | |
| 77 void DisplayWillDrawAndSwap(bool will_draw_and_swap, | |
| 78 const RenderPassList& render_passes) override; | |
| 79 void DisplayDidDrawAndSwap() override; | |
| 80 | |
| 81 // SurfaceFactoryClient implementation. | 65 // SurfaceFactoryClient implementation. |
| 82 void ReturnResources(const ReturnedResourceArray& resources) override; | 66 void ReturnResources(const ReturnedResourceArray& resources) override; |
| 83 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; | 67 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override; |
| 84 void WillDrawSurface(const LocalSurfaceId& local_surface_id, | 68 void WillDrawSurface(const LocalSurfaceId& local_surface_id, |
| 85 const gfx::Rect& damage_rect) override; | 69 const gfx::Rect& damage_rect) override; |
| 86 | 70 |
| 87 // BeginFrameObserver implementation. | 71 // BeginFrameObserver implementation. |
| 88 void OnBeginFrame(const BeginFrameArgs& args) override; | 72 void OnBeginFrame(const BeginFrameArgs& args) override; |
| 89 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; | 73 const BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
| 90 void OnBeginFrameSourcePausedChanged(bool paused) override; | 74 void OnBeginFrameSourcePausedChanged(bool paused) override; |
| 91 | 75 |
| 92 void UpdateNeedsBeginFramesInternal(); | 76 void UpdateNeedsBeginFramesInternal(); |
| 93 | 77 |
| 94 CompositorFrameSinkSupportClient* const client_; | 78 CompositorFrameSinkSupportClient* const client_; |
| 95 | 79 |
| 96 SurfaceManager* const surface_manager_; | 80 SurfaceManager* const surface_manager_; |
| 97 const FrameSinkId frame_sink_id_; | 81 const FrameSinkId frame_sink_id_; |
| 98 Display* const display_; | |
| 99 | 82 |
| 100 SurfaceFactory surface_factory_; | 83 SurfaceFactory surface_factory_; |
| 101 // Counts the number of CompositorFrames that have been submitted and have not | 84 // Counts the number of CompositorFrames that have been submitted and have not |
| 102 // yet received an ACK. | 85 // yet received an ACK. |
| 103 int ack_pending_count_ = 0; | 86 int ack_pending_count_ = 0; |
| 104 ReturnedResourceArray surface_returned_resources_; | 87 ReturnedResourceArray surface_returned_resources_; |
| 105 | 88 |
| 106 // The begin frame source being observered. Null if none. | 89 // The begin frame source being observered. Null if none. |
| 107 BeginFrameSource* begin_frame_source_ = nullptr; | 90 BeginFrameSource* begin_frame_source_ = nullptr; |
| 108 | 91 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 127 // goes away and we can remove this bool. | 110 // goes away and we can remove this bool. |
| 128 const bool handles_frame_sink_id_invalidation_; | 111 const bool handles_frame_sink_id_invalidation_; |
| 129 | 112 |
| 130 // Track the surface references for the surface corresponding to this | 113 // Track the surface references for the surface corresponding to this |
| 131 // compositor frame sink. | 114 // compositor frame sink. |
| 132 ReferencedSurfaceTracker reference_tracker_; | 115 ReferencedSurfaceTracker reference_tracker_; |
| 133 | 116 |
| 134 // The set of BeginFrame children of this CompositorFrameSink. | 117 // The set of BeginFrame children of this CompositorFrameSink. |
| 135 std::unordered_set<FrameSinkId, FrameSinkIdHash> child_frame_sinks_; | 118 std::unordered_set<FrameSinkId, FrameSinkIdHash> child_frame_sinks_; |
| 136 | 119 |
| 120 // |submits_to_display_compositor_| is true if the CompositorFrameSinkSupport | |
| 121 // submits CompositorFrames to a DisplayCompositor. It is false if | |
| 122 // CompositorFrameSinkSupport submits CompositorFrames to an offscreen | |
| 123 // texture/bitmap. (e.g. OffscreenCanvasCompositorFrameSink and | |
|
danakj
2017/02/08 21:54:40
These class names may become stale and I think the
Alex Z.
2017/02/08 22:07:52
Done.
| |
| 124 // GpuOffscreenCompositorFrameSink) | |
| 125 const bool submits_to_display_compositor_; | |
| 126 | |
| 137 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; | 127 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; |
| 138 | 128 |
| 139 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); | 129 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); |
| 140 }; | 130 }; |
| 141 | 131 |
| 142 } // namespace cc | 132 } // namespace cc |
| 143 | 133 |
| 144 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ | 134 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
| OLD | NEW |