Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d26c1e3 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

Added a name to Surface created by SurfaceFlinger

Updated the window manager to use this new facility.
Surfaces name are now printed by "dumpsys".
parent 69f22feb
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -182,7 +182,18 @@ public class Surface implements Parcelable {
            int pid, int display, int w, int h, int format, int flags)
        throws OutOfResourcesException {
        mCanvas = new CompatibleCanvas();
        init(s,pid,display,w,h,format,flags);
        init(s,pid,null,display,w,h,format,flags);
    }

    /**
     * create a surface with a name
     * {@hide}
     */
    public Surface(SurfaceSession s,
            int pid, String name, int display, int w, int h, int format, int flags)
        throws OutOfResourcesException {
        mCanvas = new CompatibleCanvas();
        init(s,pid,name,display,w,h,format,flags);
    }

    /**
@@ -400,7 +411,7 @@ public class Surface implements Parcelable {
    }
    
    private native void init(SurfaceSession s,
            int pid, int display, int w, int h, int format, int flags)
            int pid, String name, int display, int w, int h, int format, int flags)
            throws OutOfResourcesException;

    private native void init(Parcel source);
+13 −3
Original line number Diff line number Diff line
@@ -185,7 +185,8 @@ static void setSurface(JNIEnv* env, jobject clazz, const sp<Surface>& surface)

static void Surface_init(
        JNIEnv* env, jobject clazz, 
        jobject session, jint pid, jint dpy, jint w, jint h, jint format, jint flags)
        jobject session,
        jint pid, jstring jname, jint dpy, jint w, jint h, jint format, jint flags)
{
    if (session == NULL) {
        doThrow(env, "java/lang/NullPointerException");
@@ -195,7 +196,16 @@ static void Surface_init(
    SurfaceComposerClient* client =
            (SurfaceComposerClient*)env->GetIntField(session, sso.client);

    sp<SurfaceControl> surface(client->createSurface(pid, dpy, w, h, format, flags));
    sp<SurfaceControl> surface;
    if (jname == NULL) {
        surface = client->createSurface(pid, dpy, w, h, format, flags);
    } else {
        const jchar* str = env->GetStringCritical(jname, 0);
        const String8 name(str, env->GetStringLength(jname));
        env->ReleaseStringCritical(jname, str);
        surface = client->createSurface(pid, name, dpy, w, h, format, flags);
    }

    if (surface == 0) {
        doThrow(env, OutOfResourcesException);
        return;
@@ -620,7 +630,7 @@ static JNINativeMethod gSurfaceSessionMethods[] = {

static JNINativeMethod gSurfaceMethods[] = {
    {"nativeClassInit",     "()V",  (void*)nativeClassInit },
    {"init",                "(Landroid/view/SurfaceSession;IIIIII)V",  (void*)Surface_init },
    {"init",                "(Landroid/view/SurfaceSession;ILjava/lang/String;IIIII)V",  (void*)Surface_init },
    {"init",                "(Landroid/os/Parcel;)V",  (void*)Surface_initParcel },
    {"destroy",             "()V",  (void*)Surface_destroy },
    {"release",             "()V",  (void*)Surface_release },
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public:

    virtual sp<ISurface> createSurface( surface_data_t* data,
                                        int pid, 
                                        const String8& name,
                                        DisplayID display,
                                        uint32_t w,
                                        uint32_t h,
+11 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ public:
    //! Create a surface
    sp<SurfaceControl> createSurface(
            int pid,            // pid of the process the surface is for
            const String8& name,// name of the surface
            DisplayID display,  // Display to create this surface on
            uint32_t w,         // width in pixel
            uint32_t h,         // height in pixel
@@ -72,6 +73,16 @@ public:
            uint32_t flags = 0  // usage flags
    );

    sp<SurfaceControl> createSurface(
            int pid,            // pid of the process the surface is for
            DisplayID display,  // Display to create this surface on
            uint32_t w,         // width in pixel
            uint32_t h,         // height in pixel
            PixelFormat format, // pixel-format desired
            uint32_t flags = 0  // usage flags
    );


    // ------------------------------------------------------------------------
    // Composer parameters
    // All composer parameters must be changed within a transaction
+8 −0
Original line number Diff line number Diff line
@@ -728,6 +728,14 @@ LayerBaseClient::~LayerBaseClient()
    delete lcblk;
}

void LayerBaseClient::setName(const String8& name) {
    mName = name;
}

String8 LayerBaseClient::getName() const {
    return mName;
}

int32_t LayerBaseClient::serverIndex() const 
{
    sp<Client> client(this->client.promote());
Loading