1 /*
2 * Copyright 2018 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 #include "SkottieProperty.h"
9
10 #include "SkottieAdapter.h"
11 #include "SkSGColor.h"
12 #include "SkSGOpacityEffect.h"
13
14 namespace skottie {
15
operator ==(const TransformPropertyValue & other) const16 bool TransformPropertyValue::operator==(const TransformPropertyValue& other) const {
17 return this->fAnchorPoint == other.fAnchorPoint
18 && this->fPosition == other.fPosition
19 && this->fScale == other.fScale
20 && this->fSkew == other.fSkew
21 && this->fSkewAxis == other.fSkewAxis;
22 }
23
operator !=(const TransformPropertyValue & other) const24 bool TransformPropertyValue::operator!=(const TransformPropertyValue& other) const {
25 return !(*this == other);
26 }
27
28 template <>
~PropertyHandle()29 PropertyHandle<ColorPropertyValue, sksg::Color>::~PropertyHandle() {}
30
31 template <>
get() const32 ColorPropertyValue PropertyHandle<ColorPropertyValue, sksg::Color>::get() const {
33 return fNode->getColor();
34 }
35
36 template <>
set(const ColorPropertyValue & c)37 void PropertyHandle<ColorPropertyValue, sksg::Color>::set(const ColorPropertyValue& c) {
38 fNode->setColor(c);
39 }
40
41 template <>
~PropertyHandle()42 PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::~PropertyHandle() {}
43
44 template <>
get() const45 OpacityPropertyValue PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::get() const {
46 return fNode->getOpacity() * 100;
47 }
48
49 template <>
set(const OpacityPropertyValue & o)50 void PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::set(const OpacityPropertyValue& o) {
51 fNode->setOpacity(o / 100);
52 }
53
54 template <>
~PropertyHandle()55 PropertyHandle<TransformPropertyValue, TransformAdapter2D>::~PropertyHandle() {}
56
57 template <>
get() const58 TransformPropertyValue PropertyHandle<TransformPropertyValue, TransformAdapter2D>::get() const {
59 return {
60 fNode->getAnchorPoint(),
61 fNode->getPosition(),
62 fNode->getScale(),
63 fNode->getRotation(),
64 fNode->getSkew(),
65 fNode->getSkewAxis()
66 };
67 }
68
69 template <>
set(const TransformPropertyValue & t)70 void PropertyHandle<TransformPropertyValue, TransformAdapter2D>::set(
71 const TransformPropertyValue& t) {
72 fNode->setAnchorPoint(t.fAnchorPoint);
73 fNode->setPosition(t.fPosition);
74 fNode->setScale(t.fScale);
75 fNode->setRotation(t.fRotation);
76 fNode->setSkew(t.fSkew);
77 fNode->setSkewAxis(t.fSkewAxis);
78 }
79
onColorProperty(const char[],const LazyHandle<ColorPropertyHandle> &)80 void PropertyObserver::onColorProperty(const char[],
81 const LazyHandle<ColorPropertyHandle>&) {}
82
onOpacityProperty(const char[],const LazyHandle<OpacityPropertyHandle> &)83 void PropertyObserver::onOpacityProperty(const char[],
84 const LazyHandle<OpacityPropertyHandle>&) {}
85
onTransformProperty(const char[],const LazyHandle<TransformPropertyHandle> &)86 void PropertyObserver::onTransformProperty(const char[],
87 const LazyHandle<TransformPropertyHandle>&) {}
88
89 } // namespace skottie
90