Doris Liu | 30bcf69 | 2015-11-04 14:56:24 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
Doris Liu | 804618d | 2015-11-16 22:48:34 -0800 | [diff] [blame] | 20 | #include <cutils/compiler.h> |
Doris Liu | 30bcf69 | 2015-11-04 14:56:24 -0800 | [diff] [blame] | 21 | #include "SkPath.h" |
| 22 | #include <vector> |
| 23 | |
| 24 | namespace android { |
| 25 | namespace uirenderer { |
| 26 | |
Doris Liu | 804618d | 2015-11-16 22:48:34 -0800 | [diff] [blame] | 27 | struct ANDROID_API PathData { |
Doris Liu | 30bcf69 | 2015-11-04 14:56:24 -0800 | [diff] [blame] | 28 | // TODO: Try using FatVector instead of std::vector and do a micro benchmark on the performance |
| 29 | // difference. |
| 30 | std::vector<char> verbs; |
| 31 | std::vector<size_t> verbSizes; |
| 32 | std::vector<float> points; |
| 33 | bool operator== (const PathData& data) const { |
| 34 | return verbs == data.verbs && verbSizes == data.verbSizes && points == data.points; |
| 35 | } |
| 36 | |
| 37 | }; |
| 38 | |
| 39 | class VectorDrawablePath { |
| 40 | public: |
| 41 | VectorDrawablePath(const PathData& nodes); |
| 42 | VectorDrawablePath(const VectorDrawablePath& path); |
| 43 | VectorDrawablePath(const char* path, size_t strLength); |
| 44 | bool canMorph(const PathData& path); |
| 45 | bool canMorph(const VectorDrawablePath& path); |
Doris Liu | 804618d | 2015-11-16 22:48:34 -0800 | [diff] [blame] | 46 | |
Doris Liu | 30bcf69 | 2015-11-04 14:56:24 -0800 | [diff] [blame] | 47 | private: |
| 48 | PathData mData; |
| 49 | SkPath mSkPath; |
| 50 | }; |
| 51 | |
| 52 | } // namespace uirenderer |
| 53 | } // namespace android |
| 54 | |
| 55 | #endif // ANDROID_HWUI_VPATH_H |