Remove a few exports by getting rid of two std::vectors and two std::sets
[platform/core/uifw/dali-core.git] / dali / internal / render / gl-resources / context.h
index 671e838..e285ae6 100644 (file)
@@ -19,8 +19,9 @@
  */
 
 // INTERNAL INCLUDES
+#include <dali/integration-api/gl-defines.h>
 #include <dali/public-api/common/map-wrapper.h>
-#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/actors/renderable-actor.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/gl-abstraction.h>
@@ -57,13 +58,14 @@ class Program; // to be able to cache programs
 class Context
 {
 public:
-
   /**
    * Size of the VertexAttributeArray enables
    * GLES specification states that there's minimum of 8
    */
   static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 8;
 
+  static const unsigned int MAX_TEXTURE_UNITS = 8; // for GLES 2.0 its 8, which is more than DALi uses anyways
+
   /**
    * Creates the Dali Context object.
    * This method does not create an OpenGL context i.e. that is done from outside dali-core.
@@ -84,7 +86,7 @@ public:
   void GlContextCreated();
 
   /**
-   * Called when the GL context is about to be destroyed.
+   * Called when the GL context has been destroyed.
    */
   void GlContextDestroyed();
 
@@ -584,7 +586,7 @@ public:
    */
   void DeleteBuffers(GLsizei n, const GLuint* buffers)
   {
-    // TODO: this is to prevent mesh destructor from doing GL calls when DALi core is being deleted
+    // @todo: this is to prevent mesh destructor from doing GL calls when DALi core is being deleted
     // can be taken out once render manages either knows about meshes or gpubuffers and can tell them directly that context is lost
     if( this->IsGlContextCreated() )
     {
@@ -636,7 +638,7 @@ public:
 
     // reset the cached texture id's incase the driver re-uses them
     // when creating new textures
-    for( int i=0; i < mMaxTextureUnits; ++i )
+    for( unsigned int i=0; i < MAX_TEXTURE_UNITS; ++i )
     {
        mBound2dTextureId[ i ] = 0;
     }
@@ -1615,7 +1617,7 @@ public:
    */
   GLint CachedNumberOfProgramBinaryFormats() const
   {
-    return mProgramBinaryFormats.size();
+    return mProgramBinaryFormats.Count();
   }
 
   /**
@@ -1625,7 +1627,7 @@ public:
    */
   GLint CachedProgramBinaryFormat( const unsigned int formatIndex = 0 ) const
   {
-    DALI_ASSERT_ALWAYS( formatIndex < mProgramBinaryFormats.size() && "formatIndex out of bounds");
+    DALI_ASSERT_ALWAYS( formatIndex < mProgramBinaryFormats.Count() && "formatIndex out of bounds");
 
     return mProgramBinaryFormats[ formatIndex ];
   }
@@ -1648,6 +1650,11 @@ public:
   }
 
   /**
+   * Reset the program matrices
+   */
+  void ResetProgramMatrices();
+
+  /**
    * Get a cached program
    * @param [in] hash value
    * @return pointer to the program
@@ -1674,6 +1681,72 @@ public:
 
 #endif // DEBUG_ENABLED
 
+
+  /**
+   * 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
 
   /**
@@ -1726,7 +1799,7 @@ private: // Data
 
   // glBindTexture() state
   unsigned int mActiveTextureUnit;
-  std::vector<GLuint> mBound2dTextureId;  ///< The ID passed to glBindTexture(GL_TEXTURE_2D)
+  GLuint mBound2dTextureId[ MAX_TEXTURE_UNITS ];  ///< The ID passed to glBindTexture(GL_TEXTURE_2D)
 
   // glBlendColor() state
   bool mUsingDefaultBlendColor;
@@ -1742,10 +1815,9 @@ private: // Data
   GLenum mBlendEquationSeparateModeAlpha;  ///< Controls Alpha blend mode
 
   GLint mMaxTextureSize;      ///< return value from GetIntegerv(GL_MAX_TEXTURE_SIZE)
-  GLint mMaxTextureUnits;     ///< return value from GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS)
   Vector4 mClearColor;        ///< clear color
 
-  std::vector<GLint>  mProgramBinaryFormats; ///< array of supported program binary formats
+  Dali::Vector<GLint>  mProgramBinaryFormats; ///< array of supported program binary formats
 
   // Face culling mode
   CullFaceMode mCullFaceMode;
@@ -1759,8 +1831,10 @@ private: // Data
 
   Program* mCurrentProgram;
   typedef std::map< std::size_t, Program* > ProgramContainer;
-  ProgramContainer mProgramCache; /// program cache
-
+  ProgramContainer mProgramCache; ///< Cache of shader programs
+  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
 };
 
 } // namespace Internal