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

Commit dcc9d9b5 authored by Marzia Favaro's avatar Marzia Favaro
Browse files

Edge extension effect: shader reimplementation

X-axis activity transitions require the translation of the surfaces
involved. As this movement would create unwanted see-through, we would
have added side windows anchored to the moving activities, and textured
them by clamping their parents.

We are replacing the additional windows with the extension of the
surfaces, and filling the area without buffer with a shader.

See go/edge-extension-sksl for more info.

Bug: 322036393
Test: LayerSnapshotTest
Flag: EXEMPT (calls will be protected by wm shell with com.android.window.flags.edge_extension_shader)
Change-Id: I3682efd16a1b311d67a522bb85960f100948b2ea
parent 5b85b973
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -177,6 +177,7 @@ status_t layer_state_t::write(Parcel& output) const
    }

    SAFE_PARCEL(output.write, stretchEffect);
    SAFE_PARCEL(output.writeParcelable, edgeExtensionParameters);
    SAFE_PARCEL(output.write, bufferCrop);
    SAFE_PARCEL(output.write, destinationFrame);
    SAFE_PARCEL(output.writeInt32, static_cast<uint32_t>(trustedOverlay));
@@ -306,6 +307,7 @@ status_t layer_state_t::read(const Parcel& input)
    }

    SAFE_PARCEL(input.read, stretchEffect);
    SAFE_PARCEL(input.readParcelable, &edgeExtensionParameters);
    SAFE_PARCEL(input.read, bufferCrop);
    SAFE_PARCEL(input.read, destinationFrame);
    uint32_t trustedOverlayInt;
@@ -682,6 +684,10 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eStretchChanged;
        stretchEffect = other.stretchEffect;
    }
    if (other.what & eEdgeExtensionChanged) {
        what |= eEdgeExtensionChanged;
        edgeExtensionParameters = other.edgeExtensionParameters;
    }
    if (other.what & eBufferCropChanged) {
        what |= eBufferCropChanged;
        bufferCrop = other.bufferCrop;
@@ -783,6 +789,7 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const {
    CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
    CHECK_DIFF(diff, eTrustedOverlayChanged, other, trustedOverlay);
    CHECK_DIFF(diff, eStretchChanged, other, stretchEffect);
    CHECK_DIFF(diff, eEdgeExtensionChanged, other, edgeExtensionParameters);
    CHECK_DIFF(diff, eBufferCropChanged, other, bufferCrop);
    CHECK_DIFF(diff, eDestinationFrameChanged, other, destinationFrame);
    if (other.what & eProducerDisconnect) diff |= eProducerDisconnect;
+14 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include <android/gui/BnWindowInfosReportedListener.h>
#include <android/gui/DisplayState.h>
#include <android/gui/EdgeExtensionParameters.h>
#include <android/gui/ISurfaceComposerClient.h>
#include <android/gui/IWindowInfosListener.h>
#include <android/gui/TrustedPresentationThresholds.h>
@@ -2330,6 +2331,19 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setStret
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setEdgeExtensionEffect(
        const sp<SurfaceControl>& sc, const gui::EdgeExtensionParameters& effect) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }

    s->what |= layer_state_t::eEdgeExtensionChanged;
    s->edgeExtensionParameters = effect;
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBufferCrop(
        const sp<SurfaceControl>& sc, const Rect& bufferCrop) {
    layer_state_t* s = getLayerState(sc);
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.gui;


/** @hide */
parcelable EdgeExtensionParameters {
    // These represent the translation of the window as requested by the animation
    boolean extendRight;
    boolean extendLeft;
    boolean extendTop;
    boolean extendBottom;
}
 No newline at end of file
+6 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <math/mat4.h>

#include <android/gui/DropInputMode.h>
#include <android/gui/EdgeExtensionParameters.h>
#include <android/gui/FocusRequest.h>
#include <android/gui/TrustedOverlay.h>

@@ -218,6 +219,7 @@ struct layer_state_t {
        eTrustedOverlayChanged = 0x4000'00000000,
        eDropInputModeChanged = 0x8000'00000000,
        eExtendedRangeBrightnessChanged = 0x10000'00000000,
        eEdgeExtensionChanged = 0x20000'00000000,
    };

    layer_state_t();
@@ -241,7 +243,7 @@ struct layer_state_t {
            layer_state_t::eCropChanged | layer_state_t::eDestinationFrameChanged |
            layer_state_t::eMatrixChanged | layer_state_t::ePositionChanged |
            layer_state_t::eTransformToDisplayInverseChanged |
            layer_state_t::eTransparentRegionChanged;
            layer_state_t::eTransparentRegionChanged | layer_state_t::eEdgeExtensionChanged;

    // Buffer and related updates.
    static constexpr uint64_t BUFFER_CHANGES = layer_state_t::eApiChanged |
@@ -393,6 +395,9 @@ struct layer_state_t {
    // Stretch effect to be applied to this layer
    StretchEffect stretchEffect;

    // Edge extension effect to be applied to this layer
    gui::EdgeExtensionParameters edgeExtensionParameters;

    Rect bufferCrop;
    Rect destinationFrame;

+12 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <ui/BlurRegion.h>
#include <ui/ConfigStoreTypes.h>
#include <ui/DisplayedFrameStats.h>
#include <ui/EdgeExtensionEffect.h>
#include <ui/FrameStats.h>
#include <ui/GraphicTypes.h>
#include <ui/PixelFormat.h>
@@ -744,6 +745,17 @@ public:
        Transaction& setStretchEffect(const sp<SurfaceControl>& sc,
                                      const StretchEffect& stretchEffect);

        /**
         * Provides the edge extension effect configured on a container that the
         * surface is rendered within.
         * @param sc target surface the edge extension should be applied to
         * @param effect the corresponding EdgeExtensionParameters to be applied
         *    to the surface.
         * @return The transaction being constructed
         */
        Transaction& setEdgeExtensionEffect(const sp<SurfaceControl>& sc,
                                            const gui::EdgeExtensionParameters& effect);

        Transaction& setBufferCrop(const sp<SurfaceControl>& sc, const Rect& bufferCrop);
        Transaction& setDestinationFrame(const sp<SurfaceControl>& sc,
                                         const Rect& destinationFrame);
Loading