Android SurfaceView缩放错误(ThreadedRenderer)

时间:2017-01-10 12:10:32

标签: java android scale surfaceview display

  

我正在使用的当前设备:

     

三星Galaxy S6(SM-G920F)

     

Android 6.0.1

     

2560 x 1440

我创建了一个使用androids表面视图的简单游戏引擎(在单独的线程中连续渲染) 我遇到了关于窗口显示指标的问题。我的设备似乎随机地将视口缩小了0.75,导致屏幕显示不正确。

错误(SRIB_DSS / libEGL),MultiPhoneWindow?

01-10 11:21:06.761 23218-23218/? D/SecWifiDisplayUtil: Metadata value : SecSettings2
01-10 11:21:06.761 23218-23218/? D/ViewRootImpl: #1 mView = com.android.internal.policy.MultiPhoneWindow$MultiPhoneDecorView{ad58a84 I.E...... R.....ID 0,0-0,0}
01-10 11:21:06.761 23218-23248/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
01-10 11:21:06.771 23218-23218/? D/MultiPhoneWindow: performUpdateVisibility, same visibility false
01-10 11:21:06.791 23218-23218/? E/SRIB_DSS_ThreadedRenderer: initialize, mIsDcsEnabledApp=true , with format= -1 scaleFactor=0.75
01-10 11:21:06.791 23218-23218/? D/ThreadedRenderer: SRIB_DCS & DSS android_view_ThreadedRenderer_dcs_initialize Rendering in format=-1, factor=0.750000
01-10 11:21:06.791 23218-23218/? D/libEGL: SRIB_DCS:EGL_DCS_setDcsApp format=-1
01-10 11:21:06.791 23218-23218/? E/libEGL: SRIB_DSS: EGL_DSS_setDssApp factor=0.750000
01-10 11:21:06.811 23218-23248/? D/libEGL: loaded /vendor/lib64/egl/libGLES_mali.so
01-10 11:21:06.821 23218-23248/? D/libEGL: eglInitialize EGLDisplay = 0x7f8f42b178
01-10 11:21:06.821 23218-23248/? I/OpenGLRenderer: Initialized EGL, version 1.4
01-10 11:21:06.821 23218-23248/? D/: ro.exynos.dss isEnabled: 0
01-10 11:21:06.831 23218-23248/? D/mali_winsys: new_window_surface returns 0x3000,  [1920x1080]-format:1
01-10 11:21:06.841 23218-23218/? I/System.out: -----SURFACE CHANGED-----
01-10 11:21:06.841 23218-23218/? I/System.out: Width: 1920
01-10 11:21:06.841 23218-23218/? I/System.out: Height: 1080
01-10 11:21:06.841 23218-23218/? I/System.out: x: 1.0, y: 1.0
01-10 11:21:06.861 23218-23218/? D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=2

我使用相同的引擎和相同的手机创建了一些其他应用程序,但没有缩放错误。我的其他设备(Moto g XT1032)没有错误。当我卸载应用程序时,使用了正确的比例,但是当我重新启动应用程序时,它再次缩放0.75。

无错误

01-10 11:54:54.461 29397-29397/particlesystem.com.ds.mo.particlesystem D/SecWifiDisplayUtil: Metadata value : SecSettings2
01-10 11:54:54.461 29397-29397/particlesystem.com.ds.mo.particlesystem D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{1ba6bd9 I.E...... R.....ID 0,0-0,0}
01-10 11:54:54.461 29397-29728/particlesystem.com.ds.mo.particlesystem D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
01-10 11:54:54.521 29397-29728/particlesystem.com.ds.mo.particlesystem D/libEGL: loaded /vendor/lib64/egl/libGLES_mali.so
01-10 11:54:54.531 29397-29728/particlesystem.com.ds.mo.particlesystem D/libEGL: eglInitialize EGLDisplay = 0x7f9eb7f178
01-10 11:54:54.531 29397-29728/particlesystem.com.ds.mo.particlesystem I/OpenGLRenderer: Initialized EGL, version 1.4
01-10 11:54:54.531 29397-29728/particlesystem.com.ds.mo.particlesystem D/mali_winsys: new_window_surface returns 0x3000,  [2560x1440]-format:1
01-10 11:54:54.551 29397-29397/particlesystem.com.ds.mo.particlesystem I/System.out: -----SURFACE CHANGED-----
01-10 11:54:54.551 29397-29397/particlesystem.com.ds.mo.particlesystem I/System.out: Width: 2560
01-10 11:54:54.551 29397-29397/particlesystem.com.ds.mo.particlesystem I/System.out: Height: 1440
01-10 11:54:54.551 29397-29397/particlesystem.com.ds.mo.particlesystem I/System.out: x: 2.0, y: 2.0
01-10 11:54:54.601 29397-29397/particlesystem.com.ds.mo.particlesystem D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=2
01-10 11:54:54.671 29397-29397/particlesystem.com.ds.mo.particlesystem I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@de6d751 time:18008434

我在曲面改变的方法中得到缩放值。

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    System.out.println("-----SURFACE CHANGED-----");
    System.out.println("Width: " + width);
    System.out.println("Height: " + height);

    //Set Viewports

    //Get the scale value based on the surface created
    scaleX = (float) width / GAME_WIDTH;
    scaleY = (float) height / GAME_HEIGHT;

    //Round scale to 2.d.p
    scaleX = Math.round(scaleX * 100) / 100;
    scaleY = Math.round(scaleY * 100) / 100;

    System.out.println("x: " + scaleX + ", y: " + scaleY);
    resetScaleSwipe();
}

可怕的是,我在一周前使用引擎发布了我的第一个游戏,我不确定问题是否与我的设备有关。任何帮助都可以,谢谢。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案

当您将游戏发布到应用商店时,一些三星设备会尝试对其进行优化。默认情况下,输出质量设置为“平衡质量”,将分辨率降低至75%,并将fps降至60。

.Math.round()返回一个int,所以通过强制转换或更改100到100f来确保缩放值是浮点数

要解决此问题,您必须下载三星game tuner应用并将质量更改为最高版本!

  

受影响的手机:三星Galaxy系列(S6,S6e,S6e +,Note 5)