blob: 0d27017968b3011ba6c6fbf58c8366347dc5a03c [file] [log] [blame]
/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkottieProperty.h"
#include "SkottieAdapter.h"
#include "SkSGColor.h"
#include "SkSGOpacityEffect.h"
namespace skottie {
bool TransformPropertyValue::operator==(const TransformPropertyValue& other) const {
return this->fAnchorPoint == other.fAnchorPoint
&& this->fPosition == other.fPosition
&& this->fScale == other.fScale
&& this->fSkew == other.fSkew
&& this->fSkewAxis == other.fSkewAxis;
}
bool TransformPropertyValue::operator!=(const TransformPropertyValue& other) const {
return !(*this == other);
}
template <>
PropertyHandle<ColorPropertyValue, sksg::Color>::~PropertyHandle() {}
template <>
ColorPropertyValue PropertyHandle<ColorPropertyValue, sksg::Color>::get() const {
return fNode->getColor();
}
template <>
void PropertyHandle<ColorPropertyValue, sksg::Color>::set(const ColorPropertyValue& c) {
fNode->setColor(c);
}
template <>
PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::~PropertyHandle() {}
template <>
OpacityPropertyValue PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::get() const {
return fNode->getOpacity() * 100;
}
template <>
void PropertyHandle<OpacityPropertyValue, sksg::OpacityEffect>::set(const OpacityPropertyValue& o) {
fNode->setOpacity(o / 100);
}
template <>
PropertyHandle<TransformPropertyValue, TransformAdapter>::~PropertyHandle() {}
template <>
TransformPropertyValue PropertyHandle<TransformPropertyValue, TransformAdapter>::get() const {
return {
fNode->getAnchorPoint(),
fNode->getPosition(),
fNode->getScale(),
fNode->getRotation(),
fNode->getSkew(),
fNode->getSkewAxis()
};
}
template <>
void PropertyHandle<TransformPropertyValue, TransformAdapter>::set(
const TransformPropertyValue& t) {
fNode->setAnchorPoint(t.fAnchorPoint);
fNode->setPosition(t.fPosition);
fNode->setScale(t.fScale);
fNode->setRotation(t.fRotation);
fNode->setSkew(t.fSkew);
fNode->setSkewAxis(t.fSkewAxis);
}
void PropertyObserver::onColorProperty(const char[],
const LazyHandle<ColorPropertyHandle>&) {}
void PropertyObserver::onOpacityProperty(const char[],
const LazyHandle<OpacityPropertyHandle>&) {}
void PropertyObserver::onTransformProperty(const char[],
const LazyHandle<TransformPropertyHandle>&) {}
} // namespace skottie