Bitmap core patch 2 of 4 - Replace all uses of the Bitmap class with new simpler...
[platform/core/uifw/dali-core.git] / dali / integration-api / resource-types.h
index f8f0d65..847322d 100644 (file)
@@ -34,21 +34,29 @@ namespace Integration
 // Resource Types
 
 /**
- * Extendable set of resource types
+ * Extendable set of resource type identifiers used by ResourceType subclasses.
  */
 enum ResourceTypeId
 {
-  ResourceBitmap,
+  ResourceImageData,   ///< A buffer of image data with dimension and type metadata.
   ResourceNativeImage,
   ResourceTargetImage,
   ResourceShader,
   ResourceModel,
   ResourceMesh,
-  ResourceText
+  ResourceText,
+  ResourceTexture,     ///< Used to pass through a request for a GLES texture to be allocated on the render thread.
+  ResourceAppBitmap    ///< Used in Core to tag Bitmaps that belong to BitmapImages.
 };
 
 /**
- * The abstract base class for resource types.
+ * @brief A ResourceType-derived class is just a data bucket.
+ *
+ * Each ResourceType derived class carries a bundle of data specific to one or
+ * more resource request types that are unambiguously specified by the
+ * <code>id</code> member of this base class.
+ * Dispatch on that ResourceTypeId to know exactly which kind of resource
+ * request is associated with a particular instance.
  */
 struct DALI_IMPORT_API ResourceType
 {
@@ -59,9 +67,6 @@ struct DALI_IMPORT_API ResourceType
   ResourceType(ResourceTypeId typeId)
   : id(typeId) {}
 
-  /**
-   * Destructor.
-   */
   virtual ~ResourceType() {}
 
   /**
@@ -75,51 +80,44 @@ struct DALI_IMPORT_API ResourceType
 private:
 
   // Undefined copy constructor.
-  ResourceType(const ResourceType& typePath);
+  ResourceType( const ResourceType& type );
 
   // Undefined assignment operator.
-  ResourceType& operator=(const ResourceType& rhs);
+  ResourceType& operator=( const ResourceType& rhs );
 };
 
 /**
- * BitmapResourceType describes a bitmap resource, which can be requested
- * from ResourceLoader::LoadResource() or AllocateBitmapImage.
+ * ImageResourceType can be used to identify a a request as pertaining
+ * to images and carries some image attributes to modify the request.
+ * @todo Replace all uses of other image-related ResourceTypes with
+ * this one as they are duplicates.
  */
-struct DALI_IMPORT_API BitmapResourceType : public ResourceType
+struct DALI_IMPORT_API ImageResourceType : public ResourceType
 {
   /**
    * Constructor.
+   * @param[in] typeId  One of the image ResourceTypeIds.
    * @param[in] attribs parameters for image loading request
    */
-  BitmapResourceType(const ImageAttributes& attribs)
-  : ResourceType(ResourceBitmap),
-    imageAttributes(attribs) {}
-
-  /**
-   * Destructor.
-   */
-  virtual ~BitmapResourceType() {}
+  ImageResourceType(const ResourceTypeId typeId, const ImageAttributes& attribs)
+  : ResourceType(typeId),
+    imageAttributes(attribs)
+  {
+    DALI_ASSERT_DEBUG( typeId == ResourceTexture || typeId == ResourceImageData || typeId == ResourceNativeImage || typeId == ResourceTargetImage || typeId == ResourceAppBitmap );
+  }
 
   /**
    * @copydoc ResourceType::Clone
    */
   virtual ResourceType* Clone() const
   {
-    return new BitmapResourceType(imageAttributes);
+    return new ImageResourceType( id, imageAttributes );
   }
 
   /**
    * Attributes are copied from the request.
    */
   ImageAttributes imageAttributes;
-
-private:
-
-  // Undefined copy constructor.
-  BitmapResourceType(const BitmapResourceType& typePath);
-
-  // Undefined assignment operator.
-  BitmapResourceType& operator=(const BitmapResourceType& rhs);
 };
 
 /**
@@ -130,7 +128,7 @@ private:
 struct DALI_IMPORT_API NativeImageResourceType : public ResourceType
 {
   /**
-   * Constructor.
+   * Default constructor initialises the base class with the correct ResourceTypeId.
    */
   NativeImageResourceType()
   : ResourceType(ResourceNativeImage) {}
@@ -143,11 +141,6 @@ struct DALI_IMPORT_API NativeImageResourceType : public ResourceType
   : ResourceType(ResourceNativeImage),
     imageAttributes(attribs) {}
 
-  /**
-   * Destructor.
-   */
-  virtual ~NativeImageResourceType() {}
-
  /**
   * @copydoc ResourceType::Clone
   */
@@ -160,14 +153,6 @@ struct DALI_IMPORT_API NativeImageResourceType : public ResourceType
    * Attributes are copied from the request (if supplied).
    */
   ImageAttributes imageAttributes;
-
-private:
-
-  // Undefined copy constructor.
-  NativeImageResourceType(const NativeImageResourceType& typePath);
-
-  // Undefined assignment operator.
-  NativeImageResourceType& operator=(const NativeImageResourceType& rhs);
 };
 
 /**
@@ -177,7 +162,7 @@ private:
 struct DALI_IMPORT_API RenderTargetResourceType : public ResourceType
 {
   /**
-   * Constructor.
+   * Default constructor initialises the base class with the correct ResourceTypeId.
    */
   RenderTargetResourceType()
   : ResourceType(ResourceTargetImage) {}
