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
diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
index 4923785..e8c8894 100644
--- a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp
@@ -1127,7 +1127,9 @@
.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 @@
.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 @@
.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