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 #include "cc/surfaces/sequence_surface_reference_factory.h" | 5 #include "cc/surfaces/sequence_surface_reference_factory.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "cc/surfaces/sequence_surface_reference.h" | 8 #include "cc/surfaces/scoped_surface_sequence.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 | 11 |
12 std::unique_ptr<SurfaceReferenceBase> | 12 std::unique_ptr<ScopedSurfaceReferenceBase> |
13 SequenceSurfaceReferenceFactory::CreateReference( | 13 SequenceSurfaceReferenceFactory::CreateReference( |
14 SurfaceReferenceOwner* owner, | 14 SurfaceReferenceOwner* owner, |
15 const SurfaceId& surface_id) const { | 15 const SurfaceId& surface_id) const { |
16 auto seq = owner->GetSurfaceSequenceGenerator()->CreateSurfaceSequence(); | 16 auto seq = owner->GetSurfaceSequenceGenerator()->CreateSurfaceSequence(); |
17 RequireSequence(surface_id, seq); | 17 RequireSequence(surface_id, seq); |
18 return base::MakeUnique<SequenceSurfaceReference>(make_scoped_refptr(this), | 18 return base::MakeUnique<ScopedSurfaceSequence>(make_scoped_refptr(this), seq); |
19 seq); | |
20 } | 19 } |
21 | 20 |
22 void SequenceSurfaceReferenceFactory::DestroyReference( | 21 void SequenceSurfaceReferenceFactory::DestroyReference( |
23 SurfaceReferenceBase* surface_ref) const { | 22 ScopedSurfaceReferenceBase* surface_ref) const { |
24 // This method can only be called by a SurfaceReferenceBase because it's | 23 // This method can only be called by a SurfaceReferenceBase because it's |
25 // private and only SurfaceReferenceBase is a friend. The reference only | 24 // private and only SurfaceReferenceBase is a friend. The reference only |
26 // calls this method on the factory that created it. So it's safe to cast | 25 // calls this method on the factory that created it. So it's safe to cast |
27 // the passed reference to the type returned by CreateReference. | 26 // the passed reference to the type returned by CreateReference. |
28 auto ref = static_cast<SequenceSurfaceReference*>(surface_ref); | 27 auto ref = static_cast<ScopedSurfaceSequence*>(surface_ref); |
29 SatisfySequence(ref->sequence()); | 28 SatisfySequence(ref->sequence()); |
30 } | 29 } |
31 | 30 |
32 } // namespace cc | 31 } // namespace cc |
OLD | NEW |