Changed ResetGLState to only set GL state which is different from default 52/51952/4
authorFerran Sole <ferran.sole@samsung.com>
Tue, 17 Nov 2015 12:07:45 +0000 (12:07 +0000)
committerFerran Sole <ferran.sole@samsung.com>
Thu, 19 Nov 2015 14:57:07 +0000 (14:57 +0000)
Change-Id: I4884e507bba2c1ee6541fa30b5d7601bfff668e4

automated-tests/src/dali-devel/utc-Dali-Context.cpp
dali/internal/render/gl-resources/context.cpp
dali/internal/render/gl-resources/context.h

index bdc5190..09cdcd9 100644 (file)
@@ -74,10 +74,6 @@ int UtcDaliContextVertexAttribStartup(void)
   application.Render();
   application.Render();
 
-  // context class should initially set the vertex attrib locations to disable
-  // Make sure it has been modified
-  DALI_TEST_CHECK(application.GetGlAbstraction().GetVertexAttribArrayChanged());
-
   // check the locations
   for (unsigned int i = 0; i < TEST_MAX_ATTRIBUTE_CACHE_SIZE; i++)
   {
index 657898a..2112488 100644 (file)
@@ -113,7 +113,7 @@ void Context::GlContextCreated()
   mGlContextCreated = true;
 
   // Set the initial GL state, and check it.
-  ResetGlState();
+  InitializeGlState();
 
 #ifdef DEBUG_ENABLED
   PrintCurrentState();
@@ -194,107 +194,42 @@ void Context::SetVertexAttributeLocation(unsigned int location, bool state)
   }
 }
 
-void Context::ResetVertexAttributeState()
+void Context::InitializeGlState()
 {
-  // reset attribute cache
-  for( unsigned int i=0; i < MAX_ATTRIBUTE_CACHE_SIZE; ++i )
-  {
-    mVertexAttributeCachedState[ i ] = false;
-    mVertexAttributeCurrentState[ i ] = false;
-
-    LOG_GL("DisableVertexAttribArray %d\n", i);
-    CHECK_GL( mGlAbstraction, mGlAbstraction.DisableVertexAttribArray( i ) );
-  }
-}
-
-void Context::ResetGlState()
-{
-  DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::ResetGlState()\n");
+  DALI_LOG_INFO(gContextLogFilter, Debug::Verbose, "Context::InitializeGlState()\n");
   DALI_ASSERT_DEBUG(mGlContextCreated);
 
   mClearColorSet = false;
-  // Render manager will call clear in next render
-
-  // Reset internal state and Synchronize it with real OpenGL context.
-  // This may seem like overkill, but the GL context is not owned by dali-core,
-  // and no assumptions should be made about the initial state.
   mColorMask = true;
-  mGlAbstraction.ColorMask( true, true, true, true );
-
   mStencilMask = 0xFF;
-  mGlAbstraction.StencilMask( 0xFF );
-
   mBlendEnabled = false;
-  mGlAbstraction.Disable(GL_BLEND);
-
   mDepthBufferEnabled = false;
-  mGlAbstraction.Disable(GL_DEPTH_TEST);
-
   mDepthMaskEnabled = false;
-  mGlAbstraction.DepthMask(GL_FALSE);
-
-  mDitherEnabled = false; // This the only GL capability which defaults to true
-  mGlAbstraction.Disable(GL_DITHER);
-
   mPolygonOffsetFillEnabled = false;
-  mGlAbstraction.Disable(GL_POLYGON_OFFSET_FILL);
-
   mSampleAlphaToCoverageEnabled = false;
-  mGlAbstraction.Disable(GL_SAMPLE_ALPHA_TO_COVERAGE);
-
   mSampleCoverageEnabled = false;
-  mGlAbstraction.Disable(GL_SAMPLE_COVERAGE);
-
   mScissorTestEnabled = false;
-  mGlAbstraction.Disable(GL_SCISSOR_TEST);
-
   mStencilBufferEnabled = false;
-  mGlAbstraction.Disable(GL_STENCIL_TEST);
+  mDitherEnabled = false; // This and GL_MULTISAMPLE are the only GL capability which defaults to true
+  mGlAbstraction.Disable(GL_DITHER);
 
   mBoundArrayBufferId = 0;
-  LOG_GL("BindBuffer GL_ARRAY_BUFFER 0\n");
-  mGlAbstraction.BindBuffer(GL_ARRAY_BUFFER, mBoundArrayBufferId);
-
   mBoundElementArrayBufferId = 0;
-  LOG_GL("BindBuffer GL_ELEMENT_ARRAY_BUFFER 0\n");
-  mGlAbstraction.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBoundElementArrayBufferId);
-
-#ifndef EMSCRIPTEN // not in WebGL
   mBoundTransformFeedbackBufferId = 0;
