Debian Codegraph @

modules/sksg/src/SkSGTransformPriv.h

raw
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 "include/core/SkM44.h"
12 #include "include/core/SkMatrix.h"
13 #include "modules/sksg/include/SkSGTransform.h"
14
15 namespace sksg {
16
17 // Helper for accessing implementation-private Transform methods.
18 class TransformPriv final {
19 public:
20
21 static bool Is44(const sk_sp<Transform>&t) { return t->is44(); }
22
23 template <typename T, typename = std::enable_if<std::is_same<T, SkMatrix>::value ||
24 std::is_same<T, SkM44 >::value >>
25 static T As(const sk_sp<Transform>&);
26
27 private:
28 TransformPriv() = delete;
29 };
30
31 template <>
32 inline SkMatrix TransformPriv::As<SkMatrix>(const sk_sp<Transform>& t) {
33 return t->asMatrix();
34 }
35
36 template <>
37 inline SkM44 TransformPriv::As<SkM44>(const sk_sp<Transform>& t) {
38 return t->asM44();
39 }
40
41 } // namespace sksg
42
43 #endif // SkSGTransformPriv_DEFINED