#pragma once

#include "MaterialNode.h"
#include "GeometryNode.h"
#include "SvgDocument.h"

#include <memory>
#include <vector>

class SvgNode : public MaterialNode
{
public:
    SvgNode(const Transform& transform);

    unsigned getContentWidth() const;
    unsigned getContentHeight() const;

    void setContent(std::unique_ptr<SvgDocument> doc);

    void update(SceneInfo* sceneInfo);
private:
    void createOrUpdateGeometry(SceneInfo* sceneInfo);

    void onCircle(XmlElement* element, std::unique_ptr<GeometryNode>& node);
    void onPath(XmlElement* element, std::unique_ptr<GeometryNode>& node);

    bool mContentDirty{ true };

    unsigned mContentWidth{ 1 };
    unsigned mContentHeight{ 1 };

    std::vector<std::unique_ptr<GeometryNode> > mGeometryNodes;
    std::unique_ptr<SvgDocument> mContent;
};
