John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 20014 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 | #include "GraphicsJNI.h" |
| 19 | #include <android_runtime/AndroidRuntime.h> |
| 20 | |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame^] | 21 | #include <utils/RefBase.h> |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 22 | #include <CanvasProperty.h> |
| 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | using namespace uirenderer; |
| 27 | |
| 28 | #ifdef USE_OPENGL_RENDERER |
| 29 | |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 30 | static jlong createFloat(JNIEnv* env, jobject clazz, jfloat initialValue) { |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame^] | 31 | return reinterpret_cast<jlong>(new CanvasPropertyPrimitive(initialValue)); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | static jlong createPaint(JNIEnv* env, jobject clazz, jlong paintPtr) { |
| 35 | const SkPaint* paint = reinterpret_cast<const SkPaint*>(paintPtr); |
John Reck | 9fa4071 | 2014-05-09 15:26:59 -0700 | [diff] [blame^] | 36 | return reinterpret_cast<jlong>(new CanvasPropertyPaint(*paint)); |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | #endif |
| 40 | |
| 41 | // ---------------------------------------------------------------------------- |
| 42 | // JNI Glue |
| 43 | // ---------------------------------------------------------------------------- |
| 44 | |
| 45 | const char* const kClassPathName = "android/graphics/CanvasProperty"; |
| 46 | |
| 47 | static JNINativeMethod gMethods[] = { |
| 48 | #ifdef USE_OPENGL_RENDERER |
| 49 | { "nCreateFloat", "(F)J", (void*) createFloat }, |
| 50 | { "nCreatePaint", "(J)J", (void*) createPaint }, |
John Reck | 52244ff | 2014-05-01 21:27:37 -0700 | [diff] [blame] | 51 | #endif |
| 52 | }; |
| 53 | |
| 54 | int register_android_graphics_CanvasProperty(JNIEnv* env) { |
| 55 | return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); |
| 56 | } |
| 57 | |
| 58 | }; // namespace android |