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" |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 18 | #define ATRACE_TAG ATRACE_TAG_VIEW |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 19 | |
| 20 | #include <EGL/egl.h> |
| 21 | |
| 22 | #include "jni.h" |
| 23 | #include "GraphicsJNI.h" |
| 24 | #include <nativehelper/JNIHelp.h> |
| 25 | #include <android_runtime/AndroidRuntime.h> |
| 26 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 27 | #include <Animator.h> |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 28 | #include <DamageAccumulator.h> |
| 29 | #include <Matrix.h> |
John Reck | 113e082 | 2014-03-18 09:22:59 -0700 | [diff] [blame] | 30 | #include <RenderNode.h> |
John Reck | 38f6c03 | 2016-03-17 10:23:49 -0700 | [diff] [blame] | 31 | #include <renderthread/CanvasContext.h> |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 32 | #include <TreeInfo.h> |
sergeyv | dccca44 | 2016-03-21 15:38:21 -0700 | [diff] [blame] | 33 | #include <hwui/Paint.h> |
John Reck | 322b8ab | 2019-03-14 13:15:28 -0700 | [diff] [blame] | 34 | #include <utils/TraceUtils.h> |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 35 | |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 36 | #include "core_jni_helpers.h" |
| 37 | |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 38 | namespace android { |
| 39 | |
| 40 | using namespace uirenderer; |
| 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 | |
Chris Craik | 26bced4 | 2016-12-15 16:33:47 -0800 | [diff] [blame] | 51 | static void android_view_RenderNode_output(JNIEnv* env, jobject clazz, jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 52 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 53 | renderNode->output(); |
| 54 | } |
| 55 | |
Chris Craik | 26bced4 | 2016-12-15 16:33:47 -0800 | [diff] [blame] | 56 | static jint android_view_RenderNode_getDebugSize(JNIEnv* env, jobject clazz, jlong renderNodePtr) { |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 57 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 58 | return renderNode->getDebugSize(); |
| 59 | } |
| 60 | |
John Reck | 2de950d | 2017-01-25 10:58:30 -0800 | [diff] [blame] | 61 | static jlong android_view_RenderNode_create(JNIEnv* env, jobject, jstring name) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 62 | RenderNode* renderNode = new RenderNode(); |
| 63 | renderNode->incStrong(0); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 64 | if (name != NULL) { |
| 65 | const char* textArray = env->GetStringUTFChars(name, NULL); |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 66 | renderNode->setName(textArray); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 67 | env->ReleaseStringUTFChars(name, textArray); |
| 68 | } |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 69 | return reinterpret_cast<jlong>(renderNode); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 70 | } |
| 71 | |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 72 | static void releaseRenderNode(RenderNode* renderNode) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 73 | renderNode->decStrong(0); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 74 | } |
| 75 | |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 76 | static jlong android_view_RenderNode_getNativeFinalizer(JNIEnv* env, |
| 77 | jobject clazz) { |
| 78 | return static_cast<jlong>(reinterpret_cast<uintptr_t>(&releaseRenderNode)); |
| 79 | } |
| 80 | |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 81 | static void android_view_RenderNode_setDisplayList(JNIEnv* env, |
| 82 | jobject clazz, jlong renderNodePtr, jlong displayListPtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 83 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 84 | DisplayList* newData = reinterpret_cast<DisplayList*>(displayListPtr); |
John Reck | 2de950d | 2017-01-25 10:58:30 -0800 | [diff] [blame] | 85 | renderNode->setStagingDisplayList(newData); |
| 86 | } |
| 87 | |
| 88 | static jboolean android_view_RenderNode_isValid(jlong renderNodePtr) { |
| 89 | return reinterpret_cast<RenderNode*>(renderNodePtr)->isValid(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | // ---------------------------------------------------------------------------- |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 93 | // RenderProperties - setters |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 94 | // ---------------------------------------------------------------------------- |
| 95 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 96 | static jboolean android_view_RenderNode_setLayerType(jlong renderNodePtr, jint jlayerType) { |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 97 | LayerType layerType = static_cast<LayerType>(jlayerType); |
| 98 | return SET_AND_DIRTY(mutateLayerProperties().setType, layerType, RenderNode::GENERIC); |
| 99 | } |
| 100 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 101 | static jboolean android_view_RenderNode_setLayerPaint(jlong renderNodePtr, jlong paintPtr) { |
Behdad Esfahbod | 6ba30b8 | 2014-07-15 16:22:32 -0400 | [diff] [blame] | 102 | Paint* paint = reinterpret_cast<Paint*>(paintPtr); |
John Reck | 25fbb3f | 2014-06-12 13:46:45 -0700 | [diff] [blame] | 103 | return SET_AND_DIRTY(mutateLayerProperties().setFromPaint, paint, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 104 | } |
| 105 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 106 | static jboolean android_view_RenderNode_setStaticMatrix(jlong renderNodePtr, jlong matrixPtr) { |
Chris Craik | 7a02ea3 | 2013-12-27 16:43:22 -0800 | [diff] [blame] | 107 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 108 | return SET_AND_DIRTY(setStaticMatrix, matrix, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 109 | } |
| 110 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 111 | static jboolean android_view_RenderNode_setAnimationMatrix(jlong renderNodePtr, jlong matrixPtr) { |
Chris Craik | 7a02ea3 | 2013-12-27 16:43:22 -0800 | [diff] [blame] | 112 | SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixPtr); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 113 | return SET_AND_DIRTY(setAnimationMatrix, matrix, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 114 | } |
| 115 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 116 | static jboolean android_view_RenderNode_setClipToBounds(jlong renderNodePtr, |
| 117 | jboolean clipToBounds) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 118 | return SET_AND_DIRTY(setClipToBounds, clipToBounds, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 119 | } |
| 120 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 121 | static jboolean android_view_RenderNode_setClipBounds(jlong renderNodePtr, |
| 122 | jint left, jint top, jint right, jint bottom) { |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 123 | android::uirenderer::Rect clipBounds(left, top, right, bottom); |
| 124 | return SET_AND_DIRTY(setClipBounds, clipBounds, RenderNode::GENERIC); |
| 125 | } |
| 126 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 127 | static jboolean android_view_RenderNode_setClipBoundsEmpty(jlong renderNodePtr) { |
Chris Craik | a753f4c | 2014-07-24 12:39:17 -0700 | [diff] [blame] | 128 | return SET_AND_DIRTY(setClipBoundsEmpty,, RenderNode::GENERIC); |
| 129 | } |
| 130 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 131 | static jboolean android_view_RenderNode_setProjectBackwards(jlong renderNodePtr, |
| 132 | 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 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 136 | static jboolean android_view_RenderNode_setProjectionReceiver(jlong renderNodePtr, |
| 137 | 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 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 141 | static jboolean android_view_RenderNode_setOutlineRoundRect(jlong renderNodePtr, |
| 142 | jint left, jint top, jint right, jint bottom, jfloat radius, jfloat alpha) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 143 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
Chris Craik | 77b5cad | 2014-07-30 18:23:07 -0700 | [diff] [blame] | 144 | renderNode->mutateStagingProperties().mutableOutline().setRoundRect(left, top, right, bottom, |
| 145 | radius, alpha); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 146 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 147 | return true; |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 148 | } |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 149 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 150 | static jboolean android_view_RenderNode_setOutlineConvexPath(jlong renderNodePtr, |
| 151 | jlong outlinePathPtr, jfloat alpha) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 152 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 153 | SkPath* outlinePath = reinterpret_cast<SkPath*>(outlinePathPtr); |
Chris Craik | 77b5cad | 2014-07-30 18:23:07 -0700 | [diff] [blame] | 154 | renderNode->mutateStagingProperties().mutableOutline().setConvexPath(outlinePath, alpha); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 155 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 156 | return true; |
Chris Craik | b49f446 | 2014-03-20 12:44:20 -0700 | [diff] [blame] | 157 | } |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 158 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 159 | static jboolean android_view_RenderNode_setOutlineEmpty(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 160 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 161 | renderNode->mutateStagingProperties().mutableOutline().setEmpty(); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 162 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 163 | return true; |
Chris Craik | a2fe7af | 2014-01-28 17:25:06 -0800 | [diff] [blame] | 164 | } |
| 165 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 166 | static jboolean android_view_RenderNode_setOutlineNone(jlong renderNodePtr) { |
Chris Craik | 0645128 | 2014-07-21 10:25:54 -0700 | [diff] [blame] | 167 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 168 | renderNode->mutateStagingProperties().mutableOutline().setNone(); |
| 169 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
| 170 | return true; |
| 171 | } |
| 172 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 173 | static jboolean android_view_RenderNode_hasShadow(jlong renderNodePtr) { |
Chris Craik | 5c75c52 | 2014-09-05 14:08:08 -0700 | [diff] [blame] | 174 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 175 | return renderNode->stagingProperties().hasShadow(); |
| 176 | } |
| 177 | |
John Reck | d8be4a0 | 2017-11-17 15:06:24 -0800 | [diff] [blame] | 178 | static jboolean android_view_RenderNode_setSpotShadowColor(jlong renderNodePtr, jint shadowColor) { |
| 179 | return SET_AND_DIRTY(setSpotShadowColor, |
| 180 | static_cast<SkColor>(shadowColor), RenderNode::GENERIC); |
| 181 | } |
| 182 | |
| 183 | static jint android_view_RenderNode_getSpotShadowColor(jlong renderNodePtr) { |
| 184 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 185 | return renderNode->stagingProperties().getSpotShadowColor(); |
| 186 | } |
| 187 | |
| 188 | static jboolean android_view_RenderNode_setAmbientShadowColor(jlong renderNodePtr, |
| 189 | jint shadowColor) { |
| 190 | return SET_AND_DIRTY(setAmbientShadowColor, |
| 191 | static_cast<SkColor>(shadowColor), RenderNode::GENERIC); |
| 192 | } |
| 193 | |
| 194 | static jint android_view_RenderNode_getAmbientShadowColor(jlong renderNodePtr) { |
| 195 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 196 | return renderNode->stagingProperties().getAmbientShadowColor(); |
John Reck | 3c0369b | 2017-11-13 16:47:35 -0800 | [diff] [blame] | 197 | } |
| 198 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 199 | static jboolean android_view_RenderNode_setClipToOutline(jlong renderNodePtr, |
| 200 | jboolean clipToOutline) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 201 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 202 | renderNode->mutateStagingProperties().mutableOutline().setShouldClip(clipToOutline); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 203 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 204 | return true; |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 207 | static jboolean android_view_RenderNode_setRevealClip(jlong renderNodePtr, jboolean shouldClip, |
Chris Craik | 8c271ca | 2014-03-25 10:33:01 -0700 | [diff] [blame] | 208 | jfloat x, jfloat y, jfloat radius) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 209 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 210 | renderNode->mutateStagingProperties().mutableRevealClip().set( |
Chris Craik | af4d04c | 2014-07-29 12:50:14 -0700 | [diff] [blame] | 211 | shouldClip, x, y, radius); |
John Reck | ff941dc | 2014-05-14 16:34:14 -0700 | [diff] [blame] | 212 | renderNode->setPropertyFieldsDirty(RenderNode::GENERIC); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 213 | return true; |
ztenghui | fad4593 | 2014-02-06 10:33:58 -0800 | [diff] [blame] | 214 | } |
| 215 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 216 | static jboolean android_view_RenderNode_setAlpha(jlong renderNodePtr, float alpha) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 217 | return SET_AND_DIRTY(setAlpha, alpha, RenderNode::ALPHA); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 218 | } |
| 219 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 220 | static jboolean android_view_RenderNode_setHasOverlappingRendering(jlong renderNodePtr, |
| 221 | bool hasOverlappingRendering) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 222 | return SET_AND_DIRTY(setHasOverlappingRendering, hasOverlappingRendering, |
| 223 | RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 224 | } |
| 225 | |
John Reck | 9ce2bf7 | 2018-07-02 18:33:32 -0700 | [diff] [blame] | 226 | static void android_view_RenderNode_setUsageHint(jlong renderNodePtr, jint usageHint) { |
| 227 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 228 | renderNode->setUsageHint(static_cast<UsageHint>(usageHint)); |
| 229 | } |
| 230 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 231 | static jboolean android_view_RenderNode_setElevation(jlong renderNodePtr, float elevation) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 232 | return SET_AND_DIRTY(setElevation, elevation, RenderNode::Z); |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 235 | static jboolean android_view_RenderNode_setTranslationX(jlong renderNodePtr, float tx) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 236 | return SET_AND_DIRTY(setTranslationX, tx, RenderNode::TRANSLATION_X | RenderNode::X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 237 | } |
| 238 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 239 | static jboolean android_view_RenderNode_setTranslationY(jlong renderNodePtr, float ty) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 240 | return SET_AND_DIRTY(setTranslationY, ty, RenderNode::TRANSLATION_Y | RenderNode::Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 241 | } |
| 242 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 243 | static jboolean android_view_RenderNode_setTranslationZ(jlong renderNodePtr, float tz) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 244 | return SET_AND_DIRTY(setTranslationZ, tz, RenderNode::TRANSLATION_Z | RenderNode::Z); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 245 | } |
| 246 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 247 | static jboolean android_view_RenderNode_setRotation(jlong renderNodePtr, float rotation) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 248 | return SET_AND_DIRTY(setRotation, rotation, RenderNode::ROTATION); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 249 | } |
| 250 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 251 | static jboolean android_view_RenderNode_setRotationX(jlong renderNodePtr, float rx) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 252 | return SET_AND_DIRTY(setRotationX, rx, RenderNode::ROTATION_X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 255 | static jboolean android_view_RenderNode_setRotationY(jlong renderNodePtr, float ry) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 256 | return SET_AND_DIRTY(setRotationY, ry, RenderNode::ROTATION_Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 257 | } |
| 258 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 259 | static jboolean android_view_RenderNode_setScaleX(jlong renderNodePtr, float sx) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 260 | return SET_AND_DIRTY(setScaleX, sx, RenderNode::SCALE_X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 261 | } |
| 262 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 263 | static jboolean android_view_RenderNode_setScaleY(jlong renderNodePtr, float sy) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 264 | return SET_AND_DIRTY(setScaleY, sy, RenderNode::SCALE_Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 265 | } |
| 266 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 267 | static jboolean android_view_RenderNode_setPivotX(jlong renderNodePtr, float px) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 268 | return SET_AND_DIRTY(setPivotX, px, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 269 | } |
| 270 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 271 | static jboolean android_view_RenderNode_setPivotY(jlong renderNodePtr, float py) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 272 | return SET_AND_DIRTY(setPivotY, py, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 273 | } |
| 274 | |
John Reck | 8686e1f | 2018-03-21 16:31:21 -0700 | [diff] [blame] | 275 | static jboolean android_view_RenderNode_resetPivot(jlong renderNodePtr) { |
| 276 | return SET_AND_DIRTY(resetPivot, /* void */, RenderNode::GENERIC); |
| 277 | } |
| 278 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 279 | static jboolean android_view_RenderNode_setCameraDistance(jlong renderNodePtr, float distance) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 280 | return SET_AND_DIRTY(setCameraDistance, distance, RenderNode::GENERIC); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 281 | } |
| 282 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 283 | static jboolean android_view_RenderNode_setLeft(jlong renderNodePtr, int left) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 284 | return SET_AND_DIRTY(setLeft, left, RenderNode::X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 285 | } |
| 286 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 287 | static jboolean android_view_RenderNode_setTop(jlong renderNodePtr, int top) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 288 | return SET_AND_DIRTY(setTop, top, RenderNode::Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 289 | } |
| 290 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 291 | static jboolean android_view_RenderNode_setRight(jlong renderNodePtr, int right) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 292 | return SET_AND_DIRTY(setRight, right, RenderNode::X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 293 | } |
| 294 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 295 | static jboolean android_view_RenderNode_setBottom(jlong renderNodePtr, int bottom) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 296 | return SET_AND_DIRTY(setBottom, bottom, RenderNode::Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 297 | } |
| 298 | |
John Reck | ddeaa48 | 2018-10-30 10:47:43 -0700 | [diff] [blame] | 299 | static jint android_view_RenderNode_getLeft(jlong renderNodePtr) { |
| 300 | return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getLeft(); |
| 301 | } |
| 302 | |
| 303 | static jint android_view_RenderNode_getTop(jlong renderNodePtr) { |
| 304 | return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getTop(); |
| 305 | } |
| 306 | |
| 307 | static jint android_view_RenderNode_getRight(jlong renderNodePtr) { |
| 308 | return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getRight(); |
| 309 | } |
| 310 | |
| 311 | static jint android_view_RenderNode_getBottom(jlong renderNodePtr) { |
| 312 | return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getBottom(); |
| 313 | } |
| 314 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 315 | static jboolean android_view_RenderNode_setLeftTopRightBottom(jlong renderNodePtr, |
| 316 | int left, int top, int right, int bottom) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 317 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 318 | if (renderNode->mutateStagingProperties().setLeftTopRightBottom(left, top, right, bottom)) { |
| 319 | renderNode->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y); |
| 320 | return true; |
| 321 | } |
| 322 | return false; |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 323 | } |
| 324 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 325 | static jboolean android_view_RenderNode_offsetLeftAndRight(jlong renderNodePtr, jint offset) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 326 | return SET_AND_DIRTY(offsetLeftRight, offset, RenderNode::X); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 327 | } |
| 328 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 329 | static jboolean android_view_RenderNode_offsetTopAndBottom(jlong renderNodePtr, jint offset) { |
John Reck | 79c7de7 | 2014-05-23 10:33:31 -0700 | [diff] [blame] | 330 | return SET_AND_DIRTY(offsetTopBottom, offset, RenderNode::Y); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 331 | } |
| 332 | |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 333 | // ---------------------------------------------------------------------------- |
| 334 | // RenderProperties - getters |
| 335 | // ---------------------------------------------------------------------------- |
| 336 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 337 | static jboolean android_view_RenderNode_hasOverlappingRendering(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 338 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 339 | return renderNode->stagingProperties().hasOverlappingRendering(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 340 | } |
| 341 | |
Andrey Kulikov | c15c9ca | 2019-03-12 14:53:06 +0000 | [diff] [blame] | 342 | static jboolean android_view_RenderNode_getAnimationMatrix(jlong renderNodePtr, jlong outMatrixPtr) { |
| 343 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 344 | SkMatrix* outMatrix = reinterpret_cast<SkMatrix*>(outMatrixPtr); |
| 345 | |
| 346 | const SkMatrix* animationMatrix = renderNode->stagingProperties().getAnimationMatrix(); |
| 347 | |
| 348 | if (animationMatrix) { |
| 349 | *outMatrix = *animationMatrix; |
| 350 | return JNI_TRUE; |
| 351 | } |
| 352 | return JNI_FALSE; |
| 353 | } |
| 354 | |
John Reck | 470a919 | 2018-12-17 10:55:54 -0800 | [diff] [blame] | 355 | static jboolean android_view_RenderNode_getClipToBounds(jlong renderNodePtr) { |
| 356 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 357 | return renderNode->stagingProperties().getClipToBounds(); |
| 358 | } |
| 359 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 360 | static jboolean android_view_RenderNode_getClipToOutline(jlong renderNodePtr) { |
Chris Craik | deeda3d | 2014-05-05 19:09:33 -0700 | [diff] [blame] | 361 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 362 | return renderNode->stagingProperties().getOutline().getShouldClip(); |
| 363 | } |
| 364 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 365 | static jfloat android_view_RenderNode_getAlpha(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 366 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 367 | return renderNode->stagingProperties().getAlpha(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 368 | } |
| 369 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 370 | static jfloat android_view_RenderNode_getCameraDistance(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 371 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 372 | return renderNode->stagingProperties().getCameraDistance(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 373 | } |
| 374 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 375 | static jfloat android_view_RenderNode_getScaleX(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 376 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 377 | return renderNode->stagingProperties().getScaleX(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 378 | } |
| 379 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 380 | static jfloat android_view_RenderNode_getScaleY(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 381 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 382 | return renderNode->stagingProperties().getScaleY(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 383 | } |
| 384 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 385 | static jfloat android_view_RenderNode_getElevation(jlong renderNodePtr) { |
Chris Craik | cc39e16 | 2014-04-25 18:34:11 -0700 | [diff] [blame] | 386 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 387 | return renderNode->stagingProperties().getElevation(); |
| 388 | } |
| 389 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 390 | static jfloat android_view_RenderNode_getTranslationX(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 391 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 392 | return renderNode->stagingProperties().getTranslationX(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 393 | } |
| 394 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 395 | static jfloat android_view_RenderNode_getTranslationY(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 396 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 397 | return renderNode->stagingProperties().getTranslationY(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 398 | } |
| 399 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 400 | static jfloat android_view_RenderNode_getTranslationZ(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 401 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 402 | return renderNode->stagingProperties().getTranslationZ(); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 403 | } |
| 404 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 405 | static jfloat android_view_RenderNode_getRotation(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 406 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 407 | return renderNode->stagingProperties().getRotation(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 408 | } |
| 409 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 410 | static jfloat android_view_RenderNode_getRotationX(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 411 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 412 | return renderNode->stagingProperties().getRotationX(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 413 | } |
| 414 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 415 | static jfloat android_view_RenderNode_getRotationY(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 416 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 417 | return renderNode->stagingProperties().getRotationY(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 418 | } |
| 419 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 420 | static jboolean android_view_RenderNode_isPivotExplicitlySet(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 421 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 422 | return renderNode->stagingProperties().isPivotExplicitlySet(); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 423 | } |
| 424 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 425 | static jboolean android_view_RenderNode_hasIdentityMatrix(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 426 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 427 | renderNode->mutateStagingProperties().updateMatrix(); |
| 428 | return !renderNode->stagingProperties().hasTransformMatrix(); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 429 | } |
| 430 | |
John Reck | 470a919 | 2018-12-17 10:55:54 -0800 | [diff] [blame] | 431 | static jint android_view_RenderNode_getLayerType(jlong renderNodePtr) { |
| 432 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 433 | return static_cast<int>(renderNode->stagingProperties().layerProperties().type()); |
| 434 | } |
| 435 | |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 436 | // ---------------------------------------------------------------------------- |
| 437 | // RenderProperties - computed getters |
| 438 | // ---------------------------------------------------------------------------- |
| 439 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 440 | static void android_view_RenderNode_getTransformMatrix(jlong renderNodePtr, jlong outMatrixPtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 441 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 442 | SkMatrix* outMatrix = reinterpret_cast<SkMatrix*>(outMatrixPtr); |
| 443 | |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 444 | renderNode->mutateStagingProperties().updateMatrix(); |
| 445 | const SkMatrix* transformMatrix = renderNode->stagingProperties().getTransformMatrix(); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 446 | |
John Reck | f7483e3 | 2014-04-11 08:54:47 -0700 | [diff] [blame] | 447 | if (transformMatrix) { |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 448 | *outMatrix = *transformMatrix; |
| 449 | } else { |
| 450 | outMatrix->setIdentity(); |
| 451 | } |
| 452 | } |
| 453 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 454 | static void android_view_RenderNode_getInverseTransformMatrix(jlong renderNodePtr, |
| 455 | jlong outMatrixPtr) { |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 456 | // load transform matrix |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 457 | android_view_RenderNode_getTransformMatrix(renderNodePtr, outMatrixPtr); |
Chris Craik | 49e6c73 | 2014-03-31 12:34:11 -0700 | [diff] [blame] | 458 | SkMatrix* outMatrix = reinterpret_cast<SkMatrix*>(outMatrixPtr); |
| 459 | |
| 460 | // return it inverted |
| 461 | if (!outMatrix->invert(outMatrix)) { |
| 462 | // failed to load inverse, pass back identity |
| 463 | outMatrix->setIdentity(); |
| 464 | } |
| 465 | } |
| 466 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 467 | static jfloat android_view_RenderNode_getPivotX(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 468 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 469 | renderNode->mutateStagingProperties().updateMatrix(); |
| 470 | return renderNode->stagingProperties().getPivotX(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 471 | } |
| 472 | |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 473 | static jfloat android_view_RenderNode_getPivotY(jlong renderNodePtr) { |
John Reck | 8de65a8 | 2014-04-09 15:23:38 -0700 | [diff] [blame] | 474 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 475 | renderNode->mutateStagingProperties().updateMatrix(); |
| 476 | return renderNode->stagingProperties().getPivotY(); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 477 | } |
| 478 | |
John Reck | 568b2a6 | 2018-06-04 17:02:02 -0700 | [diff] [blame] | 479 | static jint android_view_RenderNode_getWidth(jlong renderNodePtr) { |
| 480 | return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getWidth(); |
| 481 | } |
| 482 | |
| 483 | static jint android_view_RenderNode_getHeight(jlong renderNodePtr) { |
| 484 | return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getHeight(); |
| 485 | } |
| 486 | |
John Reck | 1423e13 | 2018-09-21 14:30:19 -0700 | [diff] [blame] | 487 | static jboolean android_view_RenderNode_setAllowForceDark(jlong renderNodePtr, jboolean allow) { |
| 488 | return SET_AND_DIRTY(setAllowForceDark, allow, RenderNode::GENERIC); |
| 489 | } |
| 490 | |
| 491 | static jboolean android_view_RenderNode_getAllowForceDark(jlong renderNodePtr) { |
| 492 | return reinterpret_cast<RenderNode*>(renderNodePtr)->stagingProperties().getAllowForceDark(); |
| 493 | } |
| 494 | |
John Reck | f96b284 | 2018-11-29 09:44:10 -0800 | [diff] [blame] | 495 | static jlong android_view_RenderNode_getUniqueId(jlong renderNodePtr) { |
| 496 | return reinterpret_cast<RenderNode*>(renderNodePtr)->uniqueId(); |
| 497 | } |
| 498 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 499 | // ---------------------------------------------------------------------------- |
| 500 | // RenderProperties - Animations |
| 501 | // ---------------------------------------------------------------------------- |
| 502 | |
Chris Craik | 26bced4 | 2016-12-15 16:33:47 -0800 | [diff] [blame] | 503 | static void android_view_RenderNode_addAnimator(JNIEnv* env, jobject clazz, jlong renderNodePtr, |
| 504 | jlong animatorPtr) { |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 505 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
| 506 | RenderPropertyAnimator* animator = reinterpret_cast<RenderPropertyAnimator*>(animatorPtr); |
| 507 | renderNode->addAnimator(animator); |
| 508 | } |
| 509 | |
Chris Craik | 26bced4 | 2016-12-15 16:33:47 -0800 | [diff] [blame] | 510 | static void android_view_RenderNode_endAllAnimators(JNIEnv* env, jobject clazz, |
| 511 | jlong renderNodePtr) { |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 512 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
John Reck | e2478d4 | 2014-09-03 16:46:05 -0700 | [diff] [blame] | 513 | renderNode->animators().endAllStagingAnimators(); |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 514 | } |
| 515 | |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 516 | // ---------------------------------------------------------------------------- |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 517 | // SurfaceView position callback |
| 518 | // ---------------------------------------------------------------------------- |
| 519 | |
John Reck | 6b16440 | 2018-09-24 15:25:42 -0700 | [diff] [blame] | 520 | jmethodID gPositionListener_PositionChangedMethod; |
| 521 | jmethodID gPositionListener_PositionLostMethod; |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 522 | |
| 523 | static void android_view_RenderNode_requestPositionUpdates(JNIEnv* env, jobject, |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 524 | jlong renderNodePtr, jobject listener) { |
| 525 | class PositionListenerTrampoline : public RenderNode::PositionListener { |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 526 | public: |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 527 | PositionListenerTrampoline(JNIEnv* env, jobject listener) { |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 528 | env->GetJavaVM(&mVm); |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 529 | mWeakRef = env->NewWeakGlobalRef(listener); |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 530 | } |
| 531 | |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 532 | virtual ~PositionListenerTrampoline() { |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 533 | jnienv()->DeleteWeakGlobalRef(mWeakRef); |
| 534 | mWeakRef = nullptr; |
| 535 | } |
| 536 | |
| 537 | virtual void onPositionUpdated(RenderNode& node, const TreeInfo& info) override { |
| 538 | if (CC_UNLIKELY(!mWeakRef || !info.updateWindowPositions)) return; |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 539 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 540 | Matrix4 transform; |
| 541 | info.damageAccumulator->computeCurrentTransform(&transform); |
| 542 | const RenderProperties& props = node.properties(); |
| 543 | uirenderer::Rect bounds(props.getWidth(), props.getHeight()); |
| 544 | transform.mapRect(bounds); |
John Reck | 38f6c03 | 2016-03-17 10:23:49 -0700 | [diff] [blame] | 545 | |
Chris Craik | 0e974e74 | 2016-04-22 15:44:14 -0700 | [diff] [blame] | 546 | if (CC_LIKELY(transform.isPureTranslate())) { |
| 547 | // snap/round the computed bounds, so they match the rounding behavior |
| 548 | // of the clear done in SurfaceView#draw(). |
Stan Iliev | 7baca0b | 2019-05-02 11:23:00 -0400 | [diff] [blame] | 549 | bounds.snapGeometryToPixelBoundaries(false); |
Chris Craik | 0e974e74 | 2016-04-22 15:44:14 -0700 | [diff] [blame] | 550 | } else { |
| 551 | // Conservatively round out so the punched hole (in the ZOrderOnTop = true case) |
| 552 | // doesn't extend beyond the other window |
| 553 | bounds.roundOut(); |
| 554 | } |
| 555 | |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 556 | if (mPreviousPosition == bounds) { |
| 557 | return; |
| 558 | } |
| 559 | mPreviousPosition = bounds; |
| 560 | |
John Reck | 7b570de | 2016-06-27 13:27:23 -0700 | [diff] [blame] | 561 | incStrong(0); |
John Reck | 38f6c03 | 2016-03-17 10:23:49 -0700 | [diff] [blame] | 562 | auto functor = std::bind( |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 563 | std::mem_fn(&PositionListenerTrampoline::doUpdatePositionAsync), this, |
John Reck | 28912a5 | 2016-04-18 14:34:18 -0700 | [diff] [blame] | 564 | (jlong) info.canvasContext.getFrameNumber(), |
| 565 | (jint) bounds.left, (jint) bounds.top, |
John Reck | 38f6c03 | 2016-03-17 10:23:49 -0700 | [diff] [blame] | 566 | (jint) bounds.right, (jint) bounds.bottom); |
| 567 | |
| 568 | info.canvasContext.enqueueFrameWork(std::move(functor)); |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 569 | } |
| 570 | |
John Reck | aa6e84f | 2016-06-16 15:36:13 -0700 | [diff] [blame] | 571 | virtual void onPositionLost(RenderNode& node, const TreeInfo* info) override { |
| 572 | if (CC_UNLIKELY(!mWeakRef || (info && !info->updateWindowPositions))) return; |
| 573 | |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 574 | if (mPreviousPosition.isEmpty()) { |
| 575 | return; |
| 576 | } |
| 577 | mPreviousPosition.setEmpty(); |
| 578 | |
John Reck | 7b570de | 2016-06-27 13:27:23 -0700 | [diff] [blame] | 579 | ATRACE_NAME("SurfaceView position lost"); |
| 580 | JNIEnv* env = jnienv(); |
| 581 | jobject localref = env->NewLocalRef(mWeakRef); |
| 582 | if (CC_UNLIKELY(!localref)) { |
| 583 | jnienv()->DeleteWeakGlobalRef(mWeakRef); |
| 584 | mWeakRef = nullptr; |
| 585 | return; |
John Reck | aa6e84f | 2016-06-16 15:36:13 -0700 | [diff] [blame] | 586 | } |
John Reck | 7b570de | 2016-06-27 13:27:23 -0700 | [diff] [blame] | 587 | |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 588 | // TODO: Remember why this is synchronous and then make a comment |
John Reck | 6b16440 | 2018-09-24 15:25:42 -0700 | [diff] [blame] | 589 | env->CallVoidMethod(localref, gPositionListener_PositionLostMethod, |
John Reck | 7b570de | 2016-06-27 13:27:23 -0700 | [diff] [blame] | 590 | info ? info->canvasContext.getFrameNumber() : 0); |
| 591 | env->DeleteLocalRef(localref); |
John Reck | aa6e84f | 2016-06-16 15:36:13 -0700 | [diff] [blame] | 592 | } |
| 593 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 594 | private: |
| 595 | JNIEnv* jnienv() { |
| 596 | JNIEnv* env; |
| 597 | if (mVm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { |
| 598 | LOG_ALWAYS_FATAL("Failed to get JNIEnv for JavaVM: %p", mVm); |
| 599 | } |
| 600 | return env; |
| 601 | } |
| 602 | |
John Reck | 7b570de | 2016-06-27 13:27:23 -0700 | [diff] [blame] | 603 | void doUpdatePositionAsync(jlong frameNumber, jint left, jint top, |
John Reck | 38f6c03 | 2016-03-17 10:23:49 -0700 | [diff] [blame] | 604 | jint right, jint bottom) { |
| 605 | ATRACE_NAME("Update SurfaceView position"); |
| 606 | |
| 607 | JNIEnv* env = jnienv(); |
| 608 | jobject localref = env->NewLocalRef(mWeakRef); |
| 609 | if (CC_UNLIKELY(!localref)) { |
John Reck | 7b570de | 2016-06-27 13:27:23 -0700 | [diff] [blame] | 610 | env->DeleteWeakGlobalRef(mWeakRef); |
John Reck | 38f6c03 | 2016-03-17 10:23:49 -0700 | [diff] [blame] | 611 | mWeakRef = nullptr; |
John Reck | 7b570de | 2016-06-27 13:27:23 -0700 | [diff] [blame] | 612 | } else { |
John Reck | 6b16440 | 2018-09-24 15:25:42 -0700 | [diff] [blame] | 613 | env->CallVoidMethod(localref, gPositionListener_PositionChangedMethod, |
John Reck | 7b570de | 2016-06-27 13:27:23 -0700 | [diff] [blame] | 614 | frameNumber, left, top, right, bottom); |
| 615 | env->DeleteLocalRef(localref); |
John Reck | 38f6c03 | 2016-03-17 10:23:49 -0700 | [diff] [blame] | 616 | } |
| 617 | |
John Reck | 7b570de | 2016-06-27 13:27:23 -0700 | [diff] [blame] | 618 | // We need to release ourselves here |
| 619 | decStrong(0); |
John Reck | aa6e84f | 2016-06-16 15:36:13 -0700 | [diff] [blame] | 620 | } |
| 621 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 622 | JavaVM* mVm; |
| 623 | jobject mWeakRef; |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 624 | uirenderer::Rect mPreviousPosition; |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 625 | }; |
| 626 | |
| 627 | RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); |
John Reck | 51aa189 | 2019-01-30 15:28:44 -0800 | [diff] [blame] | 628 | renderNode->setPositionListener(new PositionListenerTrampoline(env, listener)); |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | // ---------------------------------------------------------------------------- |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 632 | // JNI Glue |
| 633 | // ---------------------------------------------------------------------------- |
| 634 | |
John Reck | 32f140aa6 | 2018-10-04 15:08:24 -0700 | [diff] [blame] | 635 | const char* const kClassPathName = "android/graphics/RenderNode"; |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 636 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 637 | static const JNINativeMethod gMethods[] = { |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 638 | // ---------------------------------------------------------------------------- |
| 639 | // Regular JNI |
| 640 | // ---------------------------------------------------------------------------- |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 641 | { "nCreate", "(Ljava/lang/String;)J", (void*) android_view_RenderNode_create }, |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 642 | { "nGetNativeFinalizer", "()J", (void*) android_view_RenderNode_getNativeFinalizer }, |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 643 | { "nOutput", "(J)V", (void*) android_view_RenderNode_output }, |
| 644 | { "nGetDebugSize", "(J)I", (void*) android_view_RenderNode_getDebugSize }, |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 645 | { "nAddAnimator", "(JJ)V", (void*) android_view_RenderNode_addAnimator }, |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 646 | { "nEndAllAnimators", "(J)V", (void*) android_view_RenderNode_endAllAnimators }, |
John Reck | 32f140aa6 | 2018-10-04 15:08:24 -0700 | [diff] [blame] | 647 | { "nRequestPositionUpdates", "(JLandroid/graphics/RenderNode$PositionUpdateListener;)V", (void*) android_view_RenderNode_requestPositionUpdates }, |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 648 | { "nSetDisplayList", "(JJ)V", (void*) android_view_RenderNode_setDisplayList }, |
| 649 | |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 650 | |
| 651 | // ---------------------------------------------------------------------------- |
Chris Craik | fc29424 | 2016-12-13 18:10:46 -0800 | [diff] [blame] | 652 | // Fast JNI via @CriticalNative annotation in RenderNode.java |
| 653 | // ---------------------------------------------------------------------------- |
| 654 | { "nSetDisplayList", "(JJ)V", (void*) android_view_RenderNode_setDisplayList }, |
| 655 | |
| 656 | |
| 657 | // ---------------------------------------------------------------------------- |
| 658 | // Critical JNI via @CriticalNative annotation in RenderNode.java |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 659 | // ---------------------------------------------------------------------------- |
John Reck | 2de950d | 2017-01-25 10:58:30 -0800 | [diff] [blame] | 660 | { "nIsValid", "(J)Z", (void*) android_view_RenderNode_isValid }, |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 661 | { "nSetLayerType", "(JI)Z", (void*) android_view_RenderNode_setLayerType }, |
John Reck | 470a919 | 2018-12-17 10:55:54 -0800 | [diff] [blame] | 662 | { "nGetLayerType", "(J)I", (void*) android_view_RenderNode_getLayerType }, |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 663 | { "nSetLayerPaint", "(JJ)Z", (void*) android_view_RenderNode_setLayerPaint }, |
| 664 | { "nSetStaticMatrix", "(JJ)Z", (void*) android_view_RenderNode_setStaticMatrix }, |
| 665 | { "nSetAnimationMatrix", "(JJ)Z", (void*) android_view_RenderNode_setAnimationMatrix }, |
Andrey Kulikov | c15c9ca | 2019-03-12 14:53:06 +0000 | [diff] [blame] | 666 | { "nGetAnimationMatrix", "(JJ)Z", (void*) android_view_RenderNode_getAnimationMatrix }, |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 667 | { "nSetClipToBounds", "(JZ)Z", (void*) android_view_RenderNode_setClipToBounds }, |
John Reck | 470a919 | 2018-12-17 10:55:54 -0800 | [diff] [blame] | 668 | { "nGetClipToBounds", "(J)Z", (void*) android_view_RenderNode_getClipToBounds }, |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 669 | { "nSetClipBounds", "(JIIII)Z", (void*) android_view_RenderNode_setClipBounds }, |
| 670 | { "nSetClipBoundsEmpty", "(J)Z", (void*) android_view_RenderNode_setClipBoundsEmpty }, |
| 671 | { "nSetProjectBackwards", "(JZ)Z", (void*) android_view_RenderNode_setProjectBackwards }, |
| 672 | { "nSetProjectionReceiver","(JZ)Z", (void*) android_view_RenderNode_setProjectionReceiver }, |
| 673 | |
| 674 | { "nSetOutlineRoundRect", "(JIIIIFF)Z", (void*) android_view_RenderNode_setOutlineRoundRect }, |
| 675 | { "nSetOutlineConvexPath", "(JJF)Z", (void*) android_view_RenderNode_setOutlineConvexPath }, |
| 676 | { "nSetOutlineEmpty", "(J)Z", (void*) android_view_RenderNode_setOutlineEmpty }, |
| 677 | { "nSetOutlineNone", "(J)Z", (void*) android_view_RenderNode_setOutlineNone }, |
| 678 | { "nHasShadow", "(J)Z", (void*) android_view_RenderNode_hasShadow }, |
John Reck | d8be4a0 | 2017-11-17 15:06:24 -0800 | [diff] [blame] | 679 | { "nSetSpotShadowColor", "(JI)Z", (void*) android_view_RenderNode_setSpotShadowColor }, |
| 680 | { "nGetSpotShadowColor", "(J)I", (void*) android_view_RenderNode_getSpotShadowColor }, |
| 681 | { "nSetAmbientShadowColor","(JI)Z", (void*) android_view_RenderNode_setAmbientShadowColor }, |
| 682 | { "nGetAmbientShadowColor","(J)I", (void*) android_view_RenderNode_getAmbientShadowColor }, |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 683 | { "nSetClipToOutline", "(JZ)Z", (void*) android_view_RenderNode_setClipToOutline }, |
| 684 | { "nSetRevealClip", "(JZFFF)Z", (void*) android_view_RenderNode_setRevealClip }, |
| 685 | |
| 686 | { "nSetAlpha", "(JF)Z", (void*) android_view_RenderNode_setAlpha }, |
| 687 | { "nSetHasOverlappingRendering", "(JZ)Z", |
| 688 | (void*) android_view_RenderNode_setHasOverlappingRendering }, |
John Reck | 9ce2bf7 | 2018-07-02 18:33:32 -0700 | [diff] [blame] | 689 | { "nSetUsageHint", "(JI)V", (void*) android_view_RenderNode_setUsageHint }, |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 690 | { "nSetElevation", "(JF)Z", (void*) android_view_RenderNode_setElevation }, |
| 691 | { "nSetTranslationX", "(JF)Z", (void*) android_view_RenderNode_setTranslationX }, |
| 692 | { "nSetTranslationY", "(JF)Z", (void*) android_view_RenderNode_setTranslationY }, |
| 693 | { "nSetTranslationZ", "(JF)Z", (void*) android_view_RenderNode_setTranslationZ }, |
| 694 | { "nSetRotation", "(JF)Z", (void*) android_view_RenderNode_setRotation }, |
| 695 | { "nSetRotationX", "(JF)Z", (void*) android_view_RenderNode_setRotationX }, |
| 696 | { "nSetRotationY", "(JF)Z", (void*) android_view_RenderNode_setRotationY }, |
| 697 | { "nSetScaleX", "(JF)Z", (void*) android_view_RenderNode_setScaleX }, |
| 698 | { "nSetScaleY", "(JF)Z", (void*) android_view_RenderNode_setScaleY }, |
| 699 | { "nSetPivotX", "(JF)Z", (void*) android_view_RenderNode_setPivotX }, |
| 700 | { "nSetPivotY", "(JF)Z", (void*) android_view_RenderNode_setPivotY }, |
John Reck | 8686e1f | 2018-03-21 16:31:21 -0700 | [diff] [blame] | 701 | { "nResetPivot", "(J)Z", (void*) android_view_RenderNode_resetPivot }, |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 702 | { "nSetCameraDistance", "(JF)Z", (void*) android_view_RenderNode_setCameraDistance }, |
| 703 | { "nSetLeft", "(JI)Z", (void*) android_view_RenderNode_setLeft }, |
| 704 | { "nSetTop", "(JI)Z", (void*) android_view_RenderNode_setTop }, |
| 705 | { "nSetRight", "(JI)Z", (void*) android_view_RenderNode_setRight }, |
| 706 | { "nSetBottom", "(JI)Z", (void*) android_view_RenderNode_setBottom }, |
John Reck | ddeaa48 | 2018-10-30 10:47:43 -0700 | [diff] [blame] | 707 | { "nGetLeft", "(J)I", (void*) android_view_RenderNode_getLeft }, |
| 708 | { "nGetTop", "(J)I", (void*) android_view_RenderNode_getTop }, |
| 709 | { "nGetRight", "(J)I", (void*) android_view_RenderNode_getRight }, |
| 710 | { "nGetBottom", "(J)I", (void*) android_view_RenderNode_getBottom }, |
John Reck | 395e9b8 | 2016-08-24 13:22:37 -0700 | [diff] [blame] | 711 | { "nSetLeftTopRightBottom","(JIIII)Z", (void*) android_view_RenderNode_setLeftTopRightBottom }, |
| 712 | { "nOffsetLeftAndRight", "(JI)Z", (void*) android_view_RenderNode_offsetLeftAndRight }, |
| 713 | { "nOffsetTopAndBottom", "(JI)Z", (void*) android_view_RenderNode_offsetTopAndBottom }, |
| 714 | |
| 715 | { "nHasOverlappingRendering", "(J)Z", (void*) android_view_RenderNode_hasOverlappingRendering }, |
| 716 | { "nGetClipToOutline", "(J)Z", (void*) android_view_RenderNode_getClipToOutline }, |
| 717 | { "nGetAlpha", "(J)F", (void*) android_view_RenderNode_getAlpha }, |
| 718 | { "nGetCameraDistance", "(J)F", (void*) android_view_RenderNode_getCameraDistance }, |
| 719 | { "nGetScaleX", "(J)F", (void*) android_view_RenderNode_getScaleX }, |
| 720 | { "nGetScaleY", "(J)F", (void*) android_view_RenderNode_getScaleY }, |
| 721 | { "nGetElevation", "(J)F", (void*) android_view_RenderNode_getElevation }, |
| 722 | { "nGetTranslationX", "(J)F", (void*) android_view_RenderNode_getTranslationX }, |
| 723 | { "nGetTranslationY", "(J)F", (void*) android_view_RenderNode_getTranslationY }, |
| 724 | { "nGetTranslationZ", "(J)F", (void*) android_view_RenderNode_getTranslationZ }, |
| 725 | { "nGetRotation", "(J)F", (void*) android_view_RenderNode_getRotation }, |
| 726 | { "nGetRotationX", "(J)F", (void*) android_view_RenderNode_getRotationX }, |
| 727 | { "nGetRotationY", "(J)F", (void*) android_view_RenderNode_getRotationY }, |
| 728 | { "nIsPivotExplicitlySet", "(J)Z", (void*) android_view_RenderNode_isPivotExplicitlySet }, |
| 729 | { "nHasIdentityMatrix", "(J)Z", (void*) android_view_RenderNode_hasIdentityMatrix }, |
| 730 | |
| 731 | { "nGetTransformMatrix", "(JJ)V", (void*) android_view_RenderNode_getTransformMatrix }, |
| 732 | { "nGetInverseTransformMatrix","(JJ)V", (void*) android_view_RenderNode_getInverseTransformMatrix }, |
| 733 | |
| 734 | { "nGetPivotX", "(J)F", (void*) android_view_RenderNode_getPivotX }, |
| 735 | { "nGetPivotY", "(J)F", (void*) android_view_RenderNode_getPivotY }, |
John Reck | 568b2a6 | 2018-06-04 17:02:02 -0700 | [diff] [blame] | 736 | { "nGetWidth", "(J)I", (void*) android_view_RenderNode_getWidth }, |
| 737 | { "nGetHeight", "(J)I", (void*) android_view_RenderNode_getHeight }, |
John Reck | 1423e13 | 2018-09-21 14:30:19 -0700 | [diff] [blame] | 738 | { "nSetAllowForceDark", "(JZ)Z", (void*) android_view_RenderNode_setAllowForceDark }, |
| 739 | { "nGetAllowForceDark", "(J)Z", (void*) android_view_RenderNode_getAllowForceDark }, |
John Reck | f96b284 | 2018-11-29 09:44:10 -0800 | [diff] [blame] | 740 | { "nGetUniqueId", "(J)J", (void*) android_view_RenderNode_getUniqueId }, |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 741 | }; |
| 742 | |
John Reck | f666ad7 | 2014-03-14 16:24:57 -0700 | [diff] [blame] | 743 | int register_android_view_RenderNode(JNIEnv* env) { |
John Reck | 32f140aa6 | 2018-10-04 15:08:24 -0700 | [diff] [blame] | 744 | jclass clazz = FindClassOrDie(env, "android/graphics/RenderNode$PositionUpdateListener"); |
John Reck | 6b16440 | 2018-09-24 15:25:42 -0700 | [diff] [blame] | 745 | gPositionListener_PositionChangedMethod = GetMethodIDOrDie(env, clazz, |
| 746 | "positionChanged", "(JIIII)V"); |
| 747 | gPositionListener_PositionLostMethod = GetMethodIDOrDie(env, clazz, |
| 748 | "positionLost", "(J)V"); |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 749 | return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods)); |
Chris Craik | 5438979 | 2013-12-20 13:28:11 -0800 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | }; |
| 753 | |