blob: 4ee3724d554d433f6cf25391222d5bdc5b00f9ab [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"
Robert Carr6486d312017-01-09 19:48:29 -080018#define LOG_NDEBUG 0
Mathias Agopian3866f0d2013-02-11 22:08:48 -080019
Mathias Agopian3866f0d2013-02-11 22:08:48 -080020#include "android_os_Parcel.h"
21#include "android_util_Binder.h"
John Reckf29ed282015-04-07 07:32:03 -070022#include "android/graphics/Bitmap.h"
Mathias Agopian3866f0d2013-02-11 22:08:48 -080023#include "android/graphics/GraphicsJNI.h"
24#include "android/graphics/Region.h"
Andreas Gampeed6b9df2014-11-20 22:02:20 -080025#include "core_jni_helpers.h"
Ben Wagner60126ef2015-08-07 12:13:48 -040026
Tom Cherry8ed74bb2017-07-10 14:31:18 -070027#include <android-base/chrono_utils.h>
Steven Moreland2279b252017-07-19 09:50:45 -070028#include <nativehelper/JNIHelp.h>
29#include <nativehelper/ScopedUtfChars.h>
Mathias Agopian0449a402013-03-01 23:01:51 -080030#include <android_runtime/android_view_Surface.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080031#include <android_runtime/android_view_SurfaceSession.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080032#include <gui/Surface.h>
33#include <gui/SurfaceComposerClient.h>
Ben Wagner60126ef2015-08-07 12:13:48 -040034#include <jni.h>
35#include <memory>
36#include <stdio.h>
Michael Wright1c9977b2016-07-12 13:30:10 -070037#include <system/graphics.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080038#include <ui/DisplayInfo.h>
Hangyu Kuang54ac2192016-04-25 13:22:02 -070039#include <ui/HdrCapabilities.h>
Svetoslav1376d602014-03-13 11:17:26 -070040#include <ui/FrameStats.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080041#include <ui/Rect.h>
42#include <ui/Region.h>
Mathias Agopian3866f0d2013-02-11 22:08:48 -080043#include <utils/Log.h>
44
Mathias Agopian3866f0d2013-02-11 22:08:48 -080045// ----------------------------------------------------------------------------
46
47namespace android {
48
49static const char* const OutOfResourcesException =
50 "android/view/Surface$OutOfResourcesException";
51
52static struct {
Dan Stoza00101052014-05-02 15:23:40 -070053 jclass clazz;
54 jmethodID ctor;
Mathias Agopian3866f0d2013-02-11 22:08:48 -080055 jfieldID width;
56 jfieldID height;
57 jfieldID refreshRate;
58 jfieldID density;
59 jfieldID xDpi;
60 jfieldID yDpi;
61 jfieldID secure;
Andy McFaddene8b1aeb2014-06-13 14:05:40 -070062 jfieldID appVsyncOffsetNanos;
63 jfieldID presentationDeadlineNanos;
Mathias Agopian3866f0d2013-02-11 22:08:48 -080064} gPhysicalDisplayInfoClassInfo;
65
Dan Stoza9890e3412014-05-22 16:12:54 -070066static struct {
67 jfieldID bottom;
68 jfieldID left;
69 jfieldID right;
70 jfieldID top;
71} gRectClassInfo;
72
Leon Scroggins46cb9bd2014-03-06 15:36:39 -050073// Implements SkMallocPixelRef::ReleaseProc, to delete the screenshot on unref.
74void DeleteScreenshot(void* addr, void* context) {
Leon Scroggins46cb9bd2014-03-06 15:36:39 -050075 delete ((ScreenshotClient*) context);
76}
Mathias Agopian3866f0d2013-02-11 22:08:48 -080077
Svetoslav1376d602014-03-13 11:17:26 -070078static struct {
79 nsecs_t UNDEFINED_TIME_NANO;
80 jmethodID init;
81} gWindowContentFrameStatsClassInfo;
82
83static struct {
84 nsecs_t UNDEFINED_TIME_NANO;
85 jmethodID init;
86} gWindowAnimationFrameStatsClassInfo;
87
Hangyu Kuang54ac2192016-04-25 13:22:02 -070088static struct {
89 jclass clazz;
90 jmethodID ctor;
91} gHdrCapabilitiesClassInfo;
92
Robert Carr6486d312017-01-09 19:48:29 -080093static struct {
94 jclass clazz;
95 jmethodID builder;
96} gGraphicBufferClassInfo;
97
Mathias Agopian3866f0d2013-02-11 22:08:48 -080098// ----------------------------------------------------------------------------
99
Robert Carre13b58e2017-08-31 14:50:44 -0700100static jlong nativeCreateTransaction(JNIEnv* env, jclass clazz) {
101 return reinterpret_cast<jlong>(new SurfaceComposerClient::Transaction);
102}
103
104static void releaseTransaction(SurfaceComposerClient::Transaction* t) {
105 delete t;
106}
107
108static jlong nativeGetNativeTransactionFinalizer(JNIEnv* env, jclass clazz) {
109 return static_cast<jlong>(reinterpret_cast<uintptr_t>(&releaseTransaction));
110}
111
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000112static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,
Albert Chaulk3bf2e572016-11-22 13:59:19 -0500113 jstring nameStr, jint w, jint h, jint format, jint flags, jlong parentObject,
114 jint windowType, jint ownerUid) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800115 ScopedUtfChars name(env, nameStr);
116 sp<SurfaceComposerClient> client(android_view_SurfaceSession_getClient(env, sessionObj));
Robert Carr838120c2016-11-01 18:31:12 -0700117 SurfaceControl *parent = reinterpret_cast<SurfaceControl*>(parentObject);
Robert Carrb0f39362018-03-14 13:52:25 -0700118 sp<SurfaceControl> surface;
119 status_t err = client->createSurfaceChecked(
120 String8(name.c_str()), w, h, format, &surface, flags, parent, windowType, ownerUid);
121 if (err == NAME_NOT_FOUND) {
122 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
123 return 0;
124 } else if (err != NO_ERROR) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800125 jniThrowException(env, OutOfResourcesException, NULL);
126 return 0;
127 }
Albert Chaulk3bf2e572016-11-22 13:59:19 -0500128
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800129 surface->incStrong((void *)nativeCreate);
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000130 return reinterpret_cast<jlong>(surface.get());
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800131}
132
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000133static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800134 sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800135 ctrl->decStrong((void *)nativeCreate);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800136}
137
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000138static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800139 sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
140 ctrl->clear();
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800141 ctrl->decStrong((void *)nativeCreate);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800142}
143
Chong Zhang47e36a32016-02-29 16:44:33 -0800144static void nativeDisconnect(JNIEnv* env, jclass clazz, jlong nativeObject) {
145 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
146 if (ctrl != NULL) {
147 ctrl->disconnect();
148 }
149}
150
Robert Carr6486d312017-01-09 19:48:29 -0800151static Rect rectFromObj(JNIEnv* env, jobject rectObj) {
152 int left = env->GetIntField(rectObj, gRectClassInfo.left);
153 int top = env->GetIntField(rectObj, gRectClassInfo.top);
154 int right = env->GetIntField(rectObj, gRectClassInfo.right);
155 int bottom = env->GetIntField(rectObj, gRectClassInfo.bottom);
156 return Rect(left, top, right, bottom);
157}
158
159static jobject nativeScreenshotToBuffer(JNIEnv* env, jclass clazz,
160 jobject displayTokenObj, jobject sourceCropObj, jint width, jint height,
161 jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform,
162 int rotation) {
163 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
164 if (displayToken == NULL) {
165 return NULL;
166 }
167 Rect sourceCrop = rectFromObj(env, sourceCropObj);
168 if (allLayers) {
Robert Carrfb09bcf2017-01-26 11:52:35 -0800169 minLayer = INT32_MIN;
170 maxLayer = INT32_MAX;
Robert Carr6486d312017-01-09 19:48:29 -0800171 }
172 sp<GraphicBuffer> buffer;
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000173 status_t res = ScreenshotClient::capture(displayToken,
Robert Carr6486d312017-01-09 19:48:29 -0800174 sourceCrop, width, height, minLayer, maxLayer, useIdentityTransform,
175 rotation, &buffer);
176 if (res != NO_ERROR) {
177 return NULL;
178 }
179
180 return env->CallStaticObjectMethod(gGraphicBufferClassInfo.clazz,
181 gGraphicBufferClassInfo.builder,
182 buffer->getWidth(),
183 buffer->getHeight(),
184 buffer->getPixelFormat(),
Mathias Agopian113fd302017-05-25 18:31:04 -0700185 (jint)buffer->getUsage(),
Patrik Torstensson511a8082017-03-27 15:04:11 +0100186 (jlong)buffer.get());
Robert Carr6486d312017-01-09 19:48:29 -0800187}
188
Dan Stoza9890e3412014-05-22 16:12:54 -0700189static jobject nativeScreenshotBitmap(JNIEnv* env, jclass clazz,
190 jobject displayTokenObj, jobject sourceCropObj, jint width, jint height,
Riley Andrews1d134062014-08-21 15:47:07 -0700191 jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform,
192 int rotation) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800193 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
194 if (displayToken == NULL) {
195 return NULL;
196 }
197
Robert Carr6486d312017-01-09 19:48:29 -0800198 Rect sourceCrop = rectFromObj(env, sourceCropObj);
Dan Stoza9890e3412014-05-22 16:12:54 -0700199
Ben Wagner60126ef2015-08-07 12:13:48 -0400200 std::unique_ptr<ScreenshotClient> screenshot(new ScreenshotClient());
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500201 status_t res;
Riley Andrews1d134062014-08-21 15:47:07 -0700202 if (allLayers) {
Robert Carrfb09bcf2017-01-26 11:52:35 -0800203 minLayer = INT32_MIN;
204 maxLayer = INT32_MAX;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500205 }
Riley Andrews1d134062014-08-21 15:47:07 -0700206
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000207 sp<GraphicBuffer> buffer;
208 res = ScreenshotClient::capture(displayToken, sourceCrop, width, height,
209 minLayer, maxLayer, useIdentityTransform, static_cast<uint32_t>(rotation), &buffer);
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500210 if (res != NO_ERROR) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800211 return NULL;
212 }
213
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400214 SkColorType colorType;
215 SkAlphaType alphaType;
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000216
217 PixelFormat format = buffer->getPixelFormat();
218 switch (format) {
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500219 case PIXEL_FORMAT_RGBX_8888: {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400220 colorType = kRGBA_8888_SkColorType;
221 alphaType = kOpaque_SkAlphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500222 break;
223 }
224 case PIXEL_FORMAT_RGBA_8888: {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400225 colorType = kRGBA_8888_SkColorType;
226 alphaType = kPremul_SkAlphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500227 break;
228 }
Romain Guy9505a652016-12-14 09:43:50 -0800229 case PIXEL_FORMAT_RGBA_FP16: {
230 colorType = kRGBA_F16_SkColorType;
231 alphaType = kPremul_SkAlphaType;
232 break;
233 }
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500234 case PIXEL_FORMAT_RGB_565: {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400235 colorType = kRGB_565_SkColorType;
236 alphaType = kOpaque_SkAlphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500237 break;
238 }
239 default: {
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500240 return NULL;
241 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800242 }
Romain Guy26a2b972017-04-17 09:39:51 -0700243
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000244 SkImageInfo info = SkImageInfo::Make(buffer->getWidth(), buffer->getHeight(),
245 colorType, alphaType,
246 SkColorSpace::MakeSRGB());
Romain Guy26a2b972017-04-17 09:39:51 -0700247
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000248 auto bitmap = sk_sp<Bitmap>(new Bitmap(buffer.get(), info));
249 return bitmap::createBitmap(env, bitmap.release(),
250 android::bitmap::kBitmapCreateFlag_Premultiplied, NULL);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800251}
252
Dan Stoza9890e3412014-05-22 16:12:54 -0700253static void nativeScreenshot(JNIEnv* env, jclass clazz, jobject displayTokenObj,
254 jobject surfaceObj, jobject sourceCropObj, jint width, jint height,
255 jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform) {
Mathias Agopian0449a402013-03-01 23:01:51 -0800256 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000257 if (displayToken == NULL) {
chaviw1cda84c2017-10-23 16:47:10 -0700258 return;
259 }
260
261 sp<Surface> consumer = android_view_Surface_getSurface(env, surfaceObj);
262 if (consumer == NULL) {
263 return;
264 }
265
chaviwfbe47df2017-11-10 16:14:49 -0800266 Rect sourceCrop;
267 if (sourceCropObj != NULL) {
268 sourceCrop = rectFromObj(env, sourceCropObj);
269 }
270
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000271 if (allLayers) {
272 minLayer = INT32_MIN;
273 maxLayer = INT32_MAX;
274 }
275
276 sp<GraphicBuffer> buffer;
277 ScreenshotClient::capture(displayToken, sourceCrop, width, height, minLayer, maxLayer,
278 useIdentityTransform, 0, &buffer);
279
280 Surface::attachAndQueueBuffer(consumer.get(), buffer);
chaviwfbe47df2017-11-10 16:14:49 -0800281}
282
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000283static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken,
chaviwfbe47df2017-11-10 16:14:49 -0800284 jobject sourceCropObj, jfloat frameScale) {
285
286 sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken);
287 if (layerHandle == NULL) {
288 return NULL;
289 }
290
291 Rect sourceCrop;
292 if (sourceCropObj != NULL) {
293 sourceCrop = rectFromObj(env, sourceCropObj);
294 }
295
296 sp<GraphicBuffer> buffer;
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000297 status_t res = ScreenshotClient::captureLayers(layerHandle, sourceCrop, frameScale, &buffer);
chaviwfbe47df2017-11-10 16:14:49 -0800298 if (res != NO_ERROR) {
299 return NULL;
300 }
301
302 return env->CallStaticObjectMethod(gGraphicBufferClassInfo.clazz,
303 gGraphicBufferClassInfo.builder,
304 buffer->getWidth(),
305 buffer->getHeight(),
306 buffer->getPixelFormat(),
307 (jint)buffer->getUsage(),
308 (jlong)buffer.get());
chaviw1cda84c2017-10-23 16:47:10 -0700309}
310
Robert Carre13b58e2017-08-31 14:50:44 -0700311static void nativeApplyTransaction(JNIEnv* env, jclass clazz, jlong transactionObj, jboolean sync) {
312 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
313 transaction->apply(sync);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800314}
315
Robert Carrb1579c82017-09-05 14:54:47 -0700316static void nativeMergeTransaction(JNIEnv* env, jclass clazz,
317 jlong transactionObj, jlong otherTransactionObj) {
318 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
319 auto otherTransaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(
320 otherTransactionObj);
321 transaction->merge(std::move(*otherTransaction));
322}
323
Robert Carre13b58e2017-08-31 14:50:44 -0700324static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz, jlong transactionObj) {
325 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
326 transaction->setAnimationTransaction();
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800327}
328
Robert Carre13b58e2017-08-31 14:50:44 -0700329static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong transactionObj,
330 jlong nativeObject, jint zorder) {
331 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800332
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800333 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700334 transaction->setLayer(ctrl, zorder);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800335}
336
Robert Carre13b58e2017-08-31 14:50:44 -0700337static void nativeSetRelativeLayer(JNIEnv* env, jclass clazz, jlong transactionObj,
338 jlong nativeObject,
Robert Carraf422a82017-04-10 18:34:33 -0700339 jobject relativeTo, jint zorder) {
Robert Carre13b58e2017-08-31 14:50:44 -0700340
Robert Carraf422a82017-04-10 18:34:33 -0700341 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
342 sp<IBinder> handle = ibinderForJavaObject(env, relativeTo);
343
Robert Carre13b58e2017-08-31 14:50:44 -0700344 {
345 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
346 transaction->setRelativeLayer(ctrl, handle, zorder);
347 }
Robert Carraf422a82017-04-10 18:34:33 -0700348}
349
Robert Carre13b58e2017-08-31 14:50:44 -0700350static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong transactionObj,
351 jlong nativeObject, jfloat x, jfloat y) {
352 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
353
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800354 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700355 transaction->setPosition(ctrl, x, y);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800356}
357
Robert Carr6da3cc02016-06-16 15:17:07 -0700358static void nativeSetGeometryAppliesWithResize(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700359jlong transactionObj,
Robert Carra9408d42016-06-03 13:28:48 -0700360 jlong nativeObject) {
Robert Carre13b58e2017-08-31 14:50:44 -0700361 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
362
Robert Carra9408d42016-06-03 13:28:48 -0700363 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700364 transaction->setGeometryAppliesWithResize(ctrl);
Robert Carra9408d42016-06-03 13:28:48 -0700365}
366
Robert Carre13b58e2017-08-31 14:50:44 -0700367static void nativeSetSize(JNIEnv* env, jclass clazz, jlong transactionObj,
368 jlong nativeObject, jint w, jint h) {
369 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
370
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800371 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700372 transaction->setSize(ctrl, w, h);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800373}
374
Robert Carre13b58e2017-08-31 14:50:44 -0700375static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong transactionObj,
376 jlong nativeObject, jint flags, jint mask) {
377 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
378
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800379 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700380 transaction->setFlags(ctrl, flags, mask);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800381}
382
Robert Carre13b58e2017-08-31 14:50:44 -0700383static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong transactionObj,
384 jlong nativeObject, jobject regionObj) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800385 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
386 SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj);
387 if (!region) {
388 doThrowIAE(env);
389 return;
390 }
391
392 const SkIRect& b(region->getBounds());
393 Region reg(Rect(b.fLeft, b.fTop, b.fRight, b.fBottom));
394 if (region->isComplex()) {
395 SkRegion::Iterator it(*region);
396 while (!it.done()) {
397 const SkIRect& r(it.rect());
398 reg.addRectUnchecked(r.fLeft, r.fTop, r.fRight, r.fBottom);
399 it.next();
400 }
401 }
402
Robert Carre13b58e2017-08-31 14:50:44 -0700403 {
404 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
405 transaction->setTransparentRegionHint(ctrl, reg);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800406 }
407}
408
Robert Carre13b58e2017-08-31 14:50:44 -0700409static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong transactionObj,
410 jlong nativeObject, jfloat alpha) {
411 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
412
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800413 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700414 transaction->setAlpha(ctrl, alpha);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800415}
416
Robert Carre13b58e2017-08-31 14:50:44 -0700417static void nativeSetColor(JNIEnv* env, jclass clazz, jlong transactionObj,
418 jlong nativeObject, jfloatArray fColor) {
419 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
chaviw0dd03f52017-08-25 12:15:26 -0700420 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700421
chaviw0dd03f52017-08-25 12:15:26 -0700422 float* floatColors = env->GetFloatArrayElements(fColor, 0);
423 half3 color(floatColors[0], floatColors[1], floatColors[2]);
Robert Carre13b58e2017-08-31 14:50:44 -0700424 transaction->setColor(ctrl, color);
chaviw0dd03f52017-08-25 12:15:26 -0700425}
426
Robert Carre13b58e2017-08-31 14:50:44 -0700427static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong transactionObj,
428 jlong nativeObject,
Robert Carr0edf18f2017-02-21 20:01:47 -0800429 jfloat dsdx, jfloat dtdx, jfloat dtdy, jfloat dsdy) {
Robert Carre13b58e2017-08-31 14:50:44 -0700430 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
431
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800432 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700433 transaction->setMatrix(ctrl, dsdx, dtdx, dtdy, dsdy);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800434}
435
Robert Carre13b58e2017-08-31 14:50:44 -0700436static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong transactionObj,
437 jlong nativeObject,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800438 jint l, jint t, jint r, jint b) {
Robert Carre13b58e2017-08-31 14:50:44 -0700439 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
440
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800441 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
442 Rect crop(l, t, r, b);
Robert Carre13b58e2017-08-31 14:50:44 -0700443 transaction->setCrop(ctrl, crop);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800444}
445
Robert Carre13b58e2017-08-31 14:50:44 -0700446static void nativeSetFinalCrop(JNIEnv* env, jclass clazz, jlong transactionObj,
447 jlong nativeObject,
Pablo Ceballos27982e62016-03-09 10:50:45 -0800448 jint l, jint t, jint r, jint b) {
Robert Carre13b58e2017-08-31 14:50:44 -0700449 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
450
Pablo Ceballos27982e62016-03-09 10:50:45 -0800451 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
452 Rect crop(l, t, r, b);
Robert Carre13b58e2017-08-31 14:50:44 -0700453 transaction->setFinalCrop(ctrl, crop);
Pablo Ceballos27982e62016-03-09 10:50:45 -0800454}
455
Robert Carre13b58e2017-08-31 14:50:44 -0700456static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong transactionObj,
457 jlong nativeObject, jint layerStack) {
458 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
459
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800460 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700461 transaction->setLayerStack(ctrl, layerStack);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800462}
463
464static jobject nativeGetBuiltInDisplay(JNIEnv* env, jclass clazz, jint id) {
465 sp<IBinder> token(SurfaceComposerClient::getBuiltInDisplay(id));
466 return javaObjectForIBinder(env, token);
467}
468
469static jobject nativeCreateDisplay(JNIEnv* env, jclass clazz, jstring nameObj,
470 jboolean secure) {
471 ScopedUtfChars name(env, nameObj);
472 sp<IBinder> token(SurfaceComposerClient::createDisplay(
473 String8(name.c_str()), bool(secure)));
474 return javaObjectForIBinder(env, token);
475}
476
Jesse Hall6a6bc212013-08-08 12:15:03 -0700477static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) {
478 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
479 if (token == NULL) return;
480 SurfaceComposerClient::destroyDisplay(token);
481}
482
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800483static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700484 jlong transactionObj,
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000485 jobject tokenObj, jlong nativeSurfaceObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800486 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
487 if (token == NULL) return;
Mathias Agopianffddc9b2013-02-25 15:56:31 -0800488 sp<IGraphicBufferProducer> bufferProducer;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800489 sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject));
Mathias Agopianffddc9b2013-02-25 15:56:31 -0800490 if (sur != NULL) {
491 bufferProducer = sur->getIGraphicBufferProducer();
492 }
Robert Carre13b58e2017-08-31 14:50:44 -0700493
494
495 status_t err = NO_ERROR;
496 {
497 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
498 err = transaction->setDisplaySurface(token,
499 bufferProducer);
500 }
Pablo Ceballosaff2f942016-07-29 14:49:55 -0700501 if (err != NO_ERROR) {
502 doThrowIAE(env, "Illegal Surface, could not enable async mode. Was this"
503 " Surface created with singleBufferMode?");
504 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800505}
506
507static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700508 jlong transactionObj,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800509 jobject tokenObj, jint layerStack) {
Robert Carre13b58e2017-08-31 14:50:44 -0700510
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800511 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
512 if (token == NULL) return;
513
Robert Carre13b58e2017-08-31 14:50:44 -0700514 {
515 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
516 transaction->setDisplayLayerStack(token, layerStack);
517 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800518}
519
520static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700521 jlong transactionObj,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800522 jobject tokenObj, jint orientation,
523 jint layerStackRect_left, jint layerStackRect_top, jint layerStackRect_right, jint layerStackRect_bottom,
524 jint displayRect_left, jint displayRect_top, jint displayRect_right, jint displayRect_bottom) {
525 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
526 if (token == NULL) return;
527 Rect layerStackRect(layerStackRect_left, layerStackRect_top, layerStackRect_right, layerStackRect_bottom);
528 Rect displayRect(displayRect_left, displayRect_top, displayRect_right, displayRect_bottom);
Robert Carre13b58e2017-08-31 14:50:44 -0700529
530 {
531 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
532 transaction->setDisplayProjection(token, orientation, layerStackRect, displayRect);
533 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800534}
535
Michael Wright01e840f2014-06-26 16:03:25 -0700536static void nativeSetDisplaySize(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700537 jlong transactionObj,
Michael Wright01e840f2014-06-26 16:03:25 -0700538 jobject tokenObj, jint width, jint height) {
539 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
540 if (token == NULL) return;
Robert Carre13b58e2017-08-31 14:50:44 -0700541
542 {
543 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
544 transaction->setDisplaySize(token, width, height);
545 }
Michael Wright01e840f2014-06-26 16:03:25 -0700546}
547
Dan Stoza00101052014-05-02 15:23:40 -0700548static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz,
549 jobject tokenObj) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800550 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
Dan Stoza00101052014-05-02 15:23:40 -0700551 if (token == NULL) return NULL;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800552
Dan Stoza00101052014-05-02 15:23:40 -0700553 Vector<DisplayInfo> configs;
554 if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR ||
555 configs.size() == 0) {
556 return NULL;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800557 }
558
Dan Stoza00101052014-05-02 15:23:40 -0700559 jobjectArray configArray = env->NewObjectArray(configs.size(),
560 gPhysicalDisplayInfoClassInfo.clazz, NULL);
561
562 for (size_t c = 0; c < configs.size(); ++c) {
563 const DisplayInfo& info = configs[c];
564 jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz,
565 gPhysicalDisplayInfoClassInfo.ctor);
566 env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w);
567 env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h);
568 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps);
569 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.density, info.density);
570 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi);
571 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi);
572 env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure);
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700573 env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos,
574 info.appVsyncOffset);
575 env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos,
576 info.presentationDeadline);
Dan Stoza00101052014-05-02 15:23:40 -0700577 env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj);
578 env->DeleteLocalRef(infoObj);
579 }
580
581 return configArray;
582}
583
584static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) {
585 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
586 if (token == NULL) return -1;
587 return static_cast<jint>(SurfaceComposerClient::getActiveConfig(token));
588}
589
590static jboolean nativeSetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj, jint id) {
591 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
592 if (token == NULL) return JNI_FALSE;
593 status_t err = SurfaceComposerClient::setActiveConfig(token, static_cast<int>(id));
594 return err == NO_ERROR ? JNI_TRUE : JNI_FALSE;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800595}
596
Michael Wright1c9977b2016-07-12 13:30:10 -0700597static jintArray nativeGetDisplayColorModes(JNIEnv* env, jclass, jobject tokenObj) {
598 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
599 if (token == NULL) return NULL;
600 Vector<android_color_mode_t> colorModes;
601 if (SurfaceComposerClient::getDisplayColorModes(token, &colorModes) != NO_ERROR ||
602 colorModes.isEmpty()) {
603 return NULL;
604 }
605
606 jintArray colorModesArray = env->NewIntArray(colorModes.size());
607 if (colorModesArray == NULL) {
608 jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
609 return NULL;
610 }
611 jint* colorModesArrayValues = env->GetIntArrayElements(colorModesArray, 0);
612 for (size_t i = 0; i < colorModes.size(); i++) {
613 colorModesArrayValues[i] = static_cast<jint>(colorModes[i]);
614 }
615 env->ReleaseIntArrayElements(colorModesArray, colorModesArrayValues, 0);
616 return colorModesArray;
617}
618
619static jint nativeGetActiveColorMode(JNIEnv* env, jclass, jobject tokenObj) {
620 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
621 if (token == NULL) return -1;
622 return static_cast<jint>(SurfaceComposerClient::getActiveColorMode(token));
623}
624
625static jboolean nativeSetActiveColorMode(JNIEnv* env, jclass,
626 jobject tokenObj, jint colorMode) {
627 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
628 if (token == NULL) return JNI_FALSE;
629 status_t err = SurfaceComposerClient::setActiveColorMode(token,
630 static_cast<android_color_mode_t>(colorMode));
631 return err == NO_ERROR ? JNI_TRUE : JNI_FALSE;
632}
633
Prashant Malanic55929a2014-05-25 01:59:21 -0700634static void nativeSetDisplayPowerMode(JNIEnv* env, jclass clazz, jobject tokenObj, jint mode) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800635 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
636 if (token == NULL) return;
637
Tom Cherry8ed74bb2017-07-10 14:31:18 -0700638 android::base::Timer t;
Prashant Malanic55929a2014-05-25 01:59:21 -0700639 SurfaceComposerClient::setDisplayPowerMode(token, mode);
Tom Cherry8ed74bb2017-07-10 14:31:18 -0700640 if (t.duration() > 100ms) ALOGD("Excessive delay in setPowerMode()");
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800641}
642
Svetoslav1376d602014-03-13 11:17:26 -0700643static jboolean nativeClearContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject) {
644 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
645 status_t err = ctrl->clearLayerFrameStats();
646
647 if (err < 0 && err != NO_INIT) {
648 doThrowIAE(env);
649 }
650
651 // The other end is not ready, just report we failed.
652 if (err == NO_INIT) {
653 return JNI_FALSE;
654 }
655
656 return JNI_TRUE;
657}
658
659static jboolean nativeGetContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject,
660 jobject outStats) {
661 FrameStats stats;
662
663 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
664 status_t err = ctrl->getLayerFrameStats(&stats);
665 if (err < 0 && err != NO_INIT) {
666 doThrowIAE(env);
667 }
668
669 // The other end is not ready, fine just return empty stats.
670 if (err == NO_INIT) {
671 return JNI_FALSE;
672 }
673
674 jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano);
675 size_t frameCount = stats.desiredPresentTimesNano.size();
676
677 jlongArray postedTimesNanoDst = env->NewLongArray(frameCount);
678 if (postedTimesNanoDst == NULL) {
679 return JNI_FALSE;
680 }
681
682 jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount);
683 if (presentedTimesNanoDst == NULL) {
684 return JNI_FALSE;
685 }
686
687 jlongArray readyTimesNanoDst = env->NewLongArray(frameCount);
688 if (readyTimesNanoDst == NULL) {
689 return JNI_FALSE;
690 }
691
692 nsecs_t postedTimesNanoSrc[frameCount];
693 nsecs_t presentedTimesNanoSrc[frameCount];
694 nsecs_t readyTimesNanoSrc[frameCount];
695
696 for (size_t i = 0; i < frameCount; i++) {
697 nsecs_t postedTimeNano = stats.desiredPresentTimesNano[i];
698 if (postedTimeNano == INT64_MAX) {
699 postedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
700 }
701 postedTimesNanoSrc[i] = postedTimeNano;
702
703 nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i];
704 if (presentedTimeNano == INT64_MAX) {
705 presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
706 }
707 presentedTimesNanoSrc[i] = presentedTimeNano;
708
709 nsecs_t readyTimeNano = stats.frameReadyTimesNano[i];
710 if (readyTimeNano == INT64_MAX) {
711 readyTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
712 }
713 readyTimesNanoSrc[i] = readyTimeNano;
714 }
715
716 env->SetLongArrayRegion(postedTimesNanoDst, 0, frameCount, postedTimesNanoSrc);
717 env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc);
718 env->SetLongArrayRegion(readyTimesNanoDst, 0, frameCount, readyTimesNanoSrc);
719
720 env->CallVoidMethod(outStats, gWindowContentFrameStatsClassInfo.init, refreshPeriodNano,
721 postedTimesNanoDst, presentedTimesNanoDst, readyTimesNanoDst);
722
723 if (env->ExceptionCheck()) {
724 return JNI_FALSE;
725 }
726
727 return JNI_TRUE;
728}
729
730static jboolean nativeClearAnimationFrameStats(JNIEnv* env, jclass clazz) {
731 status_t err = SurfaceComposerClient::clearAnimationFrameStats();
732
733 if (err < 0 && err != NO_INIT) {
734 doThrowIAE(env);
735 }
736
737 // The other end is not ready, just report we failed.
738 if (err == NO_INIT) {
739 return JNI_FALSE;
740 }
741
742 return JNI_TRUE;
743}
744
745static jboolean nativeGetAnimationFrameStats(JNIEnv* env, jclass clazz, jobject outStats) {
746 FrameStats stats;
747
748 status_t err = SurfaceComposerClient::getAnimationFrameStats(&stats);
749 if (err < 0 && err != NO_INIT) {
750 doThrowIAE(env);
751 }
752
753 // The other end is not ready, fine just return empty stats.
754 if (err == NO_INIT) {
755 return JNI_FALSE;
756 }
757
758 jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano);
759 size_t frameCount = stats.desiredPresentTimesNano.size();
760
761 jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount);
762 if (presentedTimesNanoDst == NULL) {
763 return JNI_FALSE;
764 }
765
766 nsecs_t presentedTimesNanoSrc[frameCount];
767
768 for (size_t i = 0; i < frameCount; i++) {
Allen Hairac5eda32014-04-24 11:50:37 -0700769 nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i];
Svetoslav1376d602014-03-13 11:17:26 -0700770 if (presentedTimeNano == INT64_MAX) {
771 presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
772 }
773 presentedTimesNanoSrc[i] = presentedTimeNano;
774 }
775
776 env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc);
777
778 env->CallVoidMethod(outStats, gWindowAnimationFrameStatsClassInfo.init, refreshPeriodNano,
779 presentedTimesNanoDst);
780
781 if (env->ExceptionCheck()) {
782 return JNI_FALSE;
783 }
784
785 return JNI_TRUE;
786}
787
Robert Carre13b58e2017-08-31 14:50:44 -0700788static void nativeDeferTransactionUntil(JNIEnv* env, jclass clazz, jlong transactionObj,
789 jlong nativeObject,
Rob Carr64e516f2015-10-29 00:20:45 +0000790 jobject handleObject, jlong frameNumber) {
791 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
792 sp<IBinder> handle = ibinderForJavaObject(env, handleObject);
793
Robert Carre13b58e2017-08-31 14:50:44 -0700794 {
795 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
796 transaction->deferTransactionUntil(ctrl, handle, frameNumber);
797 }
Rob Carr64e516f2015-10-29 00:20:45 +0000798}
799
Robert Carre13b58e2017-08-31 14:50:44 -0700800static void nativeDeferTransactionUntilSurface(JNIEnv* env, jclass clazz, jlong transactionObj,
801 jlong nativeObject,
Robert Carrd5c7dd62017-03-08 10:39:30 -0800802 jlong surfaceObject, jlong frameNumber) {
Robert Carre13b58e2017-08-31 14:50:44 -0700803 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
804
Robert Carrd5c7dd62017-03-08 10:39:30 -0800805 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
806 sp<Surface> barrier = reinterpret_cast<Surface *>(surfaceObject);
807
Robert Carre13b58e2017-08-31 14:50:44 -0700808 transaction->deferTransactionUntil(ctrl, barrier, frameNumber);
Robert Carrd5c7dd62017-03-08 10:39:30 -0800809}
810
Robert Carre13b58e2017-08-31 14:50:44 -0700811static void nativeReparentChildren(JNIEnv* env, jclass clazz, jlong transactionObj,
812 jlong nativeObject,
Robert Carrd5c7dd62017-03-08 10:39:30 -0800813 jobject newParentObject) {
Robert Carre13b58e2017-08-31 14:50:44 -0700814
Robert Carrd5c7dd62017-03-08 10:39:30 -0800815 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
816 sp<IBinder> handle = ibinderForJavaObject(env, newParentObject);
817
Robert Carre13b58e2017-08-31 14:50:44 -0700818 {
819 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
820 transaction->reparentChildren(ctrl, handle);
821 }
Robert Carrd5c7dd62017-03-08 10:39:30 -0800822}
823
Robert Carre13b58e2017-08-31 14:50:44 -0700824static void nativeReparent(JNIEnv* env, jclass clazz, jlong transactionObj,
825 jlong nativeObject,
chaviw76431402017-09-18 16:50:05 -0700826 jobject newParentObject) {
chaviw63542382017-08-17 17:39:29 -0700827 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
828 sp<IBinder> parentHandle = ibinderForJavaObject(env, newParentObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700829
830 {
831 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
832 transaction->reparent(ctrl, parentHandle);
833 }
chaviw63542382017-08-17 17:39:29 -0700834}
835
Robert Carre13b58e2017-08-31 14:50:44 -0700836static void nativeSeverChildren(JNIEnv* env, jclass clazz, jlong transactionObj,
837 jlong nativeObject) {
838 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
839
Robert Carrd5c7dd62017-03-08 10:39:30 -0800840 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700841 transaction->detachChildren(ctrl);
Robert Carrd5c7dd62017-03-08 10:39:30 -0800842}
843
Robert Carre13b58e2017-08-31 14:50:44 -0700844static void nativeSetOverrideScalingMode(JNIEnv* env, jclass clazz, jlong transactionObj,
845 jlong nativeObject,
Robert Carr1ca6a332016-04-11 18:00:43 -0700846 jint scalingMode) {
Robert Carre13b58e2017-08-31 14:50:44 -0700847 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
Robert Carr1ca6a332016-04-11 18:00:43 -0700848
Robert Carre13b58e2017-08-31 14:50:44 -0700849 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
850 transaction->setOverrideScalingMode(ctrl, scalingMode);
Robert Carr1ca6a332016-04-11 18:00:43 -0700851}
852
Chavi Weingartenb736e322018-02-23 00:27:54 +0000853static void nativeDestroyInTransaction(JNIEnv* env, jclass clazz,
854 jlong transactionObj,
855 jlong nativeObject) {
856 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
857 auto ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);
858 transaction->destroySurface(ctrl);
859}
860
Rob Carr64e516f2015-10-29 00:20:45 +0000861static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
862 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Rob Carr64e516f2015-10-29 00:20:45 +0000863 return javaObjectForIBinder(env, ctrl->getHandle());
864}
865
Hangyu Kuang54ac2192016-04-25 13:22:02 -0700866static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) {
867 sp<IBinder> token(ibinderForJavaObject(env, tokenObject));
868 if (token == NULL) return NULL;
869
870 HdrCapabilities capabilities;
871 SurfaceComposerClient::getHdrCapabilities(token, &capabilities);
872
873 const auto& types = capabilities.getSupportedHdrTypes();
874 auto typesArray = env->NewIntArray(types.size());
875 env->SetIntArrayRegion(typesArray, 0, types.size(), types.data());
876
Michael Wright9ff94c02016-03-30 18:05:40 -0700877 return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor,
Hangyu Kuang54ac2192016-04-25 13:22:02 -0700878 typesArray, capabilities.getDesiredMaxLuminance(),
879 capabilities.getDesiredMaxAverageLuminance(), capabilities.getDesiredMinLuminance());
880}
881
Jorim Jaggi06975df2017-12-01 14:52:13 +0100882static jlong nativeReadFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) {
883 Parcel* parcel = parcelForJavaObject(env, parcelObj);
884 if (parcel == NULL) {
885 doThrowNPE(env);
886 return 0;
887 }
888 sp<SurfaceControl> surface = SurfaceControl::readFromParcel(parcel);
889 if (surface == nullptr) {
890 return 0;
891 }
892 surface->incStrong((void *)nativeCreate);
893 return reinterpret_cast<jlong>(surface.get());
894}
895
896static void nativeWriteToParcel(JNIEnv* env, jclass clazz,
897 jlong nativeObject, jobject parcelObj) {
898 Parcel* parcel = parcelForJavaObject(env, parcelObj);
899 if (parcel == NULL) {
900 doThrowNPE(env);
901 return;
902 }
903 SurfaceControl* const self = reinterpret_cast<SurfaceControl *>(nativeObject);
904 self->writeToParcel(parcel);
905}
906
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800907// ----------------------------------------------------------------------------
908
Daniel Micay76f6a862015-09-19 17:31:01 -0400909static const JNINativeMethod sSurfaceControlMethods[] = {
Albert Chaulk3bf2e572016-11-22 13:59:19 -0500910 {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIIIJII)J",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800911 (void*)nativeCreate },
Jorim Jaggi06975df2017-12-01 14:52:13 +0100912 {"nativeReadFromParcel", "(Landroid/os/Parcel;)J",
913 (void*)nativeReadFromParcel },
914 {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V",
915 (void*)nativeWriteToParcel },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000916 {"nativeRelease", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800917 (void*)nativeRelease },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000918 {"nativeDestroy", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800919 (void*)nativeDestroy },
Chong Zhang47e36a32016-02-29 16:44:33 -0800920 {"nativeDisconnect", "(J)V",
921 (void*)nativeDisconnect },
Riley Andrews1d134062014-08-21 15:47:07 -0700922 {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/Bitmap;",
Mathias Agopian0449a402013-03-01 23:01:51 -0800923 (void*)nativeScreenshotBitmap },
Dan Stoza9890e3412014-05-22 16:12:54 -0700924 {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/view/Surface;Landroid/graphics/Rect;IIIIZZ)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800925 (void*)nativeScreenshot },
Robert Carre13b58e2017-08-31 14:50:44 -0700926 {"nativeCreateTransaction", "()J",
927 (void*)nativeCreateTransaction },
928 {"nativeApplyTransaction", "(JZ)V",
929 (void*)nativeApplyTransaction },
930 {"nativeGetNativeTransactionFinalizer", "()J",
931 (void*)nativeGetNativeTransactionFinalizer },
Robert Carrb1579c82017-09-05 14:54:47 -0700932 {"nativeMergeTransaction", "(JJ)V",
933 (void*)nativeMergeTransaction },
Robert Carre13b58e2017-08-31 14:50:44 -0700934 {"nativeSetAnimationTransaction", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800935 (void*)nativeSetAnimationTransaction },
Robert Carre13b58e2017-08-31 14:50:44 -0700936 {"nativeSetLayer", "(JJI)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800937 (void*)nativeSetLayer },
Robert Carre13b58e2017-08-31 14:50:44 -0700938 {"nativeSetRelativeLayer", "(JJLandroid/os/IBinder;I)V",
Robert Carraf422a82017-04-10 18:34:33 -0700939 (void*)nativeSetRelativeLayer },
Robert Carre13b58e2017-08-31 14:50:44 -0700940 {"nativeSetPosition", "(JJFF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800941 (void*)nativeSetPosition },
Robert Carre13b58e2017-08-31 14:50:44 -0700942 {"nativeSetGeometryAppliesWithResize", "(JJ)V",
Robert Carr6da3cc02016-06-16 15:17:07 -0700943 (void*)nativeSetGeometryAppliesWithResize },
Robert Carre13b58e2017-08-31 14:50:44 -0700944 {"nativeSetSize", "(JJII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800945 (void*)nativeSetSize },
Robert Carre13b58e2017-08-31 14:50:44 -0700946 {"nativeSetTransparentRegionHint", "(JJLandroid/graphics/Region;)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800947 (void*)nativeSetTransparentRegionHint },
Robert Carre13b58e2017-08-31 14:50:44 -0700948 {"nativeSetAlpha", "(JJF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800949 (void*)nativeSetAlpha },
Robert Carre13b58e2017-08-31 14:50:44 -0700950 {"nativeSetColor", "(JJ[F)V",
chaviw0dd03f52017-08-25 12:15:26 -0700951 (void*)nativeSetColor },
Robert Carre13b58e2017-08-31 14:50:44 -0700952 {"nativeSetMatrix", "(JJFFFF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800953 (void*)nativeSetMatrix },
Robert Carre13b58e2017-08-31 14:50:44 -0700954 {"nativeSetFlags", "(JJII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800955 (void*)nativeSetFlags },
Robert Carre13b58e2017-08-31 14:50:44 -0700956 {"nativeSetWindowCrop", "(JJIIII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800957 (void*)nativeSetWindowCrop },
Robert Carre13b58e2017-08-31 14:50:44 -0700958 {"nativeSetFinalCrop", "(JJIIII)V",
Pablo Ceballos27982e62016-03-09 10:50:45 -0800959 (void*)nativeSetFinalCrop },
Robert Carre13b58e2017-08-31 14:50:44 -0700960 {"nativeSetLayerStack", "(JJI)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800961 (void*)nativeSetLayerStack },
962 {"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;",
963 (void*)nativeGetBuiltInDisplay },
964 {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;",
965 (void*)nativeCreateDisplay },
Jesse Hall6a6bc212013-08-08 12:15:03 -0700966 {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V",
967 (void*)nativeDestroyDisplay },
Robert Carre13b58e2017-08-31 14:50:44 -0700968 {"nativeSetDisplaySurface", "(JLandroid/os/IBinder;J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800969 (void*)nativeSetDisplaySurface },
Robert Carre13b58e2017-08-31 14:50:44 -0700970 {"nativeSetDisplayLayerStack", "(JLandroid/os/IBinder;I)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800971 (void*)nativeSetDisplayLayerStack },
Robert Carre13b58e2017-08-31 14:50:44 -0700972 {"nativeSetDisplayProjection", "(JLandroid/os/IBinder;IIIIIIIII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800973 (void*)nativeSetDisplayProjection },
Robert Carre13b58e2017-08-31 14:50:44 -0700974 {"nativeSetDisplaySize", "(JLandroid/os/IBinder;II)V",
Michael Wright01e840f2014-06-26 16:03:25 -0700975 (void*)nativeSetDisplaySize },
Dan Stoza00101052014-05-02 15:23:40 -0700976 {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;",
977 (void*)nativeGetDisplayConfigs },
978 {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I",
979 (void*)nativeGetActiveConfig },
980 {"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z",
981 (void*)nativeSetActiveConfig },
Michael Wright1c9977b2016-07-12 13:30:10 -0700982 {"nativeGetDisplayColorModes", "(Landroid/os/IBinder;)[I",
983 (void*)nativeGetDisplayColorModes},
984 {"nativeGetActiveColorMode", "(Landroid/os/IBinder;)I",
985 (void*)nativeGetActiveColorMode},
986 {"nativeSetActiveColorMode", "(Landroid/os/IBinder;I)Z",
987 (void*)nativeSetActiveColorMode},
Michael Wright9ff94c02016-03-30 18:05:40 -0700988 {"nativeGetHdrCapabilities", "(Landroid/os/IBinder;)Landroid/view/Display$HdrCapabilities;",
989 (void*)nativeGetHdrCapabilities },
Svetoslav1376d602014-03-13 11:17:26 -0700990 {"nativeClearContentFrameStats", "(J)Z",
991 (void*)nativeClearContentFrameStats },
992 {"nativeGetContentFrameStats", "(JLandroid/view/WindowContentFrameStats;)Z",
993 (void*)nativeGetContentFrameStats },
994 {"nativeClearAnimationFrameStats", "()Z",
995 (void*)nativeClearAnimationFrameStats },
996 {"nativeGetAnimationFrameStats", "(Landroid/view/WindowAnimationFrameStats;)Z",
997 (void*)nativeGetAnimationFrameStats },
Prashant Malanic55929a2014-05-25 01:59:21 -0700998 {"nativeSetDisplayPowerMode", "(Landroid/os/IBinder;I)V",
999 (void*)nativeSetDisplayPowerMode },
Robert Carre13b58e2017-08-31 14:50:44 -07001000 {"nativeDeferTransactionUntil", "(JJLandroid/os/IBinder;J)V",
Rob Carr64e516f2015-10-29 00:20:45 +00001001 (void*)nativeDeferTransactionUntil },
Robert Carre13b58e2017-08-31 14:50:44 -07001002 {"nativeDeferTransactionUntilSurface", "(JJJJ)V",
Robert Carrd5c7dd62017-03-08 10:39:30 -08001003 (void*)nativeDeferTransactionUntilSurface },
Robert Carre13b58e2017-08-31 14:50:44 -07001004 {"nativeReparentChildren", "(JJLandroid/os/IBinder;)V",
Robert Carrd5c7dd62017-03-08 10:39:30 -08001005 (void*)nativeReparentChildren } ,
Robert Carre13b58e2017-08-31 14:50:44 -07001006 {"nativeReparent", "(JJLandroid/os/IBinder;)V",
chaviw76431402017-09-18 16:50:05 -07001007 (void*)nativeReparent },
Robert Carre13b58e2017-08-31 14:50:44 -07001008 {"nativeSeverChildren", "(JJ)V",
Robert Carrd5c7dd62017-03-08 10:39:30 -08001009 (void*)nativeSeverChildren } ,
Robert Carre13b58e2017-08-31 14:50:44 -07001010 {"nativeSetOverrideScalingMode", "(JJI)V",
Robert Carr1ca6a332016-04-11 18:00:43 -07001011 (void*)nativeSetOverrideScalingMode },
Chavi Weingartenb736e322018-02-23 00:27:54 +00001012 {"nativeDestroy", "(JJ)V",
1013 (void*)nativeDestroyInTransaction },
Rob Carr64e516f2015-10-29 00:20:45 +00001014 {"nativeGetHandle", "(J)Landroid/os/IBinder;",
Robert Carr6da3cc02016-06-16 15:17:07 -07001015 (void*)nativeGetHandle },
Robert Carr6486d312017-01-09 19:48:29 -08001016 {"nativeScreenshotToBuffer",
1017 "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/GraphicBuffer;",
1018 (void*)nativeScreenshotToBuffer },
Chavi Weingartenea2eb5a2017-11-29 21:26:24 +00001019 {"nativeCaptureLayers", "(Landroid/os/IBinder;Landroid/graphics/Rect;F)Landroid/graphics/GraphicBuffer;",
Chavi Weingartend7ec64c2017-11-30 01:52:01 +00001020 (void*)nativeCaptureLayers },
Mathias Agopian3866f0d2013-02-11 22:08:48 -08001021};
1022
1023int register_android_view_SurfaceControl(JNIEnv* env)
1024{
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001025 int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl",
Mathias Agopian3866f0d2013-02-11 22:08:48 -08001026 sSurfaceControlMethods, NELEM(sSurfaceControlMethods));
1027
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001028 jclass clazz = FindClassOrDie(env, "android/view/SurfaceControl$PhysicalDisplayInfo");
1029 gPhysicalDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, clazz);
1030 gPhysicalDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env,
1031 gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V");
1032 gPhysicalDisplayInfoClassInfo.width = GetFieldIDOrDie(env, clazz, "width", "I");
1033 gPhysicalDisplayInfoClassInfo.height = GetFieldIDOrDie(env, clazz, "height", "I");
1034 gPhysicalDisplayInfoClassInfo.refreshRate = GetFieldIDOrDie(env, clazz, "refreshRate", "F");
1035 gPhysicalDisplayInfoClassInfo.density = GetFieldIDOrDie(env, clazz, "density", "F");
1036 gPhysicalDisplayInfoClassInfo.xDpi = GetFieldIDOrDie(env, clazz, "xDpi", "F");
1037 gPhysicalDisplayInfoClassInfo.yDpi = GetFieldIDOrDie(env, clazz, "yDpi", "F");
1038 gPhysicalDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, clazz, "secure", "Z");
1039 gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env,
1040 clazz, "appVsyncOffsetNanos", "J");
1041 gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env,
1042 clazz, "presentationDeadlineNanos", "J");
Svetoslav1376d602014-03-13 11:17:26 -07001043
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001044 jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect");
1045 gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I");
1046 gRectClassInfo.left = GetFieldIDOrDie(env, rectClazz, "left", "I");
1047 gRectClassInfo.right = GetFieldIDOrDie(env, rectClazz, "right", "I");
1048 gRectClassInfo.top = GetFieldIDOrDie(env, rectClazz, "top", "I");
Dan Stoza9890e3412014-05-22 16:12:54 -07001049
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001050 jclass frameStatsClazz = FindClassOrDie(env, "android/view/FrameStats");
1051 jfieldID undefined_time_nano_field = GetStaticFieldIDOrDie(env,
1052 frameStatsClazz, "UNDEFINED_TIME_NANO", "J");
Svetoslav1376d602014-03-13 11:17:26 -07001053 nsecs_t undefined_time_nano = env->GetStaticLongField(frameStatsClazz, undefined_time_nano_field);
1054
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001055 jclass contFrameStatsClazz = FindClassOrDie(env, "android/view/WindowContentFrameStats");
1056 gWindowContentFrameStatsClassInfo.init = GetMethodIDOrDie(env,
1057 contFrameStatsClazz, "init", "(J[J[J[J)V");
Svetoslav1376d602014-03-13 11:17:26 -07001058 gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano;
1059
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001060 jclass animFrameStatsClazz = FindClassOrDie(env, "android/view/WindowAnimationFrameStats");
1061 gWindowAnimationFrameStatsClassInfo.init = GetMethodIDOrDie(env,
1062 animFrameStatsClazz, "init", "(J[J)V");
Svetoslav1376d602014-03-13 11:17:26 -07001063 gWindowAnimationFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano;
1064
Hangyu Kuang54ac2192016-04-25 13:22:02 -07001065 jclass hdrCapabilitiesClazz = FindClassOrDie(env, "android/view/Display$HdrCapabilities");
1066 gHdrCapabilitiesClassInfo.clazz = MakeGlobalRefOrDie(env, hdrCapabilitiesClazz);
1067 gHdrCapabilitiesClassInfo.ctor = GetMethodIDOrDie(env, hdrCapabilitiesClazz, "<init>",
1068 "([IFFF)V");
1069
Robert Carr6486d312017-01-09 19:48:29 -08001070 jclass graphicsBufferClazz = FindClassOrDie(env, "android/graphics/GraphicBuffer");
1071 gGraphicBufferClassInfo.clazz = MakeGlobalRefOrDie(env, graphicsBufferClazz);
1072 gGraphicBufferClassInfo.builder = GetStaticMethodIDOrDie(env, graphicsBufferClazz,
1073 "createFromExisting", "(IIIIJ)Landroid/graphics/GraphicBuffer;");
1074
Mathias Agopian3866f0d2013-02-11 22:08:48 -08001075 return err;
1076}
1077
1078};