Revert "Remove dali-core dependency of GLES version."
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-gl-abstraction.h
index 1613bb5..c68573b 100644 (file)
@@ -2,7 +2,7 @@
 #define TEST_GL_ABSTRACTION_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -49,7 +49,7 @@ static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
     "aBoneIndices"  // ATTRIB_BONE_INDICES
 };
 
-class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
+class DALI_CORE_API TestGlAbstraction: public Dali::Integration::GlAbstraction
 {
 public:
   TestGlAbstraction();
@@ -426,6 +426,7 @@ public:
       paramName<<"texture["<<i<<"]";
       namedParams[paramName.str()] = ToString(textures[i]);
       mDeletedTextureIds.push_back(textures[i]);
+      mNumGeneratedTextures--;
     }
     out << "]";
 
@@ -642,6 +643,7 @@ public:
       {
         *(textures+i) = ++mLastAutoTextureIdUsed;
       }
+      mNumGeneratedTextures++;
     }
 
     TraceCallStack::NamedParams namedParams;
@@ -663,6 +665,15 @@ public:
     mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
   }
 
+  inline GLuint GetLastGenTextureId()
+  {
+    return mLastAutoTextureIdUsed;
+  }
+  inline GLuint GetNumGeneratedTextures()
+  {
+    return mNumGeneratedTextures;
+  }
+
   inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
   {
   }
@@ -938,6 +949,15 @@ public:
     mScissorParams.y = y;
     mScissorParams.width = width;
     mScissorParams.height = height;
+
+    std::stringstream out;
+    out << x << ", " << y << ", " << width << ", " << height;
+    TraceCallStack::NamedParams namedParams;
+    namedParams["x"] = ToString( x );
+    namedParams["y"] = ToString( y );
+    namedParams["width"] = ToString( width );
+    namedParams["height"] = ToString( height );
+    mScissorTrace.PushCall( "Scissor", out.str(), namedParams );
   }
 
   inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
@@ -1135,9 +1155,12 @@ public:
     mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
   }
 
-  inline void Uniform1f(GLint location, GLfloat x)
+  inline void Uniform1f(GLint location, GLfloat value )
   {
-    if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
+    std::string params = ToString( value );
+    AddUniformCallToTraceStack( location, params );
+
+    if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, value ) )
     {
       mGetErrorResult = GL_INVALID_OPERATION;
     }
