gpu_tonemapper: Clear EGLImage mappings in Tonemapper

Tonemapper does not clear the eglImage/fd mappings in the destructor,
which leads to incorrect usage of those fds, when a tone map session
gets deleted and a new session gets created, leading to artifcats.

CRs-Fixed: 1104823
Change-Id: I9697eff93f9e5f150796a582f471246bca3b2816
This commit is contained in:
Sushil Chauhan
2017-01-11 18:09:02 -08:00
parent eb5c32bed2
commit 1cc416f122
5 changed files with 23 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright 2015 The Android Open Source Project
@@ -22,8 +22,6 @@
#include <gralloc_priv.h>
#include <ui/GraphicBuffer.h>
std::map<int, EGLImageBuffer *> EGLImageWrapper::eglImageBufferMap;
//-----------------------------------------------------------------------------
EGLImageBuffer *EGLImageWrapper::wrap(const void *pvt_handle)
//-----------------------------------------------------------------------------
@@ -65,4 +63,4 @@ void EGLImageWrapper::destroy()
delete it->second;
}
eglImageBufferMap.clear();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright 2015 The Android Open Source Project
@@ -24,11 +24,11 @@
#include "EGLImageBuffer.h"
class EGLImageWrapper {
static std::map<int, EGLImageBuffer *> eglImageBufferMap;
std::map<int, EGLImageBuffer *> eglImageBufferMap;
public:
static EGLImageBuffer *wrap(const void *pvt_handle);
static void destroy();
EGLImageBuffer *wrap(const void *pvt_handle);
void destroy();
};
#endif //__TONEMAPPER_EGLIMAGEWRAPPER_H__
#endif //__TONEMAPPER_EGLIMAGEWRAPPER_H__

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright 2015 The Android Open Source Project
@@ -19,7 +19,6 @@
#include "TonemapFactory.h"
#include <utils/Log.h>
#include "EGLImageWrapper.h"
#include "Tonemapper.h"
#include "engine.h"
@@ -41,8 +40,6 @@ Tonemapper *TonemapperFactory_GetInstance(int type, void *colorMap, int colorMap
void TonemapperFactory_Destroy()
//------------------------------------------
{
// clear EGLImage mappings
EGLImageWrapper::destroy();
// shutdown the engine
engine_shutdown();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright 2015 The Android Open Source Project
@@ -32,6 +32,7 @@ Tonemapper::Tonemapper()
tonemapTexture = 0;
lutXformTexture = 0;
programID = 0;
eglImageWrapper = new EGLImageWrapper();
}
//-----------------------------------------------------------------------------
@@ -41,6 +42,13 @@ Tonemapper::~Tonemapper()
engine_deleteInputBuffer(tonemapTexture);
engine_deleteInputBuffer(lutXformTexture);
engine_deleteProgram(programID);
// clear EGLImage mappings
if (eglImageWrapper != 0) {
eglImageWrapper->destroy();
delete eglImageWrapper;
eglImageWrapper = 0;
}
}
//-----------------------------------------------------------------------------
@@ -95,8 +103,8 @@ int Tonemapper::blit(const void *dst, const void *src, int srcFenceFd)
engine_bind();
// create eglimages if required
EGLImageBuffer *dst_buffer = EGLImageWrapper::wrap(dst);
EGLImageBuffer *src_buffer = EGLImageWrapper::wrap(src);
EGLImageBuffer *dst_buffer = eglImageWrapper->wrap(dst);
EGLImageBuffer *src_buffer = eglImageWrapper->wrap(src);
// bind the program
engine_setProgram(programID);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright 2015 The Android Open Source Project
@@ -23,11 +23,14 @@
#define TONEMAP_FORWARD 0
#define TONEMAP_INVERSE 1
#include "EGLImageWrapper.h"
class Tonemapper {
private:
unsigned int tonemapTexture;
unsigned int lutXformTexture;
unsigned int programID;
EGLImageWrapper* eglImageWrapper;
Tonemapper();
public: