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

Commit 4efb6c21 authored by Alec Mouri's avatar Alec Mouri
Browse files

Always set usage bits for GPU comp in DisplayDevice.

* Always set GRALLOC_USAGE_HW_RENDER as usage bit
* Always use RGBA8888 buffer for the GPU to render to.

Otherwise, some virtual display sinks can request a YUV buffer, which
the GPU cannot render to.

Also add back in a connect call for the scratch buffer, since that
should not have been removed.

Bug: 117680609
Change-Id: Ia0c2e99db839ff681529c041a471242d25a8f743
Test: Simulating virtual displays
Test: adb shell screenrecord
Test: Chromecast display mirroring
Test: Simulating virtual displays while mirroring displays
parent 0a9c7b81
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -288,8 +288,12 @@ DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args)

    ANativeWindow* const window = mNativeWindow.get();

    int status = native_window_api_connect(mNativeWindow.get(), NATIVE_WINDOW_API_EGL);
    int status = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
    ALOGE_IF(status != NO_ERROR, "Unable to connect BQ producer: %d", status);
    status = native_window_set_buffers_format(window, HAL_PIXEL_FORMAT_RGBA_8888);
    ALOGE_IF(status != NO_ERROR, "Unable to set BQ format to RGBA888: %d", status);
    status = native_window_set_usage(window, GRALLOC_USAGE_HW_RENDER);
    ALOGE_IF(status != NO_ERROR, "Unable to set BQ usage bits for GPU rendering: %d", status);

    mDisplayWidth = ANativeWindow_getWidth(window);
    mDisplayHeight = ANativeWindow_getHeight(window);
+2 −0
Original line number Diff line number Diff line
@@ -107,6 +107,8 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc,
    mConsumer->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
    mConsumer->setDefaultBufferSize(sinkWidth, sinkHeight);
    sink->setAsyncMode(true);
    IGraphicBufferProducer::QueueBufferOutput output;
    mSource[SOURCE_SCRATCH]->connect(nullptr, NATIVE_WINDOW_API_EGL, false, &output);
}

VirtualDisplaySurface::~VirtualDisplaySurface() {
+6 −0
Original line number Diff line number Diff line
@@ -1127,7 +1127,9 @@ public:
                .WillRepeatedly(DoAll(SetArgPointee<1>(1080 /* arbitrary */), Return(0)));
        EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
                .WillRepeatedly(DoAll(SetArgPointee<1>(1920 /* arbitrary */), Return(0)));
        EXPECT_CALL(*mNativeWindow, perform(9)).Times(1);
        EXPECT_CALL(*mNativeWindow, perform(13)).Times(1);
        EXPECT_CALL(*mNativeWindow, perform(30)).Times(1);
        auto displayDevice = mInjector.inject();

        displayDevice->getBestColorMode(mInputDataspace, mInputRenderIntent, &mOutDataspace,
@@ -1955,7 +1957,9 @@ TEST_F(HandleTransactionLockedTest, processesDisplayWidthChanges) {
            .WillOnce(DoAll(SetArgPointee<1>(oldWidth), Return(0)));
    EXPECT_CALL(*nativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
            .WillOnce(DoAll(SetArgPointee<1>(oldHeight), Return(0)));
    EXPECT_CALL(*nativeWindow, perform(9)).Times(1);
    EXPECT_CALL(*nativeWindow, perform(13)).Times(1);
    EXPECT_CALL(*nativeWindow, perform(30)).Times(1);
    display.inject();

    // There is a change to the viewport state
@@ -1999,7 +2003,9 @@ TEST_F(HandleTransactionLockedTest, processesDisplayHeightChanges) {
            .WillOnce(DoAll(SetArgPointee<1>(oldWidth), Return(0)));
    EXPECT_CALL(*nativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
            .WillOnce(DoAll(SetArgPointee<1>(oldHeight), Return(0)));
    EXPECT_CALL(*nativeWindow, perform(9)).Times(1);
    EXPECT_CALL(*nativeWindow, perform(13)).Times(1);
    EXPECT_CALL(*nativeWindow, perform(30)).Times(1);
    display.inject();

    // There is a change to the viewport state