X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fatlas-manager%2Fatlas-manager.h;h=6d4141977edb9aeeb71d188139431f795f565cd2;hp=55612fff72cb9315a5198c593d36557eb9f7481d;hb=6861f629112d44d4de1a8a7c70591e2279b951b2;hpb=7132bfee764dc2c7c68feb8c9e9c4e81c9a7d883 diff --git a/dali-toolkit/internal/atlas-manager/atlas-manager.h b/dali-toolkit/internal/atlas-manager/atlas-manager.h index 55612ff..6d41419 100644 --- a/dali-toolkit/internal/atlas-manager/atlas-manager.h +++ b/dali-toolkit/internal/atlas-manager/atlas-manager.h @@ -20,9 +20,9 @@ // EXTERNAL INCLUDES #include #include -#include -#include #include +#include +#include namespace Dali { @@ -160,6 +160,53 @@ public: typedef SizeType ImageId; static const bool MESH_OPTIMIZE = true; + struct AtlasSize + { + SizeType mWidth; ///< width of the atlas in pixels + SizeType mHeight; ///< height of the atlas in pixels + SizeType mBlockWidth; ///< width of a block in pixels + SizeType mBlockHeight; ///< height of a block in pixels + }; + + /** + * Metrics structures to describe Atlas Manager state + * + */ + struct AtlasMetricsEntry + { + AtlasSize mSize; ///< size of atlas and blocks + SizeType mBlocksUsed; ///< number of blocks used in the atlas + SizeType mTotalBlocks; ///< total blocks used by atlas + Pixel::Format mPixelFormat; ///< pixel format of the atlas + }; + + struct Metrics + { + Metrics() + : mAtlasCount( 0u ), + mTextureMemoryUsed( 0u ) + {} + + ~Metrics() + {} + + SizeType mAtlasCount; ///< number of atlases + SizeType mTextureMemoryUsed; ///< texture memory used by atlases + Dali::Vector< AtlasMetricsEntry > mAtlasMetrics; ///< container of atlas information + }; + + struct Vertex2D + { + Vector2 mPosition; + Vector2 mTexCoords; + }; + + struct Mesh2D + { + Vector< Vertex2D > mVertices; + Vector< unsigned int> mIndices; + }; + /** * Create an AtlasManager handle; this can be initialised with AtlasManager::New() * Calling member functions with an uninitialised handle is not allowed. @@ -194,8 +241,8 @@ public: */ struct AtlasSlot { - ImageId mImageId; // Id of stored Image - AtlasId mAtlasId; // Id of Atlas containing this slot + ImageId mImageId; ///< Id of stored Image + AtlasId mAtlasId; ///< Id of Atlas containing this slot }; typedef Dali::Vector< AtlasManager::AtlasSlot > slotContainer; @@ -203,19 +250,12 @@ public: /** * @brief Create a blank atlas of specific dimensions and pixel format with a certain block size * - * @param width desired atlas width in pixels - * @param height desired atlas height in pixels - * @param blockWidth block width to use in atlas in pixels - * @param blockHeight block height to use in atlas in pixels - * @param pixelformat format of a pixel in atlas + * @param[in] size desired atlas dimensions + * @param[in] pixelformat format of a pixel in atlas * * @return atlas Id */ - AtlasId CreateAtlas( SizeType width, - SizeType height, - SizeType blockWidth, - SizeType blockHeight, - Pixel::Format pixelformat = Pixel::RGBA8888 ); + AtlasId CreateAtlas( const AtlasSize& size, Pixel::Format pixelformat = Pixel::RGBA8888 ); /** * @brief Set the policy on failure to add an image to an atlas @@ -254,10 +294,12 @@ public: * @param[in] id Image Id returned in the AtlasSlot from the add operation * @param[in] position position of the resulting mesh in model space * @param[out] mesh Mesh Data Object to populate with mesh data + * @param[in] addReference Whether to increase the internal reference count for image or not */ void GenerateMeshData( ImageId id, const Vector2& position, - MeshData& mesh ); + Mesh2D& mesh, + bool addReference = true ); /** * @brief Append second mesh to the first mesh @@ -266,27 +308,15 @@ public: * @param[in] second Second mesh * @param[in] optimize should we optimize vertex data */ - void StitchMesh( MeshData& first, - const MeshData& second, - bool optimize = false ); - - /** - * @brief Combine two meshes, outputting the result into a new mesh - * - * @param[in] first First mesh - * @param[in] second Second mesh - * @param[in] optimize should we optimize vertex data - * @param[out] out resulting mesh - */ - void StitchMesh( const MeshData& first, - const MeshData& second, - MeshData& out, + void StitchMesh( Mesh2D& first, + const Mesh2D& second, bool optimize = false ); /** * @brief Get the BufferImage containing an atlas * - * @param atlas AtlasId returned when atlas was created + * @param[in] atlas AtlasId returned when atlas was created + * * @return Atlas Handle */ Dali::Atlas GetAtlasContainer( AtlasId atlas ) const; @@ -294,23 +324,25 @@ public: /** * @brief Get the Id of the atlas containing an image * - * @param id ImageId + * @param[in] id ImageId + * * @return Atlas Id */ AtlasId GetAtlas( ImageId id ); - /** - * @brief Get the size of the blocks used in an atlas + * @brief Get the current size of an atlas + * + * @param[in] atlas AtlasId * - * @param atlas AtlasId - * @return width and height of the blocks used + * @return AtlasSize structure for the atlas */ - Vector2 GetBlockSize( AtlasId atlas ); + const AtlasSize& GetAtlasSize( AtlasId atlas ); /** * @brief Get the number of blocks available in an atlas * - * @param atlas AtlasId + * @param[in] atlas AtlasId + * * @return Number of blocks free in this atlas */ SizeType GetFreeBlocks( AtlasId atlas ); @@ -318,11 +350,11 @@ public: /** * @brief Sets the pixel area of any new atlas and also the individual block size * - * @param size pixel area of atlas + * @param[in] size Atlas size structure + * * @param blockSize pixel area in atlas for a block */ - void SetAtlasSize( const Vector2& size, - const Vector2& blockSize ); + void SetNewAtlasSize( const AtlasSize& size ); /** * @brief Get the number of atlases created @@ -334,11 +366,36 @@ public: /** * @brief Get the pixel format used by an atlas * - * @param atlas AtlasId + * @param[in] atlas AtlasId + * * @return Pixel format used by this atlas */ Pixel::Format GetPixelFormat( AtlasId atlas ); + /** + * @brief Fill in a metrics structure showing current status of this Atlas Manager + * + * @param[in] metrics metrics structure to be filled + */ + void GetMetrics( Metrics& metrics ); + + /** + * @brief Get Material used by atlas + * + * @param atlas[in] atlas AtlasId + * + * @return Material used by atlas + */ + Material GetMaterial( AtlasId atlas ) const; + + /** + * @brief Get Image used by atlas + * + * @param atlas[in] atlas AtlasId + * + * @return Sampler used by atlas + */ + Image GetImage( AtlasId atlas ) const; private: explicit DALI_INTERNAL AtlasManager(Internal::AtlasManager *impl); @@ -349,4 +406,4 @@ private: } // namespace Dali -#endif // __DALI_TOOLKIT_ATLAS_MANAGER_H__ \ No newline at end of file +#endif // __DALI_TOOLKIT_ATLAS_MANAGER_H__