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

Commit b722e2d5 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "[sf] resolve handles to layer ids in binder thread" into udc-dev

parents a8014b73 1391de29
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -65,6 +65,10 @@ LayerCreationArgs::LayerCreationArgs(SurfaceFlinger* flinger, sp<Client> client,
    }
}

LayerCreationArgs::LayerCreationArgs(std::optional<uint32_t> id, bool internalLayer)
      : LayerCreationArgs(nullptr, nullptr, /*name=*/"", /*flags=*/0, /*metadata=*/{}, id,
                          internalLayer) {}

LayerCreationArgs::LayerCreationArgs(const LayerCreationArgs& args)
      : LayerCreationArgs(args.flinger, args.client, args.name, args.flags, args.metadata) {}

+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ struct LayerCreationArgs {
    LayerCreationArgs(android::SurfaceFlinger*, sp<android::Client>, std::string name,
                      uint32_t flags, gui::LayerMetadata, std::optional<uint32_t> id = std::nullopt,
                      bool internalLayer = false);
    LayerCreationArgs(std::optional<uint32_t> id, bool internalLayer = false);

    LayerCreationArgs(const LayerCreationArgs&);

    android::SurfaceFlinger* flinger;
@@ -56,6 +58,8 @@ struct LayerCreationArgs {
    wp<IBinder> parentHandle = nullptr;
    wp<IBinder> mirrorLayerHandle = nullptr;
    ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK;
    uint32_t parentId = UNASSIGNED_LAYER_ID;
    uint32_t layerIdToMirror = UNASSIGNED_LAYER_ID;
};

} // namespace android::surfaceflinger
+10 −14
Original line number Diff line number Diff line
@@ -20,8 +20,7 @@
#define LOG_TAG "LayerLifecycleManager"

#include "LayerLifecycleManager.h"
#include "Layer.h" // temporarily needed for LayerHandle
#include "LayerHandle.h"
#include "Client.h" // temporarily needed for LayerCreationArgs
#include "LayerLog.h"
#include "SwapErase.h"

