blob: 7ca35b9e41fac87f0318b9657fee04a56b5feebc [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
16ColorPropertyHandle::ColorPropertyHandle(sk_sp<sksg::Color> color)
17 : fColor(std::move(color)) {
18 SkASSERT(fColor);
19}
20
21ColorPropertyHandle::~ColorPropertyHandle() = default;
22
23SkColor ColorPropertyHandle::getColor() const {
24 return fColor->getColor();
25}
26
27void ColorPropertyHandle::setColor(SkColor color) {
28 fColor->setColor(color);
29}
30
31OpacityPropertyHandle::OpacityPropertyHandle(sk_sp<sksg::OpacityEffect> opacity)
32 : fOpacity(std::move(opacity)) {
33 SkASSERT(fOpacity);
34}
35
36OpacityPropertyHandle::~OpacityPropertyHandle() = default;
37
38float OpacityPropertyHandle::getOpacity() const {
39 return fOpacity->getOpacity() * 100;
40}
41
42void OpacityPropertyHandle::setOpacity(float opacity) {
43 fOpacity->setOpacity(opacity / 100);
44}
45
46TransformPropertyHandle::TransformPropertyHandle(sk_sp<TransformAdapter> transform)
47 : fTransform(std::move(transform)) {
48 SkASSERT(fTransform);
49}
50
51TransformPropertyHandle::~TransformPropertyHandle() = default;
52
53SkPoint TransformPropertyHandle::getAnchorPoint() const {
54 return fTransform->getAnchorPoint();
55}
56
57void TransformPropertyHandle::setAnchorPoint(const SkPoint& ap) {
58 fTransform->setAnchorPoint(ap);
59}
60
61SkPoint TransformPropertyHandle::getPosition() const {
62 return fTransform->getPosition();
63}
64
65void TransformPropertyHandle::setPosition(const SkPoint& position) {
66 fTransform->setPosition(position);
67}
68
69SkVector TransformPropertyHandle::getScale() const {
70 return fTransform->getScale();
71}
72
73void TransformPropertyHandle::setScale(const SkVector& scale) {
74 fTransform->setScale(scale);
75}
76
77SkScalar TransformPropertyHandle::getRotation() const {
78 return fTransform->getRotation();
79}
80
81void TransformPropertyHandle::setRotation(SkScalar rotation) {
82 fTransform->setRotation(rotation);
83}
84
85SkScalar TransformPropertyHandle::getSkew() const {
86 return fTransform->getSkew();
87}
88
89void TransformPropertyHandle::setSkew(SkScalar skew) {
90 fTransform->setSkew(skew);
91}
92
93SkScalar TransformPropertyHandle::getSkewAxis() const {
94 return fTransform->getSkewAxis();
95}
96
97void TransformPropertyHandle::setSkewAxis(SkScalar sa) {
98 fTransform->setSkewAxis(sa);
99}
100
101SkMatrix TransformPropertyHandle::getTotalMatrix() const {
102 return fTransform->totalMatrix();
103}
104
105void PropertyObserver::onColorProperty(const char[],
106 const LazyHandle<ColorPropertyHandle>&) {}
107
108void PropertyObserver::onOpacityProperty(const char[],
109 const LazyHandle<OpacityPropertyHandle>&) {}
110
111void PropertyObserver::onTransformProperty(const char[],
112 const LazyHandle<TransformPropertyHandle>&) {}
113
114} // namespace skottie