Remove AffectsOpacity as it slows down 99.9% of use-cases and isnot even needed for... 39/50739/3
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Fri, 30 Oct 2015 11:51:17 +0000 (11:51 +0000)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Fri, 30 Oct 2015 13:17:01 +0000 (13:17 +0000)
Change-Id: I0b82e83fbbaed86c800f75876a0967a712bd9e82

automated-tests/src/dali-devel/utc-Dali-Material.cpp
dali/devel-api/rendering/material.cpp
dali/devel-api/rendering/material.h
dali/internal/event/rendering/material-impl.cpp
dali/internal/event/rendering/material-impl.h
dali/internal/update/rendering/scene-graph-material.cpp
dali/internal/update/rendering/scene-graph-material.h

index ffb248f..3c7f581 100644 (file)
@@ -1100,50 +1100,6 @@ int UtcDaliMaterialSetTextureUniformName02(void)
   END_TEST;
 }
 
-int UtcDaliMaterialSetTextureAffectsTransparency(void)
-{
-  TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-
-  Material material = CreateMaterial();
-  material.AddTexture( image, "sTexture" );
-
-  Geometry geometry = CreateQuadGeometry();
-  Renderer renderer = Renderer::New( geometry, material );
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-  Stage::GetCurrent().Add( actor );
-
-  TestGlAbstraction& gl = application.GetGlAbstraction();
-
-  // Test SetAffectsTransparency( false )
-  material.SetTextureAffectsTransparency( 0, false );
-
-  gl.EnableEnableDisableCallTrace(true);
-  application.SendNotification();
-  application.Render();
-
-  TraceCallStack& glEnableStack = gl.GetEnableDisableTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
-
-  // Test SetAffectsTransparency( true )
-  material.SetTextureAffectsTransparency( 0, true );
-
-  glEnableStack.Reset();
-  gl.EnableEnableDisableCallTrace(true);
-  application.SendNotification();
-  application.Render();
-
-  DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
-
-  END_TEST;
-}
-
 int UtcDaliMaterialAddTexture01(void)
 {
   TestApplication application;
index f02d9ad..c284898 100644 (file)
@@ -128,11 +128,6 @@ int Material::GetTextureIndex( const std::string& uniformName )
   return GetImplementation(*this).GetTextureIndex( uniformName );
 }
 
-void Material::SetTextureAffectsTransparency( size_t index, bool affectsTransparency )
-{
-  GetImplementation(*this).SetTextureAffectsTransparency( index, affectsTransparency );
-}
-
 std::size_t Material::GetNumberOfTextures() const
 {
   return GetImplementation(*this).GetNumberOfTextures();
index acc98ca..c0b8177 100644 (file)
@@ -170,14 +170,6 @@ public:
    */
   void SetTextureUniformName( size_t index, const std::string& uniformName );
 
-  /**
-   * @brief Establish if a given texture will affect the transparency of the material ( true by default )
-   *
-   * @param[in] index The index of the texture in the array of textures
-   * @param[in] affectsTransparency True if the texture affects transparency, false otherwise
-   */
-  void SetTextureAffectsTransparency( size_t index, bool affectsTransparency );
-
   /*
    * @brief Retrive the index of a texture given its uniform name
    *
index 55d3905..756450c 100644 (file)
@@ -166,14 +166,6 @@ int Material::GetTextureIndex( const std::string& uniformName )
   return -1;
 }
 
-void Material::SetTextureAffectsTransparency( size_t index, bool affectsTransparency )
-{
-  if( index < GetNumberOfTextures() )
-  {
-    SceneGraph::SetTextureAffectsTransparencyMessage( GetEventThreadServices(), *mSceneObject, index,  affectsTransparency );
-  }
-}
-
 size_t Material::GetNumberOfTextures() const
 {
   return mTextures.size();
index 666fc3b..b5deaad 100644 (file)
@@ -100,11 +100,6 @@ public:
   int GetTextureIndex( const std::string& uniformName );
 
   /**
-   * @copydoc Dali::Material::SetTextureAffectsTransparency()
-   */
-  void SetTextureAffectsTransparency( size_t index, bool affectsTransparency );
-
-  /**
    * @copydoc Dali::Material::GetNumberOfTextures()
    */
   size_t GetNumberOfTextures() const;
@@ -323,7 +318,7 @@ private: // Data
   Dali::Material::FaceCullingMode mFaceCullingMode; ///< Local copy of face culling mode
   BlendingMode::Type mBlendingMode;                 ///< Local copy of blending mode
   BlendingOptions mBlendingOptions;                 ///< Local copy of blending options bitmask
-  Vector4* mBlendColor;                             ///< Local copy of blend color, pointer only as its reraly used
+  Vector4* mBlendColor;                             ///< Local copy of blend color, pointer only as its raraly used
   bool mOnStage;
 
 };
index 492e790..a67de19 100644 (file)
@@ -38,7 +38,6 @@ Material::Material()
   mTextureId(),
   mUniformName(),
   mIsFullyOpaque(),
-  mAffectsTransparency(),
   mConnectionObservers(),
   mFaceCullingMode( Dali::Material::NONE ),
   mBlendingMode( Dali::BlendingMode::AUTO ),
