• 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         && fHAlign == other.fHAlign
26         && fVAlign == other.fVAlign
27         && fResize == other.fResize
28         && fLineBreak == other.fLineBreak
29         && fDirection == other.fDirection
30         && fCapitalization == other.fCapitalization
31         && fBox == other.fBox
32         && fFillColor == other.fFillColor
33         && fStrokeColor == other.fStrokeColor
34         && fHasFill == other.fHasFill
35         && fHasStroke == other.fHasStroke;
36 }
37 
operator !=(const TextPropertyValue & other) const38 bool TextPropertyValue::operator!=(const TextPropertyValue& other) const {
39     return !(*this== other);
40 }
41 
operator ==(const TransformPropertyValue & other) const42 bool TransformPropertyValue::operator==(const TransformPropertyValue& other) const {
43     return this->fAnchorPoint == other.fAnchorPoint
44         && this->fPosition    == other.fPosition
45         && this->fScale       == other.fScale
46         && this->fSkew        == other.fSkew
47         && this->fSkewAxis    == other.fSkewAxis;
48 }
49 
operator !=(const TransformPropertyValue & other) const50 bool TransformPropertyValue::operator!=(const TransformPropertyValue& other) const {
51     return !(*this == other);
52 }
53 
54 template <> SK_API
~PropertyHandle()55 PropertyHandle<ColorPropertyValue, sksg::Color>::~PropertyHandle() {}
56 
57 template <> SK_API
get() const58 ColorPropertyValue PropertyHandle<ColorPropertyValue, sksg::Color>::get() const {
59     return fNode->getColor();
60 }
61 
62 template <> SK_API
set(const ColorPropertyValue & c)63 void PropertyHandle<ColorPropertyValue, sksg::Color>::set(const ColorPropertyValue& c) {
64     fNode->setColor(c);
65 }
66 
67 template <> SK_API
~PropertyHandle()68 PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::~PropertyHandle() {}
69 
70 template <> SK_API
get() const71 OpacityPropertyValue PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::get() const {
72     return fNode->getOpacity() * 100;
73 }
74 
75 template <> SK_API
set(const OpacityPropertyValue & o)76 void PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::set(const OpacityPropertyValue& o) {
77     fNode->setOpacity(o / 100);
78 }
79 
80 template <> SK_API
~PropertyHandle()81 PropertyHandle<TextPropertyValue, internal::TextAdapter>::~PropertyHandle() {}
82 
83 template <> SK_API
get() const84 TextPropertyValue PropertyHandle<TextPropertyValue, internal::TextAdapter>::get() const {
85       return fNode->getText();
86 }
87 
88 template<> SK_API
set(const TextPropertyValue & t)89 void PropertyHandle<TextPropertyValue, internal::TextAdapter>::set(const TextPropertyValue& t) {
90       fNode->setText(t);
91 }
92 
93 template <> SK_API
~PropertyHandle()94 PropertyHandle<TransformPropertyValue, internal::TransformAdapter2D>::~PropertyHandle() {}
95 
96 template <> SK_API
97 TransformPropertyValue PropertyHandle<TransformPropertyValue,
get() const98                                       internal::TransformAdapter2D>::get() const {
99     return {
100         fNode->getAnchorPoint(),
101         fNode->getPosition(),
102         fNode->getScale(),
103         fNode->getRotation(),
104         fNode->getSkew(),
105         fNode->getSkewAxis()
106     };
107 }
108 
109 template <> SK_API
set(const TransformPropertyValue & t)110 void PropertyHandle<TransformPropertyValue, internal::TransformAdapter2D>::set(
111         const TransformPropertyValue& t) {
112     fNode->setAnchorPoint(t.fAnchorPoint);
113     fNode->setPosition(t.fPosition);
114     fNode->setScale(t.fScale);
115     fNode->setRotation(t.fRotation);
116     fNode->setSkew(t.fSkew);
117     fNode->setSkewAxis(t.fSkewAxis);
118 }
119 
onColorProperty(const char[],const LazyHandle<ColorPropertyHandle> &)120 void PropertyObserver::onColorProperty(const char[],
121                                        const LazyHandle<ColorPropertyHandle>&) {}
122 
onOpacityProperty(const char[],const LazyHandle<OpacityPropertyHandle> &)123 void PropertyObserver::onOpacityProperty(const char[],
124                                          const LazyHandle<OpacityPropertyHandle>&) {}
125 
onTextProperty(const char[],const LazyHandle<TextPropertyHandle> &)126 void PropertyObserver::onTextProperty(const char[],
127                                       const LazyHandle<TextPropertyHandle>&) {}
128 
onTransformProperty(const char[],const LazyHandle<TransformPropertyHandle> &)129 void PropertyObserver::onTransformProperty(const char[],
130                                            const LazyHandle<TransformPropertyHandle>&) {}
131 
onEnterNode(const char node_name[],NodeType)132 void PropertyObserver::onEnterNode(const char node_name[], NodeType) {}
133 
onLeavingNode(const char node_name[],NodeType)134 void PropertyObserver::onLeavingNode(const char node_name[], NodeType) {}
135 
136 }  // namespace skottie
137