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

Commit 6328adc2 authored by Marin Shalamanov's avatar Marin Shalamanov Committed by Android (Google) Code Review
Browse files

Merge "CE: Output::setDisplaySize should change only bounds"

parents 751702b6 2723c4ec
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -167,15 +167,10 @@ void Output::setDisplaySize(const ui::Size& size) {

    // Update framebuffer space
    const Rect newBounds(size);
    ScaleVector scale;
    scale = getScale(state.framebufferSpace.bounds, newBounds);
    state.framebufferSpace.bounds = newBounds;
    state.framebufferSpace.content.scaleSelf(scale.x, scale.y);

    // Update display space
    scale = getScale(state.displaySpace.bounds, newBounds);
    state.displaySpace.bounds = newBounds;
    state.displaySpace.content.scaleSelf(scale.x, scale.y);
    state.transform = state.layerStackSpace.getTransform(state.displaySpace);

    // Update oriented display space
@@ -185,9 +180,7 @@ void Output::setDisplaySize(const ui::Size& size) {
        std::swap(orientedSize.width, orientedSize.height);
    }
    const Rect newOrientedBounds(orientedSize);
    scale = getScale(state.orientedDisplaySpace.bounds, newOrientedBounds);
    state.orientedDisplaySpace.bounds = newOrientedBounds;
    state.orientedDisplaySpace.content.scaleSelf(scale.x, scale.y);

    dirtyEntireOutput();
}
+0 −3
Original line number Diff line number Diff line
@@ -338,15 +338,12 @@ TEST_F(OutputTest, setDisplaySpaceSizeUpdatesOutputStateAndDirtiesEntireOutput)
    EXPECT_EQ(Rect(0, 0, 2000, 1000), state.layerStackSpace.bounds);

    EXPECT_EQ(ui::ROTATION_0, state.orientedDisplaySpace.orientation);
    EXPECT_EQ(Rect(0, 0, 900, 450), state.orientedDisplaySpace.content);
    EXPECT_EQ(Rect(0, 0, 1000, 500), state.orientedDisplaySpace.bounds);

    EXPECT_EQ(displayRect, state.displaySpace.bounds);
    EXPECT_EQ(Rect(0, 0, 450, 900), state.displaySpace.content);
    EXPECT_EQ(ui::ROTATION_90, state.displaySpace.orientation);

    EXPECT_EQ(displayRect, state.framebufferSpace.bounds);
    EXPECT_EQ(Rect(0, 0, 450, 900), state.framebufferSpace.content);
    EXPECT_EQ(ui::ROTATION_90, state.framebufferSpace.orientation);

    EXPECT_EQ(state.displaySpace.content, state.transform.transform(state.layerStackSpace.content));
+62 −6
Original line number Diff line number Diff line
@@ -604,11 +604,11 @@ TEST_F(HandleTransactionLockedTest, processesDisplayLayerStackRectChanges) {
    EXPECT_EQ(newLayerStackRect, display.mutableDisplayDevice()->getLayerStackSpaceRect());
}

