mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
renderer/accessor: added the id generator.
This function computes a unique identifier value based on the provided string. You can use this to assign a unique ID to the Paint object. Experimental APIs: - uint32_t Accessorr::id(const char* name) - uint32_t tvg_accessor_id(const char* name)
This commit is contained in:
parent
6456252b43
commit
32c4e1d815
5 changed files with 65 additions and 0 deletions
16
inc/thorvg.h
16
inc/thorvg.h
|
@ -2143,6 +2143,22 @@ public:
|
||||||
*/
|
*/
|
||||||
Result set(const Picture* picture, std::function<bool(const Paint* paint, void* data)> func, void* data) noexcept;
|
Result set(const Picture* picture, std::function<bool(const Paint* paint, void* data)> func, void* data) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Generate a unique ID (hash key) from a given name.
|
||||||
|
*
|
||||||
|
* This function computes a unique identifier value based on the provided string.
|
||||||
|
* You can use this to assign a unique ID to the Paint object.
|
||||||
|
*
|
||||||
|
* @param[in] name The input string to generate the unique identifier from.
|
||||||
|
*
|
||||||
|
* @return The generated unique identifier value.
|
||||||
|
*
|
||||||
|
* @see Paint::id
|
||||||
|
*
|
||||||
|
* @note Experimental API
|
||||||
|
*/
|
||||||
|
static uint32_t id(const char* name) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Creates a new Accessor object.
|
* @brief Creates a new Accessor object.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2569,6 +2569,36 @@ TVG_API Tvg_Result tvg_animation_del(Tvg_Animation* animation);
|
||||||
/** \} */ // end defgroup ThorVGCapi_Animation
|
/** \} */ // end defgroup ThorVGCapi_Animation
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \defgroup ThorVGCapi_Accesssor Accessor
|
||||||
|
* \brief A module for manipulation of the scene tree
|
||||||
|
*
|
||||||
|
* This module helps to control the scene tree.
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
/* Accessor API */
|
||||||
|
/************************************************************************/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Generate a unique ID (hash key) from a given name.
|
||||||
|
*
|
||||||
|
* This function computes a unique identifier value based on the provided string.
|
||||||
|
* You can use this to assign a unique ID to the Paint object.
|
||||||
|
*
|
||||||
|
* \param[in] name The input string to generate the unique identifier from.
|
||||||
|
*
|
||||||
|
* \return The generated unique identifier value.
|
||||||
|
*
|
||||||
|
* \note Experimental API
|
||||||
|
*/
|
||||||
|
TVG_API uint32_t tvg_accessor_generate_id(const char* name);
|
||||||
|
|
||||||
|
|
||||||
|
/** \} */ // end defgroup ThorVGCapi_Accessor
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \defgroup ThorVGCapi_LottieAnimation LottieAnimation
|
* \defgroup ThorVGCapi_LottieAnimation LottieAnimation
|
||||||
* \brief A module for manipulation of lottie extension features.
|
* \brief A module for manipulation of lottie extension features.
|
||||||
|
|
|
@ -894,6 +894,16 @@ TVG_API Tvg_Result tvg_animation_del(Tvg_Animation* animation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
/* Accessor API */
|
||||||
|
/************************************************************************/
|
||||||
|
|
||||||
|
TVG_API uint32_t tvg_accessor_generate_id(const char* name)
|
||||||
|
{
|
||||||
|
return Accessor::id(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Lottie Animation API */
|
/* Lottie Animation API */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
|
@ -478,6 +478,8 @@ size_t b64Decode(const char* encoded, const size_t len, char** decoded)
|
||||||
|
|
||||||
unsigned long djb2Encode(const char* str)
|
unsigned long djb2Encode(const char* str)
|
||||||
{
|
{
|
||||||
|
if (!str) return 0;
|
||||||
|
|
||||||
unsigned long hash = 5381;
|
unsigned long hash = 5381;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tvgIteratorAccessor.h"
|
#include "tvgIteratorAccessor.h"
|
||||||
|
#include "tvgCompressor.h"
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Internal Class Implementation */
|
/* Internal Class Implementation */
|
||||||
|
@ -81,6 +82,12 @@ Result Accessor::set(const Picture* picture, function<bool(const Paint* paint, v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t Accessor::id(const char* name) noexcept
|
||||||
|
{
|
||||||
|
return djb2Encode(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Accessor::~Accessor()
|
Accessor::~Accessor()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue