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

Commit fd1b40bd authored by Jeykumar Sankaran's avatar Jeykumar Sankaran Committed by Linux Build Service Account
Browse files

SurfaceFlinger: Add support for virtual display

- Creates a rendering surface when invoked via hybrid path
- Makes changes in HWC wrapper to handle virtual display via HWC

Change-Id: I86560b5009949b75c267249799a446b8279eff32
parent 43e5a299
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -161,7 +161,7 @@ HWComposer::HWComposer(
            mNumDisplays = MAX_DISPLAYS;
            mNumDisplays = MAX_DISPLAYS;
        } else if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
        } else if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
            // 1.1 adds support for multiple displays
            // 1.1 adds support for multiple displays
            mNumDisplays = NUM_PHYSICAL_DISPLAYS;
            mNumDisplays = MAX_DISPLAYS;
        } else {
        } else {
            mNumDisplays = 1;
            mNumDisplays = 1;
        }
        }
+35 −1
Original line number Original line Diff line number Diff line
@@ -1057,6 +1057,26 @@ void SurfaceFlinger::handleTransaction(uint32_t transactionFlags)
    // here the transaction has been committed
    // here the transaction has been committed
}
}


void SurfaceFlinger::setVirtualDisplayData(
    int32_t hwcDisplayId,
    const sp<IGraphicBufferProducer>& sink)
{
    sp<ANativeWindow> mNativeWindow = new Surface(sink);
    ANativeWindow* const window = mNativeWindow.get();

    int format;
    window->query(window, NATIVE_WINDOW_FORMAT, &format);

    EGLSurface surface;
    EGLint w, h;
    EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    surface = eglCreateWindowSurface(display, mEGLConfig, window, NULL);
    eglQuerySurface(display, surface, EGL_WIDTH,  &w);
    eglQuerySurface(display, surface, EGL_HEIGHT, &h);

    mHwc->setVirtualDisplayProperties(hwcDisplayId, w, h, format);
}

void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
{
{
    const LayerVector& currentLayers(mCurrentState.layersSortedByZ);
    const LayerVector& currentLayers(mCurrentState.layersSortedByZ);
@@ -1166,9 +1186,23 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
                        // etc.) but no internal state (i.e. a DisplayDevice).
                        // etc.) but no internal state (i.e. a DisplayDevice).
                        if (state.surface != NULL) {
                        if (state.surface != NULL) {
                            hwcDisplayId = allocateHwcDisplayId(state.type);
                            hwcDisplayId = allocateHwcDisplayId(state.type);

                            char value[PROPERTY_VALUE_MAX];
                            property_get("persist.sys.wfd.virtual", value, "0");
                            int wfdVirtual = atoi(value);
                            if(!wfdVirtual) {
                                dispSurface = new VirtualDisplaySurface(
                                dispSurface = new VirtualDisplaySurface(
                                    *mHwc, hwcDisplayId, state.surface,
                                    *mHwc, hwcDisplayId, state.surface,
                                    state.displayName);
                                    state.displayName);
                            } else {
                                //Read virtual display properties and create a
                                //rendering surface for it inorder to be handled
                                //by hwc.
                                setVirtualDisplayData(hwcDisplayId,
                                                                 state.surface);
                                dispSurface = new FramebufferSurface(*mHwc,
                                                                    state.type);
                            }
                        }
                        }
                    } else {
                    } else {
                        ALOGE_IF(state.surface!=NULL,
                        ALOGE_IF(state.surface!=NULL,
+4 −0
Original line number Original line Diff line number Diff line
@@ -232,6 +232,10 @@ private:
    void handleTransaction(uint32_t transactionFlags);
    void handleTransaction(uint32_t transactionFlags);
    void handleTransactionLocked(uint32_t transactionFlags);
    void handleTransactionLocked(uint32_t transactionFlags);


    // Read virtual display properties
    void setVirtualDisplayData( int32_t hwcDisplayId,
                                const sp<IGraphicBufferProducer>& sink);

    /* handlePageFilp: this is were we latch a new buffer
    /* handlePageFilp: this is were we latch a new buffer
     * if available and compute the dirty region.
     * if available and compute the dirty region.
     */
     */