本文转载自:http://blog.csdn.net/clx44551/article/details/78215730?locationNum=8&fps=1

RK3288 6.0 双屏异显,横屏+竖屏

由于是横屏+竖屏的组合,目前考虑两种实现方案。1.副屏存在黑边 2.对副屏内容进行拉伸。

默认情况下,我们设置的双屏初始rotation都为Surface.ROTATION_0,因此需将WSM中的updateRotationUncheckedLocked方法的该语句进行屏蔽。

  1. if (mRotateOnBoot) {
  2. mRotation = Surface.ROTATION_0;
  3. rotation = Surface.ROTATION_90;
  4. }
  5. /* display portrait, force android rotation according to 90 */
  6. if("true".equals(SystemProperties.get("persist.display.portrait","false"))){
  7. rotation = Surface.ROTATION_90;
  8. }
  9. //LQH
  10. // rotation = Surface.ROTATION_0;
  11. /* display portrait end */
  12. // if("vr".equals(SystemProperties.get("ro.target.product","tablet")))
  13. // rotation = Surface.ROTATION_0;
  14. if (mRotation == rotation && mAltOrientation == altOrientation) {
  15. // No change.
  16. return false;
  17. }

同时在该工程中集成了对于主屏和副屏初始角度控制的补丁,通过build.prop文件进行配置即可。

ro.sf.hwrotation=0                   主屏初始方向 (在./native/services/surfaceflinger/SurfaceFlinger.cpp进行赋值)
ro.orientation.einit=90             副屏初始方向
ro.same.orientation=false       主副屏orientaion是否相同
ro.rotation.external=false        副屏是否随主屏旋转

参考http://blog.csdn.net/ljp1205/article/details/53405641,了解Display框架及其初始化过程,主要对Display初始化时的参数进行调整。

