| 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_SURFACE_REFERENCE_MANAGER_H_ | 5 #ifndef CC_SURFACES_SURFACE_REFERENCE_MANAGER_H_ |
| 6 #define CC_SURFACES_SURFACE_REFERENCE_MANAGER_H_ | 6 #define CC_SURFACES_SURFACE_REFERENCE_MANAGER_H_ |
| 7 | 7 |
| 8 #include "cc/surfaces/surface_reference.h" | |
| 9 | |
| 10 namespace cc { | 8 namespace cc { |
| 11 | 9 |
| 12 class SurfaceId; | 10 class SurfaceId; |
| 13 | 11 |
| 14 // Interface to manage surface references. | 12 // Interface to manage surface references. |
| 15 class SurfaceReferenceManager { | 13 class SurfaceReferenceManager { |
| 16 public: | 14 public: |
| 17 // Returns the top level root SurfaceId. Surfaces that are not reachable | 15 // Returns the top level root SurfaceId. Surfaces that are not reachable |
| 18 // from the top level root may be garbage collected. It will not be a valid | 16 // from the top level root may be garbage collected. It will not be a valid |
| 19 // SurfaceId and will never correspond to a surface. | 17 // SurfaceId and will never correspond to a surface. |
| 20 virtual const SurfaceId& GetRootSurfaceId() const = 0; | 18 virtual const SurfaceId& GetRootSurfaceId() const = 0; |
| 21 | 19 |
| 22 // Adds a reference from a parent surface to a child surface. Any surface | 20 // Adds a reference from a parent surface to a child surface. Any surface |
| 23 // embedding a child surface should have a reference added so that the child | 21 // embedding a child surface should have a reference added so that the child |
| 24 // surface is not garbage collected until after the parent surface. | 22 // surface is not garbage collected until after the parent surface. |
| 25 virtual void AddSurfaceReference(const SurfaceId& parent_id, | 23 virtual void AddSurfaceReference(const SurfaceId& parent_id, |
| 26 const SurfaceId& child_id) = 0; | 24 const SurfaceId& child_id) = 0; |
| 27 | 25 |
| 28 // Removes a reference from a parent surface to a child surface. | 26 // Removes a reference from a parent surface to a child surface. |
| 29 virtual void RemoveSurfaceReference(const SurfaceId& parent_id, | 27 virtual void RemoveSurfaceReference(const SurfaceId& parent_id, |
| 30 const SurfaceId& child_id) = 0; | 28 const SurfaceId& child_id) = 0; |
| 31 | 29 |
| 32 // Adds surface references. For each reference added, this will remove the | |
| 33 // temporary reference to the child surface if one exists. | |
| 34 virtual void AddSurfaceReferences( | |
| 35 const std::vector<SurfaceReference>& references) = 0; | |
| 36 | |
| 37 // Removes surface references. | |
| 38 virtual void RemoveSurfaceReferences( | |
| 39 const std::vector<SurfaceReference>& references) = 0; | |
| 40 | |
| 41 // Returns the number of surfaces that have references to |surface_id|. When | 30 // Returns the number of surfaces that have references to |surface_id|. When |
| 42 // the count is zero nothing is referencing the surface and it may be garbage | 31 // the count is zero nothing is referencing the surface and it may be garbage |
| 43 // collected. | 32 // collected. |
| 44 virtual size_t GetSurfaceReferenceCount( | 33 virtual size_t GetSurfaceReferenceCount( |
| 45 const SurfaceId& surface_id) const = 0; | 34 const SurfaceId& surface_id) const = 0; |
| 46 | 35 |
| 47 // Returns the number of surfaces that |surface_id| has references to. | 36 // Returns the number of surfaces that |surface_id| has references to. |
| 48 virtual size_t GetReferencedSurfaceCount( | 37 virtual size_t GetReferencedSurfaceCount( |
| 49 const SurfaceId& surface_id) const = 0; | 38 const SurfaceId& surface_id) const = 0; |
| 50 | 39 |
| 51 protected: | 40 protected: |
| 52 virtual ~SurfaceReferenceManager() {} | 41 virtual ~SurfaceReferenceManager() {} |
| 53 }; | 42 }; |
| 54 | 43 |
| 55 } // namespace cc | 44 } // namespace cc |
| 56 | 45 |
| 57 #endif // CC_SURFACES_SURFACE_REFERENCE_MANAGER_H_ | 46 #endif // CC_SURFACES_SURFACE_REFERENCE_MANAGER_H_ |
| OLD | NEW |