@@ -1145,6 +1168,14 @@ public:
 
   inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
   {
+    std::string params;
+    for( int i = 0; i < count; ++i )
+    {
+      params = params + ToString( v[i] ) + ",";
+    }
+
+    AddUniformCallToTraceStack( location, params );
+
     for( int i = 0; i < count; ++i )
     {
       if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
@@ -1157,6 +1188,10 @@ public:
 
   inline void Uniform1i(GLint location, GLint x)
   {
+    std::string params = ToString( x );
+
+    AddUniformCallToTraceStack( location,  params );
+
     if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
     {
       mGetErrorResult = GL_INVALID_OPERATION;
@@ -1165,6 +1200,9 @@ public:
 
   inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
   {
+    std::string params = ToString( v );
+    AddUniformCallToTraceStack( location, params );
+
     for( int i = 0; i < count; ++i )
     {
       if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
@@ -1179,6 +1217,9 @@ public:
 
   inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
   {
+    std::string params = ToString( x ) + "," + ToString( y );
+    AddUniformCallToTraceStack( location, params );
+
     if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
                                                location,
                                                Vector2( x, y ) ) )
@@ -1189,6 +1230,9 @@ public:
 
   inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
   {
+    std::string params = ToString( v );
+    AddUniformCallToTraceStack( location, params );
+
     for( int i = 0; i < count; ++i )
     {
       if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
@@ -1203,14 +1247,21 @@ public:
 
   inline void Uniform2i(GLint location, GLint x, GLint y)
   {
+    std::string params = ToString( x ) + "," + ToString( y );
+    AddUniformCallToTraceStack( location, params );
   }
 
   inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
   {
+    std::string params = ToString( v );
+    AddUniformCallToTraceStack( location, params );
   }
 
   inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
   {
+    std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
+    AddUniformCallToTraceStack( location, params );
+
     if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
                                                location,
                                                Vector3( x, y, z ) ) )
@@ -1221,6 +1272,9 @@ public:
 
   inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
   {
+    std::string params = ToString( v );
+    AddUniformCallToTraceStack( location, params );
+
     for( int i = 0; i < count; ++i )
     {
       if( ! mProgramUniforms3f.SetUniformValue(
@@ -1236,14 +1290,21 @@ public:
 
   inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
   {
+    std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
+    AddUniformCallToTraceStack( location, params );
   }
 
   inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
   {
+    std::string params = ToString( v );
+    AddUniformCallToTraceStack( location, params );
   }
 
   inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
   {
+    std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
+    AddUniformCallToTraceStack( location, params );
+
     if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
                                               location,
                                               Vector4( x, y, z, w ) ) )
@@ -1254,6 +1315,9 @@ public:
 
   inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
   {
+    std::string params = ToString( v );
+    AddUniformCallToTraceStack( location, params );
+
     for( int i = 0; i < count; ++i )
     {
       if( ! mProgramUniforms4f.SetUniformValue(
@@ -1269,18 +1333,27 @@ public:
 
   inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
   {
+    std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
+    AddUniformCallToTraceStack( location, params );
   }
 
   inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
   {
+    std::string params = ToString( v );
+    AddUniformCallToTraceStack( location, params );
   }
 
   inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
   {
+    std::string params = ToString( value );
+    AddUniformCallToTraceStack( location, params );
   }
 
   inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
   {
+    std::string params = ToString( value );
+    AddUniformCallToTraceStack( location, params );
+
     for( int i = 0; i < count; ++i )
     {
       if( ! mProgramUniformsMat3.SetUniformValue(
@@ -1296,6 +1369,9 @@ public:
 
   inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
   {
+    std::string params = ToString( value );
+    AddUniformCallToTraceStack( location, params );
+
     for( int i = 0; i < count; ++i )
     {
       if( ! mProgramUniformsMat4.SetUniformValue(
@@ -1789,6 +1865,31 @@ public:
   {
   }
 
+private:
+
+  inline void AddUniformCallToTraceStack( GLint location, std::string& value )
+    {
+    std::string name = "<not found>";
+    bool matched = false;
+
+    UniformIDMap& map = mUniforms[mCurrentProgram];
+    for (UniformIDMap::iterator it=map.begin(); it!=map.end(); ++it)
+    {
+      if( it->second == location )
+      {
+        name = it->first;
+        matched = true;
+        break;
+      }
+    }
+
+    if ( matched )
+    {
+      mSetUniformTrace.PushCall( name, value );
+    }
+  }
+
+
 public: // TEST FUNCTIONS
   inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
   inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
@@ -1859,6 +1960,16 @@ public: // TEST FUNCTIONS
   inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
   inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
 
+  //Methods for Scissor verification
+  inline void EnableScissorCallTrace(bool enable) { mScissorTrace.Enable(enable); }
+  inline void ResetScissorCallStack() { mScissorTrace.Reset(); }
+  inline TraceCallStack& GetScissorTrace() { return mScissorTrace; }
+
+  //Methods for Uniform function verification
+  inline void EnableSetUniformCallTrace(bool enable) { mSetUniformTrace.Enable(enable); }
+  inline void ResetSetUniformCallStack() { mSetUniformTrace.Reset(); }
+  inline TraceCallStack& GetSetUniformTrace() { return mSetUniformTrace; }
+
   template <typename T>
   inline bool GetUniformValue( const char* name, T& value ) const
   {
@@ -2072,6 +2183,7 @@ private:
 
   // Data for manipulating the IDs returned by GenTextures
   GLuint mLastAutoTextureIdUsed;
+  GLuint mNumGeneratedTextures;
   std::vector<GLuint> mNextTextureIds;
   std::vector<GLuint> mDeletedTextureIds;
   std::vector<GLuint> mBoundTextures;
@@ -2091,6 +2203,8 @@ private:
   TraceCallStack mDrawTrace;
   TraceCallStack mDepthFunctionTrace;
   TraceCallStack mStencilFunctionTrace;
+  TraceCallStack mScissorTrace;
+  TraceCallStack mSetUniformTrace;
 
   // Shaders & Uniforms
   GLuint mLastShaderIdUsed;
@@ -2178,9 +2292,6 @@ private:
   ProgramUniformValue<Matrix> mProgramUniformsMat4;
   ProgramUniformValue<Matrix3> mProgramUniformsMat3;
 
-
-
-
   inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
   {
     return mProgramUniforms1i;