mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
svg_loader: _applySvgViewFlag refactored
This commit is contained in:
parent
158e36f7c9
commit
e61857f27d
1 changed files with 10 additions and 6 deletions
|
@ -756,19 +756,23 @@ static unique_ptr<Scene> _sceneBuildHelper(const SvgNode* node, const Box& vBox,
|
||||||
|
|
||||||
static void _applySvgViewFlag(const Scene* scene, float& vx, float& vy, float& vw, float& vh, float& w, float& h, SvgViewFlag viewFlag)
|
static void _applySvgViewFlag(const Scene* scene, float& vx, float& vy, float& vw, float& vh, float& w, float& h, SvgViewFlag viewFlag)
|
||||||
{
|
{
|
||||||
if (!((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Viewbox)) {
|
bool noViewbox = !((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Viewbox);
|
||||||
|
bool noWidth = !((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Width);
|
||||||
|
bool noHeight = !((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Height);
|
||||||
|
|
||||||
|
if (noViewbox) {
|
||||||
float x, y;
|
float x, y;
|
||||||
scene->bounds(&x, &y, &vw, &vh, false);
|
scene->bounds(&x, &y, &vw, &vh, false);
|
||||||
if (!((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Width) && !((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Height)) {
|
if (noWidth && noHeight) {
|
||||||
vx = x;
|
vx = x;
|
||||||
vy = y;
|
vy = y;
|
||||||
} else {
|
} else {
|
||||||
if ((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Width) vw = w;
|
vw = noWidth ? vw : w;
|
||||||
if ((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Height) vh = h;
|
vh = noHeight ? vh : h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Width)) w = vw;
|
w = noWidth ? vw : w;
|
||||||
if (!((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Height)) h = vh;
|
h = noHeight ? vh : h;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
Loading…
Add table
Reference in a new issue