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