GPU0 device implementation

As we did for the default Gralloc module, we will analyze the alloc and free methods in the GPU0 device. The alloc method is implemented in the gralloc_alloc function. The gralloc_alloc function is much longer than the one in the default Gralloc module, but it basically does three things:

  • Checks the usage parameter and decides the pixel format to decide the size of the pixel.
  • According to the information provided by the usage parameter, w, h, format, and usage create a shared memory region and allocate buffers in the host side (GPU).
  • Stores both the shared memory region and host side (GPU) buffer information in the Gralloc device data structure grdev.

Now let's take a look at the code for gralloc_alloc:

 static ...

Get Android System Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.