blob: 0d27017968b3011ba6c6fbf58c8366347dc5a03c [file] [log] [blame]
Florin Malitaa85f3a12018-09-24 17:24:59 -04001/*
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
14namespace skottie {
15
Florin Malita8ac81b72018-11-28 11:39:39 -050016bool 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;
Florin Malitaa85f3a12018-09-24 17:24:59 -040022}
23
Florin Malita8ac81b72018-11-28 11:39:39 -050024bool TransformPropertyValue::operator!=(const TransformPropertyValue& other) const {
25 return !(*this == other);
Florin Malitaa85f3a12018-09-24 17:24:59 -040026}
27
Florin Malita8ac81b72018-11-28 11:39:39 -050028template <>
29PropertyHandle<ColorPropertyValue, sksg::Color>::~PropertyHandle() {}
30
31template <>
32ColorPropertyValue PropertyHandle<ColorPropertyValue, sksg::Color>::get() const {
33 return fNode->getColor();
Florin Malitaa85f3a12018-09-24 17:24:59 -040034}
35
Florin Malita8ac81b72018-11-28 11:39:39 -050036template <>
37void PropertyHandle<ColorPropertyValue, sksg::Color>::set(const ColorPropertyValue& c) {
38 fNode->setColor(c);
Florin Malitaa85f3a12018-09-24 17:24:59 -040039}
40
Florin Malita8ac81b72018-11-28 11:39:39 -050041template <>
42PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::~PropertyHandle() {}
Florin Malitaa85f3a12018-09-24 17:24:59 -040043
Florin Malita8ac81b72018-11-28 11:39:39 -050044template <>
45OpacityPropertyValue PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::get() const {
46 return fNode->getOpacity() * 100;
Florin Malitaa85f3a12018-09-24 17:24:59 -040047}
48
Florin Malita8ac81b72018-11-28 11:39:39 -050049template <>
50void PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::set(const OpacityPropertyValue& o) {
51 fNode->setOpacity(o / 100);
Florin Malitaa85f3a12018-09-24 17:24:59 -040052}
53
Florin Malita8ac81b72018-11-28 11:39:39 -050054template <>
55PropertyHandle<TransformPropertyValue, TransformAdapter>::~PropertyHandle() {}
56
57template <>
58TransformPropertyValue PropertyHandle<TransformPropertyValue, TransformAdapter>::get() const {
59 return {
60 fNode->getAnchorPoint(),
61 fNode->getPosition(),
62 fNode->getScale(),
63 fNode->getRotation(),
64 fNode->getSkew(),
65 fNode->getSkewAxis()
66 };
Florin Malitaa85f3a12018-09-24 17:24:59 -040067}
68
Florin Malita8ac81b72018-11-28 11:39:39 -050069template <>
70void PropertyHandle<TransformPropertyValue, TransformAdapter>::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);
Florin Malitaa85f3a12018-09-24 17:24:59 -040078}
79
80void PropertyObserver::onColorProperty(const char[],
81 const LazyHandle<ColorPropertyHandle>&) {}
82
83void PropertyObserver::onOpacityProperty(const char[],
84 const LazyHandle<OpacityPropertyHandle>&) {}
85
86void PropertyObserver::onTransformProperty(const char[],
87 const LazyHandle<TransformPropertyHandle>&) {}
88
89} // namespace skottie