diff options
| author | Mister Oyster <oysterized@gmail.com> | 2017-01-02 12:44:35 +0100 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-01-02 12:44:35 +0100 |
| commit | a184d985bf43d3fe6eeba971bc6b32f79ea38b37 (patch) | |
| tree | 6f6e56e090777cc149bc1ab39e5987cc2b03e867 /mtk/gralloc_extra/GraphicBufferExtra.cpp | |
initial releasecm-13.0
Diffstat (limited to 'mtk/gralloc_extra/GraphicBufferExtra.cpp')
| -rw-r--r-- | mtk/gralloc_extra/GraphicBufferExtra.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/mtk/gralloc_extra/GraphicBufferExtra.cpp b/mtk/gralloc_extra/GraphicBufferExtra.cpp new file mode 100644 index 0000000..d1cbffc --- /dev/null +++ b/mtk/gralloc_extra/GraphicBufferExtra.cpp @@ -0,0 +1,49 @@ +#define LOG_TAG "GraphicBufferExtra" +#define ATRACE_TAG ATRACE_TAG_GRAPHICS +#include <cutils/log.h> +#include <ui/GraphicBufferExtra.h> +#include <graphics_mtk_defs.h> + +namespace android { +// --------------------------------------------------------------------------- + +ANDROID_SINGLETON_STATIC_INSTANCE( GraphicBufferExtra ) + +static GraphicBufferExtra * s_singleton_obj = NULL; + +GraphicBufferExtra::GraphicBufferExtra() + : mExtraDev(0) +{ + hw_module_t const* module; + int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); + + ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID); + if (err == 0) + { + gralloc_extra_open(module, &mExtraDev); + } + + s_singleton_obj = this; +} + +// dlclose +static void __attribute__((destructor)) gralloc_extra_dlclose(void) +{ + if (s_singleton_obj) + { + delete s_singleton_obj; + s_singleton_obj = NULL; + } +} + +GraphicBufferExtra::~GraphicBufferExtra() +{ + if (mExtraDev) + { + gralloc_extra_close(mExtraDev); + } + s_singleton_obj = NULL; +} + +// --------------------------------------------------------------------------- +}; // namespace android |
