Android, OpenGLES, CmdLine tool, getting MainDisplay resolution

后端 未结 1 454
日久生厌
日久生厌 2021-01-23 04:02

Environment

  • Windows (x64) Host
  • Android 5.0 USB connected to the Windows machine
  • Samsung Galaxy 5
  • VisualGDB
  • OpenGL (v1.4)
相关标签:
1条回答
  • 2021-01-23 04:47

    EGL doesn't have access to the display itself. It gets a window from the Window Manager, which is then composited by SurfaceFlinger with other things. The architecture is described here.

    If you don't mind using non-public APIs, and you're running as "shell" or "root" (which, as an ADB command, you will), you can do what some of the test code does and query the display properties from SurfaceFlinger directly. Take a look at WindowSurface. (You can find the classic "San Angeles" demo nearby if you want to see the code in action.) WindowSurface was added in Android 5.0 "Lollipop", replacing an older implementation that tried to bypass SurfaceFlinger (which required shutting down the Android framework). The new implementation just draws on top of whatever is running.

    The screenrecord tool uses the same SurfaceComposerClient APIs to determine how to size the video (see line 540). If all you want is the resolution and don't actually care about EGL, this is a simpler example.

    0 讨论(0)
提交回复
热议问题