| 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> | |
| 9 #include <unordered_set> | |
| 10 | |
| 11 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 12 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 13 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| 14 #include "cc/scheduler/begin_frame_source.h" | 11 #include "cc/scheduler/begin_frame_source.h" |
| 15 #include "cc/surfaces/display.h" | 12 #include "cc/surfaces/display.h" |
| 16 #include "cc/surfaces/display_client.h" | 13 #include "cc/surfaces/display_client.h" |
| 17 #include "cc/surfaces/referenced_surface_tracker.h" | |
| 18 #include "cc/surfaces/surface_factory.h" | 14 #include "cc/surfaces/surface_factory.h" |
| 19 #include "cc/surfaces/surface_factory_client.h" | 15 #include "cc/surfaces/surface_factory_client.h" |
| 20 #include "cc/surfaces/surface_id.h" | |
| 21 #include "cc/surfaces/surfaces_export.h" | 16 #include "cc/surfaces/surfaces_export.h" |
| 22 | 17 |
| 23 namespace cc { | 18 namespace cc { |
| 24 | 19 |
| 25 class CompositorFrameSinkSupportClient; | 20 class CompositorFrameSinkSupportClient; |
| 26 class Display; | 21 class Display; |
| 27 class SurfaceManager; | 22 class SurfaceManager; |
| 28 | 23 |
| 29 class CC_SURFACES_EXPORT CompositorFrameSinkSupport | 24 class CC_SURFACES_EXPORT CompositorFrameSinkSupport |
| 30 : public NON_EXPORTED_BASE(DisplayClient), | 25 : public NON_EXPORTED_BASE(DisplayClient), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 void Require(const LocalSurfaceId& local_surface_id, | 48 void Require(const LocalSurfaceId& local_surface_id, |
| 54 const SurfaceSequence& sequence); | 49 const SurfaceSequence& sequence); |
| 55 void Satisfy(const SurfaceSequence& sequence); | 50 void Satisfy(const SurfaceSequence& sequence); |
| 56 void AddChildFrameSink(const FrameSinkId& child_frame_sink_id); | 51 void AddChildFrameSink(const FrameSinkId& child_frame_sink_id); |
| 57 void RemoveChildFrameSink(const FrameSinkId& child_frame_sink_id); | 52 void RemoveChildFrameSink(const FrameSinkId& child_frame_sink_id); |
| 58 void ForceReclaimResources(); | 53 void ForceReclaimResources(); |
| 59 | 54 |
| 60 Display* display() { return display_; } | 55 Display* display() { return display_; } |
| 61 | 56 |
| 62 private: | 57 private: |
| 63 // Update surface references with SurfaceManager for current CompositorFrame | |
| 64 // that has |local_surface_id|. UpdateReferences() must be called on | |
| 65 // |reference_tracker_| before calling this. Will add and remove top-level | |
| 66 // root references if |display_| is not null. | |
| 67 void UpdateSurfaceReferences(const SurfaceId& last_surface_id, | |
| 68 const LocalSurfaceId& local_surface_id); | |
| 69 | |
| 70 void AddTopLevelRootReference(const SurfaceId& surface_id); | |
| 71 void RemoveTopLevelRootReference(const SurfaceId& surface_id); | |
| 72 | |
| 73 void DidReceiveCompositorFrameAck(); | 58 void DidReceiveCompositorFrameAck(); |
| 74 | 59 |
| 75 // DisplayClient implementation. | 60 // DisplayClient implementation. |
| 76 void DisplayOutputSurfaceLost() override; | 61 void DisplayOutputSurfaceLost() override; |
| 77 void DisplayWillDrawAndSwap(bool will_draw_and_swap, | 62 void DisplayWillDrawAndSwap(bool will_draw_and_swap, |
| 78 const RenderPassList& render_passes) override; | 63 const RenderPassList& render_passes) override; |
| 79 void DisplayDidDrawAndSwap() override; | 64 void DisplayDidDrawAndSwap() override; |
| 80 | 65 |
| 81 // SurfaceFactoryClient implementation. | 66 // SurfaceFactoryClient implementation. |
| 82 void ReturnResources(const ReturnedResourceArray& resources) override; | 67 void ReturnResources(const ReturnedResourceArray& resources) override; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // A SurfaceSequence's validity is bound to the lifetime of the parent | 105 // A SurfaceSequence's validity is bound to the lifetime of the parent |
| 121 // FrameSink that created it. We track the lifetime of FrameSink's through | 106 // FrameSink that created it. We track the lifetime of FrameSink's through |
| 122 // RegisterFrameSinkId and InvalidateFrameSink. During startup and GPU | 107 // RegisterFrameSinkId and InvalidateFrameSink. During startup and GPU |
| 123 // restart, a SurfaceSequence created by the top most layer compositor may be | 108 // restart, a SurfaceSequence created by the top most layer compositor may be |
| 124 // used prior to the creation of the associated CompositorFrameSinkSupport. | 109 // used prior to the creation of the associated CompositorFrameSinkSupport. |
| 125 // CompositorFrameSinkSupport is created asynchronously when a new GPU channel | 110 // CompositorFrameSinkSupport is created asynchronously when a new GPU channel |
| 126 // is established. Once we switch to SurfaceReferences, this ordering concern | 111 // is established. Once we switch to SurfaceReferences, this ordering concern |
| 127 // goes away and we can remove this bool. | 112 // goes away and we can remove this bool. |
| 128 const bool handles_frame_sink_id_invalidation_; | 113 const bool handles_frame_sink_id_invalidation_; |
| 129 | 114 |
| 130 // Track the surface references for the surface corresponding to this | |
| 131 // compositor frame sink. | |
| 132 ReferencedSurfaceTracker reference_tracker_; | |
| 133 | |
| 134 // The set of BeginFrame children of this CompositorFrameSink. | 115 // The set of BeginFrame children of this CompositorFrameSink. |
| 135 std::unordered_set<FrameSinkId, FrameSinkIdHash> child_frame_sinks_; | 116 std::unordered_set<FrameSinkId, FrameSinkIdHash> child_frame_sinks_; |
| 136 | 117 |
| 137 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; | 118 base::WeakPtrFactory<CompositorFrameSinkSupport> weak_factory_; |
| 138 | 119 |
| 139 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); | 120 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupport); |
| 140 }; | 121 }; |
| 141 | 122 |
| 142 } // namespace cc | 123 } // namespace cc |
| 143 | 124 |
| 144 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ | 125 #endif // CC_SURFACES_COMPOSITOR_FRAME_SINK_SUPPORT_H_ |
| OLD | NEW |