본문 바로가기
Android_Display

[Graphic] Android 그래픽 기본 정리

by 핑크토끼 2022. 4. 29.

https://source.android.com/devices/graphics/index.html 요약 

Android 프레임워크는 그래픽 드라이버의 제조업체 구현과 상호작용하는 다양한 2D 및 3D용 그래픽 렌더링 API를 제공

앱개발자는  Canvas, OpenGL ES , Vulkan 을 통해 화면에 이미지를 그린다

렌더링 되는 PATH

 Producer : 위 그림에서 OpenGL ES, 캔버스 2D, 미이서 서버 동영상 디코더 등

Consumer : Surfaceflinger

Hardware Composer : Surfaceflinger는 특정 composition(합성)을 하드웨어 컴포저에 위임해서 OpenGL및 GPU 의 작업을  합성한다 하드웨어 컴포저는 Vsync, hot plug(hdmi) 기능을 제공해야한다

Gralloc :  그래픽 메모리 할당자(그랄록)은 Producer 가 요청한 메모리를 할당하는 기능을 한다 제조사에서 Hal 에 제공한다 또한 gralloc은 상황에 따라서 메모리를 어떻게 할당할지 정하게 되는데, 그 상황은 아래와 같다.

  • How often the memory will be accessed from software (CPU)
  • How often the memory will be accessed from hardware (GPU)
  • Whether the memory will be used as an OpenGL ES (GLES) texture
  • Whether the memory will be used by a video encoder

BufferQueue : 버퍼큐는 producer 와 consumer 사이에 주고 받는 데이타를 위한 버퍼를 위한 큐이다  producer가 버퍼를 전달하면 Surfaceflinger는 모든 요소를 디스플레이에 합성한다 

Producer, BufferQueue, Consumer 사이 동작관계

1. Producer가 빈 Buffer를 요청한다(dequeue)

2. 그  Buffer를 채우고 난뒤에 queue에 돌려준다(queue)

3. 그리고 Consumer가 Buffer를 가져온다(acquire)

4. 사용하고 다시 버퍼를 큐에 돌려준다(release)