@@ -167,7 +166,7 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState
    for (const auto& transaction : transactions) {
        for (const auto& resolvedComposerState : transaction.states) {
            const auto& clientState = resolvedComposerState.state;
            uint32_t layerId = LayerHandle::getLayerId(clientState.surface);
            uint32_t layerId = resolvedComposerState.layerId;
            if (layerId == UNASSIGNED_LAYER_ID) {
                ALOGW("%s Handle %p is not valid", __func__, clientState.surface.get());
                continue;
@@ -175,15 +174,14 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState

            RequestedLayerState* layer = getLayerFromId(layerId);
            if (layer == nullptr) {
                LOG_ALWAYS_FATAL("%s Layer with handle %p (layerid=%d) not found", __func__,
                                 clientState.surface.get(), layerId);
                LOG_ALWAYS_FATAL("%s Layer with layerid=%d not found", __func__, layerId);
                continue;
            }

            if (!layer->handleAlive) {
                LOG_ALWAYS_FATAL("%s Layer's handle %p (layerid=%d) is not alive. Possible out of "
                LOG_ALWAYS_FATAL("%s Layer's with layerid=%d) is not alive. Possible out of "
                                 "order LayerLifecycleManager updates",
                                 __func__, clientState.surface.get(), layerId);
                                 __func__, layerId);
                continue;
            }

@@ -198,13 +196,11 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState

            if (layer->what & layer_state_t::eBackgroundColorChanged) {
                if (layer->bgColorLayerId == UNASSIGNED_LAYER_ID && layer->bgColor.a != 0) {
                    LayerCreationArgs backgroundLayerArgs{nullptr,
                                                          nullptr,
                                                          layer->name + "BackgroundColorLayer",
                                                          ISurfaceComposerClient::eFXSurfaceEffect,
                                                          {},
                                                          layer->id,
                                                          /*internalLayer=*/true};
                    LayerCreationArgs backgroundLayerArgs(layer->id,
                                                          /*internalLayer=*/true);
                    backgroundLayerArgs.parentId = layer->id;
                    backgroundLayerArgs.name = layer->name + "BackgroundColorLayer";
                    backgroundLayerArgs.flags = ISurfaceComposerClient::eFXSurfaceEffect;
                    std::vector<std::unique_ptr<RequestedLayerState>> newLayers;
                    newLayers.emplace_back(
                            std::make_unique<RequestedLayerState>(backgroundLayerArgs));
+8 −19
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

#include "Layer.h"
#include "LayerCreationArgs.h"
#include "LayerHandle.h"
#include "LayerLog.h"
#include "RequestedLayerState.h"

@@ -33,14 +32,6 @@ using ftl::Flags;
using namespace ftl::flag_operators;

namespace {
uint32_t getLayerIdFromSurfaceControl(sp<SurfaceControl> surfaceControl) {
    if (!surfaceControl) {
        return UNASSIGNED_LAYER_ID;
    }

    return LayerHandle::getLayerId(surfaceControl->getHandle());
}

std::string layerIdToString(uint32_t layerId) {
    return layerId == UNASSIGNED_LAYER_ID ? "none" : std::to_string(layerId);
}
@@ -64,17 +55,17 @@ RequestedLayerState::RequestedLayerState(const LayerCreationArgs& args)
        layerCreationFlags(args.flags),
        textureName(args.textureName),
        ownerUid(args.ownerUid),
        ownerPid(args.ownerPid) {
        ownerPid(args.ownerPid),
        parentId(args.parentId),
        layerIdToMirror(args.layerIdToMirror) {
    layerId = static_cast<int32_t>(args.sequence);
    changes |= RequestedLayerState::Changes::Created;
    metadata.merge(args.metadata);
    changes |= RequestedLayerState::Changes::Metadata;
    handleAlive = true;
    parentId = LayerHandle::getLayerId(args.parentHandle.promote());
    if (args.parentHandle != nullptr) {
    if (parentId != UNASSIGNED_LAYER_ID) {
        canBeRoot = false;
    }
    layerIdToMirror = LayerHandle::getLayerId(args.mirrorLayerHandle.promote());
    if (layerIdToMirror != UNASSIGNED_LAYER_ID) {
        changes |= RequestedLayerState::Changes::Mirror;
    } else if (args.layerStackToMirror != ui::INVALID_LAYER_STACK) {
@@ -209,7 +200,7 @@ void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerSta
    }
    if (clientState.what & layer_state_t::eReparent) {
        changes |= RequestedLayerState::Changes::Parent;
        parentId = getLayerIdFromSurfaceControl(clientState.parentSurfaceControlForChild);
        parentId = resolvedComposerState.parentId;
        parentSurfaceControlForChild = nullptr;
        // Once a layer has be reparented, it cannot be placed at the root. It sounds odd
        // but thats the existing logic and until we make this behavior more explicit, we need
@@ -218,7 +209,7 @@ void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerSta
    }
    if (clientState.what & layer_state_t::eRelativeLayerChanged) {
        changes |= RequestedLayerState::Changes::RelativeParent;
        relativeParentId = getLayerIdFromSurfaceControl(clientState.relativeLayerSurfaceControl);
        relativeParentId = resolvedComposerState.relativeParentId;
        isRelativeOf = true;
        relativeLayerSurfaceControl = nullptr;
    }
@@ -235,10 +226,8 @@ void RequestedLayerState::merge(const ResolvedComposerState& resolvedComposerSta
        changes |= RequestedLayerState::Changes::RelativeParent;
    }
    if (clientState.what & layer_state_t::eInputInfoChanged) {
        wp<IBinder>& touchableRegionCropHandle =
                windowInfoHandle->editInfo()->touchableRegionCropHandle;
        touchCropId = LayerHandle::getLayerId(touchableRegionCropHandle.promote());
        touchableRegionCropHandle.clear();
        touchCropId = resolvedComposerState.touchCropId;
        windowInfoHandle->editInfo()->touchableRegionCropHandle.clear();
    }
    if (clientState.what & layer_state_t::eStretchChanged) {
        stretchEffect.sanitize();
+5 −5
Original line number Diff line number Diff line
@@ -105,17 +105,17 @@ struct RequestedLayerState : layer_state_t {
    std::shared_ptr<renderengine::ExternalTexture> externalTexture;
    gui::GameMode gameMode;
    scheduler::LayerInfo::FrameRate requestedFrameRate;
    ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK;
    uint32_t parentId = UNASSIGNED_LAYER_ID;
    uint32_t relativeParentId = UNASSIGNED_LAYER_ID;
    uint32_t layerIdToMirror = UNASSIGNED_LAYER_ID;
    ui::LayerStack layerStackToMirror = ui::INVALID_LAYER_STACK;
    uint32_t touchCropId = UNASSIGNED_LAYER_ID;
    uint32_t bgColorLayerId = UNASSIGNED_LAYER_ID;

    // book keeping states
    bool handleAlive = true;
    bool isRelativeOf = false;
    uint32_t parentId = UNASSIGNED_LAYER_ID;
    uint32_t relativeParentId = UNASSIGNED_LAYER_ID;
    std::vector<uint32_t> mirrorIds{};
    uint32_t touchCropId = UNASSIGNED_LAYER_ID;
    uint32_t bgColorLayerId = UNASSIGNED_LAYER_ID;
    ftl::Flags<RequestedLayerState::Changes> changes;
    bool bgColorLayer = false;
};
Loading