Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / internal / update / rendering / scene-graph-texture-set.h
index 2d0da55..6a37f2b 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_TEXTURE_SET_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.
  */
 
 // INTERNAL INCLUDES
-#include <dali/devel-api/rendering/texture-set.h>
+#include <dali/public-api/rendering/texture-set.h>
 #include <dali/internal/common/buffer-index.h>
 #include <dali/internal/common/message.h>
 #include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
 
 namespace Dali
 {
 namespace Internal
 {
-class ResourceManager;
 
 namespace Render
 {
-class Sampler;
+struct Sampler;
+class Texture;
 }
 namespace SceneGraph
 {
 class Renderer;
-class Sampler;
 
 class TextureSet
 {
@@ -49,9 +47,9 @@ public:
   static TextureSet* New();
 
   /**
-   * Destructor
+   * Destructor. Not virtual as not a base class and not inheriting anything
    */
-  virtual ~TextureSet();
+  ~TextureSet();
 
   /**
    * Overriden delete operator
@@ -60,24 +58,18 @@ public:
   void operator delete( void* ptr );
 
   /**
-   * Prepare the texture set, check texture loading status, opacity etc
-   * @param resourceManager for checking texture details and loading status
-   */
-  void Prepare( const ResourceManager& resourceManager );
-
-  /**
-   * Set the resource id for the texture at position "index"
+   * Set the sampler to be used by the texture at position "index"
    * @param[in] index The index of the texture
-   * @param[in] imageId the resource id of the imag
+   * @param[in] sampler The sampler to be used by the texture
    */
-  void SetImage( size_t index,  ResourceId imageId );
+  void SetSampler( uint32_t index, Render::Sampler* sampler );
 
   /**
-   * Set the sampler to be used by the texture at position "index"
+   * Set the texture at position "index"
    * @param[in] index The index of the texture
-   * @param[in] sampler The sampler to be used by the texture
+   * @param[in] texture The texture
    */
-  void SetSampler( size_t index, Render::Sampler* sampler );
+  void SetTexture( uint32_t index, Render::Texture* texture );
 
   /**
    * Return whether any texture in the texture set has an alpha channel
@@ -86,16 +78,6 @@ public:
   bool HasAlpha() const;
 
   /**
-   * Get the resource status
-   * Note, we need two values as it's possible that some resource failed to load
-   * in which case resourcesReady is false (the texture set is not good to be used for rendering)
-   * but finishedResourceAcquisition if true as there is no more loading going on
-   * @param[out] resourcesReady if the texture set is ready to be used for rendering
-   * @param[out] finishedResourceAcquisition if
-   */
-  void GetResourcesStatus( bool& resourcesReady, bool& finishedResourceAcquisition );
-
-  /**
    * Adds a renderer to the Renderers list of the texture set.
    * Renderers using the TextureSet get a notification when the texture set changes
    *
@@ -111,35 +93,34 @@ public:
   void RemoveObserver( Renderer* renderer );
 
   /**
-   * Get the ResourceId of a texture in the TextureSet
+   * Get the sampler of a texture in the TextureSet
    * @param[in] index The index of the texture in the textures array
-   * @return the ResourceId
+   * @return the sampler used by the texture
    */
-  ResourceId GetTextureId( size_t index )
+  Render::Sampler* GetTextureSampler( uint32_t index )
   {
-    return mTextureId[index];
+    return mSamplers[index];
   }
 
   /**
-   * Get the sampler of a texture in the TextureSet
-   * @param[in] index The index of the texture in the textures array
-   * @return the sampler used by the texture
+   * Get the number of Textures in the texture set
+   * @return The number of Textures
    */
-  Render::Sampler* GetTextureSampler( size_t index )
+  uint32_t GetTextureCount()
   {
-    return mSamplers[index];
+    return static_cast<uint32_t>( mTextures.Size() );
   }
 
   /**
-   * Get the number of textures in the texture set
-   * @return The number of textures
+   * Get the pointer to  a Texture in the TextureSet
+   * @param[in] index The index of the texture in the textures array
+   * @return the pointer to the Texture in that position
    */
-  size_t GetTextureCount()
+  Render::Texture* GetTexture( uint32_t index )
   {
-    return mTextureId.Size();
+    return mTextures[index];
   }
 
-
 private:
 
   /**
@@ -155,32 +136,29 @@ private:
 
 private: // Data
 
-  Vector< Render::Sampler* >      mSamplers;                    ///< List of samplers used by each texture. Not owned
-  Vector< ResourceId >            mTextureId;                   ///< List of texture ids
-  Vector<Renderer*>               mRenderers;                   ///< List of renderers using the TextureSet
-  bool                            mResourcesReady;              ///< if the textures are ready to be used for rendering
-  bool                            mFinishedResourceAcquisition; ///< if resource loading is completed
-  bool                            mChanged;                     ///< if the texture set has changed since the last frame
-  bool                            mHasAlpha;                    ///< if any of the textures has an alpha channel
+  Vector< Render::Sampler* > mSamplers;                    ///< List of samplers used by each texture. Not owned
+  Vector< Render::Texture* > mTextures;                    ///< List of Textures. Not owned
+  Vector<Renderer*>          mRenderers;                   ///< List of renderers using the TextureSet
+  bool                       mHasAlpha;                    ///< if any of the textures has an alpha channel
 };
 
-inline void SetImageMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, size_t index, ResourceId resourceId )
+inline void SetTextureMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Texture* texture )
 {
-  typedef MessageValue2< TextureSet, size_t, ResourceId > LocalType;
+  using LocalType = MessageValue2<TextureSet, uint32_t, Render::Texture*>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+  uint32_t* 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( &textureSet, &TextureSet::SetImage, index, resourceId );
+  new (slot) LocalType( &textureSet, &TextureSet::SetTexture, index, texture );
 }
 
-inline void SetSamplerMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, size_t index, Render::Sampler* sampler )
+inline void SetSamplerMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, uint32_t index, Render::Sampler* sampler )
 {
-  typedef MessageValue2< TextureSet, size_t, Render::Sampler* > LocalType;
+  using LocalType = MessageValue2<TextureSet, uint32_t, Render::Sampler*>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+  uint32_t* 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( &textureSet, &TextureSet::SetSampler, index, sampler );