blob: ef3c91d230aaa0af3cc07848ff1f193627d3d5fc [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);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800118 sp<SurfaceControl> surface = client->createSurface(
Albert Chaulk3bf2e572016-11-22 13:59:19 -0500119 String8(name.c_str()), w, h, format, flags, parent, windowType, ownerUid);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800120 if (surface == NULL) {
121 jniThrowException(env, OutOfResourcesException, NULL);
122 return 0;
123 }
Albert Chaulk3bf2e572016-11-22 13:59:19 -0500124
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800125 surface->incStrong((void *)nativeCreate);
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000126 return reinterpret_cast<jlong>(surface.get());
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800127}
128
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000129static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800130 sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800131 ctrl->decStrong((void *)nativeCreate);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800132}
133
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000134static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800135 sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
136 ctrl->clear();
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800137 ctrl->decStrong((void *)nativeCreate);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800138}
139
Chong Zhang47e36a32016-02-29 16:44:33 -0800140static void nativeDisconnect(JNIEnv* env, jclass clazz, jlong nativeObject) {
141 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
142 if (ctrl != NULL) {
143 ctrl->disconnect();
144 }
145}
146
Robert Carr6486d312017-01-09 19:48:29 -0800147static Rect rectFromObj(JNIEnv* env, jobject rectObj) {
148 int left = env->GetIntField(rectObj, gRectClassInfo.left);
149 int top = env->GetIntField(rectObj, gRectClassInfo.top);
150 int right = env->GetIntField(rectObj, gRectClassInfo.right);
151 int bottom = env->GetIntField(rectObj, gRectClassInfo.bottom);
152 return Rect(left, top, right, bottom);
153}
154
155static jobject nativeScreenshotToBuffer(JNIEnv* env, jclass clazz,
156 jobject displayTokenObj, jobject sourceCropObj, jint width, jint height,
157 jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform,
158 int rotation) {
159 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
160 if (displayToken == NULL) {
161 return NULL;
162 }
163 Rect sourceCrop = rectFromObj(env, sourceCropObj);
164 if (allLayers) {
Robert Carrfb09bcf2017-01-26 11:52:35 -0800165 minLayer = INT32_MIN;
166 maxLayer = INT32_MAX;
Robert Carr6486d312017-01-09 19:48:29 -0800167 }
168 sp<GraphicBuffer> buffer;
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000169 status_t res = ScreenshotClient::capture(displayToken,
Robert Carr6486d312017-01-09 19:48:29 -0800170 sourceCrop, width, height, minLayer, maxLayer, useIdentityTransform,
171 rotation, &buffer);
172 if (res != NO_ERROR) {
173 return NULL;
174 }
175
176 return env->CallStaticObjectMethod(gGraphicBufferClassInfo.clazz,
177 gGraphicBufferClassInfo.builder,
178 buffer->getWidth(),
179 buffer->getHeight(),
180 buffer->getPixelFormat(),
Mathias Agopian113fd302017-05-25 18:31:04 -0700181 (jint)buffer->getUsage(),
Patrik Torstensson511a8082017-03-27 15:04:11 +0100182 (jlong)buffer.get());
Robert Carr6486d312017-01-09 19:48:29 -0800183}
184
Dan Stoza9890e3412014-05-22 16:12:54 -0700185static jobject nativeScreenshotBitmap(JNIEnv* env, jclass clazz,
186 jobject displayTokenObj, jobject sourceCropObj, jint width, jint height,
Riley Andrews1d134062014-08-21 15:47:07 -0700187 jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform,
188 int rotation) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800189 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
190 if (displayToken == NULL) {
191 return NULL;
192 }
193
Robert Carr6486d312017-01-09 19:48:29 -0800194 Rect sourceCrop = rectFromObj(env, sourceCropObj);
Dan Stoza9890e3412014-05-22 16:12:54 -0700195
Ben Wagner60126ef2015-08-07 12:13:48 -0400196 std::unique_ptr<ScreenshotClient> screenshot(new ScreenshotClient());
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500197 status_t res;
Riley Andrews1d134062014-08-21 15:47:07 -0700198 if (allLayers) {
Robert Carrfb09bcf2017-01-26 11:52:35 -0800199 minLayer = INT32_MIN;
200 maxLayer = INT32_MAX;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500201 }
Riley Andrews1d134062014-08-21 15:47:07 -0700202
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000203 sp<GraphicBuffer> buffer;
204 res = ScreenshotClient::capture(displayToken, sourceCrop, width, height,
205 minLayer, maxLayer, useIdentityTransform, static_cast<uint32_t>(rotation), &buffer);
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500206 if (res != NO_ERROR) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800207 return NULL;
208 }
209
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400210 SkColorType colorType;
211 SkAlphaType alphaType;
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000212
213 PixelFormat format = buffer->getPixelFormat();
214 switch (format) {
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500215 case PIXEL_FORMAT_RGBX_8888: {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400216 colorType = kRGBA_8888_SkColorType;
217 alphaType = kOpaque_SkAlphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500218 break;
219 }
220 case PIXEL_FORMAT_RGBA_8888: {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400221 colorType = kRGBA_8888_SkColorType;
222 alphaType = kPremul_SkAlphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500223 break;
224 }
Romain Guy9505a652016-12-14 09:43:50 -0800225 case PIXEL_FORMAT_RGBA_FP16: {
226 colorType = kRGBA_F16_SkColorType;
227 alphaType = kPremul_SkAlphaType;
228 break;
229 }
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500230 case PIXEL_FORMAT_RGB_565: {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400231 colorType = kRGB_565_SkColorType;
232 alphaType = kOpaque_SkAlphaType;
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500233 break;
234 }
235 default: {
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500236 return NULL;
237 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800238 }
Romain Guy26a2b972017-04-17 09:39:51 -0700239
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000240 SkImageInfo info = SkImageInfo::Make(buffer->getWidth(), buffer->getHeight(),
241 colorType, alphaType,
242 SkColorSpace::MakeSRGB());
Romain Guy26a2b972017-04-17 09:39:51 -0700243
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000244 auto bitmap = sk_sp<Bitmap>(new Bitmap(buffer.get(), info));
245 return bitmap::createBitmap(env, bitmap.release(),
246 android::bitmap::kBitmapCreateFlag_Premultiplied, NULL);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800247}
248
Dan Stoza9890e3412014-05-22 16:12:54 -0700249static void nativeScreenshot(JNIEnv* env, jclass clazz, jobject displayTokenObj,
250 jobject surfaceObj, jobject sourceCropObj, jint width, jint height,
251 jint minLayer, jint maxLayer, bool allLayers, bool useIdentityTransform) {
Mathias Agopian0449a402013-03-01 23:01:51 -0800252 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000253 if (displayToken == NULL) {
chaviw1cda84c2017-10-23 16:47:10 -0700254 return;
255 }
256
257 sp<Surface> consumer = android_view_Surface_getSurface(env, surfaceObj);
258 if (consumer == NULL) {
259 return;
260 }
261
chaviwfbe47df2017-11-10 16:14:49 -0800262 Rect sourceCrop;
263 if (sourceCropObj != NULL) {
264 sourceCrop = rectFromObj(env, sourceCropObj);
265 }
266
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000267 if (allLayers) {
268 minLayer = INT32_MIN;
269 maxLayer = INT32_MAX;
270 }
271
272 sp<GraphicBuffer> buffer;
273 ScreenshotClient::capture(displayToken, sourceCrop, width, height, minLayer, maxLayer,
274 useIdentityTransform, 0, &buffer);
275
276 Surface::attachAndQueueBuffer(consumer.get(), buffer);
chaviwfbe47df2017-11-10 16:14:49 -0800277}
278
Chavi Weingartend7ec64c2017-11-30 01:52:01 +0000279static jobject nativeCaptureLayers(JNIEnv* env, jclass clazz, jobject layerHandleToken,
chaviwfbe47df2017-11-10 16:14:49 -0800280 jobject sourceCropObj, jfloat frameScale) {
281
282 sp<IBinder> layerHandle = ibinderForJavaObject(env, layerHandleToken);
283 if (layerHandle == NULL) {
284 return NULL;
285 }
286
287 Rect sourceCrop;
288 if (sourceCropObj != NULL) {
289 sourceCrop = rectFromObj(env, sourceCropObj);
290 }
291
292 sp<GraphicBuffer> buffer;
Robert Carrd87f3cf2018-03-07 14:08:09 -0800293 status_t res = ScreenshotClient::captureChildLayers(layerHandle, sourceCrop, frameScale, &buffer);
chaviwfbe47df2017-11-10 16:14:49 -0800294 if (res != NO_ERROR) {
295 return NULL;
296 }
297
298 return env->CallStaticObjectMethod(gGraphicBufferClassInfo.clazz,
299 gGraphicBufferClassInfo.builder,
300 buffer->getWidth(),
301 buffer->getHeight(),
302 buffer->getPixelFormat(),
303 (jint)buffer->getUsage(),
304 (jlong)buffer.get());
chaviw1cda84c2017-10-23 16:47:10 -0700305}
306
Robert Carre13b58e2017-08-31 14:50:44 -0700307static void nativeApplyTransaction(JNIEnv* env, jclass clazz, jlong transactionObj, jboolean sync) {
308 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
309 transaction->apply(sync);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800310}
311
Robert Carrb1579c82017-09-05 14:54:47 -0700312static void nativeMergeTransaction(JNIEnv* env, jclass clazz,
313 jlong transactionObj, jlong otherTransactionObj) {
314 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
315 auto otherTransaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(
316 otherTransactionObj);
317 transaction->merge(std::move(*otherTransaction));
318}
319
Robert Carre13b58e2017-08-31 14:50:44 -0700320static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz, jlong transactionObj) {
321 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
322 transaction->setAnimationTransaction();
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800323}
324
Robert Carre13b58e2017-08-31 14:50:44 -0700325static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong transactionObj,
326 jlong nativeObject, jint zorder) {
327 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800328
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800329 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700330 transaction->setLayer(ctrl, zorder);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800331}
332
Robert Carre13b58e2017-08-31 14:50:44 -0700333static void nativeSetRelativeLayer(JNIEnv* env, jclass clazz, jlong transactionObj,
334 jlong nativeObject,
Robert Carraf422a82017-04-10 18:34:33 -0700335 jobject relativeTo, jint zorder) {
Robert Carre13b58e2017-08-31 14:50:44 -0700336
Robert Carraf422a82017-04-10 18:34:33 -0700337 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
338 sp<IBinder> handle = ibinderForJavaObject(env, relativeTo);
339
Robert Carre13b58e2017-08-31 14:50:44 -0700340 {
341 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
342 transaction->setRelativeLayer(ctrl, handle, zorder);
343 }
Robert Carraf422a82017-04-10 18:34:33 -0700344}
345
Robert Carre13b58e2017-08-31 14:50:44 -0700346static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong transactionObj,
347 jlong nativeObject, jfloat x, jfloat y) {
348 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
349
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800350 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700351 transaction->setPosition(ctrl, x, y);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800352}
353
Robert Carr6da3cc02016-06-16 15:17:07 -0700354static void nativeSetGeometryAppliesWithResize(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700355jlong transactionObj,
Robert Carra9408d42016-06-03 13:28:48 -0700356 jlong nativeObject) {
Robert Carre13b58e2017-08-31 14:50:44 -0700357 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
358
Robert Carra9408d42016-06-03 13:28:48 -0700359 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700360 transaction->setGeometryAppliesWithResize(ctrl);
Robert Carra9408d42016-06-03 13:28:48 -0700361}
362
Robert Carre13b58e2017-08-31 14:50:44 -0700363static void nativeSetSize(JNIEnv* env, jclass clazz, jlong transactionObj,
364 jlong nativeObject, jint w, jint h) {
365 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
366
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800367 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700368 transaction->setSize(ctrl, w, h);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800369}
370
Robert Carre13b58e2017-08-31 14:50:44 -0700371static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong transactionObj,
372 jlong nativeObject, jint flags, jint mask) {
373 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
374
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800375 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700376 transaction->setFlags(ctrl, flags, mask);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800377}
378
Robert Carre13b58e2017-08-31 14:50:44 -0700379static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong transactionObj,
380 jlong nativeObject, jobject regionObj) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800381 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
382 SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj);
383 if (!region) {
384 doThrowIAE(env);
385 return;
386 }
387
388 const SkIRect& b(region->getBounds());
389 Region reg(Rect(b.fLeft, b.fTop, b.fRight, b.fBottom));
390 if (region->isComplex()) {
391 SkRegion::Iterator it(*region);
392 while (!it.done()) {
393 const SkIRect& r(it.rect());
394 reg.addRectUnchecked(r.fLeft, r.fTop, r.fRight, r.fBottom);
395 it.next();
396 }
397 }
398
Robert Carre13b58e2017-08-31 14:50:44 -0700399 {
400 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
401 transaction->setTransparentRegionHint(ctrl, reg);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800402 }
403}
404
Robert Carre13b58e2017-08-31 14:50:44 -0700405static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong transactionObj,
406 jlong nativeObject, jfloat alpha) {
407 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
408
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800409 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700410 transaction->setAlpha(ctrl, alpha);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800411}
412
Robert Carre13b58e2017-08-31 14:50:44 -0700413static void nativeSetColor(JNIEnv* env, jclass clazz, jlong transactionObj,
414 jlong nativeObject, jfloatArray fColor) {
415 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
chaviw0dd03f52017-08-25 12:15:26 -0700416 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700417
chaviw0dd03f52017-08-25 12:15:26 -0700418 float* floatColors = env->GetFloatArrayElements(fColor, 0);
419 half3 color(floatColors[0], floatColors[1], floatColors[2]);
Robert Carre13b58e2017-08-31 14:50:44 -0700420 transaction->setColor(ctrl, color);
chaviw0dd03f52017-08-25 12:15:26 -0700421}
422
Robert Carre13b58e2017-08-31 14:50:44 -0700423static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong transactionObj,
424 jlong nativeObject,
Robert Carr0edf18f2017-02-21 20:01:47 -0800425 jfloat dsdx, jfloat dtdx, jfloat dtdy, jfloat dsdy) {
Robert Carre13b58e2017-08-31 14:50:44 -0700426 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
427
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800428 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700429 transaction->setMatrix(ctrl, dsdx, dtdx, dtdy, dsdy);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800430}
431
Robert Carre13b58e2017-08-31 14:50:44 -0700432static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong transactionObj,
433 jlong nativeObject,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800434 jint l, jint t, jint r, jint b) {
Robert Carre13b58e2017-08-31 14:50:44 -0700435 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
436
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800437 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
438 Rect crop(l, t, r, b);
Robert Carre13b58e2017-08-31 14:50:44 -0700439 transaction->setCrop(ctrl, crop);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800440}
441
Robert Carre13b58e2017-08-31 14:50:44 -0700442static void nativeSetFinalCrop(JNIEnv* env, jclass clazz, jlong transactionObj,
443 jlong nativeObject,
Pablo Ceballos27982e62016-03-09 10:50:45 -0800444 jint l, jint t, jint r, jint b) {
Robert Carre13b58e2017-08-31 14:50:44 -0700445 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
446
Pablo Ceballos27982e62016-03-09 10:50:45 -0800447 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
448 Rect crop(l, t, r, b);
Robert Carre13b58e2017-08-31 14:50:44 -0700449 transaction->setFinalCrop(ctrl, crop);
Pablo Ceballos27982e62016-03-09 10:50:45 -0800450}
451
Robert Carre13b58e2017-08-31 14:50:44 -0700452static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong transactionObj,
453 jlong nativeObject, jint layerStack) {
454 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
455
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800456 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700457 transaction->setLayerStack(ctrl, layerStack);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800458}
459
460static jobject nativeGetBuiltInDisplay(JNIEnv* env, jclass clazz, jint id) {
461 sp<IBinder> token(SurfaceComposerClient::getBuiltInDisplay(id));
462 return javaObjectForIBinder(env, token);
463}
464
465static jobject nativeCreateDisplay(JNIEnv* env, jclass clazz, jstring nameObj,
466 jboolean secure) {
467 ScopedUtfChars name(env, nameObj);
468 sp<IBinder> token(SurfaceComposerClient::createDisplay(
469 String8(name.c_str()), bool(secure)));
470 return javaObjectForIBinder(env, token);
471}
472
Jesse Hall6a6bc212013-08-08 12:15:03 -0700473static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) {
474 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
475 if (token == NULL) return;
476 SurfaceComposerClient::destroyDisplay(token);
477}
478
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800479static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700480 jlong transactionObj,
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000481 jobject tokenObj, jlong nativeSurfaceObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800482 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
483 if (token == NULL) return;
Mathias Agopianffddc9b2013-02-25 15:56:31 -0800484 sp<IGraphicBufferProducer> bufferProducer;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800485 sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject));
Mathias Agopianffddc9b2013-02-25 15:56:31 -0800486 if (sur != NULL) {
487 bufferProducer = sur->getIGraphicBufferProducer();
488 }
Robert Carre13b58e2017-08-31 14:50:44 -0700489
490
491 status_t err = NO_ERROR;
492 {
493 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
494 err = transaction->setDisplaySurface(token,
495 bufferProducer);
496 }
Pablo Ceballosaff2f942016-07-29 14:49:55 -0700497 if (err != NO_ERROR) {
498 doThrowIAE(env, "Illegal Surface, could not enable async mode. Was this"
499 " Surface created with singleBufferMode?");
500 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800501}
502
503static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700504 jlong transactionObj,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800505 jobject tokenObj, jint layerStack) {
Robert Carre13b58e2017-08-31 14:50:44 -0700506
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800507 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
508 if (token == NULL) return;
509
Robert Carre13b58e2017-08-31 14:50:44 -0700510 {
511 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
512 transaction->setDisplayLayerStack(token, layerStack);
513 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800514}
515
516static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700517 jlong transactionObj,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800518 jobject tokenObj, jint orientation,
519 jint layerStackRect_left, jint layerStackRect_top, jint layerStackRect_right, jint layerStackRect_bottom,
520 jint displayRect_left, jint displayRect_top, jint displayRect_right, jint displayRect_bottom) {
521 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
522 if (token == NULL) return;
523 Rect layerStackRect(layerStackRect_left, layerStackRect_top, layerStackRect_right, layerStackRect_bottom);
524 Rect displayRect(displayRect_left, displayRect_top, displayRect_right, displayRect_bottom);
Robert Carre13b58e2017-08-31 14:50:44 -0700525
526 {
527 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
528 transaction->setDisplayProjection(token, orientation, layerStackRect, displayRect);
529 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800530}
531
Michael Wright01e840f2014-06-26 16:03:25 -0700532static void nativeSetDisplaySize(JNIEnv* env, jclass clazz,
Robert Carre13b58e2017-08-31 14:50:44 -0700533 jlong transactionObj,
Michael Wright01e840f2014-06-26 16:03:25 -0700534 jobject tokenObj, jint width, jint height) {
535 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
536 if (token == NULL) return;
Robert Carre13b58e2017-08-31 14:50:44 -0700537
538 {
539 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
540 transaction->setDisplaySize(token, width, height);
541 }
Michael Wright01e840f2014-06-26 16:03:25 -0700542}
543
Dan Stoza00101052014-05-02 15:23:40 -0700544static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz,
545 jobject tokenObj) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800546 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
Dan Stoza00101052014-05-02 15:23:40 -0700547 if (token == NULL) return NULL;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800548
Dan Stoza00101052014-05-02 15:23:40 -0700549 Vector<DisplayInfo> configs;
550 if (SurfaceComposerClient::getDisplayConfigs(token, &configs) != NO_ERROR ||
551 configs.size() == 0) {
552 return NULL;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800553 }
554
Dan Stoza00101052014-05-02 15:23:40 -0700555 jobjectArray configArray = env->NewObjectArray(configs.size(),
556 gPhysicalDisplayInfoClassInfo.clazz, NULL);
557
558 for (size_t c = 0; c < configs.size(); ++c) {
559 const DisplayInfo& info = configs[c];
560 jobject infoObj = env->NewObject(gPhysicalDisplayInfoClassInfo.clazz,
561 gPhysicalDisplayInfoClassInfo.ctor);
562 env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w);
563 env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h);
564 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps);
565 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.density, info.density);
566 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi);
567 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi);
568 env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure);
Andy McFaddene8b1aeb2014-06-13 14:05:40 -0700569 env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos,
570 info.appVsyncOffset);
571 env->SetLongField(infoObj, gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos,
572 info.presentationDeadline);
Dan Stoza00101052014-05-02 15:23:40 -0700573 env->SetObjectArrayElement(configArray, static_cast<jsize>(c), infoObj);
574 env->DeleteLocalRef(infoObj);
575 }
576
577 return configArray;
578}
579
580static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) {
581 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
582 if (token == NULL) return -1;
583 return static_cast<jint>(SurfaceComposerClient::getActiveConfig(token));
584}
585
586static jboolean nativeSetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj, jint id) {
587 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
588 if (token == NULL) return JNI_FALSE;
589 status_t err = SurfaceComposerClient::setActiveConfig(token, static_cast<int>(id));
590 return err == NO_ERROR ? JNI_TRUE : JNI_FALSE;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800591}
592
Michael Wright1c9977b2016-07-12 13:30:10 -0700593static jintArray nativeGetDisplayColorModes(JNIEnv* env, jclass, jobject tokenObj) {
594 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
595 if (token == NULL) return NULL;
596 Vector<android_color_mode_t> colorModes;
597 if (SurfaceComposerClient::getDisplayColorModes(token, &colorModes) != NO_ERROR ||
598 colorModes.isEmpty()) {
599 return NULL;
600 }
601
602 jintArray colorModesArray = env->NewIntArray(colorModes.size());
603 if (colorModesArray == NULL) {
604 jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
605 return NULL;
606 }
607 jint* colorModesArrayValues = env->GetIntArrayElements(colorModesArray, 0);
608 for (size_t i = 0; i < colorModes.size(); i++) {
609 colorModesArrayValues[i] = static_cast<jint>(colorModes[i]);
610 }
611 env->ReleaseIntArrayElements(colorModesArray, colorModesArrayValues, 0);
612 return colorModesArray;
613}
614
615static jint nativeGetActiveColorMode(JNIEnv* env, jclass, jobject tokenObj) {
616 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
617 if (token == NULL) return -1;
618 return static_cast<jint>(SurfaceComposerClient::getActiveColorMode(token));
619}
620
621static jboolean nativeSetActiveColorMode(JNIEnv* env, jclass,
622 jobject tokenObj, jint colorMode) {
623 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
624 if (token == NULL) return JNI_FALSE;
625 status_t err = SurfaceComposerClient::setActiveColorMode(token,
626 static_cast<android_color_mode_t>(colorMode));
627 return err == NO_ERROR ? JNI_TRUE : JNI_FALSE;
628}
629
Prashant Malanic55929a2014-05-25 01:59:21 -0700630static void nativeSetDisplayPowerMode(JNIEnv* env, jclass clazz, jobject tokenObj, jint mode) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800631 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
632 if (token == NULL) return;
633
Tom Cherry8ed74bb2017-07-10 14:31:18 -0700634 android::base::Timer t;
Prashant Malanic55929a2014-05-25 01:59:21 -0700635 SurfaceComposerClient::setDisplayPowerMode(token, mode);
Tom Cherry8ed74bb2017-07-10 14:31:18 -0700636 if (t.duration() > 100ms) ALOGD("Excessive delay in setPowerMode()");
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800637}
638
Svetoslav1376d602014-03-13 11:17:26 -0700639static jboolean nativeClearContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject) {
640 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
641 status_t err = ctrl->clearLayerFrameStats();
642
643 if (err < 0 && err != NO_INIT) {
644 doThrowIAE(env);
645 }
646
647 // The other end is not ready, just report we failed.
648 if (err == NO_INIT) {
649 return JNI_FALSE;
650 }
651
652 return JNI_TRUE;
653}
654
655static jboolean nativeGetContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject,
656 jobject outStats) {
657 FrameStats stats;
658
659 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
660 status_t err = ctrl->getLayerFrameStats(&stats);
661 if (err < 0 && err != NO_INIT) {
662 doThrowIAE(env);
663 }
664
665 // The other end is not ready, fine just return empty stats.
666 if (err == NO_INIT) {
667 return JNI_FALSE;
668 }
669
670 jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano);
671 size_t frameCount = stats.desiredPresentTimesNano.size();
672
673 jlongArray postedTimesNanoDst = env->NewLongArray(frameCount);
674 if (postedTimesNanoDst == NULL) {
675 return JNI_FALSE;
676 }
677
678 jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount);
679 if (presentedTimesNanoDst == NULL) {
680 return JNI_FALSE;
681 }
682
683 jlongArray readyTimesNanoDst = env->NewLongArray(frameCount);
684 if (readyTimesNanoDst == NULL) {
685 return JNI_FALSE;
686 }
687
688 nsecs_t postedTimesNanoSrc[frameCount];
689 nsecs_t presentedTimesNanoSrc[frameCount];
690 nsecs_t readyTimesNanoSrc[frameCount];
691
692 for (size_t i = 0; i < frameCount; i++) {
693 nsecs_t postedTimeNano = stats.desiredPresentTimesNano[i];
694 if (postedTimeNano == INT64_MAX) {
695 postedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
696 }
697 postedTimesNanoSrc[i] = postedTimeNano;
698
699 nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i];
700 if (presentedTimeNano == INT64_MAX) {
701 presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
702 }
703 presentedTimesNanoSrc[i] = presentedTimeNano;
704
705 nsecs_t readyTimeNano = stats.frameReadyTimesNano[i];
706 if (readyTimeNano == INT64_MAX) {
707 readyTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
708 }
709 readyTimesNanoSrc[i] = readyTimeNano;
710 }
711
712 env->SetLongArrayRegion(postedTimesNanoDst, 0, frameCount, postedTimesNanoSrc);
713 env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc);
714 env->SetLongArrayRegion(readyTimesNanoDst, 0, frameCount, readyTimesNanoSrc);
715
716 env->CallVoidMethod(outStats, gWindowContentFrameStatsClassInfo.init, refreshPeriodNano,
717 postedTimesNanoDst, presentedTimesNanoDst, readyTimesNanoDst);
718
719 if (env->ExceptionCheck()) {
720 return JNI_FALSE;
721 }
722
723 return JNI_TRUE;
724}
725
726static jboolean nativeClearAnimationFrameStats(JNIEnv* env, jclass clazz) {
727 status_t err = SurfaceComposerClient::clearAnimationFrameStats();
728
729 if (err < 0 && err != NO_INIT) {
730 doThrowIAE(env);
731 }
732
733 // The other end is not ready, just report we failed.
734 if (err == NO_INIT) {
735 return JNI_FALSE;
736 }
737
738 return JNI_TRUE;
739}
740
741static jboolean nativeGetAnimationFrameStats(JNIEnv* env, jclass clazz, jobject outStats) {
742 FrameStats stats;
743
744 status_t err = SurfaceComposerClient::getAnimationFrameStats(&stats);
745 if (err < 0 && err != NO_INIT) {
746 doThrowIAE(env);
747 }
748
749 // The other end is not ready, fine just return empty stats.
750 if (err == NO_INIT) {
751 return JNI_FALSE;
752 }
753
754 jlong refreshPeriodNano = static_cast<jlong>(stats.refreshPeriodNano);
755 size_t frameCount = stats.desiredPresentTimesNano.size();
756
757 jlongArray presentedTimesNanoDst = env->NewLongArray(frameCount);
758 if (presentedTimesNanoDst == NULL) {
759 return JNI_FALSE;
760 }
761
762 nsecs_t presentedTimesNanoSrc[frameCount];
763
764 for (size_t i = 0; i < frameCount; i++) {
Allen Hairac5eda32014-04-24 11:50:37 -0700765 nsecs_t presentedTimeNano = stats.actualPresentTimesNano[i];
Svetoslav1376d602014-03-13 11:17:26 -0700766 if (presentedTimeNano == INT64_MAX) {
767 presentedTimeNano = gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO;
768 }
769 presentedTimesNanoSrc[i] = presentedTimeNano;
770 }
771
772 env->SetLongArrayRegion(presentedTimesNanoDst, 0, frameCount, presentedTimesNanoSrc);
773
774 env->CallVoidMethod(outStats, gWindowAnimationFrameStatsClassInfo.init, refreshPeriodNano,
775 presentedTimesNanoDst);
776
777 if (env->ExceptionCheck()) {
778 return JNI_FALSE;
779 }
780
781 return JNI_TRUE;
782}
783
Robert Carre13b58e2017-08-31 14:50:44 -0700784static void nativeDeferTransactionUntil(JNIEnv* env, jclass clazz, jlong transactionObj,
785 jlong nativeObject,
Rob Carr64e516f2015-10-29 00:20:45 +0000786 jobject handleObject, jlong frameNumber) {
787 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
788 sp<IBinder> handle = ibinderForJavaObject(env, handleObject);
789
Robert Carre13b58e2017-08-31 14:50:44 -0700790 {
791 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
792 transaction->deferTransactionUntil(ctrl, handle, frameNumber);
793 }
Rob Carr64e516f2015-10-29 00:20:45 +0000794}
795
Robert Carre13b58e2017-08-31 14:50:44 -0700796static void nativeDeferTransactionUntilSurface(JNIEnv* env, jclass clazz, jlong transactionObj,
797 jlong nativeObject,
Robert Carrd5c7dd62017-03-08 10:39:30 -0800798 jlong surfaceObject, jlong frameNumber) {
Robert Carre13b58e2017-08-31 14:50:44 -0700799 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
800
Robert Carrd5c7dd62017-03-08 10:39:30 -0800801 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
802 sp<Surface> barrier = reinterpret_cast<Surface *>(surfaceObject);
803
Robert Carre13b58e2017-08-31 14:50:44 -0700804 transaction->deferTransactionUntil(ctrl, barrier, frameNumber);
Robert Carrd5c7dd62017-03-08 10:39:30 -0800805}
806
Robert Carre13b58e2017-08-31 14:50:44 -0700807static void nativeReparentChildren(JNIEnv* env, jclass clazz, jlong transactionObj,
808 jlong nativeObject,
Robert Carrd5c7dd62017-03-08 10:39:30 -0800809 jobject newParentObject) {
Robert Carre13b58e2017-08-31 14:50:44 -0700810
Robert Carrd5c7dd62017-03-08 10:39:30 -0800811 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
812 sp<IBinder> handle = ibinderForJavaObject(env, newParentObject);
813
Robert Carre13b58e2017-08-31 14:50:44 -0700814 {
815 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
816 transaction->reparentChildren(ctrl, handle);
817 }
Robert Carrd5c7dd62017-03-08 10:39:30 -0800818}
819
Robert Carre13b58e2017-08-31 14:50:44 -0700820static void nativeReparent(JNIEnv* env, jclass clazz, jlong transactionObj,
821 jlong nativeObject,
chaviw76431402017-09-18 16:50:05 -0700822 jobject newParentObject) {
chaviw63542382017-08-17 17:39:29 -0700823 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
824 sp<IBinder> parentHandle = ibinderForJavaObject(env, newParentObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700825
826 {
827 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
828 transaction->reparent(ctrl, parentHandle);
829 }
chaviw63542382017-08-17 17:39:29 -0700830}
831
Robert Carre13b58e2017-08-31 14:50:44 -0700832static void nativeSeverChildren(JNIEnv* env, jclass clazz, jlong transactionObj,
833 jlong nativeObject) {
834 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
835
Robert Carrd5c7dd62017-03-08 10:39:30 -0800836 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Robert Carre13b58e2017-08-31 14:50:44 -0700837 transaction->detachChildren(ctrl);
Robert Carrd5c7dd62017-03-08 10:39:30 -0800838}
839
Robert Carre13b58e2017-08-31 14:50:44 -0700840static void nativeSetOverrideScalingMode(JNIEnv* env, jclass clazz, jlong transactionObj,
841 jlong nativeObject,
Robert Carr1ca6a332016-04-11 18:00:43 -0700842 jint scalingMode) {
Robert Carre13b58e2017-08-31 14:50:44 -0700843 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
Robert Carr1ca6a332016-04-11 18:00:43 -0700844
Robert Carre13b58e2017-08-31 14:50:44 -0700845 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
846 transaction->setOverrideScalingMode(ctrl, scalingMode);
Robert Carr1ca6a332016-04-11 18:00:43 -0700847}
848
Chavi Weingartenb736e322018-02-23 00:27:54 +0000849static void nativeDestroyInTransaction(JNIEnv* env, jclass clazz,
850 jlong transactionObj,
851 jlong nativeObject) {
852 auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
853 auto ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);
854 transaction->destroySurface(ctrl);
855}
856
Rob Carr64e516f2015-10-29 00:20:45 +0000857static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
858 auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
Rob Carr64e516f2015-10-29 00:20:45 +0000859 return javaObjectForIBinder(env, ctrl->getHandle());
860}
861
Hangyu Kuang54ac2192016-04-25 13:22:02 -0700862static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) {
863 sp<IBinder> token(ibinderForJavaObject(env, tokenObject));
864 if (token == NULL) return NULL;
865
866 HdrCapabilities capabilities;
867 SurfaceComposerClient::getHdrCapabilities(token, &capabilities);
868
869 const auto& types = capabilities.getSupportedHdrTypes();
870 auto typesArray = env->NewIntArray(types.size());
871 env->SetIntArrayRegion(typesArray, 0, types.size(), types.data());
872
Michael Wright9ff94c02016-03-30 18:05:40 -0700873 return env->NewObject(gHdrCapabilitiesClassInfo.clazz, gHdrCapabilitiesClassInfo.ctor,
Hangyu Kuang54ac2192016-04-25 13:22:02 -0700874 typesArray, capabilities.getDesiredMaxLuminance(),
875 capabilities.getDesiredMaxAverageLuminance(), capabilities.getDesiredMinLuminance());
876}
877
Jorim Jaggi06975df2017-12-01 14:52:13 +0100878static jlong nativeReadFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj) {
879 Parcel* parcel = parcelForJavaObject(env, parcelObj);
880 if (parcel == NULL) {
881 doThrowNPE(env);
882 return 0;
883 }
884 sp<SurfaceControl> surface = SurfaceControl::readFromParcel(parcel);
885 if (surface == nullptr) {
886 return 0;
887 }
888 surface->incStrong((void *)nativeCreate);
889 return reinterpret_cast<jlong>(surface.get());
890}
891
892static void nativeWriteToParcel(JNIEnv* env, jclass clazz,
893 jlong nativeObject, jobject parcelObj) {
894 Parcel* parcel = parcelForJavaObject(env, parcelObj);
895 if (parcel == NULL) {
896 doThrowNPE(env);
897 return;
898 }
899 SurfaceControl* const self = reinterpret_cast<SurfaceControl *>(nativeObject);
900 self->writeToParcel(parcel);
901}
902
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800903// ----------------------------------------------------------------------------
904
Daniel Micay76f6a862015-09-19 17:31:01 -0400905static const JNINativeMethod sSurfaceControlMethods[] = {
Albert Chaulk3bf2e572016-11-22 13:59:19 -0500906 {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIIIJII)J",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800907 (void*)nativeCreate },
Jorim Jaggi06975df2017-12-01 14:52:13 +0100908 {"nativeReadFromParcel", "(Landroid/os/Parcel;)J",
909 (void*)nativeReadFromParcel },
910 {"nativeWriteToParcel", "(JLandroid/os/Parcel;)V",
911 (void*)nativeWriteToParcel },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000912 {"nativeRelease", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800913 (void*)nativeRelease },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000914 {"nativeDestroy", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800915 (void*)nativeDestroy },
Chong Zhang47e36a32016-02-29 16:44:33 -0800916 {"nativeDisconnect", "(J)V",
917 (void*)nativeDisconnect },
Riley Andrews1d134062014-08-21 15:47:07 -0700918 {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/Bitmap;",
Mathias Agopian0449a402013-03-01 23:01:51 -0800919 (void*)nativeScreenshotBitmap },
Dan Stoza9890e3412014-05-22 16:12:54 -0700920 {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/view/Surface;Landroid/graphics/Rect;IIIIZZ)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800921 (void*)nativeScreenshot },
Robert Carre13b58e2017-08-31 14:50:44 -0700922 {"nativeCreateTransaction", "()J",
923 (void*)nativeCreateTransaction },
924 {"nativeApplyTransaction", "(JZ)V",
925 (void*)nativeApplyTransaction },
926 {"nativeGetNativeTransactionFinalizer", "()J",
927 (void*)nativeGetNativeTransactionFinalizer },
Robert Carrb1579c82017-09-05 14:54:47 -0700928 {"nativeMergeTransaction", "(JJ)V",
929 (void*)nativeMergeTransaction },
Robert Carre13b58e2017-08-31 14:50:44 -0700930 {"nativeSetAnimationTransaction", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800931 (void*)nativeSetAnimationTransaction },
Robert Carre13b58e2017-08-31 14:50:44 -0700932 {"nativeSetLayer", "(JJI)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800933 (void*)nativeSetLayer },
Robert Carre13b58e2017-08-31 14:50:44 -0700934 {"nativeSetRelativeLayer", "(JJLandroid/os/IBinder;I)V",
Robert Carraf422a82017-04-10 18:34:33 -0700935 (void*)nativeSetRelativeLayer },
Robert Carre13b58e2017-08-31 14:50:44 -0700936 {"nativeSetPosition", "(JJFF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800937 (void*)nativeSetPosition },
Robert Carre13b58e2017-08-31 14:50:44 -0700938 {"nativeSetGeometryAppliesWithResize", "(JJ)V",
Robert Carr6da3cc02016-06-16 15:17:07 -0700939 (void*)nativeSetGeometryAppliesWithResize },
Robert Carre13b58e2017-08-31 14:50:44 -0700940 {"nativeSetSize", "(JJII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800941 (void*)nativeSetSize },
Robert Carre13b58e2017-08-31 14:50:44 -0700942 {"nativeSetTransparentRegionHint", "(JJLandroid/graphics/Region;)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800943 (void*)nativeSetTransparentRegionHint },
Robert Carre13b58e2017-08-31 14:50:44 -0700944 {"nativeSetAlpha", "(JJF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800945 (void*)nativeSetAlpha },
Robert Carre13b58e2017-08-31 14:50:44 -0700946 {"nativeSetColor", "(JJ[F)V",
chaviw0dd03f52017-08-25 12:15:26 -0700947 (void*)nativeSetColor },
Robert Carre13b58e2017-08-31 14:50:44 -0700948 {"nativeSetMatrix", "(JJFFFF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800949 (void*)nativeSetMatrix },
Robert Carre13b58e2017-08-31 14:50:44 -0700950 {"nativeSetFlags", "(JJII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800951 (void*)nativeSetFlags },
Robert Carre13b58e2017-08-31 14:50:44 -0700952 {"nativeSetWindowCrop", "(JJIIII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800953 (void*)nativeSetWindowCrop },
Robert Carre13b58e2017-08-31 14:50:44 -0700954 {"nativeSetFinalCrop", "(JJIIII)V",
Pablo Ceballos27982e62016-03-09 10:50:45 -0800955 (void*)nativeSetFinalCrop },
Robert Carre13b58e2017-08-31 14:50:44 -0700956 {"nativeSetLayerStack", "(JJI)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800957 (void*)nativeSetLayerStack },
958 {"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;",
959 (void*)nativeGetBuiltInDisplay },
960 {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;",
961 (void*)nativeCreateDisplay },
Jesse Hall6a6bc212013-08-08 12:15:03 -0700962 {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V",
963 (void*)nativeDestroyDisplay },
Robert Carre13b58e2017-08-31 14:50:44 -0700964 {"nativeSetDisplaySurface", "(JLandroid/os/IBinder;J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800965 (void*)nativeSetDisplaySurface },
Robert Carre13b58e2017-08-31 14:50:44 -0700966 {"nativeSetDisplayLayerStack", "(JLandroid/os/IBinder;I)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800967 (void*)nativeSetDisplayLayerStack },
Robert Carre13b58e2017-08-31 14:50:44 -0700968 {"nativeSetDisplayProjection", "(JLandroid/os/IBinder;IIIIIIIII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800969 (void*)nativeSetDisplayProjection },
Robert Carre13b58e2017-08-31 14:50:44 -0700970 {"nativeSetDisplaySize", "(JLandroid/os/IBinder;II)V",
Michael Wright01e840f2014-06-26 16:03:25 -0700971 (void*)nativeSetDisplaySize },
Dan Stoza00101052014-05-02 15:23:40 -0700972 {"nativeGetDisplayConfigs", "(Landroid/os/IBinder;)[Landroid/view/SurfaceControl$PhysicalDisplayInfo;",
973 (void*)nativeGetDisplayConfigs },
974 {"nativeGetActiveConfig", "(Landroid/os/IBinder;)I",
975 (void*)nativeGetActiveConfig },
976 {"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z",
977 (void*)nativeSetActiveConfig },
Michael Wright1c9977b2016-07-12 13:30:10 -0700978 {"nativeGetDisplayColorModes", "(Landroid/os/IBinder;)[I",
979 (void*)nativeGetDisplayColorModes},
980 {"nativeGetActiveColorMode", "(Landroid/os/IBinder;)I",
981 (void*)nativeGetActiveColorMode},
982 {"nativeSetActiveColorMode", "(Landroid/os/IBinder;I)Z",
983 (void*)nativeSetActiveColorMode},
Michael Wright9ff94c02016-03-30 18:05:40 -0700984 {"nativeGetHdrCapabilities", "(Landroid/os/IBinder;)Landroid/view/Display$HdrCapabilities;",
985 (void*)nativeGetHdrCapabilities },
Svetoslav1376d602014-03-13 11:17:26 -0700986 {"nativeClearContentFrameStats", "(J)Z",
987 (void*)nativeClearContentFrameStats },
988 {"nativeGetContentFrameStats", "(JLandroid/view/WindowContentFrameStats;)Z",
989 (void*)nativeGetContentFrameStats },
990 {"nativeClearAnimationFrameStats", "()Z",
991 (void*)nativeClearAnimationFrameStats },
992 {"nativeGetAnimationFrameStats", "(Landroid/view/WindowAnimationFrameStats;)Z",
993 (void*)nativeGetAnimationFrameStats },
Prashant Malanic55929a2014-05-25 01:59:21 -0700994 {"nativeSetDisplayPowerMode", "(Landroid/os/IBinder;I)V",
995 (void*)nativeSetDisplayPowerMode },
Robert Carre13b58e2017-08-31 14:50:44 -0700996 {"nativeDeferTransactionUntil", "(JJLandroid/os/IBinder;J)V",
Rob Carr64e516f2015-10-29 00:20:45 +0000997 (void*)nativeDeferTransactionUntil },
Robert Carre13b58e2017-08-31 14:50:44 -0700998 {"nativeDeferTransactionUntilSurface", "(JJJJ)V",
Robert Carrd5c7dd62017-03-08 10:39:30 -0800999 (void*)nativeDeferTransactionUntilSurface },
Robert Carre13b58e2017-08-31 14:50:44 -07001000 {"nativeReparentChildren", "(JJLandroid/os/IBinder;)V",
Robert Carrd5c7dd62017-03-08 10:39:30 -08001001 (void*)nativeReparentChildren } ,
Robert Carre13b58e2017-08-31 14:50:44 -07001002 {"nativeReparent", "(JJLandroid/os/IBinder;)V",
chaviw76431402017-09-18 16:50:05 -07001003 (void*)nativeReparent },
Robert Carre13b58e2017-08-31 14:50:44 -07001004 {"nativeSeverChildren", "(JJ)V",
Robert Carrd5c7dd62017-03-08 10:39:30 -08001005 (void*)nativeSeverChildren } ,
Robert Carre13b58e2017-08-31 14:50:44 -07001006 {"nativeSetOverrideScalingMode", "(JJI)V",
Robert Carr1ca6a332016-04-11 18:00:43 -07001007 (void*)nativeSetOverrideScalingMode },
Chavi Weingartenb736e322018-02-23 00:27:54 +00001008 {"nativeDestroy", "(JJ)V",
1009 (void*)nativeDestroyInTransaction },
Rob Carr64e516f2015-10-29 00:20:45 +00001010 {"nativeGetHandle", "(J)Landroid/os/IBinder;",
Robert Carr6da3cc02016-06-16 15:17:07 -07001011 (void*)nativeGetHandle },
Robert Carr6486d312017-01-09 19:48:29 -08001012 {"nativeScreenshotToBuffer",
1013 "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/GraphicBuffer;",
1014 (void*)nativeScreenshotToBuffer },
Chavi Weingartenea2eb5a2017-11-29 21:26:24 +00001015 {"nativeCaptureLayers", "(Landroid/os/IBinder;Landroid/graphics/Rect;F)Landroid/graphics/GraphicBuffer;",
Chavi Weingartend7ec64c2017-11-30 01:52:01 +00001016 (void*)nativeCaptureLayers },
Mathias Agopian3866f0d2013-02-11 22:08:48 -08001017};
1018
1019int register_android_view_SurfaceControl(JNIEnv* env)
1020{
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001021 int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl",
Mathias Agopian3866f0d2013-02-11 22:08:48 -08001022 sSurfaceControlMethods, NELEM(sSurfaceControlMethods));
1023
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001024 jclass clazz = FindClassOrDie(env, "android/view/SurfaceControl$PhysicalDisplayInfo");
1025 gPhysicalDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, clazz);
1026 gPhysicalDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env,
1027 gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V");
1028 gPhysicalDisplayInfoClassInfo.width = GetFieldIDOrDie(env, clazz, "width", "I");
1029 gPhysicalDisplayInfoClassInfo.height = GetFieldIDOrDie(env, clazz, "height", "I");
1030 gPhysicalDisplayInfoClassInfo.refreshRate = GetFieldIDOrDie(env, clazz, "refreshRate", "F");
1031 gPhysicalDisplayInfoClassInfo.density = GetFieldIDOrDie(env, clazz, "density", "F");
1032 gPhysicalDisplayInfoClassInfo.xDpi = GetFieldIDOrDie(env, clazz, "xDpi", "F");
1033 gPhysicalDisplayInfoClassInfo.yDpi = GetFieldIDOrDie(env, clazz, "yDpi", "F");
1034 gPhysicalDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, clazz, "secure", "Z");
1035 gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env,
1036 clazz, "appVsyncOffsetNanos", "J");
1037 gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env,
1038 clazz, "presentationDeadlineNanos", "J");
Svetoslav1376d602014-03-13 11:17:26 -07001039
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001040 jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect");
1041 gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I");
1042 gRectClassInfo.left = GetFieldIDOrDie(env, rectClazz, "left", "I");
1043 gRectClassInfo.right = GetFieldIDOrDie(env, rectClazz, "right", "I");
1044 gRectClassInfo.top = GetFieldIDOrDie(env, rectClazz, "top", "I");
Dan Stoza9890e3412014-05-22 16:12:54 -07001045
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001046 jclass frameStatsClazz = FindClassOrDie(env, "android/view/FrameStats");
1047 jfieldID undefined_time_nano_field = GetStaticFieldIDOrDie(env,
1048 frameStatsClazz, "UNDEFINED_TIME_NANO", "J");
Svetoslav1376d602014-03-13 11:17:26 -07001049 nsecs_t undefined_time_nano = env->GetStaticLongField(frameStatsClazz, undefined_time_nano_field);
1050
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001051 jclass contFrameStatsClazz = FindClassOrDie(env, "android/view/WindowContentFrameStats");
1052 gWindowContentFrameStatsClassInfo.init = GetMethodIDOrDie(env,
1053 contFrameStatsClazz, "init", "(J[J[J[J)V");
Svetoslav1376d602014-03-13 11:17:26 -07001054 gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano;
1055
Andreas Gampeed6b9df2014-11-20 22:02:20 -08001056 jclass animFrameStatsClazz = FindClassOrDie(env, "android/view/WindowAnimationFrameStats");
1057 gWindowAnimationFrameStatsClassInfo.init = GetMethodIDOrDie(env,
1058 animFrameStatsClazz, "init", "(J[J)V");
Svetoslav1376d602014-03-13 11:17:26 -07001059 gWindowAnimationFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano;
1060
Hangyu Kuang54ac2192016-04-25 13:22:02 -07001061 jclass hdrCapabilitiesClazz = FindClassOrDie(env, "android/view/Display$HdrCapabilities");
1062 gHdrCapabilitiesClassInfo.clazz = MakeGlobalRefOrDie(env, hdrCapabilitiesClazz);
1063 gHdrCapabilitiesClassInfo.ctor = GetMethodIDOrDie(env, hdrCapabilitiesClazz, "<init>",
1064 "([IFFF)V");
1065
Robert Carr6486d312017-01-09 19:48:29 -08001066 jclass graphicsBufferClazz = FindClassOrDie(env, "android/graphics/GraphicBuffer");
1067 gGraphicBufferClassInfo.clazz = MakeGlobalRefOrDie(env, graphicsBufferClazz);
1068 gGraphicBufferClassInfo.builder = GetStaticMethodIDOrDie(env, graphicsBufferClazz,
1069 "createFromExisting", "(IIIIJ)Landroid/graphics/GraphicBuffer;");
1070
Mathias Agopian3866f0d2013-02-11 22:08:48 -08001071 return err;
1072}
1073
1074};