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

Commit 9d4e3d2f authored by Jeff Brown's avatar Jeff Brown
Browse files

Banish DisplayID from the SurfaceFlinger API.

Use only display tokens in the API to refer to new displays.

Don't require the caller to specify the display when creating
a surface (since in general a surface could be shown on
any display).

This is intended to be a minimum change just to update the API.
Note that SurfaceFlinger still uses DisplayID in a few places
internally that might cause some features not to work properly
when there are multiple displays (LayerScreenshot, for example).

Change-Id: I3d91eec2da406eefd97bcd53655d403ad865a7e6
parent 225c66a4
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public:
    /* return an IDisplayEventConnection */
    virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;

    /* create a display with given id.
    /* create a display
     * requires ACCESS_SURFACE_FLINGER permission.
     */
    virtual sp<IBinder> createDisplay() = 0;
@@ -92,10 +92,10 @@ public:
    /* Capture the specified screen. requires READ_FRAME_BUFFER permission
     * This function will fail if there is a secure window on screen.
     */
    virtual status_t captureScreen(DisplayID dpy, sp<IMemoryHeap>* heap,
    virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
            uint32_t* width, uint32_t* height, PixelFormat* format,
            uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ,
            uint32_t maxLayerZ) = 0;
            uint32_t reqWidth, uint32_t reqHeight,
            uint32_t minLayerZ, uint32_t maxLayerZ) = 0;


    /* triggers screen off and waits for it to complete */
@@ -104,12 +104,12 @@ public:
    /* triggers screen on and waits for it to complete */
    virtual void unblank() = 0;

    /* returns information about a physical screen. This is intended to be
     * used by low-level native tests */
    virtual status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info) = 0;
    /* returns information about a display
     * intended to be used to get information about built-in displays */
    virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) = 0;

    /* connects to an external display */
    virtual void connectDisplay(const sp<ISurfaceTexture> display) = 0;
    virtual void connectDisplay(const sp<ISurfaceTexture>& display) = 0;
};

