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 UnderlyingValueOwner_h | 5 #ifndef UnderlyingValueOwner_h |
6 #define UnderlyingValueOwner_h | 6 #define UnderlyingValueOwner_h |
7 | 7 |
8 #include "core/animation/TypedInterpolationValue.h" | 8 #include "core/animation/TypedInterpolationValue.h" |
9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
10 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 // Handles memory management of underlying InterpolationValues in applyStack() | 15 // Handles memory management of underlying InterpolationValues in applyStack() |
16 // Ensures we perform copy on write if we are not the owner of an underlying Int
erpolationValue. | 16 // Ensures we perform copy on write if we are not the owner of an underlying |
17 // This functions similar to a DataRef except on std::unique_ptr'd objects. | 17 // InterpolationValue. This functions similar to a DataRef except on |
| 18 // std::unique_ptr'd objects. |
18 class UnderlyingValueOwner { | 19 class UnderlyingValueOwner { |
19 WTF_MAKE_NONCOPYABLE(UnderlyingValueOwner); | 20 WTF_MAKE_NONCOPYABLE(UnderlyingValueOwner); |
20 STACK_ALLOCATED(); | 21 STACK_ALLOCATED(); |
21 | 22 |
22 public: | 23 public: |
23 UnderlyingValueOwner() | 24 UnderlyingValueOwner() |
24 : m_type(nullptr), m_valueOwner(nullptr), m_value(nullptr) {} | 25 : m_type(nullptr), m_valueOwner(nullptr), m_value(nullptr) {} |
25 | 26 |
26 operator bool() const { | 27 operator bool() const { |
27 DCHECK_EQ(static_cast<bool>(m_type), static_cast<bool>(m_value)); | 28 DCHECK_EQ(static_cast<bool>(m_type), static_cast<bool>(m_value)); |
(...skipping 17 matching lines...) Expand all Loading... |
45 | 46 |
46 private: | 47 private: |
47 const InterpolationType* m_type; | 48 const InterpolationType* m_type; |
48 InterpolationValue m_valueOwner; | 49 InterpolationValue m_valueOwner; |
49 const InterpolationValue* m_value; | 50 const InterpolationValue* m_value; |
50 }; | 51 }; |
51 | 52 |
52 } // namespace blink | 53 } // namespace blink |
53 | 54 |
54 #endif // UnderlyingValueOwner_h | 55 #endif // UnderlyingValueOwner_h |
OLD | NEW |