blob: bf6ffc5487d2a754a2690660f76c46a34615c2e1 [file] [log] [blame]
Doris Liucdd23f92015-11-11 14:31:13 -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 "jni.h"
18
19#include <PathParser.h>
20#include <SkPath.h>
21
22#include "core_jni_helpers.h"
23
24namespace android {
25
26static bool parseStringForPath(JNIEnv* env, jobject, jlong skPathHandle, jstring inputPathStr,
27 jint strLength) {
28 const char* pathString = env->GetStringUTFChars(inputPathStr, NULL);
29 SkPath* skPath = reinterpret_cast<SkPath*>(skPathHandle);
30 bool hasValidData = android::uirenderer::PathParser::parseStringForSkPath(skPath, pathString,
31 strLength);
32 env->ReleaseStringUTFChars(inputPathStr, pathString);
33 return hasValidData;
34}
35
36static const JNINativeMethod gMethods[] = {
37 {"nParseStringForPath", "(JLjava/lang/String;I)Z", (void*)parseStringForPath}
38};
39
40int register_android_util_PathParser(JNIEnv* env) {
41 return RegisterMethodsOrDie(env, "android/util/PathParser", gMethods, NELEM(gMethods));
42}
43};