blob: 245aa0f9020ea4d1c8d1d0ee88909d3f6efd4599 [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
Doris Liu1e67f082015-11-12 15:57:45 -080022#include <android/log.h>
Doris Liucdd23f92015-11-11 14:31:13 -080023#include "core_jni_helpers.h"
24
25namespace android {
26
27static bool parseStringForPath(JNIEnv* env, jobject, jlong skPathHandle, jstring inputPathStr,
28 jint strLength) {
29 const char* pathString = env->GetStringUTFChars(inputPathStr, NULL);
30 SkPath* skPath = reinterpret_cast<SkPath*>(skPathHandle);
Doris Liu1e67f082015-11-12 15:57:45 -080031
32 android::uirenderer::PathParser::ParseResult result;
33 android::uirenderer::PathParser::parseStringForSkPath(skPath, &result, pathString, strLength);
Doris Liucdd23f92015-11-11 14:31:13 -080034 env->ReleaseStringUTFChars(inputPathStr, pathString);
Doris Liu1e67f082015-11-12 15:57:45 -080035 if (result.failureOccurred) {
36 ALOGE(result.failureMessage.c_str());
37 }
38 return !result.failureOccurred;
Doris Liucdd23f92015-11-11 14:31:13 -080039}
40
41static const JNINativeMethod gMethods[] = {
42 {"nParseStringForPath", "(JLjava/lang/String;I)Z", (void*)parseStringForPath}
43};
44
45int register_android_util_PathParser(JNIEnv* env) {
46 return RegisterMethodsOrDie(env, "android/util/PathParser", gMethods, NELEM(gMethods));
47}
48};