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
This commit is contained in:
Sushil Chauhan
2017-05-02 17:09:47 -07:00
committed by Gerrit - the friendly Code Review server
parent ec4b547fbf
commit 70bc2c01f0
9 changed files with 22 additions and 13 deletions

View File

@@ -24,7 +24,6 @@
#include <map> #include <map>
#include "EGLImageWrapper.h" #include "EGLImageWrapper.h"
#include "glengine.h" #include "glengine.h"
#define EGL_PROTECTED_CONTENT_EXT 0x32C0
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
EGLImageKHR create_eglImage(android::sp<android::GraphicBuffer> graphicBuffer) EGLImageKHR create_eglImage(android::sp<android::GraphicBuffer> graphicBuffer)

View File

@@ -24,11 +24,11 @@
//---------------------------------------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------------------------------------------
Tonemapper *TonemapperFactory_GetInstance(int type, void *colorMap, int colorMapSize, Tonemapper *TonemapperFactory_GetInstance(int type, void *colorMap, int colorMapSize,
void *lutXform, int lutXformSize) void *lutXform, int lutXformSize, bool isSecure)
//---------------------------------------------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------------------------------------------
{ {
// build the tonemapper // build the tonemapper
Tonemapper *tonemapper = Tonemapper::build(type, colorMap, colorMapSize, lutXform, lutXformSize); Tonemapper *tonemapper = Tonemapper::build(type, colorMap, colorMapSize, lutXform, lutXformSize, isSecure);
return tonemapper; return tonemapper;
} }

View File

@@ -28,7 +28,7 @@ extern "C" {
// returns an instance of Tonemapper // returns an instance of Tonemapper
Tonemapper *TonemapperFactory_GetInstance(int type, void *colorMap, int colorMapSize, Tonemapper *TonemapperFactory_GetInstance(int type, void *colorMap, int colorMapSize,
void *lutXform, int lutXformSize); void *lutXform, int lutXformSize, bool isSecure);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -65,7 +65,7 @@ Tonemapper::~Tonemapper()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Tonemapper *Tonemapper::build(int type, void *colorMap, int colorMapSize, void *lutXform, Tonemapper *Tonemapper::build(int type, void *colorMap, int colorMapSize, void *lutXform,
int lutXformSize) int lutXformSize, bool isSecure)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
if (colorMapSize <= 0) { if (colorMapSize <= 0) {
@@ -76,7 +76,7 @@ Tonemapper *Tonemapper::build(int type, void *colorMap, int colorMapSize, void *
// build new tonemapper // build new tonemapper
Tonemapper *tonemapper = new Tonemapper(); Tonemapper *tonemapper = new Tonemapper();
tonemapper->engineContext = engine_initialize(); tonemapper->engineContext = engine_initialize(isSecure);
void* caller_context = engine_backup(); void* caller_context = engine_backup();
engine_bind(tonemapper->engineContext); engine_bind(tonemapper->engineContext);

View File

@@ -40,7 +40,7 @@ class Tonemapper {
public: public:
~Tonemapper(); ~Tonemapper();
static Tonemapper *build(int type, void *colorMap, int colorMapSize, void *lutXform, 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); int blit(const void *dst, const void *src, int srcFenceFd);
}; };

View File

@@ -20,7 +20,7 @@
#ifndef __TONEMAPPER_ENGINE_H__ #ifndef __TONEMAPPER_ENGINE_H__
#define __TONEMAPPER_ENGINE_H__ #define __TONEMAPPER_ENGINE_H__
void* engine_initialize(); void* engine_initialize(bool isSecure);
void engine_bind(void*); void engine_bind(void*);
void* engine_backup(); void* engine_backup();
void engine_free_backup(void*); void engine_free_backup(void*);

View File

@@ -70,7 +70,7 @@ void engine_free_backup(void* context)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// initialize GL // initialize GL
// //
void* engine_initialize() void* engine_initialize(bool isSecure)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
EngineContext* engineContext = new EngineContext(); EngineContext* engineContext = new EngineContext();
@@ -94,11 +94,18 @@ void* engine_initialize()
EGL(eglChooseConfig(engineContext->eglDisplay, eglConfigAttribList, &eglConfig, 1, &numConfig)); EGL(eglChooseConfig(engineContext->eglDisplay, eglConfigAttribList, &eglConfig, 1, &numConfig));
// context // 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); engineContext->eglContext = eglCreateContext(engineContext->eglDisplay, eglConfig, NULL, eglContextAttribList);
// surface // 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); engineContext->eglSurface = eglCreatePbufferSurface(engineContext->eglDisplay, eglConfig, eglSurfaceAttribList);
eglMakeCurrent(engineContext->eglDisplay, engineContext->eglSurface, engineContext->eglSurface, engineContext->eglContext); eglMakeCurrent(engineContext->eglDisplay, engineContext->eglSurface, engineContext->eglSurface, engineContext->eglContext);

View File

@@ -39,7 +39,9 @@
checkEglError(__FILE__, __LINE__); checkEglError(__FILE__, __LINE__);
#endif #endif
#define EGL_PROTECTED_CONTENT_EXT 0x32C0
void checkGlError(const char *file, int line); void checkGlError(const char *file, int line);
void checkEglError(const char *file, int line); void checkEglError(const char *file, int line);
#endif //__TONEMAPPER_GLENGINE_H__ #endif //__TONEMAPPER_GLENGINE_H__

View File

@@ -303,7 +303,8 @@ DisplayError HWCToneMapper::AcquireToneMapSession(Layer *layer, uint32_t *sessio
session->gpu_tone_mapper_ = TonemapperFactory_GetInstance(session->tone_map_config_.type, session->gpu_tone_mapper_ = TonemapperFactory_GetInstance(session->tone_map_config_.type,
layer->lut_3d.lutEntries, layer->lut_3d.lutEntries,
layer->lut_3d.dim, layer->lut_3d.dim,
grid_entries, grid_size); grid_entries, grid_size,
session->tone_map_config_.secure);
if (session->gpu_tone_mapper_ == NULL) { if (session->gpu_tone_mapper_ == NULL) {
DLOGE("Get Tonemapper failed!"); DLOGE("Get Tonemapper failed!");