Doris Liu | cdd23f9 | 2015-11-11 14:31:13 -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 | #include "jni.h" |
| 18 | |
| 19 | #include <PathParser.h> |
| 20 | #include <SkPath.h> |
| 21 | |
Doris Liu | 1e67f08 | 2015-11-12 15:57:45 -0800 | [diff] [blame^] | 22 | #include <android/log.h> |
Doris Liu | cdd23f9 | 2015-11-11 14:31:13 -0800 | [diff] [blame] | 23 | #include "core_jni_helpers.h" |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | static 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 Liu | 1e67f08 | 2015-11-12 15:57:45 -0800 | [diff] [blame^] | 31 | |
| 32 | android::uirenderer::PathParser::ParseResult result; |
| 33 | android::uirenderer::PathParser::parseStringForSkPath(skPath, &result, pathString, strLength); |
Doris Liu | cdd23f9 | 2015-11-11 14:31:13 -0800 | [diff] [blame] | 34 | env->ReleaseStringUTFChars(inputPathStr, pathString); |
Doris Liu | 1e67f08 | 2015-11-12 15:57:45 -0800 | [diff] [blame^] | 35 | if (result.failureOccurred) { |
| 36 | ALOGE(result.failureMessage.c_str()); |
| 37 | } |
| 38 | return !result.failureOccurred; |
Doris Liu | cdd23f9 | 2015-11-11 14:31:13 -0800 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | static const JNINativeMethod gMethods[] = { |
| 42 | {"nParseStringForPath", "(JLjava/lang/String;I)Z", (void*)parseStringForPath} |
| 43 | }; |
| 44 | |
| 45 | int register_android_util_PathParser(JNIEnv* env) { |
| 46 | return RegisterMethodsOrDie(env, "android/util/PathParser", gMethods, NELEM(gMethods)); |
| 47 | } |
| 48 | }; |