X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Fgl-resources%2Fcontext.h;h=81561ba9130a74f7b71ff566df1da2853acbad22;hb=80ed4e486ec65a56454d274388345bc5ddcc13a9;hp=c2f11acd9ed88f288ea9ab0d40b8d11375f93849;hpb=b461bf8aff79358fc27202f9ae79bd383570a9f5;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/gl-resources/context.h b/dali/internal/render/gl-resources/context.h index c2f11ac..81561ba 100644 --- a/dali/internal/render/gl-resources/context.h +++ b/dali/internal/render/gl-resources/context.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_CONTEXT_H__ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,7 +119,7 @@ public: */ void PrintGlString(const char* stringName, GLenum stringId) { - DALI_LOG_INFO(Debug::Filter::gRender, Debug::General, "GL %s = %s\n", stringName, (const char *)GetString( stringId ) ); + DALI_LOG_INFO(Debug::Filter::gRender, Debug::General, "GL %s = %s\n", stringName, reinterpret_cast< const char * >( GetString( stringId ) ) ); } /**************************************************************************************** @@ -262,39 +262,30 @@ public: * @param textureunit to bind to * @param texture to bind */ - void BindTextureForUnit( TextureUnit textureunit, GLuint texture ) + void BindTextureForUnit( TextureUnit textureunit, int target, GLuint texture ) { - if( mBound2dTextureId[ textureunit ] != texture ) + if( mBoundTextureId[ textureunit ] != texture ) { ActiveTexture( textureunit ); - Bind2dTexture( texture ); + BindTexture( target, texture ); } } /** - * Wrapper for OpenGL ES 2.0 glBindTexture(GL_TEXTURE_2D) + * Wrapper for OpenGL ES 2.0 glBindTexture( target ) */ - void Bind2dTexture( GLuint texture ) + void BindTexture( int target, GLuint texture ) { - if (mBound2dTextureId[ mActiveTextureUnit ] != texture) + if (mBoundTextureId[ mActiveTextureUnit ] != texture) { - mBound2dTextureId[ mActiveTextureUnit ] = texture; + mBoundTextureId[ mActiveTextureUnit ] = texture; - LOG_GL("BindTexture GL_TEXTURE_2D %d\n", texture); - CHECK_GL( mGlAbstraction, mGlAbstraction.BindTexture(GL_TEXTURE_2D, texture) ); + LOG_GL("BindTexture target(%d) %d\n", target, texture); + CHECK_GL( mGlAbstraction, mGlAbstraction.BindTexture(target, texture) ); } } /** - * Wrapper for OpenGL ES 2.0 glBindTexture(GL_TEXTURE_CUBE_MAP) - */ - void BindCubeMapTexture( GLuint texture ) - { - LOG_GL("BindTexture GL_TEXTURE_CUBE_MAP %d\n", texture); - CHECK_GL( mGlAbstraction, mGlAbstraction.BindTexture(GL_TEXTURE_CUBE_MAP, texture) ); - } - - /** * Wrapper for OpenGL ES 2.0 glBlendColor() */ void SetDefaultBlendColor() @@ -655,7 +646,7 @@ public: // when creating new textures for( unsigned int i=0; i < MAX_TEXTURE_UNITS; ++i ) { - mBound2dTextureId[ i ] = 0; + mBoundTextureId[ i ] = 0; } } @@ -686,11 +677,12 @@ public: */ void DepthMask(GLboolean flag) { + bool booleanFlag = flag != GL_FALSE; // only change state if needed - if( flag != mDepthMaskEnabled ) + if( booleanFlag != mDepthMaskEnabled ) { - mDepthMaskEnabled = flag; - LOG_GL("DepthMask %s\n", flag ? "True" : "False"); + mDepthMaskEnabled = booleanFlag; + LOG_GL("DepthMask %s\n", booleanFlag ? "True" : "False"); CHECK_GL( mGlAbstraction, mGlAbstraction.DepthMask( mDepthMaskEnabled ) ); } } @@ -1482,10 +1474,15 @@ public: */ void StencilFunc(GLenum func, GLint ref, GLuint mask) { + if( ( func != mStencilFunc ) || ( ref != mStencilFuncRef ) || ( mask != mStencilFuncMask ) ) + { + mStencilFunc = func; + mStencilFuncRef = ref; + mStencilFuncMask = mask; - - LOG_GL("StencilFunc %x %d %d\n", func, ref, mask); - CHECK_GL( mGlAbstraction, mGlAbstraction.StencilFunc(func, ref, mask) ); + LOG_GL("StencilFunc %x %d %d\n", func, ref, mask); + CHECK_GL( mGlAbstraction, mGlAbstraction.StencilFunc(func, ref, mask) ); + } } /** @@ -1525,8 +1522,15 @@ public: */ void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) { - LOG_GL("StencilOp %x %x %x\n", fail, zfail, zpass); - CHECK_GL( mGlAbstraction, mGlAbstraction.StencilOp(fail, zfail, zpass) ); + if( ( fail != mStencilOpFail ) || ( zfail != mStencilOpDepthFail ) || ( zpass != mStencilOpDepthPass ) ) + { + mStencilOpFail = fail; + mStencilOpDepthFail = zfail; + mStencilOpDepthPass = zpass; + + LOG_GL("StencilOp %x %x %x\n", fail, zfail, zpass); + CHECK_GL( mGlAbstraction, mGlAbstraction.StencilOp(fail, zfail, zpass) ); + } } /** @@ -1719,7 +1723,7 @@ private: // Data // glBindTexture() state TextureUnit mActiveTextureUnit; - GLuint mBound2dTextureId[ MAX_TEXTURE_UNITS ]; ///< The ID passed to glBindTexture(GL_TEXTURE_2D) + GLuint mBoundTextureId[ MAX_TEXTURE_UNITS ]; ///< The ID passed to glBindTexture() // glBlendColor() state Vector4 mBlendColor; ///< Blend color @@ -1734,6 +1738,14 @@ private: // Data GLenum mBlendEquationSeparateModeRGB; ///< Controls RGB blend mode GLenum mBlendEquationSeparateModeAlpha; ///< Controls Alpha blend mode + // glStencilFunc() and glStencilOp() state. + GLenum mStencilFunc; + GLint mStencilFuncRef; + GLuint mStencilFuncMask; + GLenum mStencilOpFail; + GLenum mStencilOpDepthFail; + GLenum mStencilOpDepthPass; + GLenum mDepthFunction; ///The depth function GLint mMaxTextureSize; ///< return value from GetIntegerv(GL_MAX_TEXTURE_SIZE)