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> |
Daniel Solomon | 10e3b33 | 2019-01-20 21:09:11 -0800 | [diff] [blame] | 39 | #include <ui/ConfigStoreTypes.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 40 | #include <ui/DisplayInfo.h> |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 41 | #include <ui/DisplayedFrameStats.h> |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 42 | #include <ui/FrameStats.h> |
Peiyong Lin | b88549e | 2018-03-28 12:03:45 -0700 | [diff] [blame] | 43 | #include <ui/GraphicTypes.h> |
Peiyong Lin | 371b98f | 2018-03-14 17:29:10 -0700 | [diff] [blame] | 44 | #include <ui/HdrCapabilities.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 45 | #include <ui/Rect.h> |
| 46 | #include <ui/Region.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 47 | #include <utils/Log.h> |
| 48 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 49 | // ---------------------------------------------------------------------------- |
| 50 | |
| 51 | namespace android { |
| 52 | |
| 53 | static const char* const OutOfResourcesException = |
| 54 | "android/view/Surface$OutOfResourcesException"; |
| 55 | |
| 56 | static struct { |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 57 | jclass clazz; |
| 58 | jmethodID ctor; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 59 | jfieldID width; |
| 60 | jfieldID height; |
| 61 | jfieldID refreshRate; |
| 62 | jfieldID density; |
| 63 | jfieldID xDpi; |
| 64 | jfieldID yDpi; |
| 65 | jfieldID secure; |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 66 | jfieldID appVsyncOffsetNanos; |
| 67 | jfieldID presentationDeadlineNanos; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 68 | } gPhysicalDisplayInfoClassInfo; |
| 69 | |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 70 | static struct { |
| 71 | jfieldID bottom; |
| 72 | jfieldID left; |
| 73 | jfieldID right; |
| 74 | jfieldID top; |
| 75 | } gRectClassInfo; |
| 76 | |
Leon Scroggins | 46cb9bd | 2014-03-06 15:36:39 -0500 | [diff] [blame] | 77 | // Implements SkMallocPixelRef::ReleaseProc, to delete the screenshot on unref. |
| 78 | void DeleteScreenshot(void* addr, void* context) { |
Leon Scroggins | 46cb9bd | 2014-03-06 15:36:39 -0500 | [diff] [blame] | 79 | delete ((ScreenshotClient*) context); |
| 80 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 81 | |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 82 | static struct { |
| 83 | nsecs_t UNDEFINED_TIME_NANO; |
| 84 | jmethodID init; |
| 85 | } gWindowContentFrameStatsClassInfo; |
| 86 | |
| 87 | static struct { |
| 88 | nsecs_t UNDEFINED_TIME_NANO; |
| 89 | jmethodID init; |
| 90 | } gWindowAnimationFrameStatsClassInfo; |
| 91 | |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 92 | static struct { |
| 93 | jclass clazz; |
| 94 | jmethodID ctor; |
| 95 | } gHdrCapabilitiesClassInfo; |
| 96 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 97 | static struct { |
| 98 | jclass clazz; |
| 99 | jmethodID builder; |
| 100 | } gGraphicBufferClassInfo; |
| 101 | |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 102 | static struct { |
| 103 | jclass clazz; |
| 104 | jmethodID ctor; |
| 105 | } gDisplayedContentSampleClassInfo; |
| 106 | |
| 107 | static struct { |
| 108 | jclass clazz; |
| 109 | jmethodID ctor; |
| 110 | } gDisplayedContentSamplingAttributesClassInfo; |
| 111 | |
Daniel Solomon | 10e3b33 | 2019-01-20 21:09:11 -0800 | [diff] [blame] | 112 | static struct { |
| 113 | jclass clazz; |
| 114 | jmethodID ctor; |
| 115 | jfieldID X; |
| 116 | jfieldID Y; |
| 117 | jfieldID Z; |
| 118 | } gCieXyzClassInfo; |
| 119 | |
| 120 | static struct { |
| 121 | jclass clazz; |
| 122 | jmethodID ctor; |
| 123 | jfieldID red; |
| 124 | jfieldID green; |
| 125 | jfieldID blue; |
| 126 | jfieldID white; |
| 127 | } gDisplayPrimariesClassInfo; |
| 128 | |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 129 | static struct { |
| 130 | jclass clazz; |
| 131 | jmethodID builder; |
| 132 | } gScreenshotGraphicBufferClassInfo; |
| 133 | |
| 134 | class JNamedColorSpace { |
| 135 | public: |
| 136 | // ColorSpace.Named.SRGB.ordinal() = 0; |
| 137 | static constexpr jint SRGB = 0; |
| 138 | |
| 139 | // ColorSpace.Named.DISPLAY_P3.ordinal() = 6; |
| 140 | static constexpr jint DISPLAY_P3 = 6; |
| 141 | }; |
| 142 | |
| 143 | constexpr jint fromDataspaceToNamedColorSpaceValue(const ui::Dataspace dataspace) { |
| 144 | switch (dataspace) { |
| 145 | case ui::Dataspace::DISPLAY_P3: |
| 146 | return JNamedColorSpace::DISPLAY_P3; |
| 147 | default: |
| 148 | return JNamedColorSpace::SRGB; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | constexpr ui::Dataspace pickDataspaceFromColorMode(const ui::ColorMode colorMode) { |
| 153 | switch (colorMode) { |
| 154 | case ui::ColorMode::DISPLAY_P3: |
| 155 | case ui::ColorMode::BT2100_PQ: |
| 156 | case ui::ColorMode::BT2100_HLG: |
| 157 | case ui::ColorMode::DISPLAY_BT2020: |
| 158 | return ui::Dataspace::DISPLAY_P3; |
| 159 | default: |
| 160 | return ui::Dataspace::V0_SRGB; |
| 161 | } |
| 162 | } |
| 163 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 164 | // ---------------------------------------------------------------------------- |
| 165 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 166 | static jlong nativeCreateTransaction(JNIEnv* env, jclass clazz) { |
| 167 | return reinterpret_cast<jlong>(new SurfaceComposerClient::Transaction); |
| 168 | } |
| 169 | |
| 170 | static void releaseTransaction(SurfaceComposerClient::Transaction* t) { |
| 171 | delete t; |
| 172 | } |
| 173 | |
| 174 | static jlong nativeGetNativeTransactionFinalizer(JNIEnv* env, jclass clazz) { |
| 175 | return static_cast<jlong>(reinterpret_cast<uintptr_t>(&releaseTransaction)); |
| 176 | } |
| 177 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 178 | static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj, |
Albert Chaulk | 3bf2e57 | 2016-11-22 13:59:19 -0500 | [diff] [blame] | 179 | jstring nameStr, jint w, jint h, jint format, jint flags, jlong parentObject, |
Evan Rosky | 485df20 | 2018-12-06 14:11:12 -0800 | [diff] [blame] | 180 | jobject metadataParcel) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 181 | ScopedUtfChars name(env, nameStr); |
Robert Carr | 76907ee | 2019-01-11 13:38:19 -0800 | [diff] [blame] | 182 | sp<SurfaceComposerClient> client; |
| 183 | if (sessionObj != NULL) { |
| 184 | client = android_view_SurfaceSession_getClient(env, sessionObj); |
| 185 | } else { |
| 186 | client = SurfaceComposerClient::getDefault(); |
| 187 | } |
Robert Carr | 838120c | 2016-11-01 18:31:12 -0700 | [diff] [blame] | 188 | SurfaceControl *parent = reinterpret_cast<SurfaceControl*>(parentObject); |
Robert Carr | b0f3936 | 2018-03-14 13:52:25 -0700 | [diff] [blame] | 189 | sp<SurfaceControl> surface; |
Evan Rosky | 485df20 | 2018-12-06 14:11:12 -0800 | [diff] [blame] | 190 | LayerMetadata metadata; |
| 191 | Parcel* parcel = parcelForJavaObject(env, metadataParcel); |
| 192 | if (parcel && !parcel->objectsCount()) { |
| 193 | status_t err = metadata.readFromParcel(parcel); |
| 194 | if (err != NO_ERROR) { |
| 195 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 196 | "Metadata parcel has wrong format"); |
| 197 | } |
| 198 | } |
| 199 | |
Robert Carr | b0f3936 | 2018-03-14 13:52:25 -0700 | [diff] [blame] | 200 | status_t err = client->createSurfaceChecked( |
Evan Rosky | 485df20 | 2018-12-06 14:11:12 -0800 | [diff] [blame] | 201 | String8(name.c_str()), w, h, format, &surface, flags, parent, std::move(metadata)); |
Robert Carr | b0f3936 | 2018-03-14 13:52:25 -0700 | [diff] [blame] | 202 | if (err == NAME_NOT_FOUND) { |
| 203 | jniThrowException(env, "java/lang/IllegalArgumentException", NULL); |
| 204 | return 0; |
| 205 | } else if (err != NO_ERROR) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 206 | jniThrowException(env, OutOfResourcesException, NULL); |
| 207 | return 0; |
| 208 | } |
Albert Chaulk | 3bf2e57 | 2016-11-22 13:59:19 -0500 | [diff] [blame] | 209 | |
Mathias Agopian | b1d90c8 | 2013-03-06 17:45:42 -0800 | [diff] [blame] | 210 | surface->incStrong((void *)nativeCreate); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 211 | return reinterpret_cast<jlong>(surface.get()); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 212 | } |
| 213 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 214 | static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 215 | sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); |
Robert Carr | cc6d483 | 2019-02-04 15:41:12 -0800 | [diff] [blame] | 216 | ctrl->release(); |
Mathias Agopian | b1d90c8 | 2013-03-06 17:45:42 -0800 | [diff] [blame] | 217 | ctrl->decStrong((void *)nativeCreate); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 218 | } |
| 219 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 220 | static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 221 | sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); |
Robert Carr | cc6d483 | 2019-02-04 15:41:12 -0800 | [diff] [blame] | 222 | ctrl->destroy(); |
Mathias Agopian | b1d90c8 | 2013-03-06 17:45:42 -0800 | [diff] [blame] | 223 | ctrl->decStrong((void *)nativeCreate); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 224 | } |
| 225 | |
Chong Zhang | 47e36a3 | 2016-02-29 16:44:33 -0800 | [diff] [blame] | 226 | static void nativeDisconnect(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 227 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 228 | if (ctrl != NULL) { |
| 229 | ctrl->disconnect(); |
| 230 | } |
| 231 | } |
| 232 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 233 | static Rect rectFromObj(JNIEnv* env, jobject rectObj) { |
| 234 | int left = env->GetIntField(rectObj, gRectClassInfo.left); |
| 235 | int top = env->GetIntField(rectObj, gRectClassInfo.top); |
| 236 | int right = env->GetIntField(rectObj, gRectClassInfo.right); |
| 237 | int bottom = env->GetIntField(rectObj, gRectClassInfo.bottom); |
| 238 | return Rect(left, top, right, bottom); |
| 239 | } |
| 240 | |
chaviw | 08520a0 | 2018-09-10 16:44:56 -0700 | [diff] [blame] | 241 | static jobject nativeScreenshot(JNIEnv* env, jclass clazz, |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 242 | jobject displayTokenObj, jobject sourceCropObj, jint width, jint height, |
Robert Carr | 5c52b13 | 2019-02-15 15:48:11 -0800 | [diff] [blame] | 243 | bool useIdentityTransform, int rotation, bool captureSecureLayers) { |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 244 | sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj); |
| 245 | if (displayToken == NULL) { |
| 246 | return NULL; |
| 247 | } |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 248 | const ui::ColorMode colorMode = SurfaceComposerClient::getActiveColorMode(displayToken); |
| 249 | const ui::Dataspace dataspace = pickDataspaceFromColorMode(colorMode); |
| 250 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 251 | Rect sourceCrop = rectFromObj(env, sourceCropObj); |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 252 | sp<GraphicBuffer> buffer; |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 253 | status_t res = ScreenshotClient::capture(displayToken, dataspace, |
Robert Carr | 5c52b13 | 2019-02-15 15:48:11 -0800 | [diff] [blame] | 254 | ui::PixelFormat::RGBA_8888, |
| 255 | sourceCrop, width, height, |
| 256 | useIdentityTransform, rotation, captureSecureLayers, &buffer); |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 257 | if (res != NO_ERROR) { |
| 258 | return NULL; |
| 259 | } |
| 260 | |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 261 | const jint namedColorSpace = fromDataspaceToNamedColorSpaceValue(dataspace); |
| 262 | return env->CallStaticObjectMethod(gScreenshotGraphicBufferClassInfo.clazz, |
| 263 | gScreenshotGraphicBufferClassInfo.builder, |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 264 | buffer->getWidth(), |
| 265 | buffer->getHeight(), |
| 266 | buffer->getPixelFormat(), |
Mathias Agopian | 113fd30 | 2017-05-25 18:31:04 -0700 | [diff] [blame] | 267 | (jint)buffer->getUsage(), |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 268 | (jlong)buffer.get(), |
| 269 | namedColorSpace); |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 270 | } |
| 271 | |
Chavi Weingarten | d7ec64c | 2017-11-30 01:52:01 +0000 | [diff] [blame] | 272 | static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken, |
Robert Carr | ffcdc51 | 2019-04-02 11:51:11 -0700 | [diff] [blame^] | 273 | jobject sourceCropObj, jfloat frameScale, jobjectArray excludeArray) { |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 274 | |
| 275 | sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken); |
| 276 | if (layerHandle == NULL) { |
| 277 | return NULL; |
| 278 | } |
| 279 | |
| 280 | Rect sourceCrop; |
| 281 | if (sourceCropObj != NULL) { |
| 282 | sourceCrop = rectFromObj(env, sourceCropObj); |
| 283 | } |
| 284 | |
Robert Carr | ffcdc51 | 2019-04-02 11:51:11 -0700 | [diff] [blame^] | 285 | std::unordered_set<sp<IBinder>,ISurfaceComposer::SpHash<IBinder>> excludeHandles; |
| 286 | if (excludeArray != NULL) { |
| 287 | const jsize len = env->GetArrayLength(excludeArray); |
| 288 | excludeHandles.reserve(len); |
| 289 | |
| 290 | for (jsize i = 0; i < len; i++) { |
| 291 | jobject obj = env->GetObjectArrayElement(excludeArray, i); |
| 292 | if (obj == nullptr) { |
| 293 | jniThrowNullPointerException(env, "Exclude layer is null"); |
| 294 | return NULL; |
| 295 | } |
| 296 | sp<IBinder> excludeHandle = ibinderForJavaObject(env, obj); |
| 297 | excludeHandles.emplace(excludeHandle); |
| 298 | } |
| 299 | } |
| 300 | |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 301 | sp<GraphicBuffer> buffer; |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 302 | const ui::Dataspace dataspace = ui::Dataspace::V0_SRGB; |
| 303 | status_t res = ScreenshotClient::captureChildLayers(layerHandle, dataspace, |
Peiyong Lin | 10a34d1 | 2018-09-19 13:56:12 -0700 | [diff] [blame] | 304 | ui::PixelFormat::RGBA_8888, sourceCrop, |
Robert Carr | ffcdc51 | 2019-04-02 11:51:11 -0700 | [diff] [blame^] | 305 | excludeHandles, frameScale, &buffer); |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 306 | if (res != NO_ERROR) { |
| 307 | return NULL; |
| 308 | } |
| 309 | |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 310 | const jint namedColorSpace = fromDataspaceToNamedColorSpaceValue(dataspace); |
| 311 | return env->CallStaticObjectMethod(gScreenshotGraphicBufferClassInfo.clazz, |
| 312 | gScreenshotGraphicBufferClassInfo.builder, |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 313 | buffer->getWidth(), |
| 314 | buffer->getHeight(), |
| 315 | buffer->getPixelFormat(), |
| 316 | (jint)buffer->getUsage(), |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 317 | (jlong)buffer.get(), |
| 318 | namedColorSpace); |
chaviw | 1cda84c | 2017-10-23 16:47:10 -0700 | [diff] [blame] | 319 | } |
| 320 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 321 | static void nativeApplyTransaction(JNIEnv* env, jclass clazz, jlong transactionObj, jboolean sync) { |
| 322 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 323 | transaction->apply(sync); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 324 | } |
| 325 | |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 326 | static void nativeMergeTransaction(JNIEnv* env, jclass clazz, |
| 327 | jlong transactionObj, jlong otherTransactionObj) { |
| 328 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 329 | auto otherTransaction = reinterpret_cast<SurfaceComposerClient::Transaction*>( |
| 330 | otherTransactionObj); |
| 331 | transaction->merge(std::move(*otherTransaction)); |
| 332 | } |
| 333 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 334 | static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz, jlong transactionObj) { |
| 335 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 336 | transaction->setAnimationTransaction(); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 337 | } |
| 338 | |
Jorim Jaggi | aa763cd | 2018-03-22 23:20:36 +0100 | [diff] [blame] | 339 | static void nativeSetEarlyWakeup(JNIEnv* env, jclass clazz, jlong transactionObj) { |
| 340 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 341 | transaction->setEarlyWakeup(); |
| 342 | } |
| 343 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 344 | static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 345 | jlong nativeObject, jint zorder) { |
| 346 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 347 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 348 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 349 | transaction->setLayer(ctrl, zorder); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 350 | } |
| 351 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 352 | static void nativeSetRelativeLayer(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 353 | jlong nativeObject, |
Robert Carr | af422a8 | 2017-04-10 18:34:33 -0700 | [diff] [blame] | 354 | jobject relativeTo, jint zorder) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 355 | |
Robert Carr | af422a8 | 2017-04-10 18:34:33 -0700 | [diff] [blame] | 356 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 357 | sp<IBinder> handle = ibinderForJavaObject(env, relativeTo); |
| 358 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 359 | { |
| 360 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 361 | transaction->setRelativeLayer(ctrl, handle, zorder); |
| 362 | } |
Robert Carr | af422a8 | 2017-04-10 18:34:33 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 365 | static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 366 | jlong nativeObject, jfloat x, jfloat y) { |
| 367 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 368 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 369 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 370 | transaction->setPosition(ctrl, x, y); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 371 | } |
| 372 | |
Robert Carr | 76907ee | 2019-01-11 13:38:19 -0800 | [diff] [blame] | 373 | static void nativeSetGeometry(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, |
| 374 | jobject sourceObj, jobject dstObj, jlong orientation) { |
| 375 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 376 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 377 | |
| 378 | Rect source, dst; |
| 379 | if (sourceObj != NULL) { |
| 380 | source = rectFromObj(env, sourceObj); |
| 381 | } |
| 382 | if (dstObj != NULL) { |
| 383 | dst = rectFromObj(env, dstObj); |
| 384 | } |
| 385 | transaction->setGeometry(ctrl, source, dst, orientation); |
| 386 | } |
| 387 | |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 388 | static void nativeSetGeometryAppliesWithResize(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 389 | jlong transactionObj, |
Robert Carr | a9408d4 | 2016-06-03 13:28:48 -0700 | [diff] [blame] | 390 | jlong nativeObject) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 391 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 392 | |
Robert Carr | a9408d4 | 2016-06-03 13:28:48 -0700 | [diff] [blame] | 393 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 394 | transaction->setGeometryAppliesWithResize(ctrl); |
Robert Carr | a9408d4 | 2016-06-03 13:28:48 -0700 | [diff] [blame] | 395 | } |
| 396 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 397 | static void nativeSetSize(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 398 | jlong nativeObject, jint w, jint h) { |
| 399 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 400 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 401 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 402 | transaction->setSize(ctrl, w, h); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 403 | } |
| 404 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 405 | static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 406 | jlong nativeObject, jint flags, jint mask) { |
| 407 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 408 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 409 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 410 | transaction->setFlags(ctrl, flags, mask); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 411 | } |
| 412 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 413 | static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 414 | jlong nativeObject, jobject regionObj) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 415 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 416 | SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj); |
| 417 | if (!region) { |
| 418 | doThrowIAE(env); |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | const SkIRect& b(region->getBounds()); |
| 423 | Region reg(Rect(b.fLeft, b.fTop, b.fRight, b.fBottom)); |
| 424 | if (region->isComplex()) { |
| 425 | SkRegion::Iterator it(*region); |
| 426 | while (!it.done()) { |
| 427 | const SkIRect& r(it.rect()); |
| 428 | reg.addRectUnchecked(r.fLeft, r.fTop, r.fRight, r.fBottom); |
| 429 | it.next(); |
| 430 | } |
| 431 | } |
| 432 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 433 | { |
| 434 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 435 | transaction->setTransparentRegionHint(ctrl, reg); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 436 | } |
| 437 | } |
| 438 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 439 | static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 440 | jlong nativeObject, jfloat alpha) { |
| 441 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 442 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 443 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 444 | transaction->setAlpha(ctrl, alpha); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 445 | } |
| 446 | |
Robert Carr | 788f574 | 2018-07-30 17:46:45 -0700 | [diff] [blame] | 447 | static void nativeSetInputWindowInfo(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 448 | jlong nativeObject, jobject inputWindow) { |
| 449 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 450 | |
Riddle Hsu | cd958bc | 2019-01-23 15:40:26 +0800 | [diff] [blame] | 451 | sp<NativeInputWindowHandle> handle = android_view_InputWindowHandle_getHandle( |
Robert Carr | 788f574 | 2018-07-30 17:46:45 -0700 | [diff] [blame] | 452 | env, inputWindow); |
| 453 | handle->updateInfo(); |
| 454 | |
| 455 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 456 | transaction->setInputWindowInfo(ctrl, *handle->getInfo()); |
| 457 | } |
| 458 | |
chaviw | 59f532e | 2018-12-26 15:34:59 -0800 | [diff] [blame] | 459 | static void nativeTransferTouchFocus(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 460 | jobject fromTokenObj, jobject toTokenObj) { |
| 461 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 462 | |
| 463 | sp<IBinder> fromToken(ibinderForJavaObject(env, fromTokenObj)); |
| 464 | sp<IBinder> toToken(ibinderForJavaObject(env, toTokenObj)); |
| 465 | transaction->transferTouchFocus(fromToken, toToken); |
| 466 | } |
| 467 | |
chaviw | 319cd078 | 2019-02-14 11:00:23 -0800 | [diff] [blame] | 468 | static void nativeSyncInputWindows(JNIEnv* env, jclass clazz, jlong transactionObj) { |
| 469 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 470 | transaction->syncInputWindows(); |
| 471 | } |
| 472 | |
Evan Rosky | 485df20 | 2018-12-06 14:11:12 -0800 | [diff] [blame] | 473 | static void nativeSetMetadata(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 474 | jlong nativeObject, jint id, jobject parcelObj) { |
| 475 | Parcel* parcel = parcelForJavaObject(env, parcelObj); |
| 476 | if (!parcel) { |
| 477 | jniThrowNullPointerException(env, "attribute data"); |
| 478 | return; |
| 479 | } |
| 480 | if (parcel->objectsCount()) { |
| 481 | jniThrowException(env, "java/lang/RuntimeException", |
| 482 | "Tried to marshall a Parcel that contained Binder objects."); |
| 483 | return; |
| 484 | } |
| 485 | |
| 486 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 487 | |
| 488 | std::vector<uint8_t> byteData(parcel->dataSize()); |
| 489 | memcpy(byteData.data(), parcel->data(), parcel->dataSize()); |
| 490 | |
| 491 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObject); |
| 492 | transaction->setMetadata(ctrl, id, std::move(byteData)); |
| 493 | } |
| 494 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 495 | static void nativeSetColor(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 496 | jlong nativeObject, jfloatArray fColor) { |
| 497 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
chaviw | 0dd03f5 | 2017-08-25 12:15:26 -0700 | [diff] [blame] | 498 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 499 | |
chaviw | 0dd03f5 | 2017-08-25 12:15:26 -0700 | [diff] [blame] | 500 | float* floatColors = env->GetFloatArrayElements(fColor, 0); |
| 501 | half3 color(floatColors[0], floatColors[1], floatColors[2]); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 502 | transaction->setColor(ctrl, color); |
chaviw | 0dd03f5 | 2017-08-25 12:15:26 -0700 | [diff] [blame] | 503 | } |
| 504 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 505 | static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 506 | jlong nativeObject, |
Robert Carr | 0edf18f | 2017-02-21 20:01:47 -0800 | [diff] [blame] | 507 | jfloat dsdx, jfloat dtdx, jfloat dtdy, jfloat dsdy) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 508 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 509 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 510 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 511 | transaction->setMatrix(ctrl, dsdx, dtdx, dtdy, dsdy); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 512 | } |
| 513 | |
Peiyong Lin | 52bb6b4 | 2018-10-01 11:40:50 -0700 | [diff] [blame] | 514 | static void nativeSetColorTransform(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 515 | jlong nativeObject, jfloatArray fMatrix, jfloatArray fTranslation) { |
| 516 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 517 | SurfaceControl* const surfaceControl = reinterpret_cast<SurfaceControl*>(nativeObject); |
| 518 | float* floatMatrix = env->GetFloatArrayElements(fMatrix, 0); |
| 519 | mat3 matrix(static_cast<float const*>(floatMatrix)); |
| 520 | float* floatTranslation = env->GetFloatArrayElements(fTranslation, 0); |
| 521 | vec3 translation(floatTranslation[0], floatTranslation[1], floatTranslation[2]); |
| 522 | transaction->setColorTransform(surfaceControl, matrix, translation); |
| 523 | } |
| 524 | |
Peiyong Lin | f4f0f64 | 2019-03-01 14:36:05 -0800 | [diff] [blame] | 525 | static void nativeSetColorSpaceAgnostic(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 526 | jlong nativeObject, jboolean agnostic) { |
| 527 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 528 | SurfaceControl* const surfaceControl = reinterpret_cast<SurfaceControl*>(nativeObject); |
| 529 | transaction->setColorSpaceAgnostic(surfaceControl, agnostic); |
| 530 | } |
| 531 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 532 | static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 533 | jlong nativeObject, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 534 | jint l, jint t, jint r, jint b) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 535 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 536 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 537 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 538 | Rect crop(l, t, r, b); |
Marissa Wall | cb32fdd | 2018-07-24 09:53:30 -0700 | [diff] [blame] | 539 | transaction->setCrop_legacy(ctrl, crop); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 540 | } |
| 541 | |
Lucas Dupin | ff9d6ab | 2018-10-16 18:05:50 -0700 | [diff] [blame] | 542 | static void nativeSetCornerRadius(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 543 | jlong nativeObject, jfloat cornerRadius) { |
| 544 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 545 | |
| 546 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 547 | transaction->setCornerRadius(ctrl, cornerRadius); |
| 548 | } |
| 549 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 550 | static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 551 | jlong nativeObject, jint layerStack) { |
| 552 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 553 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 554 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 555 | transaction->setLayerStack(ctrl, layerStack); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 556 | } |
| 557 | |
Dominik Laskowski | 3316a0a | 2019-01-25 02:56:41 -0800 | [diff] [blame] | 558 | static jlongArray nativeGetPhysicalDisplayIds(JNIEnv* env, jclass clazz) { |
| 559 | const auto displayIds = SurfaceComposerClient::getPhysicalDisplayIds(); |
| 560 | jlongArray array = env->NewLongArray(displayIds.size()); |
| 561 | if (array == nullptr) { |
| 562 | jniThrowException(env, "java/lang/OutOfMemoryError", nullptr); |
| 563 | return nullptr; |
| 564 | } |
| 565 | |
| 566 | if (displayIds.empty()) { |
| 567 | return array; |
| 568 | } |
| 569 | |
| 570 | jlong* values = env->GetLongArrayElements(array, 0); |
| 571 | for (size_t i = 0; i < displayIds.size(); ++i) { |
| 572 | values[i] = static_cast<jlong>(displayIds[i]); |
| 573 | } |
| 574 | |
| 575 | env->ReleaseLongArrayElements(array, values, 0); |
| 576 | return array; |
| 577 | } |
| 578 | |
| 579 | static jobject nativeGetPhysicalDisplayToken(JNIEnv* env, jclass clazz, jlong physicalDisplayId) { |
| 580 | sp<IBinder> token = SurfaceComposerClient::getPhysicalDisplayToken(physicalDisplayId); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 581 | return javaObjectForIBinder(env, token); |
| 582 | } |
| 583 | |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 584 | static jobject nativeGetDisplayedContentSamplingAttributes(JNIEnv* env, jclass clazz, |
| 585 | jobject tokenObj) { |
| 586 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 587 | |
| 588 | ui::PixelFormat format; |
| 589 | ui::Dataspace dataspace; |
| 590 | uint8_t componentMask; |
| 591 | status_t err = SurfaceComposerClient::getDisplayedContentSamplingAttributes( |
| 592 | token, &format, &dataspace, &componentMask); |
| 593 | if (err != OK) { |
| 594 | return nullptr; |
| 595 | } |
| 596 | return env->NewObject(gDisplayedContentSamplingAttributesClassInfo.clazz, |
| 597 | gDisplayedContentSamplingAttributesClassInfo.ctor, |
| 598 | format, dataspace, componentMask); |
| 599 | } |
| 600 | |
| 601 | static jboolean nativeSetDisplayedContentSamplingEnabled(JNIEnv* env, jclass clazz, |
| 602 | jobject tokenObj, jboolean enable, jint componentMask, jint maxFrames) { |
| 603 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
Kevin DuBois | 205a680 | 2019-01-07 17:04:46 -0800 | [diff] [blame] | 604 | status_t rc = SurfaceComposerClient::setDisplayContentSamplingEnabled( |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 605 | token, enable, componentMask, maxFrames); |
Kevin DuBois | 205a680 | 2019-01-07 17:04:46 -0800 | [diff] [blame] | 606 | return rc == OK; |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | static jobject nativeGetDisplayedContentSample(JNIEnv* env, jclass clazz, jobject tokenObj, |
| 610 | jlong maxFrames, jlong timestamp) { |
| 611 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 612 | |
| 613 | DisplayedFrameStats stats; |
| 614 | status_t err = SurfaceComposerClient::getDisplayedContentSample( |
| 615 | token, maxFrames, timestamp, &stats); |
| 616 | if (err != OK) { |
| 617 | return nullptr; |
| 618 | } |
| 619 | |
| 620 | jlongArray histogramComponent0 = env->NewLongArray(stats.component_0_sample.size()); |
| 621 | jlongArray histogramComponent1 = env->NewLongArray(stats.component_1_sample.size()); |
| 622 | jlongArray histogramComponent2 = env->NewLongArray(stats.component_2_sample.size()); |
| 623 | jlongArray histogramComponent3 = env->NewLongArray(stats.component_3_sample.size()); |
| 624 | if ((histogramComponent0 == nullptr) || |
| 625 | (histogramComponent1 == nullptr) || |
| 626 | (histogramComponent2 == nullptr) || |
| 627 | (histogramComponent3 == nullptr)) { |
| 628 | return JNI_FALSE; |
| 629 | } |
| 630 | |
| 631 | env->SetLongArrayRegion(histogramComponent0, 0, |
| 632 | stats.component_0_sample.size(), |
| 633 | reinterpret_cast<jlong*>(stats.component_0_sample.data())); |
| 634 | env->SetLongArrayRegion(histogramComponent1, 0, |
| 635 | stats.component_1_sample.size(), |
| 636 | reinterpret_cast<jlong*>(stats.component_1_sample.data())); |
| 637 | env->SetLongArrayRegion(histogramComponent2, 0, |
| 638 | stats.component_2_sample.size(), |
| 639 | reinterpret_cast<jlong*>(stats.component_2_sample.data())); |
| 640 | env->SetLongArrayRegion(histogramComponent3, 0, |
| 641 | stats.component_3_sample.size(), |
| 642 | reinterpret_cast<jlong*>(stats.component_3_sample.data())); |
| 643 | return env->NewObject(gDisplayedContentSampleClassInfo.clazz, |
| 644 | gDisplayedContentSampleClassInfo.ctor, |
| 645 | stats.numFrames, |
| 646 | histogramComponent0, |
| 647 | histogramComponent1, |
| 648 | histogramComponent2, |
| 649 | histogramComponent3); |
| 650 | } |
| 651 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 652 | static jobject nativeCreateDisplay(JNIEnv* env, jclass clazz, jstring nameObj, |
| 653 | jboolean secure) { |
| 654 | ScopedUtfChars name(env, nameObj); |
| 655 | sp<IBinder> token(SurfaceComposerClient::createDisplay( |
| 656 | String8(name.c_str()), bool(secure))); |
| 657 | return javaObjectForIBinder(env, token); |
| 658 | } |
| 659 | |
Jesse Hall | 6a6bc21 | 2013-08-08 12:15:03 -0700 | [diff] [blame] | 660 | static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) { |
| 661 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 662 | if (token == NULL) return; |
| 663 | SurfaceComposerClient::destroyDisplay(token); |
| 664 | } |
| 665 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 666 | static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 667 | jlong transactionObj, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 668 | jobject tokenObj, jlong nativeSurfaceObject) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 669 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 670 | if (token == NULL) return; |
Mathias Agopian | ffddc9b | 2013-02-25 15:56:31 -0800 | [diff] [blame] | 671 | sp<IGraphicBufferProducer> bufferProducer; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 672 | sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject)); |
Mathias Agopian | ffddc9b | 2013-02-25 15:56:31 -0800 | [diff] [blame] | 673 | if (sur != NULL) { |
| 674 | bufferProducer = sur->getIGraphicBufferProducer(); |
| 675 | } |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 676 | |
| 677 | |
| 678 | status_t err = NO_ERROR; |
| 679 | { |
| 680 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 681 | err = transaction->setDisplaySurface(token, |
| 682 | bufferProducer); |
| 683 | } |
Pablo Ceballos | aff2f94 | 2016-07-29 14:49:55 -0700 | [diff] [blame] | 684 | if (err != NO_ERROR) { |
| 685 | doThrowIAE(env, "Illegal Surface, could not enable async mode. Was this" |
| 686 | " Surface created with singleBufferMode?"); |
| 687 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 691 | jlong transactionObj, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 692 | jobject tokenObj, jint layerStack) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 693 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 694 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 695 | if (token == NULL) return; |
| 696 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 697 | { |
| 698 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 699 | transaction->setDisplayLayerStack(token, layerStack); |
| 700 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 704 | jlong transactionObj, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 705 | jobject tokenObj, jint orientation, |
| 706 | jint layerStackRect_left, jint layerStackRect_top, jint layerStackRect_right, jint layerStackRect_bottom, |
| 707 | jint displayRect_left, jint displayRect_top, jint displayRect_right, jint displayRect_bottom) { |
| 708 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 709 | if (token == NULL) return; |
| 710 | Rect layerStackRect(layerStackRect_left, layerStackRect_top, layerStackRect_right, layerStackRect_bottom); |
| 711 | Rect displayRect(displayRect_left, displayRect_top, displayRect_right, displayRect_bottom); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 712 | |
| 713 | { |
| 714 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 715 | transaction->setDisplayProjection(token, orientation, layerStackRect, displayRect); |
| 716 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 717 | } |
| 718 | |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 719 | static void nativeSetDisplaySize(JNIEnv* env, jclass clazz, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 720 | jlong transactionObj, |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 721 | jobject tokenObj, jint width, jint height) { |
| 722 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 723 | if (token == NULL) return; |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 724 | |
| 725 | { |
| 726 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 727 | transaction->setDisplaySize(token, width, height); |
| 728 | } |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 729 | } |
| 730 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 731 | static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, |
| 732 | jobject tokenObj) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 733 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 734 | if (token == NULL) return NULL; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 735 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 736 | Vector<DisplayInfo> configs; |
| 737 | if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR || |
| 738 | configs.size() == 0) { |
| 739 | return NULL; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 740 | } |
| 741 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 742 | jobjectArray configArray = env->NewObjectArray(configs.size(), |
| 743 | gPhysicalDisplayInfoClassInfo.clazz, NULL); |
| 744 | |
| 745 | for (size_t c = 0; c < configs.size(); ++c) { |
| 746 | const DisplayInfo& info = configs[c]; |
| 747 | jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz, |
| 748 | gPhysicalDisplayInfoClassInfo.ctor); |
| 749 | env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w); |
| 750 | env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h); |
| 751 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps); |
| 752 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.density, info.density); |
| 753 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi); |
| 754 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi); |
| 755 | env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure); |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 756 | env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos, |
| 757 | info.appVsyncOffset); |
| 758 | env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos, |
| 759 | info.presentationDeadline); |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 760 | env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj); |
| 761 | env->DeleteLocalRef(infoObj); |
| 762 | } |
| 763 | |
| 764 | return configArray; |
| 765 | } |
| 766 | |
Ady Abraham | 6070ce1 | 2019-01-24 18:48:58 -0800 | [diff] [blame] | 767 | static jboolean nativeSetAllowedDisplayConfigs(JNIEnv* env, jclass clazz, |
| 768 | jobject tokenObj, jintArray configArray) { |
| 769 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 770 | if (token == nullptr) return JNI_FALSE; |
| 771 | |
| 772 | std::vector<int32_t> allowedConfigs; |
| 773 | jsize configArraySize = env->GetArrayLength(configArray); |
| 774 | allowedConfigs.reserve(configArraySize); |
| 775 | |
| 776 | jint* configArrayElements = env->GetIntArrayElements(configArray, 0); |
| 777 | for (int i = 0; i < configArraySize; i++) { |
| 778 | allowedConfigs.push_back(configArrayElements[i]); |
| 779 | } |
| 780 | env->ReleaseIntArrayElements(configArray, configArrayElements, 0); |
| 781 | |
| 782 | size_t result = SurfaceComposerClient::setAllowedDisplayConfigs(token, allowedConfigs); |
| 783 | return result == NO_ERROR ? JNI_TRUE : JNI_FALSE; |
| 784 | } |
| 785 | |
Ady Abraham | 42f9a2fb | 2019-02-26 14:13:39 -0800 | [diff] [blame] | 786 | static jintArray nativeGetAllowedDisplayConfigs(JNIEnv* env, jclass clazz, jobject tokenObj) { |
| 787 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 788 | if (token == nullptr) return JNI_FALSE; |
| 789 | |
| 790 | std::vector<int32_t> allowedConfigs; |
| 791 | size_t result = SurfaceComposerClient::getAllowedDisplayConfigs(token, &allowedConfigs); |
| 792 | if (result != NO_ERROR) { |
| 793 | return nullptr; |
| 794 | } |
| 795 | |
| 796 | jintArray allowedConfigsArray = env->NewIntArray(allowedConfigs.size()); |
| 797 | if (allowedConfigsArray == nullptr) { |
| 798 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 799 | return nullptr; |
| 800 | } |
| 801 | jint* allowedConfigsArrayValues = env->GetIntArrayElements(allowedConfigsArray, 0); |
| 802 | for (size_t i = 0; i < allowedConfigs.size(); i++) { |
| 803 | allowedConfigsArrayValues[i] = static_cast<jint>(allowedConfigs[i]); |
| 804 | } |
| 805 | env->ReleaseIntArrayElements(allowedConfigsArray, allowedConfigsArrayValues, 0); |
| 806 | return allowedConfigsArray; |
| 807 | } |
| 808 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 809 | static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { |
| 810 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 811 | if (token == NULL) return -1; |
| 812 | return static_cast<jint>(SurfaceComposerClient::getActiveConfig(token)); |
| 813 | } |
| 814 | |
| 815 | static jboolean nativeSetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj, jint id) { |
| 816 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 817 | if (token == NULL) return JNI_FALSE; |
| 818 | status_t err = SurfaceComposerClient::setActiveConfig(token, static_cast<int>(id)); |
| 819 | return err == NO_ERROR ? JNI_TRUE : JNI_FALSE; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 820 | } |
| 821 | |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 822 | static jintArray nativeGetDisplayColorModes(JNIEnv* env, jclass, jobject tokenObj) { |
| 823 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 824 | if (token == NULL) return NULL; |
Peiyong Lin | b88549e | 2018-03-28 12:03:45 -0700 | [diff] [blame] | 825 | Vector<ui::ColorMode> colorModes; |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 826 | if (SurfaceComposerClient::getDisplayColorModes(token, &colorModes) != NO_ERROR || |
| 827 | colorModes.isEmpty()) { |
| 828 | return NULL; |
| 829 | } |
| 830 | |
| 831 | jintArray colorModesArray = env->NewIntArray(colorModes.size()); |
| 832 | if (colorModesArray == NULL) { |
| 833 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 834 | return NULL; |
| 835 | } |
| 836 | jint* colorModesArrayValues = env->GetIntArrayElements(colorModesArray, 0); |
| 837 | for (size_t i = 0; i < colorModes.size(); i++) { |
| 838 | colorModesArrayValues[i] = static_cast<jint>(colorModes[i]); |
| 839 | } |
| 840 | env->ReleaseIntArrayElements(colorModesArray, colorModesArrayValues, 0); |
| 841 | return colorModesArray; |
| 842 | } |
| 843 | |
Daniel Solomon | 10e3b33 | 2019-01-20 21:09:11 -0800 | [diff] [blame] | 844 | static jobject nativeGetDisplayNativePrimaries(JNIEnv* env, jclass, jobject tokenObj) { |
| 845 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 846 | if (token == NULL) return NULL; |
| 847 | |
| 848 | ui::DisplayPrimaries primaries; |
| 849 | if (SurfaceComposerClient::getDisplayNativePrimaries(token, primaries) != NO_ERROR) { |
| 850 | return NULL; |
| 851 | } |
| 852 | |
| 853 | jobject jred = env->NewObject(gCieXyzClassInfo.clazz, gCieXyzClassInfo.ctor); |
| 854 | if (jred == NULL) { |
| 855 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 856 | return NULL; |
| 857 | } |
| 858 | |
| 859 | jobject jgreen = env->NewObject(gCieXyzClassInfo.clazz, gCieXyzClassInfo.ctor); |
| 860 | if (jgreen == NULL) { |
| 861 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 862 | return NULL; |
| 863 | } |
| 864 | |
| 865 | jobject jblue = env->NewObject(gCieXyzClassInfo.clazz, gCieXyzClassInfo.ctor); |
| 866 | if (jblue == NULL) { |
| 867 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 868 | return NULL; |
| 869 | } |
| 870 | |
| 871 | jobject jwhite = env->NewObject(gCieXyzClassInfo.clazz, gCieXyzClassInfo.ctor); |
| 872 | if (jwhite == NULL) { |
| 873 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 874 | return NULL; |
| 875 | } |
| 876 | |
| 877 | jobject jprimaries = env->NewObject(gDisplayPrimariesClassInfo.clazz, |
| 878 | gDisplayPrimariesClassInfo.ctor); |
| 879 | if (jprimaries == NULL) { |
| 880 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 881 | return NULL; |
| 882 | } |
| 883 | |
| 884 | env->SetFloatField(jred, gCieXyzClassInfo.X, primaries.red.X); |
| 885 | env->SetFloatField(jred, gCieXyzClassInfo.Y, primaries.red.Y); |
| 886 | env->SetFloatField(jred, gCieXyzClassInfo.Z, primaries.red.Z); |
| 887 | env->SetFloatField(jgreen, gCieXyzClassInfo.X, primaries.green.X); |
| 888 | env->SetFloatField(jgreen, gCieXyzClassInfo.Y, primaries.green.Y); |
| 889 | env->SetFloatField(jgreen, gCieXyzClassInfo.Z, primaries.green.Z); |
| 890 | env->SetFloatField(jblue, gCieXyzClassInfo.X, primaries.blue.X); |
| 891 | env->SetFloatField(jblue, gCieXyzClassInfo.Y, primaries.blue.Y); |
| 892 | env->SetFloatField(jblue, gCieXyzClassInfo.Z, primaries.blue.Z); |
| 893 | env->SetFloatField(jwhite, gCieXyzClassInfo.X, primaries.white.X); |
| 894 | env->SetFloatField(jwhite, gCieXyzClassInfo.Y, primaries.white.Y); |
| 895 | env->SetFloatField(jwhite, gCieXyzClassInfo.Z, primaries.white.Z); |
| 896 | env->SetObjectField(jprimaries, gDisplayPrimariesClassInfo.red, jred); |
| 897 | env->SetObjectField(jprimaries, gDisplayPrimariesClassInfo.green, jgreen); |
| 898 | env->SetObjectField(jprimaries, gDisplayPrimariesClassInfo.blue, jblue); |
| 899 | env->SetObjectField(jprimaries, gDisplayPrimariesClassInfo.white, jwhite); |
| 900 | |
| 901 | return jprimaries; |
| 902 | } |
| 903 | |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 904 | static jint nativeGetActiveColorMode(JNIEnv* env, jclass, jobject tokenObj) { |
| 905 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 906 | if (token == NULL) return -1; |
| 907 | return static_cast<jint>(SurfaceComposerClient::getActiveColorMode(token)); |
| 908 | } |
| 909 | |
Peiyong Lin | 5f4a568 | 2019-01-17 11:37:07 -0800 | [diff] [blame] | 910 | static jintArray nativeGetCompositionDataspaces(JNIEnv* env, jclass) { |
| 911 | ui::Dataspace defaultDataspace, wcgDataspace; |
| 912 | ui::PixelFormat defaultPixelFormat, wcgPixelFormat; |
| 913 | if (SurfaceComposerClient::getCompositionPreference(&defaultDataspace, |
| 914 | &defaultPixelFormat, |
| 915 | &wcgDataspace, |
| 916 | &wcgPixelFormat) != NO_ERROR) { |
| 917 | return nullptr; |
| 918 | } |
| 919 | jintArray array = env->NewIntArray(2); |
| 920 | if (array == nullptr) { |
| 921 | jniThrowException(env, "java/lang/OutOfMemoryError", nullptr); |
| 922 | return nullptr; |
| 923 | } |
| 924 | jint* arrayValues = env->GetIntArrayElements(array, 0); |
| 925 | arrayValues[0] = static_cast<jint>(defaultDataspace); |
| 926 | arrayValues[1] = static_cast<jint>(wcgDataspace); |
| 927 | env->ReleaseIntArrayElements(array, arrayValues, 0); |
| 928 | return array; |
| 929 | } |
| 930 | |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 931 | static jboolean nativeSetActiveColorMode(JNIEnv* env, jclass, |
| 932 | jobject tokenObj, jint colorMode) { |
| 933 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 934 | if (token == NULL) return JNI_FALSE; |
| 935 | status_t err = SurfaceComposerClient::setActiveColorMode(token, |
Peiyong Lin | b88549e | 2018-03-28 12:03:45 -0700 | [diff] [blame] | 936 | static_cast<ui::ColorMode>(colorMode)); |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 937 | return err == NO_ERROR ? JNI_TRUE : JNI_FALSE; |
| 938 | } |
| 939 | |
Prashant Malani | c55929a | 2014-05-25 01:59:21 -0700 | [diff] [blame] | 940 | static void nativeSetDisplayPowerMode(JNIEnv* env, jclass clazz, jobject tokenObj, jint mode) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 941 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 942 | if (token == NULL) return; |
| 943 | |
Tom Cherry | 8ed74bb | 2017-07-10 14:31:18 -0700 | [diff] [blame] | 944 | android::base::Timer t; |
Prashant Malani | c55929a | 2014-05-25 01:59:21 -0700 | [diff] [blame] | 945 | SurfaceComposerClient::setDisplayPowerMode(token, mode); |
Tom Cherry | 8ed74bb | 2017-07-10 14:31:18 -0700 | [diff] [blame] | 946 | if (t.duration() > 100ms) ALOGD("Excessive delay in setPowerMode()"); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 947 | } |
| 948 | |
Peiyong Lin | 0ddb7d4 | 2019-01-16 13:25:09 -0800 | [diff] [blame] | 949 | static jboolean nativeGetProtectedContentSupport(JNIEnv* env, jclass) { |
| 950 | return static_cast<jboolean>(SurfaceComposerClient::getProtectedContentSupport()); |
| 951 | } |
| 952 | |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 953 | static jboolean nativeClearContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 954 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 955 | status_t err = ctrl->clearLayerFrameStats(); |
| 956 | |
| 957 | if (err < 0 && err != NO_INIT) { |
| 958 | doThrowIAE(env); |
| 959 | } |
| 960 | |
| 961 | // The other end is not ready, just report we failed. |
| 962 | if (err == NO_INIT) { |
| 963 | return JNI_FALSE; |
| 964 | } |
| 965 | |
| 966 | return JNI_TRUE; |
| 967 | } |
| 968 | |
| 969 | static jboolean nativeGetContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject, |
| 970 | jobject outStats) { |
| 971 | FrameStats stats; |
| 972 | |
| 973 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 974 | status_t err = ctrl->getLayerFrameStats(&stats); |
| 975 | if (err < 0 && err != NO_INIT) { |
| 976 | doThrowIAE(env); |
| 977 | } |
| 978 | |
| 979 | // The other end is not ready, fine just return empty stats. |
| 980 | if (err == NO_INIT) { |
| 981 | return JNI_FALSE; |
| 982 | } |
| 983 | |
| 984 | jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano); |
| 985 | size_t frameCount = stats.desiredPresentTimesNano.size(); |
| 986 | |
| 987 | jlongArray postedTimesNanoDst = env->NewLongArray(frameCount); |
| 988 | if (postedTimesNanoDst == NULL) { |
| 989 | return JNI_FALSE; |
| 990 | } |
| 991 | |
| 992 | jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount); |
| 993 | if (presentedTimesNanoDst == NULL) { |
| 994 | return JNI_FALSE; |
| 995 | } |
| 996 | |
| 997 | jlongArray readyTimesNanoDst = env->NewLongArray(frameCount); |
| 998 | if (readyTimesNanoDst == NULL) { |
| 999 | return JNI_FALSE; |
| 1000 | } |
| 1001 | |
| 1002 | nsecs_t postedTimesNanoSrc[frameCount]; |
| 1003 | nsecs_t presentedTimesNanoSrc[frameCount]; |
| 1004 | nsecs_t readyTimesNanoSrc[frameCount]; |
| 1005 | |
| 1006 | for (size_t i = 0; i < frameCount; i++) { |
| 1007 | nsecs_t postedTimeNano = stats.desiredPresentTimesNano[i]; |
| 1008 | if (postedTimeNano == INT64_MAX) { |
| 1009 | postedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 1010 | } |
| 1011 | postedTimesNanoSrc[i] = postedTimeNano; |
| 1012 | |
| 1013 | nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i]; |
| 1014 | if (presentedTimeNano == INT64_MAX) { |
| 1015 | presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 1016 | } |
| 1017 | presentedTimesNanoSrc[i] = presentedTimeNano; |
| 1018 | |
| 1019 | nsecs_t readyTimeNano = stats.frameReadyTimesNano[i]; |
| 1020 | if (readyTimeNano == INT64_MAX) { |
| 1021 | readyTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 1022 | } |
| 1023 | readyTimesNanoSrc[i] = readyTimeNano; |
| 1024 | } |
| 1025 | |
| 1026 | env->SetLongArrayRegion(postedTimesNanoDst, 0, frameCount, postedTimesNanoSrc); |
| 1027 | env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc); |
| 1028 | env->SetLongArrayRegion(readyTimesNanoDst, 0, frameCount, readyTimesNanoSrc); |
| 1029 | |
| 1030 | env->CallVoidMethod(outStats, gWindowContentFrameStatsClassInfo.init, refreshPeriodNano, |
| 1031 | postedTimesNanoDst, presentedTimesNanoDst, readyTimesNanoDst); |
| 1032 | |
| 1033 | if (env->ExceptionCheck()) { |
| 1034 | return JNI_FALSE; |
| 1035 | } |
| 1036 | |
| 1037 | return JNI_TRUE; |
| 1038 | } |
| 1039 | |
| 1040 | static jboolean nativeClearAnimationFrameStats(JNIEnv* env, jclass clazz) { |
| 1041 | status_t err = SurfaceComposerClient::clearAnimationFrameStats(); |
| 1042 | |
| 1043 | if (err < 0 && err != NO_INIT) { |
| 1044 | doThrowIAE(env); |
| 1045 | } |
| 1046 | |
| 1047 | // The other end is not ready, just report we failed. |
| 1048 | if (err == NO_INIT) { |
| 1049 | return JNI_FALSE; |
| 1050 | } |
| 1051 | |
| 1052 | return JNI_TRUE; |
| 1053 | } |
| 1054 | |
| 1055 | static jboolean nativeGetAnimationFrameStats(JNIEnv* env, jclass clazz, jobject outStats) { |
| 1056 | FrameStats stats; |
| 1057 | |
| 1058 | status_t err = SurfaceComposerClient::getAnimationFrameStats(&stats); |
| 1059 | if (err < 0 && err != NO_INIT) { |
| 1060 | doThrowIAE(env); |
| 1061 | } |
| 1062 | |
| 1063 | // The other end is not ready, fine just return empty stats. |
| 1064 | if (err == NO_INIT) { |
| 1065 | return JNI_FALSE; |
| 1066 | } |
| 1067 | |
| 1068 | jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano); |
| 1069 | size_t frameCount = stats.desiredPresentTimesNano.size(); |
| 1070 | |
| 1071 | jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount); |
| 1072 | if (presentedTimesNanoDst == NULL) { |
| 1073 | return JNI_FALSE; |
| 1074 | } |
| 1075 | |
| 1076 | nsecs_t presentedTimesNanoSrc[frameCount]; |
| 1077 | |
| 1078 | for (size_t i = 0; i < frameCount; i++) { |
Allen Hair | ac5eda3 | 2014-04-24 11:50:37 -0700 | [diff] [blame] | 1079 | nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i]; |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1080 | if (presentedTimeNano == INT64_MAX) { |
| 1081 | presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 1082 | } |
| 1083 | presentedTimesNanoSrc[i] = presentedTimeNano; |
| 1084 | } |
| 1085 | |
| 1086 | env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc); |
| 1087 | |
| 1088 | env->CallVoidMethod(outStats, gWindowAnimationFrameStatsClassInfo.init, refreshPeriodNano, |
| 1089 | presentedTimesNanoDst); |
| 1090 | |
| 1091 | if (env->ExceptionCheck()) { |
| 1092 | return JNI_FALSE; |
| 1093 | } |
| 1094 | |
| 1095 | return JNI_TRUE; |
| 1096 | } |
| 1097 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1098 | static void nativeDeferTransactionUntil(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 1099 | jlong nativeObject, |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 1100 | jobject handleObject, jlong frameNumber) { |
| 1101 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 1102 | sp<IBinder> handle = ibinderForJavaObject(env, handleObject); |
| 1103 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1104 | { |
| 1105 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
Marissa Wall | cb32fdd | 2018-07-24 09:53:30 -0700 | [diff] [blame] | 1106 | transaction->deferTransactionUntil_legacy(ctrl, handle, frameNumber); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1107 | } |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 1108 | } |
| 1109 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1110 | static void nativeDeferTransactionUntilSurface(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 1111 | jlong nativeObject, |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1112 | jlong surfaceObject, jlong frameNumber) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1113 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 1114 | |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1115 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 1116 | sp<Surface> barrier = reinterpret_cast<Surface *>(surfaceObject); |
| 1117 | |
Marissa Wall | cb32fdd | 2018-07-24 09:53:30 -0700 | [diff] [blame] | 1118 | transaction->deferTransactionUntil_legacy(ctrl, barrier, frameNumber); |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1119 | } |
| 1120 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1121 | static void nativeReparentChildren(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 1122 | jlong nativeObject, |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1123 | jobject newParentObject) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1124 | |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1125 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 1126 | sp<IBinder> handle = ibinderForJavaObject(env, newParentObject); |
| 1127 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1128 | { |
| 1129 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 1130 | transaction->reparentChildren(ctrl, handle); |
| 1131 | } |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1132 | } |
| 1133 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1134 | static void nativeReparent(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 1135 | jlong nativeObject, |
Robert Carr | 10584fa | 2019-01-14 15:55:19 -0800 | [diff] [blame] | 1136 | jlong newParentObject) { |
chaviw | 6354238 | 2017-08-17 17:39:29 -0700 | [diff] [blame] | 1137 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | 10584fa | 2019-01-14 15:55:19 -0800 | [diff] [blame] | 1138 | auto newParent = reinterpret_cast<SurfaceControl *>(newParentObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1139 | |
| 1140 | { |
| 1141 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
Robert Carr | 10584fa | 2019-01-14 15:55:19 -0800 | [diff] [blame] | 1142 | transaction->reparent(ctrl, newParent != NULL ? newParent->getHandle() : NULL); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1143 | } |
chaviw | 6354238 | 2017-08-17 17:39:29 -0700 | [diff] [blame] | 1144 | } |
| 1145 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1146 | static void nativeSeverChildren(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 1147 | jlong nativeObject) { |
| 1148 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
| 1149 | |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1150 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1151 | transaction->detachChildren(ctrl); |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1152 | } |
| 1153 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1154 | static void nativeSetOverrideScalingMode(JNIEnv* env, jclass clazz, jlong transactionObj, |
| 1155 | jlong nativeObject, |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 1156 | jint scalingMode) { |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1157 | auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 1158 | |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1159 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 1160 | transaction->setOverrideScalingMode(ctrl, scalingMode); |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 1161 | } |
| 1162 | |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 1163 | static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 1164 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 1165 | return javaObjectForIBinder(env, ctrl->getHandle()); |
| 1166 | } |
| 1167 | |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 1168 | static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) { |
| 1169 | sp<IBinder> token(ibinderForJavaObject(env, tokenObject)); |
| 1170 | if (token == NULL) return NULL; |
| 1171 | |
| 1172 | HdrCapabilities capabilities; |
| 1173 | SurfaceComposerClient::getHdrCapabilities(token, &capabilities); |
| 1174 | |
| 1175 | const auto& types = capabilities.getSupportedHdrTypes(); |
Peiyong Lin | 3a0c6e1 | 2018-04-16 11:05:29 -0700 | [diff] [blame] | 1176 | std::vector<int32_t> intTypes; |
| 1177 | for (auto type : types) { |
| 1178 | intTypes.push_back(static_cast<int32_t>(type)); |
| 1179 | } |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 1180 | auto typesArray = env->NewIntArray(types.size()); |
Peiyong Lin | 3a0c6e1 | 2018-04-16 11:05:29 -0700 | [diff] [blame] | 1181 | env->SetIntArrayRegion(typesArray, 0, intTypes.size(), intTypes.data()); |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 1182 | |
Michael Wright | 9ff94c0 | 2016-03-30 18:05:40 -0700 | [diff] [blame] | 1183 | return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor, |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 1184 | typesArray, capabilities.getDesiredMaxLuminance(), |
| 1185 | capabilities.getDesiredMaxAverageLuminance(), capabilities.getDesiredMinLuminance()); |
| 1186 | } |
| 1187 | |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 1188 | static jlong nativeReadFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) { |
| 1189 | Parcel* parcel = parcelForJavaObject(env, parcelObj); |
| 1190 | if (parcel == NULL) { |
| 1191 | doThrowNPE(env); |
| 1192 | return 0; |
| 1193 | } |
| 1194 | sp<SurfaceControl> surface = SurfaceControl::readFromParcel(parcel); |
| 1195 | if (surface == nullptr) { |
| 1196 | return 0; |
| 1197 | } |
| 1198 | surface->incStrong((void *)nativeCreate); |
| 1199 | return reinterpret_cast<jlong>(surface.get()); |
| 1200 | } |
| 1201 | |
chaviw | beb7a0c | 2018-12-05 13:49:54 -0800 | [diff] [blame] | 1202 | static jlong nativeCopyFromSurfaceControl(JNIEnv* env, jclass clazz, jlong surfaceControlNativeObj) { |
| 1203 | sp<SurfaceControl> surface(reinterpret_cast<SurfaceControl *>(surfaceControlNativeObj)); |
| 1204 | if (surface == nullptr) { |
| 1205 | return 0; |
| 1206 | } |
Robert Carr | 5fea55b | 2018-12-10 13:05:52 -0800 | [diff] [blame] | 1207 | |
| 1208 | sp<SurfaceControl> newSurface = new SurfaceControl(surface); |
| 1209 | newSurface->incStrong((void *)nativeCreate); |
| 1210 | return reinterpret_cast<jlong>(newSurface.get()); |
chaviw | beb7a0c | 2018-12-05 13:49:54 -0800 | [diff] [blame] | 1211 | } |
| 1212 | |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 1213 | static void nativeWriteToParcel(JNIEnv* env, jclass clazz, |
| 1214 | jlong nativeObject, jobject parcelObj) { |
| 1215 | Parcel* parcel = parcelForJavaObject(env, parcelObj); |
| 1216 | if (parcel == NULL) { |
| 1217 | doThrowNPE(env); |
| 1218 | return; |
| 1219 | } |
| 1220 | SurfaceControl* const self = reinterpret_cast<SurfaceControl *>(nativeObject); |
chaviw | beb7a0c | 2018-12-05 13:49:54 -0800 | [diff] [blame] | 1221 | if (self != nullptr) { |
| 1222 | self->writeToParcel(parcel); |
| 1223 | } |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 1224 | } |
| 1225 | |
Dan Gittik | 832b497 | 2019-02-13 18:17:47 +0000 | [diff] [blame] | 1226 | static jboolean nativeGetDisplayBrightnessSupport(JNIEnv* env, jclass clazz, |
| 1227 | jobject displayTokenObject) { |
| 1228 | sp<IBinder> displayToken(ibinderForJavaObject(env, displayTokenObject)); |
| 1229 | if (displayToken == nullptr) { |
| 1230 | return JNI_FALSE; |
| 1231 | } |
| 1232 | return static_cast<jboolean>(SurfaceComposerClient::getDisplayBrightnessSupport(displayToken)); |
| 1233 | } |
| 1234 | |
| 1235 | static jboolean nativeSetDisplayBrightness(JNIEnv* env, jclass clazz, jobject displayTokenObject, |
| 1236 | jfloat brightness) { |
| 1237 | sp<IBinder> displayToken(ibinderForJavaObject(env, displayTokenObject)); |
| 1238 | if (displayToken == nullptr) { |
| 1239 | return JNI_FALSE; |
| 1240 | } |
| 1241 | status_t error = SurfaceComposerClient::setDisplayBrightness(displayToken, brightness); |
| 1242 | return error == OK ? JNI_TRUE : JNI_FALSE; |
| 1243 | } |
| 1244 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1245 | // ---------------------------------------------------------------------------- |
| 1246 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 1247 | static const JNINativeMethod sSurfaceControlMethods[] = { |
Evan Rosky | 485df20 | 2018-12-06 14:11:12 -0800 | [diff] [blame] | 1248 | {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIIIJLandroid/os/Parcel;)J", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1249 | (void*)nativeCreate }, |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 1250 | {"nativeReadFromParcel", "(Landroid/os/Parcel;)J", |
| 1251 | (void*)nativeReadFromParcel }, |
chaviw | beb7a0c | 2018-12-05 13:49:54 -0800 | [diff] [blame] | 1252 | {"nativeCopyFromSurfaceControl", "(J)J" , |
| 1253 | (void*)nativeCopyFromSurfaceControl }, |
Jorim Jaggi | 06975df | 2017-12-01 14:52:13 +0100 | [diff] [blame] | 1254 | {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V", |
| 1255 | (void*)nativeWriteToParcel }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1256 | {"nativeRelease", "(J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1257 | (void*)nativeRelease }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 1258 | {"nativeDestroy", "(J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1259 | (void*)nativeDestroy }, |
Chong Zhang | 47e36a3 | 2016-02-29 16:44:33 -0800 | [diff] [blame] | 1260 | {"nativeDisconnect", "(J)V", |
| 1261 | (void*)nativeDisconnect }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1262 | {"nativeCreateTransaction", "()J", |
| 1263 | (void*)nativeCreateTransaction }, |
| 1264 | {"nativeApplyTransaction", "(JZ)V", |
| 1265 | (void*)nativeApplyTransaction }, |
| 1266 | {"nativeGetNativeTransactionFinalizer", "()J", |
| 1267 | (void*)nativeGetNativeTransactionFinalizer }, |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 1268 | {"nativeMergeTransaction", "(JJ)V", |
| 1269 | (void*)nativeMergeTransaction }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1270 | {"nativeSetAnimationTransaction", "(J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1271 | (void*)nativeSetAnimationTransaction }, |
Jorim Jaggi | aa763cd | 2018-03-22 23:20:36 +0100 | [diff] [blame] | 1272 | {"nativeSetEarlyWakeup", "(J)V", |
| 1273 | (void*)nativeSetEarlyWakeup }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1274 | {"nativeSetLayer", "(JJI)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1275 | (void*)nativeSetLayer }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1276 | {"nativeSetRelativeLayer", "(JJLandroid/os/IBinder;I)V", |
Robert Carr | af422a8 | 2017-04-10 18:34:33 -0700 | [diff] [blame] | 1277 | (void*)nativeSetRelativeLayer }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1278 | {"nativeSetPosition", "(JJFF)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1279 | (void*)nativeSetPosition }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1280 | {"nativeSetGeometryAppliesWithResize", "(JJ)V", |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 1281 | (void*)nativeSetGeometryAppliesWithResize }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1282 | {"nativeSetSize", "(JJII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1283 | (void*)nativeSetSize }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1284 | {"nativeSetTransparentRegionHint", "(JJLandroid/graphics/Region;)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1285 | (void*)nativeSetTransparentRegionHint }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1286 | {"nativeSetAlpha", "(JJF)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1287 | (void*)nativeSetAlpha }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1288 | {"nativeSetColor", "(JJ[F)V", |
chaviw | 0dd03f5 | 2017-08-25 12:15:26 -0700 | [diff] [blame] | 1289 | (void*)nativeSetColor }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1290 | {"nativeSetMatrix", "(JJFFFF)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1291 | (void*)nativeSetMatrix }, |
Peiyong Lin | 52bb6b4 | 2018-10-01 11:40:50 -0700 | [diff] [blame] | 1292 | {"nativeSetColorTransform", "(JJ[F[F)V", |
| 1293 | (void*)nativeSetColorTransform }, |
Peiyong Lin | f4f0f64 | 2019-03-01 14:36:05 -0800 | [diff] [blame] | 1294 | {"nativeSetColorSpaceAgnostic", "(JJZ)V", |
| 1295 | (void*)nativeSetColorSpaceAgnostic }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1296 | {"nativeSetFlags", "(JJII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1297 | (void*)nativeSetFlags }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1298 | {"nativeSetWindowCrop", "(JJIIII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1299 | (void*)nativeSetWindowCrop }, |
Lucas Dupin | ff9d6ab | 2018-10-16 18:05:50 -0700 | [diff] [blame] | 1300 | {"nativeSetCornerRadius", "(JJF)V", |
| 1301 | (void*)nativeSetCornerRadius }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1302 | {"nativeSetLayerStack", "(JJI)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1303 | (void*)nativeSetLayerStack }, |
Dominik Laskowski | 3316a0a | 2019-01-25 02:56:41 -0800 | [diff] [blame] | 1304 | {"nativeGetPhysicalDisplayIds", "()[J", |
| 1305 | (void*)nativeGetPhysicalDisplayIds }, |
| 1306 | {"nativeGetPhysicalDisplayToken", "(J)Landroid/os/IBinder;", |
| 1307 | (void*)nativeGetPhysicalDisplayToken }, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1308 | {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;", |
| 1309 | (void*)nativeCreateDisplay }, |
Jesse Hall | 6a6bc21 | 2013-08-08 12:15:03 -0700 | [diff] [blame] | 1310 | {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V", |
| 1311 | (void*)nativeDestroyDisplay }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1312 | {"nativeSetDisplaySurface", "(JLandroid/os/IBinder;J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1313 | (void*)nativeSetDisplaySurface }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1314 | {"nativeSetDisplayLayerStack", "(JLandroid/os/IBinder;I)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1315 | (void*)nativeSetDisplayLayerStack }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1316 | {"nativeSetDisplayProjection", "(JLandroid/os/IBinder;IIIIIIIII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1317 | (void*)nativeSetDisplayProjection }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1318 | {"nativeSetDisplaySize", "(JLandroid/os/IBinder;II)V", |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 1319 | (void*)nativeSetDisplaySize }, |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 1320 | {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;", |
| 1321 | (void*)nativeGetDisplayConfigs }, |
| 1322 | {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I", |
| 1323 | (void*)nativeGetActiveConfig }, |
| 1324 | {"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z", |
| 1325 | (void*)nativeSetActiveConfig }, |
Ady Abraham | 6070ce1 | 2019-01-24 18:48:58 -0800 | [diff] [blame] | 1326 | {"nativeSetAllowedDisplayConfigs", "(Landroid/os/IBinder;[I)Z", |
| 1327 | (void*)nativeSetAllowedDisplayConfigs }, |
Ady Abraham | 42f9a2fb | 2019-02-26 14:13:39 -0800 | [diff] [blame] | 1328 | {"nativeGetAllowedDisplayConfigs", "(Landroid/os/IBinder;)[I", |
| 1329 | (void*)nativeGetAllowedDisplayConfigs }, |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 1330 | {"nativeGetDisplayColorModes", "(Landroid/os/IBinder;)[I", |
| 1331 | (void*)nativeGetDisplayColorModes}, |
Daniel Solomon | 10e3b33 | 2019-01-20 21:09:11 -0800 | [diff] [blame] | 1332 | {"nativeGetDisplayNativePrimaries", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayPrimaries;", |
| 1333 | (void*)nativeGetDisplayNativePrimaries }, |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 1334 | {"nativeGetActiveColorMode", "(Landroid/os/IBinder;)I", |
| 1335 | (void*)nativeGetActiveColorMode}, |
| 1336 | {"nativeSetActiveColorMode", "(Landroid/os/IBinder;I)Z", |
| 1337 | (void*)nativeSetActiveColorMode}, |
Peiyong Lin | 5f4a568 | 2019-01-17 11:37:07 -0800 | [diff] [blame] | 1338 | {"nativeGetCompositionDataspaces", "()[I", |
| 1339 | (void*)nativeGetCompositionDataspaces}, |
Michael Wright | 9ff94c0 | 2016-03-30 18:05:40 -0700 | [diff] [blame] | 1340 | {"nativeGetHdrCapabilities", "(Landroid/os/IBinder;)Landroid/view/Display$HdrCapabilities;", |
| 1341 | (void*)nativeGetHdrCapabilities }, |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1342 | {"nativeClearContentFrameStats", "(J)Z", |
| 1343 | (void*)nativeClearContentFrameStats }, |
| 1344 | {"nativeGetContentFrameStats", "(JLandroid/view/WindowContentFrameStats;)Z", |
| 1345 | (void*)nativeGetContentFrameStats }, |
| 1346 | {"nativeClearAnimationFrameStats", "()Z", |
| 1347 | (void*)nativeClearAnimationFrameStats }, |
| 1348 | {"nativeGetAnimationFrameStats", "(Landroid/view/WindowAnimationFrameStats;)Z", |
| 1349 | (void*)nativeGetAnimationFrameStats }, |
Prashant Malani | c55929a | 2014-05-25 01:59:21 -0700 | [diff] [blame] | 1350 | {"nativeSetDisplayPowerMode", "(Landroid/os/IBinder;I)V", |
| 1351 | (void*)nativeSetDisplayPowerMode }, |
Peiyong Lin | 0ddb7d4 | 2019-01-16 13:25:09 -0800 | [diff] [blame] | 1352 | {"nativeGetProtectedContentSupport", "()Z", |
| 1353 | (void*)nativeGetProtectedContentSupport }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1354 | {"nativeDeferTransactionUntil", "(JJLandroid/os/IBinder;J)V", |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 1355 | (void*)nativeDeferTransactionUntil }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1356 | {"nativeDeferTransactionUntilSurface", "(JJJJ)V", |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1357 | (void*)nativeDeferTransactionUntilSurface }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1358 | {"nativeReparentChildren", "(JJLandroid/os/IBinder;)V", |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1359 | (void*)nativeReparentChildren } , |
Robert Carr | 10584fa | 2019-01-14 15:55:19 -0800 | [diff] [blame] | 1360 | {"nativeReparent", "(JJJ)V", |
chaviw | 7643140 | 2017-09-18 16:50:05 -0700 | [diff] [blame] | 1361 | (void*)nativeReparent }, |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1362 | {"nativeSeverChildren", "(JJ)V", |
Robert Carr | d5c7dd6 | 2017-03-08 10:39:30 -0800 | [diff] [blame] | 1363 | (void*)nativeSeverChildren } , |
Robert Carr | e13b58e | 2017-08-31 14:50:44 -0700 | [diff] [blame] | 1364 | {"nativeSetOverrideScalingMode", "(JJI)V", |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 1365 | (void*)nativeSetOverrideScalingMode }, |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 1366 | {"nativeGetHandle", "(J)Landroid/os/IBinder;", |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 1367 | (void*)nativeGetHandle }, |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 1368 | {"nativeScreenshot", |
| 1369 | "(Landroid/os/IBinder;Landroid/graphics/Rect;IIZIZ)" |
| 1370 | "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", |
chaviw | 08520a0 | 2018-09-10 16:44:56 -0700 | [diff] [blame] | 1371 | (void*)nativeScreenshot }, |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 1372 | {"nativeCaptureLayers", |
Robert Carr | ffcdc51 | 2019-04-02 11:51:11 -0700 | [diff] [blame^] | 1373 | "(Landroid/os/IBinder;Landroid/graphics/Rect;F[Landroid/os/IBinder;)" |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 1374 | "Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;", |
Chavi Weingarten | d7ec64c | 2017-11-30 01:52:01 +0000 | [diff] [blame] | 1375 | (void*)nativeCaptureLayers }, |
Robert Carr | 788f574 | 2018-07-30 17:46:45 -0700 | [diff] [blame] | 1376 | {"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V", |
chaviw | 59f532e | 2018-12-26 15:34:59 -0800 | [diff] [blame] | 1377 | (void*)nativeSetInputWindowInfo }, |
| 1378 | {"nativeTransferTouchFocus", "(JLandroid/os/IBinder;Landroid/os/IBinder;)V", |
| 1379 | (void*)nativeTransferTouchFocus }, |
Evan Rosky | 485df20 | 2018-12-06 14:11:12 -0800 | [diff] [blame] | 1380 | {"nativeSetMetadata", "(JILandroid/os/Parcel;)V", |
| 1381 | (void*)nativeSetMetadata }, |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 1382 | {"nativeGetDisplayedContentSamplingAttributes", |
| 1383 | "(Landroid/os/IBinder;)Landroid/hardware/display/DisplayedContentSamplingAttributes;", |
| 1384 | (void*)nativeGetDisplayedContentSamplingAttributes }, |
| 1385 | {"nativeSetDisplayedContentSamplingEnabled", "(Landroid/os/IBinder;ZII)Z", |
| 1386 | (void*)nativeSetDisplayedContentSamplingEnabled }, |
| 1387 | {"nativeGetDisplayedContentSample", |
| 1388 | "(Landroid/os/IBinder;JJ)Landroid/hardware/display/DisplayedContentSample;", |
| 1389 | (void*)nativeGetDisplayedContentSample }, |
Robert Carr | 76907ee | 2019-01-11 13:38:19 -0800 | [diff] [blame] | 1390 | {"nativeSetGeometry", "(JJLandroid/graphics/Rect;Landroid/graphics/Rect;J)V", |
chaviw | 319cd078 | 2019-02-14 11:00:23 -0800 | [diff] [blame] | 1391 | (void*)nativeSetGeometry }, |
| 1392 | {"nativeSyncInputWindows", "(J)V", |
Dan Gittik | 832b497 | 2019-02-13 18:17:47 +0000 | [diff] [blame] | 1393 | (void*)nativeSyncInputWindows }, |
| 1394 | {"nativeGetDisplayBrightnessSupport", "(Landroid/os/IBinder;)Z", |
| 1395 | (void*)nativeGetDisplayBrightnessSupport }, |
| 1396 | {"nativeSetDisplayBrightness", "(Landroid/os/IBinder;F)Z", |
| 1397 | (void*)nativeSetDisplayBrightness }, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1398 | }; |
| 1399 | |
| 1400 | int register_android_view_SurfaceControl(JNIEnv* env) |
| 1401 | { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1402 | int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1403 | sSurfaceControlMethods, NELEM(sSurfaceControlMethods)); |
| 1404 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1405 | jclass clazz = FindClassOrDie(env, "android/view/SurfaceControl$PhysicalDisplayInfo"); |
| 1406 | gPhysicalDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, clazz); |
| 1407 | gPhysicalDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, |
| 1408 | gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V"); |
| 1409 | gPhysicalDisplayInfoClassInfo.width = GetFieldIDOrDie(env, clazz, "width", "I"); |
| 1410 | gPhysicalDisplayInfoClassInfo.height = GetFieldIDOrDie(env, clazz, "height", "I"); |
| 1411 | gPhysicalDisplayInfoClassInfo.refreshRate = GetFieldIDOrDie(env, clazz, "refreshRate", "F"); |
| 1412 | gPhysicalDisplayInfoClassInfo.density = GetFieldIDOrDie(env, clazz, "density", "F"); |
| 1413 | gPhysicalDisplayInfoClassInfo.xDpi = GetFieldIDOrDie(env, clazz, "xDpi", "F"); |
| 1414 | gPhysicalDisplayInfoClassInfo.yDpi = GetFieldIDOrDie(env, clazz, "yDpi", "F"); |
| 1415 | gPhysicalDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, clazz, "secure", "Z"); |
| 1416 | gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env, |
| 1417 | clazz, "appVsyncOffsetNanos", "J"); |
| 1418 | gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env, |
| 1419 | clazz, "presentationDeadlineNanos", "J"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1420 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1421 | jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect"); |
| 1422 | gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I"); |
| 1423 | gRectClassInfo.left = GetFieldIDOrDie(env, rectClazz, "left", "I"); |
| 1424 | gRectClassInfo.right = GetFieldIDOrDie(env, rectClazz, "right", "I"); |
| 1425 | gRectClassInfo.top = GetFieldIDOrDie(env, rectClazz, "top", "I"); |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 1426 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1427 | jclass frameStatsClazz = FindClassOrDie(env, "android/view/FrameStats"); |
| 1428 | jfieldID undefined_time_nano_field = GetStaticFieldIDOrDie(env, |
| 1429 | frameStatsClazz, "UNDEFINED_TIME_NANO", "J"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1430 | nsecs_t undefined_time_nano = env->GetStaticLongField(frameStatsClazz, undefined_time_nano_field); |
| 1431 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1432 | jclass contFrameStatsClazz = FindClassOrDie(env, "android/view/WindowContentFrameStats"); |
| 1433 | gWindowContentFrameStatsClassInfo.init = GetMethodIDOrDie(env, |
| 1434 | contFrameStatsClazz, "init", "(J[J[J[J)V"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1435 | gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano; |
| 1436 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1437 | jclass animFrameStatsClazz = FindClassOrDie(env, "android/view/WindowAnimationFrameStats"); |
| 1438 | gWindowAnimationFrameStatsClassInfo.init = GetMethodIDOrDie(env, |
| 1439 | animFrameStatsClazz, "init", "(J[J)V"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 1440 | gWindowAnimationFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano; |
| 1441 | |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 1442 | jclass hdrCapabilitiesClazz = FindClassOrDie(env, "android/view/Display$HdrCapabilities"); |
| 1443 | gHdrCapabilitiesClassInfo.clazz = MakeGlobalRefOrDie(env, hdrCapabilitiesClazz); |
| 1444 | gHdrCapabilitiesClassInfo.ctor = GetMethodIDOrDie(env, hdrCapabilitiesClazz, "<init>", |
| 1445 | "([IFFF)V"); |
| 1446 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 1447 | jclass graphicsBufferClazz = FindClassOrDie(env, "android/graphics/GraphicBuffer"); |
| 1448 | gGraphicBufferClassInfo.clazz = MakeGlobalRefOrDie(env, graphicsBufferClazz); |
| 1449 | gGraphicBufferClassInfo.builder = GetStaticMethodIDOrDie(env, graphicsBufferClazz, |
| 1450 | "createFromExisting", "(IIIIJ)Landroid/graphics/GraphicBuffer;"); |
| 1451 | |
Peiyong Lin | e3e5efd | 2019-03-21 20:59:47 +0000 | [diff] [blame] | 1452 | jclass screenshotGraphicsBufferClazz = FindClassOrDie(env, |
| 1453 | "android/view/SurfaceControl$ScreenshotGraphicBuffer"); |
| 1454 | gScreenshotGraphicBufferClassInfo.clazz = |
| 1455 | MakeGlobalRefOrDie(env, screenshotGraphicsBufferClazz); |
| 1456 | gScreenshotGraphicBufferClassInfo.builder = GetStaticMethodIDOrDie(env, |
| 1457 | screenshotGraphicsBufferClazz, |
| 1458 | "createFromNative", "(IIIIJI)Landroid/view/SurfaceControl$ScreenshotGraphicBuffer;"); |
| 1459 | |
Kevin DuBois | bf76b11b | 2018-09-04 09:14:15 -0700 | [diff] [blame] | 1460 | jclass displayedContentSampleClazz = FindClassOrDie(env, |
| 1461 | "android/hardware/display/DisplayedContentSample"); |
| 1462 | gDisplayedContentSampleClassInfo.clazz = MakeGlobalRefOrDie(env, displayedContentSampleClazz); |
| 1463 | gDisplayedContentSampleClassInfo.ctor = GetMethodIDOrDie(env, |
| 1464 | displayedContentSampleClazz, "<init>", "(J[J[J[J[J)V"); |
| 1465 | |
| 1466 | jclass displayedContentSamplingAttributesClazz = FindClassOrDie(env, |
| 1467 | "android/hardware/display/DisplayedContentSamplingAttributes"); |
| 1468 | gDisplayedContentSamplingAttributesClassInfo.clazz = MakeGlobalRefOrDie(env, |
| 1469 | displayedContentSamplingAttributesClazz); |
| 1470 | gDisplayedContentSamplingAttributesClassInfo.ctor = GetMethodIDOrDie(env, |
| 1471 | displayedContentSamplingAttributesClazz, "<init>", "(III)V"); |
Daniel Solomon | 10e3b33 | 2019-01-20 21:09:11 -0800 | [diff] [blame] | 1472 | |
| 1473 | jclass cieXyzClazz = FindClassOrDie(env, "android/view/SurfaceControl$CieXyz"); |
| 1474 | gCieXyzClassInfo.clazz = MakeGlobalRefOrDie(env, cieXyzClazz); |
| 1475 | gCieXyzClassInfo.ctor = GetMethodIDOrDie(env, gCieXyzClassInfo.clazz, "<init>", "()V"); |
| 1476 | gCieXyzClassInfo.X = GetFieldIDOrDie(env, cieXyzClazz, "X", "F"); |
| 1477 | gCieXyzClassInfo.Y = GetFieldIDOrDie(env, cieXyzClazz, "Y", "F"); |
| 1478 | gCieXyzClassInfo.Z = GetFieldIDOrDie(env, cieXyzClazz, "Z", "F"); |
| 1479 | |
| 1480 | jclass displayPrimariesClazz = FindClassOrDie(env, |
| 1481 | "android/view/SurfaceControl$DisplayPrimaries"); |
| 1482 | gDisplayPrimariesClassInfo.clazz = MakeGlobalRefOrDie(env, displayPrimariesClazz); |
| 1483 | gDisplayPrimariesClassInfo.ctor = GetMethodIDOrDie(env, gDisplayPrimariesClassInfo.clazz, |
| 1484 | "<init>", "()V"); |
| 1485 | gDisplayPrimariesClassInfo.red = GetFieldIDOrDie(env, displayPrimariesClazz, "red", |
| 1486 | "Landroid/view/SurfaceControl$CieXyz;"); |
| 1487 | gDisplayPrimariesClassInfo.green = GetFieldIDOrDie(env, displayPrimariesClazz, "green", |
| 1488 | "Landroid/view/SurfaceControl$CieXyz;"); |
| 1489 | gDisplayPrimariesClassInfo.blue = GetFieldIDOrDie(env, displayPrimariesClazz, "blue", |
| 1490 | "Landroid/view/SurfaceControl$CieXyz;"); |
| 1491 | gDisplayPrimariesClassInfo.white = GetFieldIDOrDie(env, displayPrimariesClazz, "white", |
| 1492 | "Landroid/view/SurfaceControl$CieXyz;"); |
| 1493 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 1494 | return err; |
| 1495 | } |
| 1496 | |
Dominik Laskowski | 3316a0a | 2019-01-25 02:56:41 -0800 | [diff] [blame] | 1497 | } // namespace android |