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 #include "cc/surfaces/sequence_surface_reference_factory.h" |
| 6 |
| 7 #include "cc/surfaces/sequence_surface_reference.h" |
| 8 |
| 9 namespace cc { |
| 10 |
| 11 std::unique_ptr<SurfaceReferenceBase> |
| 12 SequenceSurfaceReferenceFactory::CreateReference( |
| 13 SurfaceReferenceOwner* owner, |
| 14 const SurfaceId& surface_id) const { |
| 15 auto seq = owner->GetSurfaceSequenceGenerator()->CreateSurfaceSequence(); |
| 16 RequireSequence(surface_id, seq); |
| 17 return base::MakeUnique<SequenceSurfaceReference>(make_scoped_refptr(this), |
| 18 seq); |
| 19 } |
| 20 |
| 21 void SequenceSurfaceReferenceFactory::DestroyReference( |
| 22 SurfaceReferenceBase* surface_ref, |
| 23 CompositorFrameMetadata* metadata) const { |
| 24 // This method can only be called by a SurfaceReferenceBase because it's |
| 25 // 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 |
| 27 // the passed reference to the type returned by CreateReference. |
| 28 auto ref = static_cast<SequenceSurfaceReference*>(surface_ref); |
| 29 metadata->satisfies_sequences.push_back(ref->sequence().sequence); |
| 30 } |
| 31 |
| 32 void SequenceSurfaceReferenceFactory::DestroyReference( |
| 33 SurfaceReferenceBase* surface_ref) const { |
| 34 // We can do this static_cast for the same reason explained above. |
| 35 auto ref = static_cast<SequenceSurfaceReference*>(surface_ref); |
| 36 SatisfySequence(ref->sequence()); |
| 37 } |
| 38 |
| 39 } // namespace cc |
OLD | NEW |