该部分的代码在base/services/core/java/com/android/server/display/LocalDisplayAdapter.java的getDisplayDeviceInfoLocked()方法下完成:

  1. @Override
  2. public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
  3. if (mInfo == null) {
  4. SurfaceControl.PhysicalDisplayInfo phys = mDisplayInfos[mActivePhysIndex];
  5. mInfo = new DisplayDeviceInfo();
  6. mInfo.width = phys.width;
  7. mInfo.height = phys.height;
  8. mInfo.modeId = mActiveModeId;
  9. mInfo.defaultModeId = mDefaultModeId;
  10. mInfo.supportedModes = new Display.Mode[mSupportedModes.size()];
  11. for (int i = 0; i < mSupportedModes.size(); i++) {
  12. DisplayModeRecord record = mSupportedModes.valueAt(i);
  13. mInfo.supportedModes[i] = record.mMode;
  14. }
  15. mInfo.colorTransformId = mActiveColorTransformId;
  16. mInfo.defaultColorTransformId = mDefaultColorTransformId;
  17. mInfo.supportedColorTransforms =
  18. new Display.ColorTransform[mSupportedColorTransforms.size()];
  19. for (int i = 0; i < mSupportedColorTransforms.size(); i++) {
  20. mInfo.supportedColorTransforms[i] = mSupportedColorTransforms.valueAt(i);
  21. }
  22. mInfo.appVsyncOffsetNanos = phys.appVsyncOffsetNanos;
  23. mInfo.presentationDeadlineNanos = phys.presentationDeadlineNanos;
  24. mInfo.state = mState;
  25. mInfo.uniqueId = getUniqueId();
  26. // Assume that all built-in displays that have secure output (eg. HDCP) also
  27. // support compositing from gralloc protected buffers.
  28. if (phys.secure) {
  29. mInfo.flags = DisplayDeviceInfo.FLAG_SECURE
  30. | DisplayDeviceInfo.FLAG_SUPPORTS_PROTECTED_BUFFERS;
  31. }
  32. if (mBuiltInDisplayId == SurfaceControl.BUILT_IN_DISPLAY_ID_MAIN) {
  33. final Resources res = getContext().getResources();
  34. mInfo.name = res.getString(
  35. com.android.internal.R.string.display_manager_built_in_display_name);
  36. mInfo.flags |= DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY
  37. | DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT;
  38. if (res.getBoolean(com.android.internal.R.bool.config_mainBuiltInDisplayIsRound)
  39. || (Build.HARDWARE.contains("goldfish")
  40. && SystemProperties.getBoolean(PROPERTY_EMULATOR_CIRCULAR, false))) {
  41. mInfo.flags |= DisplayDeviceInfo.FLAG_ROUND;
  42. }
  43. mInfo.type = Display.TYPE_BUILT_IN;
  44. mInfo.densityDpi = (int)(phys.density * 160 + 0.5f);
  45. mInfo.xDpi = phys.xDpi;
  46. mInfo.yDpi = phys.yDpi;
  47. mInfo.touch = DisplayDeviceInfo.TOUCH_INTERNAL;
  48. } else {
  49. mInfo.type = Display.TYPE_HDMI;
  50. mInfo.flags |= DisplayDeviceInfo.FLAG_PRESENTATION;
  51. boolean noRotate = "0".equals(SystemProperties.get("ro.sf.hwrotation"));
  52. if(noRotate && mBuiltInDisplayId == SurfaceControl.BUILT_IN_DISPLAY_ID_HDMI){
  53. if (SystemProperties.getBoolean("ro.rotation.external", false)) {
  54. mInfo.flags |= DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT;
  55. }
  56. String value = SystemProperties.get("ro.orientation.einit");
  57. if ("0".equals(value)) {
  58. mInfo.rotation = Surface.ROTATION_0;
  59. } else if ("90".equals(value)) {
  60. mInfo.rotation = Surface.ROTATION_90;
  61. } else if ("180".equals(value)) {
  62. mInfo.rotation = Surface.ROTATION_180;
  63. } else if ("270".equals(value)) {
  64. mInfo.rotation = Surface.ROTATION_270;
  65. }
  66. }
  67. mInfo.name = getContext().getResources().getString(
  68. com.android.internal.R.string.display_manager_hdmi_display_name);
  69. mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL;
  70. mInfo.setAssumedDensityForExternalDisplay(phys.width, phys.height);
  71. // For demonstration purposes, allow rotation of the external display.
  72. // In the future we might allow the user to configure this directly.
  73. if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) {
  74. mInfo.rotation = Surface.ROTATION_270;
  75. }
  76. // For demonstration purposes, allow rotation of the external display
  77. // to follow the built-in display.
  78. if (SystemProperties.getBoolean("persist.demo.hdmirotates", false)) {
  79. mInfo.flags |= DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT;
  80. }
  81. }
  82. }
  83. return mInfo;
  84. }

