Revert "[Tizen] Add codes for Dali Windows Backend"
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / render-texture.h
index b117a14..d9192e0 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_RENDER_TEXTURE_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
 #include <string>
 
 // INTERNAL INCLUDES
-#include <dali/devel-api/rendering/sampler.h>
-#include <dali/devel-api/rendering/texture.h>
+#include <dali/public-api/images/image-operations.h> // Dali::ImageDimensions
+#include <dali/public-api/rendering/sampler.h>
+#include <dali/public-api/rendering/texture.h>
 #include <dali/internal/event/rendering/texture-impl.h>
-#include <dali/integration-api/resource-declarations.h>
-
 #include <dali/internal/render/gl-resources/context.h>
-#include <dali/integration-api/gl-defines.h>
 #include <dali/internal/render/renderers/render-sampler.h>
+#include <dali/integration-api/gl-defines.h>
 
 namespace Dali
 {
@@ -38,104 +37,37 @@ namespace Render
 {
 struct Sampler;
 
-/**
- * This class is the mapping between texture id, sampler and sampler uniform name
- */
 class Texture
 {
 public:
 
-  /**
-   * Enumeration to tell that this sampler does not have a unique index yet
-   */
-  enum
-  {
-    NOT_INITIALIZED = -1
-  };
-
-  /**
-   * Constructor
-   */
-  Texture()
-  : mSampler( 0 ),
-    mTextureId( Integration::InvalidResourceId )
-  {}
-
-  /**
-   * Constructor
-   */
-  Texture( Integration::ResourceId textureId, Render::Sampler* sampler )
-  : mSampler( sampler ),
-    mTextureId( textureId)
-  {}
-
-  /**
-   * Destructor
-   */
-  ~Texture()
-  {}
-
-  /*
-   * Get the Render::Sampler used by the texture
-   * @Return The Render::Sampler being used or 0 if using the default
-   */
-  inline const Render::Sampler* GetSampler() const
-  {
-    return mSampler;
-  }
-
-public: // called from RenderThread
-
-  /**
-   * @param[in] buffer A vector wit
-   * Get the texture ID
-   * @return the id of the associated texture
-   */
-  inline Integration::ResourceId GetTextureId() const
-  {
-    return mTextureId;
-  }
-
-private:
-
-  Render::Sampler*        mSampler;
-  Integration::ResourceId mTextureId;
-};
-
-
-//TODO : Remove the old Render::Texture class (see above) once it is no longer needed by Image
-class NewTexture
-{
-public:
-
   typedef Dali::TextureType::Type Type;
 
   /**
    * 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( Type type, Pixel::Format format, unsigned int width, unsigned int height );
+  Texture( Type type, Pixel::Format format, ImageDimensions size );
 
   /**
    * Constructor from native image
    * @param[in] nativeImageInterface The native image
    */
-  NewTexture( NativeImageInterfacePtr nativeImageInterface );
+  Texture( NativeImageInterfacePtr nativeImageInterface );
 
   /**
    * Destructor
    */
-  ~NewTexture();
+  ~Texture();
 
   /**
    * Creates the texture in the GPU.
    * Creates the texture and reserves memory for the first mipmap level
    * @param[in] context The GL context
    */
-  void Initialize(Context& context);
+  void Initialize( Context& context );
 
   /**
    * Deletes the texture from the GPU
@@ -144,12 +76,17 @@ public:
   void Destroy( Context& context );
 
   /**
+   * Called by RenderManager to inform the texture that the context has been destroyed
+   */
+  void GlContextDestroyed();
+
+  /**
    * Uploads data to the texture.
    * @param[in] context The GL context
    * @param[in] pixelData A pixel data object
    * @param[in] params Upload parameters. See UploadParams
    */
-  void Upload( Context& context, PixelDataPtr pixelData, const Internal::NewTexture::UploadParams& params );
+  void Upload( Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params );
 
   /**
    * Bind the texture to the given texture unit and applies the given sampler
@@ -182,30 +119,21 @@ public:
   }
 
   /**
-   * Get the width of the texture
-   * @return Width of the texture
-   */
-  unsigned int GetWidth() const
-  {
-    return mWidth;
-  }
-
-  /**
-   * Get the height of the texture
-   * @return Height of the texture
+   * Get the type of the texture
+   * @return Type of the texture
    */
-  unsigned int GetHeight() const
+  Type GetType() const
   {
-    return mHeight;
+    return mType;
   }
 
   /**
-   * Get the type of the texture
-   * @return Type of the texture
+   * Check if the texture is a native image
+   * @return if the texture is a native image
    */
-  Type GetType() const
+  bool IsNativeImage() const
   {
-    return mType;
+    return mNativeImage;
   }
 
 private:
@@ -217,15 +145,20 @@ private:
    */
   void ApplySampler( Context& context, Render::Sampler* sampler );
 
-  GLuint mId;                         ///<Id of the texture
-  Type mType;                         ///<Type of the texture
-  Render::Sampler mSampler;           ///<The current sampler state
-  NativeImageInterfacePtr mNativeImage; ///<Pointer to native image
-  GLenum mInternalFormat;             ///<The format of the pixel data
-  GLenum mPixelDataType;              ///<The data type of the pixel data
-  unsigned int mWidth;                ///<Widht of the texture
-  unsigned int mHeight;               ///<Height of the texture
-  bool mHasAlpha : 1;                 ///<Whether the format has an alpha channel
+  NativeImageInterfacePtr mNativeImage; ///< Pointer to native image
+  Render::Sampler mSampler;             ///< The current sampler state
+  GLuint mId;                           ///< Id of the texture
+  GLuint mTarget;                       ///< Specifies the target to which the texture is bound.
+  GLint mGlInternalFormat;              ///< The gl internal format of the pixel data
+  GLenum mGlFormat;                     ///< The gl format of the pixel data
+  GLenum mPixelDataType;                ///< The data type of the pixel data
+  uint16_t mWidth;                      ///< Width of the texture
+  uint16_t mHeight;                     ///< Height of the texture
+  uint16_t mMaxMipMapLevel;             ///< Maximum mipmap level
+  Type mType:2;                         ///< Type of the texture
+  bool mHasAlpha : 1;                   ///< Whether the format has an alpha channel
+  bool mIsCompressed : 1;               ///< Whether the format is compressed
+
 };