@@ -191,11 +176,6 @@ struct DALI_IMPORT_API RenderTargetResourceType : public ResourceType
     imageAttributes(attribs) {}
 
   /**
-   * Destructor.
-   */
-  virtual ~RenderTargetResourceType() {}
-
-  /**
    * @copydoc ResourceType::Clone
    */
   virtual ResourceType* Clone() const
@@ -207,14 +187,6 @@ struct DALI_IMPORT_API RenderTargetResourceType : public ResourceType
    * Attributes are copied from the request.
    */
   ImageAttributes imageAttributes;
-
-private:
-
-  // Undefined copy constructor.
-  RenderTargetResourceType(const RenderTargetResourceType& typePath);
-
-  // Undefined assignment operator.
-  RenderTargetResourceType& operator=(const RenderTargetResourceType& rhs);
 };
 
 /**
@@ -223,9 +195,6 @@ private:
  */
 struct DALI_IMPORT_API ShaderResourceType : public ResourceType
 {
-  /**
-   * Constructor.
-   */
   ShaderResourceType(size_t shaderHash, const std::string& vertexSource, const std::string& fragmentSource)
   : ResourceType(ResourceShader),
     hash(shaderHash),
@@ -235,13 +204,6 @@ struct DALI_IMPORT_API ShaderResourceType : public ResourceType
   }
 
   /**
-   * Destructor.
-   */
-  virtual ~ShaderResourceType()
-  {
-  }
-
-  /**
    * @copydoc ResourceType::Clone
    */
   virtual ResourceType* Clone() const
@@ -253,14 +215,6 @@ public: // Attributes
   size_t            hash;              ///< Hash of the vertex/fragment sources
   const std::string vertexShader;      ///< source code for vertex program
   const std::string fragmentShader;    ///< source code for fragment program
-
-private:
-
-  // Undefined copy constructor.
-  ShaderResourceType(const ShaderResourceType& typePath);
-
-  // Undefined assignment operator.
-  ShaderResourceType& operator=(const ShaderResourceType& rhs);
 };
 
 /**
@@ -298,10 +252,10 @@ struct DALI_IMPORT_API TextResourceType : public ResourceType
      * on the 32 bit words that follow so rather than using the minimum number of
      * bits for each, we give "loaded" a whole 8 bits and push it to a byte-aligned
      * address to make access possible via a plain byte load instead of a load,
-     * mask, shift sequence. The naive bitwidths before this modification are as follows:
+     * mask, shift sequence. The naive bitwidths before this modification are as follows:<code>
      *    character:21;
      *    quality:1;
-     *    loaded:1;
+     *    loaded:1;</code>
      *  @{
      */
     uint32_t character:21;       ///< character code (UTF-32), max value of 0x10ffff (21 bits)
@@ -355,13 +309,6 @@ struct DALI_IMPORT_API TextResourceType : public ResourceType
   }
 
   /**
-   * virtual destructor
-   */
-  virtual ~TextResourceType()
-  {
-  }
-
-  /**
    * @copydoc ResourceType::Clone
    */
   virtual ResourceType* Clone() const
@@ -392,14 +339,6 @@ struct DALI_IMPORT_API TextResourceType : public ResourceType
   Vector2 mMaxGlyphSize;  ///< Max glyph size for font
 
   GlyphCacheMode mCache; ///< Whether text glyphs should be cached.
-
-private:
-
-  // Undefined copy constructor.
-  TextResourceType(const TextResourceType& typePath);
-
-  // Undefined copy constructor.
-  TextResourceType& operator=(const TextResourceType& rhs);
 };
 
 /**
@@ -409,7 +348,7 @@ private:
 struct DALI_IMPORT_API ModelResourceType : public ResourceType
 {
   /**
-   * Constructor.
+   * Default constructor initialises the base class with the correct ResourceTypeId.
    */
   ModelResourceType()
     : ResourceType(ResourceModel)
@@ -417,27 +356,12 @@ struct DALI_IMPORT_API ModelResourceType : public ResourceType
   }
 
   /**
-   * Destructor.
-   */
-  virtual ~ModelResourceType()
-  {
-  }
-
-  /**
    * @copydoc ResourceType::Clone
    */
   virtual ResourceType* Clone() const
   {
     return new ModelResourceType();
   }
-
-private:
-
-  // Undefined copy constructor.
-  ModelResourceType(const ModelResourceType& typePath);
-
-  // Undefined assignment operator.
-  ModelResourceType& operator=(const ModelResourceType& rhs);
 };
 
 
@@ -448,31 +372,18 @@ private:
 struct DALI_IMPORT_API MeshResourceType : public ResourceType
 {
   /**
-   * Constructor.
+   * Default constructor initialises the base class with the correct ResourceTypeId.
    */
   MeshResourceType()
   : ResourceType(ResourceMesh) {}
 
   /**
-   * Destructor.
-   */
-  virtual ~MeshResourceType() {}
-
-  /**
    * @copydoc ResourceType::Clone
    */
   virtual ResourceType* Clone() const
   {
     return new MeshResourceType();
   }
-
-private:
-
-  // Undefined copy constructor.
-  MeshResourceType(const MeshResourceType& typePath);
-
-  // Undefined assignment operator.
-  MeshResourceType& operator=(const MeshResourceType& rhs);
 };
 
 inline bool operator==(const TextResourceType::GlyphPosition& lhs, const TextResourceType::GlyphPosition& rhs)