最终显示的frame大小确定,在framework/native/service/surfaceflinger/DisplayDevice.cpp中

  1. bool isHdmiScreen = mType == DisplayDevice::DISPLAY_EXTERNAL;
  2. if (isHdmiScreen) {
  3. int eInitOrientation = 0;
  4. bool isSfHwrotated = false;
  5. bool isSupportRotation = false;
  6. bool isPrimaryExternalSameOrientation = false;
  7. Rect newFrame = Rect(0,0,getWidth(),getHeight());
  8. Rect newFrameRotated = Rect(0,0,getHeight(),getWidth());
  9. float frameRatio = (float)frame.getWidth() / frame.getHeight();
  10. char value[PROPERTY_VALUE_MAX];
  11. property_get("ro.sf.hwrotation", value, "0");
  12. isSfHwrotated = atoi(value) != 0;
  13. property_get("ro.same.orientation", value, "false");
  14. isPrimaryExternalSameOrientation = !strcmp(value,"true");
  15. if(!isSfHwrotated) {
  16. property_get("ro.orientation.einit", value, "0");
  17. eInitOrientation = atoi(value) / 90;
  18. property_get("ro.rotation.external", value, "false");
  19. isSupportRotation = !strcmp(value,"true");
  20. }
  21. if (isSupportRotation && !isPrimaryExternalSameOrientation) {
  22. mClientOrientation = orientation;
  23. if (eInitOrientation % 2 == 1) {
  24. frame = frameRatio > 1.0 ? frame : newFrameRotated;
  25. ALOGE("%d,[%d,%d]",__LINE__,frame.getWidth(),frame.getHeight());
  26. } else {
  27. frame = frameRatio > 1.0 ? newFrame : frame;
  28. ALOGE("%d,[%d,%d]",__LINE__,frame.getWidth(),frame.getHeight());
  29. }
  30. } else if (isSupportRotation) {
  31. mClientOrientation = orientation;
  32. if (eInitOrientation % 2 == 1) {
  33. //frame = frameRatio > 1.0 ? frame : frame;
  34. ALOGE("%d,[%d,%d]",__LINE__,frame.getWidth(),frame.getHeight());
  35. } else {
  36. frame = frameRatio > 1.0 ? newFrame : newFrameRotated;
  37. ALOGE("%d,[%d,%d]",__LINE__,frame.getWidth(),frame.getHeight());
  38. }
  39. } else if (eInitOrientation % 2 != 0) {
  40. if (isPrimaryExternalSameOrientation) {
  41. //frame = frameRatio > 1.0 ? frame : frame;
  42. ALOGE("%d,[%d,%d]",__LINE__,frame.getWidth(),frame.getHeight());
  43. } else {
  44. //应该走的这里
  45. frame = frameRatio > 1.0 ? frame : newFrameRotated;
  46. ALOGE("%d,[%d,%d]",__LINE__,frame.getWidth(),frame.getHeight());
  47. }
  48. } else if (eInitOrientation % 2 == 0) {
  49. if (isPrimaryExternalSameOrientation) {
  50. frame = frameRatio > 1.0 ? newFrame : frame;
  51. ALOGE("%d,[%d,%d]",__LINE__,frame.getWidth(),frame.getHeight());
  52. } else {
  53. frame = frameRatio > 1.0 ? newFrame : frame;
  54. ALOGE("%d,[%d,%d]",__LINE__,frame.getWidth(),frame.getHeight());
  55. }
  56. } else {
  57. frame = frameRatio > 1.0 ? newFrame : frame;
  58. ALOGE("%d,[%d,%d]",__LINE__,frame.getWidth(),frame.getHeight());
  59. }
  60. ALOGE("update frame [%d,%d]",frame.getWidth(),frame.getHeight());
  61. }

根据具体情况进行配置,即可实现 双屏异显,横屏+竖屏,竖屏存在黑边的效果。在上面的补丁中,可对frame进行强制定义为副屏大小,则可以实现拉伸效果,填充黑边。

  1. frame=Rect(0,0,getHeight(),getWidth());

但两块屏幕比例相差较大的情况下,拉伸显示的效果较差。

注:在设置中将g-sensor的旋转功能关闭,旋转对上述实现存在一定影响。

