GraphicBufferMapper.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2007 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef ANDROID_UI_BUFFER_MAPPER_H
  17. #define ANDROID_UI_BUFFER_MAPPER_H
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #include <utils/Singleton.h>
  21. #include <hardware/gralloc.h>
  22. struct gralloc_module_t;
  23. namespace android {
  24. // ---------------------------------------------------------------------------
  25. class Rect;
  26. class GraphicBufferMapper : public Singleton<GraphicBufferMapper>
  27. {
  28. public:
  29. static inline GraphicBufferMapper& get() { return getInstance(); }
  30. status_t registerBuffer(buffer_handle_t handle);
  31. status_t unregisterBuffer(buffer_handle_t handle);
  32. status_t lock(buffer_handle_t handle,
  33. uint32_t usage, const Rect& bounds, void** vaddr);
  34. status_t lockYCbCr(buffer_handle_t handle,
  35. uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr);
  36. status_t unlock(buffer_handle_t handle);
  37. status_t lockAsync(buffer_handle_t handle,
  38. uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd);
  39. status_t lockAsyncYCbCr(buffer_handle_t handle,
  40. uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr,
  41. int fenceFd);
  42. status_t unlockAsync(buffer_handle_t handle, int *fenceFd);
  43. #ifdef EXYNOS4_ENHANCEMENTS
  44. status_t getphys(buffer_handle_t handle, void** paddr);
  45. #endif
  46. // dumps information about the mapping of this handle
  47. void dump(buffer_handle_t handle);
  48. private:
  49. friend class Singleton<GraphicBufferMapper>;
  50. GraphicBufferMapper();
  51. gralloc_module_t const *mAllocMod;
  52. };
  53. // ---------------------------------------------------------------------------
  54. }; // namespace android
  55. #endif // ANDROID_UI_BUFFER_MAPPER_H