X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Frenderers%2Frender-texture.h;h=ea8cd138d355f1ccf19de0d132f4b156617d6a49;hb=b8153c3ab592e6ebeaeebf31137538f972c27653;hp=e50ec3d7e4641d952da65e469fcdcb246b2bc2b5;hpb=8513ce64554f7e406b71f8ea231a1380e93fcf37;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/renderers/render-texture.h b/dali/internal/render/renderers/render-texture.h index e50ec3d..ea8cd13 100644 --- a/dali/internal/render/renderers/render-texture.h +++ b/dali/internal/render/renderers/render-texture.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_RENDER_TEXTURE_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -18,15 +18,20 @@ */ // EXTERNAL INCLUDES +#include // uint16_t, uint32_t #include // INTERNAL INCLUDES +#include // Dali::ImageDimensions #include #include + +#include +#include +#include +#include #include -#include #include -#include namespace Dali { @@ -39,23 +44,21 @@ struct Sampler; class Texture { public: - - typedef Dali::TextureType::Type Type; + using Type = Dali::TextureType::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 */ - Texture( 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 */ - Texture( NativeImageInterfacePtr nativeImageInterface ); + explicit Texture(NativeImageInterfacePtr nativeImageInterface); /** * Destructor @@ -63,84 +66,58 @@ public: ~Texture(); /** - * Creates the texture in the GPU. - * Creates the texture and reserves memory for the first mipmap level - * @param[in] context The GL context + * Stores the graphics controller for use when required. + * + * @param[in] graphicsController The graphics controller to use */ - void Initialize(Context& context); + void Initialize(Graphics::Controller& graphicsController); /** - * Deletes the texture from the GPU - * @param[in] context The GL context + * Create the texture without a buffer + * @param[in] usage How texture will be used */ - void Destroy( Context& context ); + void Create(Graphics::TextureUsageFlags usage); /** - * Called by RenderManager to inform the texture that the context has been destroyed + * Create a texture with a buffer if non-null + * @param[in] usage How texture will be used + * @param[in] buffer Buffer to copy */ - void GlContextDestroyed(); + void CreateWithData(Graphics::TextureUsageFlags usage, uint8_t* buffer, uint32_t bufferSize); /** - * 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 + * Deletes the texture from the GPU */ - void Upload( Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params ); + void Destroy(); /** - * Bind the texture to the given texture unit and applies the given sampler - * @param[in] context The GL context - * @param[in] textureUnit the texture unit - * @param[in] sampler The sampler to be used with the texture - * @return true if the bind succeeded, false otherwise + * Uploads data to the texture. + * @param[in] pixelData A pixel data object + * @param[in] params Upload parameters. See UploadParams */ - bool Bind( Context& context, unsigned int textureUnit, Render::Sampler* sampler ); + void Upload(PixelDataPtr pixelData, const Internal::Texture::UploadParams& params); /** * Auto generates mipmaps for the texture - * @param[in] context The GL context */ - void GenerateMipmaps( Context& context ); + void GenerateMipmaps(); /** - * Retrieve wheter the texture has an alpha channel + * Retrieve whether the texture has an alpha channel * @return True if the texture has alpha channel, false otherwise */ - bool HasAlphaChannel(); - - /** - * Get the id of the texture - * @return Id of the texture - */ - GLuint GetId() - { - return mId; - } - - /** - * Get the width of the texture - * @return Width of the texture - */ - unsigned int GetWidth() const - { - return mWidth; - } + [[nodiscard]] bool HasAlphaChannel() const; /** - * Get the height of the texture - * @return Height of the texture + * Get the graphics object associated with this texture */ - unsigned int GetHeight() const - { - return mHeight; - } + [[nodiscard]] Graphics::Texture* GetGraphicsObject() const; /** * Get the type of the texture * @return Type of the texture */ - Type GetType() const + [[nodiscard]] Type GetType() const { return mType; } @@ -149,33 +126,31 @@ public: * Check if the texture is a native image * @return if the texture is a native image */ - bool IsNativeImage() const + [[nodiscard]] bool IsNativeImage() const { - return mNativeImage; + return static_cast(mNativeImage); } private: - /** * Helper method to apply a sampler to the texture - * @param[in] context The GL context * @param[in] sampler The sampler */ - void ApplySampler( Context& context, Render::Sampler* sampler ); + void ApplySampler(Render::Sampler* sampler); + +private: + Graphics::Controller* mGraphicsController; + Graphics::UniquePtr mGraphicsTexture; - GLuint mId; ///< Id of the texture - GLuint mTarget; ///< Specifies the target to which the texture is bound. - 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; ///< Width of the texture - unsigned int mHeight; ///< Height of the texture - bool mHasAlpha : 1; ///< Whether the format has an alpha channel - bool mIsCompressed : 1; ///< Whether the format is compressed -}; + Render::Sampler mSampler; ///< The current sampler state + Pixel::Format mPixelFormat; ///< Pixel format of the texture + uint16_t mWidth; ///< Width of the texture + uint16_t mHeight; ///< Height of the texture + Type mType : 3; ///< Type of the texture + bool mHasAlpha : 1; ///< Whether the format has an alpha channel +}; } // namespace Render @@ -183,5 +158,4 @@ private: } // namespace Dali - #endif // DALI_INTERNAL_RENDER_TEXTURE_H