From 70bc2c01f0786908bc29de1d93ca462734b0c933 Mon Sep 17 00:00:00 2001 From: Sushil Chauhan Date: Tue, 2 May 2017 17:09:47 -0700 Subject: [PATCH] hwc: gpu_tonemapper: Create Secure EGL Context - HWC tonemapper passes secure flag to GPU tonemapper to create object with secure EGL context. - Tonemapper object gets created with secure EGL context for the tone mapping of secure HDR layer. CRs-Fixed: 2048764 Change-Id: I7129505283527dbab17f1e9731d8f141b48bb310 --- gpu_tonemapper/EGLImageBuffer.cpp | 1 - gpu_tonemapper/TonemapFactory.cpp | 4 ++-- gpu_tonemapper/TonemapFactory.h | 2 +- gpu_tonemapper/Tonemapper.cpp | 4 ++-- gpu_tonemapper/Tonemapper.h | 2 +- gpu_tonemapper/engine.h | 2 +- gpu_tonemapper/glengine.cpp | 13 ++++++++++--- gpu_tonemapper/glengine.h | 4 +++- sdm/libs/hwc/hwc_tonemapper.cpp | 3 ++- 9 files changed, 22 insertions(+), 13 deletions(-) diff --git a/gpu_tonemapper/EGLImageBuffer.cpp b/gpu_tonemapper/EGLImageBuffer.cpp index 3ed236b1..eeb02733 100644 --- a/gpu_tonemapper/EGLImageBuffer.cpp +++ b/gpu_tonemapper/EGLImageBuffer.cpp @@ -24,7 +24,6 @@ #include #include "EGLImageWrapper.h" #include "glengine.h" -#define EGL_PROTECTED_CONTENT_EXT 0x32C0 //----------------------------------------------------------------------------- EGLImageKHR create_eglImage(android::sp graphicBuffer) diff --git a/gpu_tonemapper/TonemapFactory.cpp b/gpu_tonemapper/TonemapFactory.cpp index 5aae6979..3233682e 100644 --- a/gpu_tonemapper/TonemapFactory.cpp +++ b/gpu_tonemapper/TonemapFactory.cpp @@ -24,11 +24,11 @@ //---------------------------------------------------------------------------------------------------------------------------------------------------------- Tonemapper *TonemapperFactory_GetInstance(int type, void *colorMap, int colorMapSize, - void *lutXform, int lutXformSize) + void *lutXform, int lutXformSize, bool isSecure) //---------------------------------------------------------------------------------------------------------------------------------------------------------- { // build the tonemapper - Tonemapper *tonemapper = Tonemapper::build(type, colorMap, colorMapSize, lutXform, lutXformSize); + Tonemapper *tonemapper = Tonemapper::build(type, colorMap, colorMapSize, lutXform, lutXformSize, isSecure); return tonemapper; } diff --git a/gpu_tonemapper/TonemapFactory.h b/gpu_tonemapper/TonemapFactory.h index 404f4cda..17cad400 100644 --- a/gpu_tonemapper/TonemapFactory.h +++ b/gpu_tonemapper/TonemapFactory.h @@ -28,7 +28,7 @@ extern "C" { // returns an instance of Tonemapper Tonemapper *TonemapperFactory_GetInstance(int type, void *colorMap, int colorMapSize, - void *lutXform, int lutXformSize); + void *lutXform, int lutXformSize, bool isSecure); #ifdef __cplusplus } diff --git a/gpu_tonemapper/Tonemapper.cpp b/gpu_tonemapper/Tonemapper.cpp index c6646f62..981863d4 100644 --- a/gpu_tonemapper/Tonemapper.cpp +++ b/gpu_tonemapper/Tonemapper.cpp @@ -65,7 +65,7 @@ Tonemapper::~Tonemapper() //----------------------------------------------------------------------------- Tonemapper *Tonemapper::build(int type, void *colorMap, int colorMapSize, void *lutXform, - int lutXformSize) + int lutXformSize, bool isSecure) //----------------------------------------------------------------------------- { if (colorMapSize <= 0) { @@ -76,7 +76,7 @@ Tonemapper *Tonemapper::build(int type, void *colorMap, int colorMapSize, void * // build new tonemapper Tonemapper *tonemapper = new Tonemapper(); - tonemapper->engineContext = engine_initialize(); + tonemapper->engineContext = engine_initialize(isSecure); void* caller_context = engine_backup(); engine_bind(tonemapper->engineContext); diff --git a/gpu_tonemapper/Tonemapper.h b/gpu_tonemapper/Tonemapper.h index 88866d5f..707cdfe6 100644 --- a/gpu_tonemapper/Tonemapper.h +++ b/gpu_tonemapper/Tonemapper.h @@ -40,7 +40,7 @@ class Tonemapper { public: ~Tonemapper(); static Tonemapper *build(int type, void *colorMap, int colorMapSize, void *lutXform, - int lutXformSize); + int lutXformSize, bool isSecure); int blit(const void *dst, const void *src, int srcFenceFd); }; diff --git a/gpu_tonemapper/engine.h b/gpu_tonemapper/engine.h index 84c7dc66..e0bf2aa5 100644 --- a/gpu_tonemapper/engine.h +++ b/gpu_tonemapper/engine.h @@ -20,7 +20,7 @@ #ifndef __TONEMAPPER_ENGINE_H__ #define __TONEMAPPER_ENGINE_H__ -void* engine_initialize(); +void* engine_initialize(bool isSecure); void engine_bind(void*); void* engine_backup(); void engine_free_backup(void*); diff --git a/gpu_tonemapper/glengine.cpp b/gpu_tonemapper/glengine.cpp index 90fe5022..6cfe15f5 100644 --- a/gpu_tonemapper/glengine.cpp +++ b/gpu_tonemapper/glengine.cpp @@ -70,7 +70,7 @@ void engine_free_backup(void* context) //----------------------------------------------------------------------------- // initialize GL // -void* engine_initialize() +void* engine_initialize(bool isSecure) //----------------------------------------------------------------------------- { EngineContext* engineContext = new EngineContext(); @@ -94,11 +94,18 @@ void* engine_initialize() EGL(eglChooseConfig(engineContext->eglDisplay, eglConfigAttribList, &eglConfig, 1, &numConfig)); // context - EGLint eglContextAttribList[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE}; + EGLint eglContextAttribList[] = {EGL_CONTEXT_CLIENT_VERSION, 3, + isSecure ? EGL_PROTECTED_CONTENT_EXT : EGL_NONE, + isSecure ? EGL_TRUE : EGL_NONE, + EGL_NONE}; engineContext->eglContext = eglCreateContext(engineContext->eglDisplay, eglConfig, NULL, eglContextAttribList); // surface - EGLint eglSurfaceAttribList[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE, EGL_NONE}; + EGLint eglSurfaceAttribList[] = {EGL_WIDTH, 1, + EGL_HEIGHT, 1, + isSecure ? EGL_PROTECTED_CONTENT_EXT : EGL_NONE, + isSecure ? EGL_TRUE : EGL_NONE, + EGL_NONE}; engineContext->eglSurface = eglCreatePbufferSurface(engineContext->eglDisplay, eglConfig, eglSurfaceAttribList); eglMakeCurrent(engineContext->eglDisplay, engineContext->eglSurface, engineContext->eglSurface, engineContext->eglContext); diff --git a/gpu_tonemapper/glengine.h b/gpu_tonemapper/glengine.h index c5b166cc..f6aeec84 100644 --- a/gpu_tonemapper/glengine.h +++ b/gpu_tonemapper/glengine.h @@ -39,7 +39,9 @@ checkEglError(__FILE__, __LINE__); #endif +#define EGL_PROTECTED_CONTENT_EXT 0x32C0 + void checkGlError(const char *file, int line); void checkEglError(const char *file, int line); -#endif //__TONEMAPPER_GLENGINE_H__ \ No newline at end of file +#endif //__TONEMAPPER_GLENGINE_H__ diff --git a/sdm/libs/hwc/hwc_tonemapper.cpp b/sdm/libs/hwc/hwc_tonemapper.cpp index 0ceb2e5c..c09ff9e2 100644 --- a/sdm/libs/hwc/hwc_tonemapper.cpp +++ b/sdm/libs/hwc/hwc_tonemapper.cpp @@ -303,7 +303,8 @@ DisplayError HWCToneMapper::AcquireToneMapSession(Layer *layer, uint32_t *sessio session->gpu_tone_mapper_ = TonemapperFactory_GetInstance(session->tone_map_config_.type, layer->lut_3d.lutEntries, layer->lut_3d.dim, - grid_entries, grid_size); + grid_entries, grid_size, + session->tone_map_config_.secure); if (session->gpu_tone_mapper_ == NULL) { DLOGE("Get Tonemapper failed!");