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" |
John Reck | f29ed28 | 2015-04-07 07:32:03 -0700 | [diff] [blame] | 22 | #include "android/graphics/Bitmap.h" |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 23 | #include "android/graphics/GraphicsJNI.h" |
| 24 | #include "android/graphics/Region.h" |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 25 | #include "core_jni_helpers.h" |
Ben Wagner | 60126ef | 2015-08-07 12:13:48 -0400 | [diff] [blame] | 26 | |
| 27 | #include <JNIHelp.h> |
| 28 | #include <ScopedUtfChars.h> |
Mathias Agopian | 0449a40 | 2013-03-01 23:01:51 -0800 | [diff] [blame] | 29 | #include <android_runtime/android_view_Surface.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 30 | #include <android_runtime/android_view_SurfaceSession.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 31 | #include <gui/Surface.h> |
| 32 | #include <gui/SurfaceComposerClient.h> |
Ben Wagner | 60126ef | 2015-08-07 12:13:48 -0400 | [diff] [blame] | 33 | #include <jni.h> |
| 34 | #include <memory> |
| 35 | #include <stdio.h> |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 36 | #include <system/graphics.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 37 | #include <ui/DisplayInfo.h> |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 38 | #include <ui/HdrCapabilities.h> |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 39 | #include <ui/FrameStats.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 40 | #include <ui/Rect.h> |
| 41 | #include <ui/Region.h> |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 42 | #include <utils/Log.h> |
| 43 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 44 | // ---------------------------------------------------------------------------- |
| 45 | |
| 46 | namespace android { |
| 47 | |
| 48 | static const char* const OutOfResourcesException = |
| 49 | "android/view/Surface$OutOfResourcesException"; |
| 50 | |
| 51 | static struct { |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 52 | jclass clazz; |
| 53 | jmethodID ctor; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 54 | jfieldID width; |
| 55 | jfieldID height; |
| 56 | jfieldID refreshRate; |
| 57 | jfieldID density; |
| 58 | jfieldID xDpi; |
| 59 | jfieldID yDpi; |
| 60 | jfieldID secure; |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 61 | jfieldID appVsyncOffsetNanos; |
| 62 | jfieldID presentationDeadlineNanos; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 63 | } gPhysicalDisplayInfoClassInfo; |
| 64 | |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 65 | static struct { |
| 66 | jfieldID bottom; |
| 67 | jfieldID left; |
| 68 | jfieldID right; |
| 69 | jfieldID top; |
| 70 | } gRectClassInfo; |
| 71 | |
Leon Scroggins | 46cb9bd | 2014-03-06 15:36:39 -0500 | [diff] [blame] | 72 | // Implements SkMallocPixelRef::ReleaseProc, to delete the screenshot on unref. |
| 73 | void DeleteScreenshot(void* addr, void* context) { |
| 74 | SkASSERT(addr == ((ScreenshotClient*) context)->getPixels()); |
| 75 | delete ((ScreenshotClient*) context); |
| 76 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 77 | |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 78 | static struct { |
| 79 | nsecs_t UNDEFINED_TIME_NANO; |
| 80 | jmethodID init; |
| 81 | } gWindowContentFrameStatsClassInfo; |
| 82 | |
| 83 | static struct { |
| 84 | nsecs_t UNDEFINED_TIME_NANO; |
| 85 | jmethodID init; |
| 86 | } gWindowAnimationFrameStatsClassInfo; |
| 87 | |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 88 | static struct { |
| 89 | jclass clazz; |
| 90 | jmethodID ctor; |
| 91 | } gHdrCapabilitiesClassInfo; |
| 92 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 93 | static struct { |
| 94 | jclass clazz; |
| 95 | jmethodID builder; |
| 96 | } gGraphicBufferClassInfo; |
| 97 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 98 | // ---------------------------------------------------------------------------- |
| 99 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 100 | static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj, |
Albert Chaulk | 3bf2e57 | 2016-11-22 13:59:19 -0500 | [diff] [blame] | 101 | jstring nameStr, jint w, jint h, jint format, jint flags, jlong parentObject, |
| 102 | jint windowType, jint ownerUid) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 103 | ScopedUtfChars name(env, nameStr); |
| 104 | sp<SurfaceComposerClient> client(android_view_SurfaceSession_getClient(env, sessionObj)); |
Robert Carr | 838120c | 2016-11-01 18:31:12 -0700 | [diff] [blame] | 105 | SurfaceControl *parent = reinterpret_cast<SurfaceControl*>(parentObject); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 106 | sp<SurfaceControl> surface = client->createSurface( |
Albert Chaulk | 3bf2e57 | 2016-11-22 13:59:19 -0500 | [diff] [blame] | 107 | String8(name.c_str()), w, h, format, flags, parent, windowType, ownerUid); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 108 | if (surface == NULL) { |
| 109 | jniThrowException(env, OutOfResourcesException, NULL); |
| 110 | return 0; |
| 111 | } |
Albert Chaulk | 3bf2e57 | 2016-11-22 13:59:19 -0500 | [diff] [blame] | 112 | |
Mathias Agopian | b1d90c8 | 2013-03-06 17:45:42 -0800 | [diff] [blame] | 113 | surface->incStrong((void *)nativeCreate); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 114 | return reinterpret_cast<jlong>(surface.get()); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 115 | } |
| 116 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 117 | static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 118 | sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); |
Mathias Agopian | b1d90c8 | 2013-03-06 17:45:42 -0800 | [diff] [blame] | 119 | ctrl->decStrong((void *)nativeCreate); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 120 | } |
| 121 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 122 | static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 123 | sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject)); |
| 124 | ctrl->clear(); |
Mathias Agopian | b1d90c8 | 2013-03-06 17:45:42 -0800 | [diff] [blame] | 125 | ctrl->decStrong((void *)nativeCreate); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 126 | } |
| 127 | |
Chong Zhang | 47e36a3 | 2016-02-29 16:44:33 -0800 | [diff] [blame] | 128 | static void nativeDisconnect(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 129 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 130 | if (ctrl != NULL) { |
| 131 | ctrl->disconnect(); |
| 132 | } |
| 133 | } |
| 134 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 135 | static Rect rectFromObj(JNIEnv* env, jobject rectObj) { |
| 136 | int left = env->GetIntField(rectObj, gRectClassInfo.left); |
| 137 | int top = env->GetIntField(rectObj, gRectClassInfo.top); |
| 138 | int right = env->GetIntField(rectObj, gRectClassInfo.right); |
| 139 | int bottom = env->GetIntField(rectObj, gRectClassInfo.bottom); |
| 140 | return Rect(left, top, right, bottom); |
| 141 | } |
| 142 | |
| 143 | static jobject nativeScreenshotToBuffer(JNIEnv* env, jclass clazz, |
| 144 | jobject displayTokenObj, jobject sourceCropObj, jint width, jint height, |
| 145 | jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform, |
| 146 | int rotation) { |
| 147 | sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj); |
| 148 | if (displayToken == NULL) { |
| 149 | return NULL; |
| 150 | } |
| 151 | Rect sourceCrop = rectFromObj(env, sourceCropObj); |
| 152 | if (allLayers) { |
Robert Carr | fb09bcf | 2017-01-26 11:52:35 -0800 | [diff] [blame] | 153 | minLayer = INT32_MIN; |
| 154 | maxLayer = INT32_MAX; |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 155 | } |
| 156 | sp<GraphicBuffer> buffer; |
| 157 | status_t res = ScreenshotClient::captureToBuffer(displayToken, |
| 158 | sourceCrop, width, height, minLayer, maxLayer, useIdentityTransform, |
| 159 | rotation, &buffer); |
| 160 | if (res != NO_ERROR) { |
| 161 | return NULL; |
| 162 | } |
| 163 | |
| 164 | return env->CallStaticObjectMethod(gGraphicBufferClassInfo.clazz, |
| 165 | gGraphicBufferClassInfo.builder, |
| 166 | buffer->getWidth(), |
| 167 | buffer->getHeight(), |
| 168 | buffer->getPixelFormat(), |
| 169 | buffer->getUsage(), |
| 170 | (void*)buffer.get()); |
| 171 | } |
| 172 | |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 173 | static jobject nativeScreenshotBitmap(JNIEnv* env, jclass clazz, |
| 174 | jobject displayTokenObj, jobject sourceCropObj, jint width, jint height, |
Riley Andrews | 1d13406 | 2014-08-21 15:47:07 -0700 | [diff] [blame] | 175 | jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform, |
| 176 | int rotation) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 177 | sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj); |
| 178 | if (displayToken == NULL) { |
| 179 | return NULL; |
| 180 | } |
| 181 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 182 | Rect sourceCrop = rectFromObj(env, sourceCropObj); |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 183 | |
Ben Wagner | 60126ef | 2015-08-07 12:13:48 -0400 | [diff] [blame] | 184 | std::unique_ptr<ScreenshotClient> screenshot(new ScreenshotClient()); |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 185 | status_t res; |
Riley Andrews | 1d13406 | 2014-08-21 15:47:07 -0700 | [diff] [blame] | 186 | if (allLayers) { |
Robert Carr | fb09bcf | 2017-01-26 11:52:35 -0800 | [diff] [blame] | 187 | minLayer = INT32_MIN; |
| 188 | maxLayer = INT32_MAX; |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 189 | } |
Riley Andrews | 1d13406 | 2014-08-21 15:47:07 -0700 | [diff] [blame] | 190 | |
| 191 | res = screenshot->update(displayToken, sourceCrop, width, height, |
| 192 | minLayer, maxLayer, useIdentityTransform, static_cast<uint32_t>(rotation)); |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 193 | if (res != NO_ERROR) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 194 | return NULL; |
| 195 | } |
| 196 | |
Leon Scroggins III | f35b989 | 2015-07-31 10:38:40 -0400 | [diff] [blame] | 197 | SkColorType colorType; |
| 198 | SkAlphaType alphaType; |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 199 | switch (screenshot->getFormat()) { |
| 200 | case PIXEL_FORMAT_RGBX_8888: { |
Leon Scroggins III | f35b989 | 2015-07-31 10:38:40 -0400 | [diff] [blame] | 201 | colorType = kRGBA_8888_SkColorType; |
| 202 | alphaType = kOpaque_SkAlphaType; |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 203 | break; |
| 204 | } |
| 205 | case PIXEL_FORMAT_RGBA_8888: { |
Leon Scroggins III | f35b989 | 2015-07-31 10:38:40 -0400 | [diff] [blame] | 206 | colorType = kRGBA_8888_SkColorType; |
| 207 | alphaType = kPremul_SkAlphaType; |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 208 | break; |
| 209 | } |
Romain Guy | 9505a65 | 2016-12-14 09:43:50 -0800 | [diff] [blame] | 210 | case PIXEL_FORMAT_RGBA_FP16: { |
| 211 | colorType = kRGBA_F16_SkColorType; |
| 212 | alphaType = kPremul_SkAlphaType; |
| 213 | break; |
| 214 | } |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 215 | case PIXEL_FORMAT_RGB_565: { |
Leon Scroggins III | f35b989 | 2015-07-31 10:38:40 -0400 | [diff] [blame] | 216 | colorType = kRGB_565_SkColorType; |
| 217 | alphaType = kOpaque_SkAlphaType; |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 218 | break; |
| 219 | } |
| 220 | default: { |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 221 | return NULL; |
| 222 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 223 | } |
Leon Scroggins III | f35b989 | 2015-07-31 10:38:40 -0400 | [diff] [blame] | 224 | SkImageInfo screenshotInfo = SkImageInfo::Make(screenshot->getWidth(), |
| 225 | screenshot->getHeight(), |
Romain Guy | 253f2c2 | 2016-09-28 17:34:42 -0700 | [diff] [blame] | 226 | colorType, |
| 227 | alphaType, |
| 228 | GraphicsJNI::defaultColorSpace()); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 229 | |
John Reck | f29ed28 | 2015-04-07 07:32:03 -0700 | [diff] [blame] | 230 | const size_t rowBytes = |
Derek Sollenberger | b644a3b | 2014-01-17 15:45:10 -0500 | [diff] [blame] | 231 | screenshot->getStride() * android::bytesPerPixel(screenshot->getFormat()); |
| 232 | |
Leon Scroggins III | f35b989 | 2015-07-31 10:38:40 -0400 | [diff] [blame] | 233 | if (!screenshotInfo.width() || !screenshotInfo.height()) { |
John Reck | f29ed28 | 2015-04-07 07:32:03 -0700 | [diff] [blame] | 234 | return NULL; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 235 | } |
| 236 | |
sergeyv | c1c5406 | 2016-10-19 18:47:26 -0700 | [diff] [blame] | 237 | auto bitmap = new Bitmap( |
John Reck | f29ed28 | 2015-04-07 07:32:03 -0700 | [diff] [blame] | 238 | (void*) screenshot->getPixels(), (void*) screenshot.get(), DeleteScreenshot, |
| 239 | screenshotInfo, rowBytes, nullptr); |
Ben Wagner | 60126ef | 2015-08-07 12:13:48 -0400 | [diff] [blame] | 240 | screenshot.release(); |
sergeyv | c1c5406 | 2016-10-19 18:47:26 -0700 | [diff] [blame] | 241 | bitmap->setImmutable(); |
| 242 | return bitmap::createBitmap(env, bitmap, |
| 243 | android::bitmap::kBitmapCreateFlag_Premultiplied, NULL); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 244 | } |
| 245 | |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 246 | static void nativeScreenshot(JNIEnv* env, jclass clazz, jobject displayTokenObj, |
| 247 | jobject surfaceObj, jobject sourceCropObj, jint width, jint height, |
| 248 | jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform) { |
Mathias Agopian | 0449a40 | 2013-03-01 23:01:51 -0800 | [diff] [blame] | 249 | sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj); |
| 250 | if (displayToken != NULL) { |
| 251 | sp<Surface> consumer = android_view_Surface_getSurface(env, surfaceObj); |
| 252 | if (consumer != NULL) { |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 253 | int left = env->GetIntField(sourceCropObj, gRectClassInfo.left); |
| 254 | int top = env->GetIntField(sourceCropObj, gRectClassInfo.top); |
| 255 | int right = env->GetIntField(sourceCropObj, gRectClassInfo.right); |
| 256 | int bottom = env->GetIntField(sourceCropObj, gRectClassInfo.bottom); |
| 257 | Rect sourceCrop(left, top, right, bottom); |
| 258 | |
Mathias Agopian | 0449a40 | 2013-03-01 23:01:51 -0800 | [diff] [blame] | 259 | if (allLayers) { |
Robert Carr | fb09bcf | 2017-01-26 11:52:35 -0800 | [diff] [blame] | 260 | minLayer = INT32_MIN; |
| 261 | maxLayer = INT32_MAX; |
Mathias Agopian | 0449a40 | 2013-03-01 23:01:51 -0800 | [diff] [blame] | 262 | } |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 263 | ScreenshotClient::capture(displayToken, |
| 264 | consumer->getIGraphicBufferProducer(), sourceCrop, |
Robert Carr | 7f6e986 | 2017-01-31 09:22:14 -0800 | [diff] [blame] | 265 | width, height, minLayer, maxLayer, |
Dan Stoza | 16ec12a | 2014-02-14 15:06:55 -0800 | [diff] [blame] | 266 | useIdentityTransform); |
Mathias Agopian | 0449a40 | 2013-03-01 23:01:51 -0800 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 271 | static void nativeOpenTransaction(JNIEnv* env, jclass clazz) { |
| 272 | SurfaceComposerClient::openGlobalTransaction(); |
| 273 | } |
| 274 | |
Robert Carr | e9953b1 | 2016-05-23 20:52:04 -0700 | [diff] [blame] | 275 | |
| 276 | static void nativeCloseTransaction(JNIEnv* env, jclass clazz, jboolean sync) { |
| 277 | SurfaceComposerClient::closeGlobalTransaction(sync); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz) { |
| 281 | SurfaceComposerClient::setAnimationTransaction(); |
| 282 | } |
| 283 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 284 | static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong nativeObject, jint zorder) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 285 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 286 | status_t err = ctrl->setLayer(zorder); |
| 287 | if (err < 0 && err != NO_INIT) { |
| 288 | doThrowIAE(env); |
| 289 | } |
| 290 | } |
| 291 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 292 | static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat x, jfloat y) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 293 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 294 | status_t err = ctrl->setPosition(x, y); |
| 295 | if (err < 0 && err != NO_INIT) { |
| 296 | doThrowIAE(env); |
| 297 | } |
| 298 | } |
| 299 | |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 300 | static void nativeSetGeometryAppliesWithResize(JNIEnv* env, jclass clazz, |
Robert Carr | a9408d4 | 2016-06-03 13:28:48 -0700 | [diff] [blame] | 301 | jlong nativeObject) { |
| 302 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 303 | status_t err = ctrl->setGeometryAppliesWithResize(); |
Robert Carr | a9408d4 | 2016-06-03 13:28:48 -0700 | [diff] [blame] | 304 | if (err < 0 && err != NO_INIT) { |
| 305 | doThrowIAE(env); |
| 306 | } |
| 307 | } |
| 308 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 309 | static void nativeSetSize(JNIEnv* env, jclass clazz, jlong nativeObject, jint w, jint h) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 310 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 311 | status_t err = ctrl->setSize(w, h); |
| 312 | if (err < 0 && err != NO_INIT) { |
| 313 | doThrowIAE(env); |
| 314 | } |
| 315 | } |
| 316 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 317 | static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong nativeObject, jint flags, jint mask) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 318 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 319 | status_t err = ctrl->setFlags(flags, mask); |
| 320 | if (err < 0 && err != NO_INIT) { |
| 321 | doThrowIAE(env); |
| 322 | } |
| 323 | } |
| 324 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 325 | static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong nativeObject, jobject regionObj) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 326 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 327 | SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj); |
| 328 | if (!region) { |
| 329 | doThrowIAE(env); |
| 330 | return; |
| 331 | } |
| 332 | |
| 333 | const SkIRect& b(region->getBounds()); |
| 334 | Region reg(Rect(b.fLeft, b.fTop, b.fRight, b.fBottom)); |
| 335 | if (region->isComplex()) { |
| 336 | SkRegion::Iterator it(*region); |
| 337 | while (!it.done()) { |
| 338 | const SkIRect& r(it.rect()); |
| 339 | reg.addRectUnchecked(r.fLeft, r.fTop, r.fRight, r.fBottom); |
| 340 | it.next(); |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | status_t err = ctrl->setTransparentRegionHint(reg); |
| 345 | if (err < 0 && err != NO_INIT) { |
| 346 | doThrowIAE(env); |
| 347 | } |
| 348 | } |
| 349 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 350 | static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat alpha) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 351 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 352 | status_t err = ctrl->setAlpha(alpha); |
| 353 | if (err < 0 && err != NO_INIT) { |
| 354 | doThrowIAE(env); |
| 355 | } |
| 356 | } |
| 357 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 358 | static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong nativeObject, |
Robert Carr | 0edf18f | 2017-02-21 20:01:47 -0800 | [diff] [blame] | 359 | jfloat dsdx, jfloat dtdx, jfloat dtdy, jfloat dsdy) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 360 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
Robert Carr | 0edf18f | 2017-02-21 20:01:47 -0800 | [diff] [blame] | 361 | status_t err = ctrl->setMatrix(dsdx, dtdx, dtdy, dsdy); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 362 | if (err < 0 && err != NO_INIT) { |
| 363 | doThrowIAE(env); |
| 364 | } |
| 365 | } |
| 366 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 367 | static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong nativeObject, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 368 | jint l, jint t, jint r, jint b) { |
| 369 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 370 | Rect crop(l, t, r, b); |
| 371 | status_t err = ctrl->setCrop(crop); |
| 372 | if (err < 0 && err != NO_INIT) { |
| 373 | doThrowIAE(env); |
| 374 | } |
| 375 | } |
| 376 | |
Pablo Ceballos | 27982e6 | 2016-03-09 10:50:45 -0800 | [diff] [blame] | 377 | static void nativeSetFinalCrop(JNIEnv* env, jclass clazz, jlong nativeObject, |
| 378 | jint l, jint t, jint r, jint b) { |
| 379 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 380 | Rect crop(l, t, r, b); |
| 381 | status_t err = ctrl->setFinalCrop(crop); |
| 382 | if (err < 0 && err != NO_INIT) { |
| 383 | doThrowIAE(env); |
| 384 | } |
| 385 | } |
| 386 | |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 387 | static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong nativeObject, jint layerStack) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 388 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 389 | status_t err = ctrl->setLayerStack(layerStack); |
| 390 | if (err < 0 && err != NO_INIT) { |
| 391 | doThrowIAE(env); |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | static jobject nativeGetBuiltInDisplay(JNIEnv* env, jclass clazz, jint id) { |
| 396 | sp<IBinder> token(SurfaceComposerClient::getBuiltInDisplay(id)); |
| 397 | return javaObjectForIBinder(env, token); |
| 398 | } |
| 399 | |
| 400 | static jobject nativeCreateDisplay(JNIEnv* env, jclass clazz, jstring nameObj, |
| 401 | jboolean secure) { |
| 402 | ScopedUtfChars name(env, nameObj); |
| 403 | sp<IBinder> token(SurfaceComposerClient::createDisplay( |
| 404 | String8(name.c_str()), bool(secure))); |
| 405 | return javaObjectForIBinder(env, token); |
| 406 | } |
| 407 | |
Jesse Hall | 6a6bc21 | 2013-08-08 12:15:03 -0700 | [diff] [blame] | 408 | static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) { |
| 409 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 410 | if (token == NULL) return; |
| 411 | SurfaceComposerClient::destroyDisplay(token); |
| 412 | } |
| 413 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 414 | static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 415 | jobject tokenObj, jlong nativeSurfaceObject) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 416 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 417 | if (token == NULL) return; |
Mathias Agopian | ffddc9b | 2013-02-25 15:56:31 -0800 | [diff] [blame] | 418 | sp<IGraphicBufferProducer> bufferProducer; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 419 | sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject)); |
Mathias Agopian | ffddc9b | 2013-02-25 15:56:31 -0800 | [diff] [blame] | 420 | if (sur != NULL) { |
| 421 | bufferProducer = sur->getIGraphicBufferProducer(); |
| 422 | } |
Pablo Ceballos | aff2f94 | 2016-07-29 14:49:55 -0700 | [diff] [blame] | 423 | status_t err = SurfaceComposerClient::setDisplaySurface(token, |
| 424 | bufferProducer); |
| 425 | if (err != NO_ERROR) { |
| 426 | doThrowIAE(env, "Illegal Surface, could not enable async mode. Was this" |
| 427 | " Surface created with singleBufferMode?"); |
| 428 | } |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz, |
| 432 | jobject tokenObj, jint layerStack) { |
| 433 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 434 | if (token == NULL) return; |
| 435 | |
| 436 | SurfaceComposerClient::setDisplayLayerStack(token, layerStack); |
| 437 | } |
| 438 | |
| 439 | static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz, |
| 440 | jobject tokenObj, jint orientation, |
| 441 | jint layerStackRect_left, jint layerStackRect_top, jint layerStackRect_right, jint layerStackRect_bottom, |
| 442 | jint displayRect_left, jint displayRect_top, jint displayRect_right, jint displayRect_bottom) { |
| 443 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 444 | if (token == NULL) return; |
| 445 | Rect layerStackRect(layerStackRect_left, layerStackRect_top, layerStackRect_right, layerStackRect_bottom); |
| 446 | Rect displayRect(displayRect_left, displayRect_top, displayRect_right, displayRect_bottom); |
| 447 | SurfaceComposerClient::setDisplayProjection(token, orientation, layerStackRect, displayRect); |
| 448 | } |
| 449 | |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 450 | static void nativeSetDisplaySize(JNIEnv* env, jclass clazz, |
| 451 | jobject tokenObj, jint width, jint height) { |
| 452 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 453 | if (token == NULL) return; |
| 454 | SurfaceComposerClient::setDisplaySize(token, width, height); |
| 455 | } |
| 456 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 457 | static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, |
| 458 | jobject tokenObj) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 459 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 460 | if (token == NULL) return NULL; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 461 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 462 | Vector<DisplayInfo> configs; |
| 463 | if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR || |
| 464 | configs.size() == 0) { |
| 465 | return NULL; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 466 | } |
| 467 | |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 468 | jobjectArray configArray = env->NewObjectArray(configs.size(), |
| 469 | gPhysicalDisplayInfoClassInfo.clazz, NULL); |
| 470 | |
| 471 | for (size_t c = 0; c < configs.size(); ++c) { |
| 472 | const DisplayInfo& info = configs[c]; |
| 473 | jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz, |
| 474 | gPhysicalDisplayInfoClassInfo.ctor); |
| 475 | env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w); |
| 476 | env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h); |
| 477 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps); |
| 478 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.density, info.density); |
| 479 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi); |
| 480 | env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi); |
| 481 | env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure); |
Andy McFadden | e8b1aeb | 2014-06-13 14:05:40 -0700 | [diff] [blame] | 482 | env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos, |
| 483 | info.appVsyncOffset); |
| 484 | env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos, |
| 485 | info.presentationDeadline); |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 486 | env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj); |
| 487 | env->DeleteLocalRef(infoObj); |
| 488 | } |
| 489 | |
| 490 | return configArray; |
| 491 | } |
| 492 | |
| 493 | static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { |
| 494 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 495 | if (token == NULL) return -1; |
| 496 | return static_cast<jint>(SurfaceComposerClient::getActiveConfig(token)); |
| 497 | } |
| 498 | |
| 499 | static jboolean nativeSetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj, jint id) { |
| 500 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 501 | if (token == NULL) return JNI_FALSE; |
| 502 | status_t err = SurfaceComposerClient::setActiveConfig(token, static_cast<int>(id)); |
| 503 | return err == NO_ERROR ? JNI_TRUE : JNI_FALSE; |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 504 | } |
| 505 | |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 506 | static jintArray nativeGetDisplayColorModes(JNIEnv* env, jclass, jobject tokenObj) { |
| 507 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 508 | if (token == NULL) return NULL; |
| 509 | Vector<android_color_mode_t> colorModes; |
| 510 | if (SurfaceComposerClient::getDisplayColorModes(token, &colorModes) != NO_ERROR || |
| 511 | colorModes.isEmpty()) { |
| 512 | return NULL; |
| 513 | } |
| 514 | |
| 515 | jintArray colorModesArray = env->NewIntArray(colorModes.size()); |
| 516 | if (colorModesArray == NULL) { |
| 517 | jniThrowException(env, "java/lang/OutOfMemoryError", NULL); |
| 518 | return NULL; |
| 519 | } |
| 520 | jint* colorModesArrayValues = env->GetIntArrayElements(colorModesArray, 0); |
| 521 | for (size_t i = 0; i < colorModes.size(); i++) { |
| 522 | colorModesArrayValues[i] = static_cast<jint>(colorModes[i]); |
| 523 | } |
| 524 | env->ReleaseIntArrayElements(colorModesArray, colorModesArrayValues, 0); |
| 525 | return colorModesArray; |
| 526 | } |
| 527 | |
| 528 | static jint nativeGetActiveColorMode(JNIEnv* env, jclass, jobject tokenObj) { |
| 529 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 530 | if (token == NULL) return -1; |
| 531 | return static_cast<jint>(SurfaceComposerClient::getActiveColorMode(token)); |
| 532 | } |
| 533 | |
| 534 | static jboolean nativeSetActiveColorMode(JNIEnv* env, jclass, |
| 535 | jobject tokenObj, jint colorMode) { |
| 536 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 537 | if (token == NULL) return JNI_FALSE; |
| 538 | status_t err = SurfaceComposerClient::setActiveColorMode(token, |
| 539 | static_cast<android_color_mode_t>(colorMode)); |
| 540 | return err == NO_ERROR ? JNI_TRUE : JNI_FALSE; |
| 541 | } |
| 542 | |
Prashant Malani | c55929a | 2014-05-25 01:59:21 -0700 | [diff] [blame] | 543 | static void nativeSetDisplayPowerMode(JNIEnv* env, jclass clazz, jobject tokenObj, jint mode) { |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 544 | sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); |
| 545 | if (token == NULL) return; |
| 546 | |
Prashant Malani | c55929a | 2014-05-25 01:59:21 -0700 | [diff] [blame] | 547 | ALOGD_IF_SLOW(100, "Excessive delay in setPowerMode()"); |
| 548 | SurfaceComposerClient::setDisplayPowerMode(token, mode); |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 549 | } |
| 550 | |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 551 | static jboolean nativeClearContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 552 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 553 | status_t err = ctrl->clearLayerFrameStats(); |
| 554 | |
| 555 | if (err < 0 && err != NO_INIT) { |
| 556 | doThrowIAE(env); |
| 557 | } |
| 558 | |
| 559 | // The other end is not ready, just report we failed. |
| 560 | if (err == NO_INIT) { |
| 561 | return JNI_FALSE; |
| 562 | } |
| 563 | |
| 564 | return JNI_TRUE; |
| 565 | } |
| 566 | |
| 567 | static jboolean nativeGetContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject, |
| 568 | jobject outStats) { |
| 569 | FrameStats stats; |
| 570 | |
| 571 | SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 572 | status_t err = ctrl->getLayerFrameStats(&stats); |
| 573 | if (err < 0 && err != NO_INIT) { |
| 574 | doThrowIAE(env); |
| 575 | } |
| 576 | |
| 577 | // The other end is not ready, fine just return empty stats. |
| 578 | if (err == NO_INIT) { |
| 579 | return JNI_FALSE; |
| 580 | } |
| 581 | |
| 582 | jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano); |
| 583 | size_t frameCount = stats.desiredPresentTimesNano.size(); |
| 584 | |
| 585 | jlongArray postedTimesNanoDst = env->NewLongArray(frameCount); |
| 586 | if (postedTimesNanoDst == NULL) { |
| 587 | return JNI_FALSE; |
| 588 | } |
| 589 | |
| 590 | jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount); |
| 591 | if (presentedTimesNanoDst == NULL) { |
| 592 | return JNI_FALSE; |
| 593 | } |
| 594 | |
| 595 | jlongArray readyTimesNanoDst = env->NewLongArray(frameCount); |
| 596 | if (readyTimesNanoDst == NULL) { |
| 597 | return JNI_FALSE; |
| 598 | } |
| 599 | |
| 600 | nsecs_t postedTimesNanoSrc[frameCount]; |
| 601 | nsecs_t presentedTimesNanoSrc[frameCount]; |
| 602 | nsecs_t readyTimesNanoSrc[frameCount]; |
| 603 | |
| 604 | for (size_t i = 0; i < frameCount; i++) { |
| 605 | nsecs_t postedTimeNano = stats.desiredPresentTimesNano[i]; |
| 606 | if (postedTimeNano == INT64_MAX) { |
| 607 | postedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 608 | } |
| 609 | postedTimesNanoSrc[i] = postedTimeNano; |
| 610 | |
| 611 | nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i]; |
| 612 | if (presentedTimeNano == INT64_MAX) { |
| 613 | presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 614 | } |
| 615 | presentedTimesNanoSrc[i] = presentedTimeNano; |
| 616 | |
| 617 | nsecs_t readyTimeNano = stats.frameReadyTimesNano[i]; |
| 618 | if (readyTimeNano == INT64_MAX) { |
| 619 | readyTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 620 | } |
| 621 | readyTimesNanoSrc[i] = readyTimeNano; |
| 622 | } |
| 623 | |
| 624 | env->SetLongArrayRegion(postedTimesNanoDst, 0, frameCount, postedTimesNanoSrc); |
| 625 | env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc); |
| 626 | env->SetLongArrayRegion(readyTimesNanoDst, 0, frameCount, readyTimesNanoSrc); |
| 627 | |
| 628 | env->CallVoidMethod(outStats, gWindowContentFrameStatsClassInfo.init, refreshPeriodNano, |
| 629 | postedTimesNanoDst, presentedTimesNanoDst, readyTimesNanoDst); |
| 630 | |
| 631 | if (env->ExceptionCheck()) { |
| 632 | return JNI_FALSE; |
| 633 | } |
| 634 | |
| 635 | return JNI_TRUE; |
| 636 | } |
| 637 | |
| 638 | static jboolean nativeClearAnimationFrameStats(JNIEnv* env, jclass clazz) { |
| 639 | status_t err = SurfaceComposerClient::clearAnimationFrameStats(); |
| 640 | |
| 641 | if (err < 0 && err != NO_INIT) { |
| 642 | doThrowIAE(env); |
| 643 | } |
| 644 | |
| 645 | // The other end is not ready, just report we failed. |
| 646 | if (err == NO_INIT) { |
| 647 | return JNI_FALSE; |
| 648 | } |
| 649 | |
| 650 | return JNI_TRUE; |
| 651 | } |
| 652 | |
| 653 | static jboolean nativeGetAnimationFrameStats(JNIEnv* env, jclass clazz, jobject outStats) { |
| 654 | FrameStats stats; |
| 655 | |
| 656 | status_t err = SurfaceComposerClient::getAnimationFrameStats(&stats); |
| 657 | if (err < 0 && err != NO_INIT) { |
| 658 | doThrowIAE(env); |
| 659 | } |
| 660 | |
| 661 | // The other end is not ready, fine just return empty stats. |
| 662 | if (err == NO_INIT) { |
| 663 | return JNI_FALSE; |
| 664 | } |
| 665 | |
| 666 | jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano); |
| 667 | size_t frameCount = stats.desiredPresentTimesNano.size(); |
| 668 | |
| 669 | jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount); |
| 670 | if (presentedTimesNanoDst == NULL) { |
| 671 | return JNI_FALSE; |
| 672 | } |
| 673 | |
| 674 | nsecs_t presentedTimesNanoSrc[frameCount]; |
| 675 | |
| 676 | for (size_t i = 0; i < frameCount; i++) { |
Allen Hair | ac5eda3 | 2014-04-24 11:50:37 -0700 | [diff] [blame] | 677 | nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i]; |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 678 | if (presentedTimeNano == INT64_MAX) { |
| 679 | presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO; |
| 680 | } |
| 681 | presentedTimesNanoSrc[i] = presentedTimeNano; |
| 682 | } |
| 683 | |
| 684 | env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc); |
| 685 | |
| 686 | env->CallVoidMethod(outStats, gWindowAnimationFrameStatsClassInfo.init, refreshPeriodNano, |
| 687 | presentedTimesNanoDst); |
| 688 | |
| 689 | if (env->ExceptionCheck()) { |
| 690 | return JNI_FALSE; |
| 691 | } |
| 692 | |
| 693 | return JNI_TRUE; |
| 694 | } |
| 695 | |
Jeff Tinker | 3896db1 | 2017-03-03 00:20:22 +0000 | [diff] [blame^] | 696 | |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 697 | static void nativeDeferTransactionUntil(JNIEnv* env, jclass clazz, jlong nativeObject, |
| 698 | jobject handleObject, jlong frameNumber) { |
| 699 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 700 | sp<IBinder> handle = ibinderForJavaObject(env, handleObject); |
| 701 | |
| 702 | ctrl->deferTransactionUntil(handle, frameNumber); |
| 703 | } |
| 704 | |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 705 | static void nativeSetOverrideScalingMode(JNIEnv* env, jclass clazz, jlong nativeObject, |
| 706 | jint scalingMode) { |
| 707 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 708 | |
| 709 | ctrl->setOverrideScalingMode(scalingMode); |
| 710 | } |
| 711 | |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 712 | static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 713 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 714 | |
| 715 | return javaObjectForIBinder(env, ctrl->getHandle()); |
| 716 | } |
| 717 | |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 718 | static jboolean nativeGetTransformToDisplayInverse(JNIEnv* env, jclass clazz, jlong nativeObject) { |
| 719 | bool out = false; |
| 720 | auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject); |
| 721 | status_t status = ctrl->getTransformToDisplayInverse(&out); |
| 722 | if (status != NO_ERROR) { |
| 723 | return false; |
| 724 | } |
| 725 | return out; |
| 726 | } |
| 727 | |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 728 | static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) { |
| 729 | sp<IBinder> token(ibinderForJavaObject(env, tokenObject)); |
| 730 | if (token == NULL) return NULL; |
| 731 | |
| 732 | HdrCapabilities capabilities; |
| 733 | SurfaceComposerClient::getHdrCapabilities(token, &capabilities); |
| 734 | |
| 735 | const auto& types = capabilities.getSupportedHdrTypes(); |
| 736 | auto typesArray = env->NewIntArray(types.size()); |
| 737 | env->SetIntArrayRegion(typesArray, 0, types.size(), types.data()); |
| 738 | |
Michael Wright | 9ff94c0 | 2016-03-30 18:05:40 -0700 | [diff] [blame] | 739 | return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor, |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 740 | typesArray, capabilities.getDesiredMaxLuminance(), |
| 741 | capabilities.getDesiredMaxAverageLuminance(), capabilities.getDesiredMinLuminance()); |
| 742 | } |
| 743 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 744 | // ---------------------------------------------------------------------------- |
| 745 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 746 | static const JNINativeMethod sSurfaceControlMethods[] = { |
Albert Chaulk | 3bf2e57 | 2016-11-22 13:59:19 -0500 | [diff] [blame] | 747 | {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIIIJII)J", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 748 | (void*)nativeCreate }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 749 | {"nativeRelease", "(J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 750 | (void*)nativeRelease }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 751 | {"nativeDestroy", "(J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 752 | (void*)nativeDestroy }, |
Chong Zhang | 47e36a3 | 2016-02-29 16:44:33 -0800 | [diff] [blame] | 753 | {"nativeDisconnect", "(J)V", |
| 754 | (void*)nativeDisconnect }, |
Riley Andrews | 1d13406 | 2014-08-21 15:47:07 -0700 | [diff] [blame] | 755 | {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/Bitmap;", |
Mathias Agopian | 0449a40 | 2013-03-01 23:01:51 -0800 | [diff] [blame] | 756 | (void*)nativeScreenshotBitmap }, |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 757 | {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/view/Surface;Landroid/graphics/Rect;IIIIZZ)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 758 | (void*)nativeScreenshot }, |
| 759 | {"nativeOpenTransaction", "()V", |
| 760 | (void*)nativeOpenTransaction }, |
Robert Carr | e9953b1 | 2016-05-23 20:52:04 -0700 | [diff] [blame] | 761 | {"nativeCloseTransaction", "(Z)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 762 | (void*)nativeCloseTransaction }, |
| 763 | {"nativeSetAnimationTransaction", "()V", |
| 764 | (void*)nativeSetAnimationTransaction }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 765 | {"nativeSetLayer", "(JI)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 766 | (void*)nativeSetLayer }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 767 | {"nativeSetPosition", "(JFF)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 768 | (void*)nativeSetPosition }, |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 769 | {"nativeSetGeometryAppliesWithResize", "(J)V", |
| 770 | (void*)nativeSetGeometryAppliesWithResize }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 771 | {"nativeSetSize", "(JII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 772 | (void*)nativeSetSize }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 773 | {"nativeSetTransparentRegionHint", "(JLandroid/graphics/Region;)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 774 | (void*)nativeSetTransparentRegionHint }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 775 | {"nativeSetAlpha", "(JF)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 776 | (void*)nativeSetAlpha }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 777 | {"nativeSetMatrix", "(JFFFF)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 778 | (void*)nativeSetMatrix }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 779 | {"nativeSetFlags", "(JII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 780 | (void*)nativeSetFlags }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 781 | {"nativeSetWindowCrop", "(JIIII)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 782 | (void*)nativeSetWindowCrop }, |
Pablo Ceballos | 27982e6 | 2016-03-09 10:50:45 -0800 | [diff] [blame] | 783 | {"nativeSetFinalCrop", "(JIIII)V", |
| 784 | (void*)nativeSetFinalCrop }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 785 | {"nativeSetLayerStack", "(JI)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 786 | (void*)nativeSetLayerStack }, |
| 787 | {"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;", |
| 788 | (void*)nativeGetBuiltInDisplay }, |
| 789 | {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;", |
| 790 | (void*)nativeCreateDisplay }, |
Jesse Hall | 6a6bc21 | 2013-08-08 12:15:03 -0700 | [diff] [blame] | 791 | {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V", |
| 792 | (void*)nativeDestroyDisplay }, |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 793 | {"nativeSetDisplaySurface", "(Landroid/os/IBinder;J)V", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 794 | (void*)nativeSetDisplaySurface }, |
| 795 | {"nativeSetDisplayLayerStack", "(Landroid/os/IBinder;I)V", |
| 796 | (void*)nativeSetDisplayLayerStack }, |
| 797 | {"nativeSetDisplayProjection", "(Landroid/os/IBinder;IIIIIIIII)V", |
| 798 | (void*)nativeSetDisplayProjection }, |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 799 | {"nativeSetDisplaySize", "(Landroid/os/IBinder;II)V", |
| 800 | (void*)nativeSetDisplaySize }, |
Dan Stoza | 0010105 | 2014-05-02 15:23:40 -0700 | [diff] [blame] | 801 | {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;", |
| 802 | (void*)nativeGetDisplayConfigs }, |
| 803 | {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I", |
| 804 | (void*)nativeGetActiveConfig }, |
| 805 | {"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z", |
| 806 | (void*)nativeSetActiveConfig }, |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 807 | {"nativeGetDisplayColorModes", "(Landroid/os/IBinder;)[I", |
| 808 | (void*)nativeGetDisplayColorModes}, |
| 809 | {"nativeGetActiveColorMode", "(Landroid/os/IBinder;)I", |
| 810 | (void*)nativeGetActiveColorMode}, |
| 811 | {"nativeSetActiveColorMode", "(Landroid/os/IBinder;I)Z", |
| 812 | (void*)nativeSetActiveColorMode}, |
Michael Wright | 9ff94c0 | 2016-03-30 18:05:40 -0700 | [diff] [blame] | 813 | {"nativeGetHdrCapabilities", "(Landroid/os/IBinder;)Landroid/view/Display$HdrCapabilities;", |
| 814 | (void*)nativeGetHdrCapabilities }, |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 815 | {"nativeClearContentFrameStats", "(J)Z", |
| 816 | (void*)nativeClearContentFrameStats }, |
| 817 | {"nativeGetContentFrameStats", "(JLandroid/view/WindowContentFrameStats;)Z", |
| 818 | (void*)nativeGetContentFrameStats }, |
| 819 | {"nativeClearAnimationFrameStats", "()Z", |
| 820 | (void*)nativeClearAnimationFrameStats }, |
| 821 | {"nativeGetAnimationFrameStats", "(Landroid/view/WindowAnimationFrameStats;)Z", |
| 822 | (void*)nativeGetAnimationFrameStats }, |
Prashant Malani | c55929a | 2014-05-25 01:59:21 -0700 | [diff] [blame] | 823 | {"nativeSetDisplayPowerMode", "(Landroid/os/IBinder;I)V", |
| 824 | (void*)nativeSetDisplayPowerMode }, |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 825 | {"nativeDeferTransactionUntil", "(JLandroid/os/IBinder;J)V", |
| 826 | (void*)nativeDeferTransactionUntil }, |
Robert Carr | 1ca6a33 | 2016-04-11 18:00:43 -0700 | [diff] [blame] | 827 | {"nativeSetOverrideScalingMode", "(JI)V", |
| 828 | (void*)nativeSetOverrideScalingMode }, |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 829 | {"nativeGetHandle", "(J)Landroid/os/IBinder;", |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 830 | (void*)nativeGetHandle }, |
| 831 | {"nativeGetTransformToDisplayInverse", "(J)Z", |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 832 | (void*)nativeGetTransformToDisplayInverse }, |
| 833 | {"nativeScreenshotToBuffer", |
| 834 | "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/GraphicBuffer;", |
| 835 | (void*)nativeScreenshotToBuffer }, |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 836 | }; |
| 837 | |
| 838 | int register_android_view_SurfaceControl(JNIEnv* env) |
| 839 | { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 840 | int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl", |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 841 | sSurfaceControlMethods, NELEM(sSurfaceControlMethods)); |
| 842 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 843 | jclass clazz = FindClassOrDie(env, "android/view/SurfaceControl$PhysicalDisplayInfo"); |
| 844 | gPhysicalDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, clazz); |
| 845 | gPhysicalDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env, |
| 846 | gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V"); |
| 847 | gPhysicalDisplayInfoClassInfo.width = GetFieldIDOrDie(env, clazz, "width", "I"); |
| 848 | gPhysicalDisplayInfoClassInfo.height = GetFieldIDOrDie(env, clazz, "height", "I"); |
| 849 | gPhysicalDisplayInfoClassInfo.refreshRate = GetFieldIDOrDie(env, clazz, "refreshRate", "F"); |
| 850 | gPhysicalDisplayInfoClassInfo.density = GetFieldIDOrDie(env, clazz, "density", "F"); |
| 851 | gPhysicalDisplayInfoClassInfo.xDpi = GetFieldIDOrDie(env, clazz, "xDpi", "F"); |
| 852 | gPhysicalDisplayInfoClassInfo.yDpi = GetFieldIDOrDie(env, clazz, "yDpi", "F"); |
| 853 | gPhysicalDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, clazz, "secure", "Z"); |
| 854 | gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env, |
| 855 | clazz, "appVsyncOffsetNanos", "J"); |
| 856 | gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env, |
| 857 | clazz, "presentationDeadlineNanos", "J"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 858 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 859 | jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect"); |
| 860 | gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I"); |
| 861 | gRectClassInfo.left = GetFieldIDOrDie(env, rectClazz, "left", "I"); |
| 862 | gRectClassInfo.right = GetFieldIDOrDie(env, rectClazz, "right", "I"); |
| 863 | gRectClassInfo.top = GetFieldIDOrDie(env, rectClazz, "top", "I"); |
Dan Stoza | 9890e341 | 2014-05-22 16:12:54 -0700 | [diff] [blame] | 864 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 865 | jclass frameStatsClazz = FindClassOrDie(env, "android/view/FrameStats"); |
| 866 | jfieldID undefined_time_nano_field = GetStaticFieldIDOrDie(env, |
| 867 | frameStatsClazz, "UNDEFINED_TIME_NANO", "J"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 868 | nsecs_t undefined_time_nano = env->GetStaticLongField(frameStatsClazz, undefined_time_nano_field); |
| 869 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 870 | jclass contFrameStatsClazz = FindClassOrDie(env, "android/view/WindowContentFrameStats"); |
| 871 | gWindowContentFrameStatsClassInfo.init = GetMethodIDOrDie(env, |
| 872 | contFrameStatsClazz, "init", "(J[J[J[J)V"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 873 | gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano; |
| 874 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 875 | jclass animFrameStatsClazz = FindClassOrDie(env, "android/view/WindowAnimationFrameStats"); |
| 876 | gWindowAnimationFrameStatsClassInfo.init = GetMethodIDOrDie(env, |
| 877 | animFrameStatsClazz, "init", "(J[J)V"); |
Svetoslav | 1376d60 | 2014-03-13 11:17:26 -0700 | [diff] [blame] | 878 | gWindowAnimationFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano; |
| 879 | |
Hangyu Kuang | 54ac219 | 2016-04-25 13:22:02 -0700 | [diff] [blame] | 880 | jclass hdrCapabilitiesClazz = FindClassOrDie(env, "android/view/Display$HdrCapabilities"); |
| 881 | gHdrCapabilitiesClassInfo.clazz = MakeGlobalRefOrDie(env, hdrCapabilitiesClazz); |
| 882 | gHdrCapabilitiesClassInfo.ctor = GetMethodIDOrDie(env, hdrCapabilitiesClazz, "<init>", |
| 883 | "([IFFF)V"); |
| 884 | |
Robert Carr | 6486d31 | 2017-01-09 19:48:29 -0800 | [diff] [blame] | 885 | jclass graphicsBufferClazz = FindClassOrDie(env, "android/graphics/GraphicBuffer"); |
| 886 | gGraphicBufferClassInfo.clazz = MakeGlobalRefOrDie(env, graphicsBufferClazz); |
| 887 | gGraphicBufferClassInfo.builder = GetStaticMethodIDOrDie(env, graphicsBufferClazz, |
| 888 | "createFromExisting", "(IIIIJ)Landroid/graphics/GraphicBuffer;"); |
| 889 | |
Mathias Agopian | 3866f0d | 2013-02-11 22:08:48 -0800 | [diff] [blame] | 890 | return err; |
| 891 | } |
| 892 | |
| 893 | }; |