surfaceflinger: add install orientation to DisplayDevice
Rather than querying it from SurfaceFlinger, initialize
DisplayDevice with the install orientation.
Bug: 113041375
Test: take screenshot, rotate screen, screencap
Change-Id: Ibffe47033276e938388af775749c56f170fe8c77
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index cd86f81..9a35bca 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -218,6 +218,7 @@
std::unique_ptr<RE::Surface> renderSurface,
int displayWidth,
int displayHeight,
+ int displayInstallOrientation,
bool hasWideColorGamut,
const HdrCapabilities& hdrCapabilities,
const int32_t supportedPerFrameMetadata,
@@ -233,6 +234,7 @@
mSurface{std::move(renderSurface)},
mDisplayWidth(displayWidth),
mDisplayHeight(displayHeight),
+ mDisplayInstallOrientation(displayInstallOrientation),
mPageFlipCount(0),
mIsSecure(isSecure),
mLayerStack(NO_LAYER_STACK),
@@ -604,9 +606,8 @@
// need to take care of primary display rotation for mGlobalTransform
// for case if the panel is not installed aligned with device orientation
if (mType == DisplayType::DISPLAY_PRIMARY) {
- int primaryDisplayOrientation = SurfaceFlinger::primaryDisplayOrientation;
DisplayDevice::orientationToTransfrom(
- (orientation + primaryDisplayOrientation) % (DisplayState::eOrientation270 + 1),
+ (orientation + mDisplayInstallOrientation) % (DisplayState::eOrientation270 + 1),
w, h, &R);
}
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index ddb09c5..c7ed927 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -87,6 +87,7 @@
std::unique_ptr<RE::Surface> renderSurface,
int displayWidth,
int displayHeight,
+ int displayInstallOrientation,
bool hasWideColorGamut,
const HdrCapabilities& hdrCapabilities,
const int32_t supportedPerFrameMetadata,
@@ -110,6 +111,7 @@
int getWidth() const;
int getHeight() const;
+ int getInstallOrientation() const { return mDisplayInstallOrientation; }
void setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
@@ -234,6 +236,7 @@
std::unique_ptr<RE::Surface> mSurface;
int mDisplayWidth;
int mDisplayHeight;
+ const int mDisplayInstallOrientation;
mutable uint32_t mPageFlipCount;
std::string mDisplayName;
bool mIsSecure;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 328724b..4ef66d5 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2438,14 +2438,18 @@
nativeWindow->setSwapInterval(nativeWindow.get(), 0);
}
+ const int displayInstallOrientation = state.type == DisplayDevice::DISPLAY_PRIMARY ?
+ primaryDisplayOrientation : DisplayState::eOrientationDefault;
+
// virtual displays are always considered enabled
auto initialPowerMode = state.isVirtual() ? HWC_POWER_MODE_NORMAL : HWC_POWER_MODE_OFF;
sp<DisplayDevice> display =
new DisplayDevice(this, state.type, displayId, state.isSecure, displayToken,
nativeWindow, dispSurface, std::move(renderSurface), displayWidth,
- displayHeight, hasWideColorGamut, hdrCapabilities,
- supportedPerFrameMetadata, hwcColorModes, initialPowerMode);
+ displayHeight, displayInstallOrientation, hasWideColorGamut,
+ hdrCapabilities, supportedPerFrameMetadata, hwcColorModes,
+ initialPowerMode);
if (maxFrameBufferAcquiredBuffers >= 3) {
nativeWindowSurface->preallocateBuffers();
@@ -5093,7 +5097,7 @@
reqHeight = uint32_t(display->getViewport().height());
}
- // XXX primaryDisplayOrientation is ignored
+ // XXX display->getInstallOrientation() is ignored
}
DisplayRenderArea renderArea(display, sourceCrop, reqWidth, reqHeight, renderAreaRotation);
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index bc43576..4e59c97 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -329,8 +329,9 @@
sp<DisplayDevice> device =
new DisplayDevice(mFlinger.mFlinger.get(), mType, mDisplayId, mSecure,
mDisplayToken, mNativeWindow, mDisplaySurface,
- std::move(mRenderSurface), 0, 0, false, HdrCapabilities(), 0,
- hdrAndRenderIntents, HWC_POWER_MODE_NORMAL);
+ std::move(mRenderSurface), 0, 0,
+ DisplayState::eOrientationDefault, false, HdrCapabilities(),
+ 0, hdrAndRenderIntents, HWC_POWER_MODE_NORMAL);
mFlinger.mutableDisplays().emplace(mDisplayToken, device);
DisplayDeviceState state;