X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Frenderers%2Frender-texture.h;h=8e3dc3df079520fa8040629b23556280a5fa9d5b;hb=5a35dc806d3f0f846232014534295c577275dc4c;hp=83c82f87edc59090339475f9f62f03de3bd8177d;hpb=6d393c62039167b16a8ae6d3a700122210a6102d;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 83c82f8..8e3dc3d 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) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -17,18 +17,29 @@ * limitations under the License. */ -#include -#include +// EXTERNAL INCLUDES #include +// INTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include + namespace Dali { namespace Internal { namespace Render { -class Sampler; +struct Sampler; +/** + * This class is the mapping between texture id, sampler and sampler uniform name + */ class Texture { public: @@ -37,18 +48,16 @@ public: * Constructor */ Texture() - :mUniformName(""), - mTextureId(Integration::InvalidResourceId), - mSampler(0) + : mSampler( 0 ), + mTextureId( Integration::InvalidResourceId ) {} /** * Constructor */ - Texture( const char* samplerName, Integration::ResourceId textureId, Render::Sampler* sampler ) - :mUniformName(samplerName), - mTextureId( textureId), - mSampler(sampler) + Texture( Integration::ResourceId textureId, Render::Sampler* sampler ) + : mSampler( sampler ), + mTextureId( textureId) {} /** @@ -66,35 +75,155 @@ public: return mSampler; } -public: // SamplerDataProvider interface - called from RenderThread +public: // called from RenderThread + /** - * Get the texture unit uniform name - * @return the name of the texture unit uniform + * Get the texture ID + * @return the id of the associated texture */ - inline const char* GetUniformName() const + inline Integration::ResourceId GetTextureId() const { - return mUniformName.c_str(); + 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; + /** - * Get the texture ID - * @param[in] bufferIndex The buffer index to use - * @return the identity of the associated texture + * 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 */ - inline Integration::ResourceId GetTextureId() const + NewTexture( Type type, Pixel::Format format, unsigned int width, unsigned int height ); + + /** + * Constructor from native image + * @param[in] nativeImageInterface The native image + */ + NewTexture( NativeImageInterfacePtr nativeImageInterface ); + + /** + * Destructor + */ + ~NewTexture(); + + /** + * 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); + + /** + * Deletes the texture from the GPU + * @param[in] context The GL context + */ + void Destroy( Context& context ); + + /** + * 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 ); + + /** + * 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 + */ + bool Bind( Context& context, unsigned int textureUnit, Render::Sampler* sampler ); + + /** + * Auto generates mipmaps for the texture + * @param[in] context The GL context + */ + void GenerateMipmaps( Context& context ); + + /** + * Retrieve wheter 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 mTextureId; + return mId; + } + + /** + * 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 + */ + unsigned int GetHeight() const + { + return mHeight; + } + + /** + * Get the type of the texture + * @return Type of the texture + */ + Type GetType() const + { + return mType; } private: - std::string mUniformName; - Integration::ResourceId mTextureId; - Render::Sampler* mSampler; + + /** + * 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 ); + + GLuint mId; ///