Skip to content

Commit 527635e

Browse files
committed
Squashed commit of hwrotation support
surfaceflinger: Reimplement hwrotation Change-Id: Ia26bb36b5b6de132af49c272c4472ad2703afbda surfaceflinger: odd hw rotation (90/270) patch for swapping width/height This patch works in addition to the following commit re-implementing ro.sf.hwrotation: CyanogenMod/android_frameworks_native@7d28343 When using values of 90 and 270 for ro.sf.hwrotation the LCD width and height also need to be swapped to display properly. Change-Id: I2874fdb8f8d8b855df6d62d338c9a22360491973 NOTE: This patch does not fix the initial startup of bootanimation Fix boot animation rotation problem when ro.sf.hwrotation is set to 90 or 270 Change-Id: I7ad3c83e23ce38280818ec5283d173d50c889531 sf: Only apply hwrotation to primary displays We must onot rotate virtual displays (aka overÃls) so we need to access the mType member. Change-Id: Ib51030cec5ce7609f12be9a5e46310f75442b680
1 parent 9b8b9a6 commit 527635e

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

services/surfaceflinger/DisplayDevice.cpp

+23-1
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,20 @@ status_t DisplayDevice::orientationToTransfrom(
446446
int orientation, int w, int h, Transform* tr)
447447
{
448448
uint32_t flags = 0;
449+
char value[PROPERTY_VALUE_MAX];
450+
property_get("ro.sf.hwrotation", value, "0");
451+
int additionalRot = atoi(value);
452+
453+
if (additionalRot && mType == DISPLAY_PRIMARY) {
454+
additionalRot /= 90;
455+
if (orientation == DisplayState::eOrientationUnchanged) {
456+
orientation = additionalRot;
457+
} else {
458+
orientation += additionalRot;
459+
orientation %= 4;
460+
}
461+
}
462+
449463
switch (orientation) {
450464
case DisplayState::eOrientationDefault:
451465
flags = Transform::ROT_0;
@@ -501,7 +515,15 @@ void DisplayDevice::setProjection(int orientation,
501515
if (!frame.isValid()) {
502516
// the destination frame can be invalid if it has never been set,
503517
// in that case we assume the whole display frame.
504-
frame = Rect(w, h);
518+
char value[PROPERTY_VALUE_MAX];
519+
property_get("ro.sf.hwrotation", value, "0");
520+
int additionalRot = atoi(value);
521+
522+
if (additionalRot == 90 || additionalRot == 270) {
523+
frame = Rect(h, w);
524+
} else {
525+
frame = Rect(w, h);
526+
}
505527
}
506528

507529
if (viewport.isEmpty()) {

services/surfaceflinger/DisplayDevice.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class DisplayDevice : public LightRefBase<DisplayDevice>
234234
/*
235235
* Transaction state
236236
*/
237-
static status_t orientationToTransfrom(int orientation,
237+
status_t orientationToTransfrom(int orientation,
238238
int w, int h, Transform* tr);
239239

240240
uint32_t mLayerStack;

services/surfaceflinger/SurfaceFlinger.cpp

+15-4
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,21 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
598598
info.orientation = 0;
599599
}
600600

601-
info.w = hwConfig->getWidth();
602-
info.h = hwConfig->getHeight();
603-
info.xdpi = xdpi;
604-
info.ydpi = ydpi;
601+
char value[PROPERTY_VALUE_MAX];
602+
property_get("ro.sf.hwrotation", value, "0");
603+
int additionalRot = atoi(value) / 90;
604+
if ((type == DisplayDevice::DISPLAY_PRIMARY) && (additionalRot & DisplayState::eOrientationSwapMask)) {
605+
info.h = hwConfig->getWidth();
606+
info.w = hwConfig->getHeight();
607+
info.xdpi = ydpi;
608+
info.ydpi = xdpi;
609+
}
610+
else {
611+
info.w = hwConfig->getWidth();
612+
info.h = hwConfig->getHeight();
613+
info.xdpi = xdpi;
614+
info.ydpi = ydpi;
615+
}
605616
info.fps = 1e9 / hwConfig->getVsyncPeriod();
606617
info.appVsyncOffset = VSYNC_EVENT_PHASE_OFFSET_NS;
607618

0 commit comments

Comments
 (0)