blob: 20441c15b8ab0e016c24bfd4a8cc778ce1a08c57 [file] [log] [blame]
Florin Malitadf0e1af2019-01-10 11:27:13 -05001/*
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
13namespace sksg {
14
15// Helper for accessing implementation-private Transform methods.
16class TransformPriv final {
17public:
Florin Malita13c1b962019-01-10 14:44:59 -050018
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 Malitadf0e1af2019-01-10 11:27:13 -050024
25private:
26 TransformPriv() = delete;
27};
28
Florin Malita13c1b962019-01-10 14:44:59 -050029template <>
30inline SkMatrix TransformPriv::As<SkMatrix>(const sk_sp<Transform>& t) {
31 return t->asMatrix();
32}
33
34template <>
35inline SkMatrix44 TransformPriv::As<SkMatrix44>(const sk_sp<Transform>& t) {
36 return t->asMatrix44();
37}
38
Florin Malitadf0e1af2019-01-10 11:27:13 -050039} // namespace sksg
40
41#endif // SkSGTransformPriv_DEFINED