• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef EMU_CAMERA_GRALLOC_MODULE_H
2 #define EMU_CAMERA_GRALLOC_MODULE_H
3 
4 #include <hardware/gralloc.h>
5 
6 class GrallocModule
7 {
8 public:
getInstance()9   static GrallocModule &getInstance() {
10     static GrallocModule instance;
11     return instance;
12   }
13 
lock(buffer_handle_t handle,int usage,int l,int t,int w,int h,void ** vaddr)14   int lock(buffer_handle_t handle,
15       int usage, int l, int t, int w, int h, void **vaddr) {
16     return mModule->lock(mModule, handle, usage, l, t, w, h, vaddr);
17   }
18 
19 #ifdef GRALLOC_MODULE_API_VERSION_0_2
lock_ycbcr(buffer_handle_t handle,int usage,int l,int t,int w,int h,struct android_ycbcr * ycbcr)20   int lock_ycbcr(buffer_handle_t handle,
21       int usage, int l, int t, int w, int h,
22       struct android_ycbcr *ycbcr) {
23     return mModule->lock_ycbcr(mModule, handle, usage, l, t, w, h, ycbcr);
24   }
25 #endif
26 
unlock(buffer_handle_t handle)27   int unlock(buffer_handle_t handle) {
28     return mModule->unlock(mModule, handle);
29   }
30 
31 private:
GrallocModule()32   GrallocModule() {
33     const hw_module_t *module = NULL;
34     int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
35     if (ret) {
36       ALOGE("%s: Failed to get gralloc module: %d", __FUNCTION__, ret);
37     }
38     mModule = reinterpret_cast<const gralloc_module_t*>(module);
39   }
40   const gralloc_module_t *mModule;
41 };
42 
43 #endif
44