blob: c9a54ca870fa2386b47e9301bc2c7a9bda5a24c7 [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#include "VectorDrawablePath.h"
18
19#include "PathParser.h"
Doris Liu804618d2015-11-16 22:48:34 -080020#include "utils/VectorDrawableUtils.h"
Doris Liu30bcf692015-11-04 14:56:24 -080021
22#include <math.h>
23#include <utils/Log.h>
24
25namespace android {
26namespace uirenderer {
27
Doris Liu30bcf692015-11-04 14:56:24 -080028
29VectorDrawablePath::VectorDrawablePath(const char* pathStr, size_t strLength) {
Doris Liu1e67f082015-11-12 15:57:45 -080030 PathParser::ParseResult result;
31 PathParser::getPathDataFromString(&mData, &result, pathStr, strLength);
32 if (!result.failureOccurred) {
Doris Liu804618d2015-11-16 22:48:34 -080033 VectorDrawableUtils::verbsToPath(&mSkPath, mData);
Doris Liu1e67f082015-11-12 15:57:45 -080034 }
Doris Liu30bcf692015-11-04 14:56:24 -080035}
36
37VectorDrawablePath::VectorDrawablePath(const PathData& data) {
38 mData = data;
39 // Now we need to construct a path
Doris Liu804618d2015-11-16 22:48:34 -080040 VectorDrawableUtils::verbsToPath(&mSkPath, data);
Doris Liu30bcf692015-11-04 14:56:24 -080041}
42
43VectorDrawablePath::VectorDrawablePath(const VectorDrawablePath& path) {
44 mData = path.mData;
Doris Liu804618d2015-11-16 22:48:34 -080045 VectorDrawableUtils::verbsToPath(&mSkPath, mData);
Doris Liu30bcf692015-11-04 14:56:24 -080046}
47
Doris Liu30bcf692015-11-04 14:56:24 -080048
Doris Liu804618d2015-11-16 22:48:34 -080049bool VectorDrawablePath::canMorph(const PathData& morphTo) {
50 return VectorDrawableUtils::canMorph(mData, morphTo);
Doris Liu30bcf692015-11-04 14:56:24 -080051}
52
53bool VectorDrawablePath::canMorph(const VectorDrawablePath& path) {
54 return canMorph(path.mData);
55}
Doris Liu30bcf692015-11-04 14:56:24 -080056
Doris Liu30bcf692015-11-04 14:56:24 -080057
58}; // namespace uirenderer
59}; // namespace android