X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Fgl-resources%2Fcontext.h;h=59ed39659b0fe479a0056405f9c16d75547ac3bc;hb=091424324901c46a18959bfc0dd52f7ce8a0a811;hp=e542f3351ff80dbdd3307cdc1d894d72a99678d3;hpb=d2fad552be0c0410b7070db30ce3b3d5dba81222;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 e542f33..59ed396 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) 2014 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. @@ -23,10 +23,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -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 ) ) ); } /**************************************************************************************** @@ -286,6 +286,29 @@ public: } /** + * Wrapper for OpenGL ES 2.0 glBindTexture( target ) + */ + void BindTexture( int target, GLuint texture ) + { + if (mBound2dTextureId[ mActiveTextureUnit ] != texture) + { + mBound2dTextureId[ mActiveTextureUnit ] = 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() @@ -537,7 +560,7 @@ public: * enables GL_CULL_FACE if in any of the face culling modes * otherwise disables GL_CULL_FACE */ - void CullFace( Dali::Material::FaceCullingMode mode ) + void CullFace( Dali::FaceCullingMode::Type mode ) { // Avoid unnecessary calls to gl if(mCullFaceMode != mode) @@ -545,14 +568,14 @@ public: mCullFaceMode = mode; switch(mode) { - case Dali::Material::NONE: + case Dali::FaceCullingMode::NONE: { LOG_GL("Disable GL_CULL_FACE\n"); CHECK_GL( mGlAbstraction, mGlAbstraction.Disable(GL_CULL_FACE) ); break; } - case Dali::Material::CULL_FRONT: + case Dali::FaceCullingMode::FRONT: { LOG_GL("Enable GL_CULL_FACE\n"); CHECK_GL( mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE) ); @@ -561,7 +584,7 @@ public: break; } - case Dali::Material::CULL_BACK: + case Dali::FaceCullingMode::BACK: { LOG_GL("Enable GL_CULL_FACE\n"); CHECK_GL( mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE) ); @@ -570,7 +593,7 @@ public: break; } - case Dali::Material::CULL_BACK_AND_FRONT: + case Dali::FaceCullingMode::FRONT_AND_BACK: { LOG_GL("Enable GL_CULL_FACE\n"); CHECK_GL( mGlAbstraction, mGlAbstraction.Enable(GL_CULL_FACE) ); @@ -664,8 +687,12 @@ public: */ void DepthFunc(GLenum func) { - LOG_GL("DepthFunc %x\n", func); - CHECK_GL( mGlAbstraction, mGlAbstraction.DepthFunc(func) ); + if( func != mDepthFunction ) + { + mDepthFunction = func; + LOG_GL("DepthFunc %x\n", func); + CHECK_GL( mGlAbstraction, mGlAbstraction.DepthFunc(func) ); + } } /** @@ -673,11 +700,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 ) ); } } @@ -1642,70 +1670,6 @@ public: */ const Rect< int >& GetViewport(); - /** - * Set the frame count of render thread - */ - inline void SetFrameCount(unsigned int frameCount) - { - mFrameCount = frameCount; - } - - /** - * Get the frame count - */ - inline unsigned int GetFrameCount() - { - return mFrameCount; - } - - /** - * Increment the count of culled renderers - */ - inline void IncrementCulledCount() - { - mCulledCount++; - } - - /** - * Clear the count of culled renderers - */ - inline void ClearCulledCount() - { - mCulledCount = 0; - } - - /** - * Get the count of culled renderers in this frame - */ - inline unsigned int GetCulledCount() - { - return mCulledCount; - } - - /** - * Increment the count of culled renderers - */ - inline void IncrementRendererCount() - { - mRendererCount++; - } - - /** - * Clear the count of image renderers - */ - inline void ClearRendererCount() - { - mRendererCount = 0; - } - - /** - * Get the count of image renderers in this frame - */ - inline unsigned int GetRendererCount() - { - return mRendererCount; - } - private: // Implementation /** @@ -1785,11 +1749,13 @@ private: // Data GLenum mBlendEquationSeparateModeRGB; ///< Controls RGB blend mode GLenum mBlendEquationSeparateModeAlpha; ///< Controls Alpha blend mode + GLenum mDepthFunction; ///The depth function + GLint mMaxTextureSize; ///< return value from GetIntegerv(GL_MAX_TEXTURE_SIZE) Vector4 mClearColor; ///< clear color // Face culling mode - Dali::Material::FaceCullingMode mCullFaceMode; + Dali::FaceCullingMode::Type mCullFaceMode; // cached viewport size Rect< int > mViewPort; @@ -1798,9 +1764,6 @@ private: // Data bool mVertexAttributeCachedState[ MAX_ATTRIBUTE_CACHE_SIZE ]; ///< Value cache for Enable Vertex Attribute bool mVertexAttributeCurrentState[ MAX_ATTRIBUTE_CACHE_SIZE ]; ///< Current state on the driver for Enable Vertex Attribute - unsigned int mFrameCount; ///< Number of render frames - unsigned int mCulledCount; ///< Number of culled renderers per frame - unsigned int mRendererCount; ///< Number of image renderers per frame FrameBufferStateCache mFrameBufferStateCache; ///< frame buffer state cache };