From: Nick Holland Date: Wed, 10 May 2017 14:32:17 +0000 (+0100) Subject: Fix support for NativeImage X-Git-Tag: dali_1.2.40~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8513ce64554f7e406b71f8ea231a1380e93fcf37;p=platform%2Fcore%2Fuifw%2Fdali-core.git Fix support for NativeImage - Fixed program to recognise uniforms with type: GL_SAMPLER_EXTERNAL_OES - Fixed Framebuffer renderer to use GL_TEXTURE_EXTERNAL_OES Change-Id: I337ab3f461aa43fd10b311895b2f186b2462e617 --- diff --git a/dali/integration-api/gl-defines.h b/dali/integration-api/gl-defines.h index eebb484..8a2f740 100644 --- a/dali/integration-api/gl-defines.h +++ b/dali/integration-api/gl-defines.h @@ -859,5 +859,9 @@ #define GL_TEXTURE_EXTERNAL_OES 0x8D65 #endif +/* GL_SAMPLER_EXTERNAL_OES */ +#ifndef GL_SAMPLER_EXTERNAL_OES +#define GL_SAMPLER_EXTERNAL_OES 0x8D66 +#endif #endif // __DALI_INTERNAL_GL_DEFINES_H__ diff --git a/dali/internal/render/renderers/render-frame-buffer.cpp b/dali/internal/render/renderers/render-frame-buffer.cpp index 6281d9b..238a8cf 100644 --- a/dali/internal/render/renderers/render-frame-buffer.cpp +++ b/dali/internal/render/renderers/render-frame-buffer.cpp @@ -85,7 +85,15 @@ void FrameBuffer::AttachColorTexture( Context& context, Render::Texture* texture // Create a color attachment. if( texture->GetType() == TextureType::TEXTURE_2D ) { - context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->GetId(), mipmapLevel ); + if( !texture->IsNativeImage() ) + { + context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->GetId(), mipmapLevel ); + } + else + { + // If it's a native image we need to use GL_TEXTURE_EXTERNAL_OES as the texture target parameter + context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_EXTERNAL_OES, texture->GetId(), mipmapLevel ); + } } else { diff --git a/dali/internal/render/renderers/render-texture.h b/dali/internal/render/renderers/render-texture.h index db5988b..e50ec3d 100644 --- a/dali/internal/render/renderers/render-texture.h +++ b/dali/internal/render/renderers/render-texture.h @@ -145,6 +145,15 @@ public: return mType; } + /** + * Check if the texture is a native image + * @return if the texture is a native image + */ + bool IsNativeImage() const + { + return mNativeImage; + } + private: /** @@ -161,7 +170,7 @@ private: NativeImageInterfacePtr mNativeImage; ///< Pointer to native image GLenum mInternalFormat; ///< The format of the pixel data GLenum mPixelDataType; ///< The data type of the pixel data - unsigned int mWidth; ///< Widht of the texture + unsigned int mWidth; ///< Width of the texture unsigned int mHeight; ///< Height of the texture bool mHasAlpha : 1; ///< Whether the format has an alpha channel bool mIsCompressed : 1; ///< Whether the format is compressed diff --git a/dali/internal/render/shaders/program.cpp b/dali/internal/render/shaders/program.cpp index 0f22758..5739f18 100644 --- a/dali/internal/render/shaders/program.cpp +++ b/dali/internal/render/shaders/program.cpp @@ -261,7 +261,7 @@ void Program::GetActiveSamplerUniforms() mGlAbstraction.GetActiveUniform( mProgramId, (GLuint)i, uniformMaxNameLength, &nameLength, &number, &type, name ); - if( type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE ) /// Is there a native sampler type? + if( type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES ) { GLuint location = mGlAbstraction.GetUniformLocation( mProgramId, name ); samplerNames.push_back(name); @@ -277,7 +277,9 @@ void Program::GetActiveSamplerUniforms() int samplerPosition = 0; while( token ) { - if( ( strncmp( token, "sampler2D", 9u ) == 0 ) || ( strncmp( token, "samplerCube", 11u ) == 0 ) ) + if( ( strncmp( token, "sampler2D", 9u ) == 0 ) || + ( strncmp( token, "samplerCube", 11u ) == 0 ) || + ( strncmp( token, "samplerExternalOES", 18u ) == 0 ) ) { bool found( false ); token = strtok_r( NULL, " ;\n", &nextPtr );