mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
common picture: recover viewbox() api.
though picture has size() api, we have a regression issue in tizen, we can't remove this api until we resolve any regression conditions.
This commit is contained in:
parent
b6590314f6
commit
a4ccf4d812
7 changed files with 47 additions and 7 deletions
|
@ -1090,6 +1090,15 @@ public:
|
|||
*/
|
||||
Result load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept;
|
||||
|
||||
/**
|
||||
* @brief Gets the position and the size of the loaded SVG picture.
|
||||
*
|
||||
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
|
||||
*
|
||||
* @BETA_API
|
||||
*/
|
||||
Result viewbox(float* x, float* y, float* w, float* h) const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Creates a new Picture object.
|
||||
*
|
||||
|
|
|
@ -1696,6 +1696,14 @@ TVG_EXPORT Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data,
|
|||
TVG_EXPORT Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, float* h);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Gets the position and the size of the loaded picture. (BETA version)
|
||||
*
|
||||
* \warning Please do not use it, this API is not official one. It can be modified in the next version.
|
||||
*/
|
||||
TVG_EXPORT Tvg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h);
|
||||
|
||||
|
||||
/** \} */ // end defgroup ThorVGCapi_Picture
|
||||
|
||||
|
||||
|
|
|
@ -476,6 +476,13 @@ TVG_EXPORT Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, flo
|
|||
return (Tvg_Result) reinterpret_cast<Picture*>(CCP(paint))->size(w, h);
|
||||
}
|
||||
|
||||
|
||||
TVG_EXPORT Tvg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h)
|
||||
{
|
||||
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
|
||||
return (Tvg_Result) reinterpret_cast<Picture*>(CCP(paint))->viewbox(x, y, w, h);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* Gradient API */
|
||||
/************************************************************************/
|
||||
|
|
|
@ -30,7 +30,13 @@ namespace tvg
|
|||
class LoadModule
|
||||
{
|
||||
public:
|
||||
//default view box, if any.
|
||||
float vx = 0;
|
||||
float vy = 0;
|
||||
float vw = 0;
|
||||
float vh = 0;
|
||||
float w = 0, h = 0; //default image size
|
||||
bool preserveAspect = true; //keep aspect ratio by default.
|
||||
|
||||
virtual ~LoadModule() {}
|
||||
|
||||
|
|
|
@ -74,6 +74,13 @@ Result Picture::load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept
|
|||
}
|
||||
|
||||
|
||||
Result Picture::viewbox(float* x, float* y, float* w, float* h) const noexcept
|
||||
{
|
||||
if (pImpl->viewbox(x, y, w, h)) return Result::Success;
|
||||
return Result::InsufficientCondition;
|
||||
}
|
||||
|
||||
|
||||
Result Picture::size(float w, float h) noexcept
|
||||
{
|
||||
if (pImpl->size(w, h)) return Result::Success;
|
||||
|
|
|
@ -137,6 +137,16 @@ struct Picture::Impl
|
|||
return false;
|
||||
}
|
||||
|
||||
bool viewbox(float* x, float* y, float* w, float* h) const
|
||||
{
|
||||
if (!loader) return false;
|
||||
if (x) *x = loader->vx;
|
||||
if (y) *y = loader->vy;
|
||||
if (w) *w = loader->vw;
|
||||
if (h) *h = loader->vh;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool size(uint32_t w, uint32_t h)
|
||||
{
|
||||
this->w = w;
|
||||
|
|
|
@ -35,14 +35,7 @@ public:
|
|||
SvgLoaderData loaderData;
|
||||
unique_ptr<Scene> root;
|
||||
|
||||
//default view box, if any.
|
||||
float vx = 0;
|
||||
float vy = 0;
|
||||
float vw = 0;
|
||||
float vh = 0;
|
||||
|
||||
bool copy = false;
|
||||
bool preserveAspect = true; //aspect ratio option
|
||||
|
||||
SvgLoader();
|
||||
~SvgLoader();
|
||||
|
|
Loading…
Add table
Reference in a new issue