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

Commit d51ac5e0 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Remove displayBounds when computing layer bounds" into sc-v2-dev

parents 892082b8 3c332b3f
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -2413,23 +2413,28 @@ void SurfaceFlinger::postComposition() {
    }
}

FloatRect SurfaceFlinger::getLayerClipBoundsForDisplay(const DisplayDevice& displayDevice) const {
    return displayDevice.getLayerStackSpaceRect().toFloatRect();
}

void SurfaceFlinger::computeLayerBounds() {
    // Find the largest width and height among all the displays.
    int32_t maxDisplayWidth = 0;
    int32_t maxDisplayHeight = 0;
    for (const auto& pair : ON_MAIN_THREAD(mDisplays)) {
        const auto& displayDevice = pair.second;
        const auto display = displayDevice->getCompositionDisplay();
        for (const auto& layer : mDrawingState.layersSortedByZ) {
            // only consider the layers on the given layer stack
            if (!display->belongsInOutput(layer->getLayerStack(), layer->getPrimaryDisplayOnly())) {
                continue;
        int32_t width = displayDevice->getWidth();
        int32_t height = displayDevice->getHeight();
        if (width > maxDisplayWidth) {
            maxDisplayWidth = width;
        }
        if (height > maxDisplayHeight) {
            maxDisplayHeight = height;
        }

            layer->computeBounds(getLayerClipBoundsForDisplay(*displayDevice), ui::Transform(),
                                 0.f /* shadowRadius */);
    }

    // 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);
    for (const auto& layer : mDrawingState.layersSortedByZ) {
        layer->computeBounds(maxBounds, ui::Transform(), 0.f /* shadowRadius */);
    }
}

+0 −7
Original line number Diff line number Diff line
@@ -350,13 +350,6 @@ protected:
            REQUIRES(mStateLock);
    virtual void commitTransactionLocked();

    // Used internally by computeLayerBounds() to gets the clip rectangle to use for the
    // root layers on a particular display in layer-coordinate space. The
    // layers (and effectively their children) will be clipped against this
    // rectangle. The base behavior is to clip to the visible region of the
    // display.
    virtual FloatRect getLayerClipBoundsForDisplay(const DisplayDevice&) const;

    virtual void processDisplayAdded(const wp<IBinder>& displayToken, const DisplayDeviceState&)
            REQUIRES(mStateLock);

+9 −0
Original line number Diff line number Diff line
@@ -176,6 +176,15 @@ TEST_F(EffectLayerTest, BlurEffectLayerIsVisible) {
    }
}

TEST_F(EffectLayerTest, EffectLayerWithColorNoCrop) {
    const auto display = SurfaceComposerClient::getInternalDisplayToken();
    ui::DisplayMode mode;
    ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode));
    const ui::Size& resolution = mode.resolution;
    auto shot = screenshot();
    shot->expectColor(Rect(0, 0, resolution.getWidth(), resolution.getHeight()), Color::RED);
}

} // namespace android

// TODO(b/129481165): remove the #pragma below and fix conversion issues