Loading cmds/bootanimation/BootAnimation.cpp +6 −3 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,7 @@ #include <ui/DisplayInfo.h> #include <ui/DisplayInfo.h> #include <ui/FramebufferNativeWindow.h> #include <ui/FramebufferNativeWindow.h> #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> Loading Loading @@ -216,14 +217,16 @@ status_t BootAnimation::initTexture(void* buffer, size_t len) status_t BootAnimation::readyToRun() { status_t BootAnimation::readyToRun() { mAssets.addDefaultAssets(); mAssets.addDefaultAssets(); sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay( ISurfaceComposer::eDisplayIdMain)); DisplayInfo dinfo; DisplayInfo dinfo; status_t status = SurfaceComposerClient::getDisplayInfo(0, &dinfo); status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo); if (status) if (status) return -1; return -1; // create the native surface // create the native surface sp<SurfaceControl> control = session()->createSurface( sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"), 0, dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); SurfaceComposerClient::openGlobalTransaction(); SurfaceComposerClient::openGlobalTransaction(); control->setLayer(0x40000000); control->setLayer(0x40000000); Loading cmds/screencap/screencap.cpp +13 −4 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <binder/IMemory.h> #include <binder/IMemory.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <gui/ISurfaceComposer.h> #include <SkImageEncoder.h> #include <SkImageEncoder.h> #include <SkBitmap.h> #include <SkBitmap.h> Loading @@ -33,15 +34,18 @@ using namespace android; using namespace android; static uint32_t DEFAULT_DISPLAY_ID = ISurfaceComposer::eDisplayIdMain; static void usage(const char* pname) static void usage(const char* pname) { { fprintf(stderr, fprintf(stderr, "usage: %s [-hp] [FILENAME]\n" "usage: %s [-hp] [-d display-id] [FILENAME]\n" " -h: this message\n" " -h: this message\n" " -p: save the file as a png.\n" " -p: save the file as a png.\n" " -d: specify the display id to capture, default %d.\n" "If FILENAME ends with .png it will be saved as a png.\n" "If FILENAME ends with .png it will be saved as a png.\n" "If FILENAME is not given, the results will be printed to stdout.\n", "If FILENAME is not given, the results will be printed to stdout.\n", pname pname, DEFAULT_DISPLAY_ID ); ); } } Loading Loading @@ -87,12 +91,16 @@ int main(int argc, char** argv) { { const char* pname = argv[0]; const char* pname = argv[0]; bool png = false; bool png = false; int32_t displayId = DEFAULT_DISPLAY_ID; int c; int c; while ((c = getopt(argc, argv, "ph")) != -1) { while ((c = getopt(argc, argv, "phd:")) != -1) { switch (c) { switch (c) { case 'p': case 'p': png = true; png = true; break; break; case 'd': displayId = atoi(optarg); break; case '?': case '?': case 'h': case 'h': usage(pname); usage(pname); Loading Loading @@ -131,7 +139,8 @@ int main(int argc, char** argv) size_t size = 0; size_t size = 0; ScreenshotClient screenshot; ScreenshotClient screenshot; if (screenshot.update() == NO_ERROR) { sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay(displayId); if (display != NULL && screenshot.update(display) == NO_ERROR) { base = screenshot.getPixels(); base = screenshot.getPixels(); w = screenshot.getWidth(); w = screenshot.getWidth(); h = screenshot.getHeight(); h = screenshot.getHeight(); Loading core/java/android/view/Surface.java +17 −4 Original line number Original line Diff line number Diff line Loading @@ -17,9 +17,15 @@ package android.view; package android.view; import android.content.res.CompatibilityInfo.Translator; import android.content.res.CompatibilityInfo.Translator; import android.graphics.*; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.Region; import android.graphics.SurfaceTexture; import android.os.Parcelable; import android.os.Parcelable; import android.os.Parcel; import android.os.Parcel; import android.os.Process; import android.os.SystemProperties; import android.os.SystemProperties; import android.util.Log; import android.util.Log; Loading Loading @@ -250,13 +256,20 @@ public class Surface implements Parcelable { public Surface(SurfaceSession s, public Surface(SurfaceSession s, int pid, String name, int layerStack, int w, int h, int format, int flags) int pid, String name, int layerStack, int w, int h, int format, int flags) throws OutOfResourcesException { throws OutOfResourcesException { // FIXME: remove pid and layerstack arguments checkHeadless(); checkHeadless(); if (DEBUG_RELEASE) { if (DEBUG_RELEASE) { mCreationStack = new Exception(); mCreationStack = new Exception(); } } if (name == null) { name = "<pid " + Process.myPid() + ">"; } mCanvas = new CompatibleCanvas(); mCanvas = new CompatibleCanvas(); init(s, pid, name, layerStack, w, h, format, flags); init(s, name, w, h, format, flags); setLayerStack(layerStack); mName = name; mName = name; } } Loading Loading @@ -496,8 +509,8 @@ public class Surface implements Parcelable { } } } } private native void init(SurfaceSession s, private native void init(SurfaceSession s, String name, int pid, String name, int layerStack, int w, int h, int format, int flags) int w, int h, int format, int flags) throws OutOfResourcesException; throws OutOfResourcesException; private native void init(Parcel source) throws OutOfResourcesException; private native void init(Parcel source) throws OutOfResourcesException; Loading core/java/android/view/SurfaceSession.java +21 −13 Original line number Original line Diff line number Diff line Loading @@ -24,26 +24,34 @@ package android.view; * {@hide} * {@hide} */ */ public class SurfaceSession { public class SurfaceSession { private int mClient; private native void nativeInit(); private native void nativeDestroy(); private native void nativeKill(); /** Create a new connection with the surface flinger. */ /** Create a new connection with the surface flinger. */ public SurfaceSession() { public SurfaceSession() { init(); nativeInit(); } } /** Forcibly detach native resources associated with this object. * Unlike destroy(), after this call any surfaces that were created * from the session will no longer work. The session itself is destroyed. */ public native void kill(); /* no user serviceable parts here ... */ /* no user serviceable parts here ... */ @Override @Override protected void finalize() throws Throwable { protected void finalize() throws Throwable { destroy(); try { nativeDestroy(); } finally { super.finalize(); } } } private native void init(); /** private native void destroy(); * Forcibly detach native resources associated with this object. * Unlike destroy(), after this call any surfaces that were created private int mClient; * from the session will no longer work. The session itself is destroyed. */ public void kill() { nativeKill(); } } } core/jni/android_view_Surface.cpp +32 −30 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <binder/IMemory.h> #include <binder/IMemory.h> #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceTexture.h> #include <gui/SurfaceTexture.h> Loading Loading @@ -107,14 +108,14 @@ static no_t no; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static void SurfaceSession_init(JNIEnv* env, jobject clazz) static void SurfaceSession_nativeInit(JNIEnv* env, jobject clazz) { { sp<SurfaceComposerClient> client = new SurfaceComposerClient; sp<SurfaceComposerClient> client = new SurfaceComposerClient; client->incStrong(clazz); client->incStrong(clazz); env->SetIntField(clazz, sso.client, (int)client.get()); env->SetIntField(clazz, sso.client, (int)client.get()); } } static void SurfaceSession_destroy(JNIEnv* env, jobject clazz) static void SurfaceSession_nativeDestroy(JNIEnv* env, jobject clazz) { { SurfaceComposerClient* client = SurfaceComposerClient* client = (SurfaceComposerClient*)env->GetIntField(clazz, sso.client); (SurfaceComposerClient*)env->GetIntField(clazz, sso.client); Loading @@ -124,7 +125,7 @@ static void SurfaceSession_destroy(JNIEnv* env, jobject clazz) } } } } static void SurfaceSession_kill(JNIEnv* env, jobject clazz) static void SurfaceSession_nativeKill(JNIEnv* env, jobject clazz) { { SurfaceComposerClient* client = SurfaceComposerClient* client = (SurfaceComposerClient*)env->GetIntField(clazz, sso.client); (SurfaceComposerClient*)env->GetIntField(clazz, sso.client); Loading Loading @@ -221,7 +222,7 @@ void setSurface(JNIEnv* env, jobject clazz, const sp<Surface>& surface) static void Surface_init( static void Surface_init( JNIEnv* env, jobject clazz, JNIEnv* env, jobject clazz, jobject session, jobject session, jint, jstring jname, jint layerStack, jint w, jint h, jint format, jint flags) jstring jname, jint w, jint h, jint format, jint flags) { { if (session == NULL) { if (session == NULL) { doThrowNPE(env); doThrowNPE(env); Loading @@ -231,15 +232,10 @@ static void Surface_init( SurfaceComposerClient* client = SurfaceComposerClient* client = (SurfaceComposerClient*)env->GetIntField(session, sso.client); (SurfaceComposerClient*)env->GetIntField(session, sso.client); sp<SurfaceControl> surface; if (jname == NULL) { surface = client->createSurface(layerStack, w, h, format, flags); } else { const jchar* str = env->GetStringCritical(jname, 0); const jchar* str = env->GetStringCritical(jname, 0); const String8 name(str, env->GetStringLength(jname)); const String8 name(str, env->GetStringLength(jname)); env->ReleaseStringCritical(jname, str); env->ReleaseStringCritical(jname, str); surface = client->createSurface(name, layerStack, w, h, format, flags); sp<SurfaceControl> surface = client->createSurface(name, w, h, format, flags); } if (surface == 0) { if (surface == 0) { jniThrowException(env, OutOfResourcesException, NULL); jniThrowException(env, OutOfResourcesException, NULL); Loading Loading @@ -473,12 +469,11 @@ static void Surface_closeTransaction( } } static void Surface_setOrientation( static void Surface_setOrientation( JNIEnv* env, jobject clazz, jint display, jint orientation) JNIEnv* env, jobject clazz, jint, jint orientation) { { int err = SurfaceComposerClient::setOrientation(display, orientation, 0); sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay( if (err < 0) { ISurfaceComposer::eDisplayIdMain); doThrowIAE(env); SurfaceComposerClient::setDisplayOrientation(display, orientation); } } } class ScreenshotPixelRef : public SkPixelRef { class ScreenshotPixelRef : public SkPixelRef { Loading @@ -492,12 +487,13 @@ public: SkSafeUnref(fCTable); SkSafeUnref(fCTable); } } status_t update(int width, int height, int minLayer, int maxLayer, bool allLayers) { status_t update(const sp<IBinder>& display, int width, int height, int minLayer, int maxLayer, bool allLayers) { status_t res = (width > 0 && height > 0) status_t res = (width > 0 && height > 0) ? (allLayers ? (allLayers ? mScreenshot.update(width, height) ? mScreenshot.update(display, width, height) : mScreenshot.update(width, height, minLayer, maxLayer)) : mScreenshot.update(display, width, height, minLayer, maxLayer)) : mScreenshot.update(); : mScreenshot.update(display); if (res != NO_ERROR) { if (res != NO_ERROR) { return res; return res; } } Loading Loading @@ -538,11 +534,15 @@ private: typedef SkPixelRef INHERITED; typedef SkPixelRef INHERITED; }; }; static jobject doScreenshot(JNIEnv* env, jobject clazz, jint width, jint height, static jobject doScreenshot(JNIEnv* env, jobject clazz, jint width, jint height, jint minLayer, jint maxLayer, bool allLayers) jint minLayer, jint maxLayer, bool allLayers) { { sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay( ISurfaceComposer::eDisplayIdMain); ScreenshotPixelRef* pixels = new ScreenshotPixelRef(NULL); ScreenshotPixelRef* pixels = new ScreenshotPixelRef(NULL); if (pixels->update(width, height, minLayer, maxLayer, allLayers) != NO_ERROR) { if (pixels->update(display, width, height, minLayer, maxLayer, allLayers) != NO_ERROR) { delete pixels; delete pixels; return 0; return 0; } } Loading Loading @@ -721,8 +721,10 @@ static void Surface_setLayerStack(JNIEnv* env, jobject thiz, jint layerStack) { { const sp<SurfaceControl>& surface(getSurfaceControl(env, thiz)); const sp<SurfaceControl>& surface(getSurfaceControl(env, thiz)); if (surface == 0) return; if (surface == 0) return; status_t err = surface->setLayerStack(layerStack); // TODO(mathias): Everything. if (err<0 && err!=NO_INIT) { doThrowIAE(env); } } } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- Loading Loading @@ -826,14 +828,14 @@ static void Surface_writeToParcel( static void nativeClassInit(JNIEnv* env, jclass clazz); static void nativeClassInit(JNIEnv* env, jclass clazz); static JNINativeMethod gSurfaceSessionMethods[] = { static JNINativeMethod gSurfaceSessionMethods[] = { {"init", "()V", (void*)SurfaceSession_init }, {"nativeInit", "()V", (void*)SurfaceSession_nativeInit }, {"destroy", "()V", (void*)SurfaceSession_destroy }, {"nativeDestroy", "()V", (void*)SurfaceSession_nativeDestroy }, {"kill", "()V", (void*)SurfaceSession_kill }, {"nativeKill", "()V", (void*)SurfaceSession_nativeKill }, }; }; static JNINativeMethod gSurfaceMethods[] = { static JNINativeMethod gSurfaceMethods[] = { {"nativeClassInit", "()V", (void*)nativeClassInit }, {"nativeClassInit", "()V", (void*)nativeClassInit }, {"init", "(Landroid/view/SurfaceSession;ILjava/lang/String;IIIII)V", (void*)Surface_init }, {"init", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIII)V", (void*)Surface_init }, {"init", "(Landroid/os/Parcel;)V", (void*)Surface_initParcel }, {"init", "(Landroid/os/Parcel;)V", (void*)Surface_initParcel }, {"initFromSurfaceTexture", "(Landroid/graphics/SurfaceTexture;)V", (void*)Surface_initFromSurfaceTexture }, {"initFromSurfaceTexture", "(Landroid/graphics/SurfaceTexture;)V", (void*)Surface_initFromSurfaceTexture }, {"getIdentity", "()I", (void*)Surface_getIdentity }, {"getIdentity", "()I", (void*)Surface_getIdentity }, Loading Loading
cmds/bootanimation/BootAnimation.cpp +6 −3 Original line number Original line Diff line number Diff line Loading @@ -38,6 +38,7 @@ #include <ui/DisplayInfo.h> #include <ui/DisplayInfo.h> #include <ui/FramebufferNativeWindow.h> #include <ui/FramebufferNativeWindow.h> #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> Loading Loading @@ -216,14 +217,16 @@ status_t BootAnimation::initTexture(void* buffer, size_t len) status_t BootAnimation::readyToRun() { status_t BootAnimation::readyToRun() { mAssets.addDefaultAssets(); mAssets.addDefaultAssets(); sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay( ISurfaceComposer::eDisplayIdMain)); DisplayInfo dinfo; DisplayInfo dinfo; status_t status = SurfaceComposerClient::getDisplayInfo(0, &dinfo); status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo); if (status) if (status) return -1; return -1; // create the native surface // create the native surface sp<SurfaceControl> control = session()->createSurface( sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"), 0, dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); SurfaceComposerClient::openGlobalTransaction(); SurfaceComposerClient::openGlobalTransaction(); control->setLayer(0x40000000); control->setLayer(0x40000000); Loading
cmds/screencap/screencap.cpp +13 −4 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <binder/IMemory.h> #include <binder/IMemory.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <gui/ISurfaceComposer.h> #include <SkImageEncoder.h> #include <SkImageEncoder.h> #include <SkBitmap.h> #include <SkBitmap.h> Loading @@ -33,15 +34,18 @@ using namespace android; using namespace android; static uint32_t DEFAULT_DISPLAY_ID = ISurfaceComposer::eDisplayIdMain; static void usage(const char* pname) static void usage(const char* pname) { { fprintf(stderr, fprintf(stderr, "usage: %s [-hp] [FILENAME]\n" "usage: %s [-hp] [-d display-id] [FILENAME]\n" " -h: this message\n" " -h: this message\n" " -p: save the file as a png.\n" " -p: save the file as a png.\n" " -d: specify the display id to capture, default %d.\n" "If FILENAME ends with .png it will be saved as a png.\n" "If FILENAME ends with .png it will be saved as a png.\n" "If FILENAME is not given, the results will be printed to stdout.\n", "If FILENAME is not given, the results will be printed to stdout.\n", pname pname, DEFAULT_DISPLAY_ID ); ); } } Loading Loading @@ -87,12 +91,16 @@ int main(int argc, char** argv) { { const char* pname = argv[0]; const char* pname = argv[0]; bool png = false; bool png = false; int32_t displayId = DEFAULT_DISPLAY_ID; int c; int c; while ((c = getopt(argc, argv, "ph")) != -1) { while ((c = getopt(argc, argv, "phd:")) != -1) { switch (c) { switch (c) { case 'p': case 'p': png = true; png = true; break; break; case 'd': displayId = atoi(optarg); break; case '?': case '?': case 'h': case 'h': usage(pname); usage(pname); Loading Loading @@ -131,7 +139,8 @@ int main(int argc, char** argv) size_t size = 0; size_t size = 0; ScreenshotClient screenshot; ScreenshotClient screenshot; if (screenshot.update() == NO_ERROR) { sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay(displayId); if (display != NULL && screenshot.update(display) == NO_ERROR) { base = screenshot.getPixels(); base = screenshot.getPixels(); w = screenshot.getWidth(); w = screenshot.getWidth(); h = screenshot.getHeight(); h = screenshot.getHeight(); Loading
core/java/android/view/Surface.java +17 −4 Original line number Original line Diff line number Diff line Loading @@ -17,9 +17,15 @@ package android.view; package android.view; import android.content.res.CompatibilityInfo.Translator; import android.content.res.CompatibilityInfo.Translator; import android.graphics.*; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.Region; import android.graphics.SurfaceTexture; import android.os.Parcelable; import android.os.Parcelable; import android.os.Parcel; import android.os.Parcel; import android.os.Process; import android.os.SystemProperties; import android.os.SystemProperties; import android.util.Log; import android.util.Log; Loading Loading @@ -250,13 +256,20 @@ public class Surface implements Parcelable { public Surface(SurfaceSession s, public Surface(SurfaceSession s, int pid, String name, int layerStack, int w, int h, int format, int flags) int pid, String name, int layerStack, int w, int h, int format, int flags) throws OutOfResourcesException { throws OutOfResourcesException { // FIXME: remove pid and layerstack arguments checkHeadless(); checkHeadless(); if (DEBUG_RELEASE) { if (DEBUG_RELEASE) { mCreationStack = new Exception(); mCreationStack = new Exception(); } } if (name == null) { name = "<pid " + Process.myPid() + ">"; } mCanvas = new CompatibleCanvas(); mCanvas = new CompatibleCanvas(); init(s, pid, name, layerStack, w, h, format, flags); init(s, name, w, h, format, flags); setLayerStack(layerStack); mName = name; mName = name; } } Loading Loading @@ -496,8 +509,8 @@ public class Surface implements Parcelable { } } } } private native void init(SurfaceSession s, private native void init(SurfaceSession s, String name, int pid, String name, int layerStack, int w, int h, int format, int flags) int w, int h, int format, int flags) throws OutOfResourcesException; throws OutOfResourcesException; private native void init(Parcel source) throws OutOfResourcesException; private native void init(Parcel source) throws OutOfResourcesException; Loading
core/java/android/view/SurfaceSession.java +21 −13 Original line number Original line Diff line number Diff line Loading @@ -24,26 +24,34 @@ package android.view; * {@hide} * {@hide} */ */ public class SurfaceSession { public class SurfaceSession { private int mClient; private native void nativeInit(); private native void nativeDestroy(); private native void nativeKill(); /** Create a new connection with the surface flinger. */ /** Create a new connection with the surface flinger. */ public SurfaceSession() { public SurfaceSession() { init(); nativeInit(); } } /** Forcibly detach native resources associated with this object. * Unlike destroy(), after this call any surfaces that were created * from the session will no longer work. The session itself is destroyed. */ public native void kill(); /* no user serviceable parts here ... */ /* no user serviceable parts here ... */ @Override @Override protected void finalize() throws Throwable { protected void finalize() throws Throwable { destroy(); try { nativeDestroy(); } finally { super.finalize(); } } } private native void init(); /** private native void destroy(); * Forcibly detach native resources associated with this object. * Unlike destroy(), after this call any surfaces that were created private int mClient; * from the session will no longer work. The session itself is destroyed. */ public void kill() { nativeKill(); } } }
core/jni/android_view_Surface.cpp +32 −30 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <binder/IMemory.h> #include <binder/IMemory.h> #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceComposerClient.h> #include <gui/SurfaceTexture.h> #include <gui/SurfaceTexture.h> Loading Loading @@ -107,14 +108,14 @@ static no_t no; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static void SurfaceSession_init(JNIEnv* env, jobject clazz) static void SurfaceSession_nativeInit(JNIEnv* env, jobject clazz) { { sp<SurfaceComposerClient> client = new SurfaceComposerClient; sp<SurfaceComposerClient> client = new SurfaceComposerClient; client->incStrong(clazz); client->incStrong(clazz); env->SetIntField(clazz, sso.client, (int)client.get()); env->SetIntField(clazz, sso.client, (int)client.get()); } } static void SurfaceSession_destroy(JNIEnv* env, jobject clazz) static void SurfaceSession_nativeDestroy(JNIEnv* env, jobject clazz) { { SurfaceComposerClient* client = SurfaceComposerClient* client = (SurfaceComposerClient*)env->GetIntField(clazz, sso.client); (SurfaceComposerClient*)env->GetIntField(clazz, sso.client); Loading @@ -124,7 +125,7 @@ static void SurfaceSession_destroy(JNIEnv* env, jobject clazz) } } } } static void SurfaceSession_kill(JNIEnv* env, jobject clazz) static void SurfaceSession_nativeKill(JNIEnv* env, jobject clazz) { { SurfaceComposerClient* client = SurfaceComposerClient* client = (SurfaceComposerClient*)env->GetIntField(clazz, sso.client); (SurfaceComposerClient*)env->GetIntField(clazz, sso.client); Loading Loading @@ -221,7 +222,7 @@ void setSurface(JNIEnv* env, jobject clazz, const sp<Surface>& surface) static void Surface_init( static void Surface_init( JNIEnv* env, jobject clazz, JNIEnv* env, jobject clazz, jobject session, jobject session, jint, jstring jname, jint layerStack, jint w, jint h, jint format, jint flags) jstring jname, jint w, jint h, jint format, jint flags) { { if (session == NULL) { if (session == NULL) { doThrowNPE(env); doThrowNPE(env); Loading @@ -231,15 +232,10 @@ static void Surface_init( SurfaceComposerClient* client = SurfaceComposerClient* client = (SurfaceComposerClient*)env->GetIntField(session, sso.client); (SurfaceComposerClient*)env->GetIntField(session, sso.client); sp<SurfaceControl> surface; if (jname == NULL) { surface = client->createSurface(layerStack, w, h, format, flags); } else { const jchar* str = env->GetStringCritical(jname, 0); const jchar* str = env->GetStringCritical(jname, 0); const String8 name(str, env->GetStringLength(jname)); const String8 name(str, env->GetStringLength(jname)); env->ReleaseStringCritical(jname, str); env->ReleaseStringCritical(jname, str); surface = client->createSurface(name, layerStack, w, h, format, flags); sp<SurfaceControl> surface = client->createSurface(name, w, h, format, flags); } if (surface == 0) { if (surface == 0) { jniThrowException(env, OutOfResourcesException, NULL); jniThrowException(env, OutOfResourcesException, NULL); Loading Loading @@ -473,12 +469,11 @@ static void Surface_closeTransaction( } } static void Surface_setOrientation( static void Surface_setOrientation( JNIEnv* env, jobject clazz, jint display, jint orientation) JNIEnv* env, jobject clazz, jint, jint orientation) { { int err = SurfaceComposerClient::setOrientation(display, orientation, 0); sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay( if (err < 0) { ISurfaceComposer::eDisplayIdMain); doThrowIAE(env); SurfaceComposerClient::setDisplayOrientation(display, orientation); } } } class ScreenshotPixelRef : public SkPixelRef { class ScreenshotPixelRef : public SkPixelRef { Loading @@ -492,12 +487,13 @@ public: SkSafeUnref(fCTable); SkSafeUnref(fCTable); } } status_t update(int width, int height, int minLayer, int maxLayer, bool allLayers) { status_t update(const sp<IBinder>& display, int width, int height, int minLayer, int maxLayer, bool allLayers) { status_t res = (width > 0 && height > 0) status_t res = (width > 0 && height > 0) ? (allLayers ? (allLayers ? mScreenshot.update(width, height) ? mScreenshot.update(display, width, height) : mScreenshot.update(width, height, minLayer, maxLayer)) : mScreenshot.update(display, width, height, minLayer, maxLayer)) : mScreenshot.update(); : mScreenshot.update(display); if (res != NO_ERROR) { if (res != NO_ERROR) { return res; return res; } } Loading Loading @@ -538,11 +534,15 @@ private: typedef SkPixelRef INHERITED; typedef SkPixelRef INHERITED; }; }; static jobject doScreenshot(JNIEnv* env, jobject clazz, jint width, jint height, static jobject doScreenshot(JNIEnv* env, jobject clazz, jint width, jint height, jint minLayer, jint maxLayer, bool allLayers) jint minLayer, jint maxLayer, bool allLayers) { { sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay( ISurfaceComposer::eDisplayIdMain); ScreenshotPixelRef* pixels = new ScreenshotPixelRef(NULL); ScreenshotPixelRef* pixels = new ScreenshotPixelRef(NULL); if (pixels->update(width, height, minLayer, maxLayer, allLayers) != NO_ERROR) { if (pixels->update(display, width, height, minLayer, maxLayer, allLayers) != NO_ERROR) { delete pixels; delete pixels; return 0; return 0; } } Loading Loading @@ -721,8 +721,10 @@ static void Surface_setLayerStack(JNIEnv* env, jobject thiz, jint layerStack) { { const sp<SurfaceControl>& surface(getSurfaceControl(env, thiz)); const sp<SurfaceControl>& surface(getSurfaceControl(env, thiz)); if (surface == 0) return; if (surface == 0) return; status_t err = surface->setLayerStack(layerStack); // TODO(mathias): Everything. if (err<0 && err!=NO_INIT) { doThrowIAE(env); } } } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- Loading Loading @@ -826,14 +828,14 @@ static void Surface_writeToParcel( static void nativeClassInit(JNIEnv* env, jclass clazz); static void nativeClassInit(JNIEnv* env, jclass clazz); static JNINativeMethod gSurfaceSessionMethods[] = { static JNINativeMethod gSurfaceSessionMethods[] = { {"init", "()V", (void*)SurfaceSession_init }, {"nativeInit", "()V", (void*)SurfaceSession_nativeInit }, {"destroy", "()V", (void*)SurfaceSession_destroy }, {"nativeDestroy", "()V", (void*)SurfaceSession_nativeDestroy }, {"kill", "()V", (void*)SurfaceSession_kill }, {"nativeKill", "()V", (void*)SurfaceSession_nativeKill }, }; }; static JNINativeMethod gSurfaceMethods[] = { static JNINativeMethod gSurfaceMethods[] = { {"nativeClassInit", "()V", (void*)nativeClassInit }, {"nativeClassInit", "()V", (void*)nativeClassInit }, {"init", "(Landroid/view/SurfaceSession;ILjava/lang/String;IIIII)V", (void*)Surface_init }, {"init", "(Landroid/view/SurfaceSession;Ljava/lang/String;IIII)V", (void*)Surface_init }, {"init", "(Landroid/os/Parcel;)V", (void*)Surface_initParcel }, {"init", "(Landroid/os/Parcel;)V", (void*)Surface_initParcel }, {"initFromSurfaceTexture", "(Landroid/graphics/SurfaceTexture;)V", (void*)Surface_initFromSurfaceTexture }, {"initFromSurfaceTexture", "(Landroid/graphics/SurfaceTexture;)V", (void*)Surface_initFromSurfaceTexture }, {"getIdentity", "()I", (void*)Surface_getIdentity }, {"getIdentity", "()I", (void*)Surface_getIdentity }, Loading