diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 8a0d0bc9edd5..6005cd7afe2f 100755 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -427,6 +427,22 @@ void DisplayDevice::setProjection(int orientation, Rect viewport(newViewport); Rect frame(newFrame); + int displayOrientation = DisplayState::eOrientationDefault; + char property[PROPERTY_VALUE_MAX]; + if (mType == DISPLAY_PRIMARY) { + if (property_get("ro.sf.hwrotation", property, NULL) > 0) { + switch (atoi(property)) { + case 90: + displayOrientation = DisplayState::eOrientation90; + break; + case 270: + displayOrientation = DisplayState::eOrientation270; + break; + } + } + } + + orientation = (orientation + displayOrientation) % 4; const int w = mDisplayWidth; const int h = mDisplayHeight; @@ -440,10 +456,16 @@ void DisplayDevice::setProjection(int orientation, frame = Rect(h, w); } else { frame = Rect(w, h); + if (R.getOrientation() & Transform::ROT_90) { + // frame is always specified in the logical orientation + // of the display (ie: post-rotation). + swap(frame.right, frame.bottom); + } } } if (viewport.isEmpty()) { + b/services/surfaceflinger/SurfaceFlinger.cpp // viewport can be invalid if it has never been set, in that case // we assume the whole display size. // it's also invalid to have an empty viewport, so we handle that