diff options
author | 2022-12-21 01:28:52 +0000 | |
---|---|---|
committer | 2022-12-21 01:28:52 +0000 | |
commit | 35802ed3de0ee67ca01329d87c9a4aceacdc4a14 (patch) | |
tree | 0b249cead5e21474ded63d6230e0835c874e200c /cmds/bootanimation/BootAnimation.cpp | |
parent | 65abc1c3f4863a85c09f319f2f8970a7fd2ac431 (diff) | |
parent | bebb6c21629c6c2642dce0496f882866037bc94e (diff) |
Merge "Set orientation for boot animation and default display rotation." into tm-qpr-dev am: 432b3b38ff am: bebb6c2162
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20698326
Change-Id: Ife76249d38adf5e1a274589cefde652767acf33d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'cmds/bootanimation/BootAnimation.cpp')
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 80512f7b3187..00d9a4bf05f0 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -603,6 +603,15 @@ status_t BootAnimation::readyToRun() { mFlingerSurface = s; mTargetInset = -1; + // Rotate the boot animation according to the value specified in the sysprop + // ro.bootanim.set_orientation_<display_id>. Four values are supported: ORIENTATION_0, + // ORIENTATION_90, ORIENTATION_180 and ORIENTATION_270. + // If the value isn't specified or is ORIENTATION_0, nothing will be changed. + // This is needed to support having boot animation in orientations different from the natural + // device orientation. For example, on tablets that may want to keep natural orientation + // portrait for applications compatibility and to have the boot animation in landscape. + rotateAwayFromNaturalOrientationIfNeeded(); + projectSceneToWindow(); // Register a display event receiver @@ -616,6 +625,50 @@ status_t BootAnimation::readyToRun() { return NO_ERROR; } +void BootAnimation::rotateAwayFromNaturalOrientationIfNeeded() { + const auto orientation = parseOrientationProperty(); + + if (orientation == ui::ROTATION_0) { + // Do nothing if the sysprop isn't set or is set to ROTATION_0. + return; + } + + if (orientation == ui::ROTATION_90 || orientation == ui::ROTATION_270) { + std::swap(mWidth, mHeight); + std::swap(mInitWidth, mInitHeight); + mFlingerSurfaceControl->updateDefaultBufferSize(mWidth, mHeight); + } + + Rect displayRect(0, 0, mWidth, mHeight); + Rect layerStackRect(0, 0, mWidth, mHeight); + + SurfaceComposerClient::Transaction t; + t.setDisplayProjection(mDisplayToken, orientation, layerStackRect, displayRect); + t.apply(); +} + +ui::Rotation BootAnimation::parseOrientationProperty() { + const auto displayIds = SurfaceComposerClient::getPhysicalDisplayIds(); + if (displayIds.size() == 0) { + return ui::ROTATION_0; + } + const auto displayId = displayIds[0]; + const auto syspropName = [displayId] { + std::stringstream ss; + ss << "ro.bootanim.set_orientation_" << displayId.value; + return ss.str(); + }(); + const auto syspropValue = android::base::GetProperty(syspropName, "ORIENTATION_0"); + if (syspropValue == "ORIENTATION_90") { + return ui::ROTATION_90; + } else if (syspropValue == "ORIENTATION_180") { + return ui::ROTATION_180; + } else if (syspropValue == "ORIENTATION_270") { + return ui::ROTATION_270; + } + return ui::ROTATION_0; +} + void BootAnimation::projectSceneToWindow() { glViewport(0, 0, mWidth, mHeight); glScissor(0, 0, mWidth, mHeight); |