surfaceflinger: Consolidate display orientation compensation hooks
Dedupe rotation calculation code and make rotation a statically available property in the DisplayDevice Change-Id: Ic517ab0d2c05026cd6fa46d664aab7926be17b62
This commit is contained in:
parent
3904525bce
commit
f8e2372ad7
@ -84,6 +84,7 @@ DisplayDevice::DisplayDevice(
|
|||||||
mIsSecure(isSecure),
|
mIsSecure(isSecure),
|
||||||
mSecureLayerVisible(false),
|
mSecureLayerVisible(false),
|
||||||
mLayerStack(NO_LAYER_STACK),
|
mLayerStack(NO_LAYER_STACK),
|
||||||
|
mHardwareOrientation(0),
|
||||||
mOrientation(),
|
mOrientation(),
|
||||||
mPowerMode(HWC_POWER_MODE_OFF),
|
mPowerMode(HWC_POWER_MODE_OFF),
|
||||||
mActiveConfig(0)
|
mActiveConfig(0)
|
||||||
@ -131,7 +132,12 @@ DisplayDevice::DisplayDevice(
|
|||||||
// was created with createDisplay().
|
// was created with createDisplay().
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case DISPLAY_PRIMARY:
|
case DISPLAY_PRIMARY:
|
||||||
|
char value[PROPERTY_VALUE_MAX];
|
||||||
mDisplayName = "Built-in Screen";
|
mDisplayName = "Built-in Screen";
|
||||||
|
|
||||||
|
/* hwrotation applies only to the primary display */
|
||||||
|
property_get("ro.sf.hwrotation", value, "0");
|
||||||
|
mHardwareOrientation = atoi(value);
|
||||||
break;
|
break;
|
||||||
case DISPLAY_EXTERNAL:
|
case DISPLAY_EXTERNAL:
|
||||||
mDisplayName = "HDMI Screen";
|
mDisplayName = "HDMI Screen";
|
||||||
@ -392,9 +398,7 @@ status_t DisplayDevice::orientationToTransfrom(
|
|||||||
int orientation, int w, int h, Transform* tr)
|
int orientation, int w, int h, Transform* tr)
|
||||||
{
|
{
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
char value[PROPERTY_VALUE_MAX];
|
int additionalRot = this->getHardwareOrientation();
|
||||||
property_get("ro.sf.hwrotation", value, "0");
|
|
||||||
int additionalRot = atoi(value);
|
|
||||||
|
|
||||||
if (additionalRot) {
|
if (additionalRot) {
|
||||||
additionalRot /= 90;
|
additionalRot /= 90;
|
||||||
@ -466,11 +470,7 @@ void DisplayDevice::setProjection(int orientation,
|
|||||||
if (!frame.isValid()) {
|
if (!frame.isValid()) {
|
||||||
// the destination frame can be invalid if it has never been set,
|
// the destination frame can be invalid if it has never been set,
|
||||||
// in that case we assume the whole display frame.
|
// in that case we assume the whole display frame.
|
||||||
char value[PROPERTY_VALUE_MAX];
|
if ((mHardwareOrientation/90) & DisplayState::eOrientationSwapMask) {
|
||||||
property_get("ro.sf.hwrotation", value, "0");
|
|
||||||
int additionalRot = atoi(value);
|
|
||||||
|
|
||||||
if (additionalRot == 90 || additionalRot == 270) {
|
|
||||||
frame = Rect(h, w);
|
frame = Rect(h, w);
|
||||||
} else {
|
} else {
|
||||||
frame = Rect(w, h);
|
frame = Rect(w, h);
|
||||||
@ -529,6 +529,10 @@ void DisplayDevice::setProjection(int orientation,
|
|||||||
mFrame = frame;
|
mFrame = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DisplayDevice::getHardwareOrientation() {
|
||||||
|
return mHardwareOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
void DisplayDevice::dump(String8& result) const {
|
void DisplayDevice::dump(String8& result) const {
|
||||||
const Transform& tr(mGlobalTransform);
|
const Transform& tr(mGlobalTransform);
|
||||||
result.appendFormat(
|
result.appendFormat(
|
||||||
|
@ -173,6 +173,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
uint32_t getPageFlipCount() const;
|
uint32_t getPageFlipCount() const;
|
||||||
void dump(String8& result) const;
|
void dump(String8& result) const;
|
||||||
|
int getHardwareOrientation();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
@ -217,6 +218,7 @@ private:
|
|||||||
int w, int h, Transform* tr);
|
int w, int h, Transform* tr);
|
||||||
|
|
||||||
uint32_t mLayerStack;
|
uint32_t mLayerStack;
|
||||||
|
int mHardwareOrientation;
|
||||||
int mOrientation;
|
int mOrientation;
|
||||||
// user-provided visible area of the layer stack
|
// user-provided visible area of the layer stack
|
||||||
Rect mViewport;
|
Rect mViewport;
|
||||||
|
@ -641,9 +641,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
|
|||||||
info.orientation = 0;
|
info.orientation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char value[PROPERTY_VALUE_MAX];
|
int additionalRot = mDisplays[0]->getHardwareOrientation() / 90;
|
||||||
property_get("ro.sf.hwrotation", value, "0");
|
|
||||||
int additionalRot = atoi(value) / 90;
|
|
||||||
if ((type == DisplayDevice::DISPLAY_PRIMARY) && (additionalRot & DisplayState::eOrientationSwapMask)) {
|
if ((type == DisplayDevice::DISPLAY_PRIMARY) && (additionalRot & DisplayState::eOrientationSwapMask)) {
|
||||||
info.h = hwConfig.width;
|
info.h = hwConfig.width;
|
||||||
info.w = hwConfig.height;
|
info.w = hwConfig.height;
|
||||||
|
Loading…
Reference in New Issue
Block a user