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
diff --git a/gpu_tonemapper/EGLImageBuffer.cpp b/gpu_tonemapper/EGLImageBuffer.cpp
index 3ed236b..eeb0273 100644
--- a/gpu_tonemapper/EGLImageBuffer.cpp
+++ b/gpu_tonemapper/EGLImageBuffer.cpp
@@ -24,7 +24,6 @@
#include <map>
#include "EGLImageWrapper.h"
#include "glengine.h"
-#define EGL_PROTECTED_CONTENT_EXT 0x32C0
//-----------------------------------------------------------------------------
EGLImageKHR create_eglImage(android::sp<android::GraphicBuffer> graphicBuffer)
diff --git a/gpu_tonemapper/TonemapFactory.cpp b/gpu_tonemapper/TonemapFactory.cpp
index 5aae697..3233682 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 404f4cd..17cad40 100644
--- a/gpu_tonemapper/TonemapFactory.h
+++ b/gpu_tonemapper/TonemapFactory.h
@@ -28,7 +28,7 @@
// 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 c6646f6..981863d 100644
--- a/gpu_tonemapper/Tonemapper.cpp
+++ b/gpu_tonemapper/Tonemapper.cpp
@@ -65,7 +65,7 @@
//-----------------------------------------------------------------------------
Tonemapper *Tonemapper::build(int type, void *colorMap, int colorMapSize, void *lutXform,
- int lutXformSize)
+ int lutXformSize, bool isSecure)
//-----------------------------------------------------------------------------
{
if (colorMapSize <= 0) {
@@ -76,7 +76,7 @@
// 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 88866d5..707cdfe 100644
--- a/gpu_tonemapper/Tonemapper.h
+++ b/gpu_tonemapper/Tonemapper.h
@@ -40,7 +40,7 @@
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 84c7dc6..e0bf2aa 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 90fe502..6cfe15f 100644
--- a/gpu_tonemapper/glengine.cpp
+++ b/gpu_tonemapper/glengine.cpp
@@ -70,7 +70,7 @@
//-----------------------------------------------------------------------------
// initialize GL
//
-void* engine_initialize()
+void* engine_initialize(bool isSecure)
//-----------------------------------------------------------------------------
{
EngineContext* engineContext = new EngineContext();
@@ -94,11 +94,18 @@
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 c5b166c..f6aeec8 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__