blob: a9ed9dce590e9cf0747b59af22c197c5026f8ea3 [file] [log] [blame]
Mathias Agopian3866f0d2013-02-11 22:08:48 -08001/*
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"
18
Mathias Agopian3866f0d2013-02-11 22:08:48 -080019#include "android_os_Parcel.h"
20#include "android_util_Binder.h"
John Reckf29ed282015-04-07 07:32:03 -070021#include "android/graphics/Bitmap.h"
Mathias Agopian3866f0d2013-02-11 22:08:48 -080022#include "android/graphics/GraphicsJNI.h"
23#include "android/graphics/Region.h"
Andreas Gampeed6b9df2014-11-20 22:02:20 -080024#include "core_jni_helpers.h"
Ben Wagner60126ef2015-08-07 12:13:48 -040025
26#include <JNIHelp.h>
27#include <ScopedUtfChars.h>
Mathias Agopian0449a402013-03-01 23:01:51 -080028#include <android_runtime/android_view_Surface.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080029#include <android_runtime/android_view_SurfaceSession.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080030#include <gui/Surface.h>
31#include <gui/SurfaceComposerClient.h>
Ben Wagner60126ef2015-08-07 12:13:48 -040032#include <jni.h>
33#include <memory>
34#include <stdio.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080035#include <ui/DisplayInfo.h>
Hangyu Kuang54ac2192016-04-25 13:22:02 -070036#include <ui/HdrCapabilities.h>
Svetoslav1376d602014-03-13 11:17:26 -070037#include <ui/FrameStats.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080038#include <ui/Rect.h>
39#include <ui/Region.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080040#include <utils/Log.h>
41
Mathias Agopian3866f0d2013-02-11 22:08:48 -080042// ----------------------------------------------------------------------------
43
44namespace android {
45
46static const char* const OutOfResourcesException =
47 "android/view/Surface$OutOfResourcesException";
48
49static struct {
Dan Stoza00101052014-05-02 15:23:40 -070050 jclass clazz;
51 jmethodID ctor;
Mathias Agopian3866f0d2013-02-11 22:08:48 -080052 jfieldID width;
53 jfieldID height;
54 jfieldID refreshRate;
55 jfieldID density;
56 jfieldID xDpi;
57 jfieldID yDpi;
58 jfieldID secure;
Andy McFaddene8b1aeb2014-06-13 14:05:40 -070059 jfieldID appVsyncOffsetNanos;
60 jfieldID presentationDeadlineNanos;
Dan Stoza904f4852015-08-31 12:01:48 -070061 jfieldID colorTransform;
Mathias Agopian3866f0d2013-02-11 22:08:48 -080062} gPhysicalDisplayInfoClassInfo;
63
Dan Stoza9890e3412014-05-22 16:12:54 -070064static struct {
65 jfieldID bottom;
66 jfieldID left;
67 jfieldID right;
68 jfieldID top;
69} gRectClassInfo;
70
Leon Scroggins46cb9bd2014-03-06 15:36:39 -050071// Implements SkMallocPixelRef::ReleaseProc, to delete the screenshot on unref.
72void DeleteScreenshot(void* addr, void* context) {
73 SkASSERT(addr == ((ScreenshotClient*) context)->getPixels());
74 delete ((ScreenshotClient*) context);
75}
Mathias Agopian3866f0d2013-02-11 22:08:48 -080076
Svetoslav1376d602014-03-13 11:17:26 -070077static struct {
78 nsecs_t UNDEFINED_TIME_NANO;
79 jmethodID init;
80} gWindowContentFrameStatsClassInfo;
81
82static struct {
83 nsecs_t UNDEFINED_TIME_NANO;
84 jmethodID init;
85} gWindowAnimationFrameStatsClassInfo;
86
Hangyu Kuang54ac2192016-04-25 13:22:02 -070087static struct {
88 jclass clazz;
89 jmethodID ctor;
90} gHdrCapabilitiesClassInfo;
91
Mathias Agopian3866f0d2013-02-11 22:08:48 -080092// ----------------------------------------------------------------------------
93
Ashok Bhat36bef0b2014-01-20 20:08:01 +000094static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,
Mathias Agopian3866f0d2013-02-11 22:08:48 -080095 jstring nameStr, jint w, jint h, jint format, jint flags) {
96 ScopedUtfChars name(env, nameStr);
97 sp<SurfaceComposerClient> client(android_view_SurfaceSession_getClient(env, sessionObj));
98 sp<SurfaceControl> surface = client->createSurface(
99 String8(name.c_str()), w, h, format, flags);
100 if (surface == NULL) {
101 jniThrowException(env, OutOfResourcesException, NULL);
102 return 0;
103 }
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800104 surface->incStrong((void *)nativeCreate);
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000105 return reinterpret_cast<jlong>(surface.get());
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800106}
107
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000108static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800109 sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800110 ctrl->decStrong((void *)nativeCreate);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800111}
112
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000113static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800114 sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
115 ctrl->clear();
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800116 ctrl->decStrong((void *)nativeCreate);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800117}
118
Chong Zhang47e36a32016-02-29 16:44:33 -0800119static void nativeDisconnect(JNIEnv* env, jclass clazz, jlong nativeObject) {
120 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
121 if (ctrl != NULL) {
122 ctrl->disconnect();
123 }
124}
125
Dan Stoza9890e3412014-05-22 16:12:54 -0700126static jobject nativeScreenshotBitmap(JNIEnv* env, jclass clazz,
127 jobject displayTokenObj, jobject sourceCropObj, jint width, jint height,
Riley Andrews1d134062014-08-21 15:47:07 -0700128 jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform,
129 int rotation) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800130 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
131 if (displayToken == NULL) {
132 return NULL;
133 }
134
Dan Stoza9890e3412014-05-22 16:12:54 -0700135 int left = env->GetIntField(sourceCropObj, gRectClassInfo.left);
136 int top = env->GetIntField(sourceCropObj, gRectClassInfo.top);
137 int right = env->GetIntField(sourceCropObj, gRectClassInfo.right);
138 int bottom = env->GetIntField(sourceCropObj, gRectClassInfo.bottom);
139 Rect sourceCrop(left, top, right, bottom);
140
Ben Wagner60126ef2015-08-07 12:13:48 -0400141 std::unique_ptr<ScreenshotClient> screenshot(new ScreenshotClient());
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500142 status_t res;
Riley Andrews1d134062014-08-21 15:47:07 -0700143 if (allLayers) {
144 minLayer = 0;
Andreas Gampe0f0b4912014-11-12 08:03:48 -0800145 maxLayer = -1;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500146 }
Riley Andrews1d134062014-08-21 15:47:07 -0700147
148 res = screenshot->update(displayToken, sourceCrop, width, height,
149 minLayer, maxLayer, useIdentityTransform, static_cast<uint32_t>(rotation));
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500150 if (res != NO_ERROR) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800151 return NULL;
152 }
153
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400154 SkColorType colorType;
155 SkAlphaType alphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500156 switch (screenshot->getFormat()) {
157 case PIXEL_FORMAT_RGBX_8888: {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400158 colorType = kRGBA_8888_SkColorType;
159 alphaType = kOpaque_SkAlphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500160 break;
161 }
162 case PIXEL_FORMAT_RGBA_8888: {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400163 colorType = kRGBA_8888_SkColorType;
164 alphaType = kPremul_SkAlphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500165 break;
166 }
167 case PIXEL_FORMAT_RGB_565: {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400168 colorType = kRGB_565_SkColorType;
169 alphaType = kOpaque_SkAlphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500170 break;
171 }
172 default: {
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500173 return NULL;
174 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800175 }
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400176 SkImageInfo screenshotInfo = SkImageInfo::Make(screenshot->getWidth(),
177 screenshot->getHeight(),
178 colorType, alphaType);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800179
John Reckf29ed282015-04-07 07:32:03 -0700180 const size_t rowBytes =
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500181 screenshot->getStride() * android::bytesPerPixel(screenshot->getFormat());
182
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400183 if (!screenshotInfo.width() || !screenshotInfo.height()) {
John Reckf29ed282015-04-07 07:32:03 -0700184 return NULL;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800185 }
186
John Reckf29ed282015-04-07 07:32:03 -0700187 Bitmap* bitmap = new Bitmap(
188 (void*) screenshot->getPixels(), (void*) screenshot.get(), DeleteScreenshot,
189 screenshotInfo, rowBytes, nullptr);
Ben Wagner60126ef2015-08-07 12:13:48 -0400190 screenshot.release();
John Reckae2e8b42015-05-06 14:55:05 -0700191 bitmap->peekAtPixelRef()->setImmutable();
John Reckf29ed282015-04-07 07:32:03 -0700192
Chris Craik1abf5d62013-08-16 12:47:03 -0700193 return GraphicsJNI::createBitmap(env, bitmap,
194 GraphicsJNI::kBitmapCreateFlag_Premultiplied, NULL);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800195}
196
Dan Stoza9890e3412014-05-22 16:12:54 -0700197static void nativeScreenshot(JNIEnv* env, jclass clazz, jobject displayTokenObj,
198 jobject surfaceObj, jobject sourceCropObj, jint width, jint height,
199 jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform) {
Mathias Agopian0449a402013-03-01 23:01:51 -0800200 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
201 if (displayToken != NULL) {
202 sp<Surface> consumer = android_view_Surface_getSurface(env, surfaceObj);
203 if (consumer != NULL) {
Dan Stoza9890e3412014-05-22 16:12:54 -0700204 int left = env->GetIntField(sourceCropObj, gRectClassInfo.left);
205 int top = env->GetIntField(sourceCropObj, gRectClassInfo.top);
206 int right = env->GetIntField(sourceCropObj, gRectClassInfo.right);
207 int bottom = env->GetIntField(sourceCropObj, gRectClassInfo.bottom);
208 Rect sourceCrop(left, top, right, bottom);
209
Mathias Agopian0449a402013-03-01 23:01:51 -0800210 if (allLayers) {
211 minLayer = 0;
212 maxLayer = -1;
213 }
Dan Stoza9890e3412014-05-22 16:12:54 -0700214 ScreenshotClient::capture(displayToken,
215 consumer->getIGraphicBufferProducer(), sourceCrop,
Dan Stoza16ec12a2014-02-14 15:06:55 -0800216 width, height, uint32_t(minLayer), uint32_t(maxLayer),
217 useIdentityTransform);
Mathias Agopian0449a402013-03-01 23:01:51 -0800218 }
219 }
220}
221
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800222static void nativeOpenTransaction(JNIEnv* env, jclass clazz) {
223 SurfaceComposerClient::openGlobalTransaction();
224}
225
Robert Carre9953b12016-05-23 20:52:04 -0700226
227static void nativeCloseTransaction(JNIEnv* env, jclass clazz, jboolean sync) {
228 SurfaceComposerClient::closeGlobalTransaction(sync);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800229}
230
231static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz) {
232 SurfaceComposerClient::setAnimationTransaction();
233}
234
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000235static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong nativeObject, jint zorder) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800236 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
237 status_t err = ctrl->setLayer(zorder);
238 if (err < 0 && err != NO_INIT) {
239 doThrowIAE(env);
240 }
241}
242
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000243static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat x, jfloat y) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800244 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
245 status_t err = ctrl->setPosition(x, y);
246 if (err < 0 && err != NO_INIT) {
247 doThrowIAE(env);
248 }
249}
250
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000251static void nativeSetSize(JNIEnv* env, jclass clazz, jlong nativeObject, jint w, jint h) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800252 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
253 status_t err = ctrl->setSize(w, h);
254 if (err < 0 && err != NO_INIT) {
255 doThrowIAE(env);
256 }
257}
258
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000259static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong nativeObject, jint flags, jint mask) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800260 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
261 status_t err = ctrl->setFlags(flags, mask);
262 if (err < 0 && err != NO_INIT) {
263 doThrowIAE(env);
264 }
265}
266
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000267static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong nativeObject, jobject regionObj) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800268 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
269 SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj);
270 if (!region) {
271 doThrowIAE(env);
272 return;
273 }
274
275 const SkIRect& b(region->getBounds());
276 Region reg(Rect(b.fLeft, b.fTop, b.fRight, b.fBottom));
277 if (region->isComplex()) {
278 SkRegion::Iterator it(*region);
279 while (!it.done()) {
280 const SkIRect& r(it.rect());
281 reg.addRectUnchecked(r.fLeft, r.fTop, r.fRight, r.fBottom);
282 it.next();
283 }
284 }
285
286 status_t err = ctrl->setTransparentRegionHint(reg);
287 if (err < 0 && err != NO_INIT) {
288 doThrowIAE(env);
289 }
290}
291
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000292static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat alpha) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800293 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
294 status_t err = ctrl->setAlpha(alpha);
295 if (err < 0 && err != NO_INIT) {
296 doThrowIAE(env);
297 }
298}
299
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000300static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong nativeObject,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800301 jfloat dsdx, jfloat dtdx, jfloat dsdy, jfloat dtdy) {
302 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
303 status_t err = ctrl->setMatrix(dsdx, dtdx, dsdy, dtdy);
304 if (err < 0 && err != NO_INIT) {
305 doThrowIAE(env);
306 }
307}
308
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000309static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong nativeObject,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800310 jint l, jint t, jint r, jint b) {
311 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
312 Rect crop(l, t, r, b);
313 status_t err = ctrl->setCrop(crop);
314 if (err < 0 && err != NO_INIT) {
315 doThrowIAE(env);
316 }
317}
318
Pablo Ceballos27982e62016-03-09 10:50:45 -0800319static void nativeSetFinalCrop(JNIEnv* env, jclass clazz, jlong nativeObject,
320 jint l, jint t, jint r, jint b) {
321 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
322 Rect crop(l, t, r, b);
323 status_t err = ctrl->setFinalCrop(crop);
324 if (err < 0 && err != NO_INIT) {
325 doThrowIAE(env);
326 }
327}
328
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000329static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong nativeObject, jint layerStack) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800330 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
331 status_t err = ctrl->setLayerStack(layerStack);
332 if (err < 0 && err != NO_INIT) {
333 doThrowIAE(env);
334 }
335}
336
337static jobject nativeGetBuiltInDisplay(JNIEnv* env, jclass clazz, jint id) {
338 sp<IBinder> token(SurfaceComposerClient::getBuiltInDisplay(id));
339 return javaObjectForIBinder(env, token);
340}
341
342static jobject nativeCreateDisplay(JNIEnv* env, jclass clazz, jstring nameObj,
343 jboolean secure) {
344 ScopedUtfChars name(env, nameObj);
345 sp<IBinder> token(SurfaceComposerClient::createDisplay(
346 String8(name.c_str()), bool(secure)));
347 return javaObjectForIBinder(env, token);
348}
349
Jesse Hall6a6bc212013-08-08 12:15:03 -0700350static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) {
351 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
352 if (token == NULL) return;
353 SurfaceComposerClient::destroyDisplay(token);
354}
355
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800356static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz,
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000357 jobject tokenObj, jlong nativeSurfaceObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800358 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
359 if (token == NULL) return;
Mathias Agopianffddc9b2013-02-25 15:56:31 -0800360 sp<IGraphicBufferProducer> bufferProducer;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800361 sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject));
Mathias Agopianffddc9b2013-02-25 15:56:31 -0800362 if (sur != NULL) {
363 bufferProducer = sur->getIGraphicBufferProducer();
364 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800365 SurfaceComposerClient::setDisplaySurface(token, bufferProducer);
366}
367
368static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz,
369 jobject tokenObj, jint layerStack) {
370 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
371 if (token == NULL) return;
372
373 SurfaceComposerClient::setDisplayLayerStack(token, layerStack);
374}
375
376static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz,
377 jobject tokenObj, jint orientation,
378 jint layerStackRect_left, jint layerStackRect_top, jint layerStackRect_right, jint layerStackRect_bottom,
379 jint displayRect_left, jint displayRect_top, jint displayRect_right, jint displayRect_bottom) {
380 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
381 if (token == NULL) return;
382 Rect layerStackRect(layerStackRect_left, layerStackRect_top, layerStackRect_right, layerStackRect_bottom);
383 Rect displayRect(displayRect_left, displayRect_top, displayRect_right, displayRect_bottom);
384 SurfaceComposerClient::setDisplayProjection(token, orientation, layerStackRect, displayRect);
385}
386
Michael Wright01e840f2014-06-26 16:03:25 -0700387static void nativeSetDisplaySize(JNIEnv* env, jclass clazz,
388 jobject tokenObj, jint width, jint height) {
389 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
390 if (token == NULL) return;
391 SurfaceComposerClient::setDisplaySize(token, width, height);
392}
393
Dan Stoza00101052014-05-02 15:23:40 -0700394static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz,
395 jobject tokenObj) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800396 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
Dan Stoza00101052014-05-02 15:23:40 -0700397 if (token == NULL) return NULL;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800398
Dan Stoza00101052014-05-02 15:23:40 -0700399 Vector<DisplayInfo> configs;
400 if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR ||
401 configs.size() == 0) {
402 return NULL;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800403 }
404
Dan Stoza00101052014-05-02 15:23:40 -0700405 jobjectArray configArray = env->NewObjectArray(configs.size(),
406 gPhysicalDisplayInfoClassInfo.clazz, NULL);
407
408 for (size_t c = 0; c < configs.size(); ++c) {
409 const DisplayInfo& info = configs[c];
410 jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz,
411 gPhysicalDisplayInfoClassInfo.ctor);
412 env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w);
413 env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h);
414 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps);
415 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.density, info.density);
416 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi);
417 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi);
418 env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure);
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700419 env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos,
420 info.appVsyncOffset);
421 env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos,
422 info.presentationDeadline);
Dan Stoza904f4852015-08-31 12:01:48 -0700423 env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.colorTransform,
424 info.colorTransform);
Dan Stoza00101052014-05-02 15:23:40 -0700425 env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj);
426 env->DeleteLocalRef(infoObj);
427 }
428
429 return configArray;
430}
431
432static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) {
433 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
434 if (token == NULL) return -1;
435 return static_cast<jint>(SurfaceComposerClient::getActiveConfig(token));
436}
437
438static jboolean nativeSetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj, jint id) {
439 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
440 if (token == NULL) return JNI_FALSE;
441 status_t err = SurfaceComposerClient::setActiveConfig(token, static_cast<int>(id));
442 return err == NO_ERROR ? JNI_TRUE : JNI_FALSE;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800443}
444
Prashant Malanic55929a2014-05-25 01:59:21 -0700445static void nativeSetDisplayPowerMode(JNIEnv* env, jclass clazz, jobject tokenObj, jint mode) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800446 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
447 if (token == NULL) return;
448
Prashant Malanic55929a2014-05-25 01:59:21 -0700449 ALOGD_IF_SLOW(100, "Excessive delay in setPowerMode()");
450 SurfaceComposerClient::setDisplayPowerMode(token, mode);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800451}
452
Svetoslav1376d602014-03-13 11:17:26 -0700453static jboolean nativeClearContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject) {
454 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
455 status_t err = ctrl->clearLayerFrameStats();
456
457 if (err < 0 && err != NO_INIT) {
458 doThrowIAE(env);
459 }
460
461 // The other end is not ready, just report we failed.
462 if (err == NO_INIT) {
463 return JNI_FALSE;
464 }
465
466 return JNI_TRUE;
467}
468
469static jboolean nativeGetContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject,
470 jobject outStats) {
471 FrameStats stats;
472
473 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
474 status_t err = ctrl->getLayerFrameStats(&stats);
475 if (err < 0 && err != NO_INIT) {
476 doThrowIAE(env);
477 }
478
479 // The other end is not ready, fine just return empty stats.
480 if (err == NO_INIT) {
481 return JNI_FALSE;
482 }
483
484 jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano);
485 size_t frameCount = stats.desiredPresentTimesNano.size();
486
487 jlongArray postedTimesNanoDst = env->NewLongArray(frameCount);
488 if (postedTimesNanoDst == NULL) {
489 return JNI_FALSE;
490 }
491
492 jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount);
493 if (presentedTimesNanoDst == NULL) {
494 return JNI_FALSE;
495 }
496
497 jlongArray readyTimesNanoDst = env->NewLongArray(frameCount);
498 if (readyTimesNanoDst == NULL) {
499 return JNI_FALSE;
500 }
501
502 nsecs_t postedTimesNanoSrc[frameCount];
503 nsecs_t presentedTimesNanoSrc[frameCount];
504 nsecs_t readyTimesNanoSrc[frameCount];
505
506 for (size_t i = 0; i < frameCount; i++) {
507 nsecs_t postedTimeNano = stats.desiredPresentTimesNano[i];
508 if (postedTimeNano == INT64_MAX) {
509 postedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
510 }
511 postedTimesNanoSrc[i] = postedTimeNano;
512
513 nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i];
514 if (presentedTimeNano == INT64_MAX) {
515 presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
516 }
517 presentedTimesNanoSrc[i] = presentedTimeNano;
518
519 nsecs_t readyTimeNano = stats.frameReadyTimesNano[i];
520 if (readyTimeNano == INT64_MAX) {
521 readyTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
522 }
523 readyTimesNanoSrc[i] = readyTimeNano;
524 }
525
526 env->SetLongArrayRegion(postedTimesNanoDst, 0, frameCount, postedTimesNanoSrc);
527 env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc);
528 env->SetLongArrayRegion(readyTimesNanoDst, 0, frameCount, readyTimesNanoSrc);
529
530 env->CallVoidMethod(outStats, gWindowContentFrameStatsClassInfo.init, refreshPeriodNano,
531 postedTimesNanoDst, presentedTimesNanoDst, readyTimesNanoDst);
532
533 if (env->ExceptionCheck()) {
534 return JNI_FALSE;
535 }
536
537 return JNI_TRUE;
538}
539
540static jboolean nativeClearAnimationFrameStats(JNIEnv* env, jclass clazz) {
541 status_t err = SurfaceComposerClient::clearAnimationFrameStats();
542
543 if (err < 0 && err != NO_INIT) {
544 doThrowIAE(env);
545 }
546
547 // The other end is not ready, just report we failed.
548 if (err == NO_INIT) {
549 return JNI_FALSE;
550 }
551
552 return JNI_TRUE;
553}
554
555static jboolean nativeGetAnimationFrameStats(JNIEnv* env, jclass clazz, jobject outStats) {
556 FrameStats stats;
557
558 status_t err = SurfaceComposerClient::getAnimationFrameStats(&stats);
559 if (err < 0 && err != NO_INIT) {
560 doThrowIAE(env);
561 }
562
563 // The other end is not ready, fine just return empty stats.
564 if (err == NO_INIT) {
565 return JNI_FALSE;
566 }
567
568 jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano);
569 size_t frameCount = stats.desiredPresentTimesNano.size();
570
571 jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount);
572 if (presentedTimesNanoDst == NULL) {
573 return JNI_FALSE;
574 }
575
576 nsecs_t presentedTimesNanoSrc[frameCount];
577
578 for (size_t i = 0; i < frameCount; i++) {
Allen Hairac5eda32014-04-24 11:50:37 -0700579 nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i];
Svetoslav1376d602014-03-13 11:17:26 -0700580 if (presentedTimeNano == INT64_MAX) {
581 presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
582 }
583 presentedTimesNanoSrc[i] = presentedTimeNano;
584 }
585
586 env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc);
587
588 env->CallVoidMethod(outStats, gWindowAnimationFrameStatsClassInfo.init, refreshPeriodNano,
589 presentedTimesNanoDst);
590
591 if (env->ExceptionCheck()) {
592 return JNI_FALSE;
593 }
594
595 return JNI_TRUE;
596}
597
Rob Carr64e516f2015-10-29 00:20:45 +0000598
599static void nativeDeferTransactionUntil(JNIEnv* env, jclass clazz, jlong nativeObject,
600 jobject handleObject, jlong frameNumber) {
601 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
602 sp<IBinder> handle = ibinderForJavaObject(env, handleObject);
603
604 ctrl->deferTransactionUntil(handle, frameNumber);
605}
606
Robert Carr1ca6a332016-04-11 18:00:43 -0700607static void nativeSetOverrideScalingMode(JNIEnv* env, jclass clazz, jlong nativeObject,
608 jint scalingMode) {
609 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
610
611 ctrl->setOverrideScalingMode(scalingMode);
612}
613
Rob Carr64e516f2015-10-29 00:20:45 +0000614static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
615 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
616
617 return javaObjectForIBinder(env, ctrl->getHandle());
618}
619
Hangyu Kuang54ac2192016-04-25 13:22:02 -0700620static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) {
621 sp<IBinder> token(ibinderForJavaObject(env, tokenObject));
622 if (token == NULL) return NULL;
623
624 HdrCapabilities capabilities;
625 SurfaceComposerClient::getHdrCapabilities(token, &capabilities);
626
627 const auto& types = capabilities.getSupportedHdrTypes();
628 auto typesArray = env->NewIntArray(types.size());
629 env->SetIntArrayRegion(typesArray, 0, types.size(), types.data());
630
Michael Wright9ff94c02016-03-30 18:05:40 -0700631 return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor,
Hangyu Kuang54ac2192016-04-25 13:22:02 -0700632 typesArray, capabilities.getDesiredMaxLuminance(),
633 capabilities.getDesiredMaxAverageLuminance(), capabilities.getDesiredMinLuminance());
634}
635
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800636// ----------------------------------------------------------------------------
637
Daniel Micay76f6a862015-09-19 17:31:01 -0400638static const JNINativeMethod sSurfaceControlMethods[] = {
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000639 {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIII)J",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800640 (void*)nativeCreate },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000641 {"nativeRelease", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800642 (void*)nativeRelease },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000643 {"nativeDestroy", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800644 (void*)nativeDestroy },
Chong Zhang47e36a32016-02-29 16:44:33 -0800645 {"nativeDisconnect", "(J)V",
646 (void*)nativeDisconnect },
Riley Andrews1d134062014-08-21 15:47:07 -0700647 {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/Bitmap;",
Mathias Agopian0449a402013-03-01 23:01:51 -0800648 (void*)nativeScreenshotBitmap },
Dan Stoza9890e3412014-05-22 16:12:54 -0700649 {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/view/Surface;Landroid/graphics/Rect;IIIIZZ)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800650 (void*)nativeScreenshot },
651 {"nativeOpenTransaction", "()V",
652 (void*)nativeOpenTransaction },
Robert Carre9953b12016-05-23 20:52:04 -0700653 {"nativeCloseTransaction", "(Z)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800654 (void*)nativeCloseTransaction },
655 {"nativeSetAnimationTransaction", "()V",
656 (void*)nativeSetAnimationTransaction },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000657 {"nativeSetLayer", "(JI)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800658 (void*)nativeSetLayer },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000659 {"nativeSetPosition", "(JFF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800660 (void*)nativeSetPosition },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000661 {"nativeSetSize", "(JII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800662 (void*)nativeSetSize },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000663 {"nativeSetTransparentRegionHint", "(JLandroid/graphics/Region;)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800664 (void*)nativeSetTransparentRegionHint },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000665 {"nativeSetAlpha", "(JF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800666 (void*)nativeSetAlpha },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000667 {"nativeSetMatrix", "(JFFFF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800668 (void*)nativeSetMatrix },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000669 {"nativeSetFlags", "(JII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800670 (void*)nativeSetFlags },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000671 {"nativeSetWindowCrop", "(JIIII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800672 (void*)nativeSetWindowCrop },
Pablo Ceballos27982e62016-03-09 10:50:45 -0800673 {"nativeSetFinalCrop", "(JIIII)V",
674 (void*)nativeSetFinalCrop },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000675 {"nativeSetLayerStack", "(JI)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800676 (void*)nativeSetLayerStack },
677 {"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;",
678 (void*)nativeGetBuiltInDisplay },
679 {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;",
680 (void*)nativeCreateDisplay },
Jesse Hall6a6bc212013-08-08 12:15:03 -0700681 {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V",
682 (void*)nativeDestroyDisplay },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000683 {"nativeSetDisplaySurface", "(Landroid/os/IBinder;J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800684 (void*)nativeSetDisplaySurface },
685 {"nativeSetDisplayLayerStack", "(Landroid/os/IBinder;I)V",
686 (void*)nativeSetDisplayLayerStack },
687 {"nativeSetDisplayProjection", "(Landroid/os/IBinder;IIIIIIIII)V",
688 (void*)nativeSetDisplayProjection },
Michael Wright01e840f2014-06-26 16:03:25 -0700689 {"nativeSetDisplaySize", "(Landroid/os/IBinder;II)V",
690 (void*)nativeSetDisplaySize },
Dan Stoza00101052014-05-02 15:23:40 -0700691 {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;",
692 (void*)nativeGetDisplayConfigs },
693 {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I",
694 (void*)nativeGetActiveConfig },
695 {"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z",
696 (void*)nativeSetActiveConfig },
Michael Wright9ff94c02016-03-30 18:05:40 -0700697 {"nativeGetHdrCapabilities", "(Landroid/os/IBinder;)Landroid/view/Display$HdrCapabilities;",
698 (void*)nativeGetHdrCapabilities },
Svetoslav1376d602014-03-13 11:17:26 -0700699 {"nativeClearContentFrameStats", "(J)Z",
700 (void*)nativeClearContentFrameStats },
701 {"nativeGetContentFrameStats", "(JLandroid/view/WindowContentFrameStats;)Z",
702 (void*)nativeGetContentFrameStats },
703 {"nativeClearAnimationFrameStats", "()Z",
704 (void*)nativeClearAnimationFrameStats },
705 {"nativeGetAnimationFrameStats", "(Landroid/view/WindowAnimationFrameStats;)Z",
706 (void*)nativeGetAnimationFrameStats },
Prashant Malanic55929a2014-05-25 01:59:21 -0700707 {"nativeSetDisplayPowerMode", "(Landroid/os/IBinder;I)V",
708 (void*)nativeSetDisplayPowerMode },
Rob Carr64e516f2015-10-29 00:20:45 +0000709 {"nativeDeferTransactionUntil", "(JLandroid/os/IBinder;J)V",
710 (void*)nativeDeferTransactionUntil },
Robert Carr1ca6a332016-04-11 18:00:43 -0700711 {"nativeSetOverrideScalingMode", "(JI)V",
712 (void*)nativeSetOverrideScalingMode },
Rob Carr64e516f2015-10-29 00:20:45 +0000713 {"nativeGetHandle", "(J)Landroid/os/IBinder;",
714 (void*)nativeGetHandle }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800715};
716
717int register_android_view_SurfaceControl(JNIEnv* env)
718{
Andreas Gampeed6b9df2014-11-20 22:02:20 -0800719 int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800720 sSurfaceControlMethods, NELEM(sSurfaceControlMethods));
721
Andreas Gampeed6b9df2014-11-20 22:02:20 -0800722 jclass clazz = FindClassOrDie(env, "android/view/SurfaceControl$PhysicalDisplayInfo");
723 gPhysicalDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, clazz);
724 gPhysicalDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env,
725 gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V");
726 gPhysicalDisplayInfoClassInfo.width = GetFieldIDOrDie(env, clazz, "width", "I");
727 gPhysicalDisplayInfoClassInfo.height = GetFieldIDOrDie(env, clazz, "height", "I");
728 gPhysicalDisplayInfoClassInfo.refreshRate = GetFieldIDOrDie(env, clazz, "refreshRate", "F");
729 gPhysicalDisplayInfoClassInfo.density = GetFieldIDOrDie(env, clazz, "density", "F");
730 gPhysicalDisplayInfoClassInfo.xDpi = GetFieldIDOrDie(env, clazz, "xDpi", "F");
731 gPhysicalDisplayInfoClassInfo.yDpi = GetFieldIDOrDie(env, clazz, "yDpi", "F");
732 gPhysicalDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, clazz, "secure", "Z");
733 gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env,
734 clazz, "appVsyncOffsetNanos", "J");
735 gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env,
736 clazz, "presentationDeadlineNanos", "J");
Dan Stoza904f4852015-08-31 12:01:48 -0700737 gPhysicalDisplayInfoClassInfo.colorTransform = GetFieldIDOrDie(env, clazz,
738 "colorTransform", "I");
Svetoslav1376d602014-03-13 11:17:26 -0700739
Andreas Gampeed6b9df2014-11-20 22:02:20 -0800740 jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect");
741 gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I");
742 gRectClassInfo.left = GetFieldIDOrDie(env, rectClazz, "left", "I");
743 gRectClassInfo.right = GetFieldIDOrDie(env, rectClazz, "right", "I");
744 gRectClassInfo.top = GetFieldIDOrDie(env, rectClazz, "top", "I");
Dan Stoza9890e3412014-05-22 16:12:54 -0700745
Andreas Gampeed6b9df2014-11-20 22:02:20 -0800746 jclass frameStatsClazz = FindClassOrDie(env, "android/view/FrameStats");
747 jfieldID undefined_time_nano_field = GetStaticFieldIDOrDie(env,
748 frameStatsClazz, "UNDEFINED_TIME_NANO", "J");
Svetoslav1376d602014-03-13 11:17:26 -0700749 nsecs_t undefined_time_nano = env->GetStaticLongField(frameStatsClazz, undefined_time_nano_field);
750
Andreas Gampeed6b9df2014-11-20 22:02:20 -0800751 jclass contFrameStatsClazz = FindClassOrDie(env, "android/view/WindowContentFrameStats");
752 gWindowContentFrameStatsClassInfo.init = GetMethodIDOrDie(env,
753 contFrameStatsClazz, "init", "(J[J[J[J)V");
Svetoslav1376d602014-03-13 11:17:26 -0700754 gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano;
755
Andreas Gampeed6b9df2014-11-20 22:02:20 -0800756 jclass animFrameStatsClazz = FindClassOrDie(env, "android/view/WindowAnimationFrameStats");
757 gWindowAnimationFrameStatsClassInfo.init = GetMethodIDOrDie(env,
758 animFrameStatsClazz, "init", "(J[J)V");
Svetoslav1376d602014-03-13 11:17:26 -0700759 gWindowAnimationFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano;
760
Hangyu Kuang54ac2192016-04-25 13:22:02 -0700761 jclass hdrCapabilitiesClazz = FindClassOrDie(env, "android/view/Display$HdrCapabilities");
762 gHdrCapabilitiesClassInfo.clazz = MakeGlobalRefOrDie(env, hdrCapabilitiesClazz);
763 gHdrCapabilitiesClassInfo.ctor = GetMethodIDOrDie(env, hdrCapabilitiesClazz, "<init>",
764 "([IFFF)V");
765
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800766 return err;
767}
768
769};