blob: 684ee23b9fca0dbb6e82764703011defb250ecf9 [file] [log] [blame]
John Reck52244ff2014-05-01 21:27:37 -07001/*
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
John Reck52244ff2014-05-01 21:27:37 -070017#include "GraphicsJNI.h"
John Reck52244ff2014-05-01 21:27:37 -070018
sergeyvdccca442016-03-21 15:38:21 -070019#include <hwui/Paint.h>
John Reck9fa40712014-05-09 15:26:59 -070020#include <utils/RefBase.h>
John Reck52244ff2014-05-01 21:27:37 -070021#include <CanvasProperty.h>
22
23namespace android {
24
Andreas Gampeed6b9df2014-11-20 22:02:20 -080025using namespace uirenderer;
John Reck52244ff2014-05-01 21:27:37 -070026
John Reck52244ff2014-05-01 21:27:37 -070027static jlong createFloat(JNIEnv* env, jobject clazz, jfloat initialValue) {
John Reck9fa40712014-05-09 15:26:59 -070028 return reinterpret_cast<jlong>(new CanvasPropertyPrimitive(initialValue));
John Reck52244ff2014-05-01 21:27:37 -070029}
30
31static jlong createPaint(JNIEnv* env, jobject clazz, jlong paintPtr) {
Behdad Esfahbod6ba30b82014-07-15 16:22:32 -040032 const Paint* paint = reinterpret_cast<const Paint*>(paintPtr);
John Reck9fa40712014-05-09 15:26:59 -070033 return reinterpret_cast<jlong>(new CanvasPropertyPaint(*paint));
John Reck52244ff2014-05-01 21:27:37 -070034}
35
John Reck52244ff2014-05-01 21:27:37 -070036// ----------------------------------------------------------------------------
37// JNI Glue
38// ----------------------------------------------------------------------------
39
Daniel Micay76f6a862015-09-19 17:31:01 -040040static const JNINativeMethod gMethods[] = {
John Reck52244ff2014-05-01 21:27:37 -070041 { "nCreateFloat", "(F)J", (void*) createFloat },
42 { "nCreatePaint", "(J)J", (void*) createPaint },
John Reck52244ff2014-05-01 21:27:37 -070043};
44
45int register_android_graphics_CanvasProperty(JNIEnv* env) {
John Recka2732a22014-12-18 13:52:33 -080046 return RegisterMethodsOrDie(env, "android/graphics/CanvasProperty", gMethods,
47 NELEM(gMethods));
John Reck52244ff2014-05-01 21:27:37 -070048}
49
50}; // namespace android