summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2014-01-04 04:44:47 +0000
committerSteve Kondik <shade@chemlab.org>2015-11-10 10:56:31 -0800
commitf8e2372ad7c6ab5ba0363352607f5ded918add01 (patch)
tree2599c09cefcd0550f155ff644f35dc4d69d14770 /services/surfaceflinger
parent3904525bce6b924ad0501f15899d7550f05fcf0d (diff)
downloadframeworks_native-f8e2372ad7c6ab5ba0363352607f5ded918add01.zip
frameworks_native-f8e2372ad7c6ab5ba0363352607f5ded918add01.tar.gz
frameworks_native-f8e2372ad7c6ab5ba0363352607f5ded918add01.tar.bz2
surfaceflinger: Consolidate display orientation compensation hooks
Dedupe rotation calculation code and make rotation a statically available property in the DisplayDevice Change-Id: Ic517ab0d2c05026cd6fa46d664aab7926be17b62
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r--services/surfaceflinger/DisplayDevice.cpp20
-rw-r--r--services/surfaceflinger/DisplayDevice.h2
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp4
3 files changed, 15 insertions, 11 deletions
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 1f607f2..d890b02 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -84,6 +84,7 @@ DisplayDevice::DisplayDevice(
mIsSecure(isSecure),
mSecureLayerVisible(false),
mLayerStack(NO_LAYER_STACK),
+ mHardwareOrientation(0),
mOrientation(),
mPowerMode(HWC_POWER_MODE_OFF),
mActiveConfig(0)
@@ -131,7 +132,12 @@ DisplayDevice::DisplayDevice(
// was created with createDisplay().
switch (mType) {
case DISPLAY_PRIMARY:
+ char value[PROPERTY_VALUE_MAX];
mDisplayName = "Built-in Screen";
+
+ /* hwrotation applies only to the primary display */
+ property_get("ro.sf.hwrotation", value, "0");
+ mHardwareOrientation = atoi(value);
break;
case DISPLAY_EXTERNAL:
mDisplayName = "HDMI Screen";
@@ -392,9 +398,7 @@ status_t DisplayDevice::orientationToTransfrom(
int orientation, int w, int h, Transform* tr)
{
uint32_t flags = 0;
- char value[PROPERTY_VALUE_MAX];
- property_get("ro.sf.hwrotation", value, "0");
- int additionalRot = atoi(value);
+ int additionalRot = this->getHardwareOrientation();
if (additionalRot) {
additionalRot /= 90;
@@ -466,11 +470,7 @@ void DisplayDevice::setProjection(int orientation,
if (!frame.isValid()) {
// the destination frame can be invalid if it has never been set,
// in that case we assume the whole display frame.
- char value[PROPERTY_VALUE_MAX];
- property_get("ro.sf.hwrotation", value, "0");
- int additionalRot = atoi(value);
-
- if (additionalRot == 90 || additionalRot == 270) {
+ if ((mHardwareOrientation/90) & DisplayState::eOrientationSwapMask) {
frame = Rect(h, w);
} else {
frame = Rect(w, h);
@@ -529,6 +529,10 @@ void DisplayDevice::setProjection(int orientation,
mFrame = frame;
}
+int DisplayDevice::getHardwareOrientation() {
+ return mHardwareOrientation;
+}
+
void DisplayDevice::dump(String8& result) const {
const Transform& tr(mGlobalTransform);
result.appendFormat(
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index f492a42..65f08df 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -173,6 +173,7 @@ public:
*/
uint32_t getPageFlipCount() const;
void dump(String8& result) const;
+ int getHardwareOrientation();
private:
/*
@@ -217,6 +218,7 @@ private:
int w, int h, Transform* tr);
uint32_t mLayerStack;
+ int mHardwareOrientation;
int mOrientation;
// user-provided visible area of the layer stack
Rect mViewport;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 429231c..1a4aa41 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -641,9 +641,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
info.orientation = 0;
}
- char value[PROPERTY_VALUE_MAX];
- property_get("ro.sf.hwrotation", value, "0");
- int additionalRot = atoi(value) / 90;
+ int additionalRot = mDisplays[0]->getHardwareOrientation() / 90;
if ((type == DisplayDevice::DISPLAY_PRIMARY) && (additionalRot & DisplayState::eOrientationSwapMask)) {
info.h = hwConfig.width;
info.w = hwConfig.height;