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

Commit ec96c171 authored by Jeykumar Sankaran's avatar Jeykumar Sankaran Committed by Manish Kumar
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
(cherry picked from commit 577c0753b7aef84b99252545dc256c66d4f9d028)
(cherry picked from commit 80062f383e7dc012a0ac5eb6f33b8b8edc21377a)
parent 48d7b507
Loading
Loading
Loading
Loading
+42 −9
Original line number Diff line number Diff line
@@ -1244,6 +1244,26 @@ void SurfaceFlinger::handleTransaction(uint32_t transactionFlags)
    // 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)
{
    const LayerVector& currentLayers(mCurrentState.layersSortedByZ);
@@ -1356,19 +1376,32 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
                        // etc.) but no internal state (i.e. a DisplayDevice).
                        if (state.surface != NULL) {

                            char value[PROPERTY_VALUE_MAX];
                            hwcDisplayId = allocateHwcDisplayId(state.type);
                            sp<VirtualDisplaySurface> vds = new VirtualDisplaySurface(
                            property_get("persist.sys.wfd.virtual", value, "0");
                            int wfdVirtual = atoi(value);
                            if(!wfdVirtual) {
                                sp<VirtualDisplaySurface> dispSurface =
                                              new VirtualDisplaySurface(
                                    *mHwc, hwcDisplayId, state.surface, bq,
                                    state.displayName);

                            dispSurface = vds;
                                if (hwcDisplayId >= 0) {
                                producer = vds;
                                   producer = dispSurface;
                                } else {
                                  // There won't be any interaction with HWC for this virtual display,
                                  // so the GLES driver can pass buffers directly to the sink.
                                  producer = state.surface;
                                }
                            } 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, bq);
                                producer = bq;
                            }
                        }
                    } else {
                        ALOGE_IF(state.surface!=NULL,
@@ -1383,7 +1416,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
                    }

                    const wp<IBinder>& display(curr.keyAt(i));
                    if (dispSurface != NULL) {
                    if (dispSurface != NULL && producer != NULL) {
                        sp<DisplayDevice> hw = new DisplayDevice(this,
                                state.type, hwcDisplayId, state.isSecure,
                                display, dispSurface, producer, mEGLConfig);
+4 −0
Original line number Diff line number Diff line
@@ -248,6 +248,10 @@ private:
    void handleTransaction(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
     * if available and compute the dirty region.
     */