{
namespace
{
-const char* FRAGMENT_PREFIX = "#extension GL_OES_EGL_image_external:require\n";
-const char* SAMPLER_TYPE = "samplerExternalOES";
+const char* SAMPLER_TYPE = "samplerExternalOES";
// clang-format off
tbm_format FORMATS_BLENDING_REQUIRED[] = {
}
NativeImageSourceTizen::NativeImageSourceTizen(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
-: mWidth(width),
+: mCustomFragmentPrefix(),
+ mWidth(width),
mHeight(height),
mOwnTbmSurface(false),
mTbmSurface(NULL),
GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
mEglGraphics = static_cast<EglGraphics*>(graphics);
+ mCustomFragmentPrefix = mEglGraphics->GetEglImageExtensionString();
+
mTbmSurface = GetSurfaceFromAny(nativeImageSource);
if(mTbmSurface != NULL)
bool NativeImageSourceTizen::CreateResource()
{
+ // If an EGL image exists, use it as it is without creating it.
+ if(mEglImageKHR != NULL)
+ {
+ return true;
+ }
+
// casting from an unsigned int to a void *, which should then be cast back
// to an unsigned int in the driver.
EGLClientBuffer eglBuffer = reinterpret_cast<EGLClientBuffer>(mTbmSurface);
Dali::Mutex::ScopedLock lock(mMutex);
if(mSetSource)
{
- void* eglImage = mEglImageKHR;
+ // Destroy previous eglImage because use for new one.
+ // if mEglImageKHR is not to be NULL here, it will not be updated with a new eglImage.
+ mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
+ mEglImageKHR = NULL;
if(CreateResource())
{
TargetTexture();
}
- mEglImageExtensions->DestroyImageKHR(eglImage);
-
mSetSource = false;
}
}
const char* NativeImageSourceTizen::GetCustomFragmentPrefix() const
{
- return FRAGMENT_PREFIX;
+ return mCustomFragmentPrefix;
}
const char* NativeImageSourceTizen::GetCustomSamplerTypename() const
{
tbm_surface_info_s info;
- if(tbm_surface_map(mTbmSurface, TBM_SURF_OPTION_READ, &info) != TBM_SURFACE_ERROR_NONE)
+ if(tbm_surface_map(mTbmSurface, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &info) != TBM_SURFACE_ERROR_NONE)
{
DALI_LOG_ERROR("Fail to map tbm_surface\n");