RK3288 6.0 双屏异显,横屏+竖屏【转】的更多相关文章

  1. RK3288 双屏异显,两屏默认方向不一致

    CPU:RK3288 系统:Android 5.1 RK3288 支持双屏异显,一般都会同方向显示,如果遇到两个 lcd 的默认方向不一致,只需修改下面参数即可. 例如:主屏为mipi接口,分辨率为 ...

  2. RK3288 增加双屏异显 eDP+LVDS

    CPU:RK3288 系统:Android 5.1 下面是官方文档中的信息. 1.rk3288 支持的显示接口可以任意组合. 2.双屏异显时,一个显示接口当主屏,另一个当副屏:主副屏由板级 dts 文 ...

  3. Rk3288 双屏异显单触摸

    系统版本:RK3288 android 5.1 设备同时有两个lcd,主屏是mipi接口,带有触摸屏,触摸屏是usb接口,副屏是hdmi接口,没有触摸屏,正常情况下,两个lcd显示相同内容,触摸屏一切 ...

  4. RK3288 双屏异显时,触摸屏(USB接口)无反应

    系统版本:RK3288 android 5.1 设备同时有两个lcd,主屏是mipi接口,带有触摸屏,触摸屏是usb接口,副屏是hdmi接口,没有触摸屏,正常情况下,两个lcd显示相同内容,触摸屏一切 ...

  5. [Android6.0][RK3399] 双屏异显代码实现流程分析(一)【转】

    本文转载自:http://blog.csdn.net/dearsq/article/details/55049182 Platform: RK3399 OS: Android 6.0 Version: ...

  6. iTOP-4418/6818开发板支持双屏异显,双屏同显

    iTOP-4418/6818开发板平台安卓系统下支持双屏异显,双屏同显,客户可按照不同用途,分别播放适合屏幕显示方式的内容 ,如HDMI屏幕和LCD屏幕显示不同内容, 一个屏幕播放广告,另一个屏幕运行 ...

  7. 【ARM开发板】迅为IMX6开发板QT下LVDS和HDMI双屏异显

    本文转自迅为论坛:http://www.topeetboard.com 平台:迅为-IMX6开发板 首先开发板分别连接9.7寸屏和HDMI显示器,然后使用MfgTool工具烧写QT系统,然后拨码开关设 ...

  8. iTOP-iMX6开发板Android系统下LVDS和HDMI双屏异显方法

    迅为iMX6 开发板 android 系统下 LVDS 和 HDMI 双屏异显的使用过程. 注意,iTOP-iMX6 开发板的 android 系统想要实现对 LVDS 和 HDMI 双屏异显功能的支 ...

  9. HTML5中判断横屏竖屏

    在移动端中我们经常碰到横屏竖屏的问题,那么我们应该如何去判断或者针对横屏.竖屏来写不同的代码呢. 这里有两种方法: 一:CSS判断横屏竖屏 写在同一个CSS中 1 2 3 4 5 6 @media s ...

随机推荐

  1. Python 函数对象-函数嵌套-名称空间与作用域-闭包函数

    今日内容: 1. 函数对象 函数是第一类对象: 指的是函数名指向的值可以被当中数据去使用 1.可以被引用 2.可以当做参数传给另一个函数 3.可以当做一个函数的返回值 4.可以当做容器类型的元素 2. ...

  2. winform 实现两个datagridview之间的数据联动

    再做数据库开发的时候,经常会遇到表带上明细表,比如,一个学校有好多系,每个系又有好多专业.... 在winform中,都会使用datagridview来显示数据,现在就来说说如何实现之间的联动.比如现 ...

  3. Phong 光照模型(镜面反射)

    Phong 光照模型 镜面反射(高光),是光线经过物体表面,反射到视野中,当反射光线与人的眼睛看得方向平行时,强度最大,高光效果最明显,夹角为90度时,强度最小. specular = I*R*V: ...

  4. Qt项目——数字内容管理系统的参考资料和细节

    打开文件路径,若带空格,要用引号括起路径 LPCWSTR与QString的转换:LPCWSTR strL = strQ.toStdWString().c_str(); 用指定程序打开文件(选择文件的打 ...

  5. 九度oj 题目1062:分段函数

    题目1062:分段函数 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3874 解决:2278 题目描述: 编写程序,计算下列分段函数y=f(x)的值.y=-x+2.5; 0<=x& ...

  6. 牛客网暑期ACM多校训练营(第二场)B discount

    链接:https://www.nowcoder.com/acm/contest/140/B来源:牛客网 题目描述 White Rabbit wants to buy some drinks from ...

  7. 转盘抽奖 canvas & 抽奖 H5 源码

    转盘抽奖 canvas https://github.com/givebest/wechat-turntalbe-canvas https://blog.givebest.cn/GB-canvas-t ...

  8. Maven 引入外部包

    当需要从外部引入一个包(譬如说读写Excel 的POI  jar 包 ), 不需要手动地去官网下载一个包然后粘贴到相应的地方. 只需要把Java 工程 转为 Maven 工程 ( 在工程上右键 > ...

  9. UVA 10652 凸包问题

    #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> # ...

  10. [luoguP1045] 麦森数(快速幂 + 高精度)

    传送门 这道题纯粹是考数学.编程复杂度不大(别看我写了一百多行其实有些是可以不必写的). 计算位数不必用高精时刻存,不然可想而知时间复杂度之大.首先大家要知道一个数学公式 logn(a*b)=logn ...