// ----------------------------------------------------------------------------
+2 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ namespace android {

// ----------------------------------------------------------------------------

// TODO: Remove this declaration, it is only used internally by SurfaceFlinger.
typedef int32_t    DisplayID;

// ----------------------------------------------------------------------------
@@ -70,7 +71,7 @@ public:
     * Requires ACCESS_SURFACE_FLINGER permission
     */
    virtual sp<ISurface> createSurface(surface_data_t* data,
            const String8& name, DisplayID display, uint32_t w, uint32_t h,
            const String8& name, uint32_t w, uint32_t h,
            PixelFormat format, uint32_t flags) = 0;

    /*
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public:
    // release surface data from java
    void        clear();
    
    status_t    setLayerStack(int32_t layerStack);
    status_t    setLayer(int32_t layer);
    status_t    setPosition(int32_t x, int32_t y);
    status_t    setSize(uint32_t w, uint32_t h);
+12 −16
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ class DisplayInfo;
class Composer;
class IMemoryHeap;
class ISurfaceComposerClient;
class ISurfaceTexture;
class Region;

// ---------------------------------------------------------------------------
@@ -64,7 +65,7 @@ public:
            void* cookie = NULL, uint32_t flags = 0);

    // Get information about a display
    static status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info);
    static status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);

    // ------------------------------------------------------------------------
    // surface creation / destruction
@@ -72,23 +73,19 @@ public:
    //! Create a surface
    sp<SurfaceControl> createSurface(
            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
            PixelFormat format, // pixel-format desired
            uint32_t flags = 0  // usage flags
    );

    sp<SurfaceControl> createSurface(
            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
    );

    //! Create a display
    static sp<IBinder> createDisplay();

    //! Get the token for the existing default displays.
    //! Possible values for id are eDisplayIdMain and eDisplayIdHdmi.
    static sp<IBinder> getBuiltInDisplay(int32_t id);

    // ------------------------------------------------------------------------
    // Composer parameters
    // All composer parameters must be changed within a transaction
@@ -102,9 +99,6 @@ public:
    //! Close a composer transaction on all active SurfaceComposerClients.
    static void closeGlobalTransaction(bool synchronous = false);

    //! Set the orientation of the given display
    static int setOrientation(DisplayID dpy, int orientation, uint32_t flags);

    status_t    hide(SurfaceID id);
    status_t    show(SurfaceID id, int32_t layer = -1);
    status_t    setFlags(SurfaceID id, uint32_t flags, uint32_t mask);
@@ -150,9 +144,11 @@ public:
    ScreenshotClient();

    // frees the previous screenshot and capture a new one
    status_t update();
    status_t update(uint32_t reqWidth, uint32_t reqHeight);
    status_t update(uint32_t reqWidth, uint32_t reqHeight,
    status_t update(const sp<IBinder>& display);
    status_t update(const sp<IBinder>& display,
            uint32_t reqWidth, uint32_t reqHeight);
    status_t update(const sp<IBinder>& display,
            uint32_t reqWidth, uint32_t reqHeight,
            uint32_t minLayerZ, uint32_t maxLayerZ);

    // release memory occupied by the screenshot
+10 −10
Original line number Diff line number Diff line
@@ -102,15 +102,15 @@ public:
        remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
    }

    virtual status_t captureScreen(DisplayID dpy,
            sp<IMemoryHeap>* heap,
    virtual status_t captureScreen(
            const sp<IBinder>& display, sp<IMemoryHeap>* heap,
            uint32_t* width, uint32_t* height, PixelFormat* format,
            uint32_t reqWidth, uint32_t reqHeight,
            uint32_t minLayerZ, uint32_t maxLayerZ)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeInt32(dpy);
        data.writeStrongBinder(display);
        data.writeInt32(reqWidth);
        data.writeInt32(reqHeight);
        data.writeInt32(minLayerZ);
@@ -210,18 +210,18 @@ public:
        remote()->transact(BnSurfaceComposer::UNBLANK, data, &reply);
    }

    virtual status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info)
    virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeInt32(dpy);
        data.writeStrongBinder(display);
        remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
        memcpy(info, reply.readInplace(sizeof(DisplayInfo)), sizeof(DisplayInfo));
        return reply.readInt32();
    }


    virtual void connectDisplay(const sp<ISurfaceTexture> display) {
    virtual void connectDisplay(const sp<ISurfaceTexture>& display) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeStrongBinder(display->asBinder());
@@ -274,7 +274,7 @@ status_t BnSurfaceComposer::onTransact(
        } break;
        case CAPTURE_SCREEN: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            DisplayID dpy = data.readInt32();
            sp<IBinder> display = data.readStrongBinder();
            uint32_t reqWidth = data.readInt32();
            uint32_t reqHeight = data.readInt32();
            uint32_t minLayerZ = data.readInt32();
@@ -282,7 +282,7 @@ status_t BnSurfaceComposer::onTransact(
            sp<IMemoryHeap> heap;
            uint32_t w, h;
            PixelFormat f;
            status_t res = captureScreen(dpy, &heap, &w, &h, &f,
            status_t res = captureScreen(display, &heap, &w, &h, &f,
                    reqWidth, reqHeight, minLayerZ, maxLayerZ);
            reply->writeStrongBinder(heap->asBinder());
            reply->writeInt32(w);
@@ -327,8 +327,8 @@ status_t BnSurfaceComposer::onTransact(
        case GET_DISPLAY_INFO: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            DisplayInfo info;
            DisplayID dpy = data.readInt32();
            status_t result = getDisplayInfo(dpy, &info);
            sp<IBinder> display = data.readStrongBinder();
            status_t result = getDisplayInfo(display, &info);
            memcpy(reply->writeInplace(sizeof(DisplayInfo)), &info, sizeof(DisplayInfo));
            reply->writeInt32(result);
        } break;
Loading