@@ -83,8 +82,6 @@ void Material::PrepareRender( BufferIndex bufferIndex )
 {
   mBlendPolicy = OPAQUE;
 
-  // @todo MESH_REWORK Add dirty flags to reduce processing.
-
   switch( mBlendingMode )
   {
     case BlendingMode::OFF:
@@ -101,7 +98,7 @@ void Material::PrepareRender( BufferIndex bufferIndex )
     {
       bool opaque = true;
 
-      //  @todo: MESH_REWORK - Change hints for new SceneGraphShader:
+      // @todo: Change hints for new SceneGraphShader:
       // If shader hint OUTPUT_IS_OPAQUE is enabled, set policy to ALWAYS_OPAQUE
       // If shader hint OUTPUT_IS_TRANSPARENT is enabled, set policy to ALWAYS_TRANSPARENT
       // else test remainder, and set policy to either ALWAYS_TRANSPARENT or USE_ACTOR_COLOR
@@ -113,21 +110,14 @@ void Material::PrepareRender( BufferIndex bufferIndex )
 
       if( opaque )
       {
-        unsigned int opaqueCount=0;
-        unsigned int affectingCount=0;
         size_t textureCount( GetTextureCount() );
         for( unsigned int i(0); i<textureCount; ++i )
         {
-          if( mAffectsTransparency[i] )
+          if( !mIsFullyOpaque[i] )
           {
-            ++affectingCount;
-            if( mIsFullyOpaque[i] )
-            {
-              ++opaqueCount;
-            }
+            opaque = false;
           }
         }
-        opaque = (opaqueCount == affectingCount);
       }
 
       mBlendPolicy = opaque ? Material::USE_ACTOR_COLOR : Material::TRANSPARENT;
@@ -173,7 +163,6 @@ void Material::AddTexture( const std::string& name, ResourceId id, Render::Sampl
   mUniformName.push_back( name );
   mSamplers.PushBack( sampler );
   mIsFullyOpaque.PushBack( false );
-  mAffectsTransparency.PushBack( true );
 
   mConnectionObservers.ConnectionsChanged(*this);
 }
@@ -184,7 +173,6 @@ void Material::RemoveTexture( size_t index )
   mUniformName.erase( mUniformName.begin() + index );
   mSamplers.Erase( mSamplers.Begin()+index );
   mIsFullyOpaque.Erase( mIsFullyOpaque.Begin()+index );
-  mAffectsTransparency.Erase( mAffectsTransparency.Begin()+index );
   mConnectionObservers.ConnectionsChanged( *this );
 }
 
index eed1cb3..16a769d 100644 (file)
@@ -155,17 +155,6 @@ public:
    */
   void SetTextureUniformName( size_t index, const std::string& uniformName );
 
-  /**
-   * Establish if a given texture will affect the transparency of the object ( true by default )
-   * @param[in] index The index of the texture in the array of textures
-   * @param[in] affectsTransparency True if the texture affects transparency, false otherwise
-   */
-  void SetAffectsTransparency( size_t index, bool affectsTransparency )
-  {
-    mAffectsTransparency[index] = affectsTransparency;
-    mConnectionObservers.ConnectionsChanged(*this);
-  }
-
 public: // Implementation of MaterialDataProvider
 
   /**
@@ -275,18 +264,17 @@ public: // PropertyOwner implementation
 
 private: // Data
 
-  Shader* mShader;
-  Vector4* mBlendColor; // not double buffered as its not animateable and not frequently changed
-  Vector< Render::Sampler* > mSamplers; // Not owned
-  Vector< ResourceId >  mTextureId;
-  std::vector< std::string > mUniformName;
-  Vector< bool >        mIsFullyOpaque;
-  Vector< bool >        mAffectsTransparency;
-  ConnectionChangePropagator mConnectionObservers;
+  Shader*                     mShader;
+  Vector4*                    mBlendColor; // not double buffered as its not animateable and not frequently changed
+  Vector< Render::Sampler* >  mSamplers; // Not owned
+  Vector< ResourceId >        mTextureId;
+  std::vector< std::string >  mUniformName;
+  Vector< bool >              mIsFullyOpaque;
+  ConnectionChangePropagator  mConnectionObservers;
   Dali::Material::FaceCullingMode  mFaceCullingMode; // not double buffered as its not animateable and not frequently changed
-  BlendingMode::Type  mBlendingMode; // not double buffered as its not animateable and not frequently changed
-  BlendingOptions  mBlendingOptions; // not double buffered as its not animateable and not frequently changed
-  BlendPolicy mBlendPolicy; ///< The blend policy as determined by PrepareRender
+  BlendingMode::Type          mBlendingMode; // not double buffered as its not animateable and not frequently changed
+  BlendingOptions             mBlendingOptions; // not double buffered as its not animateable and not frequently changed
+  BlendPolicy                 mBlendPolicy; ///< The blend policy as determined by PrepareRender
 
 };
 
@@ -396,17 +384,6 @@ inline void SetTextureUniformNameMessage( EventThreadServices& eventThreadServic
   new (slot) LocalType( &material, &Material::SetTextureUniformName, index, uniformName );
 }
 
-inline void SetTextureAffectsTransparencyMessage( EventThreadServices& eventThreadServices, const Material& material, size_t index, bool affectsTransparency )
-{
-  typedef MessageValue2< Material, size_t, bool > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &material, &Material::SetAffectsTransparency, index, affectsTransparency );
-}
-
 } // namespace SceneGraph
 
 } // namespace Internal