| 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_REFERENCED_SURFACE_TRACKER_H_ |
| 6 #define CC_SURFACES_REFERENCED_SURFACE_TRACKER_H_ |
| 7 |
| 8 #include <unordered_set> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "cc/surfaces/frame_sink_id.h" |
| 13 #include "cc/surfaces/surface_id.h" |
| 14 #include "cc/surfaces/surface_reference.h" |
| 15 #include "cc/surfaces/surfaces_export.h" |
| 16 |
| 17 namespace cc { |
| 18 |
| 19 // Tracks surface references for a client surface. UpdateReferences() should be |
| 20 // called once per CompositorFrame to populate |references_to_add_| and |
| 21 // |references_to_remove_|. |
| 22 class CC_SURFACES_EXPORT ReferencedSurfaceTracker { |
| 23 public: |
| 24 explicit ReferencedSurfaceTracker(const FrameSinkId& frame_sink_id); |
| 25 ~ReferencedSurfaceTracker(); |
| 26 |
| 27 const SurfaceId& current_surface_id() const { return current_surface_id_; } |
| 28 |
| 29 std::vector<SurfaceReference>& references_to_add() { |
| 30 return references_to_add_; |
| 31 } |
| 32 |
| 33 std::vector<SurfaceReference>& references_to_remove() { |
| 34 return references_to_remove_; |
| 35 } |
| 36 |
| 37 // Update the references for a CompositorFrame. If |local_frame_id| has |
| 38 // changed then new references will be generated for everything in |
| 39 // |referenced_surfaces|. Otherwise a diff from the referenced surfaces in the |
| 40 // last frame will be computed. This should be called once per |
| 41 // CompositorFrame. |
| 42 void UpdateReferences(const LocalFrameId& local_frame_id, |
| 43 const std::vector<SurfaceId>& referenced_surfaces); |
| 44 |
| 45 private: |
| 46 // Updates |referenced_surfaces_| based on a |new_referenced_surfaces| from a |
| 47 // CompositorFrame. Populates |references_to_add_| and |references_to_remove_| |
| 48 // based on the difference between the sets. |
| 49 void ProcessNewReferences(const std::unordered_set<SurfaceId, SurfaceIdHash>& |
| 50 new_referenced_surfaces); |
| 51 |
| 52 // Adds reference from |current_surface_id_| to |surface_id|. |
| 53 void AddSurfaceReference(const SurfaceId& surface_id); |
| 54 |
| 55 // Removes reference from |current_surface_id_| to |surface_id|. |
| 56 void RemoveSurfaceReference(const SurfaceId& surface_id); |
| 57 |
| 58 // The id of the client surface that is embedding other surfaces. |
| 59 SurfaceId current_surface_id_; |
| 60 |
| 61 // TODO(samans): Use the same SurfaceId set that SurfaceManager holds. |
| 62 // Set of surfaces referenced by the last submitted CompositorFrame. |
| 63 std::unordered_set<SurfaceId, SurfaceIdHash> referenced_surfaces_; |
| 64 |
| 65 // References to surfaces that should be added for the next CompositorFrame. |
| 66 std::vector<SurfaceReference> references_to_add_; |
| 67 |
| 68 // References to surfaces that should be removed after the next |
| 69 // CompositorFrame has been submitted and the surfaces are no longer needed by |
| 70 // |current_surface_id_|. |
| 71 std::vector<SurfaceReference> references_to_remove_; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(ReferencedSurfaceTracker); |
| 74 }; |
| 75 |
| 76 } // namespace cc |
| 77 |
| 78 #endif // CC_SURFACES_REFERENCED_SURFACE_TRACKER_H_ |
| OLD | NEW |