Chris Craik | 5438979 | 2013-12-20 13:28:11 -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 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 26 | #include <Animator.h> |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 27 | #include <DisplayListRenderer.h> |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 28 | #include <RenderNode.h> |
Behdad Esfahbod | 6ba30b8 | 2014-07-15 16:22:32 -0400 | [diff] [blame] | 29 | #include <Paint.h> |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 30 | |
| 31 | namespace android { |
| 32 | |
| 33 | using namespace uirenderer; |
| 34 | |
| 35 | /** |
| 36 | * Note: OpenGLRenderer JNI layer is generated and compiled only on supported |
| 37 | * devices. This means all the logic must be compiled only when the |
| 38 | * preprocessor variable USE_OPENGL_RENDERER is defined. |
| 39 | */ |
| 40 | #ifdef USE_OPENGL_RENDERER |
| 41 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 42 | #define SET_AND_DIRTY(prop, val, dirtyFlag) \ |
| 43 | (reinterpret_cast<RenderNode*>(renderNodePtr)->mutateStagingProperties().prop(val) \ |
| 44 | ? (reinterpret_cast<RenderNode*>(renderNodePtr)->setPropertyFieldsDirty(dirtyFlag), true) \ |
| 45 | : false) |
| 46 | |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 47 | // ---------------------------------------------------------------------------- |
| 48 | // DisplayList view properties |
| 49 | // ---------------------------------------------------------------------------- |
| 50 | |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 51 | static void android_view_RenderNode_output(JNIEnv* env, |
| 52 | jobject clazz, jlong renderNodePtr) { |
| 53 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 54 | renderNode->output(); |
| 55 | } |
| 56 | |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 57 | static jint android_view_RenderNode_getDebugSize(JNIEnv* env, |
| 58 | jobject clazz, jlong renderNodePtr) { |
| 59 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 60 | return renderNode->getDebugSize(); |
| 61 | } |
| 62 | |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 63 | static jlong android_view_RenderNode_create(JNIEnv* env, jobject clazz, jstring name) { |
| 64 | RenderNode* renderNode = new RenderNode(); |
| 65 | renderNode->incStrong(0); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 66 | if (name != NULL) { |
| 67 | const char* textArray = env->GetStringUTFChars(name, NULL); |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 68 | renderNode->setName(textArray); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 69 | env->ReleaseStringUTFChars(name, textArray); |
| 70 | } |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 71 | return reinterpret_cast<jlong>(renderNode); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 72 | } |
| 73 | |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 74 | static void android_view_RenderNode_destroyRenderNode(JNIEnv* env, |
| 75 | jobject clazz, jlong renderNodePtr) { |
| 76 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 77 | renderNode->decStrong(0); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 78 | } |
| 79 | |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 80 | static void android_view_RenderNode_setDisplayListData(JNIEnv* env, |
| 81 | jobject clazz, jlong renderNodePtr, jlong newDataPtr) { |
| 82 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 83 | DisplayListData* newData = reinterpret_cast<DisplayListData*>(newDataPtr); |
| 84 | renderNode->setStagingDisplayList(newData); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | // ---------------------------------------------------------------------------- |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 88 | // RenderProperties - setters |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 89 | // ---------------------------------------------------------------------------- |
| 90 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 91 | static jboolean android_view_RenderNode_setLayerType(JNIEnv* env, |
| 92 | jobject clazz, jlong renderNodePtr, jint jlayerType) { |
| 93 | LayerType layerType = static_cast<LayerType>(jlayerType); |
| 94 | return SET_AND_DIRTY(mutateLayerProperties().setType, layerType, RenderNode::GENERIC); |
| 95 | } |
| 96 | |
| 97 | static jboolean android_view_RenderNode_setLayerPaint(JNIEnv* env, |
| 98 | jobject clazz, jlong renderNodePtr, jlong paintPtr) { |
Behdad Esfahbod | 6ba30b8 | 2014-07-15 16:22:32 -0400 | [diff] [blame] | 99 | Paint* paint = reinterpret_cast<Paint*>(paintPtr); |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 100 | return SET_AND_DIRTY(mutateLayerProperties().setFromPaint, paint, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 101 | } |
| 102 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 103 | static jboolean android_view_RenderNode_setStaticMatrix(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 104 | jobject clazz, jlong renderNodePtr, jlong matrixPtr) { |
Chris Craik | 7a02ea3 | 2013-12-27 16:43:22 -0800 | [diff] [blame] | 105 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 106 | return SET_AND_DIRTY(setStaticMatrix, matrix, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 107 | } |
| 108 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 109 | static jboolean android_view_RenderNode_setAnimationMatrix(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 110 | jobject clazz, jlong renderNodePtr, jlong matrixPtr) { |
Chris Craik | 7a02ea3 | 2013-12-27 16:43:22 -0800 | [diff] [blame] | 111 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 112 | return SET_AND_DIRTY(setAnimationMatrix, matrix, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 113 | } |
| 114 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 115 | static jboolean android_view_RenderNode_setClipToBounds(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 116 | jobject clazz, jlong renderNodePtr, jboolean clipToBounds) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 117 | return SET_AND_DIRTY(setClipToBounds, clipToBounds, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 118 | } |
| 119 | |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 120 | static jboolean android_view_RenderNode_setClipBounds(JNIEnv* env, |
| 121 | jobject clazz, jlong renderNodePtr, jint left, jint top, jint right, jint bottom) { |
| 122 | android::uirenderer::Rect clipBounds(left, top, right, bottom); |
| 123 | return SET_AND_DIRTY(setClipBounds, clipBounds, RenderNode::GENERIC); |
| 124 | } |
| 125 | |
| 126 | static jboolean android_view_RenderNode_setClipBoundsEmpty(JNIEnv* env, |
| 127 | jobject clazz, jlong renderNodePtr) { |
| 128 | return SET_AND_DIRTY(setClipBoundsEmpty,, RenderNode::GENERIC); |
| 129 | } |
| 130 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 131 | static jboolean android_view_RenderNode_setProjectBackwards(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 132 | jobject clazz, jlong renderNodePtr, jboolean shouldProject) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 133 | return SET_AND_DIRTY(setProjectBackwards, shouldProject, RenderNode::GENERIC); |
Alan Viverette | 58f09b3 | 2014-01-08 17:18:19 -0800 | [diff] [blame] | 134 | } |
| 135 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 136 | static jboolean android_view_RenderNode_setProjectionReceiver(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 137 | jobject clazz, jlong renderNodePtr, jboolean shouldRecieve) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 138 | return SET_AND_DIRTY(setProjectionReceiver, shouldRecieve, RenderNode::GENERIC); |
Chris Craik | 1df2644 | 2014-02-05 16:50:41 -0800 | [diff] [blame] | 139 | } |
| 140 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 141 | static jboolean android_view_RenderNode_setOutlineRoundRect(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 142 | jobject clazz, jlong renderNodePtr, jint left, jint top, |
Chris Craik | 77b5cad | 2014-07-30 18:23:07 -0700 | [diff] [blame] | 143 | jint right, jint bottom, jfloat radius, jfloat alpha) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 144 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
Chris Craik | 77b5cad | 2014-07-30 18:23:07 -0700 | [diff] [blame] | 145 | renderNode->mutateStagingProperties().mutableOutline().setRoundRect(left, top, right, bottom, |
| 146 | radius, alpha); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 147 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 148 | return true; |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 149 | } |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 150 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 151 | static jboolean android_view_RenderNode_setOutlineConvexPath(JNIEnv* env, |
Chris Craik | 77b5cad | 2014-07-30 18:23:07 -0700 | [diff] [blame] | 152 | jobject clazz, jlong renderNodePtr, jlong outlinePathPtr, jfloat alpha) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 153 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 154 | SkPath* outlinePath = reinterpret_cast<SkPath*>(outlinePathPtr); |
Chris Craik | 77b5cad | 2014-07-30 18:23:07 -0700 | [diff] [blame] | 155 | renderNode->mutateStagingProperties().mutableOutline().setConvexPath(outlinePath, alpha); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 156 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 157 | return true; |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 158 | } |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 159 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 160 | static jboolean android_view_RenderNode_setOutlineEmpty(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 161 | jobject clazz, jlong renderNodePtr) { |
| 162 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 163 | renderNode->mutateStagingProperties().mutableOutline().setEmpty(); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 164 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 165 | return true; |
Chris Craik | a2fe7af | 2014-01-28 17:25:06 -0800 | [diff] [blame] | 166 | } |
| 167 | |
Chris Craik | 0645128 | 2014-07-21 10:25:54 -0700 | [diff] [blame] | 168 | static jboolean android_view_RenderNode_setOutlineNone(JNIEnv* env, |
| 169 | jobject clazz, jlong renderNodePtr) { |
| 170 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 171 | renderNode->mutateStagingProperties().mutableOutline().setNone(); |
| 172 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
| 173 | return true; |
| 174 | } |
| 175 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 176 | static jboolean android_view_RenderNode_setClipToOutline(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 177 | jobject clazz, jlong renderNodePtr, jboolean clipToOutline) { |
| 178 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 179 | renderNode->mutateStagingProperties().mutableOutline().setShouldClip(clipToOutline); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 180 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 181 | return true; |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 182 | } |
| 183 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 184 | static jboolean android_view_RenderNode_setRevealClip(JNIEnv* env, |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 185 | jobject clazz, jlong renderNodePtr, jboolean shouldClip, |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 186 | jfloat x, jfloat y, jfloat radius) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 187 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 188 | renderNode->mutateStagingProperties().mutableRevealClip().set( |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 189 | shouldClip, x, y, radius); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 190 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 191 | return true; |
ztenghui | fad4593 | 2014-02-06 10:33:58 -0800 | [diff] [blame] | 192 | } |
| 193 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 194 | static jboolean android_view_RenderNode_setAlpha(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 195 | jobject clazz, jlong renderNodePtr, float alpha) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 196 | return SET_AND_DIRTY(setAlpha, alpha, RenderNode::ALPHA); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 197 | } |
| 198 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 199 | static jboolean android_view_RenderNode_setHasOverlappingRendering(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 200 | jobject clazz, jlong renderNodePtr, bool hasOverlappingRendering) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 201 | return SET_AND_DIRTY(setHasOverlappingRendering, hasOverlappingRendering, |
| 202 | RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 203 | } |
| 204 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 205 | static jboolean android_view_RenderNode_setElevation(JNIEnv* env, |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 206 | jobject clazz, jlong renderNodePtr, float elevation) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 207 | return SET_AND_DIRTY(setElevation, elevation, RenderNode::Z); |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 208 | } |
| 209 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 210 | static jboolean android_view_RenderNode_setTranslationX(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 211 | jobject clazz, jlong renderNodePtr, float tx) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 212 | return SET_AND_DIRTY(setTranslationX, tx, RenderNode::TRANSLATION_X | RenderNode::X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 213 | } |
| 214 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 215 | static jboolean android_view_RenderNode_setTranslationY(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 216 | jobject clazz, jlong renderNodePtr, float ty) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 217 | return SET_AND_DIRTY(setTranslationY, ty, RenderNode::TRANSLATION_Y | RenderNode::Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 218 | } |
| 219 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 220 | static jboolean android_view_RenderNode_setTranslationZ(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 221 | jobject clazz, jlong renderNodePtr, float tz) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 222 | return SET_AND_DIRTY(setTranslationZ, tz, RenderNode::TRANSLATION_Z | RenderNode::Z); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 223 | } |
| 224 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 225 | static jboolean android_view_RenderNode_setRotation(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 226 | jobject clazz, jlong renderNodePtr, float rotation) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 227 | return SET_AND_DIRTY(setRotation, rotation, RenderNode::ROTATION); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 228 | } |
| 229 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 230 | static jboolean android_view_RenderNode_setRotationX(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 231 | jobject clazz, jlong renderNodePtr, float rx) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 232 | return SET_AND_DIRTY(setRotationX, rx, RenderNode::ROTATION_X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 233 | } |
| 234 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 235 | static jboolean android_view_RenderNode_setRotationY(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 236 | jobject clazz, jlong renderNodePtr, float ry) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 237 | return SET_AND_DIRTY(setRotationY, ry, RenderNode::ROTATION_Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 238 | } |
| 239 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 240 | static jboolean android_view_RenderNode_setScaleX(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 241 | jobject clazz, jlong renderNodePtr, float sx) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 242 | return SET_AND_DIRTY(setScaleX, sx, RenderNode::SCALE_X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 243 | } |
| 244 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 245 | static jboolean android_view_RenderNode_setScaleY(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 246 | jobject clazz, jlong renderNodePtr, float sy) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 247 | return SET_AND_DIRTY(setScaleY, sy, RenderNode::SCALE_Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 248 | } |
| 249 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 250 | static jboolean android_view_RenderNode_setPivotX(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 251 | jobject clazz, jlong renderNodePtr, float px) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 252 | return SET_AND_DIRTY(setPivotX, px, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 253 | } |
| 254 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 255 | static jboolean android_view_RenderNode_setPivotY(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 256 | jobject clazz, jlong renderNodePtr, float py) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 257 | return SET_AND_DIRTY(setPivotY, py, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 258 | } |
| 259 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 260 | static jboolean android_view_RenderNode_setCameraDistance(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 261 | jobject clazz, jlong renderNodePtr, float distance) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 262 | return SET_AND_DIRTY(setCameraDistance, distance, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 263 | } |
| 264 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 265 | static jboolean android_view_RenderNode_setLeft(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 266 | jobject clazz, jlong renderNodePtr, int left) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 267 | return SET_AND_DIRTY(setLeft, left, RenderNode::X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 268 | } |
| 269 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 270 | static jboolean android_view_RenderNode_setTop(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 271 | jobject clazz, jlong renderNodePtr, int top) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 272 | return SET_AND_DIRTY(setTop, top, RenderNode::Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 273 | } |
| 274 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 275 | static jboolean android_view_RenderNode_setRight(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 276 | jobject clazz, jlong renderNodePtr, int right) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 277 | return SET_AND_DIRTY(setRight, right, RenderNode::X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 278 | } |
| 279 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 280 | static jboolean android_view_RenderNode_setBottom(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 281 | jobject clazz, jlong renderNodePtr, int bottom) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 282 | return SET_AND_DIRTY(setBottom, bottom, RenderNode::Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 283 | } |
| 284 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 285 | static jboolean android_view_RenderNode_setLeftTopRightBottom(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 286 | jobject clazz, jlong renderNodePtr, int left, int top, |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 287 | int right, int bottom) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 288 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 289 | if (renderNode->mutateStagingProperties().setLeftTopRightBottom(left, top, right, bottom)) { |
| 290 | renderNode->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y); |
| 291 | return true; |
| 292 | } |
| 293 | return false; |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 294 | } |
| 295 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 296 | static jboolean android_view_RenderNode_offsetLeftAndRight(JNIEnv* env, |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 297 | jobject clazz, jlong renderNodePtr, jint offset) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 298 | return SET_AND_DIRTY(offsetLeftRight, offset, RenderNode::X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 299 | } |
| 300 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 301 | static jboolean android_view_RenderNode_offsetTopAndBottom(JNIEnv* env, |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 302 | jobject clazz, jlong renderNodePtr, jint offset) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 303 | return SET_AND_DIRTY(offsetTopBottom, offset, RenderNode::Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 304 | } |
| 305 | |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 306 | // ---------------------------------------------------------------------------- |
| 307 | // RenderProperties - getters |
| 308 | // ---------------------------------------------------------------------------- |
| 309 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 310 | static jboolean android_view_RenderNode_hasOverlappingRendering(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 311 | jobject clazz, jlong renderNodePtr) { |
| 312 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 313 | return renderNode->stagingProperties().hasOverlappingRendering(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 314 | } |
| 315 | |
Chris Craik | deeda3d | 2014-05-05 19:09:33 -0700 | [diff] [blame] | 316 | static jboolean android_view_RenderNode_getClipToOutline(JNIEnv* env, |
| 317 | jobject clazz, jlong renderNodePtr) { |
| 318 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 319 | return renderNode->stagingProperties().getOutline().getShouldClip(); |
| 320 | } |
| 321 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 322 | static jfloat android_view_RenderNode_getAlpha(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 323 | jobject clazz, jlong renderNodePtr) { |
| 324 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 325 | return renderNode->stagingProperties().getAlpha(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 326 | } |
| 327 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 328 | static jfloat android_view_RenderNode_getCameraDistance(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 329 | jobject clazz, jlong renderNodePtr) { |
| 330 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 331 | return renderNode->stagingProperties().getCameraDistance(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 332 | } |
| 333 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 334 | static jfloat android_view_RenderNode_getScaleX(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 335 | jobject clazz, jlong renderNodePtr) { |
| 336 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 337 | return renderNode->stagingProperties().getScaleX(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 338 | } |
| 339 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 340 | static jfloat android_view_RenderNode_getScaleY(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 341 | jobject clazz, jlong renderNodePtr) { |
| 342 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 343 | return renderNode->stagingProperties().getScaleY(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 344 | } |
| 345 | |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 346 | static jfloat android_view_RenderNode_getElevation(JNIEnv* env, |
| 347 | jobject clazz, jlong renderNodePtr) { |
| 348 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 349 | return renderNode->stagingProperties().getElevation(); |
| 350 | } |
| 351 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 352 | static jfloat android_view_RenderNode_getTranslationX(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 353 | jobject clazz, jlong renderNodePtr) { |
| 354 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 355 | return renderNode->stagingProperties().getTranslationX(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 356 | } |
| 357 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 358 | static jfloat android_view_RenderNode_getTranslationY(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 359 | jobject clazz, jlong renderNodePtr) { |
| 360 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 361 | return renderNode->stagingProperties().getTranslationY(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 362 | } |
| 363 | |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 364 | static jfloat android_view_RenderNode_getTranslationZ(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 365 | jobject clazz, jlong renderNodePtr) { |
| 366 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 367 | return renderNode->stagingProperties().getTranslationZ(); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 368 | } |
| 369 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 370 | static jfloat android_view_RenderNode_getRotation(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 371 | jobject clazz, jlong renderNodePtr) { |
| 372 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 373 | return renderNode->stagingProperties().getRotation(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 374 | } |
| 375 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 376 | static jfloat android_view_RenderNode_getRotationX(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 377 | jobject clazz, jlong renderNodePtr) { |
| 378 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 379 | return renderNode->stagingProperties().getRotationX(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 380 | } |
| 381 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 382 | static jfloat android_view_RenderNode_getRotationY(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 383 | jobject clazz, jlong renderNodePtr) { |
| 384 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 385 | return renderNode->stagingProperties().getRotationY(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 386 | } |
| 387 | |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 388 | static jboolean android_view_RenderNode_isPivotExplicitlySet(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 389 | jobject clazz, jlong renderNodePtr) { |
| 390 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 391 | return renderNode->stagingProperties().isPivotExplicitlySet(); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | static jboolean android_view_RenderNode_hasIdentityMatrix(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 395 | jobject clazz, jlong renderNodePtr) { |
| 396 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 397 | renderNode->mutateStagingProperties().updateMatrix(); |
| 398 | return !renderNode->stagingProperties().hasTransformMatrix(); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | // ---------------------------------------------------------------------------- |
| 402 | // RenderProperties - computed getters |
| 403 | // ---------------------------------------------------------------------------- |
| 404 | |
| 405 | static void android_view_RenderNode_getTransformMatrix(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 406 | jobject clazz, jlong renderNodePtr, jlong outMatrixPtr) { |
| 407 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 408 | SkMatrix* outMatrix = reinterpret_cast<SkMatrix*>(outMatrixPtr); |
| 409 | |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 410 | renderNode->mutateStagingProperties().updateMatrix(); |
| 411 | const SkMatrix* transformMatrix = renderNode->stagingProperties().getTransformMatrix(); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 412 | |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 413 | if (transformMatrix) { |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 414 | *outMatrix = *transformMatrix; |
| 415 | } else { |
| 416 | outMatrix->setIdentity(); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | static void android_view_RenderNode_getInverseTransformMatrix(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 421 | jobject clazz, jlong renderNodePtr, jlong outMatrixPtr) { |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 422 | // load transform matrix |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 423 | android_view_RenderNode_getTransformMatrix(env, clazz, renderNodePtr, outMatrixPtr); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 424 | SkMatrix* outMatrix = reinterpret_cast<SkMatrix*>(outMatrixPtr); |
| 425 | |
| 426 | // return it inverted |
| 427 | if (!outMatrix->invert(outMatrix)) { |
| 428 | // failed to load inverse, pass back identity |
| 429 | outMatrix->setIdentity(); |
| 430 | } |
| 431 | } |
| 432 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 433 | static jfloat android_view_RenderNode_getPivotX(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 434 | jobject clazz, jlong renderNodePtr) { |
| 435 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 436 | renderNode->mutateStagingProperties().updateMatrix(); |
| 437 | return renderNode->stagingProperties().getPivotX(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 438 | } |
| 439 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 440 | static jfloat android_view_RenderNode_getPivotY(JNIEnv* env, |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 441 | jobject clazz, jlong renderNodePtr) { |
| 442 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 443 | renderNode->mutateStagingProperties().updateMatrix(); |
| 444 | return renderNode->stagingProperties().getPivotY(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 445 | } |
| 446 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 447 | // ---------------------------------------------------------------------------- |
| 448 | // RenderProperties - Animations |
| 449 | // ---------------------------------------------------------------------------- |
| 450 | |
| 451 | static void android_view_RenderNode_addAnimator(JNIEnv* env, jobject clazz, |
| 452 | jlong renderNodePtr, jlong animatorPtr) { |
| 453 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 454 | RenderPropertyAnimator* animator = reinterpret_cast<RenderPropertyAnimator*>(animatorPtr); |
| 455 | renderNode->addAnimator(animator); |
| 456 | } |
| 457 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 458 | static void android_view_RenderNode_endAllAnimators(JNIEnv* env, jobject clazz, |
| 459 | jlong renderNodePtr) { |
| 460 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
John Reck | e2478d4 | 2014-09-03 16:46:05 -0700 | [diff] [blame] | 461 | renderNode->animators().endAllStagingAnimators(); |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 462 | } |
| 463 | |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 464 | #endif // USE_OPENGL_RENDERER |
| 465 | |
| 466 | // ---------------------------------------------------------------------------- |
| 467 | // JNI Glue |
| 468 | // ---------------------------------------------------------------------------- |
| 469 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 470 | const char* const kClassPathName = "android/view/RenderNode"; |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 471 | |
| 472 | static JNINativeMethod gMethods[] = { |
| 473 | #ifdef USE_OPENGL_RENDERER |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 474 | { "nCreate", "(Ljava/lang/String;)J", (void*) android_view_RenderNode_create }, |
| 475 | { "nDestroyRenderNode", "(J)V", (void*) android_view_RenderNode_destroyRenderNode }, |
| 476 | { "nSetDisplayListData", "(JJ)V", (void*) android_view_RenderNode_setDisplayListData }, |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 477 | { "nOutput", "(J)V", (void*) android_view_RenderNode_output }, |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 478 | { "nGetDebugSize", "(J)I", (void*) android_view_RenderNode_getDebugSize }, |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 479 | |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 480 | { "nSetLayerType", "(JI)Z", (void*) android_view_RenderNode_setLayerType }, |
| 481 | { "nSetLayerPaint", "(JJ)Z", (void*) android_view_RenderNode_setLayerPaint }, |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 482 | { "nSetStaticMatrix", "(JJ)Z", (void*) android_view_RenderNode_setStaticMatrix }, |
| 483 | { "nSetAnimationMatrix", "(JJ)Z", (void*) android_view_RenderNode_setAnimationMatrix }, |
| 484 | { "nSetClipToBounds", "(JZ)Z", (void*) android_view_RenderNode_setClipToBounds }, |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 485 | { "nSetClipBounds", "(JIIII)Z", (void*) android_view_RenderNode_setClipBounds }, |
| 486 | { "nSetClipBoundsEmpty", "(J)Z", (void*) android_view_RenderNode_setClipBoundsEmpty }, |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 487 | { "nSetProjectBackwards", "(JZ)Z", (void*) android_view_RenderNode_setProjectBackwards }, |
| 488 | { "nSetProjectionReceiver","(JZ)Z", (void*) android_view_RenderNode_setProjectionReceiver }, |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 489 | |
Chris Craik | 77b5cad | 2014-07-30 18:23:07 -0700 | [diff] [blame] | 490 | { "nSetOutlineRoundRect", "(JIIIIFF)Z", (void*) android_view_RenderNode_setOutlineRoundRect }, |
| 491 | { "nSetOutlineConvexPath", "(JJF)Z", (void*) android_view_RenderNode_setOutlineConvexPath }, |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 492 | { "nSetOutlineEmpty", "(J)Z", (void*) android_view_RenderNode_setOutlineEmpty }, |
Chris Craik | 0645128 | 2014-07-21 10:25:54 -0700 | [diff] [blame] | 493 | { "nSetOutlineNone", "(J)Z", (void*) android_view_RenderNode_setOutlineNone }, |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 494 | { "nSetClipToOutline", "(JZ)Z", (void*) android_view_RenderNode_setClipToOutline }, |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 495 | { "nSetRevealClip", "(JZFFF)Z", (void*) android_view_RenderNode_setRevealClip }, |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 496 | |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 497 | { "nSetAlpha", "(JF)Z", (void*) android_view_RenderNode_setAlpha }, |
| 498 | { "nSetHasOverlappingRendering", "(JZ)Z", |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 499 | (void*) android_view_RenderNode_setHasOverlappingRendering }, |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 500 | { "nSetElevation", "(JF)Z", (void*) android_view_RenderNode_setElevation }, |
| 501 | { "nSetTranslationX", "(JF)Z", (void*) android_view_RenderNode_setTranslationX }, |
| 502 | { "nSetTranslationY", "(JF)Z", (void*) android_view_RenderNode_setTranslationY }, |
| 503 | { "nSetTranslationZ", "(JF)Z", (void*) android_view_RenderNode_setTranslationZ }, |
| 504 | { "nSetRotation", "(JF)Z", (void*) android_view_RenderNode_setRotation }, |
| 505 | { "nSetRotationX", "(JF)Z", (void*) android_view_RenderNode_setRotationX }, |
| 506 | { "nSetRotationY", "(JF)Z", (void*) android_view_RenderNode_setRotationY }, |
| 507 | { "nSetScaleX", "(JF)Z", (void*) android_view_RenderNode_setScaleX }, |
| 508 | { "nSetScaleY", "(JF)Z", (void*) android_view_RenderNode_setScaleY }, |
| 509 | { "nSetPivotX", "(JF)Z", (void*) android_view_RenderNode_setPivotX }, |
| 510 | { "nSetPivotY", "(JF)Z", (void*) android_view_RenderNode_setPivotY }, |
| 511 | { "nSetCameraDistance", "(JF)Z", (void*) android_view_RenderNode_setCameraDistance }, |
| 512 | { "nSetLeft", "(JI)Z", (void*) android_view_RenderNode_setLeft }, |
| 513 | { "nSetTop", "(JI)Z", (void*) android_view_RenderNode_setTop }, |
| 514 | { "nSetRight", "(JI)Z", (void*) android_view_RenderNode_setRight }, |
| 515 | { "nSetBottom", "(JI)Z", (void*) android_view_RenderNode_setBottom }, |
| 516 | { "nSetLeftTopRightBottom","(JIIII)Z", (void*) android_view_RenderNode_setLeftTopRightBottom }, |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 517 | { "nOffsetLeftAndRight", "(JI)Z", (void*) android_view_RenderNode_offsetLeftAndRight }, |
| 518 | { "nOffsetTopAndBottom", "(JI)Z", (void*) android_view_RenderNode_offsetTopAndBottom }, |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 519 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 520 | { "nHasOverlappingRendering", "(J)Z", (void*) android_view_RenderNode_hasOverlappingRendering }, |
Chris Craik | deeda3d | 2014-05-05 19:09:33 -0700 | [diff] [blame] | 521 | { "nGetClipToOutline", "(J)Z", (void*) android_view_RenderNode_getClipToOutline }, |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 522 | { "nGetAlpha", "(J)F", (void*) android_view_RenderNode_getAlpha }, |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 523 | { "nGetCameraDistance", "(J)F", (void*) android_view_RenderNode_getCameraDistance }, |
| 524 | { "nGetScaleX", "(J)F", (void*) android_view_RenderNode_getScaleX }, |
| 525 | { "nGetScaleY", "(J)F", (void*) android_view_RenderNode_getScaleY }, |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 526 | { "nGetElevation", "(J)F", (void*) android_view_RenderNode_getElevation }, |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 527 | { "nGetTranslationX", "(J)F", (void*) android_view_RenderNode_getTranslationX }, |
| 528 | { "nGetTranslationY", "(J)F", (void*) android_view_RenderNode_getTranslationY }, |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 529 | { "nGetTranslationZ", "(J)F", (void*) android_view_RenderNode_getTranslationZ }, |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 530 | { "nGetRotation", "(J)F", (void*) android_view_RenderNode_getRotation }, |
| 531 | { "nGetRotationX", "(J)F", (void*) android_view_RenderNode_getRotationX }, |
| 532 | { "nGetRotationY", "(J)F", (void*) android_view_RenderNode_getRotationY }, |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 533 | { "nIsPivotExplicitlySet", "(J)Z", (void*) android_view_RenderNode_isPivotExplicitlySet }, |
| 534 | { "nHasIdentityMatrix", "(J)Z", (void*) android_view_RenderNode_hasIdentityMatrix }, |
| 535 | |
| 536 | { "nGetTransformMatrix", "(JJ)V", (void*) android_view_RenderNode_getTransformMatrix }, |
| 537 | { "nGetInverseTransformMatrix","(JJ)V", (void*) android_view_RenderNode_getInverseTransformMatrix }, |
| 538 | |
| 539 | { "nGetPivotX", "(J)F", (void*) android_view_RenderNode_getPivotX }, |
| 540 | { "nGetPivotY", "(J)F", (void*) android_view_RenderNode_getPivotY }, |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 541 | |
| 542 | { "nAddAnimator", "(JJ)V", (void*) android_view_RenderNode_addAnimator }, |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 543 | { "nEndAllAnimators", "(J)V", (void*) android_view_RenderNode_endAllAnimators }, |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 544 | #endif |
| 545 | }; |
| 546 | |
| 547 | #ifdef USE_OPENGL_RENDERER |
| 548 | #define FIND_CLASS(var, className) \ |
| 549 | var = env->FindClass(className); \ |
| 550 | LOG_FATAL_IF(! var, "Unable to find class " className); |
| 551 | |
| 552 | #define GET_METHOD_ID(var, clazz, methodName, methodDescriptor) \ |
| 553 | var = env->GetMethodID(clazz, methodName, methodDescriptor); \ |
| 554 | LOG_FATAL_IF(! var, "Unable to find method " methodName); |
| 555 | #else |
| 556 | #define FIND_CLASS(var, className) |
| 557 | #define GET_METHOD_ID(var, clazz, methodName, methodDescriptor) |
| 558 | #endif |
| 559 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 560 | int register_android_view_RenderNode(JNIEnv* env) { |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 561 | return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); |
| 562 | } |
| 563 | |
| 564 | }; |
| 565 | |