Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | #define LOG_TAG "OpenGLRenderer" |
| 18 | |
| 19 | #include <EGL/egl.h> |
| 20 | |
| 21 | #include "jni.h" |
| 22 | #include "GraphicsJNI.h" |
| 23 | #include <nativehelper/JNIHelp.h> |
| 24 | #include <android_runtime/AndroidRuntime.h> |
| 25 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 26 | #include <DisplayList.h> |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 27 | #include <DisplayListRenderer.h> |
| 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | using namespace uirenderer; |
| 32 | |
| 33 | /** |
| 34 | * Note: OpenGLRenderer JNI layer is generated and compiled only on supported |
| 35 | * devices. This means all the logic must be compiled only when the |
| 36 | * preprocessor variable USE_OPENGL_RENDERER is defined. |
| 37 | */ |
| 38 | #ifdef USE_OPENGL_RENDERER |
| 39 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 40 | // ---------------------------------------------------------------------------- |
| 41 | // DisplayList view properties |
| 42 | // ---------------------------------------------------------------------------- |
| 43 | |
Chet Haase | 6a2d17f | 2012-09-30 12:14:13 -0700 | [diff] [blame] | 44 | static void android_view_GLES20DisplayList_reset(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 45 | jobject clazz, jlong displayListHandle) { |
| 46 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | 6a2d17f | 2012-09-30 12:14:13 -0700 | [diff] [blame] | 47 | displayList->reset(); |
| 48 | } |
| 49 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 50 | static jint android_view_GLES20DisplayList_getDisplayListSize(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 51 | jobject clazz, jlong displayListHandle) { |
| 52 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 53 | return displayList->getSize(); |
| 54 | } |
| 55 | |
| 56 | static void android_view_GLES20DisplayList_setDisplayListName(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 57 | jobject clazz, jlong displayListHandle, jstring name) { |
| 58 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 59 | if (name != NULL) { |
| 60 | const char* textArray = env->GetStringUTFChars(name, NULL); |
| 61 | displayList->setName(textArray); |
| 62 | env->ReleaseStringUTFChars(name, textArray); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | static void android_view_GLES20DisplayList_destroyDisplayList(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 67 | jobject clazz, jlong displayListHandle) { |
| 68 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 69 | DisplayList::destroyDisplayListDeferred(displayList); |
| 70 | } |
| 71 | |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 72 | // ---------------------------------------------------------------------------- |
| 73 | // DisplayList view properties |
| 74 | // ---------------------------------------------------------------------------- |
| 75 | |
| 76 | static void android_view_GLES20DisplayList_setCaching(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 77 | jobject clazz, jlong displayListHandle, jboolean caching) { |
| 78 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 79 | displayList->setCaching(caching); |
| 80 | } |
| 81 | |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 82 | //serban |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 83 | static void android_view_GLES20DisplayList_setStaticMatrix(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 84 | jobject clazz, jlong displayListHandle, jlong matrixHandle) { |
| 85 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
| 86 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 87 | displayList->setStaticMatrix(matrix); |
| 88 | } |
| 89 | |
| 90 | static void android_view_GLES20DisplayList_setAnimationMatrix(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 91 | jobject clazz, jlong displayListHandle, jlong matrixHandle) { |
| 92 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
| 93 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); |
Chet Haase | 9420abd | 2012-03-29 16:28:32 -0700 | [diff] [blame] | 94 | displayList->setAnimationMatrix(matrix); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 95 | } |
| 96 | |
Chet Haase | dd67159 | 2013-04-19 14:54:34 -0700 | [diff] [blame] | 97 | static void android_view_GLES20DisplayList_setClipToBounds(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 98 | jobject clazz, jlong displayListHandle, jboolean clipToBounds) { |
| 99 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | dd67159 | 2013-04-19 14:54:34 -0700 | [diff] [blame] | 100 | displayList->setClipToBounds(clipToBounds); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | static void android_view_GLES20DisplayList_setAlpha(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 104 | jobject clazz, jlong displayListHandle, jfloat alpha) { |
| 105 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 106 | displayList->setAlpha(alpha); |
| 107 | } |
| 108 | |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 109 | static void android_view_GLES20DisplayList_setHasOverlappingRendering(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 110 | jobject clazz, jlong displayListHandle, jboolean hasOverlappingRendering) { |
| 111 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 112 | displayList->setHasOverlappingRendering(hasOverlappingRendering); |
| 113 | } |
| 114 | |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 115 | static void android_view_GLES20DisplayList_setTranslationX(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 116 | jobject clazz, jlong displayListHandle, jfloat tx) { |
| 117 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 118 | displayList->setTranslationX(tx); |
| 119 | } |
| 120 | |
| 121 | static void android_view_GLES20DisplayList_setTranslationY(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 122 | jobject clazz, jlong displayListHandle, jfloat ty) { |
| 123 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 124 | displayList->setTranslationY(ty); |
| 125 | } |
| 126 | |
| 127 | static void android_view_GLES20DisplayList_setRotation(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 128 | jobject clazz, jlong displayListHandle, jfloat rotation) { |
| 129 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 130 | displayList->setRotation(rotation); |
| 131 | } |
| 132 | |
| 133 | static void android_view_GLES20DisplayList_setRotationX(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 134 | jobject clazz, jlong displayListHandle, jfloat rx) { |
| 135 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 136 | displayList->setRotationX(rx); |
| 137 | } |
| 138 | |
| 139 | static void android_view_GLES20DisplayList_setRotationY(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 140 | jobject clazz, jlong displayListHandle, jfloat ry) { |
| 141 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 142 | displayList->setRotationY(ry); |
| 143 | } |
| 144 | |
| 145 | static void android_view_GLES20DisplayList_setScaleX(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 146 | jobject clazz, jlong displayListHandle, jfloat sx) { |
| 147 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 148 | displayList->setScaleX(sx); |
| 149 | } |
| 150 | |
| 151 | static void android_view_GLES20DisplayList_setScaleY(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 152 | jobject clazz, jlong displayListHandle, jfloat sy) { |
| 153 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 154 | displayList->setScaleY(sy); |
| 155 | } |
| 156 | |
| 157 | static void android_view_GLES20DisplayList_setTransformationInfo(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 158 | jobject clazz, jlong displayListHandle, jfloat alpha, |
| 159 | jfloat translationX, jfloat translationY, jfloat rotation, jfloat rotationX, jfloat rotationY, |
| 160 | jfloat scaleX, jfloat scaleY) { |
| 161 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 162 | displayList->setAlpha(alpha); |
| 163 | displayList->setTranslationX(translationX); |
| 164 | displayList->setTranslationY(translationY); |
| 165 | displayList->setRotation(rotation); |
| 166 | displayList->setRotationX(rotationX); |
| 167 | displayList->setRotationY(rotationY); |
| 168 | displayList->setScaleX(scaleX); |
| 169 | displayList->setScaleY(scaleY); |
| 170 | } |
| 171 | |
| 172 | static void android_view_GLES20DisplayList_setPivotX(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 173 | jobject clazz, jlong displayListHandle, jfloat px) { |
| 174 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 175 | displayList->setPivotX(px); |
| 176 | } |
| 177 | |
| 178 | static void android_view_GLES20DisplayList_setPivotY(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 179 | jobject clazz, jlong displayListHandle, jfloat py) { |
| 180 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 181 | displayList->setPivotY(py); |
| 182 | } |
| 183 | |
| 184 | static void android_view_GLES20DisplayList_setCameraDistance(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 185 | jobject clazz, jlong displayListHandle, jfloat distance) { |
| 186 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 187 | displayList->setCameraDistance(distance); |
| 188 | } |
| 189 | |
| 190 | static void android_view_GLES20DisplayList_setLeft(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 191 | jobject clazz, jlong displayListHandle, jint left) { |
| 192 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 193 | displayList->setLeft(left); |
| 194 | } |
| 195 | |
| 196 | static void android_view_GLES20DisplayList_setTop(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 197 | jobject clazz, jlong displayListHandle, jint top) { |
| 198 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 199 | displayList->setTop(top); |
| 200 | } |
| 201 | |
| 202 | static void android_view_GLES20DisplayList_setRight(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 203 | jobject clazz, jlong displayListHandle, jint right) { |
| 204 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 205 | displayList->setRight(right); |
| 206 | } |
| 207 | |
| 208 | static void android_view_GLES20DisplayList_setBottom(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 209 | jobject clazz, jlong displayListHandle, jint bottom) { |
| 210 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 211 | displayList->setBottom(bottom); |
| 212 | } |
| 213 | |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 214 | static void android_view_GLES20DisplayList_setLeftTopRightBottom(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 215 | jobject clazz, jlong displayListHandle, jint left, jint top, |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 216 | int right, int bottom) { |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 217 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 218 | displayList->setLeftTopRightBottom(left, top, right, bottom); |
| 219 | } |
| 220 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 221 | static void android_view_GLES20DisplayList_offsetLeftAndRight(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 222 | jobject clazz, jlong displayListHandle, jfloat offset) { |
| 223 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 224 | displayList->offsetLeftRight(offset); |
| 225 | } |
| 226 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 227 | static void android_view_GLES20DisplayList_offsetTopAndBottom(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 228 | jobject clazz, jlong displayListHandle, jfloat offset) { |
| 229 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 230 | displayList->offsetTopBottom(offset); |
| 231 | } |
| 232 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 233 | static void android_view_GLES20DisplayList_getMatrix(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 234 | jobject clazz, jlong displayListHandle, jlong matrixHandle) { |
| 235 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
| 236 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 237 | SkMatrix* source = displayList->getStaticMatrix(); |
| 238 | if (source) { |
| 239 | matrix->setConcat(SkMatrix::I(), *source); |
| 240 | } else { |
| 241 | matrix->setIdentity(); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | static jboolean android_view_GLES20DisplayList_hasOverlappingRendering(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 246 | jobject clazz, jlong displayListHandle) { |
| 247 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 248 | return displayList->hasOverlappingRendering(); |
| 249 | } |
| 250 | |
| 251 | static jfloat android_view_GLES20DisplayList_getAlpha(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 252 | jobject clazz, jlong displayListHandle) { |
| 253 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 254 | return displayList->getAlpha(); |
| 255 | } |
| 256 | |
| 257 | static jfloat android_view_GLES20DisplayList_getLeft(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 258 | jobject clazz, jlong displayListHandle) { |
| 259 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 260 | return displayList->getLeft(); |
| 261 | } |
| 262 | |
| 263 | static jfloat android_view_GLES20DisplayList_getTop(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 264 | jobject clazz, jlong displayListHandle) { |
| 265 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 266 | return displayList->getTop(); |
| 267 | } |
| 268 | |
| 269 | static jfloat android_view_GLES20DisplayList_getRight(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 270 | jobject clazz, jlong displayListHandle) { |
| 271 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 272 | return displayList->getRight(); |
| 273 | } |
| 274 | |
| 275 | static jfloat android_view_GLES20DisplayList_getBottom(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 276 | jobject clazz, jlong displayListHandle) { |
| 277 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 278 | return displayList->getBottom(); |
| 279 | } |
| 280 | |
| 281 | static jfloat android_view_GLES20DisplayList_getCameraDistance(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 282 | jobject clazz, jlong displayListHandle) { |
| 283 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 284 | return displayList->getCameraDistance(); |
| 285 | } |
| 286 | |
| 287 | static jfloat android_view_GLES20DisplayList_getScaleX(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 288 | jobject clazz, jlong displayListHandle) { |
| 289 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 290 | return displayList->getScaleX(); |
| 291 | } |
| 292 | |
| 293 | static jfloat android_view_GLES20DisplayList_getScaleY(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 294 | jobject clazz, jlong displayListHandle) { |
| 295 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 296 | return displayList->getScaleY(); |
| 297 | } |
| 298 | |
| 299 | static jfloat android_view_GLES20DisplayList_getTranslationX(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 300 | jobject clazz, jlong displayListHandle) { |
| 301 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 302 | return displayList->getTranslationX(); |
| 303 | } |
| 304 | |
| 305 | static jfloat android_view_GLES20DisplayList_getTranslationY(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 306 | jobject clazz, jlong displayListHandle) { |
| 307 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 308 | return displayList->getTranslationY(); |
| 309 | } |
| 310 | |
| 311 | static jfloat android_view_GLES20DisplayList_getRotation(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 312 | jobject clazz, jlong displayListHandle) { |
| 313 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 314 | return displayList->getRotation(); |
| 315 | } |
| 316 | |
| 317 | static jfloat android_view_GLES20DisplayList_getRotationX(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 318 | jobject clazz, jlong displayListHandle) { |
| 319 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 320 | return displayList->getRotationX(); |
| 321 | } |
| 322 | |
| 323 | static jfloat android_view_GLES20DisplayList_getRotationY(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 324 | jobject clazz, jlong displayListHandle) { |
| 325 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 326 | return displayList->getRotationY(); |
| 327 | } |
| 328 | |
| 329 | static jfloat android_view_GLES20DisplayList_getPivotX(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 330 | jobject clazz, jlong displayListHandle) { |
| 331 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 332 | return displayList->getPivotX(); |
| 333 | } |
| 334 | |
| 335 | static jfloat android_view_GLES20DisplayList_getPivotY(JNIEnv* env, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 336 | jobject clazz, jlong displayListHandle) { |
| 337 | DisplayList* displayList = reinterpret_cast<DisplayList*>(displayListHandle); |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 338 | return displayList->getPivotY(); |
| 339 | } |
| 340 | |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 341 | #endif // USE_OPENGL_RENDERER |
| 342 | |
| 343 | // ---------------------------------------------------------------------------- |
| 344 | // JNI Glue |
| 345 | // ---------------------------------------------------------------------------- |
| 346 | |
| 347 | const char* const kClassPathName = "android/view/GLES20DisplayList"; |
| 348 | |
| 349 | static JNINativeMethod gMethods[] = { |
| 350 | #ifdef USE_OPENGL_RENDERER |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 351 | { "nDestroyDisplayList", "(J)V", (void*) android_view_GLES20DisplayList_destroyDisplayList }, |
| 352 | { "nGetDisplayListSize", "(J)I", (void*) android_view_GLES20DisplayList_getDisplayListSize }, |
| 353 | { "nSetDisplayListName", "(JLjava/lang/String;)V", |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 354 | (void*) android_view_GLES20DisplayList_setDisplayListName }, |
| 355 | |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 356 | { "nReset", "(J)V", (void*) android_view_GLES20DisplayList_reset }, |
| 357 | { "nSetCaching", "(JZ)V", (void*) android_view_GLES20DisplayList_setCaching }, |
| 358 | { "nSetStaticMatrix", "(JJ)V", (void*) android_view_GLES20DisplayList_setStaticMatrix }, |
| 359 | { "nSetAnimationMatrix", "(JJ)V", (void*) android_view_GLES20DisplayList_setAnimationMatrix }, |
| 360 | { "nSetClipToBounds", "(JZ)V", (void*) android_view_GLES20DisplayList_setClipToBounds }, |
| 361 | { "nSetAlpha", "(JF)V", (void*) android_view_GLES20DisplayList_setAlpha }, |
| 362 | { "nSetHasOverlappingRendering", "(JZ)V", |
Chet Haase | db8c9a6 | 2012-03-21 18:54:18 -0700 | [diff] [blame] | 363 | (void*) android_view_GLES20DisplayList_setHasOverlappingRendering }, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 364 | { "nSetTranslationX", "(JF)V", (void*) android_view_GLES20DisplayList_setTranslationX }, |
| 365 | { "nSetTranslationY", "(JF)V", (void*) android_view_GLES20DisplayList_setTranslationY }, |
| 366 | { "nSetRotation", "(JF)V", (void*) android_view_GLES20DisplayList_setRotation }, |
| 367 | { "nSetRotationX", "(JF)V", (void*) android_view_GLES20DisplayList_setRotationX }, |
| 368 | { "nSetRotationY", "(JF)V", (void*) android_view_GLES20DisplayList_setRotationY }, |
| 369 | { "nSetScaleX", "(JF)V", (void*) android_view_GLES20DisplayList_setScaleX }, |
| 370 | { "nSetScaleY", "(JF)V", (void*) android_view_GLES20DisplayList_setScaleY }, |
| 371 | { "nSetTransformationInfo","(JFFFFFFFF)V", |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 372 | (void*) android_view_GLES20DisplayList_setTransformationInfo }, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 373 | { "nSetPivotX", "(JF)V", (void*) android_view_GLES20DisplayList_setPivotX }, |
| 374 | { "nSetPivotY", "(JF)V", (void*) android_view_GLES20DisplayList_setPivotY }, |
| 375 | { "nSetCameraDistance", "(JF)V", (void*) android_view_GLES20DisplayList_setCameraDistance }, |
| 376 | { "nSetLeft", "(JI)V", (void*) android_view_GLES20DisplayList_setLeft }, |
| 377 | { "nSetTop", "(JI)V", (void*) android_view_GLES20DisplayList_setTop }, |
| 378 | { "nSetRight", "(JI)V", (void*) android_view_GLES20DisplayList_setRight }, |
| 379 | { "nSetBottom", "(JI)V", (void*) android_view_GLES20DisplayList_setBottom }, |
| 380 | { "nSetLeftTopRightBottom","(JIIII)V", |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 381 | (void*) android_view_GLES20DisplayList_setLeftTopRightBottom }, |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 382 | { "nOffsetLeftAndRight", "(JF)V", (void*) android_view_GLES20DisplayList_offsetLeftAndRight }, |
| 383 | { "nOffsetTopAndBottom", "(JF)V", (void*) android_view_GLES20DisplayList_offsetTopAndBottom }, |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 384 | |
Romain Guy | 52036b1 | 2013-02-14 18:03:37 -0800 | [diff] [blame] | 385 | |
Ashok Bhat | a039843 | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 386 | { "nGetMatrix", "(JJ)V", (void*) android_view_GLES20DisplayList_getMatrix }, |
| 387 | { "nHasOverlappingRendering", "(J)Z", (void*) android_view_GLES20DisplayList_hasOverlappingRendering }, |
| 388 | { "nGetAlpha", "(J)F", (void*) android_view_GLES20DisplayList_getAlpha }, |
| 389 | { "nGetLeft", "(J)F", (void*) android_view_GLES20DisplayList_getLeft }, |
| 390 | { "nGetTop", "(J)F", (void*) android_view_GLES20DisplayList_getTop }, |
| 391 | { "nGetRight", "(J)F", (void*) android_view_GLES20DisplayList_getRight }, |
| 392 | { "nGetBottom", "(J)F", (void*) android_view_GLES20DisplayList_getBottom }, |
| 393 | { "nGetCameraDistance", "(J)F", (void*) android_view_GLES20DisplayList_getCameraDistance }, |
| 394 | { "nGetScaleX", "(J)F", (void*) android_view_GLES20DisplayList_getScaleX }, |
| 395 | { "nGetScaleY", "(J)F", (void*) android_view_GLES20DisplayList_getScaleY }, |
| 396 | { "nGetTranslationX", "(J)F", (void*) android_view_GLES20DisplayList_getTranslationX }, |
| 397 | { "nGetTranslationY", "(J)F", (void*) android_view_GLES20DisplayList_getTranslationY }, |
| 398 | { "nGetRotation", "(J)F", (void*) android_view_GLES20DisplayList_getRotation }, |
| 399 | { "nGetRotationX", "(J)F", (void*) android_view_GLES20DisplayList_getRotationX }, |
| 400 | { "nGetRotationY", "(J)F", (void*) android_view_GLES20DisplayList_getRotationY }, |
| 401 | { "nGetPivotX", "(J)F", (void*) android_view_GLES20DisplayList_getPivotX }, |
| 402 | { "nGetPivotY", "(J)F", (void*) android_view_GLES20DisplayList_getPivotY }, |
Chet Haase | a1cff50 | 2012-02-21 13:43:44 -0800 | [diff] [blame] | 403 | #endif |
| 404 | }; |
| 405 | |
| 406 | #ifdef USE_OPENGL_RENDERER |
| 407 | #define FIND_CLASS(var, className) \ |
| 408 | var = env->FindClass(className); \ |
| 409 | LOG_FATAL_IF(! var, "Unable to find class " className); |
| 410 | |
| 411 | #define GET_METHOD_ID(var, clazz, methodName, methodDescriptor) \ |
| 412 | var = env->GetMethodID(clazz, methodName, methodDescriptor); \ |
| 413 | LOG_FATAL_IF(! var, "Unable to find method " methodName); |
| 414 | #else |
| 415 | #define FIND_CLASS(var, className) |
| 416 | #define GET_METHOD_ID(var, clazz, methodName, methodDescriptor) |
| 417 | #endif |
| 418 | |
| 419 | int register_android_view_GLES20DisplayList(JNIEnv* env) { |
| 420 | return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); |
| 421 | } |
| 422 | |
| 423 | }; |
| 424 | |