TEST_F(HandleTransactionLockedTest, processesDisplayFrameChanges) {
TEST_F(HandleTransactionLockedTest, processesDisplayRectChanges) {
    using Case = NonHwcVirtualDisplayCase;

    const Rect oldFrame(0, 0, 0, 0);
    const Rect newFrame(0, 0, 123, 456);
    const Rect oldDisplayRect(0, 0);
    const Rect newDisplayRect(123, 456);

    // --------------------------------------------------------------------
    // Preconditions
@@ -618,8 +618,8 @@ TEST_F(HandleTransactionLockedTest, processesDisplayFrameChanges) {
    display.inject();

    // There is a change to the layerStackSpaceRect state
    display.mutableDrawingDisplayState().orientedDisplaySpaceRect = oldFrame;
    display.mutableCurrentDisplayState().orientedDisplaySpaceRect = newFrame;
    display.mutableDrawingDisplayState().orientedDisplaySpaceRect = oldDisplayRect;
    display.mutableCurrentDisplayState().orientedDisplaySpaceRect = newDisplayRect;

    // --------------------------------------------------------------------
    // Invocation
@@ -629,7 +629,7 @@ TEST_F(HandleTransactionLockedTest, processesDisplayFrameChanges) {
    // --------------------------------------------------------------------
    // Postconditions

    EXPECT_EQ(newFrame, display.mutableDisplayDevice()->getOrientedDisplaySpaceRect());
    EXPECT_EQ(newDisplayRect, display.mutableDisplayDevice()->getOrientedDisplaySpaceRect());
}

TEST_F(HandleTransactionLockedTest, processesDisplayWidthChanges) {
@@ -722,5 +722,61 @@ TEST_F(HandleTransactionLockedTest, processesDisplayHeightChanges) {
    mFlinger.handleTransactionLocked(eDisplayTransactionNeeded);
}

TEST_F(HandleTransactionLockedTest, processesDisplaySizeDisplayRectAndLayerStackRectChanges) {
    using Case = NonHwcVirtualDisplayCase;

    constexpr uint32_t kOldWidth = 567;
    constexpr uint32_t kOldHeight = 456;
    const auto kOldSize = Rect(kOldWidth, kOldHeight);

    constexpr uint32_t kNewWidth = 234;
    constexpr uint32_t kNewHeight = 123;
    const auto kNewSize = Rect(kNewWidth, kNewHeight);

    // --------------------------------------------------------------------
    // Preconditions

    // A display is set up
    auto nativeWindow = new mock::NativeWindow();
    auto displaySurface = new compositionengine::mock::DisplaySurface();
    sp<GraphicBuffer> buf = new GraphicBuffer();
    auto display = Case::Display::makeFakeExistingDisplayInjector(this);
    display.setNativeWindow(nativeWindow);
    display.setDisplaySurface(displaySurface);
    // Setup injection expectations
    EXPECT_CALL(*nativeWindow, query(NATIVE_WINDOW_WIDTH, _))
            .WillOnce(DoAll(SetArgPointee<1>(kOldWidth), Return(0)));
    EXPECT_CALL(*nativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
            .WillOnce(DoAll(SetArgPointee<1>(kOldHeight), Return(0)));
    display.inject();

    // There is a change to the layerStackSpaceRect state
    display.mutableDrawingDisplayState().width = kOldWidth;
    display.mutableDrawingDisplayState().height = kOldHeight;
    display.mutableDrawingDisplayState().layerStackSpaceRect = kOldSize;
    display.mutableDrawingDisplayState().orientedDisplaySpaceRect = kOldSize;

    display.mutableCurrentDisplayState().width = kNewWidth;
    display.mutableCurrentDisplayState().height = kNewHeight;
    display.mutableCurrentDisplayState().layerStackSpaceRect = kNewSize;
    display.mutableCurrentDisplayState().orientedDisplaySpaceRect = kNewSize;

    // --------------------------------------------------------------------
    // Call Expectations

    EXPECT_CALL(*displaySurface, resizeBuffers(kNewWidth, kNewHeight)).Times(1);

    // --------------------------------------------------------------------
    // Invocation

    mFlinger.handleTransactionLocked(eDisplayTransactionNeeded);

    EXPECT_EQ(display.mutableDisplayDevice()->getBounds(), kNewSize);
    EXPECT_EQ(display.mutableDisplayDevice()->getWidth(), kNewWidth);
    EXPECT_EQ(display.mutableDisplayDevice()->getHeight(), kNewHeight);
    EXPECT_EQ(display.mutableDisplayDevice()->getOrientedDisplaySpaceRect(), kNewSize);
    EXPECT_EQ(display.mutableDisplayDevice()->getLayerStackSpaceRect(), kNewSize);
}

} // namespace
} // namespace android