| 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_FACTORY_H_ | 5 #ifndef CC_SURFACES_SURFACE_REFERENCE_FACTORY_H_ |
| 6 #define CC_SURFACES_SURFACE_REFERENCE_FACTORY_H_ | 6 #define CC_SURFACES_SURFACE_REFERENCE_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "cc/surfaces/surface_id.h" | 9 #include "cc/surfaces/surface_id.h" |
| 10 #include "cc/surfaces/surface_reference_owner.h" | 10 #include "cc/surfaces/surface_reference_owner.h" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 | 13 |
| 14 class SurfaceReferenceBase; | 14 class ScopedSurfaceReferenceBase; |
| 15 | 15 |
| 16 // Creates surface references. Returns an object of type | 16 // Creates surface references. Returns an object of type |
| 17 // SurfaceReferenceBase which holds on to its corresponding | 17 // ScopedSurfaceReferenceBase which holds on to its corresponding |
| 18 // surface reference until destruction. The referenced surface | 18 // surface reference until destruction. The referenced surface |
| 19 // will be kept alive as long as there is a reference to it. | 19 // will be kept alive as long as there is a reference to it. |
| 20 class SurfaceReferenceFactory | 20 class SurfaceReferenceFactory |
| 21 : public base::RefCountedThreadSafe<SurfaceReferenceFactory> { | 21 : public base::RefCountedThreadSafe<SurfaceReferenceFactory> { |
| 22 public: | 22 public: |
| 23 virtual std::unique_ptr<SurfaceReferenceBase> CreateReference( | 23 virtual std::unique_ptr<ScopedSurfaceReferenceBase> CreateReference( |
| 24 SurfaceReferenceOwner* owner, | 24 SurfaceReferenceOwner* owner, |
| 25 const SurfaceId& surface_id) const = 0; | 25 const SurfaceId& surface_id) const = 0; |
| 26 | 26 |
| 27 SurfaceReferenceFactory() = default; | 27 SurfaceReferenceFactory() = default; |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 virtual ~SurfaceReferenceFactory() = default; | 30 virtual ~SurfaceReferenceFactory() = default; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 friend class SurfaceReferenceBase; | 33 friend class ScopedSurfaceReferenceBase; |
| 34 friend class base::RefCountedThreadSafe<SurfaceReferenceFactory>; | 34 friend class base::RefCountedThreadSafe<SurfaceReferenceFactory>; |
| 35 | 35 |
| 36 virtual void DestroyReference(SurfaceReferenceBase* surface_ref) const = 0; | 36 virtual void DestroyReference( |
| 37 ScopedSurfaceReferenceBase* surface_ref) const = 0; |
| 37 | 38 |
| 38 DISALLOW_COPY_AND_ASSIGN(SurfaceReferenceFactory); | 39 DISALLOW_COPY_AND_ASSIGN(SurfaceReferenceFactory); |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 } // namespace cc | 42 } // namespace cc |
| 42 | 43 |
| 43 #endif // CC_SURFACES_SURFACE_REFERENCE_FACTORY_H_ | 44 #endif // CC_SURFACES_SURFACE_REFERENCE_FACTORY_H_ |
| OLD | NEW |