| 1 | /* | 
|---|---|
| 2 | * Copyright 2019 Google Inc. | 
| 3 | * | 
| 4 | * Use of this source code is governed by a BSD-style license that can be | 
| 5 | * found in the LICENSE file. | 
| 6 | */ | 
| 7 | |
| 8 | #ifndef SkSGTransformPriv_DEFINED | 
| 9 | #define SkSGTransformPriv_DEFINED | 
| 10 | |
| 11 | #include "modules/sksg/include/SkSGTransform.h" | 
| 12 | |
| 13 | namespace sksg { | 
| 14 | |
| 15 | // Helper for accessing implementation-private Transform methods. | 
| 16 | class TransformPriv final { | 
| 17 | public: | 
| 18 | |
| 19 | static bool Is44(const sk_sp<Transform>&t) { return t->is44(); } | 
| 20 | |
| 21 | template <typename T, typename = std::enable_if<std::is_same<T, SkMatrix>::value || | 
| 22 | std::is_same<T, SkM44 >::value >> | 
| 23 | static T As(const sk_sp<Transform>&); | 
| 24 | |
| 25 | private: | 
| 26 | TransformPriv() = delete; | 
| 27 | }; | 
| 28 | |
| 29 | template <> | 
| 30 | inline SkMatrix TransformPriv::As<SkMatrix>(const sk_sp<Transform>& t) { | 
| 31 | return t->asMatrix(); | 
| 32 | } | 
| 33 | |
| 34 | template <> | 
| 35 | inline SkM44 TransformPriv::As<SkM44>(const sk_sp<Transform>& t) { | 
| 36 | return t->asM44(); | 
| 37 | } | 
| 38 | |
| 39 | } // namespace sksg | 
| 40 | |
| 41 | #endif // SkSGTransformPriv_DEFINED | 
| 42 | 
