Chromium Code Reviews| 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 UpdateReferencedSurfaces( | |
|
Fady Samuel
2017/01/18 20:47:40
Maybe call this UpdateReferencedSurfacesInternal s
kylechar
2017/01/18 20:52:28
Change named to something less similar sound, done
| |
| 50 const std::unordered_set<SurfaceId, SurfaceIdHash>& | |
| 51 new_referenced_surfaces); | |
| 52 | |
| 53 // Adds reference from |current_surface_id_| to |surface_id|. | |
| 54 void AddSurfaceReference(const SurfaceId& surface_id); | |
| 55 | |
| 56 // Removes reference from |current_surface_id_| to |surface_id|. | |
| 57 void RemoveSurfaceReference(const SurfaceId& surface_id); | |
| 58 | |
| 59 // The id of the client surface that is embedding other surfaces. | |
| 60 SurfaceId current_surface_id_; | |
| 61 | |
| 62 // TODO(samans): Use the same SurfaceId set that SurfaceManager holds. | |
| 63 // Set of surfaces referenced by the last submitted CompositorFrame. | |
| 64 std::unordered_set<SurfaceId, SurfaceIdHash> referenced_surfaces_; | |
| 65 | |
| 66 // References to surfaces that should be added for the next CompositorFrame. | |
| 67 std::vector<SurfaceReference> references_to_add_; | |
| 68 | |
| 69 // References to surfaces that should be removed after the next | |
| 70 // CompositorFrame has been submitted and the surfaces are no longer needed by | |
| 71 // |current_surface_id_|. | |
| 72 std::vector<SurfaceReference> references_to_remove_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(ReferencedSurfaceTracker); | |
| 75 }; | |
| 76 | |
| 77 } // namespace cc | |
| 78 | |
| 79 #endif // CC_SURFACES_REFERENCED_SURFACE_TRACKER_H_ | |
| OLD | NEW |