/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/ThirdParty/RmlUi/Source/SVG/DecoratorSVG.cpp
67 строк
2 KB
C-Core
Updated RmlUi to 6.2 and added some improvements (#1813)
10 фев 2026, 01:19
Не верифицирован
10 фев 2026, 01:19
58e2d41
Код
Авторство
О чём код?
#include "DecoratorSVG.h" #include "../../Include/RmlUi/Core/Element.h" #include "../../Include/RmlUi/Core/ElementDocument.h" #include "../../Include/RmlUi/Core/Geometry.h" #include "../../Include/RmlUi/Core/PropertyDefinition.h" #include "SVGCache.h" namespace Rml { namespace SVG { DecoratorSVG::DecoratorSVG(const String& source, const bool crop_to_content) : source_path(source), crop_to_content(crop_to_content) { RMLUI_ASSERT(!source_path.empty()); } DecoratorSVG::~DecoratorSVG() {} DecoratorDataHandle DecoratorSVG::GenerateElementData(Element* element, BoxArea paint_area) const { SharedPtr<SVGData> handle = SVGCache::GetHandle(source_path, source_path, SVGCache::File, element, crop_to_content, paint_area); if (!handle) return {}; Data* data = new Data{ std::move(handle), paint_area, }; return reinterpret_cast<DecoratorDataHandle>(data); } void DecoratorSVG::ReleaseElementData(DecoratorDataHandle element_data) const { Data* data = reinterpret_cast<Data*>(element_data); delete data; } void DecoratorSVG::RenderElement(Element* element, DecoratorDataHandle element_data) const { Data* data = reinterpret_cast<Data*>(element_data); RMLUI_ASSERT(data && data->handle); data->handle->geometry.Render(element->GetAbsoluteOffset(data->paint_area), data->handle->texture); } DecoratorSVGInstancer::DecoratorSVGInstancer() { source_id = RegisterProperty("source", "").AddParser("string").GetId(); crop_id = RegisterProperty("crop", "crop-none").AddParser("keyword", "crop-none, crop-to-content").GetId(); RegisterShorthand("decorator", "source, crop", ShorthandType::FallThrough); } DecoratorSVGInstancer::~DecoratorSVGInstancer() {} SharedPtr<Decorator> DecoratorSVGInstancer::InstanceDecorator(const String&, const PropertyDictionary& properties, const DecoratorInstancerInterface&) { String source = properties.GetProperty(source_id)->Get<String>(); if (source.empty()) return nullptr; const bool crop_to_content = properties.GetProperty(crop_id)->Get<int>() != 0; return MakeShared<DecoratorSVG>(source, crop_to_content); } } // namespace SVG } // namespace Rml