X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fimage-loader%2Fatlas-packer.h;h=6d480e0f33dd985e2bbd6e9e56649f774b7bc0b3;hb=f25afa77b0b54726b8e12d91e8fdb84f6172d666;hp=b356124af5ceba93dab3608f191561abb06d7071;hpb=b694e7e2ae624e206e1548b1a863c554eb9cd4d7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/image-loader/atlas-packer.h b/dali-toolkit/internal/image-loader/atlas-packer.h index b356124..6d480e0 100644 --- a/dali-toolkit/internal/image-loader/atlas-packer.h +++ b/dali-toolkit/internal/image-loader/atlas-packer.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_ATLAS_PACKER_H /* - * Copyright (c) 2019 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. @@ -17,20 +17,17 @@ * limitations under the License. */ -#include #include #include #include +#include namespace Dali { - namespace Toolkit { - namespace Internal { - /** * Binary space tree based bin packing algorithm. * It is initialised with a fixed width and height and will fit each block into the first node where it fits @@ -39,11 +36,10 @@ namespace Internal class AtlasPacker { public: - /** * rectangular area (x,y,width,height) */ - typedef uint32_t SizeType; + typedef uint32_t SizeType; typedef Rect RectArea; /** @@ -51,12 +47,12 @@ public: */ struct Node { - Node( Node* parent, SizeType x, SizeType y, SizeType width, SizeType height ); + Node(Node* parent, SizeType x, SizeType y, SizeType width, SizeType height); RectArea rectArea; - Node* parent; - Node* child[2]; - bool occupied; + Node* parent; + Node* child[2]; + bool occupied; }; /** @@ -65,7 +61,7 @@ public: * @param[in] atlasWidth The width of the atlas. * @param[in] atlasHeight The height of the atlas. */ - AtlasPacker( SizeType atlasWidth, SizeType atlasHeight ); + AtlasPacker(SizeType atlasWidth, SizeType atlasHeight); /** * Destructor @@ -81,8 +77,7 @@ public: * @param[out] packPositionY The y coordinate of the position to pack the block. * @return True if there are room for this block, false otherwise. */ - bool Pack( SizeType blockWidth, SizeType blockHeight, - SizeType& packPositionX, SizeType& packPositionY); + bool Pack(SizeType blockWidth, SizeType blockHeight, SizeType& packPositionX, SizeType& packPositionY); /** * Delete the block. @@ -92,7 +87,7 @@ public: * @param[in] blockWidth The width of the block to delete. * @param[in] blockHeight The height of the block to delete. */ - void DeleteBlock( SizeType packPositionX, SizeType packPositionY, SizeType blockWidth, SizeType blockHeight ); + void DeleteBlock(SizeType packPositionX, SizeType packPositionY, SizeType blockWidth, SizeType blockHeight); /** * Query how much empty space left. @@ -107,10 +102,9 @@ public: * @param[out] packPositions The packing position of each block. * @return The required size to accommodate all the blocks. */ - static Uint16Pair GroupPack( const Dali::Vector& blockSizes, Dali::Vector& packPositions ); + static Uint16Pair GroupPack(const Dali::Vector& blockSizes, Dali::Vector& packPositions); private: - /* * Search the node which can pack the block with given size. * @@ -120,7 +114,7 @@ private: * @return The poniter pointing to node that can pack the block. * If it is NULL, there are no room in the subtree to pack the block. */ - Node* InsertNode( Node* root, SizeType blockWidth, SizeType blockHeight ); + Node* InsertNode(Node* root, SizeType blockWidth, SizeType blockHeight); /** * Split the node into two to fit the block width/size. @@ -129,7 +123,7 @@ private: * @param[in] blockWidth The width of the block to pack. * @param[in] blockHeight The height of the block to pack. */ - void SplitNode( Node* node, SizeType blockWidth, SizeType blockHeight ); + void SplitNode(Node* node, SizeType blockWidth, SizeType blockHeight); /** * Search the node at the given position and with the given size. @@ -140,21 +134,21 @@ private: * @param[in] blockWidth The width of the block. * @param[in] blockHeight The height of the block. */ - Node* SearchNode( Node* node, SizeType packPositionX, SizeType packPositionY, SizeType blockWidth, SizeType blockHeight ); + Node* SearchNode(Node* node, SizeType packPositionX, SizeType packPositionY, SizeType blockWidth, SizeType blockHeight); /** * Merge the rect of the node to non-occupied area. * * @param[in] node The node to me merged to the non-occupied area */ - void MergeToNonOccupied( Node* node ); + void MergeToNonOccupied(Node* node); /** * Delete a node and its subtree. * * @parm[in] node The node to delete. */ - void DeleteNode( Node* node ); + void DeleteNode(Node* node); /** * Pack a block into the atlas. If there is no enough room, grow the partition tree. @@ -164,8 +158,7 @@ private: * @param[out] packPositionX The x coordinate of the position to pack the block. * @param[out] packPositionY The y coordinate of the position to pack the block. */ - void GrowPack( SizeType blockWidth, SizeType blockHeight, - SizeType& packPositionX, SizeType& packPositionY ); + void GrowPack(SizeType blockWidth, SizeType blockHeight, SizeType& packPositionX, SizeType& packPositionY); /** * Add extra node into the partition tree to accommodate the given block. @@ -173,22 +166,19 @@ private: * @param[in] blockWidth The width of the block to pack. * @param[in] blockHeight The height of the block to pack. */ - void GrowNode( SizeType blockWidth, SizeType blockHeight ); + void GrowNode(SizeType blockWidth, SizeType blockHeight); // Undefined - AtlasPacker( const AtlasPacker& atlasPacker); + AtlasPacker(const AtlasPacker& atlasPacker); // Undefined - AtlasPacker& operator=( const AtlasPacker& atlasPacker ); + AtlasPacker& operator=(const AtlasPacker& atlasPacker); private: - - Node* mRoot; ///< The root of the binary space tree + Node* mRoot; ///< The root of the binary space tree unsigned int mAvailableArea; - }; - } // namespace Internal } // namespace Toolkit