blob: c5ab284f765d0052ec2a3e72267db10d0959edd0 [file] [log] [blame]
Mathias Agopian3866f0d2013-02-11 22:08:48 -08001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "SurfaceControl"
18
19#include <stdio.h>
20
21#include "jni.h"
22#include "JNIHelp.h"
23
24#include "android_os_Parcel.h"
25#include "android_util_Binder.h"
26#include "android/graphics/GraphicsJNI.h"
27#include "android/graphics/Region.h"
28
29#include <android_runtime/AndroidRuntime.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>
32
33#include <gui/Surface.h>
34#include <gui/SurfaceComposerClient.h>
35
36#include <ui/DisplayInfo.h>
37#include <ui/Rect.h>
38#include <ui/Region.h>
39
40#include <utils/Log.h>
41
42#include <ScopedUtfChars.h>
43
44// ----------------------------------------------------------------------------
45
46namespace android {
47
48static const char* const OutOfResourcesException =
49 "android/view/Surface$OutOfResourcesException";
50
51static struct {
52 jfieldID width;
53 jfieldID height;
54 jfieldID refreshRate;
55 jfieldID density;
56 jfieldID xDpi;
57 jfieldID yDpi;
58 jfieldID secure;
59} gPhysicalDisplayInfoClassInfo;
60
61
62class ScreenshotPixelRef : public SkPixelRef {
63public:
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -050064 ScreenshotPixelRef(const SkImageInfo& info, ScreenshotClient* screenshot) :
65 SkPixelRef(info),
66 mScreenshot(screenshot) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -080067 setImmutable();
68 }
69
70 virtual ~ScreenshotPixelRef() {
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -050071 delete mScreenshot;
Mathias Agopian3866f0d2013-02-11 22:08:48 -080072 }
73
74protected:
75 // overrides from SkPixelRef
76 virtual void* onLockPixels(SkColorTable** ct) {
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -050077 *ct = NULL;
78 return (void*)mScreenshot->getPixels();
Mathias Agopian3866f0d2013-02-11 22:08:48 -080079 }
80
81 virtual void onUnlockPixels() {
82 }
83
Kristian Monsene32e2b32013-02-14 21:35:35 -080084 SK_DECLARE_UNFLATTENABLE_OBJECT()
Mathias Agopian3866f0d2013-02-11 22:08:48 -080085private:
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -050086 ScreenshotClient* mScreenshot;
Mathias Agopian3866f0d2013-02-11 22:08:48 -080087
88 typedef SkPixelRef INHERITED;
89};
90
91
92// ----------------------------------------------------------------------------
93
Ashok Bhat36bef0b2014-01-20 20:08:01 +000094static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,
Mathias Agopian3866f0d2013-02-11 22:08:48 -080095 jstring nameStr, jint w, jint h, jint format, jint flags) {
96 ScopedUtfChars name(env, nameStr);
97 sp<SurfaceComposerClient> client(android_view_SurfaceSession_getClient(env, sessionObj));
98 sp<SurfaceControl> surface = client->createSurface(
99 String8(name.c_str()), w, h, format, flags);
100 if (surface == NULL) {
101 jniThrowException(env, OutOfResourcesException, NULL);
102 return 0;
103 }
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800104 surface->incStrong((void *)nativeCreate);
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000105 return reinterpret_cast<jlong>(surface.get());
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800106}
107
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000108static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800109 sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800110 ctrl->decStrong((void *)nativeCreate);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800111}
112
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000113static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800114 sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
115 ctrl->clear();
Mathias Agopianb1d90c82013-03-06 17:45:42 -0800116 ctrl->decStrong((void *)nativeCreate);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800117}
118
Mathias Agopian0449a402013-03-01 23:01:51 -0800119static jobject nativeScreenshotBitmap(JNIEnv* env, jclass clazz, jobject displayTokenObj,
Dan Stoza16ec12a2014-02-14 15:06:55 -0800120 jint width, jint height, jint minLayer, jint maxLayer, bool allLayers,
121 bool useIdentityTransform) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800122 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
123 if (displayToken == NULL) {
124 return NULL;
125 }
126
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500127 ScreenshotClient* screenshot = new ScreenshotClient();
128 status_t res;
129 if (width > 0 && height > 0) {
130 if (allLayers) {
131 res = screenshot->update(displayToken, width, height, useIdentityTransform);
132 } else {
133 res = screenshot->update(displayToken, width, height, minLayer, maxLayer,
134 useIdentityTransform);
135 }
136 } else {
137 res = screenshot->update(displayToken, useIdentityTransform);
138 }
139 if (res != NO_ERROR) {
140 delete screenshot;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800141 return NULL;
142 }
143
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500144 SkImageInfo screenshotInfo;
145 screenshotInfo.fWidth = screenshot->getWidth();
146 screenshotInfo.fHeight = screenshot->getHeight();
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800147
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500148 switch (screenshot->getFormat()) {
149 case PIXEL_FORMAT_RGBX_8888: {
150 screenshotInfo.fColorType = kRGBA_8888_SkColorType;
151 screenshotInfo.fAlphaType = kIgnore_SkAlphaType;
152 break;
153 }
154 case PIXEL_FORMAT_RGBA_8888: {
155 screenshotInfo.fColorType = kRGBA_8888_SkColorType;
156 screenshotInfo.fAlphaType = kPremul_SkAlphaType;
157 break;
158 }
159 case PIXEL_FORMAT_RGB_565: {
160 screenshotInfo.fColorType = kRGB_565_SkColorType;
161 screenshotInfo.fAlphaType = kIgnore_SkAlphaType;
162 break;
163 }
164 default: {
165 delete screenshot;
166 return NULL;
167 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800168 }
169
Derek Sollenbergerb644a3b2014-01-17 15:45:10 -0500170 // takes ownership of ScreenshotClient
171 ScreenshotPixelRef* pixels = new ScreenshotPixelRef(screenshotInfo, screenshot);
172 const ssize_t rowBytes =
173 screenshot->getStride() * android::bytesPerPixel(screenshot->getFormat());
174
175 SkBitmap* bitmap = new SkBitmap();
176 bitmap->setConfig(screenshotInfo, (size_t)rowBytes);
177 if (screenshotInfo.fWidth > 0 && screenshotInfo.fHeight > 0) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800178 bitmap->setPixelRef(pixels)->unref();
179 bitmap->lockPixels();
180 } else {
181 // be safe with an empty bitmap.
182 delete pixels;
183 bitmap->setPixels(NULL);
184 }
185
Chris Craik1abf5d62013-08-16 12:47:03 -0700186 return GraphicsJNI::createBitmap(env, bitmap,
187 GraphicsJNI::kBitmapCreateFlag_Premultiplied, NULL);
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800188}
189
Mathias Agopian0449a402013-03-01 23:01:51 -0800190static void nativeScreenshot(JNIEnv* env, jclass clazz,
191 jobject displayTokenObj, jobject surfaceObj,
Dan Stoza16ec12a2014-02-14 15:06:55 -0800192 jint width, jint height, jint minLayer, jint maxLayer, bool allLayers,
193 bool useIdentityTransform) {
Mathias Agopian0449a402013-03-01 23:01:51 -0800194 sp<IBinder> displayToken = ibinderForJavaObject(env, displayTokenObj);
195 if (displayToken != NULL) {
196 sp<Surface> consumer = android_view_Surface_getSurface(env, surfaceObj);
197 if (consumer != NULL) {
198 if (allLayers) {
199 minLayer = 0;
200 maxLayer = -1;
201 }
202 ScreenshotClient::capture(
203 displayToken, consumer->getIGraphicBufferProducer(),
Dan Stoza16ec12a2014-02-14 15:06:55 -0800204 width, height, uint32_t(minLayer), uint32_t(maxLayer),
205 useIdentityTransform);
Mathias Agopian0449a402013-03-01 23:01:51 -0800206 }
207 }
208}
209
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800210static void nativeOpenTransaction(JNIEnv* env, jclass clazz) {
211 SurfaceComposerClient::openGlobalTransaction();
212}
213
214static void nativeCloseTransaction(JNIEnv* env, jclass clazz) {
215 SurfaceComposerClient::closeGlobalTransaction();
216}
217
218static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz) {
219 SurfaceComposerClient::setAnimationTransaction();
220}
221
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000222static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong nativeObject, jint zorder) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800223 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
224 status_t err = ctrl->setLayer(zorder);
225 if (err < 0 && err != NO_INIT) {
226 doThrowIAE(env);
227 }
228}
229
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000230static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat x, jfloat y) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800231 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
232 status_t err = ctrl->setPosition(x, y);
233 if (err < 0 && err != NO_INIT) {
234 doThrowIAE(env);
235 }
236}
237
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000238static void nativeSetSize(JNIEnv* env, jclass clazz, jlong nativeObject, jint w, jint h) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800239 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
240 status_t err = ctrl->setSize(w, h);
241 if (err < 0 && err != NO_INIT) {
242 doThrowIAE(env);
243 }
244}
245
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000246static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong nativeObject, jint flags, jint mask) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800247 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
248 status_t err = ctrl->setFlags(flags, mask);
249 if (err < 0 && err != NO_INIT) {
250 doThrowIAE(env);
251 }
252}
253
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000254static void nativeSetTransparentRegionHint(JNIEnv* env, jclass clazz, jlong nativeObject, jobject regionObj) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800255 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
256 SkRegion* region = android_graphics_Region_getSkRegion(env, regionObj);
257 if (!region) {
258 doThrowIAE(env);
259 return;
260 }
261
262 const SkIRect& b(region->getBounds());
263 Region reg(Rect(b.fLeft, b.fTop, b.fRight, b.fBottom));
264 if (region->isComplex()) {
265 SkRegion::Iterator it(*region);
266 while (!it.done()) {
267 const SkIRect& r(it.rect());
268 reg.addRectUnchecked(r.fLeft, r.fTop, r.fRight, r.fBottom);
269 it.next();
270 }
271 }
272
273 status_t err = ctrl->setTransparentRegionHint(reg);
274 if (err < 0 && err != NO_INIT) {
275 doThrowIAE(env);
276 }
277}
278
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000279static void nativeSetAlpha(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat alpha) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800280 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
281 status_t err = ctrl->setAlpha(alpha);
282 if (err < 0 && err != NO_INIT) {
283 doThrowIAE(env);
284 }
285}
286
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000287static void nativeSetMatrix(JNIEnv* env, jclass clazz, jlong nativeObject,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800288 jfloat dsdx, jfloat dtdx, jfloat dsdy, jfloat dtdy) {
289 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
290 status_t err = ctrl->setMatrix(dsdx, dtdx, dsdy, dtdy);
291 if (err < 0 && err != NO_INIT) {
292 doThrowIAE(env);
293 }
294}
295
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000296static void nativeSetWindowCrop(JNIEnv* env, jclass clazz, jlong nativeObject,
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800297 jint l, jint t, jint r, jint b) {
298 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
299 Rect crop(l, t, r, b);
300 status_t err = ctrl->setCrop(crop);
301 if (err < 0 && err != NO_INIT) {
302 doThrowIAE(env);
303 }
304}
305
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000306static void nativeSetLayerStack(JNIEnv* env, jclass clazz, jlong nativeObject, jint layerStack) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800307 SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
308 status_t err = ctrl->setLayerStack(layerStack);
309 if (err < 0 && err != NO_INIT) {
310 doThrowIAE(env);
311 }
312}
313
314static jobject nativeGetBuiltInDisplay(JNIEnv* env, jclass clazz, jint id) {
315 sp<IBinder> token(SurfaceComposerClient::getBuiltInDisplay(id));
316 return javaObjectForIBinder(env, token);
317}
318
319static jobject nativeCreateDisplay(JNIEnv* env, jclass clazz, jstring nameObj,
320 jboolean secure) {
321 ScopedUtfChars name(env, nameObj);
322 sp<IBinder> token(SurfaceComposerClient::createDisplay(
323 String8(name.c_str()), bool(secure)));
324 return javaObjectForIBinder(env, token);
325}
326
Jesse Hall6a6bc212013-08-08 12:15:03 -0700327static void nativeDestroyDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) {
328 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
329 if (token == NULL) return;
330 SurfaceComposerClient::destroyDisplay(token);
331}
332
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800333static void nativeSetDisplaySurface(JNIEnv* env, jclass clazz,
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000334 jobject tokenObj, jlong nativeSurfaceObject) {
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800335 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
336 if (token == NULL) return;
Mathias Agopianffddc9b2013-02-25 15:56:31 -0800337 sp<IGraphicBufferProducer> bufferProducer;
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800338 sp<Surface> sur(reinterpret_cast<Surface *>(nativeSurfaceObject));
Mathias Agopianffddc9b2013-02-25 15:56:31 -0800339 if (sur != NULL) {
340 bufferProducer = sur->getIGraphicBufferProducer();
341 }
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800342 SurfaceComposerClient::setDisplaySurface(token, bufferProducer);
343}
344
345static void nativeSetDisplayLayerStack(JNIEnv* env, jclass clazz,
346 jobject tokenObj, jint layerStack) {
347 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
348 if (token == NULL) return;
349
350 SurfaceComposerClient::setDisplayLayerStack(token, layerStack);
351}
352
353static void nativeSetDisplayProjection(JNIEnv* env, jclass clazz,
354 jobject tokenObj, jint orientation,
355 jint layerStackRect_left, jint layerStackRect_top, jint layerStackRect_right, jint layerStackRect_bottom,
356 jint displayRect_left, jint displayRect_top, jint displayRect_right, jint displayRect_bottom) {
357 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
358 if (token == NULL) return;
359 Rect layerStackRect(layerStackRect_left, layerStackRect_top, layerStackRect_right, layerStackRect_bottom);
360 Rect displayRect(displayRect_left, displayRect_top, displayRect_right, displayRect_bottom);
361 SurfaceComposerClient::setDisplayProjection(token, orientation, layerStackRect, displayRect);
362}
363
364static jboolean nativeGetDisplayInfo(JNIEnv* env, jclass clazz,
365 jobject tokenObj, jobject infoObj) {
366 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
367 if (token == NULL) return JNI_FALSE;
368
369 DisplayInfo info;
370 if (SurfaceComposerClient::getDisplayInfo(token, &info)) {
371 return JNI_FALSE;
372 }
373
374 env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.width, info.w);
375 env->SetIntField(infoObj, gPhysicalDisplayInfoClassInfo.height, info.h);
376 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.refreshRate, info.fps);
377 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.density, info.density);
378 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.xDpi, info.xdpi);
379 env->SetFloatField(infoObj, gPhysicalDisplayInfoClassInfo.yDpi, info.ydpi);
380 env->SetBooleanField(infoObj, gPhysicalDisplayInfoClassInfo.secure, info.secure);
381 return JNI_TRUE;
382}
383
384static void nativeBlankDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) {
385 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
386 if (token == NULL) return;
387
388 ALOGD_IF_SLOW(100, "Excessive delay in blankDisplay() while turning screen off");
389 SurfaceComposerClient::blankDisplay(token);
390}
391
392static void nativeUnblankDisplay(JNIEnv* env, jclass clazz, jobject tokenObj) {
393 sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
394 if (token == NULL) return;
395
396 ALOGD_IF_SLOW(100, "Excessive delay in unblankDisplay() while turning screen on");
397 SurfaceComposerClient::unblankDisplay(token);
398}
399
400// ----------------------------------------------------------------------------
401
402static JNINativeMethod sSurfaceControlMethods[] = {
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000403 {"nativeCreate", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIII)J",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800404 (void*)nativeCreate },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000405 {"nativeRelease", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800406 (void*)nativeRelease },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000407 {"nativeDestroy", "(J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800408 (void*)nativeDestroy },
Dan Stoza16ec12a2014-02-14 15:06:55 -0800409 {"nativeScreenshot", "(Landroid/os/IBinder;IIIIZZ)Landroid/graphics/Bitmap;",
Mathias Agopian0449a402013-03-01 23:01:51 -0800410 (void*)nativeScreenshotBitmap },
Dan Stoza16ec12a2014-02-14 15:06:55 -0800411 {"nativeScreenshot", "(Landroid/os/IBinder;Landroid/view/Surface;IIIIZZ)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800412 (void*)nativeScreenshot },
413 {"nativeOpenTransaction", "()V",
414 (void*)nativeOpenTransaction },
415 {"nativeCloseTransaction", "()V",
416 (void*)nativeCloseTransaction },
417 {"nativeSetAnimationTransaction", "()V",
418 (void*)nativeSetAnimationTransaction },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000419 {"nativeSetLayer", "(JI)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800420 (void*)nativeSetLayer },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000421 {"nativeSetPosition", "(JFF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800422 (void*)nativeSetPosition },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000423 {"nativeSetSize", "(JII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800424 (void*)nativeSetSize },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000425 {"nativeSetTransparentRegionHint", "(JLandroid/graphics/Region;)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800426 (void*)nativeSetTransparentRegionHint },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000427 {"nativeSetAlpha", "(JF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800428 (void*)nativeSetAlpha },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000429 {"nativeSetMatrix", "(JFFFF)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800430 (void*)nativeSetMatrix },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000431 {"nativeSetFlags", "(JII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800432 (void*)nativeSetFlags },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000433 {"nativeSetWindowCrop", "(JIIII)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800434 (void*)nativeSetWindowCrop },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000435 {"nativeSetLayerStack", "(JI)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800436 (void*)nativeSetLayerStack },
437 {"nativeGetBuiltInDisplay", "(I)Landroid/os/IBinder;",
438 (void*)nativeGetBuiltInDisplay },
439 {"nativeCreateDisplay", "(Ljava/lang/String;Z)Landroid/os/IBinder;",
440 (void*)nativeCreateDisplay },
Jesse Hall6a6bc212013-08-08 12:15:03 -0700441 {"nativeDestroyDisplay", "(Landroid/os/IBinder;)V",
442 (void*)nativeDestroyDisplay },
Ashok Bhat36bef0b2014-01-20 20:08:01 +0000443 {"nativeSetDisplaySurface", "(Landroid/os/IBinder;J)V",
Mathias Agopian3866f0d2013-02-11 22:08:48 -0800444 (void*)nativeSetDisplaySurface },
445 {"nativeSetDisplayLayerStack", "(Landroid/os/IBinder;I)V",
446 (void*)nativeSetDisplayLayerStack },
447 {"nativeSetDisplayProjection", "(Landroid/os/IBinder;IIIIIIIII)V",
448 (void*)nativeSetDisplayProjection },
449 {"nativeGetDisplayInfo", "(Landroid/os/IBinder;Landroid/view/SurfaceControl$PhysicalDisplayInfo;)Z",
450 (void*)nativeGetDisplayInfo },
451 {"nativeBlankDisplay", "(Landroid/os/IBinder;)V",
452 (void*)nativeBlankDisplay },
453 {"nativeUnblankDisplay", "(Landroid/os/IBinder;)V",
454 (void*)nativeUnblankDisplay },
455};
456
457int register_android_view_SurfaceControl(JNIEnv* env)
458{
459 int err = AndroidRuntime::registerNativeMethods(env, "android/view/SurfaceControl",
460 sSurfaceControlMethods, NELEM(sSurfaceControlMethods));
461
462 jclass clazz = env->FindClass("android/view/SurfaceControl$PhysicalDisplayInfo");
463 gPhysicalDisplayInfoClassInfo.width = env->GetFieldID(clazz, "width", "I");
464 gPhysicalDisplayInfoClassInfo.height = env->GetFieldID(clazz, "height", "I");
465 gPhysicalDisplayInfoClassInfo.refreshRate = env->GetFieldID(clazz, "refreshRate", "F");
466 gPhysicalDisplayInfoClassInfo.density = env->GetFieldID(clazz, "density", "F");
467 gPhysicalDisplayInfoClassInfo.xDpi = env->GetFieldID(clazz, "xDpi", "F");
468 gPhysicalDisplayInfoClassInfo.yDpi = env->GetFieldID(clazz, "yDpi", "F");
469 gPhysicalDisplayInfoClassInfo.secure = env->GetFieldID(clazz, "secure", "Z");
470 return err;
471}
472
473};