Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / texture-impl.h
index 852e952..fb8f1c3 100644 (file)
 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/images/pixel.h>
-#include <dali/devel-api/rendering/texture.h> // Dali::Internal::Render::Texture
+#include <dali/public-api/images/image-operations.h> // Dali::ImageDimensions
+#include <dali/public-api/rendering/texture.h> // Dali::Internal::Render::Texture
 #include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/event/images/pixel-data-impl.h>
 
 namespace Dali
 {
@@ -32,13 +34,13 @@ namespace Internal
 {
 namespace Render
 {
-class NewTexture;
+class Texture;
 }
 
-class NewTexture;
-typedef IntrusivePtr<NewTexture> NewTexturePtr;
+class Texture;
+using TexturePtr = IntrusivePtr<Texture>;
 
-class NewTexture : public BaseObject
+class Texture : public BaseObject
 {
 public:
 
@@ -47,12 +49,12 @@ public:
    */
   struct UploadParams
   {
-    unsigned int layer;    ///< Specifies the layer of a cube map or array texture
-    unsigned int mipmap;   ///< Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
-    unsigned int xOffset;  ///< Specifies a texel offset in the x direction within the texture array.
-    unsigned int yOffset;  ///< Specifies a texel offset in the y direction within the texture array.
-    unsigned int width;    ///< Specifies the width of the texture subimage
-    unsigned int height;   ///< Specifies the height of the texture subimage.
+    uint16_t layer;    ///< Specifies the layer of a cube map or array texture
+    uint16_t mipmap;   ///< Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
+    uint16_t xOffset;  ///< Specifies a texel offset in the x direction within the texture array.
+    uint16_t yOffset;  ///< Specifies a texel offset in the y direction within the texture array.
+    uint16_t width;    ///< Specifies the width of the texture subimage
+    uint16_t height;   ///< Specifies the height of the texture subimage.
   };
 
   /**
@@ -64,31 +66,31 @@ public:
    * @param[in] height The height of the texture
    * @return A smart-pointer to the newly allocated Texture.
    */
-  static NewTexturePtr New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height);
+  static TexturePtr New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height);
 
   /**
    * @brief Creates a new Texture from a native image
    * @param[in] nativeImageInterface The native image
    * @return A smart-pointer to the newly allocated Texture.
    */
-  static NewTexturePtr New( NativeImageInterface& nativeImageInterface );
+  static TexturePtr New( NativeImageInterface& nativeImageInterface );
 
   /**
    * @brief Get the texture render object
    *
    * @return the texture render object
    */
-  Render::NewTexture* GetRenderObject() const;
+  Render::Texture* GetRenderObject() const;
 
   /**
    * @copydoc Dali::Texture::Upload()
    */
-  void Upload( Vector<unsigned char>& buffer );
+  bool Upload( PixelDataPtr pixelData );
 
   /**
    * @copydoc Dali::Texture::Upload()
    */
-  void Upload( Vector<unsigned char>& buffer,
+  bool Upload( PixelDataPtr pixelData,
                unsigned int layer, unsigned int mipmap,
                unsigned int xOffset, unsigned int yOffset,
                unsigned int width, unsigned int height );
@@ -108,23 +110,21 @@ public:
    */
   unsigned int GetHeight() const;
 
-
 private: // implementation
 
   /**
    * Constructor
    * @param[in] type The type of the texture
    * @param[in] format The format of the pixel data
-   * @param[in] width The width of the texture
-   * @param[in] height The height of the texture
+   * @param[in] size The size of the texture
    */
-  NewTexture(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height );
+  Texture(TextureType::Type type, Pixel::Format format, ImageDimensions size );
 
   /**
    * Constructor from native image
    * @param[in] nativeImageInterface The native image
    */
-  NewTexture( NativeImageInterfacePtr nativeImageInterface );
+  Texture( NativeImageInterfacePtr nativeImageInterface );
 
   /**
    * Second stage initialization of the Texture
@@ -136,50 +136,43 @@ protected:
   /**
    * A reference counted object may only be deleted by calling Unreference()
    */
-  virtual ~NewTexture();
+  virtual ~Texture();
 
 private: // unimplemented methods
-  NewTexture( const NewTexture& );
-  NewTexture& operator=( const NewTexture& );
+  Texture( const Texture& );
+  Texture& operator=( const Texture& );
 
 private: // data
 
-  /**
-   * @brief Helper method to check that upload parameters are correct
-   * @param[in] buffer A vector with the data to be uploaded
-   * @param[in] parameters The uploading parameters
-   */
-  bool CheckUploadParametres( const Vector<unsigned char>& buffer, const UploadParams& parameters) const;
-
   Internal::EventThreadServices& mEventThreadServices;    ///<Used to send messages to the render thread via update thread
-  Internal::Render::NewTexture* mRenderObject;            ///<The Render::Texture associated to this texture
+  Internal::Render::Texture* mRenderObject;            ///<The Render::Texture associated to this texture
 
   NativeImageInterfacePtr mNativeImage; ///< Pointer to native image
-  Dali::TextureType::Type mType;      ///< Texture type (cached)
-  Pixel::Format mFormat;              ///< Pixel format
-  unsigned int mWidth;                ///< Width of the texture
-  unsigned int mHeight;               ///< Height of the texture
+  ImageDimensions mSize;                ///< Size of the texture
+  Dali::TextureType::Type mType;        ///< Texture type (cached)
+  Pixel::Format mFormat;                ///< Pixel format
+
 };
 
 } // namespace Internal
 
 // Helpers for public-api forwarding methods
-inline Internal::NewTexture& GetImplementation(Dali::Texture& handle)
+inline Internal::Texture& GetImplementation(Dali::Texture& handle)
 {
   DALI_ASSERT_ALWAYS(handle && "Texture handle is empty");
 
   BaseObject& object = handle.GetBaseObject();
 
-  return static_cast<Internal::NewTexture&>(object);
+  return static_cast<Internal::Texture&>(object);
 }
 
-inline const Internal::NewTexture& GetImplementation(const Dali::Texture& handle)
+inline const Internal::Texture& GetImplementation(const Dali::Texture& handle)
 {
   DALI_ASSERT_ALWAYS(handle && "Texture handle is empty");
 
   const BaseObject& object = handle.GetBaseObject();
 
-  return static_cast<const Internal::NewTexture&>(object);
+  return static_cast<const Internal::Texture&>(object);
 }
 
 } // namespace Dali