| 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 namespace cc { | 8 namespace cc { |
| 9 | 9 |
| 10 class SurfaceId; | 10 class SurfaceId; |
| 11 | 11 |
| 12 // Interface to manage surface references. | 12 // Interface to manage surface references. |
| 13 class SurfaceReferenceManager { | 13 class SurfaceReferenceManager { |
| 14 public: | 14 public: |
| 15 // Returns the top level root SurfaceId. Surfaces that are not reachable | 15 // Returns the top level root SurfaceId. Surfaces that are not reachable |
| 16 // 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 |
| 17 // SurfaceId and will never correspond to a surface. | 17 // SurfaceId and will never correspond to a surface. |
| 18 virtual const SurfaceId& GetRootSurfaceId() const = 0; | 18 virtual const SurfaceId& GetRootSurfaceId() const = 0; |
| 19 | 19 |
| 20 // 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 |
| 21 // 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 |
| 22 // surface is not garbage collected until after the parent surface. | 22 // surface is not garbage collected until after the parent surface. Returns |
| 23 virtual void AddSurfaceReference(const SurfaceId& parent_id, | 23 // false if the reference was invalid or already exists and wasn't added. |
| 24 virtual bool AddSurfaceReference(const SurfaceId& parent_id, |
| 24 const SurfaceId& child_id) = 0; | 25 const SurfaceId& child_id) = 0; |
| 25 | 26 |
| 26 // Removes a reference from a parent surface to a child surface. | 27 // Removes a reference from a parent surface to a child surface. Return false |
| 27 virtual void RemoveSurfaceReference(const SurfaceId& parent_id, | 28 // if the reference doesn't exist and wasn't removed. |
| 29 virtual bool RemoveSurfaceReference(const SurfaceId& parent_id, |
| 28 const SurfaceId& child_id) = 0; | 30 const SurfaceId& child_id) = 0; |
| 29 | 31 |
| 30 // Returns the number of surfaces that have references to |surface_id|. When | 32 // Returns the number of surfaces that have references to |surface_id|. When |
| 31 // the count is zero nothing is referencing the surface and it may be garbage | 33 // the count is zero nothing is referencing the surface and it may be garbage |
| 32 // collected. | 34 // collected. |
| 33 virtual size_t GetSurfaceReferenceCount( | 35 virtual size_t GetSurfaceReferenceCount( |
| 34 const SurfaceId& surface_id) const = 0; | 36 const SurfaceId& surface_id) const = 0; |
| 35 | 37 |
| 36 // Returns the number of surfaces that |surface_id| has references to. | 38 // Returns the number of surfaces that |surface_id| has references to. |
| 37 virtual size_t GetReferencedSurfaceCount( | 39 virtual size_t GetReferencedSurfaceCount( |
| 38 const SurfaceId& surface_id) const = 0; | 40 const SurfaceId& surface_id) const = 0; |
| 39 | 41 |
| 40 protected: | 42 protected: |
| 41 virtual ~SurfaceReferenceManager() {} | 43 virtual ~SurfaceReferenceManager() {} |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 } // namespace cc | 46 } // namespace cc |
| 45 | 47 |
| 46 #endif // CC_SURFACES_SURFACE_REFERENCE_MANAGER_H_ | 48 #endif // CC_SURFACES_SURFACE_REFERENCE_MANAGER_H_ |
| OLD | NEW |