SF: Redesign API to query display information
The DisplayInfo list returned by ISurfaceComposer for display configs
contains display information/state redundant across configs.
Extract config information to DisplayConfig, and repurpose DisplayInfo
for immutable information about a physical display. In a future CL, SF
will populate DisplayInfo with additional data (e.g. connection type,
EDID fields) on initial connection. DisplayConfigs retain the ability
to reload on subsequent connections. Introduce ui::DisplayState for
transactional state applicable to both physical and virtual displays.
Bug: 144601064
Test: dumpsys display
Change-Id: I72003e8ef71483ef483d0de85d28b859a6c9f5fc
diff --git a/services/automotive/display/CarWindowService.cpp b/services/automotive/display/CarWindowService.cpp
index e95c9e1..fbefef0 100644
--- a/services/automotive/display/CarWindowService.cpp
+++ b/services/automotive/display/CarWindowService.cpp
@@ -13,8 +13,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-#include <ui/DisplayInfo.h>
+
+#include <utility>
+
#include <gui/bufferqueue/2.0/B2HGraphicBufferProducer.h>
+#include <ui/DisplayConfig.h>
+#include <ui/DisplayState.h>
#include "CarWindowService.h"
@@ -38,31 +42,37 @@
return nullptr;
}
- // Get main display parameters.
- sp<IBinder> mainDpy = SurfaceComposerClient::getInternalDisplayToken();
- if (mainDpy == nullptr) {
+ const auto displayToken = SurfaceComposerClient::getInternalDisplayToken();
+ if (displayToken == nullptr) {
ALOGE("Failed to get internal display ");
return nullptr;
}
- DisplayInfo mainDpyInfo;
- err = SurfaceComposerClient::getDisplayInfo(mainDpy, &mainDpyInfo);
+
+ DisplayConfig displayConfig;
+ err = SurfaceComposerClient::getActiveDisplayConfig(displayToken, &displayConfig);
if (err != NO_ERROR) {
- ALOGE("Failed to get display characteristics");
+ ALOGE("Failed to get active display config");
return nullptr;
}
- unsigned int mWidth, mHeight;
- if (mainDpyInfo.orientation != ui::ROTATION_0 &&
- mainDpyInfo.orientation != ui::ROTATION_180) {
- // rotated
- mWidth = mainDpyInfo.h;
- mHeight = mainDpyInfo.w;
- } else {
- mWidth = mainDpyInfo.w;
- mHeight = mainDpyInfo.h;
+
+ ui::DisplayState displayState;
+ err = SurfaceComposerClient::getDisplayState(displayToken, &displayState);
+ if (err != NO_ERROR) {
+ ALOGE("Failed to get display state");
+ return nullptr;
+ }
+
+ const ui::Size& resolution = displayConfig.resolution;
+ auto width = resolution.getWidth();
+ auto height = resolution.getHeight();
+
+ if (displayState.orientation == ui::ROTATION_90 ||
+ displayState.orientation == ui::ROTATION_270) {
+ std::swap(width, height);
}
mSurfaceControl = mSurfaceComposerClient->createSurface(
- String8("Automotive Display"), mWidth, mHeight,
+ String8("Automotive Display"), width, height,
PIXEL_FORMAT_RGBX_8888, ISurfaceComposerClient::eOpaque);
if (mSurfaceControl == nullptr || !mSurfaceControl->isValid()) {
ALOGE("Failed to create SurfaceControl");