mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-30 01:55:39 +00:00
3acd894f37
d13d8e521 Refactoring 4925c87a8 Update 794c38591 Update 49eee9643 Update 914aee5ea Update 3bb00ecee Fix ParserString string-view iterator cast in windows fabea2008 Fix string-view iterator cast in windows bbcf0d34f Update 081df20f2 Update fe3101f91 Refactoring e9a41dc83 Refactoring 637121f89 Update lunasvg.cpp d0abdccb1 Remove Document transformation methods caa4b2410 Fix ft_stroke_border_export assertion 592533914 Fix SW_FT_Outline points overflow #55 0d40b061c Update git-subtree-dir: external/lunasvg git-subtree-split: d13d8e521c21f5f750ef0f6f92163f0131afdd3e
78 lines
2.2 KiB
C++
78 lines
2.2 KiB
C++
#include "maskelement.h"
|
|
#include "parser.h"
|
|
#include "layoutcontext.h"
|
|
|
|
namespace lunasvg {
|
|
|
|
MaskElement::MaskElement()
|
|
: StyledElement(ElementID::Mask)
|
|
{
|
|
}
|
|
|
|
Length MaskElement::x() const
|
|
{
|
|
auto& value = get(PropertyID::X);
|
|
return Parser::parseLength(value, AllowNegativeLengths, Length::MinusTenPercent);
|
|
}
|
|
|
|
Length MaskElement::y() const
|
|
{
|
|
auto& value = get(PropertyID::Y);
|
|
return Parser::parseLength(value, AllowNegativeLengths, Length::MinusTenPercent);
|
|
}
|
|
|
|
Length MaskElement::width() const
|
|
{
|
|
auto& value = get(PropertyID::Width);
|
|
return Parser::parseLength(value, ForbidNegativeLengths, Length::OneTwentyPercent);
|
|
}
|
|
|
|
Length MaskElement::height() const
|
|
{
|
|
auto& value = get(PropertyID::Height);
|
|
return Parser::parseLength(value, ForbidNegativeLengths, Length::OneTwentyPercent);
|
|
}
|
|
|
|
Units MaskElement::maskUnits() const
|
|
{
|
|
auto& value = get(PropertyID::MaskUnits);
|
|
return Parser::parseUnits(value, Units::ObjectBoundingBox);
|
|
}
|
|
|
|
Units MaskElement::maskContentUnits() const
|
|
{
|
|
auto& value = get(PropertyID::MaskContentUnits);
|
|
return Parser::parseUnits(value, Units::UserSpaceOnUse);
|
|
}
|
|
|
|
std::unique_ptr<LayoutMask> MaskElement::getMasker(LayoutContext* context) const
|
|
{
|
|
auto w = this->width();
|
|
auto h = this->height();
|
|
if(w.isZero() || h.isZero() || context->hasReference(this))
|
|
return nullptr;
|
|
|
|
LayoutBreaker layoutBreaker(context, this);
|
|
auto masker = std::make_unique<LayoutMask>();
|
|
masker->units = maskUnits();
|
|
masker->contentUnits = maskContentUnits();
|
|
masker->opacity = opacity();
|
|
masker->clipper = context->getClipper(clip_path());
|
|
masker->masker = context->getMasker(mask());
|
|
|
|
LengthContext lengthContext(this, maskUnits());
|
|
masker->x = lengthContext.valueForLength(x(), LengthMode::Width);
|
|
masker->y = lengthContext.valueForLength(y(), LengthMode::Height);
|
|
masker->width = lengthContext.valueForLength(w, LengthMode::Width);
|
|
masker->height = lengthContext.valueForLength(h, LengthMode::Height);
|
|
layoutChildren(context, masker.get());
|
|
return masker;
|
|
}
|
|
|
|
std::unique_ptr<Node> MaskElement::clone() const
|
|
{
|
|
return cloneElement<MaskElement>();
|
|
}
|
|
|
|
} // namespace lunasvg
|