1 /* 2 * Copyright (C) 2022 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 package org.robolectric.nativeruntime; 18 19 import android.graphics.RenderNode.PositionUpdateListener; 20 21 /** 22 * Native methods for RenderNode JNI registration. 23 * 24 * <p>Native method signatures are derived from 25 * https://cs.android.com/android/platform/superproject/+/android-12.0.0_r1:frameworks/base/graphics/java/android/graphics/RenderNode.java 26 */ 27 public final class RenderNodeNatives { 28 nCreate(String name)29 public static native long nCreate(String name); 30 nGetNativeFinalizer()31 public static native long nGetNativeFinalizer(); 32 nOutput(long renderNode)33 public static native void nOutput(long renderNode); 34 nGetUsageSize(long renderNode)35 public static native int nGetUsageSize(long renderNode); 36 nGetAllocatedSize(long renderNode)37 public static native int nGetAllocatedSize(long renderNode); 38 nRequestPositionUpdates( long renderNode, PositionUpdateListener callback)39 public static native void nRequestPositionUpdates( 40 long renderNode, PositionUpdateListener callback); 41 nAddAnimator(long renderNode, long animatorPtr)42 public static native void nAddAnimator(long renderNode, long animatorPtr); 43 nEndAllAnimators(long renderNode)44 public static native void nEndAllAnimators(long renderNode); 45 nDiscardDisplayList(long renderNode)46 public static native void nDiscardDisplayList(long renderNode); 47 nIsValid(long renderNode)48 public static native boolean nIsValid(long renderNode); 49 nGetTransformMatrix(long renderNode, long nativeMatrix)50 public static native void nGetTransformMatrix(long renderNode, long nativeMatrix); 51 nGetInverseTransformMatrix(long renderNode, long nativeMatrix)52 public static native void nGetInverseTransformMatrix(long renderNode, long nativeMatrix); 53 nHasIdentityMatrix(long renderNode)54 public static native boolean nHasIdentityMatrix(long renderNode); 55 nOffsetTopAndBottom(long renderNode, int offset)56 public static native boolean nOffsetTopAndBottom(long renderNode, int offset); 57 nOffsetLeftAndRight(long renderNode, int offset)58 public static native boolean nOffsetLeftAndRight(long renderNode, int offset); 59 nSetLeftTopRightBottom( long renderNode, int left, int top, int right, int bottom)60 public static native boolean nSetLeftTopRightBottom( 61 long renderNode, int left, int top, int right, int bottom); 62 nSetLeft(long renderNode, int left)63 public static native boolean nSetLeft(long renderNode, int left); 64 nSetTop(long renderNode, int top)65 public static native boolean nSetTop(long renderNode, int top); 66 nSetRight(long renderNode, int right)67 public static native boolean nSetRight(long renderNode, int right); 68 nSetBottom(long renderNode, int bottom)69 public static native boolean nSetBottom(long renderNode, int bottom); 70 nGetLeft(long renderNode)71 public static native int nGetLeft(long renderNode); 72 nGetTop(long renderNode)73 public static native int nGetTop(long renderNode); 74 nGetRight(long renderNode)75 public static native int nGetRight(long renderNode); 76 nGetBottom(long renderNode)77 public static native int nGetBottom(long renderNode); 78 nSetCameraDistance(long renderNode, float distance)79 public static native boolean nSetCameraDistance(long renderNode, float distance); 80 nSetPivotY(long renderNode, float pivotY)81 public static native boolean nSetPivotY(long renderNode, float pivotY); 82 nSetPivotX(long renderNode, float pivotX)83 public static native boolean nSetPivotX(long renderNode, float pivotX); 84 nResetPivot(long renderNode)85 public static native boolean nResetPivot(long renderNode); 86 nSetLayerType(long renderNode, int layerType)87 public static native boolean nSetLayerType(long renderNode, int layerType); 88 nGetLayerType(long renderNode)89 public static native int nGetLayerType(long renderNode); 90 nSetLayerPaint(long renderNode, long paint)91 public static native boolean nSetLayerPaint(long renderNode, long paint); 92 nSetClipToBounds(long renderNode, boolean clipToBounds)93 public static native boolean nSetClipToBounds(long renderNode, boolean clipToBounds); 94 nGetClipToBounds(long renderNode)95 public static native boolean nGetClipToBounds(long renderNode); 96 nSetClipBounds( long renderNode, int left, int top, int right, int bottom)97 public static native boolean nSetClipBounds( 98 long renderNode, int left, int top, int right, int bottom); 99 nSetClipBoundsEmpty(long renderNode)100 public static native boolean nSetClipBoundsEmpty(long renderNode); 101 nSetProjectBackwards(long renderNode, boolean shouldProject)102 public static native boolean nSetProjectBackwards(long renderNode, boolean shouldProject); 103 nSetProjectionReceiver(long renderNode, boolean shouldReceive)104 public static native boolean nSetProjectionReceiver(long renderNode, boolean shouldReceive); 105 nSetOutlineRoundRect( long renderNode, int left, int top, int right, int bottom, float radius, float alpha)106 public static native boolean nSetOutlineRoundRect( 107 long renderNode, int left, int top, int right, int bottom, float radius, float alpha); 108 nSetOutlinePath(long renderNode, long nativePath, float alpha)109 public static native boolean nSetOutlinePath(long renderNode, long nativePath, float alpha); 110 nSetOutlineEmpty(long renderNode)111 public static native boolean nSetOutlineEmpty(long renderNode); 112 nSetOutlineNone(long renderNode)113 public static native boolean nSetOutlineNone(long renderNode); 114 nClearStretch(long renderNode)115 public static native boolean nClearStretch(long renderNode); 116 nStretch( long renderNode, float vecX, float vecY, float maxStretchX, float maxStretchY)117 public static native boolean nStretch( 118 long renderNode, float vecX, float vecY, float maxStretchX, float maxStretchY); 119 nHasShadow(long renderNode)120 public static native boolean nHasShadow(long renderNode); 121 nSetSpotShadowColor(long renderNode, int color)122 public static native boolean nSetSpotShadowColor(long renderNode, int color); 123 nSetAmbientShadowColor(long renderNode, int color)124 public static native boolean nSetAmbientShadowColor(long renderNode, int color); 125 nGetSpotShadowColor(long renderNode)126 public static native int nGetSpotShadowColor(long renderNode); 127 nGetAmbientShadowColor(long renderNode)128 public static native int nGetAmbientShadowColor(long renderNode); 129 nSetClipToOutline(long renderNode, boolean clipToOutline)130 public static native boolean nSetClipToOutline(long renderNode, boolean clipToOutline); 131 nSetRevealClip( long renderNode, boolean shouldClip, float x, float y, float radius)132 public static native boolean nSetRevealClip( 133 long renderNode, boolean shouldClip, float x, float y, float radius); 134 nSetAlpha(long renderNode, float alpha)135 public static native boolean nSetAlpha(long renderNode, float alpha); 136 nSetRenderEffect(long renderNode, long renderEffect)137 public static native boolean nSetRenderEffect(long renderNode, long renderEffect); 138 nSetHasOverlappingRendering( long renderNode, boolean hasOverlappingRendering)139 public static native boolean nSetHasOverlappingRendering( 140 long renderNode, boolean hasOverlappingRendering); 141 nSetUsageHint(long renderNode, int usageHint)142 public static native void nSetUsageHint(long renderNode, int usageHint); 143 nSetElevation(long renderNode, float lift)144 public static native boolean nSetElevation(long renderNode, float lift); 145 nSetTranslationX(long renderNode, float translationX)146 public static native boolean nSetTranslationX(long renderNode, float translationX); 147 nSetTranslationY(long renderNode, float translationY)148 public static native boolean nSetTranslationY(long renderNode, float translationY); 149 nSetTranslationZ(long renderNode, float translationZ)150 public static native boolean nSetTranslationZ(long renderNode, float translationZ); 151 nSetRotation(long renderNode, float rotation)152 public static native boolean nSetRotation(long renderNode, float rotation); 153 nSetRotationX(long renderNode, float rotationX)154 public static native boolean nSetRotationX(long renderNode, float rotationX); 155 nSetRotationY(long renderNode, float rotationY)156 public static native boolean nSetRotationY(long renderNode, float rotationY); 157 nSetScaleX(long renderNode, float scaleX)158 public static native boolean nSetScaleX(long renderNode, float scaleX); 159 nSetScaleY(long renderNode, float scaleY)160 public static native boolean nSetScaleY(long renderNode, float scaleY); 161 nSetStaticMatrix(long renderNode, long nativeMatrix)162 public static native boolean nSetStaticMatrix(long renderNode, long nativeMatrix); 163 nSetAnimationMatrix(long renderNode, long animationMatrix)164 public static native boolean nSetAnimationMatrix(long renderNode, long animationMatrix); 165 nHasOverlappingRendering(long renderNode)166 public static native boolean nHasOverlappingRendering(long renderNode); 167 nGetAnimationMatrix(long renderNode, long animationMatrix)168 public static native boolean nGetAnimationMatrix(long renderNode, long animationMatrix); 169 nGetClipToOutline(long renderNode)170 public static native boolean nGetClipToOutline(long renderNode); 171 nGetAlpha(long renderNode)172 public static native float nGetAlpha(long renderNode); 173 nGetCameraDistance(long renderNode)174 public static native float nGetCameraDistance(long renderNode); 175 nGetScaleX(long renderNode)176 public static native float nGetScaleX(long renderNode); 177 nGetScaleY(long renderNode)178 public static native float nGetScaleY(long renderNode); 179 nGetElevation(long renderNode)180 public static native float nGetElevation(long renderNode); 181 nGetTranslationX(long renderNode)182 public static native float nGetTranslationX(long renderNode); 183 nGetTranslationY(long renderNode)184 public static native float nGetTranslationY(long renderNode); 185 nGetTranslationZ(long renderNode)186 public static native float nGetTranslationZ(long renderNode); 187 nGetRotation(long renderNode)188 public static native float nGetRotation(long renderNode); 189 nGetRotationX(long renderNode)190 public static native float nGetRotationX(long renderNode); 191 nGetRotationY(long renderNode)192 public static native float nGetRotationY(long renderNode); 193 nIsPivotExplicitlySet(long renderNode)194 public static native boolean nIsPivotExplicitlySet(long renderNode); 195 nGetPivotX(long renderNode)196 public static native float nGetPivotX(long renderNode); 197 nGetPivotY(long renderNode)198 public static native float nGetPivotY(long renderNode); 199 nGetWidth(long renderNode)200 public static native int nGetWidth(long renderNode); 201 nGetHeight(long renderNode)202 public static native int nGetHeight(long renderNode); 203 nSetAllowForceDark(long renderNode, boolean allowForceDark)204 public static native boolean nSetAllowForceDark(long renderNode, boolean allowForceDark); 205 nGetAllowForceDark(long renderNode)206 public static native boolean nGetAllowForceDark(long renderNode); 207 nGetUniqueId(long renderNode)208 public static native long nGetUniqueId(long renderNode); 209 RenderNodeNatives()210 private RenderNodeNatives() {} 211 } 212