Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [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 "SurfaceControl" |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 18 | #define LOG_NDEBUG 0 |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 19 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 20 | #include "android_os_Parcel.h" |
| 21 | #include "android_util_Binder.h" |
Robert Carr | 788f574 | 2018-07-30 17:46:45 -0700 | [diff] [blame] | 22 | #include "android_hardware_input_InputWindowHandle.h" |
John Reck | f29ed28 | 2015-04-07 07:32:03 -0700 | [diff] [blame] | 23 | #include "android/graphics/Bitmap.h" |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 24 | #include "android/graphics/GraphicsJNI.h" |
| 25 | #include "android/graphics/Region.h" |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 26 | #include "core_jni_helpers.h" |
Ben Wagner | 60126ef | 2015-08-07 12:13:48 -0400 | [diff] [blame] | 27 | |
Tom Cherry | 8ed74bb | 2017-07-10 14:31:18 -0700 | [diff] [blame] | 28 | #include <android-base/chrono_utils.h> |
Steven Moreland | 2279b25 | 2017-07-19 09:50:45 -0700 | [diff] [blame] | 29 | #include <nativehelper/JNIHelp.h> |
| 30 | #include <nativehelper/ScopedUtfChars.h> |
Mathias Agopian | 0449a40 | 2013-03-01 23:01:51 -0800 | [diff] [blame] | 31 | #include <android_runtime/android_view_Surface.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 32 | #include <android_runtime/android_view_SurfaceSession.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 33 | #include <gui/Surface.h> |
| 34 | #include <gui/SurfaceComposerClient.h> |
Ben Wagner | 60126ef | 2015-08-07 12:13:48 -0400 | [diff] [blame] | 35 | #include <jni.h> |
| 36 | #include <memory> |
| 37 | #include <stdio.h> |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 38 | #include <system/graphics.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 39 | #include <ui/DisplayInfo.h> |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 40 | #include <ui/DisplayedFrameStats.h> |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 41 | #include <ui/FrameStats.h> |
Peiyong Lin | b88549e | 2018-03-28 12:03:45 -0700 | [diff] [blame] | 42 | #include <ui/GraphicTypes.h> |
Peiyong Lin | 371b98f | 2018-03-14 17:29:10 -0700 | [diff] [blame] | 43 | #include <ui/HdrCapabilities.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 44 | #include <ui/Rect.h> |
| 45 | #include <ui/Region.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 46 | #include <utils/Log.h> |
| 47 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 48 | // ---------------------------------------------------------------------------- |
| 49 | |
| 50 | namespace android { |
| 51 | |
| 52 | static const char* const OutOfResourcesException = |
| 53 | "android/view/Surface$OutOfResourcesException"; |
| 54 | |
| 55 | static struct { |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 56 | jclass clazz; |
| 57 | jmethodID ctor; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 58 | jfieldID width; |
| 59 | jfieldID height; |
| 60 | jfieldID refreshRate; |
| 61 | jfieldID density; |
| 62 | jfieldID xDpi; |
| 63 | jfieldID yDpi; |
| 64 | jfieldID secure; |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 65 | jfieldID appVsyncOffsetNanos; |
| 66 | jfieldID presentationDeadlineNanos; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 67 | } gPhysicalDisplayInfoClassInfo; |
| 68 | |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 69 | static struct { |
| 70 | jfieldID bottom; |
| 71 | jfieldID left; |
| 72 | jfieldID right; |
| 73 | jfieldID top; |
| 74 | } gRectClassInfo; |
| 75 | |
Leon Scroggins | 46cb9bd | 2014-03-06 15:36:39 -0500 | [diff] [blame] | 76 | // Implements SkMallocPixelRef::ReleaseProc, to delete the screenshot on unref. |
| 77 | void DeleteScreenshot(void* addr, void* context) { |
Leon Scroggins | 46cb9bd | 2014-03-06 15:36:39 -0500 | [diff] [blame] | 78 | delete ((ScreenshotClient*) context); |
| 79 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 80 | |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 81 | static struct { |
| 82 | nsecs_t UNDEFINED_TIME_NANO; |
| 83 | jmethodID init; |
| 84 | } gWindowContentFrameStatsClassInfo; |
| 85 | |
| 86 | static struct { |
| 87 | nsecs_t UNDEFINED_TIME_NANO; |
| 88 | jmethodID init; |
| 89 | } gWindowAnimationFrameStatsClassInfo; |
| 90 | |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 91 | static struct { |
| 92 | jclass clazz; |
| 93 | jmethodID ctor; |
| 94 | } gHdrCapabilitiesClassInfo; |
| 95 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 96 | static struct { |
| 97 | jclass clazz; |
| 98 | jmethodID builder; |
| 99 | } gGraphicBufferClassInfo; |
| 100 | |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 101 | static struct { |
| 102 | jclass clazz; |
| 103 | jmethodID ctor; |
| 104 | } gDisplayedContentSampleClassInfo; |
| 105 | |
| 106 | static struct { |
| 107 | jclass clazz; |
| 108 | jmethodID ctor; |
| 109 | } gDisplayedContentSamplingAttributesClassInfo; |
| 110 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 111 | // ---------------------------------------------------------------------------- |
| 112 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 113 | static jlong nativeCreateTransaction(JNIEnv* env, jclass clazz) { |
| 114 | return reinterpret_cast<jlong>(new SurfaceComposerClient::Transaction); |
| 115 | } |
| 116 | |
| 117 | static void releaseTransaction(SurfaceComposerClient::Transaction* t) { |
| 118 | delete t; |
| 119 | } |
| 120 | |
| 121 | static jlong nativeGetNativeTransactionFinalizer(JNIEnv* env, jclass clazz) { |
| 122 | return static_cast<jlong>(reinterpret_cast<uintptr_t>(&releaseTransaction)); |
| 123 | } |
| 124 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 125 | static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj, |
Albert Chaulk | 3bf2e57 | 2016-11-22 13:59:19 -0500 | [diff] [blame] | 126 | jstring nameStr, jint w, jint h, jint format, jint flags, jlong parentObject, |
| 127 | jint windowType, jint ownerUid) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 128 | ScopedUtfChars name(env, nameStr); |
| 129 | sp<SurfaceComposerClient> client(android_view_SurfaceSession_getClient(env, sessionObj)); |
Robert Carr | 838120c | 2016-11-01 18:31:12 -0700 | [diff] [blame] | 130 | SurfaceControl *parent = reinterpret_cast<SurfaceControl*>(parentObject); |
Robert Carr | b0f3936 | 2018-03-14 13:52:25 -0700 | [diff] [blame] | 131 | sp<SurfaceControl> surface; |
| 132 | status_t err = client->createSurfaceChecked( |
| 133 | String8(name.c_str()), w, h, format, &surface, flags, parent, windowType, ownerUid); |
| 134 | if (err == NAME_NOT_FOUND) { |
| 135 | jniThrowException(env, "java/lang/IllegalArgumentException", NULL); |
| 136 | return 0; |
| 137 | } else if (err != NO_ERROR) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 138 | jniThrowException(env, OutOfResourcesException, NULL); |
| 139 | return 0; |
| 140 | } |
Albert Chaulk | 3bf2e57 | 2016-11-22 13:59:19 -0500 | [diff] [blame] | 141 | |
Mathias Agopian | b1d90c8 | 2013-03-06 17:45:42 -0800 | [diff] [blame] | 142 | surface->incStrong((void *)nativeCreate); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 143 | return reinterpret_cast<jlong>(surface.get()); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 144 | } |
| 145 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 146 | static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 147 | sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); |
Mathias Agopian | b1d90c8 | 2013-03-06 17:45:42 -0800 | [diff] [blame] | 148 | ctrl->decStrong((void *)nativeCreate); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 149 | } |
| 150 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 151 | static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 152 | sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); |
| 153 | ctrl->clear(); |
Mathias Agopian | b1d90c8 | 2013-03-06 17:45:42 -0800 | [diff] [blame] | 154 | ctrl->decStrong((void *)nativeCreate); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 155 | } |
| 156 | |
Chong Zhang | 47e36a3 | 2016-02-29 16:44:33 -0800 | [diff] [blame] | 157 | static void nativeDisconnect(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 158 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 159 | if (ctrl != NULL) { |
| 160 | ctrl->disconnect(); |
| 161 | } |
| 162 | } |
| 163 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 164 | static Rect rectFromObj(JNIEnv* env, jobject rectObj) { |
| 165 | int left = env->GetIntField(rectObj, gRectClassInfo.left); |
| 166 | int top = env->GetIntField(rectObj, gRectClassInfo.top); |
| 167 | int right = env->GetIntField(rectObj, gRectClassInfo.right); |
| 168 | int bottom = env->GetIntField(rectObj, gRectClassInfo.bottom); |
| 169 | return Rect(left, top, right, bottom); |
| 170 | } |
| 171 | |
chaviw | 08520a0 | 2018-09-10 16:44:56 -0700 | [diff] [blame] | 172 | static jobject nativeScreenshot(JNIEnv* env, jclass clazz, |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 173 | jobject displayTokenObj, jobject sourceCropObj, jint width, jint height, |
chaviw | 08520a0 | 2018-09-10 16:44:56 -0700 | [diff] [blame] | 174 | bool useIdentityTransform, int rotation) { |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 175 | sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj); |
| 176 | if (displayToken == NULL) { |
| 177 | return NULL; |
| 178 | } |
| 179 | Rect sourceCrop = rectFromObj(env, sourceCropObj); |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 180 | sp<GraphicBuffer> buffer; |
Peiyong Lin | 10a34d1 | 2018-09-19 13:56:12 -0700 | [diff] [blame] | 181 | status_t res = ScreenshotClient::capture(displayToken, ui::Dataspace::V0_SRGB, |
| 182 | ui::PixelFormat::RGBA_8888, |
| 183 | sourceCrop, width, height, |
| 184 | useIdentityTransform, rotation, &buffer); |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 185 | if (res != NO_ERROR) { |
| 186 | return NULL; |
| 187 | } |
| 188 | |
| 189 | return env->CallStaticObjectMethod(gGraphicBufferClassInfo.clazz, |
| 190 | gGraphicBufferClassInfo.builder, |
| 191 | buffer->getWidth(), |
| 192 | buffer->getHeight(), |
| 193 | buffer->getPixelFormat(), |
Mathias Agopian | 113fd30 | 2017-05-25 18:31:04 -0700 | [diff] [blame] | 194 | (jint)buffer->getUsage(), |
Patrik Torstensson | 511a808 | 2017-03-27 15:04:11 +0100 | [diff] [blame] | 195 | (jlong)buffer.get()); |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 196 | } |
| 197 | |
Chavi Weingarten | d7ec64c | 2017-11-30 01:52:01 +0000 | [diff] [blame] | 198 | static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken, |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 199 | jobject sourceCropObj, jfloat frameScale) { |
| 200 | |
| 201 | sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken); |
| 202 | if (layerHandle == NULL) { |
| 203 | return NULL; |
| 204 | } |
| 205 | |
| 206 | Rect sourceCrop; |
| 207 | if (sourceCropObj != NULL) { |
| 208 | sourceCrop = rectFromObj(env, sourceCropObj); |
| 209 | } |
| 210 | |
| 211 | sp<GraphicBuffer> buffer; |
Peiyong Lin | 10a34d1 | 2018-09-19 13:56:12 -0700 | [diff] [blame] | 212 | status_t res = ScreenshotClient::captureChildLayers(layerHandle, ui::Dataspace::V0_SRGB, |
| 213 | ui::PixelFormat::RGBA_8888, sourceCrop, |
| 214 | frameScale, &buffer); |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 215 | if (res != NO_ERROR) { |
| 216 | return NULL; |
| 217 | } |
| 218 | |
| 219 | return env->CallStaticObjectMethod(gGraphicBufferClassInfo.clazz, |
| 220 | gGraphicBufferClassInfo.builder, |
| 221 | buffer->getWidth(), |
| 222 | buffer->getHeight(), |
| 223 | buffer->getPixelFormat(), |
| 224 | (jint)buffer->getUsage(), |
| 225 | (jlong)buffer.get()); |
chaviw | 1cda84c | 2017-10-23 16:47:10 -0700 | [diff] [blame] | 226 | } |
| 227 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 228 | static void nativeApplyTransaction(JNIEnv* env, jclass clazz, jlong transactionObj, jboolean sync) { |
| 229 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 230 | transaction->apply(sync); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 231 | } |
| 232 | |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 233 | static void nativeMergeTransaction(JNIEnv* env, jclass clazz, |
| 234 | jlong transactionObj, jlong otherTransactionObj) { |
| 235 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 236 | auto otherTransaction = reinterpret_cast<SurfaceComposerClient::Transaction*>( |
| 237 | otherTransactionObj); |
| 238 | transaction->merge(std::move(*otherTransaction)); |
| 239 | } |
| 240 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 241 | static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz, jlong transactionObj) { |
| 242 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 243 | transaction->setAnimationTransaction(); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 244 | } |
| 245 | |
Jorim Jaggi | aa763cd | 2018-03-22 23:20:36 +0100 | [diff] [blame] | 246 | static void nativeSetEarlyWakeup(JNIEnv* env, jclass clazz, jlong transactionObj) { |
| 247 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 248 | transaction->setEarlyWakeup(); |
| 249 | } |
| 250 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 251 | static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 252 | jlong nativeObject, jint zorder) { |
| 253 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 254 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 255 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 256 | transaction->setLayer(ctrl, zorder); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 257 | } |
| 258 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 259 | static void nativeSetRelativeLayer(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 260 | jlong nativeObject, |
Robert Carr | af422a8 | 2017-04-10 18:34:33 -0700 | [diff] [blame] | 261 | jobject relativeTo, jint zorder) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 262 | |
Robert Carr | af422a8 | 2017-04-10 18:34:33 -0700 | [diff] [blame] | 263 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 264 | sp<IBinder> handle = ibinderForJavaObject(env, relativeTo); |
| 265 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 266 | { |
| 267 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 268 | transaction->setRelativeLayer(ctrl, handle, zorder); |
| 269 | } |
Robert Carr | af422a8 | 2017-04-10 18:34:33 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 272 | static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 273 | jlong nativeObject, jfloat x, jfloat y) { |
| 274 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 275 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 276 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 277 | transaction->setPosition(ctrl, x, y); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 278 | } |
| 279 | |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 280 | static void nativeSetGeometryAppliesWithResize(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 281 | jlong transactionObj, |
Robert Carr | a9408d4 | 2016-06-03 13:28:48 -0700 | [diff] [blame] | 282 | jlong nativeObject) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 283 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 284 | |
Robert Carr | a9408d4 | 2016-06-03 13:28:48 -0700 | [diff] [blame] | 285 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 286 | transaction->setGeometryAppliesWithResize(ctrl); |
Robert Carr | a9408d4 | 2016-06-03 13:28:48 -0700 | [diff] [blame] | 287 | } |
| 288 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 289 | static void nativeSetSize(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 290 | jlong nativeObject, jint w, jint h) { |
| 291 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 292 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 293 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 294 | transaction->setSize(ctrl, w, h); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 295 | } |
| 296 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 297 | static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 298 | jlong nativeObject, jint flags, jint mask) { |
| 299 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 300 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 301 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 302 | transaction->setFlags(ctrl, flags, mask); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 303 | } |
| 304 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 305 | static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 306 | jlong nativeObject, jobject regionObj) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 307 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 308 | SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj); |
| 309 | if (!region) { |
| 310 | doThrowIAE(env); |
| 311 | return; |
| 312 | } |
| 313 | |
| 314 | const SkIRect& b(region->getBounds()); |
| 315 | Region reg(Rect(b.fLeft, b.fTop, b.fRight, b.fBottom)); |
| 316 | if (region->isComplex()) { |
| 317 | SkRegion::Iterator it(*region); |
| 318 | while (!it.done()) { |
| 319 | const SkIRect& r(it.rect()); |
| 320 | reg.addRectUnchecked(r.fLeft, r.fTop, r.fRight, r.fBottom); |
| 321 | it.next(); |
| 322 | } |
| 323 | } |
| 324 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 325 | { |
| 326 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 327 | transaction->setTransparentRegionHint(ctrl, reg); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 328 | } |
| 329 | } |
| 330 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 331 | static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 332 | jlong nativeObject, jfloat alpha) { |
| 333 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 334 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 335 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 336 | transaction->setAlpha(ctrl, alpha); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 337 | } |
| 338 | |
Robert Carr | 788f574 | 2018-07-30 17:46:45 -0700 | [diff] [blame] | 339 | static void nativeSetInputWindowInfo(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 340 | jlong nativeObject, jobject inputWindow) { |
| 341 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 342 | |
| 343 | sp<NativeInputWindowHandle> handle = android_server_InputWindowHandle_getHandle( |
| 344 | env, inputWindow); |
| 345 | handle->updateInfo(); |
| 346 | |
| 347 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 348 | transaction->setInputWindowInfo(ctrl, *handle->getInfo()); |
| 349 | } |
| 350 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 351 | static void nativeSetColor(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 352 | jlong nativeObject, jfloatArray fColor) { |
| 353 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
chaviw | 0dd03f5 | 2017-08-25 12:15:26 -0700 | [diff] [blame] | 354 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 355 | |
chaviw | 0dd03f5 | 2017-08-25 12:15:26 -0700 | [diff] [blame] | 356 | float* floatColors = env->GetFloatArrayElements(fColor, 0); |
| 357 | half3 color(floatColors[0], floatColors[1], floatColors[2]); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 358 | transaction->setColor(ctrl, color); |
chaviw | 0dd03f5 | 2017-08-25 12:15:26 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 361 | static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 362 | jlong nativeObject, |
Robert Carr | 0edf18f | 2017-02-21 20:01:47 -0800 | [diff] [blame] | 363 | jfloat dsdx, jfloat dtdx, jfloat dtdy, jfloat dsdy) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 364 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 365 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 366 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 367 | transaction->setMatrix(ctrl, dsdx, dtdx, dtdy, dsdy); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 368 | } |
| 369 | |
Peiyong Lin | 52bb6b4 | 2018-10-01 11:40:50 -0700 | [diff] [blame] | 370 | static void nativeSetColorTransform(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 371 | jlong nativeObject, jfloatArray fMatrix, jfloatArray fTranslation) { |
| 372 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 373 | SurfaceControl* const surfaceControl = reinterpret_cast<SurfaceControl*>(nativeObject); |
| 374 | float* floatMatrix = env->GetFloatArrayElements(fMatrix, 0); |
| 375 | mat3 matrix(static_cast<float const*>(floatMatrix)); |
| 376 | float* floatTranslation = env->GetFloatArrayElements(fTranslation, 0); |
| 377 | vec3 translation(floatTranslation[0], floatTranslation[1], floatTranslation[2]); |
| 378 | transaction->setColorTransform(surfaceControl, matrix, translation); |
| 379 | } |
| 380 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 381 | static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 382 | jlong nativeObject, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 383 | jint l, jint t, jint r, jint b) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 384 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 385 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 386 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 387 | Rect crop(l, t, r, b); |
Marissa Wall | cb32fdd | 2018-07-24 09:53:30 -0700 | [diff] [blame] | 388 | transaction->setCrop_legacy(ctrl, crop); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 389 | } |
| 390 | |
Lucas Dupin | ff9d6ab | 2018-10-16 18:05:50 -0700 | [diff] [blame] | 391 | static void nativeSetCornerRadius(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 392 | jlong nativeObject, jfloat cornerRadius) { |
| 393 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 394 | |
| 395 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 396 | transaction->setCornerRadius(ctrl, cornerRadius); |
| 397 | } |
| 398 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 399 | static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 400 | jlong nativeObject, jint layerStack) { |
| 401 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 402 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 403 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 404 | transaction->setLayerStack(ctrl, layerStack); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | static jobject nativeGetBuiltInDisplay(JNIEnv* env, jclass clazz, jint id) { |
| 408 | sp<IBinder> token(SurfaceComposerClient::getBuiltInDisplay(id)); |
| 409 | return javaObjectForIBinder(env, token); |
| 410 | } |
| 411 | |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 412 | static jobject nativeGetDisplayedContentSamplingAttributes(JNIEnv* env, jclass clazz, |
| 413 | jobject tokenObj) { |
| 414 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 415 | |
| 416 | ui::PixelFormat format; |
| 417 | ui::Dataspace dataspace; |
| 418 | uint8_t componentMask; |
| 419 | status_t err = SurfaceComposerClient::getDisplayedContentSamplingAttributes( |
| 420 | token, &format, &dataspace, &componentMask); |
| 421 | if (err != OK) { |
| 422 | return nullptr; |
| 423 | } |
| 424 | return env->NewObject(gDisplayedContentSamplingAttributesClassInfo.clazz, |
| 425 | gDisplayedContentSamplingAttributesClassInfo.ctor, |
| 426 | format, dataspace, componentMask); |
| 427 | } |
| 428 | |
| 429 | static jboolean nativeSetDisplayedContentSamplingEnabled(JNIEnv* env, jclass clazz, |
| 430 | jobject tokenObj, jboolean enable, jint componentMask, jint maxFrames) { |
| 431 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 432 | return SurfaceComposerClient::setDisplayContentSamplingEnabled( |
| 433 | token, enable, componentMask, maxFrames); |
| 434 | } |
| 435 | |
| 436 | static jobject nativeGetDisplayedContentSample(JNIEnv* env, jclass clazz, jobject tokenObj, |
| 437 | jlong maxFrames, jlong timestamp) { |
| 438 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 439 | |
| 440 | DisplayedFrameStats stats; |
| 441 | status_t err = SurfaceComposerClient::getDisplayedContentSample( |
| 442 | token, maxFrames, timestamp, &stats); |
| 443 | if (err != OK) { |
| 444 | return nullptr; |
| 445 | } |
| 446 | |
| 447 | jlongArray histogramComponent0 = env->NewLongArray(stats.component_0_sample.size()); |
| 448 | jlongArray histogramComponent1 = env->NewLongArray(stats.component_1_sample.size()); |
| 449 | jlongArray histogramComponent2 = env->NewLongArray(stats.component_2_sample.size()); |
| 450 | jlongArray histogramComponent3 = env->NewLongArray(stats.component_3_sample.size()); |
| 451 | if ((histogramComponent0 == nullptr) || |
| 452 | (histogramComponent1 == nullptr) || |
| 453 | (histogramComponent2 == nullptr) || |
| 454 | (histogramComponent3 == nullptr)) { |
| 455 | return JNI_FALSE; |
| 456 | } |
| 457 | |
| 458 | env->SetLongArrayRegion(histogramComponent0, 0, |
| 459 | stats.component_0_sample.size(), |
| 460 | reinterpret_cast<jlong*>(stats.component_0_sample.data())); |
| 461 | env->SetLongArrayRegion(histogramComponent1, 0, |
| 462 | stats.component_1_sample.size(), |
| 463 | reinterpret_cast<jlong*>(stats.component_1_sample.data())); |
| 464 | env->SetLongArrayRegion(histogramComponent2, 0, |
| 465 | stats.component_2_sample.size(), |
| 466 | reinterpret_cast<jlong*>(stats.component_2_sample.data())); |
| 467 | env->SetLongArrayRegion(histogramComponent3, 0, |
| 468 | stats.component_3_sample.size(), |
| 469 | reinterpret_cast<jlong*>(stats.component_3_sample.data())); |
| 470 | return env->NewObject(gDisplayedContentSampleClassInfo.clazz, |
| 471 | gDisplayedContentSampleClassInfo.ctor, |
| 472 | stats.numFrames, |
| 473 | histogramComponent0, |
| 474 | histogramComponent1, |
| 475 | histogramComponent2, |
| 476 | histogramComponent3); |
| 477 | } |
| 478 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 479 | static jobject nativeCreateDisplay(JNIEnv* env, jclass clazz, jstring nameObj, |
| 480 | jboolean secure) { |
| 481 | ScopedUtfChars name(env, nameObj); |
| 482 | sp<IBinder> token(SurfaceComposerClient::createDisplay( |
| 483 | String8(name.c_str()), bool(secure))); |
| 484 | return javaObjectForIBinder(env, token); |
| 485 | } |
| 486 | |
Jesse Hall | 6a6bc21 | 2013-08-08 12:15:03 -0700 | [diff] [blame] | 487 | static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) { |
| 488 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 489 | if (token == NULL) return; |
| 490 | SurfaceComposerClient::destroyDisplay(token); |
| 491 | } |
| 492 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 493 | static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 494 | jlong transactionObj, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 495 | jobject tokenObj, jlong nativeSurfaceObject) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 496 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 497 | if (token == NULL) return; |
Mathias Agopian | ffddc9b | 2013-02-25 15:56:31 -0800 | [diff] [blame] | 498 | sp<IGraphicBufferProducer> bufferProducer; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 499 | sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject)); |
Mathias Agopian | ffddc9b | 2013-02-25 15:56:31 -0800 | [diff] [blame] | 500 | if (sur != NULL) { |
| 501 | bufferProducer = sur->getIGraphicBufferProducer(); |
| 502 | } |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 503 | |
| 504 | |
| 505 | status_t err = NO_ERROR; |
| 506 | { |
| 507 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 508 | err = transaction->setDisplaySurface(token, |
| 509 | bufferProducer); |
| 510 | } |
Pablo Ceballos | aff2f94 | 2016-07-29 14:49:55 -0700 | [diff] [blame] | 511 | if (err != NO_ERROR) { |
| 512 | doThrowIAE(env, "Illegal Surface, could not enable async mode. Was this" |
| 513 | " Surface created with singleBufferMode?"); |
| 514 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 518 | jlong transactionObj, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 519 | jobject tokenObj, jint layerStack) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 520 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 521 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 522 | if (token == NULL) return; |
| 523 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 524 | { |
| 525 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 526 | transaction->setDisplayLayerStack(token, layerStack); |
| 527 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 531 | jlong transactionObj, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 532 | jobject tokenObj, jint orientation, |
| 533 | jint layerStackRect_left, jint layerStackRect_top, jint layerStackRect_right, jint layerStackRect_bottom, |
| 534 | jint displayRect_left, jint displayRect_top, jint displayRect_right, jint displayRect_bottom) { |
| 535 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 536 | if (token == NULL) return; |
| 537 | Rect layerStackRect(layerStackRect_left, layerStackRect_top, layerStackRect_right, layerStackRect_bottom); |
| 538 | Rect displayRect(displayRect_left, displayRect_top, displayRect_right, displayRect_bottom); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 539 | |
| 540 | { |
| 541 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 542 | transaction->setDisplayProjection(token, orientation, layerStackRect, displayRect); |
| 543 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 544 | } |
| 545 | |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 546 | static void nativeSetDisplaySize(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 547 | jlong transactionObj, |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 548 | jobject tokenObj, jint width, jint height) { |
| 549 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 550 | if (token == NULL) return; |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 551 | |
| 552 | { |
| 553 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 554 | transaction->setDisplaySize(token, width, height); |
| 555 | } |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 556 | } |
| 557 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 558 | static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, |
| 559 | jobject tokenObj) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 560 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 561 | if (token == NULL) return NULL; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 562 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 563 | Vector<DisplayInfo> configs; |
| 564 | if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR || |
| 565 | configs.size() == 0) { |
| 566 | return NULL; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 567 | } |
| 568 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 569 | jobjectArray configArray = env->NewObjectArray(configs.size(), |
| 570 | gPhysicalDisplayInfoClassInfo.clazz, NULL); |
| 571 | |
| 572 | for (size_t c = 0; c < configs.size(); ++c) { |
| 573 | const DisplayInfo& info = configs[c]; |
| 574 | jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz, |
| 575 | gPhysicalDisplayInfoClassInfo.ctor); |
| 576 | env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w); |
| 577 | env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h); |
| 578 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps); |
| 579 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.density, info.density); |
| 580 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi); |
| 581 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi); |
| 582 | env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure); |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 583 | env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos, |
| 584 | info.appVsyncOffset); |
| 585 | env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos, |
| 586 | info.presentationDeadline); |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 587 | env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj); |
| 588 | env->DeleteLocalRef(infoObj); |
| 589 | } |
| 590 | |
| 591 | return configArray; |
| 592 | } |
| 593 | |
| 594 | static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { |
| 595 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 596 | if (token == NULL) return -1; |
| 597 | return static_cast<jint>(SurfaceComposerClient::getActiveConfig(token)); |
| 598 | } |
| 599 | |
| 600 | static jboolean nativeSetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj, jint id) { |
| 601 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 602 | if (token == NULL) return JNI_FALSE; |
| 603 | status_t err = SurfaceComposerClient::setActiveConfig(token, static_cast<int>(id)); |
| 604 | return err == NO_ERROR ? JNI_TRUE : JNI_FALSE; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 605 | } |
| 606 | |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 607 | static jintArray nativeGetDisplayColorModes(JNIEnv* env, jclass, jobject tokenObj) { |
| 608 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 609 | if (token == NULL) return NULL; |
Peiyong Lin | b88549e | 2018-03-28 12:03:45 -0700 | [diff] [blame] | 610 | Vector<ui::ColorMode> colorModes; |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 611 | if (SurfaceComposerClient::getDisplayColorModes(token, &colorModes) != NO_ERROR || |
| 612 | colorModes.isEmpty()) { |
| 613 | return NULL; |
| 614 | } |
| 615 | |
| 616 | jintArray colorModesArray = env->NewIntArray(colorModes.size()); |
| 617 | if (colorModesArray == NULL) { |
| 618 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 619 | return NULL; |
| 620 | } |
| 621 | jint* colorModesArrayValues = env->GetIntArrayElements(colorModesArray, 0); |
| 622 | for (size_t i = 0; i < colorModes.size(); i++) { |
| 623 | colorModesArrayValues[i] = static_cast<jint>(colorModes[i]); |
| 624 | } |
| 625 | env->ReleaseIntArrayElements(colorModesArray, colorModesArrayValues, 0); |
| 626 | return colorModesArray; |
| 627 | } |
| 628 | |
| 629 | static jint nativeGetActiveColorMode(JNIEnv* env, jclass, jobject tokenObj) { |
| 630 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 631 | if (token == NULL) return -1; |
| 632 | return static_cast<jint>(SurfaceComposerClient::getActiveColorMode(token)); |
| 633 | } |
| 634 | |
| 635 | static jboolean nativeSetActiveColorMode(JNIEnv* env, jclass, |
| 636 | jobject tokenObj, jint colorMode) { |
| 637 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 638 | if (token == NULL) return JNI_FALSE; |
| 639 | status_t err = SurfaceComposerClient::setActiveColorMode(token, |
Peiyong Lin | b88549e | 2018-03-28 12:03:45 -0700 | [diff] [blame] | 640 | static_cast<ui::ColorMode>(colorMode)); |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 641 | return err == NO_ERROR ? JNI_TRUE : JNI_FALSE; |
| 642 | } |
| 643 | |
Prashant Malani | c55929a | 2014-05-25 01:59:21 -0700 | [diff] [blame] | 644 | static void nativeSetDisplayPowerMode(JNIEnv* env, jclass clazz, jobject tokenObj, jint mode) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 645 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 646 | if (token == NULL) return; |
| 647 | |
Tom Cherry | 8ed74bb | 2017-07-10 14:31:18 -0700 | [diff] [blame] | 648 | android::base::Timer t; |
Prashant Malani | c55929a | 2014-05-25 01:59:21 -0700 | [diff] [blame] | 649 | SurfaceComposerClient::setDisplayPowerMode(token, mode); |
Tom Cherry | 8ed74bb | 2017-07-10 14:31:18 -0700 | [diff] [blame] | 650 | if (t.duration() > 100ms) ALOGD("Excessive delay in setPowerMode()"); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 651 | } |
| 652 | |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 653 | static jboolean nativeClearContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 654 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 655 | status_t err = ctrl->clearLayerFrameStats(); |
| 656 | |
| 657 | if (err < 0 && err != NO_INIT) { |
| 658 | doThrowIAE(env); |
| 659 | } |
| 660 | |
| 661 | // The other end is not ready, just report we failed. |
| 662 | if (err == NO_INIT) { |
| 663 | return JNI_FALSE; |
| 664 | } |
| 665 | |
| 666 | return JNI_TRUE; |
| 667 | } |
| 668 | |
| 669 | static jboolean nativeGetContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject, |
| 670 | jobject outStats) { |
| 671 | FrameStats stats; |
| 672 | |
| 673 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 674 | status_t err = ctrl->getLayerFrameStats(&stats); |
| 675 | if (err < 0 && err != NO_INIT) { |
| 676 | doThrowIAE(env); |
| 677 | } |
| 678 | |
| 679 | // The other end is not ready, fine just return empty stats. |
| 680 | if (err == NO_INIT) { |
| 681 | return JNI_FALSE; |
| 682 | } |
| 683 | |
| 684 | jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano); |
| 685 | size_t frameCount = stats.desiredPresentTimesNano.size(); |
| 686 | |
| 687 | jlongArray postedTimesNanoDst = env->NewLongArray(frameCount); |
| 688 | if (postedTimesNanoDst == NULL) { |
| 689 | return JNI_FALSE; |
| 690 | } |
| 691 | |
| 692 | jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount); |
| 693 | if (presentedTimesNanoDst == NULL) { |
| 694 | return JNI_FALSE; |
| 695 | } |
| 696 | |
| 697 | jlongArray readyTimesNanoDst = env->NewLongArray(frameCount); |
| 698 | if (readyTimesNanoDst == NULL) { |
| 699 | return JNI_FALSE; |
| 700 | } |
| 701 | |
| 702 | nsecs_t postedTimesNanoSrc[frameCount]; |
| 703 | nsecs_t presentedTimesNanoSrc[frameCount]; |
| 704 | nsecs_t readyTimesNanoSrc[frameCount]; |
| 705 | |
| 706 | for (size_t i = 0; i < frameCount; i++) { |
| 707 | nsecs_t postedTimeNano = stats.desiredPresentTimesNano[i]; |
| 708 | if (postedTimeNano == INT64_MAX) { |
| 709 | postedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 710 | } |
| 711 | postedTimesNanoSrc[i] = postedTimeNano; |
| 712 | |
| 713 | nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i]; |
| 714 | if (presentedTimeNano == INT64_MAX) { |
| 715 | presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 716 | } |
| 717 | presentedTimesNanoSrc[i] = presentedTimeNano; |
| 718 | |
| 719 | nsecs_t readyTimeNano = stats.frameReadyTimesNano[i]; |
| 720 | if (readyTimeNano == INT64_MAX) { |
| 721 | readyTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 722 | } |
| 723 | readyTimesNanoSrc[i] = readyTimeNano; |
| 724 | } |
| 725 | |
| 726 | env->SetLongArrayRegion(postedTimesNanoDst, 0, frameCount, postedTimesNanoSrc); |
| 727 | env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc); |
| 728 | env->SetLongArrayRegion(readyTimesNanoDst, 0, frameCount, readyTimesNanoSrc); |
| 729 | |
| 730 | env->CallVoidMethod(outStats, gWindowContentFrameStatsClassInfo.init, refreshPeriodNano, |
| 731 | postedTimesNanoDst, presentedTimesNanoDst, readyTimesNanoDst); |
| 732 | |
| 733 | if (env->ExceptionCheck()) { |
| 734 | return JNI_FALSE; |
| 735 | } |
| 736 | |
| 737 | return JNI_TRUE; |
| 738 | } |
| 739 | |
| 740 | static jboolean nativeClearAnimationFrameStats(JNIEnv* env, jclass clazz) { |
| 741 | status_t err = SurfaceComposerClient::clearAnimationFrameStats(); |
| 742 | |
| 743 | if (err < 0 && err != NO_INIT) { |
| 744 | doThrowIAE(env); |
| 745 | } |
| 746 | |
| 747 | // The other end is not ready, just report we failed. |
| 748 | if (err == NO_INIT) { |
| 749 | return JNI_FALSE; |
| 750 | } |
| 751 | |
| 752 | return JNI_TRUE; |
| 753 | } |
| 754 | |
| 755 | static jboolean nativeGetAnimationFrameStats(JNIEnv* env, jclass clazz, jobject outStats) { |
| 756 | FrameStats stats; |
| 757 | |
| 758 | status_t err = SurfaceComposerClient::getAnimationFrameStats(&stats); |
| 759 | if (err < 0 && err != NO_INIT) { |
| 760 | doThrowIAE(env); |
| 761 | } |
| 762 | |
| 763 | // The other end is not ready, fine just return empty stats. |
| 764 | if (err == NO_INIT) { |
| 765 | return JNI_FALSE; |
| 766 | } |
| 767 | |
| 768 | jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano); |
| 769 | size_t frameCount = stats.desiredPresentTimesNano.size(); |
| 770 | |
| 771 | jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount); |
| 772 | if (presentedTimesNanoDst == NULL) { |
| 773 | return JNI_FALSE; |
| 774 | } |
| 775 | |
| 776 | nsecs_t presentedTimesNanoSrc[frameCount]; |
| 777 | |
| 778 | for (size_t i = 0; i < frameCount; i++) { |
Allen Hair | ac5eda3 | 2014-04-24 11:50:37 -0700 | [diff] [blame] | 779 | nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i]; |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 780 | if (presentedTimeNano == INT64_MAX) { |
| 781 | presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 782 | } |
| 783 | presentedTimesNanoSrc[i] = presentedTimeNano; |
| 784 | } |
| 785 | |
| 786 | env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc); |
| 787 | |
| 788 | env->CallVoidMethod(outStats, gWindowAnimationFrameStatsClassInfo.init, refreshPeriodNano, |
| 789 | presentedTimesNanoDst); |
| 790 | |
| 791 | if (env->ExceptionCheck()) { |
| 792 | return JNI_FALSE; |
| 793 | } |
| 794 | |
| 795 | return JNI_TRUE; |
| 796 | } |
| 797 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 798 | static void nativeDeferTransactionUntil(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 799 | jlong nativeObject, |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 800 | jobject handleObject, jlong frameNumber) { |
| 801 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 802 | sp<IBinder> handle = ibinderForJavaObject(env, handleObject); |
| 803 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 804 | { |
| 805 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
Marissa Wall | cb32fdd | 2018-07-24 09:53:30 -0700 | [diff] [blame] | 806 | transaction->deferTransactionUntil_legacy(ctrl, handle, frameNumber); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 807 | } |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 808 | } |
| 809 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 810 | static void nativeDeferTransactionUntilSurface(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 811 | jlong nativeObject, |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 812 | jlong surfaceObject, jlong frameNumber) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 813 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 814 | |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 815 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 816 | sp<Surface> barrier = reinterpret_cast<Surface *>(surfaceObject); |
| 817 | |
Marissa Wall | cb32fdd | 2018-07-24 09:53:30 -0700 | [diff] [blame] | 818 | transaction->deferTransactionUntil_legacy(ctrl, barrier, frameNumber); |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 819 | } |
| 820 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 821 | static void nativeReparentChildren(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 822 | jlong nativeObject, |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 823 | jobject newParentObject) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 824 | |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 825 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 826 | sp<IBinder> handle = ibinderForJavaObject(env, newParentObject); |
| 827 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 828 | { |
| 829 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 830 | transaction->reparentChildren(ctrl, handle); |
| 831 | } |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 832 | } |
| 833 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 834 | static void nativeReparent(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 835 | jlong nativeObject, |
chaviw | 7643140 | 2017-09-18 16:50:05 -0700 | [diff] [blame] | 836 | jobject newParentObject) { |
chaviw | 6354238 | 2017-08-17 17:39:29 -0700 | [diff] [blame] | 837 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 838 | sp<IBinder> parentHandle = ibinderForJavaObject(env, newParentObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 839 | |
| 840 | { |
| 841 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 842 | transaction->reparent(ctrl, parentHandle); |
| 843 | } |
chaviw | 6354238 | 2017-08-17 17:39:29 -0700 | [diff] [blame] | 844 | } |
| 845 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 846 | static void nativeSeverChildren(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 847 | jlong nativeObject) { |
| 848 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 849 | |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 850 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 851 | transaction->detachChildren(ctrl); |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 852 | } |
| 853 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 854 | static void nativeSetOverrideScalingMode(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 855 | jlong nativeObject, |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 856 | jint scalingMode) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 857 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 858 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 859 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 860 | transaction->setOverrideScalingMode(ctrl, scalingMode); |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 861 | } |
| 862 | |
Chavi Weingarten | b736e32 | 2018-02-23 00:27:54 +0000 | [diff] [blame] | 863 | static void nativeDestroyInTransaction(JNIEnv* env, jclass clazz, |
| 864 | jlong transactionObj, |
| 865 | jlong nativeObject) { |
| 866 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 867 | auto ctrl = reinterpret_cast<SurfaceControl*>(nativeObject); |
| 868 | transaction->destroySurface(ctrl); |
| 869 | } |
| 870 | |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 871 | static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 872 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 873 | return javaObjectForIBinder(env, ctrl->getHandle()); |
| 874 | } |
| 875 | |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 876 | static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) { |
| 877 | sp<IBinder> token(ibinderForJavaObject(env, tokenObject)); |
| 878 | if (token == NULL) return NULL; |
| 879 | |
| 880 | HdrCapabilities capabilities; |
| 881 | SurfaceComposerClient::getHdrCapabilities(token, &capabilities); |
| 882 | |
| 883 | const auto& types = capabilities.getSupportedHdrTypes(); |
Peiyong Lin | 3a0c6e1 | 2018-04-16 11:05:29 -0700 | [diff] [blame] | 884 | std::vector<int32_t> intTypes; |
| 885 | for (auto type : types) { |
| 886 | intTypes.push_back(static_cast<int32_t>(type)); |
| 887 | } |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 888 | auto typesArray = env->NewIntArray(types.size()); |
Peiyong Lin | 3a0c6e1 | 2018-04-16 11:05:29 -0700 | [diff] [blame] | 889 | env->SetIntArrayRegion(typesArray, 0, intTypes.size(), intTypes.data()); |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 890 | |
Michael Wright | 9ff94c0 | 2016-03-30 18:05:40 -0700 | [diff] [blame] | 891 | return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor, |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 892 | typesArray, capabilities.getDesiredMaxLuminance(), |
| 893 | capabilities.getDesiredMaxAverageLuminance(), capabilities.getDesiredMinLuminance()); |
| 894 | } |
| 895 | |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 896 | static jlong nativeReadFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) { |
| 897 | Parcel* parcel = parcelForJavaObject(env, parcelObj); |
| 898 | if (parcel == NULL) { |
| 899 | doThrowNPE(env); |
| 900 | return 0; |
| 901 | } |
| 902 | sp<SurfaceControl> surface = SurfaceControl::readFromParcel(parcel); |
| 903 | if (surface == nullptr) { |
| 904 | return 0; |
| 905 | } |
| 906 | surface->incStrong((void *)nativeCreate); |
| 907 | return reinterpret_cast<jlong>(surface.get()); |
| 908 | } |
| 909 | |
chaviw | beb7a0c | 2018-12-05 13:49:54 -0800 | [diff] [blame] | 910 | static jlong nativeCopyFromSurfaceControl(JNIEnv* env, jclass clazz, jlong surfaceControlNativeObj) { |
| 911 | sp<SurfaceControl> surface(reinterpret_cast<SurfaceControl *>(surfaceControlNativeObj)); |
| 912 | if (surface == nullptr) { |
| 913 | return 0; |
| 914 | } |
Robert Carr | 5fea55b | 2018-12-10 13:05:52 -0800 | [diff] [blame^] | 915 | |
| 916 | sp<SurfaceControl> newSurface = new SurfaceControl(surface); |
| 917 | newSurface->incStrong((void *)nativeCreate); |
| 918 | return reinterpret_cast<jlong>(newSurface.get()); |
chaviw | beb7a0c | 2018-12-05 13:49:54 -0800 | [diff] [blame] | 919 | } |
| 920 | |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 921 | static void nativeWriteToParcel(JNIEnv* env, jclass clazz, |
| 922 | jlong nativeObject, jobject parcelObj) { |
| 923 | Parcel* parcel = parcelForJavaObject(env, parcelObj); |
| 924 | if (parcel == NULL) { |
| 925 | doThrowNPE(env); |
| 926 | return; |
| 927 | } |
| 928 | SurfaceControl* const self = reinterpret_cast<SurfaceControl *>(nativeObject); |
chaviw | beb7a0c | 2018-12-05 13:49:54 -0800 | [diff] [blame] | 929 | if (self != nullptr) { |
| 930 | self->writeToParcel(parcel); |
| 931 | } |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 932 | } |
| 933 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 934 | // ---------------------------------------------------------------------------- |
| 935 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 936 | static const JNINativeMethod sSurfaceControlMethods[] = { |
Albert Chaulk | 3bf2e57 | 2016-11-22 13:59:19 -0500 | [diff] [blame] | 937 | {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIIIJII)J", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 938 | (void*)nativeCreate }, |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 939 | {"nativeReadFromParcel", "(Landroid/os/Parcel;)J", |
| 940 | (void*)nativeReadFromParcel }, |
chaviw | beb7a0c | 2018-12-05 13:49:54 -0800 | [diff] [blame] | 941 | {"nativeCopyFromSurfaceControl", "(J)J" , |
| 942 | (void*)nativeCopyFromSurfaceControl }, |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 943 | {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V", |
| 944 | (void*)nativeWriteToParcel }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 945 | {"nativeRelease", "(J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 946 | (void*)nativeRelease }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 947 | {"nativeDestroy", "(J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 948 | (void*)nativeDestroy }, |
Chong Zhang | 47e36a3 | 2016-02-29 16:44:33 -0800 | [diff] [blame] | 949 | {"nativeDisconnect", "(J)V", |
| 950 | (void*)nativeDisconnect }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 951 | {"nativeCreateTransaction", "()J", |
| 952 | (void*)nativeCreateTransaction }, |
| 953 | {"nativeApplyTransaction", "(JZ)V", |
| 954 | (void*)nativeApplyTransaction }, |
| 955 | {"nativeGetNativeTransactionFinalizer", "()J", |
| 956 | (void*)nativeGetNativeTransactionFinalizer }, |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 957 | {"nativeMergeTransaction", "(JJ)V", |
| 958 | (void*)nativeMergeTransaction }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 959 | {"nativeSetAnimationTransaction", "(J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 960 | (void*)nativeSetAnimationTransaction }, |
Jorim Jaggi | aa763cd | 2018-03-22 23:20:36 +0100 | [diff] [blame] | 961 | {"nativeSetEarlyWakeup", "(J)V", |
| 962 | (void*)nativeSetEarlyWakeup }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 963 | {"nativeSetLayer", "(JJI)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 964 | (void*)nativeSetLayer }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 965 | {"nativeSetRelativeLayer", "(JJLandroid/os/IBinder;I)V", |
Robert Carr | af422a8 | 2017-04-10 18:34:33 -0700 | [diff] [blame] | 966 | (void*)nativeSetRelativeLayer }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 967 | {"nativeSetPosition", "(JJFF)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 968 | (void*)nativeSetPosition }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 969 | {"nativeSetGeometryAppliesWithResize", "(JJ)V", |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 970 | (void*)nativeSetGeometryAppliesWithResize }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 971 | {"nativeSetSize", "(JJII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 972 | (void*)nativeSetSize }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 973 | {"nativeSetTransparentRegionHint", "(JJLandroid/graphics/Region;)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 974 | (void*)nativeSetTransparentRegionHint }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 975 | {"nativeSetAlpha", "(JJF)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 976 | (void*)nativeSetAlpha }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 977 | {"nativeSetColor", "(JJ[F)V", |
chaviw | 0dd03f5 | 2017-08-25 12:15:26 -0700 | [diff] [blame] | 978 | (void*)nativeSetColor }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 979 | {"nativeSetMatrix", "(JJFFFF)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 980 | (void*)nativeSetMatrix }, |
Peiyong Lin | 52bb6b4 | 2018-10-01 11:40:50 -0700 | [diff] [blame] | 981 | {"nativeSetColorTransform", "(JJ[F[F)V", |
| 982 | (void*)nativeSetColorTransform }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 983 | {"nativeSetFlags", "(JJII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 984 | (void*)nativeSetFlags }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 985 | {"nativeSetWindowCrop", "(JJIIII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 986 | (void*)nativeSetWindowCrop }, |
Lucas Dupin | ff9d6ab | 2018-10-16 18:05:50 -0700 | [diff] [blame] | 987 | {"nativeSetCornerRadius", "(JJF)V", |
| 988 | (void*)nativeSetCornerRadius }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 989 | {"nativeSetLayerStack", "(JJI)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 990 | (void*)nativeSetLayerStack }, |
| 991 | {"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;", |
| 992 | (void*)nativeGetBuiltInDisplay }, |
| 993 | {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;", |
| 994 | (void*)nativeCreateDisplay }, |
Jesse Hall | 6a6bc21 | 2013-08-08 12:15:03 -0700 | [diff] [blame] | 995 | {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V", |
| 996 | (void*)nativeDestroyDisplay }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 997 | {"nativeSetDisplaySurface", "(JLandroid/os/IBinder;J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 998 | (void*)nativeSetDisplaySurface }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 999 | {"nativeSetDisplayLayerStack", "(JLandroid/os/IBinder;I)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1000 | (void*)nativeSetDisplayLayerStack }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1001 | {"nativeSetDisplayProjection", "(JLandroid/os/IBinder;IIIIIIIII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1002 | (void*)nativeSetDisplayProjection }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1003 | {"nativeSetDisplaySize", "(JLandroid/os/IBinder;II)V", |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 1004 | (void*)nativeSetDisplaySize }, |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 1005 | {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;", |
| 1006 | (void*)nativeGetDisplayConfigs }, |
| 1007 | {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I", |
| 1008 | (void*)nativeGetActiveConfig }, |
| 1009 | {"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z", |
| 1010 | (void*)nativeSetActiveConfig }, |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 1011 | {"nativeGetDisplayColorModes", "(Landroid/os/IBinder;)[I", |
| 1012 | (void*)nativeGetDisplayColorModes}, |
| 1013 | {"nativeGetActiveColorMode", "(Landroid/os/IBinder;)I", |
| 1014 | (void*)nativeGetActiveColorMode}, |
| 1015 | {"nativeSetActiveColorMode", "(Landroid/os/IBinder;I)Z", |
| 1016 | (void*)nativeSetActiveColorMode}, |
Michael Wright | 9ff94c0 | 2016-03-30 18:05:40 -0700 | [diff] [blame] | 1017 | {"nativeGetHdrCapabilities", "(Landroid/os/IBinder;)Landroid/view/Display$HdrCapabilities;", |
| 1018 | (void*)nativeGetHdrCapabilities }, |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1019 | {"nativeClearContentFrameStats", "(J)Z", |
| 1020 | (void*)nativeClearContentFrameStats }, |
| 1021 | {"nativeGetContentFrameStats", "(JLandroid/view/WindowContentFrameStats;)Z", |
| 1022 | (void*)nativeGetContentFrameStats }, |
| 1023 | {"nativeClearAnimationFrameStats", "()Z", |
| 1024 | (void*)nativeClearAnimationFrameStats }, |
| 1025 | {"nativeGetAnimationFrameStats", "(Landroid/view/WindowAnimationFrameStats;)Z", |
| 1026 | (void*)nativeGetAnimationFrameStats }, |
Prashant Malani | c55929a | 2014-05-25 01:59:21 -0700 | [diff] [blame] | 1027 | {"nativeSetDisplayPowerMode", "(Landroid/os/IBinder;I)V", |
| 1028 | (void*)nativeSetDisplayPowerMode }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1029 | {"nativeDeferTransactionUntil", "(JJLandroid/os/IBinder;J)V", |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 1030 | (void*)nativeDeferTransactionUntil }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1031 | {"nativeDeferTransactionUntilSurface", "(JJJJ)V", |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1032 | (void*)nativeDeferTransactionUntilSurface }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1033 | {"nativeReparentChildren", "(JJLandroid/os/IBinder;)V", |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1034 | (void*)nativeReparentChildren } , |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1035 | {"nativeReparent", "(JJLandroid/os/IBinder;)V", |
chaviw | 7643140 | 2017-09-18 16:50:05 -0700 | [diff] [blame] | 1036 | (void*)nativeReparent }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1037 | {"nativeSeverChildren", "(JJ)V", |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1038 | (void*)nativeSeverChildren } , |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1039 | {"nativeSetOverrideScalingMode", "(JJI)V", |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 1040 | (void*)nativeSetOverrideScalingMode }, |
Chavi Weingarten | b736e32 | 2018-02-23 00:27:54 +0000 | [diff] [blame] | 1041 | {"nativeDestroy", "(JJ)V", |
| 1042 | (void*)nativeDestroyInTransaction }, |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 1043 | {"nativeGetHandle", "(J)Landroid/os/IBinder;", |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 1044 | (void*)nativeGetHandle }, |
chaviw | 08520a0 | 2018-09-10 16:44:56 -0700 | [diff] [blame] | 1045 | {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/graphics/Rect;IIZI)Landroid/graphics/GraphicBuffer;", |
| 1046 | (void*)nativeScreenshot }, |
Chavi Weingarten | ea2eb5a | 2017-11-29 21:26:24 +0000 | [diff] [blame] | 1047 | {"nativeCaptureLayers", "(Landroid/os/IBinder;Landroid/graphics/Rect;F)Landroid/graphics/GraphicBuffer;", |
Chavi Weingarten | d7ec64c | 2017-11-30 01:52:01 +0000 | [diff] [blame] | 1048 | (void*)nativeCaptureLayers }, |
Robert Carr | 788f574 | 2018-07-30 17:46:45 -0700 | [diff] [blame] | 1049 | {"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V", |
| 1050 | (void*)nativeSetInputWindowInfo }, |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 1051 | {"nativeGetDisplayedContentSamplingAttributes", |
| 1052 | "(Landroid/os/IBinder;)Landroid/hardware/display/DisplayedContentSamplingAttributes;", |
| 1053 | (void*)nativeGetDisplayedContentSamplingAttributes }, |
| 1054 | {"nativeSetDisplayedContentSamplingEnabled", "(Landroid/os/IBinder;ZII)Z", |
| 1055 | (void*)nativeSetDisplayedContentSamplingEnabled }, |
| 1056 | {"nativeGetDisplayedContentSample", |
| 1057 | "(Landroid/os/IBinder;JJ)Landroid/hardware/display/DisplayedContentSample;", |
| 1058 | (void*)nativeGetDisplayedContentSample }, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1059 | }; |
| 1060 | |
| 1061 | int register_android_view_SurfaceControl(JNIEnv* env) |
| 1062 | { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1063 | int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1064 | sSurfaceControlMethods, NELEM(sSurfaceControlMethods)); |
| 1065 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1066 | jclass clazz = FindClassOrDie(env, "android/view/SurfaceControl$PhysicalDisplayInfo"); |
| 1067 | gPhysicalDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, clazz); |
| 1068 | gPhysicalDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, |
| 1069 | gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V"); |
| 1070 | gPhysicalDisplayInfoClassInfo.width = GetFieldIDOrDie(env, clazz, "width", "I"); |
| 1071 | gPhysicalDisplayInfoClassInfo.height = GetFieldIDOrDie(env, clazz, "height", "I"); |
| 1072 | gPhysicalDisplayInfoClassInfo.refreshRate = GetFieldIDOrDie(env, clazz, "refreshRate", "F"); |
| 1073 | gPhysicalDisplayInfoClassInfo.density = GetFieldIDOrDie(env, clazz, "density", "F"); |
| 1074 | gPhysicalDisplayInfoClassInfo.xDpi = GetFieldIDOrDie(env, clazz, "xDpi", "F"); |
| 1075 | gPhysicalDisplayInfoClassInfo.yDpi = GetFieldIDOrDie(env, clazz, "yDpi", "F"); |
| 1076 | gPhysicalDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, clazz, "secure", "Z"); |
| 1077 | gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env, |
| 1078 | clazz, "appVsyncOffsetNanos", "J"); |
| 1079 | gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env, |
| 1080 | clazz, "presentationDeadlineNanos", "J"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1081 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1082 | jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect"); |
| 1083 | gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I"); |
| 1084 | gRectClassInfo.left = GetFieldIDOrDie(env, rectClazz, "left", "I"); |
| 1085 | gRectClassInfo.right = GetFieldIDOrDie(env, rectClazz, "right", "I"); |
| 1086 | gRectClassInfo.top = GetFieldIDOrDie(env, rectClazz, "top", "I"); |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 1087 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1088 | jclass frameStatsClazz = FindClassOrDie(env, "android/view/FrameStats"); |
| 1089 | jfieldID undefined_time_nano_field = GetStaticFieldIDOrDie(env, |
| 1090 | frameStatsClazz, "UNDEFINED_TIME_NANO", "J"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1091 | nsecs_t undefined_time_nano = env->GetStaticLongField(frameStatsClazz, undefined_time_nano_field); |
| 1092 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1093 | jclass contFrameStatsClazz = FindClassOrDie(env, "android/view/WindowContentFrameStats"); |
| 1094 | gWindowContentFrameStatsClassInfo.init = GetMethodIDOrDie(env, |
| 1095 | contFrameStatsClazz, "init", "(J[J[J[J)V"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1096 | gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano; |
| 1097 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1098 | jclass animFrameStatsClazz = FindClassOrDie(env, "android/view/WindowAnimationFrameStats"); |
| 1099 | gWindowAnimationFrameStatsClassInfo.init = GetMethodIDOrDie(env, |
| 1100 | animFrameStatsClazz, "init", "(J[J)V"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1101 | gWindowAnimationFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano; |
| 1102 | |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 1103 | jclass hdrCapabilitiesClazz = FindClassOrDie(env, "android/view/Display$HdrCapabilities"); |
| 1104 | gHdrCapabilitiesClassInfo.clazz = MakeGlobalRefOrDie(env, hdrCapabilitiesClazz); |
| 1105 | gHdrCapabilitiesClassInfo.ctor = GetMethodIDOrDie(env, hdrCapabilitiesClazz, "<init>", |
| 1106 | "([IFFF)V"); |
| 1107 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 1108 | jclass graphicsBufferClazz = FindClassOrDie(env, "android/graphics/GraphicBuffer"); |
| 1109 | gGraphicBufferClassInfo.clazz = MakeGlobalRefOrDie(env, graphicsBufferClazz); |
| 1110 | gGraphicBufferClassInfo.builder = GetStaticMethodIDOrDie(env, graphicsBufferClazz, |
| 1111 | "createFromExisting", "(IIIIJ)Landroid/graphics/GraphicBuffer;"); |
| 1112 | |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 1113 | jclass displayedContentSampleClazz = FindClassOrDie(env, |
| 1114 | "android/hardware/display/DisplayedContentSample"); |
| 1115 | gDisplayedContentSampleClassInfo.clazz = MakeGlobalRefOrDie(env, displayedContentSampleClazz); |
| 1116 | gDisplayedContentSampleClassInfo.ctor = GetMethodIDOrDie(env, |
| 1117 | displayedContentSampleClazz, "<init>", "(J[J[J[J[J)V"); |
| 1118 | |
| 1119 | jclass displayedContentSamplingAttributesClazz = FindClassOrDie(env, |
| 1120 | "android/hardware/display/DisplayedContentSamplingAttributes"); |
| 1121 | gDisplayedContentSamplingAttributesClassInfo.clazz = MakeGlobalRefOrDie(env, |
| 1122 | displayedContentSamplingAttributesClazz); |
| 1123 | gDisplayedContentSamplingAttributesClassInfo.ctor = GetMethodIDOrDie(env, |
| 1124 | displayedContentSamplingAttributesClazz, "<init>", "(III)V"); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1125 | return err; |
| 1126 | } |
| 1127 | |
| 1128 | }; |