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.cpp
index 6dc4384..d943940 100644 (file)
@@ -29,8 +29,6 @@
 #include <dali/internal/render/common/render-manager.h>
 #include <dali/integration-api/debug.h>
 
-using namespace std;
-
 namespace Dali
 {
 
@@ -72,6 +70,7 @@ const unsigned int UNINITIALIZED_TEXTURE_UNIT = std::numeric_limits<unsigned int
 
 #ifdef DEBUG_ENABLED
 Debug::Filter* Context::gGlLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_CONTEXT");
+Debug::Filter* gContextLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_CONTEXT_META");
 #endif
 
 Context::Context(Integration::GlAbstraction& glAbstraction)
@@ -101,11 +100,13 @@ Context::Context(Integration::GlAbstraction& glAbstraction)
   mBlendEquationSeparateModeRGB( GL_FUNC_ADD ),
   mBlendEquationSeparateModeAlpha( GL_FUNC_ADD ),
   mMaxTextureSize(0),
-  mMaxTextureUnits(0),
   mClearColor(Color::WHITE),    // initial color, never used until it's been set by the user
   mCullFaceMode(CullNone),
   mViewPort( 0, 0, 0, 0 ),
-  mCurrentProgram( NULL )
+  mCurrentProgram( NULL ),
+  mFrameCount( 0 ),
+  mCulledCount( 0 ),
+  mRendererCount( 0 )
 {
 }
 
@@ -118,6 +119,8 @@ Context::~Context()
 
 void Context::GlContextCreated()
 {
+  DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::GlContextCreated()\n");
+
   DALI_ASSERT_DEBUG(!mGlContextCreated);
 
   mGlContextCreated = true;
@@ -125,15 +128,14 @@ void Context::GlContextCreated()
   // Set the initial GL state, and check it.
   ResetGlState();
 
-  const ProgramContainer::iterator endp = mProgramCache.end();
-  for ( ProgramContainer::iterator itp = mProgramCache.begin(); itp != endp; ++itp )
-  {
-    (*itp).second->GlContextCreated();
-  }
+  // Programs now load on demand
 }
 
 void Context::GlContextDestroyed()
 {
+  DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::GlContextDestroyed()\n");
+  SetCurrentProgram( NULL );
+  // Inform programs they are no longer valid
   const ProgramContainer::iterator endp = mProgramCache.end();
   for ( ProgramContainer::iterator itp = mProgramCache.begin(); itp != endp; ++itp )
   {
@@ -155,6 +157,16 @@ const char* Context::ErrorToString( GLenum errorCode )
   return "Unknown Open GLES error";
 }
 
+void Context::ResetProgramMatrices()
+{
+  const ProgramContainer::iterator endp = mProgramCache.end();
+  for ( ProgramContainer::iterator itp = mProgramCache.begin(); itp != endp; ++itp )
+  {
+    (*itp).second->SetProjectionMatrix( NULL );
+    (*itp).second->SetViewMatrix( NULL );
+  }
+}
+
 Program* Context::GetCachedProgram( std::size_t hash ) const
 {
   std::map< std::size_t, Program* >::const_iterator iter = mProgramCache.find(hash);
@@ -242,6 +254,7 @@ void Context::ResetVertexAttributeState()
 
 void Context::ResetGlState()
 {
+  DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::ResetGlState()\n");
   DALI_ASSERT_DEBUG(mGlContextCreated);
 
   mClearColorSet = false;
@@ -319,12 +332,8 @@ void Context::ResetGlState()
   mGlAbstraction.FrontFace(GL_CCW);
   mGlAbstraction.CullFace(GL_BACK);
 
-  // get max texture units
-  mGlAbstraction.GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mMaxTextureUnits);
-  DALI_ASSERT_DEBUG(mMaxTextureUnits > 7);  // according to GLES 2.0 specification
-  mBound2dTextureId.reserve(mMaxTextureUnits);
   // rebind texture units
-  for( int i=0; i < mMaxTextureUnits; ++i )
+  for( unsigned int i=0; i < MAX_TEXTURE_UNITS; ++i )
   {
     mBound2dTextureId[ i ] = 0;
     // set active texture
@@ -340,7 +349,7 @@ void Context::ResetGlState()
   mGlAbstraction.GetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS_OES, &numProgramBinaryFormats);
   if( GL_NO_ERROR == mGlAbstraction.GetError() && 0 != numProgramBinaryFormats )
   {
-    mProgramBinaryFormats.resize(numProgramBinaryFormats);
+    mProgramBinaryFormats.Resize(numProgramBinaryFormats);
     mGlAbstraction.GetIntegerv(GL_PROGRAM_BINARY_FORMATS_OES, &mProgramBinaryFormats[0]);
   }