Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 "GraphicBuffer" |
| 18 | |
| 19 | #include "jni.h" |
| 20 | #include "JNIHelp.h" |
| 21 | |
| 22 | #include "android_os_Parcel.h" |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 23 | #include "GraphicBuffer.h" |
| 24 | #include "GraphicsJNI.h" |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 25 | |
| 26 | #include <android_runtime/AndroidRuntime.h> |
| 27 | |
| 28 | #include <binder/Parcel.h> |
| 29 | |
| 30 | #include <ui/GraphicBuffer.h> |
| 31 | #include <ui/PixelFormat.h> |
| 32 | |
| 33 | #include <gui/IGraphicBufferAlloc.h> |
| 34 | #include <gui/ISurfaceComposer.h> |
sergeyv | 9a02987 | 2016-11-29 10:13:28 -0800 | [diff] [blame] | 35 | #include <hwui/Bitmap.h> |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 36 | |
| 37 | #include <SkCanvas.h> |
| 38 | #include <SkBitmap.h> |
| 39 | |
| 40 | #include <private/gui/ComposerService.h> |
| 41 | |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 42 | #include "core_jni_helpers.h" |
| 43 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 44 | namespace android { |
| 45 | |
| 46 | // ---------------------------------------------------------------------------- |
| 47 | // Defines |
| 48 | // ---------------------------------------------------------------------------- |
| 49 | |
| 50 | // Debug |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 51 | static const bool kDebugGraphicBuffer = false; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 52 | |
Chih-Hung Hsieh | cef190d | 2016-05-19 15:25:50 -0700 | [diff] [blame] | 53 | #define LOCK_CANVAS_USAGE (GraphicBuffer::USAGE_SW_READ_OFTEN | GraphicBuffer::USAGE_SW_WRITE_OFTEN) |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 54 | |
| 55 | // ---------------------------------------------------------------------------- |
| 56 | // JNI Helpers |
| 57 | // ---------------------------------------------------------------------------- |
| 58 | |
| 59 | static struct { |
| 60 | jfieldID mNativeObject; |
| 61 | } gGraphicBufferClassInfo; |
| 62 | |
| 63 | static struct { |
| 64 | jmethodID set; |
| 65 | jfieldID left; |
| 66 | jfieldID top; |
| 67 | jfieldID right; |
| 68 | jfieldID bottom; |
| 69 | } gRectClassInfo; |
| 70 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 71 | #define GET_INT(object, field) \ |
| 72 | env->GetIntField(object, field) |
| 73 | |
| 74 | #define SET_INT(object, field, value) \ |
| 75 | env->SetIntField(object, field, value) |
| 76 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 77 | #define GET_LONG(object, field) \ |
| 78 | env->GetLongField(object, field) |
| 79 | |
| 80 | #define SET_LONG(object, field, value) \ |
| 81 | env->SetLongField(object, field, value) |
| 82 | |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 83 | #define INVOKEV(object, method, ...) \ |
| 84 | env->CallVoidMethod(object, method, __VA_ARGS__) |
| 85 | |
| 86 | // ---------------------------------------------------------------------------- |
| 87 | // Types |
| 88 | // ---------------------------------------------------------------------------- |
| 89 | |
| 90 | class GraphicBufferWrapper { |
| 91 | public: |
Chih-Hung Hsieh | c6baf56 | 2016-04-27 11:29:23 -0700 | [diff] [blame] | 92 | explicit GraphicBufferWrapper(const sp<GraphicBuffer>& buffer): buffer(buffer) { |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | sp<GraphicBuffer> buffer; |
| 96 | }; |
| 97 | |
| 98 | // ---------------------------------------------------------------------------- |
| 99 | // GraphicBuffer lifecycle |
| 100 | // ---------------------------------------------------------------------------- |
| 101 | |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 102 | static jlong android_graphics_GraphicBuffer_create(JNIEnv* env, jobject clazz, |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 103 | jint width, jint height, jint format, jint usage) { |
| 104 | |
| 105 | sp<ISurfaceComposer> composer(ComposerService::getComposerService()); |
| 106 | sp<IGraphicBufferAlloc> alloc(composer->createGraphicBufferAlloc()); |
| 107 | if (alloc == NULL) { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 108 | if (kDebugGraphicBuffer) { |
| 109 | ALOGW("createGraphicBufferAlloc() failed in GraphicBuffer.create()"); |
| 110 | } |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 111 | return NULL; |
| 112 | } |
| 113 | |
| 114 | status_t error; |
Craig Donner | 850054c | 2016-10-26 11:47:23 -0700 | [diff] [blame] | 115 | sp<GraphicBuffer> buffer(alloc->createGraphicBuffer(width, height, format, 1, usage, &error)); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 116 | if (buffer == NULL) { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 117 | if (kDebugGraphicBuffer) { |
| 118 | ALOGW("createGraphicBuffer() failed in GraphicBuffer.create()"); |
| 119 | } |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 120 | return NULL; |
| 121 | } |
| 122 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 123 | GraphicBufferWrapper* wrapper = new GraphicBufferWrapper(buffer); |
| 124 | return reinterpret_cast<jlong>(wrapper); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 125 | } |
| 126 | |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 127 | static void android_graphics_GraphicBuffer_destroy(JNIEnv* env, jobject clazz, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 128 | jlong wrapperHandle) { |
| 129 | GraphicBufferWrapper* wrapper = |
| 130 | reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 131 | delete wrapper; |
| 132 | } |
| 133 | |
| 134 | // ---------------------------------------------------------------------------- |
| 135 | // Canvas management |
| 136 | // ---------------------------------------------------------------------------- |
| 137 | |
Mike Reed | b933055 | 2014-06-16 17:31:48 -0400 | [diff] [blame] | 138 | static inline SkColorType convertPixelFormat(int32_t format) { |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 139 | switch (format) { |
| 140 | case PIXEL_FORMAT_RGBA_8888: |
Mike Reed | b933055 | 2014-06-16 17:31:48 -0400 | [diff] [blame] | 141 | return kN32_SkColorType; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 142 | case PIXEL_FORMAT_RGBX_8888: |
Mike Reed | b933055 | 2014-06-16 17:31:48 -0400 | [diff] [blame] | 143 | return kN32_SkColorType; |
Romain Guy | 9505a65 | 2016-12-14 09:43:50 -0800 | [diff] [blame] | 144 | case PIXEL_FORMAT_RGBA_FP16: |
| 145 | return kRGBA_F16_SkColorType; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 146 | case PIXEL_FORMAT_RGB_565: |
Mike Reed | b933055 | 2014-06-16 17:31:48 -0400 | [diff] [blame] | 147 | return kRGB_565_SkColorType; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 148 | default: |
Mike Reed | b933055 | 2014-06-16 17:31:48 -0400 | [diff] [blame] | 149 | return kUnknown_SkColorType; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 153 | static jboolean android_graphics_GraphicBuffer_lockCanvas(JNIEnv* env, jobject, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 154 | jlong wrapperHandle, jobject canvas, jobject dirtyRect) { |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 155 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 156 | GraphicBufferWrapper* wrapper = |
| 157 | reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 158 | if (!wrapper) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 159 | return JNI_FALSE; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | sp<GraphicBuffer> buffer(wrapper->buffer); |
| 163 | |
Pablo Ceballos | 8270292 | 2015-08-07 17:28:03 -0700 | [diff] [blame] | 164 | Rect rect(Rect::EMPTY_RECT); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 165 | if (dirtyRect) { |
| 166 | rect.left = GET_INT(dirtyRect, gRectClassInfo.left); |
| 167 | rect.top = GET_INT(dirtyRect, gRectClassInfo.top); |
| 168 | rect.right = GET_INT(dirtyRect, gRectClassInfo.right); |
| 169 | rect.bottom = GET_INT(dirtyRect, gRectClassInfo.bottom); |
| 170 | } else { |
| 171 | rect.set(Rect(buffer->getWidth(), buffer->getHeight())); |
| 172 | } |
| 173 | |
| 174 | void* bits = NULL; |
| 175 | status_t status = buffer->lock(LOCK_CANVAS_USAGE, rect, &bits); |
| 176 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 177 | if (status) return JNI_FALSE; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 178 | if (!bits) { |
| 179 | buffer->unlock(); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 180 | return JNI_FALSE; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | ssize_t bytesCount = buffer->getStride() * bytesPerPixel(buffer->getPixelFormat()); |
| 184 | |
| 185 | SkBitmap bitmap; |
Mike Reed | b933055 | 2014-06-16 17:31:48 -0400 | [diff] [blame] | 186 | bitmap.setInfo(SkImageInfo::Make(buffer->getWidth(), buffer->getHeight(), |
| 187 | convertPixelFormat(buffer->getPixelFormat()), |
Romain Guy | 253f2c2 | 2016-09-28 17:34:42 -0700 | [diff] [blame] | 188 | kPremul_SkAlphaType, |
| 189 | GraphicsJNI::defaultColorSpace()), |
Mike Reed | b933055 | 2014-06-16 17:31:48 -0400 | [diff] [blame] | 190 | bytesCount); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 191 | |
| 192 | if (buffer->getWidth() > 0 && buffer->getHeight() > 0) { |
| 193 | bitmap.setPixels(bits); |
| 194 | } else { |
| 195 | bitmap.setPixels(NULL); |
| 196 | } |
| 197 | |
John Reck | c1b33d6 | 2015-04-22 09:04:45 -0700 | [diff] [blame] | 198 | Canvas* nativeCanvas = GraphicsJNI::getNativeCanvas(env, canvas); |
| 199 | nativeCanvas->setBitmap(bitmap); |
Mike Reed | 6e49c9f | 2016-12-02 15:36:59 -0500 | [diff] [blame] | 200 | nativeCanvas->clipRect(rect.left, rect.top, rect.right, rect.bottom, |
Mike Reed | 6c67f1d | 2016-12-14 10:29:54 -0500 | [diff] [blame] | 201 | SkClipOp::kIntersect); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 202 | |
| 203 | if (dirtyRect) { |
| 204 | INVOKEV(dirtyRect, gRectClassInfo.set, |
| 205 | int(rect.left), int(rect.top), int(rect.right), int(rect.bottom)); |
| 206 | } |
| 207 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 208 | return JNI_TRUE; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 209 | } |
| 210 | |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 211 | static jboolean android_graphics_GraphicBuffer_unlockCanvasAndPost(JNIEnv* env, jobject, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 212 | jlong wrapperHandle, jobject canvas) { |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 213 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 214 | GraphicBufferWrapper* wrapper = |
| 215 | reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle); |
John Reck | c1b33d6 | 2015-04-22 09:04:45 -0700 | [diff] [blame] | 216 | Canvas* nativeCanvas = GraphicsJNI::getNativeCanvas(env, canvas); |
| 217 | nativeCanvas->setBitmap(SkBitmap()); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 218 | |
| 219 | if (wrapper) { |
| 220 | status_t status = wrapper->buffer->unlock(); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 221 | return status == 0 ? JNI_TRUE : JNI_FALSE; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 222 | } |
| 223 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 224 | return JNI_FALSE; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | // ---------------------------------------------------------------------------- |
| 228 | // Serialization |
| 229 | // ---------------------------------------------------------------------------- |
| 230 | |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 231 | static void android_graphics_GraphicBuffer_write(JNIEnv* env, jobject clazz, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 232 | jlong wrapperHandle, jobject dest) { |
| 233 | GraphicBufferWrapper* wrapper = |
| 234 | reinterpret_cast<GraphicBufferWrapper*>(wrapperHandle); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 235 | Parcel* parcel = parcelForJavaObject(env, dest); |
| 236 | if (parcel) { |
| 237 | parcel->write(*wrapper->buffer); |
| 238 | } |
| 239 | } |
| 240 | |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 241 | static jlong android_graphics_GraphicBuffer_read(JNIEnv* env, jobject clazz, |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 242 | jobject in) { |
| 243 | |
| 244 | Parcel* parcel = parcelForJavaObject(env, in); |
| 245 | if (parcel) { |
| 246 | sp<GraphicBuffer> buffer = new GraphicBuffer(); |
| 247 | parcel->read(*buffer); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 248 | return reinterpret_cast<jlong>(new GraphicBufferWrapper(buffer)); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | return NULL; |
| 252 | } |
| 253 | |
| 254 | // ---------------------------------------------------------------------------- |
| 255 | // External helpers |
| 256 | // ---------------------------------------------------------------------------- |
| 257 | |
| 258 | sp<GraphicBuffer> graphicBufferForJavaObject(JNIEnv* env, jobject obj) { |
| 259 | if (obj) { |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 260 | jlong nativeObject = env->GetLongField(obj, gGraphicBufferClassInfo.mNativeObject); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 261 | GraphicBufferWrapper* wrapper = (GraphicBufferWrapper*) nativeObject; |
| 262 | if (wrapper != NULL) { |
| 263 | sp<GraphicBuffer> buffer(wrapper->buffer); |
| 264 | return buffer; |
| 265 | } |
| 266 | } |
| 267 | return NULL; |
| 268 | } |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 269 | }; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 270 | |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 271 | using namespace android; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 272 | // ---------------------------------------------------------------------------- |
| 273 | // JNI Glue |
| 274 | // ---------------------------------------------------------------------------- |
| 275 | |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 276 | const char* const kClassPathName = "android/graphics/GraphicBuffer"; |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 277 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 278 | static const JNINativeMethod gMethods[] = { |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 279 | { "nCreateGraphicBuffer", "(IIII)J", (void*) android_graphics_GraphicBuffer_create }, |
| 280 | { "nDestroyGraphicBuffer", "(J)V", (void*) android_graphics_GraphicBuffer_destroy }, |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 281 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 282 | { "nWriteGraphicBufferToParcel", "(JLandroid/os/Parcel;)V", |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 283 | (void*) android_graphics_GraphicBuffer_write }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 284 | { "nReadGraphicBufferFromParcel", "(Landroid/os/Parcel;)J", |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 285 | (void*) android_graphics_GraphicBuffer_read }, |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 286 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 287 | { "nLockCanvas", "(JLandroid/graphics/Canvas;Landroid/graphics/Rect;)Z", |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 288 | (void*) android_graphics_GraphicBuffer_lockCanvas }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 289 | { "nUnlockCanvasAndPost", "(JLandroid/graphics/Canvas;)Z", |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 290 | (void*) android_graphics_GraphicBuffer_unlockCanvasAndPost } |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 291 | }; |
| 292 | |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 293 | int register_android_graphics_GraphicBuffer(JNIEnv* env) { |
| 294 | jclass clazz = FindClassOrDie(env, "android/graphics/GraphicBuffer"); |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 295 | gGraphicBufferClassInfo.mNativeObject = GetFieldIDOrDie(env, clazz, "mNativeObject", "J"); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 296 | |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 297 | clazz = FindClassOrDie(env, "android/graphics/Rect"); |
| 298 | gRectClassInfo.set = GetMethodIDOrDie(env, clazz, "set", "(IIII)V"); |
| 299 | gRectClassInfo.left = GetFieldIDOrDie(env, clazz, "left", "I"); |
| 300 | gRectClassInfo.top = GetFieldIDOrDie(env, clazz, "top", "I"); |
| 301 | gRectClassInfo.right = GetFieldIDOrDie(env, clazz, "right", "I"); |
| 302 | gRectClassInfo.bottom = GetFieldIDOrDie(env, clazz, "bottom", "I"); |
Romain Guy | 3b748a4 | 2013-04-17 18:54:38 -0700 | [diff] [blame] | 303 | |
Andreas Gampe | 987f79f | 2014-11-18 17:29:46 -0800 | [diff] [blame] | 304 | return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods)); |
sergeyv | 0a0f231 | 2017-01-04 13:58:52 -0800 | [diff] [blame^] | 305 | } |