-  LOG_GL("BindBuffer GL_TRANSFORM_FEEDBACK_BUFFER 0\n");
-  mGlAbstraction.BindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, mBoundTransformFeedbackBufferId);
-#endif
-
-  mActiveTextureUnit = TEXTURE_UNIT_LAST;
+  mActiveTextureUnit = TEXTURE_UNIT_IMAGE;
 
-  mUsingDefaultBlendColor = true;
-  mGlAbstraction.BlendColor( 0.0f, 0.0f, 0.0f, 0.0f );
+  mUsingDefaultBlendColor = true; //Default blend color is (0,0,0,0)
 
   mBlendFuncSeparateSrcRGB = GL_ONE;
   mBlendFuncSeparateDstRGB = GL_ZERO;
   mBlendFuncSeparateSrcAlpha = GL_ONE;
   mBlendFuncSeparateDstAlpha = GL_ZERO;
-  mGlAbstraction.BlendFuncSeparate( mBlendFuncSeparateSrcRGB, mBlendFuncSeparateDstRGB,
-                                    mBlendFuncSeparateSrcAlpha, mBlendFuncSeparateDstAlpha );
 
   // initial state is GL_FUNC_ADD for both RGB and Alpha blend modes
   mBlendEquationSeparateModeRGB = GL_FUNC_ADD;
   mBlendEquationSeparateModeAlpha = GL_FUNC_ADD;
-  mGlAbstraction.BlendEquationSeparate( mBlendEquationSeparateModeRGB, mBlendEquationSeparateModeAlpha);
-
-  mCullFaceMode = Dali::Material::NONE;
-  mGlAbstraction.Disable(GL_CULL_FACE);
-  mGlAbstraction.FrontFace(GL_CCW);
-  mGlAbstraction.CullFace(GL_BACK);
 
-  // rebind texture units to 0
-  for( unsigned int i=0; i < MAX_TEXTURE_UNITS; ++i )
-  {
-    mBound2dTextureId[ i ] = 0;
-    // set active texture
-    mGlAbstraction.ActiveTexture( GL_TEXTURE0 + i );
-    mGlAbstraction.BindTexture(GL_TEXTURE_2D, mBound2dTextureId[ i ] );
-  }
+  mCullFaceMode = Dali::Material::NONE; //By default cullface is disabled, front face is set to CCW and cull face is set to back
 
   // get maximum texture size
   mGlAbstraction.GetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
@@ -302,8 +237,6 @@ void Context::ResetGlState()
   // reset viewport, this will be set to something useful when rendering
   mViewPort.x = mViewPort.y = mViewPort.width = mViewPort.height = 0;
 
-  ResetVertexAttributeState();
-
   mFrameBufferStateCache.Reset();
 }
 
index 996335f..e542f33 100644 (file)
@@ -1730,11 +1730,6 @@ private: // Implementation
   void FlushVertexAttributeLocations();
 
   /**
-   * Reset the cached internal vertex attribute state
-   */
-  void ResetVertexAttributeState();
-
-  /**
    * Either enables or disables a vertex attribute location in the cache
    * The cahnges won't take affect until FlushVertexAttributeLocations is called
    * @param location attribute location
@@ -1745,7 +1740,7 @@ private: // Implementation
   /**
    * Sets the initial GL state.
    */
-  void ResetGlState();
+  void InitializeGlState();
 
 private: // Data