android 屏幕旋转(Android屏幕旋转)
android 屏幕旋转(Android屏幕旋转)
Android screen rotation
The screen is LANDSCAPE, so it defaults to PORTRAIT.
Rotate FrameBuffer. in 1.kernel
The startup parameters include fbcon=rotate:1 (0: normal screen; 1: clockwise turn to 90 degree; 2: to 180 degree; 3: clockwise to 270 degree)
Finally, there is a similar item in the generated autoconf.h:
#define CONFIG_CMDLINE "console=ttySAC0115200
fbcon=rotate:1""
The parsing is in the $(kernel) /drivers/video/console/fbcon.c
Static int __init fb_console_setup (char *this_opt);
Just initialize the variable initial_rotation, and then initial_rotation passes it to other structures that you need.
Note: reference $(kernel) /documentation/fb/fbcon.txt
2.android OS rotating screen
The system defaults to the vertical screen, and the MID uses a horizontal screen, so you need to do a conversion action.
PORTRAIT LANDSCAPE <------ screen display mode
ROTATION_0 ROTATION_90
ROTATION_90 ROTATION_180
ROTATION_180 ROTATION_270
ROTATION_270 ROTATION_0
Source and code in the treatment of ROTATION_180 and ROTATION_270 is relatively small, only in sensor and KeyQueue, so if only to let the system display for the vertical screen, the Android in Surface.ROTATION_0 to Surface.ROTATION_90, Surface.ROTATION_90 to Surface.ROTATION_0. So, the screen after the startup is vertical.
After the changes, the boot or LANDSCAPE display, into the HOME is also, will soon automatically rotate to PORTRAIT mode, this is due to
$(Cupcake)
/frameworks/base/services/java/com/android/server/WindowManagerService.java
EnableScreenAfterBoot (->performEnableScreen)
(->mPolicy.enableScreenAfterBoot) (mPolicy), the superclass pointer can point to
PhoneWindowManager or MidWindowManager, by configuration file $(Cupcake) /build/target/product/core.mk
PRODUCT_POLICY: = android.policy_phone
//PRODUCT_POLICY: = android.policy_mid
Specify.
PhoneWindowManager:: enableScreenAfterBoot ()
->updateRotation
(Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE)
->mWindowManager.setRotation () completes setting rotation and clears LOGO.
3. vertical panel during startup
In the boot process, the default is displayed according to the width and height of the screen, will not rotate, to make it display logo is vertical screen, that is, rotating 90 degrees, you need to do the following work:
$(Cupcake)
/frameworks/base/libs/surfaceflinger/SurfaceFlinger.cpp
Status_t SurfaceFlinger:: readyToRun ()
//const, uint32_t, w = hw.getWidth ();
//const, uint32_t, H = hw.getHeight ();
//swap w&h for portrait display in landscape panel. jeff.
Const uint32_t H = hw.getWidth ();
Const, uint32_t, w = hw.getHeight ();
Exchange width and height, so that the ViewPort shape created by OpenGL in the back is vertical. You can change the parameters of the following function, but too much. But how do you make the vertical viewport rotate 90 degrees? Here's the GraphicPlane:: mGlobalTransform, the Transform. That indicates the end of the current spin. So when you create GraphicPlane, initialize mGlobalTransform to rotate 90 degrees.
GraphicPlane::graphicplane()
(0):MHW
{
/杰夫补充。默认旋转天使90
morientationtransform。reset();
morientation = isurfacecomposer::eorientation90;
mglobaltransform = morientationtransform * mtransform;
}
此段从status_t graphicplane::setorientation(国际方向)复
制过来,注意修改mglobaltransform:
如果(方向= = isurfacecomposer::eorientation90){ // isurfacecomposer::eorientationdefault /杰夫
//确保默认方向是最优的
morientationtransform。reset();
morientation =方向;
/ / mglobaltransform = mtransform;
mglobaltransform = morientationtransform * mtransform;/杰夫
返回no_error;
}
注意morientationtransform。reset();要修改为默认旋转90度。参照status_t graphicplane::orientationtotransfrom
中的设置,修改为:
无效的变换:reset() {
mtransform。reset();
M型= 0;
设置(0,- 1,1,0);/ /杰夫
集(800,0);
}
参考:
status_t graphicplane::orientationtotransfrom(
int int int方向,W,H,变换* TR)
{
浮点数a,b,c,d,x,y;
开关(方向){
案例:eorientationdefault isurfacecomposer:
a,1;b,0;c,0;d,1;x,0;y,0;
打破;
案例:eorientation90 isurfacecomposer:
a,0;b,1;c,1;d,0;x,w;y,0;
打破;
案例:eorientation180 isurfacecomposer:
a,1;b,0;c,0;d,1;x,w;y,h;
打破;
案例:eorientation270 isurfacecomposer:
a,0;b,1;c,1;d,0;x,0;y,h;
打破;
违约:
返回bad_value;
}
集(a,b,c,d);
设置(x,y);
返回no_error;
}
修改之后,默认就是竖屏(旋转90度)显示了。