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

Commit b3206283 authored by Lloyd Pique's avatar Lloyd Pique
Browse files

Create processDisplayChangesLocked

This simply extracts the code in handleTransactionLocked for the
eDisplayTransactionNeeded case into its own function.

There were no changes other than a quick clang-format of the extracted function.

Bug: 38464421
Test: Builds
Change-Id: Id84f5b990fb6818db1f8b0c37ac02bf3caa26002
Merged-In: Id84f5b990fb6818db1f8b0c37ac02bf3caa26002
(cherry picked from commit 347200f0)
parent 14906cd8
Loading
Loading
Loading
Loading
+144 −157
Original line number Diff line number Diff line
@@ -2089,34 +2089,7 @@ void SurfaceFlinger::handleTransaction(uint32_t transactionFlags)
    // here the transaction has been committed
}

void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
{
    // Notify all layers of available frames
    mCurrentState.traverseInZOrder([](Layer* layer) {
        layer->notifyAvailableFrames();
    });

    /*
     * Traversal of the children
     * (perform the transaction for each of them if needed)
     */

    if (transactionFlags & eTraversalNeeded) {
        mCurrentState.traverseInZOrder([&](Layer* layer) {
            uint32_t trFlags = layer->getTransactionFlags(eTransactionNeeded);
            if (!trFlags) return;

            const uint32_t flags = layer->doTransaction(0);
            if (flags & Layer::eVisibleRegion)
                mVisibleRegionsDirty = true;
        });
    }

    /*
     * Perform display own transactions if needed
     */

    if (transactionFlags & eDisplayTransactionNeeded) {
void SurfaceFlinger::processDisplayChangesLocked() {
    // here we take advantage of Vector's copy-on-write semantics to
    // improve performance by skipping the transaction entirely when
    // know that the lists are identical
@@ -2142,8 +2115,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
                    const sp<const DisplayDevice> defaultDisplay(getDefaultDisplayDeviceLocked());
                    defaultDisplay->makeCurrent(mEGLDisplay, mEGLContext);
                    sp<DisplayDevice> hw(getDisplayDeviceLocked(draw.keyAt(i)));
                        if (hw != NULL)
                            hw->disconnect(getHwComposer());
                    if (hw != NULL) hw->disconnect(getHwComposer());
                    if (draw[i].type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES)
                        mEventThread->onHotplugReceived(draw[i].type, false);
                    mDisplays.removeItem(draw.keyAt(i));
@@ -2162,8 +2134,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
                    // from the drawing state, so that it get re-added
                    // below.
                    sp<DisplayDevice> hw(getDisplayDeviceLocked(display));
                        if (hw != NULL)
                            hw->disconnect(getHwComposer());
                    if (hw != NULL) hw->disconnect(getHwComposer());
                    mDisplays.removeItem(display);
                    mDrawingState.displays.removeItemsAt(i);
                    dc--;
@@ -2176,12 +2147,9 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
                    if (state.layerStack != draw[i].layerStack) {
                        disp->setLayerStack(state.layerStack);
                    }
                        if ((state.orientation != draw[i].orientation)
                                || (state.viewport != draw[i].viewport)
                                || (state.frame != draw[i].frame))
                        {
                            disp->setProjection(state.orientation,
                                    state.viewport, state.frame);
                    if ((state.orientation != draw[i].orientation) ||
                        (state.viewport != draw[i].viewport) || (state.frame != draw[i].frame)) {
                        disp->setProjection(state.orientation, state.viewport, state.frame);
                    }
                    if (state.width != draw[i].width || state.height != draw[i].height) {
                        disp->setDisplaySize(state.width, state.height);
@@ -2209,36 +2177,26 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
                    // they have external state (layer stack, projection,
                    // etc.) but no internal state (i.e. a DisplayDevice).
                    if (state.surface != NULL) {

                        // Allow VR composer to use virtual displays.
                        if (mUseHwcVirtualDisplays || mHwc->isUsingVrComposer()) {
                            int width = 0;
                                int status = state.surface->query(
                                        NATIVE_WINDOW_WIDTH, &width);
                                ALOGE_IF(status != NO_ERROR,
                                        "Unable to query width (%d)", status);
                            int status = state.surface->query(NATIVE_WINDOW_WIDTH, &width);
                            ALOGE_IF(status != NO_ERROR, "Unable to query width (%d)", status);
                            int height = 0;
                                status = state.surface->query(
                                        NATIVE_WINDOW_HEIGHT, &height);
                                ALOGE_IF(status != NO_ERROR,
                                        "Unable to query height (%d)", status);
                            status = state.surface->query(NATIVE_WINDOW_HEIGHT, &height);
                            ALOGE_IF(status != NO_ERROR, "Unable to query height (%d)", status);
                            int intFormat = 0;
                                status = state.surface->query(
                                        NATIVE_WINDOW_FORMAT, &intFormat);
                                ALOGE_IF(status != NO_ERROR,
                                        "Unable to query format (%d)", status);
                                auto format = static_cast<android_pixel_format_t>(
                                        intFormat);
                            status = state.surface->query(NATIVE_WINDOW_FORMAT, &intFormat);
                            ALOGE_IF(status != NO_ERROR, "Unable to query format (%d)", status);
                            auto format = static_cast<android_pixel_format_t>(intFormat);

                                mHwc->allocateVirtualDisplay(width, height, &format,
                                        &hwcId);
                            mHwc->allocateVirtualDisplay(width, height, &format, &hwcId);
                        }

                        // TODO: Plumb requested format back up to consumer

                        sp<VirtualDisplaySurface> vds =
                                    new VirtualDisplaySurface(*mHwc,
                                            hwcId, state.surface, bqProducer,
                                new VirtualDisplaySurface(*mHwc, hwcId, state.surface, bqProducer,
                                                          bqConsumer, state.displayName);

                        dispSurface = vds;
@@ -2259,12 +2217,10 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
                if (dispSurface != NULL) {
                    sp<DisplayDevice> hw =
                            new DisplayDevice(this, state.type, hwcId, state.isSecure, display,
                                                  dispSurface, producer,
                                                  mRenderEngine->getEGLConfig(),
                                              dispSurface, producer, mRenderEngine->getEGLConfig(),
                                              hasWideColorDisplay);
                    hw->setLayerStack(state.layerStack);
                        hw->setProjection(state.orientation,
                                state.viewport, state.frame);
                    hw->setProjection(state.orientation, state.viewport, state.frame);
                    hw->setDisplayName(state.displayName);
                    mDisplays.add(display, hw);
                    if (!state.isVirtualDisplay()) {
@@ -2276,6 +2232,37 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
    }
}

void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
{
    // Notify all layers of available frames
    mCurrentState.traverseInZOrder([](Layer* layer) {
        layer->notifyAvailableFrames();
    });

    /*
     * Traversal of the children
     * (perform the transaction for each of them if needed)
     */

    if (transactionFlags & eTraversalNeeded) {
        mCurrentState.traverseInZOrder([&](Layer* layer) {
            uint32_t trFlags = layer->getTransactionFlags(eTransactionNeeded);
            if (!trFlags) return;

            const uint32_t flags = layer->doTransaction(0);
            if (flags & Layer::eVisibleRegion)
                mVisibleRegionsDirty = true;
        });
    }

    /*
     * Perform display own transactions if needed
     */

    if (transactionFlags & eDisplayTransactionNeeded) {
        processDisplayChangesLocked();
    }

    if (transactionFlags & (eTraversalNeeded|eDisplayTransactionNeeded)) {
        // The transform hint might have changed for some layers
        // (either because a display has changed, or because a layer
+1 −0
Original line number Diff line number Diff line
@@ -576,6 +576,7 @@ private:
    /* ------------------------------------------------------------------------
     * Display management
     */
    void processDisplayChangesLocked();

    /* ------------------------------------------------------------------------
     * VSync