• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "modules/skottie/include/SkottieProperty.h"
9 
10 #include "modules/skottie/src/Transform.h"
11 #include "modules/skottie/src/text/TextAdapter.h"
12 #include "modules/sksg/include/SkSGOpacityEffect.h"
13 #include "modules/sksg/include/SkSGPaint.h"
14 
15 namespace skottie {
16 
operator ==(const TextPropertyValue & other) const17 bool TextPropertyValue::operator==(const TextPropertyValue& other) const {
18     return fTypeface == other.fTypeface
19         && fText == other.fText
20         && fTextSize == other.fTextSize
21         && fStrokeWidth == other.fStrokeWidth
22         && fLineHeight == other.fLineHeight
23         && fLineShift == other.fLineShift
24         && fAscent == other.fAscent
25         && fMaxLines == other.fMaxLines
26         && fHAlign == other.fHAlign
27         && fVAlign == other.fVAlign
28         && fResize == other.fResize
29         && fLineBreak == other.fLineBreak
30         && fDirection == other.fDirection
31         && fCapitalization == other.fCapitalization
32         && fBox == other.fBox
33         && fFillColor == other.fFillColor
34         && fStrokeColor == other.fStrokeColor
35         && fPaintOrder == other.fPaintOrder
36         && fStrokeJoin == other.fStrokeJoin
37         && fHasFill == other.fHasFill
38         && fHasStroke == other.fHasStroke
39         && fDecorator == other.fDecorator;
40 }
41 
operator !=(const TextPropertyValue & other) const42 bool TextPropertyValue::operator!=(const TextPropertyValue& other) const {
43     return !(*this== other);
44 }
45 
operator ==(const TransformPropertyValue & other) const46 bool TransformPropertyValue::operator==(const TransformPropertyValue& other) const {
47     return this->fAnchorPoint == other.fAnchorPoint
48         && this->fPosition    == other.fPosition
49         && this->fScale       == other.fScale
50         && this->fSkew        == other.fSkew
51         && this->fSkewAxis    == other.fSkewAxis;
52 }
53 
operator !=(const TransformPropertyValue & other) const54 bool TransformPropertyValue::operator!=(const TransformPropertyValue& other) const {
55     return !(*this == other);
56 }
57 
58 template <> SK_API
~PropertyHandle()59 PropertyHandle<ColorPropertyValue, sksg::Color>::~PropertyHandle() {}
60 
61 template <> SK_API
get() const62 ColorPropertyValue PropertyHandle<ColorPropertyValue, sksg::Color>::get() const {
63     return fNode->getColor();
64 }
65 
66 template <> SK_API
set(const ColorPropertyValue & c)67 void PropertyHandle<ColorPropertyValue, sksg::Color>::set(const ColorPropertyValue& c) {
68     fNode->setColor(c);
69 }
70 
71 template <> SK_API
~PropertyHandle()72 PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::~PropertyHandle() {}
73 
74 template <> SK_API
get() const75 OpacityPropertyValue PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::get() const {
76     return fNode->getOpacity() * 100;
77 }
78 
79 template <> SK_API
set(const OpacityPropertyValue & o)80 void PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::set(const OpacityPropertyValue& o) {
81     fNode->setOpacity(o / 100);
82 }
83 
84 template <> SK_API
~PropertyHandle()85 PropertyHandle<TextPropertyValue, internal::TextAdapter>::~PropertyHandle() {}
86 
87 template <> SK_API
get() const88 TextPropertyValue PropertyHandle<TextPropertyValue, internal::TextAdapter>::get() const {
89       return fNode->getText();
90 }
91 
92 template<> SK_API
set(const TextPropertyValue & t)93 void PropertyHandle<TextPropertyValue, internal::TextAdapter>::set(const TextPropertyValue& t) {
94       fNode->setText(t);
95 }
96 
97 template <> SK_API
~PropertyHandle()98 PropertyHandle<TransformPropertyValue, internal::TransformAdapter2D>::~PropertyHandle() {}
99 
100 template <> SK_API
101 TransformPropertyValue PropertyHandle<TransformPropertyValue,
get() const102                                       internal::TransformAdapter2D>::get() const {
103     return {
104         fNode->getAnchorPoint(),
105         fNode->getPosition(),
106         fNode->getScale(),
107         fNode->getRotation(),
108         fNode->getSkew(),
109         fNode->getSkewAxis()
110     };
111 }
112 
113 template <> SK_API
set(const TransformPropertyValue & t)114 void PropertyHandle<TransformPropertyValue, internal::TransformAdapter2D>::set(
115         const TransformPropertyValue& t) {
116     fNode->setAnchorPoint(t.fAnchorPoint);
117     fNode->setPosition(t.fPosition);
118     fNode->setScale(t.fScale);
119     fNode->setRotation(t.fRotation);
120     fNode->setSkew(t.fSkew);
121     fNode->setSkewAxis(t.fSkewAxis);
122 }
123 
onColorProperty(const char[],const LazyHandle<ColorPropertyHandle> &)124 void PropertyObserver::onColorProperty(const char[],
125                                        const LazyHandle<ColorPropertyHandle>&) {}
126 
onOpacityProperty(const char[],const LazyHandle<OpacityPropertyHandle> &)127 void PropertyObserver::onOpacityProperty(const char[],
128                                          const LazyHandle<OpacityPropertyHandle>&) {}
129 
onTextProperty(const char[],const LazyHandle<TextPropertyHandle> &)130 void PropertyObserver::onTextProperty(const char[],
131                                       const LazyHandle<TextPropertyHandle>&) {}
132 
onTransformProperty(const char[],const LazyHandle<TransformPropertyHandle> &)133 void PropertyObserver::onTransformProperty(const char[],
134                                            const LazyHandle<TransformPropertyHandle>&) {}
135 
onEnterNode(const char node_name[],NodeType)136 void PropertyObserver::onEnterNode(const char node_name[], NodeType) {}
137 
onLeavingNode(const char node_name[],NodeType)138 void PropertyObserver::onLeavingNode(const char node_name[], NodeType) {}
139 
140 }  // namespace skottie
141