Merge "Support glTF extention: KHR_texture_transform" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 23 Nov 2023 15:12:02 +0000 (15:12 +0000)
committerGerrit Code Review <gerrit@review>
Thu, 23 Nov 2023 15:12:02 +0000 (15:12 +0000)
1  2 
dali-scene3d/public-api/loader/material-definition.h

@@@ -34,7 -34,6 +34,7 @@@ namespace Dali::Scene3D::Loade
  {
  /**
   * @brief Helper enum for encoding and decoding sampler states.
 + * @SINCE_2_0.7
   */
  struct DALI_SCENE3D_API SamplerFlags
  {
    };
  
    /**
 -   * @return SamplerFlags bit pattern calculated from the given Dali Sampler settings.
 +   * @brief Retrieves the bit pattern calculated from the given Dali Sampler settings.
 +   * @SINCE_2_0.7
 +   * @return SamplerFlags bit pattern.
     */
    static Type Encode(FilterMode::Type minFilter, FilterMode::Type magFilter, WrapMode::Type wrapS, WrapMode::Type wrapT);
  
    /**
     * @brief Decodes the minification filter patter of @a flags into the corresponding FilterMode.
 +   * @SINCE_2_0.7
     */
    static FilterMode::Type GetMinFilter(Type flags);
  
    /**
     * @brief Decodes the magnification filter patter of @a flags into the corresponding FilterMode.
 +   * @SINCE_2_0.7
     */
    static FilterMode::Type GetMagFilter(Type flags);
  
    /**
     * @brief Decodes the horizontal wrap pattern of @a flags into the corresponding WrapMode.
 +   * @SINCE_2_0.7
     */
    static WrapMode::Type GetWrapS(Type flags);
  
    /**
     * @brief Decodes the vertical wrap pattern of @a flags into the corresponding WrapMode.
 +   * @SINCE_2_0.7
     */
    static WrapMode::Type GetWrapT(Type flags);
  
    /**
     * @brief Creates a Sampler with the settings encoded in @a flags.
 +   * @SINCE_2_0.7
     */
    static Sampler MakeSampler(Type flags);
  };
  
  /**
   * @brief Defines a texture from a combination of an image URI and its sampler definition.
 + * @SINCE_2_0.7
   */
  struct DALI_SCENE3D_API TextureDefinition
  {
+   static const Matrix3 DEFAULT_TRANSFORM;
    std::string          mImageUri; // When the texture is loaded from embedded resources, this URI is used as a data stream.
    std::string          mDirectoryPath;
    SamplerFlags::Type   mSamplerFlags;
    ImageDimensions      mMinImageDimensions;
    SamplingMode::Type   mSamplingMode;
+   Matrix3              mTransform{DEFAULT_TRANSFORM}; // Texture transform
    std::vector<uint8_t> mTextureBuffer;
  
-   TextureDefinition(const std::string& imageUri = "", SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT, ImageDimensions minImageDimensions = ImageDimensions(), SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR);
-   TextureDefinition(std::string&& imageUri, SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT, ImageDimensions minImageDimensions = ImageDimensions(), SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR);
-   TextureDefinition(std::vector<uint8_t>&& textureBuffer, SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT, ImageDimensions minImageDimensions = ImageDimensions(), SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR);
+   TextureDefinition(const std::string& imageUri = "", SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT, ImageDimensions minImageDimensions = ImageDimensions(), SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR, Matrix3 transform = DEFAULT_TRANSFORM);
+   TextureDefinition(std::string&& imageUri, SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT, ImageDimensions minImageDimensions = ImageDimensions(), SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR, Matrix3 transform = DEFAULT_TRANSFORM);
+   TextureDefinition(std::vector<uint8_t>&& textureBuffer, SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT, ImageDimensions minImageDimensions = ImageDimensions(), SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR, Matrix3 transform = DEFAULT_TRANSFORM);
  };
  
  /**
   *  is enabled, and an index of an environment (usually of all environments in a
   *  scene). Textures from the environment are added last when the DALi TextureSet
   *  is being created.
 + * @SINCE_2_0.7
   */
  struct DALI_SCENE3D_API MaterialDefinition
  {
  
    /**
     * @brief A(n image based) texture that's used in a material.
 +   * @SINCE_2_0.7
     */
    struct TextureStage
    {
    /**
     * @brief Loads (or, in the case of solid color materials, creates) raw pixel data,
     *  which is then returned.
 +   * @SINCE_2_0.7
     * @note This may be called from any thread.
     */
    RawData LoadRaw(const std::string& imagesPath);
     * @brief Creates Textures from the pixel data in @a raw, gets the
     *  the cube maps from the iEnvironment'th element of @a environments,
     *  then creates a DALi TextureSet and returns it.
 +   * @SINCE_2_0.7
     * @note This must be called from the event thread.
     * @note The textures are added in the following order: 2D, cube maps.
     */
  
    /**
     * @brief Checks if the given mask matches any of the textures defined.
 +   * @SINCE_2_0.7
     */
    bool CheckTextures(uint32_t flags) const;
  
    /**
     * @return The alpha test reference value.
 +   * @SINCE_2_0.7
     * @note A value of 0.f means no alpha testing.
     */
    float GetAlphaCutoff() const
  
    /**
     * @brief Encodes the alpha test reference @a value in flags.
 +   * @SINCE_2_0.7
     * @note A value of 0.f means no alpha testing.
     */
    void SetAlphaCutoff(float value)