blob: 40ce986b1a57257913957004d4643ff001586da5 [file] [log] [blame]
Doris Liu30bcf692015-11-04 14:56:24 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_HWUI_VPATH_H
18#define ANDROID_HWUI_VPATH_H
19
20#include "SkPath.h"
21#include <vector>
22
23namespace android {
24namespace uirenderer {
25
26
27
28struct PathData {
29 // TODO: Try using FatVector instead of std::vector and do a micro benchmark on the performance
30 // difference.
31 std::vector<char> verbs;
32 std::vector<size_t> verbSizes;
33 std::vector<float> points;
34 bool operator== (const PathData& data) const {
35 return verbs == data.verbs && verbSizes == data.verbSizes && points == data.points;
36 }
37
38};
39
40class VectorDrawablePath {
41public:
42 VectorDrawablePath(const PathData& nodes);
43 VectorDrawablePath(const VectorDrawablePath& path);
44 VectorDrawablePath(const char* path, size_t strLength);
45 bool canMorph(const PathData& path);
46 bool canMorph(const VectorDrawablePath& path);
47 static void verbsToPath(SkPath* outPath, const PathData* data);
48 static void interpolatePaths(PathData* outPathData, const PathData* from, const PathData* to,
49 float fraction);
50private:
51 PathData mData;
52 SkPath mSkPath;
53};
54
55} // namespace uirenderer
56} // namespace android
57
58#endif // ANDROID_HWUI_VPATH_H