14bbc2931263b232fba61807fca00e127573eff42Doris Liu/*
24bbc2931263b232fba61807fca00e127573eff42Doris Liu * Copyright (C) 2015 The Android Open Source Project
34bbc2931263b232fba61807fca00e127573eff42Doris Liu *
44bbc2931263b232fba61807fca00e127573eff42Doris Liu * Licensed under the Apache License, Version 2.0 (the "License");
54bbc2931263b232fba61807fca00e127573eff42Doris Liu * you may not use this file except in compliance with the License.
64bbc2931263b232fba61807fca00e127573eff42Doris Liu * You may obtain a copy of the License at
74bbc2931263b232fba61807fca00e127573eff42Doris Liu *
84bbc2931263b232fba61807fca00e127573eff42Doris Liu *      http://www.apache.org/licenses/LICENSE-2.0
94bbc2931263b232fba61807fca00e127573eff42Doris Liu *
104bbc2931263b232fba61807fca00e127573eff42Doris Liu * Unless required by applicable law or agreed to in writing, software
114bbc2931263b232fba61807fca00e127573eff42Doris Liu * distributed under the License is distributed on an "AS IS" BASIS,
124bbc2931263b232fba61807fca00e127573eff42Doris Liu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134bbc2931263b232fba61807fca00e127573eff42Doris Liu * See the License for the specific language governing permissions and
144bbc2931263b232fba61807fca00e127573eff42Doris Liu * limitations under the License.
154bbc2931263b232fba61807fca00e127573eff42Doris Liu */
164bbc2931263b232fba61807fca00e127573eff42Doris Liu
174bbc2931263b232fba61807fca00e127573eff42Doris Liu#ifndef ANDROID_HWUI_VPATH_H
184bbc2931263b232fba61807fca00e127573eff42Doris Liu#define ANDROID_HWUI_VPATH_H
194bbc2931263b232fba61807fca00e127573eff42Doris Liu
20dccca44ffda4836b56a21da95a046c9708ffd49csergeyv#include "hwui/Canvas.h"
211d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu#include "DisplayList.h"
22766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu
234bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <SkBitmap.h>
244bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <SkColor.h>
251d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu#include <SkColorFilter.h>
26c2de46fadd4ca9c6aa2d9dd7a65b161b28fc6f3bDoris Liu#include <SkCanvas.h>
274bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <SkMatrix.h>
284bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <SkPaint.h>
294bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <SkPath.h>
304bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <SkPathMeasure.h>
314bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <SkRect.h>
32dbee9bb342cdfaa5155b1918f90262c05e2464cbTeng-Hui Zhu#include <SkShader.h>
334bbc2931263b232fba61807fca00e127573eff42Doris Liu
344bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <cutils/compiler.h>
354bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <stddef.h>
364bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <vector>
374bbc2931263b232fba61807fca00e127573eff42Doris Liu#include <string>
384bbc2931263b232fba61807fca00e127573eff42Doris Liu
394bbc2931263b232fba61807fca00e127573eff42Doris Liunamespace android {
404bbc2931263b232fba61807fca00e127573eff42Doris Liunamespace uirenderer {
414bbc2931263b232fba61807fca00e127573eff42Doris Liu
424bbc2931263b232fba61807fca00e127573eff42Doris Liunamespace VectorDrawable {
4332d7cda0b89a114171f14de0753674090b3d75fcDoris Liu#define VD_SET_PRIMITIVE_FIELD_WITH_FLAG(field, value, flag) (VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(field, (value)) ? ((flag) = true, true) : false)
4432d7cda0b89a114171f14de0753674090b3d75fcDoris Liu#define VD_SET_PROP(field, value) ((value) != (field) ? ((field) = (value), true) : false)
4532d7cda0b89a114171f14de0753674090b3d75fcDoris Liu#define VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(field, value) ({ bool retVal = VD_SET_PROP((mPrimitiveFields.field), (value));\
461d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    onPropertyChanged(); retVal;})
4732d7cda0b89a114171f14de0753674090b3d75fcDoris Liu#define UPDATE_SKPROP(field, value) ({bool retVal = ((field) != (value)); if ((field) != (value)) SkRefCnt_SafeAssign((field), (value)); retVal;})
484bbc2931263b232fba61807fca00e127573eff42Doris Liu
494bbc2931263b232fba61807fca00e127573eff42Doris Liu/* A VectorDrawable is composed of a tree of nodes.
504bbc2931263b232fba61807fca00e127573eff42Doris Liu * Each node can be a group node, or a path.
514bbc2931263b232fba61807fca00e127573eff42Doris Liu * A group node can have groups or paths as children, but a path node has
524bbc2931263b232fba61807fca00e127573eff42Doris Liu * no children.
534bbc2931263b232fba61807fca00e127573eff42Doris Liu * One example can be:
544bbc2931263b232fba61807fca00e127573eff42Doris Liu *                 Root Group
554bbc2931263b232fba61807fca00e127573eff42Doris Liu *                /    |     \
564bbc2931263b232fba61807fca00e127573eff42Doris Liu *           Group    Path    Group
574bbc2931263b232fba61807fca00e127573eff42Doris Liu *          /     \             |
584bbc2931263b232fba61807fca00e127573eff42Doris Liu *         Path   Path         Path
594bbc2931263b232fba61807fca00e127573eff42Doris Liu *
601d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * VectorDrawables are drawn into bitmap caches first, then the caches are drawn to the given
611d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * canvas with root alpha applied. Two caches are maintained for VD, one in UI thread, the other in
621d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * Render Thread. A generation id is used to keep track of changes in the vector drawable tree.
631d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * Each cache has their own generation id to track whether they are up to date with the latest
641d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * change in the tree.
651d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu *
661d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * Any property change to the vector drawable coming from UI thread (such as bulk setters to update
671d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * all the properties, and viewport change, etc.) are only modifying the staging properties. The
681d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * staging properties will then be marked dirty and will be pushed over to render thread properties
691d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * at sync point. If staging properties are not dirty at sync point, we sync backwards by updating
701d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu * staging properties with render thread properties to reflect the latest animation value.
711d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu *
724bbc2931263b232fba61807fca00e127573eff42Doris Liu */
731d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
741d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liuclass PropertyChangedListener {
751d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liupublic:
761d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    PropertyChangedListener(bool* dirty, bool* stagingDirty)
771d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            : mDirty(dirty), mStagingDirty(stagingDirty) {}
781d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    void onPropertyChanged() {
791d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            *mDirty = true;
801d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    }
811d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    void onStagingPropertyChanged() {
821d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            *mStagingDirty = true;
831d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    }
841d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liuprivate:
851d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    bool* mDirty;
861d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    bool* mStagingDirty;
871d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu};
881d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
894bbc2931263b232fba61807fca00e127573eff42Doris Liuclass ANDROID_API Node {
904bbc2931263b232fba61807fca00e127573eff42Doris Liupublic:
911d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    class Properties {
921d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    public:
931d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        Properties(Node* node) : mNode(node) {}
941d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        inline void onPropertyChanged() {
951d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mNode->onPropertyChanged(this);
961d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
971d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    private:
981d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        Node* mNode;
991d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    };
1004bbc2931263b232fba61807fca00e127573eff42Doris Liu    Node(const Node& node) {
1014bbc2931263b232fba61807fca00e127573eff42Doris Liu        mName = node.mName;
1024bbc2931263b232fba61807fca00e127573eff42Doris Liu    }
1034bbc2931263b232fba61807fca00e127573eff42Doris Liu    Node() {}
104c2de46fadd4ca9c6aa2d9dd7a65b161b28fc6f3bDoris Liu    virtual void draw(SkCanvas* outCanvas, const SkMatrix& currentMatrix,
1051d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float scaleX, float scaleY, bool useStagingData) = 0;
1064bbc2931263b232fba61807fca00e127573eff42Doris Liu    virtual void dump() = 0;
1074bbc2931263b232fba61807fca00e127573eff42Doris Liu    void setName(const char* name) {
1084bbc2931263b232fba61807fca00e127573eff42Doris Liu        mName = name;
1094bbc2931263b232fba61807fca00e127573eff42Doris Liu    }
1101d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    virtual void setPropertyChangedListener(PropertyChangedListener* listener) {
1111d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        mPropertyChangedListener = listener;
1121d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    }
1131d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    virtual void onPropertyChanged(Properties* properties) = 0;
1144bbc2931263b232fba61807fca00e127573eff42Doris Liu    virtual ~Node(){}
1151d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    virtual void syncProperties() = 0;
1164bbc2931263b232fba61807fca00e127573eff42Doris Liuprotected:
1174bbc2931263b232fba61807fca00e127573eff42Doris Liu    std::string mName;
1181d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    PropertyChangedListener* mPropertyChangedListener = nullptr;
1194bbc2931263b232fba61807fca00e127573eff42Doris Liu};
1204bbc2931263b232fba61807fca00e127573eff42Doris Liu
1214bbc2931263b232fba61807fca00e127573eff42Doris Liuclass ANDROID_API Path : public Node {
1224bbc2931263b232fba61807fca00e127573eff42Doris Liupublic:
1234bbc2931263b232fba61807fca00e127573eff42Doris Liu    struct ANDROID_API Data {
1244bbc2931263b232fba61807fca00e127573eff42Doris Liu        std::vector<char> verbs;
1254bbc2931263b232fba61807fca00e127573eff42Doris Liu        std::vector<size_t> verbSizes;
1264bbc2931263b232fba61807fca00e127573eff42Doris Liu        std::vector<float> points;
1274bbc2931263b232fba61807fca00e127573eff42Doris Liu        bool operator==(const Data& data) const {
1284bbc2931263b232fba61807fca00e127573eff42Doris Liu            return verbs == data.verbs && verbSizes == data.verbSizes
1294bbc2931263b232fba61807fca00e127573eff42Doris Liu                    && points == data.points;
1304bbc2931263b232fba61807fca00e127573eff42Doris Liu        }
1314bbc2931263b232fba61807fca00e127573eff42Doris Liu    };
1321d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
1331d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    class PathProperties : public Properties {
1341d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    public:
1351d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        PathProperties(Node* node) : Properties(node) {}
1361d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void syncProperties(const PathProperties& prop) {
1371d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mData = prop.mData;
1381d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            onPropertyChanged();
1391d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
1401d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setData(const Data& data) {
1411d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            // Updates the path data. Note that we don't generate a new Skia path right away
1421d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            // because there are cases where the animation is changing the path data, but the view
1431d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            // that hosts the VD has gone off screen, in which case we won't even draw. So we
1441d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            // postpone the Skia path generation to the draw time.
1451d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            if (data == mData) {
1461d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                return;
1471d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            }
1481d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mData = data;
1491d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            onPropertyChanged();
1501d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
1511d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
1521d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        const Data& getData() const {
1531d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mData;
1541d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
1551d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    private:
1561d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        Data mData;
1571d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    };
1581d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
1594bbc2931263b232fba61807fca00e127573eff42Doris Liu    Path(const Path& path);
1604bbc2931263b232fba61807fca00e127573eff42Doris Liu    Path(const char* path, size_t strLength);
1614bbc2931263b232fba61807fca00e127573eff42Doris Liu    Path() {}
1621d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
1634bbc2931263b232fba61807fca00e127573eff42Doris Liu    void dump() override;
164c2de46fadd4ca9c6aa2d9dd7a65b161b28fc6f3bDoris Liu    void draw(SkCanvas* outCanvas, const SkMatrix& groupStackedMatrix,
1651d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float scaleX, float scaleY, bool useStagingData) override;
1664bbc2931263b232fba61807fca00e127573eff42Doris Liu    static float getMatrixScale(const SkMatrix& groupStackedMatrix);
1671d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    virtual void syncProperties() override;
1681d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    virtual void onPropertyChanged(Properties* prop) override {
1691d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        if (prop == &mStagingProperties) {
1701d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mStagingPropertiesDirty = true;
1711d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            if (mPropertyChangedListener) {
1721d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                mPropertyChangedListener->onStagingPropertyChanged();
1731d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            }
1741d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        } else if (prop == &mProperties){
1751d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mSkPathDirty = true;
1761d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            if (mPropertyChangedListener) {
1771d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                mPropertyChangedListener->onPropertyChanged();
1781d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            }
1791d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
1801d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    }
1811d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    PathProperties* mutateStagingProperties() { return &mStagingProperties; }
1821d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    const PathProperties* stagingProperties() { return &mStagingProperties; }
1831d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
1841d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    // This should only be called from animations on RT
1851d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    PathProperties* mutateProperties() { return &mProperties; }
1864bbc2931263b232fba61807fca00e127573eff42Doris Liu
1874bbc2931263b232fba61807fca00e127573eff42Doris Liuprotected:
1884bbc2931263b232fba61807fca00e127573eff42Doris Liu    virtual const SkPath& getUpdatedPath();
1891d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    virtual void getStagingPath(SkPath* outPath);
19046591f4a2dbd785bcae2b82bb490e78208605ec8Teng-Hui Zhu    virtual void drawPath(SkCanvas *outCanvas, SkPath& renderPath,
1911d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float strokeScale, const SkMatrix& matrix, bool useStagingData) = 0;
1921d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
1931d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    // Internal data, render thread only.
1944bbc2931263b232fba61807fca00e127573eff42Doris Liu    bool mSkPathDirty = true;
1951d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    SkPath mSkPath;
1961d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
1971d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liuprivate:
1981d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    PathProperties mProperties = PathProperties(this);
1991d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    PathProperties mStagingProperties = PathProperties(this);
2001d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    bool mStagingPropertiesDirty = true;
2014bbc2931263b232fba61807fca00e127573eff42Doris Liu};
2024bbc2931263b232fba61807fca00e127573eff42Doris Liu
2034bbc2931263b232fba61807fca00e127573eff42Doris Liuclass ANDROID_API FullPath: public Path {
2044bbc2931263b232fba61807fca00e127573eff42Doris Liupublic:
2051d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    class FullPathProperties : public Properties {
2061d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    public:
2071d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        struct PrimitiveFields {
2081d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float strokeWidth = 0;
2091d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            SkColor strokeColor = SK_ColorTRANSPARENT;
2101d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float strokeAlpha = 1;
2111d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            SkColor fillColor = SK_ColorTRANSPARENT;
2121d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float fillAlpha = 1;
2131d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float trimPathStart = 0;
2141d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float trimPathEnd = 1;
2151d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float trimPathOffset = 0;
2161d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            int32_t strokeLineCap = SkPaint::Cap::kButt_Cap;
2171d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            int32_t strokeLineJoin = SkPaint::Join::kMiter_Join;
2181d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float strokeMiterLimit = 4;
2191d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            int fillType = 0; /* non-zero or kWinding_FillType in Skia */
2201d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        };
2211d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        FullPathProperties(Node* mNode) : Properties(mNode), mTrimDirty(false) {}
222ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu        ~FullPathProperties() {
223ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu            SkSafeUnref(fillGradient);
224ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu            SkSafeUnref(strokeGradient);
225ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu        }
2261d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void syncProperties(const FullPathProperties& prop) {
2271d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields = prop.mPrimitiveFields;
2281d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mTrimDirty = true;
229ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu            UPDATE_SKPROP(fillGradient, prop.fillGradient);
230ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu            UPDATE_SKPROP(strokeGradient, prop.strokeGradient);
2311d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            onPropertyChanged();
2321d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2331d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setFillGradient(SkShader* gradient) {
234ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu            if(UPDATE_SKPROP(fillGradient, gradient)) {
2351d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                onPropertyChanged();
2361d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            }
2371d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2381d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setStrokeGradient(SkShader* gradient) {
239ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu            if(UPDATE_SKPROP(strokeGradient, gradient)) {
2401d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                onPropertyChanged();
2411d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            }
2421d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2431d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        SkShader* getFillGradient() const {
2441d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return fillGradient;
2451d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2461d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        SkShader* getStrokeGradient() const {
2471d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return strokeGradient;
2481d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2491d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getStrokeWidth() const{
2501d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.strokeWidth;
2511d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2521d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setStrokeWidth(float strokeWidth) {
25332d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(strokeWidth, strokeWidth);
2541d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2551d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        SkColor getStrokeColor() const{
2561d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.strokeColor;
2571d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2581d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setStrokeColor(SkColor strokeColor) {
25932d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(strokeColor, strokeColor);
2601d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2611d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getStrokeAlpha() const{
2621d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.strokeAlpha;
2631d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2641d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setStrokeAlpha(float strokeAlpha) {
26532d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(strokeAlpha, strokeAlpha);
2661d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2671d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        SkColor getFillColor() const {
2681d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.fillColor;
2691d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2701d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setFillColor(SkColor fillColor) {
27132d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(fillColor, fillColor);
2721d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2731d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getFillAlpha() const{
2741d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.fillAlpha;
2751d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2761d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setFillAlpha(float fillAlpha) {
27732d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(fillAlpha, fillAlpha);
2781d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2791d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getTrimPathStart() const{
2801d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.trimPathStart;
2811d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2821d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setTrimPathStart(float trimPathStart) {
28332d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_WITH_FLAG(trimPathStart, trimPathStart, mTrimDirty);
2841d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2851d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getTrimPathEnd() const{
2861d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.trimPathEnd;
2871d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2881d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setTrimPathEnd(float trimPathEnd) {
28932d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_WITH_FLAG(trimPathEnd, trimPathEnd, mTrimDirty);
2901d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2911d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getTrimPathOffset() const{
2921d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.trimPathOffset;
2931d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
2941d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setTrimPathOffset(float trimPathOffset) {
29532d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_WITH_FLAG(trimPathOffset, trimPathOffset, mTrimDirty);
2961d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
297766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu
2981d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getStrokeMiterLimit() const {
2991d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.strokeMiterLimit;
3001d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
3011d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getStrokeLineCap() const {
3021d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.strokeLineCap;
3031d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
3041d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getStrokeLineJoin() const {
3051d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.strokeLineJoin;
3061d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
3071d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getFillType() const {
3081d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.fillType;
3091d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
3101d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        bool copyProperties(int8_t* outProperties, int length) const;
3111d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void updateProperties(float strokeWidth, SkColor strokeColor, float strokeAlpha,
3121d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                SkColor fillColor, float fillAlpha, float trimPathStart, float trimPathEnd,
3131d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                float trimPathOffset, float strokeMiterLimit, int strokeLineCap, int strokeLineJoin,
3141d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                int fillType) {
3151d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.strokeWidth = strokeWidth;
3161d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.strokeColor = strokeColor;
3171d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.strokeAlpha = strokeAlpha;
3181d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.fillColor = fillColor;
3191d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.fillAlpha = fillAlpha;
3201d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.trimPathStart = trimPathStart;
3211d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.trimPathEnd = trimPathEnd;
3221d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.trimPathOffset = trimPathOffset;
3231d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.strokeMiterLimit = strokeMiterLimit;
3241d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.strokeLineCap = strokeLineCap;
3251d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.strokeLineJoin = strokeLineJoin;
3261d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.fillType = fillType;
3271d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mTrimDirty = true;
3281d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            onPropertyChanged();
3291d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
3301d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        // Set property values during animation
3311d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setColorPropertyValue(int propertyId, int32_t value);
3321d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setPropertyValue(int propertyId, float value);
3331d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        bool mTrimDirty;
3341d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    private:
3351d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        enum class Property {
3361d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            strokeWidth = 0,
3371d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            strokeColor,
3381d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            strokeAlpha,
3391d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            fillColor,
3401d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            fillAlpha,
3411d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            trimPathStart,
3421d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            trimPathEnd,
3431d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            trimPathOffset,
3441d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            strokeLineCap,
3451d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            strokeLineJoin,
3461d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            strokeMiterLimit,
3471d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            fillType,
3481d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            count,
3491d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        };
3501d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        PrimitiveFields mPrimitiveFields;
351ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu        SkShader* fillGradient = nullptr;
352ad21fe27627c8f4a1de886a2d1c5296694dc3501Doris Liu        SkShader* strokeGradient = nullptr;
3531d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    };
354766431aa57c16ece8842287a92b2e7208e3b8ac3Doris Liu
3551d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    // Called from UI thread
3564bbc2931263b232fba61807fca00e127573eff42Doris Liu    FullPath(const FullPath& path); // for cloning
3574bbc2931263b232fba61807fca00e127573eff42Doris Liu    FullPath(const char* path, size_t strLength) : Path(path, strLength) {}
3584bbc2931263b232fba61807fca00e127573eff42Doris Liu    FullPath() : Path() {}
3591d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    void dump() override;
3601d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    FullPathProperties* mutateStagingProperties() { return &mStagingProperties; }
3611d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    const FullPathProperties* stagingProperties() { return &mStagingProperties; }
3621d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
3631d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    // This should only be called from animations on RT
3641d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    FullPathProperties* mutateProperties() { return &mProperties; }
3651d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
3661d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    virtual void syncProperties() override;
3671d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    virtual void onPropertyChanged(Properties* properties) override {
3681d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        Path::onPropertyChanged(properties);
3691d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        if (properties == &mStagingProperties) {
3701d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mStagingPropertiesDirty = true;
3711d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            if (mPropertyChangedListener) {
3721d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                mPropertyChangedListener->onStagingPropertyChanged();
3731d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            }
3741d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        } else if (properties == &mProperties) {
3751d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            if (mPropertyChangedListener) {
3761d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                mPropertyChangedListener->onPropertyChanged();
3771d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            }
3781d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
3794bbc2931263b232fba61807fca00e127573eff42Doris Liu    }
380dbee9bb342cdfaa5155b1918f90262c05e2464cbTeng-Hui Zhu
3814bbc2931263b232fba61807fca00e127573eff42Doris Liuprotected:
3824bbc2931263b232fba61807fca00e127573eff42Doris Liu    const SkPath& getUpdatedPath() override;
3831d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    void getStagingPath(SkPath* outPath) override;
38446591f4a2dbd785bcae2b82bb490e78208605ec8Teng-Hui Zhu    void drawPath(SkCanvas* outCanvas, SkPath& renderPath,
3851d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float strokeScale, const SkMatrix& matrix, bool useStagingData) override;
3864bbc2931263b232fba61807fca00e127573eff42Doris Liuprivate:
3871d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
3881d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    FullPathProperties mProperties = FullPathProperties(this);
3891d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    FullPathProperties mStagingProperties = FullPathProperties(this);
3901d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    bool mStagingPropertiesDirty = true;
3911d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
3921d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    // Intermediate data for drawing, render thread only
3934bbc2931263b232fba61807fca00e127573eff42Doris Liu    SkPath mTrimmedSkPath;
3941d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu
3954bbc2931263b232fba61807fca00e127573eff42Doris Liu};
3964bbc2931263b232fba61807fca00e127573eff42Doris Liu
3974bbc2931263b232fba61807fca00e127573eff42Doris Liuclass ANDROID_API ClipPath: public Path {
3984bbc2931263b232fba61807fca00e127573eff42Doris Liupublic:
3994bbc2931263b232fba61807fca00e127573eff42Doris Liu    ClipPath(const ClipPath& path) : Path(path) {}
4004bbc2931263b232fba61807fca00e127573eff42Doris Liu    ClipPath(const char* path, size_t strLength) : Path(path, strLength) {}
4014bbc2931263b232fba61807fca00e127573eff42Doris Liu    ClipPath() : Path() {}
4024bbc2931263b232fba61807fca00e127573eff42Doris Liu
4034bbc2931263b232fba61807fca00e127573eff42Doris Liuprotected:
40446591f4a2dbd785bcae2b82bb490e78208605ec8Teng-Hui Zhu    void drawPath(SkCanvas* outCanvas, SkPath& renderPath,
4051d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float strokeScale, const SkMatrix& matrix, bool useStagingData) override;
4064bbc2931263b232fba61807fca00e127573eff42Doris Liu};
4074bbc2931263b232fba61807fca00e127573eff42Doris Liu
4084bbc2931263b232fba61807fca00e127573eff42Doris Liuclass ANDROID_API Group: public Node {
4094bbc2931263b232fba61807fca00e127573eff42Doris Liupublic:
4101d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    class GroupProperties : public Properties {
4111d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    public:
4121d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        GroupProperties(Node* mNode) : Properties(mNode) {}
4131d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        struct PrimitiveFields {
4141d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float rotate = 0;
4151d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float pivotX = 0;
4161d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float pivotY = 0;
4171d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float scaleX = 1;
4181d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float scaleY = 1;
4191d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float translateX = 0;
4201d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            float translateY = 0;
4211d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        } mPrimitiveFields;
4221d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void syncProperties(const GroupProperties& prop) {
4231d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields = prop.mPrimitiveFields;
4241d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            onPropertyChanged();
4251d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4261d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getRotation() const {
4271d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.rotate;
4281d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4291d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setRotation(float rotation) {
43032d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(rotate, rotation);
4311d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4321d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getPivotX() const {
4331d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.pivotX;
4341d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4351d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setPivotX(float pivotX) {
43632d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(pivotX, pivotX);
4371d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4381d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getPivotY() const {
4391d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.pivotY;
4401d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4411d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setPivotY(float pivotY) {
44232d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(pivotY, pivotY);
4431d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4441d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getScaleX() const {
4451d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.scaleX;
4461d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4471d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setScaleX(float scaleX) {
44832d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(scaleX, scaleX);
4491d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4501d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getScaleY() const {
4511d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.scaleY;
4521d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4531d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setScaleY(float scaleY) {
45432d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(scaleY, scaleY);
4551d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4561d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getTranslateX() const {
4571d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.translateX;
4581d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4591d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setTranslateX(float translateX) {
46032d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(translateX, translateX);
4611d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4621d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getTranslateY() const {
4631d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            return mPrimitiveFields.translateY;
4641d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4651d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setTranslateY(float translateY) {
46632d7cda0b89a114171f14de0753674090b3d75fcDoris Liu            VD_SET_PRIMITIVE_FIELD_AND_NOTIFY(translateY, translateY);
4671d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4681d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void updateProperties(float rotate, float pivotX, float pivotY,
4691d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu                float scaleX, float scaleY, float translateX, float translateY) {
4701d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.rotate = rotate;
4711d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.pivotX = pivotX;
4721d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.pivotY = pivotY;
4731d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.scaleX = scaleX;
4741d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.scaleY = scaleY;
4751d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.translateX = translateX;
4761d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            mPrimitiveFields.translateY = translateY;
4771d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            onPropertyChanged();
4781d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        }
4791d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        void setPropertyValue(int propertyId, float value);
4801d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        float getPropertyValue(int propertyId) const;
4811d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        bool copyProperties(float* outProperties, int length) const;
4821d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        static bool isValidProperty(int propertyId);
4831d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu    private:
4841d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu        enum class Property {
4851d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            rotate = 0,
4861d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            pivotX,
4871d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            pivotY,
4881d8e194661085f9a18ab1b3cd12f9e19d3a86be5Doris Liu            scaleX,
489