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