android_frameworks_base/libs/hwui/VectorDrawablePath.cpp
Doris Liu 804618d086 VectorDrawable native rendering - Step 2 of MANY
Introduced PathData in Java, which is effectively a thin layer around the
native instance. PathData holds the verbs and points which is being used
in path morphing/interpolation. The verbs and points can be interpreted
into skia path commands, which is now done in native and therefore saves
a handful of JNI calls during path creation.

Removed the old PathDataNode mechanism and changed the PathEvaluator
to use PathData instead.

Also added tests and a microbench. Also ran CTS tests for VectorDrawable
and AnimatedVectorDrawable, and passed all of the existing tests.

Change-Id: Ia166f5172ff031fe18b154327967f911a62caec1
2015-11-18 13:38:23 -08:00

60 lines
1.7 KiB
C++

/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "VectorDrawablePath.h"
#include "PathParser.h"
#include "utils/VectorDrawableUtils.h"
#include <math.h>
#include <utils/Log.h>
namespace android {
namespace uirenderer {
VectorDrawablePath::VectorDrawablePath(const char* pathStr, size_t strLength) {
PathParser::ParseResult result;
PathParser::getPathDataFromString(&mData, &result, pathStr, strLength);
if (!result.failureOccurred) {
VectorDrawableUtils::verbsToPath(&mSkPath, mData);
}
}
VectorDrawablePath::VectorDrawablePath(const PathData& data) {
mData = data;
// Now we need to construct a path
VectorDrawableUtils::verbsToPath(&mSkPath, data);
}
VectorDrawablePath::VectorDrawablePath(const VectorDrawablePath& path) {
mData = path.mData;
VectorDrawableUtils::verbsToPath(&mSkPath, mData);
}
bool VectorDrawablePath::canMorph(const PathData& morphTo) {
return VectorDrawableUtils::canMorph(mData, morphTo);
}
bool VectorDrawablePath::canMorph(const VectorDrawablePath& path) {
return canMorph(path.mData);
}
}; // namespace uirenderer
}; // namespace android