Florin Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 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 | |
Florin Malita | 8ac81b7 | 2018-11-28 11:39:39 -0500 | [diff] [blame^] | 16 | 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; |
Florin Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 22 | } |
| 23 | |
Florin Malita | 8ac81b7 | 2018-11-28 11:39:39 -0500 | [diff] [blame^] | 24 | bool TransformPropertyValue::operator!=(const TransformPropertyValue& other) const { |
| 25 | return !(*this == other); |
Florin Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 26 | } |
| 27 | |
Florin Malita | 8ac81b7 | 2018-11-28 11:39:39 -0500 | [diff] [blame^] | 28 | template <> |
| 29 | PropertyHandle<ColorPropertyValue, sksg::Color>::~PropertyHandle() {} |
| 30 | |
| 31 | template <> |
| 32 | ColorPropertyValue PropertyHandle<ColorPropertyValue, sksg::Color>::get() const { |
| 33 | return fNode->getColor(); |
Florin Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 34 | } |
| 35 | |
Florin Malita | 8ac81b7 | 2018-11-28 11:39:39 -0500 | [diff] [blame^] | 36 | template <> |
| 37 | void PropertyHandle<ColorPropertyValue, sksg::Color>::set(const ColorPropertyValue& c) { |
| 38 | fNode->setColor(c); |
Florin Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 39 | } |
| 40 | |
Florin Malita | 8ac81b7 | 2018-11-28 11:39:39 -0500 | [diff] [blame^] | 41 | template <> |
| 42 | PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::~PropertyHandle() {} |
Florin Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 43 | |
Florin Malita | 8ac81b7 | 2018-11-28 11:39:39 -0500 | [diff] [blame^] | 44 | template <> |
| 45 | OpacityPropertyValue PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::get() const { |
| 46 | return fNode->getOpacity() * 100; |
Florin Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 47 | } |
| 48 | |
Florin Malita | 8ac81b7 | 2018-11-28 11:39:39 -0500 | [diff] [blame^] | 49 | template <> |
| 50 | void PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::set(const OpacityPropertyValue& o) { |
| 51 | fNode->setOpacity(o / 100); |
Florin Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 52 | } |
| 53 | |
Florin Malita | 8ac81b7 | 2018-11-28 11:39:39 -0500 | [diff] [blame^] | 54 | template <> |
| 55 | PropertyHandle<TransformPropertyValue, TransformAdapter>::~PropertyHandle() {} |
| 56 | |
| 57 | template <> |
| 58 | TransformPropertyValue 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 Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 67 | } |
| 68 | |
Florin Malita | 8ac81b7 | 2018-11-28 11:39:39 -0500 | [diff] [blame^] | 69 | template <> |
| 70 | void 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 Malita | a85f3a1 | 2018-09-24 17:24:59 -0400 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | void PropertyObserver::onColorProperty(const char[], |
| 81 | const LazyHandle<ColorPropertyHandle>&) {} |
| 82 | |
| 83 | void PropertyObserver::onOpacityProperty(const char[], |
| 84 | const LazyHandle<OpacityPropertyHandle>&) {} |
| 85 | |
| 86 | void PropertyObserver::onTransformProperty(const char[], |
| 87 | const LazyHandle<TransformPropertyHandle>&) {} |
| 88 | |
| 89 | } // namespace skottie |