Florin Malita | df0e1af | 2019-01-10 11:27:13 -0500 | [diff] [blame] | 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 "SkSGTransform.h" |
| 12 | |
| 13 | namespace sksg { |
| 14 | |
| 15 | // Helper for accessing implementation-private Transform methods. |
| 16 | class TransformPriv final { |
| 17 | public: |
Florin Malita | 13c1b96 | 2019-01-10 14:44:59 -0500 | [diff] [blame] | 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, SkMatrix44>::value >> |
| 23 | static T As(const sk_sp<Transform>&); |
Florin Malita | df0e1af | 2019-01-10 11:27:13 -0500 | [diff] [blame] | 24 | |
| 25 | private: |
| 26 | TransformPriv() = delete; |
| 27 | }; |
| 28 | |
Florin Malita | 13c1b96 | 2019-01-10 14:44:59 -0500 | [diff] [blame] | 29 | template <> |
| 30 | inline SkMatrix TransformPriv::As<SkMatrix>(const sk_sp<Transform>& t) { |
| 31 | return t->asMatrix(); |
| 32 | } |
| 33 | |
| 34 | template <> |
| 35 | inline SkMatrix44 TransformPriv::As<SkMatrix44>(const sk_sp<Transform>& t) { |
| 36 | return t->asMatrix44(); |
| 37 | } |
| 38 | |
Florin Malita | df0e1af | 2019-01-10 11:27:13 -0500 | [diff] [blame] | 39 | } // namespace sksg |
| 40 | |
| 41 | #endif // SkSGTransformPriv_DEFINED |