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

Commit 502fb739 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7880955 from ebff6bd2 to sc-v2-release

Change-Id: Icb15527837cd7d5dbe76fbcdb4aaf2ffcd6aa73f
parents 6791e903 ebff6bd2
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -421,8 +421,6 @@ void Layer::prepareBasicGeometryCompositionState() {

    compositionState->blendMode = static_cast<Hwc2::IComposerClient::BlendMode>(blendMode);
    compositionState->alpha = alpha;
    compositionState->backgroundBlurRadius = drawingState.backgroundBlurRadius;
    compositionState->blurRegions = drawingState.blurRegions;
    compositionState->stretchEffect = getStretchEffect();
}

@@ -498,6 +496,9 @@ void Layer::preparePerFrameCompositionState() {
        compositionState->stretchEffect.hasEffect()) {
        compositionState->forceClientComposition = true;
    }
    // If there are no visible region changes, we still need to update blur parameters.
    compositionState->blurRegions = drawingState.blurRegions;
    compositionState->backgroundBlurRadius = drawingState.backgroundBlurRadius;
}

void Layer::prepareCursorCompositionState() {
@@ -938,8 +939,11 @@ bool Layer::setCornerRadius(float cornerRadius) {

bool Layer::setBackgroundBlurRadius(int backgroundBlurRadius) {
    if (mDrawingState.backgroundBlurRadius == backgroundBlurRadius) return false;

    // If we start or stop drawing blur then the layer's visibility state may change so increment
    // the magic sequence number.
    if (mDrawingState.backgroundBlurRadius == 0 || backgroundBlurRadius == 0) {
        mDrawingState.sequence++;
    }
    mDrawingState.backgroundBlurRadius = backgroundBlurRadius;
    mDrawingState.modified = true;
    setTransactionFlags(eTransactionNeeded);
@@ -972,6 +976,11 @@ bool Layer::setTransparentRegionHint(const Region& transparent) {
}

bool Layer::setBlurRegions(const std::vector<BlurRegion>& blurRegions) {
    // If we start or stop drawing blur then the layer's visibility state may change so increment
    // the magic sequence number.
    if (mDrawingState.blurRegions.size() == 0 || blurRegions.size() == 0) {
        mDrawingState.sequence++;
    }
    mDrawingState.blurRegions = blurRegions;
    mDrawingState.modified = true;
    setTransactionFlags(eTransactionNeeded);
+14 −0
Original line number Diff line number Diff line
@@ -94,8 +94,22 @@ void LayerRenderArea::render(std::function<void()> drawLayers) {
    // no need to check rotation because there is none
    mNeedsFiltering = sourceCrop.width() != getReqWidth() || sourceCrop.height() != getReqHeight();

    // If layer is offscreen, update mirroring info if it exists
    if (mLayer->isRemovedFromCurrentState()) {
        mLayer->traverse(LayerVector::StateSet::Drawing,
                         [&](Layer* layer) { layer->updateMirrorInfo(); });
        mLayer->traverse(LayerVector::StateSet::Drawing,
                         [&](Layer* layer) { layer->updateCloneBufferInfo(); });
    }

    if (!mChildrenOnly) {
        mTransform = mLayer->getTransform().inverse();
        // If the layer is offscreen, compute bounds since we don't compute bounds for offscreen
        // layers in a regular cycles.
        if (mLayer->isRemovedFromCurrentState()) {
            FloatRect maxBounds = mFlinger.getMaxDisplayBounds();
            mLayer->computeBounds(maxBounds, ui::Transform(), 0.f /* shadowRadius */);
        }
        drawLayers();
    } else {
        uint32_t w = static_cast<uint32_t>(getWidth());
+20 −20
Original line number Diff line number Diff line
@@ -2455,7 +2455,7 @@ void SurfaceFlinger::postComposition() {
    }
}

void SurfaceFlinger::computeLayerBounds() {
FloatRect SurfaceFlinger::getMaxDisplayBounds() {
    // Find the largest width and height among all the displays.
    int32_t maxDisplayWidth = 0;
    int32_t maxDisplayHeight = 0;
@@ -2473,8 +2473,13 @@ void SurfaceFlinger::computeLayerBounds() {

    // Ignore display bounds for now since they will be computed later. Use a large Rect bound
    // to ensure it's bigger than an actual display will be.
    FloatRect maxBounds(-maxDisplayWidth * 10, -maxDisplayHeight * 10, maxDisplayWidth * 10,
                        maxDisplayHeight * 10);
    FloatRect maxBounds = FloatRect(-maxDisplayWidth * 10, -maxDisplayHeight * 10,
                                    maxDisplayWidth * 10, maxDisplayHeight * 10);
    return maxBounds;
}

void SurfaceFlinger::computeLayerBounds() {
    FloatRect maxBounds = getMaxDisplayBounds();
    for (const auto& layer : mDrawingState.layersSortedByZ) {
        layer->computeBounds(maxBounds, ui::Transform(), 0.f /* shadowRadius */);
    }
@@ -6167,9 +6172,7 @@ status_t SurfaceFlinger::captureLayers(const LayerCaptureArgs& args,
    sp<Layer> parent;
    Rect crop(args.sourceCrop);
    std::unordered_set<sp<Layer>, ISurfaceComposer::SpHash<Layer>> excludeLayers;
    Rect layerStackSpaceRect;
    ui::Dataspace dataspace;
    bool captureSecureLayers;

    // Call this before holding mStateLock to avoid any deadlocking.
    bool canCaptureBlackoutContent = hasCaptureBlackoutContentPermission();
@@ -6178,7 +6181,7 @@ status_t SurfaceFlinger::captureLayers(const LayerCaptureArgs& args,
        Mutex::Autolock lock(mStateLock);

        parent = fromHandle(args.layerHandle).promote();
        if (parent == nullptr || parent->isRemovedFromCurrentState()) {
        if (parent == nullptr) {
            ALOGE("captureLayers called with an invalid or removed parent");
            return NAME_NOT_FOUND;
        }
@@ -6217,39 +6220,36 @@ status_t SurfaceFlinger::captureLayers(const LayerCaptureArgs& args,
            }
        }

        const auto display = findDisplay(WithLayerStack(parent->getLayerStack()));
        if (!display) {
            return NAME_NOT_FOUND;
        }

        layerStackSpaceRect = display->getLayerStackSpaceRect();

        // The dataspace is depended on the color mode of display, that could use non-native mode
        // (ex. displayP3) to enhance the content, but some cases are checking native RGB in bytes,
        // and failed if display is not in native mode. This provide a way to force using native
        // colors when capture.
        dataspace = args.dataspace;
        if (dataspace == ui::Dataspace::UNKNOWN) {
            auto display = findDisplay(WithLayerStack(parent->getLayerStack()));
            if (!display) {
                // If the layer is not on a display, use the dataspace for the default display.
                display = getDefaultDisplayDeviceLocked();
            }

            const ui::ColorMode colorMode = display->getCompositionDisplay()->getState().colorMode;
            dataspace = pickDataspaceFromColorMode(colorMode);
        }

        captureSecureLayers = args.captureSecureLayers && display->isSecure();
    } // mStateLock

    // really small crop or frameScale
    if (reqSize.width <= 0) {
        reqSize.width = 1;
    }
    if (reqSize.height <= 0) {
        reqSize.height = 1;
    if (reqSize.width <= 0 || reqSize.height <= 0) {
        ALOGW("Failed to captureLayes: crop or scale too small");
        return BAD_VALUE;
    }

    Rect layerStackSpaceRect(0, 0, reqSize.width, reqSize.height);
    bool childrenOnly = args.childrenOnly;
    RenderAreaFuture renderAreaFuture = ftl::defer([=]() -> std::unique_ptr<RenderArea> {
        return std::make_unique<LayerRenderArea>(*this, parent, crop, reqSize, dataspace,
                                                 childrenOnly, layerStackSpaceRect,
                                                 captureSecureLayers);
                                                 args.captureSecureLayers);
    });

    auto traverseLayers = [parent, args, excludeLayers](const LayerVector::Visitor& visitor) {
+1 −0
Original line number Diff line number Diff line
@@ -337,6 +337,7 @@ public:
    // Disables expensive rendering for all displays
    // This is scheduled on the main thread
    void disableExpensiveRendering();
    FloatRect getMaxDisplayBounds();

protected:
    // We're reference counted, never destroy SurfaceFlinger directly
+0 −11
Original line number Diff line number Diff line
@@ -52,17 +52,6 @@ protected:
    }
};

TEST_F(InvalidHandleTest, createSurfaceInvalidParentHandle) {
    // The createSurface is scheduled now, we could still get a created surface from createSurface.
    // Should verify if it actually added into current state by checking the screenshot.
    auto notSc = mScc->createSurface(String8("lolcats"), 19, 47, PIXEL_FORMAT_RGBA_8888, 0,
                                     mNotSc->getHandle());
    LayerCaptureArgs args;
    args.layerHandle = notSc->getHandle();
    ScreenCaptureResults captureResults;
    ASSERT_EQ(NAME_NOT_FOUND, ScreenCapture::captureLayers(args, captureResults));
}

TEST_F(InvalidHandleTest, captureLayersInvalidHandle) {
    LayerCaptureArgs args;
    args.layerHandle = mNotSc->getHandle();
Loading