X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Frendering%2Ftexture-impl.h;h=4d3a1330ee539c9c53ba72f15a46f4cac333b659;hb=1eac313ff98060f49ae6451a5365093a6024c017;hp=4464dcba42f774e364f285e1009a4bb24bad148d;hpb=90c71466dc82244af67e9b027cc4f6a20d91f1cb;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/rendering/texture-impl.h b/dali/internal/event/rendering/texture-impl.h index 4464dcb..4d3a133 100644 --- a/dali/internal/event/rendering/texture-impl.h +++ b/dali/internal/event/rendering/texture-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_NEW_TEXTURE_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -19,44 +19,26 @@ */ // INTERNAL INCLUDES -#include // DALI_ASSERT_ALWAYS -#include // Dali::IntrusivePtr -#include -#include -#include // Dali::ImageDimensions -#include // Dali::Internal::Render::Texture #include #include +#include +#include // DALI_ASSERT_ALWAYS +#include // Dali::IntrusivePtr +#include // Dali::ImageDimensions +#include +#include +#include // Dali::Internal::Render::Texture namespace Dali { namespace Internal { -namespace Render -{ -class Texture; -} - class Texture; -typedef IntrusivePtr TexturePtr; +using TexturePtr = IntrusivePtr; class Texture : public BaseObject { public: - - /** - * @brief Structure used to pass parameters to the Upload method - */ - struct UploadParams - { - 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. - }; - /** * @brief Create a new Texture. * @@ -66,34 +48,70 @@ public: * @param[in] height The height of the texture * @return A smart-pointer to the newly allocated Texture. */ - static TexturePtr New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height); + static TexturePtr New(TextureType::Type type, Pixel::Format format, uint32_t width, uint32_t 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 TexturePtr New( NativeImageInterface& nativeImageInterface ); + static TexturePtr New(NativeImageInterface& nativeImageInterface); + + /** + * @brief Create a new Texture with resourceId. + * + * @param[in] type The type of the texture + * @param[in] resourceId The unique id of this texture combind with TextureUploadManager + * @return A smart-pointer to the newly allocated Texture. + */ + static TexturePtr New(TextureType::Type type, uint32_t resourceId); /** * @brief Get the texture render object * * @return the texture render object */ - Render::Texture* GetRenderObject() const; + Render::TextureKey GetRenderTextureKey() const; /** * @copydoc Dali::Texture::Upload() */ - bool Upload( PixelDataPtr pixelData ); + bool Upload(PixelDataPtr pixelData); /** * @copydoc Dali::Texture::Upload() */ - bool Upload( PixelDataPtr pixelData, - unsigned int layer, unsigned int mipmap, - unsigned int xOffset, unsigned int yOffset, - unsigned int width, unsigned int height ); + bool Upload(PixelDataPtr pixelData, + uint32_t layer, + uint32_t mipmap, + uint32_t xOffset, + uint32_t yOffset, + uint32_t width, + uint32_t height); + + /** + * @copydoc Dali::Texture::UploadSubPixelData() + */ + bool UploadSubPixelData(PixelDataPtr pixelData, + uint32_t dataXOffset, + uint32_t dataYOffset, + uint32_t dataWidth, + uint32_t dataHeight); + + /** + * @copydoc Dali::Texture::UploadSubPixelData() + */ + bool UploadSubPixelData(PixelDataPtr pixelData, + uint32_t dataXOffset, + uint32_t dataYOffset, + uint32_t dataWidth, + uint32_t dataHeight, + uint32_t layer, + uint32_t mipmap, + uint32_t xOffset, + uint32_t yOffset, + uint32_t width, + uint32_t height); /** * @copydoc Dali::Texture::GenerateMipmaps() @@ -103,28 +121,74 @@ public: /** * @copydoc Dali::Texture::GetWidth() */ - unsigned int GetWidth() const; + uint32_t GetWidth() const; /** * @copydoc Dali::Texture::GetHeight() */ - unsigned int GetHeight() const; + uint32_t GetHeight() const; -private: // implementation + /** + * @copydoc Dali::Texture::GetPixelFormat() + */ + Pixel::Format GetPixelFormat() const; + + /** + * @copydoc Dali::Integration::GetTextureResourceId() + */ + uint32_t GetResourceId() const; /** + * @copydoc Dali::Integration::GetTextureType() + */ + Dali::TextureType::Type GetTextureType() const; + + /** + * @copydoc Dali::Integration::SetTextureSize() + */ + void SetSize(const ImageDimensions& size); + + /** + * @copydoc Dali::Integration::SetTexturePixelFormat() + */ + void SetPixelFormat(Pixel::Format format); + + /** + * @brief Determine if the texture is a native image + * + * @return true if the texture has been initialized with a native image + */ + bool IsNative() const; + + /** + * @brief Apply any native texture code to the given fragment shader + * + * @param[in,out] shader The fragment shader + * @return true if the shader has been modified. + */ + bool ApplyNativeFragmentShader(std::string& shader); + +private: // implementation + /** * Constructor * @param[in] type The type of the texture * @param[in] format The format of the pixel data * @param[in] size The size of the texture */ - Texture(TextureType::Type type, Pixel::Format format, ImageDimensions size ); + Texture(TextureType::Type type, Pixel::Format format, ImageDimensions size); /** * Constructor from native image * @param[in] nativeImageInterface The native image */ - Texture( NativeImageInterfacePtr nativeImageInterface ); + Texture(NativeImageInterfacePtr nativeImageInterface); + + /** + * Constructor from resource id + * @param[in] type The type of the texture + * @param[in] resourceId The resouce id for texture upload manager using + */ + Texture(TextureType::Type type, uint32_t resourceId); /** * Second stage initialization of the Texture @@ -132,26 +196,27 @@ private: // implementation void Initialize(); protected: - /** * A reference counted object may only be deleted by calling Unreference() */ - virtual ~Texture(); + ~Texture() override; private: // unimplemented methods - Texture( const Texture& ); - Texture& operator=( const Texture& ); - -private: // data + Texture(const Texture&); + Texture& operator=(const Texture&); - Internal::EventThreadServices& mEventThreadServices; ///