#ifndef _RIVE_SKIA_RENDERER_HPP_
#define _RIVE_SKIA_RENDERER_HPP_

#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkImage.h"
#include "rive/renderer.hpp"
#include <vector>

namespace rive
{
	class SkiaRenderPath : public RenderPath
	{
	private:
		SkPath m_Path;

	public:
		const SkPath& path() const { return m_Path; }
		void reset() override;
		void addRenderPath(RenderPath* path, const Mat2D& transform) override;
		void fillRule(FillRule value) override;
		void moveTo(float x, float y) override;
		void lineTo(float x, float y) override;
		void cubicTo(
		    float ox, float oy, float ix, float iy, float x, float y) override;
		virtual void close() override;
	};

	struct GradientStop
	{
		unsigned int color;
		float stop;
		GradientStop(unsigned int color, float stop) : color(color), stop(stop)
		{
		}
	};

	class SkiaGradientBuilder
	{
	public:
		std::vector<GradientStop> stops;
		float sx, sy, ex, ey;
		virtual ~SkiaGradientBuilder() {}
		SkiaGradientBuilder(float sx, float sy, float ex, float ey) :
		    sx(sx), sy(sy), ex(ex), ey(ey)
		{
		}

		virtual void make(SkPaint& paint) = 0;
	};

	class SkiaRadialGradientBuilder : public SkiaGradientBuilder
	{
	public:
		SkiaRadialGradientBuilder(float sx, float sy, float ex, float ey) :
		    SkiaGradientBuilder(sx, sy, ex, ey)
		{
		}
		void make(SkPaint& paint) override;
	};

	class SkiaLinearGradientBuilder : public SkiaGradientBuilder
	{
	public:
		SkiaLinearGradientBuilder(float sx, float sy, float ex, float ey) :
		    SkiaGradientBuilder(sx, sy, ex, ey)
		{
		}
		void make(SkPaint& paint) override;
	};

	class SkiaRenderPaint : public RenderPaint
	{
	private:
		SkPaint m_Paint;
		SkiaGradientBuilder* m_GradientBuilder;

	public:
		const SkPaint& paint() const { return m_Paint; }
		SkiaRenderPaint();
		void style(RenderPaintStyle style) override;
		void color(unsigned int value) override;
		void thickness(float value) override;
		void join(StrokeJoin value) override;
		void cap(StrokeCap value) override;
		void blendMode(BlendMode value) override;

		void linearGradient(float sx, float sy, float ex, float ey) override;
		void radialGradient(float sx, float sy, float ex, float ey) override;
		void addStop(unsigned int color, float stop) override;
		void completeGradient() override;
	};

	class SkiaRenderImage : public RenderImage
	{
	private:
		sk_sp<SkImage> m_SkImage;

	public:
		sk_sp<SkImage> skImage() const { return m_SkImage; };
		bool decode(const uint8_t* bytes, std::size_t size) override;
	};

	class SkiaRenderer : public Renderer
	{
	protected:
		SkCanvas* m_Canvas;

	public:
		SkiaRenderer(SkCanvas* canvas) : m_Canvas(canvas) {}
		void save() override;
		void restore() override;
		void transform(const Mat2D& transform) override;
		void drawPath(RenderPath* path, RenderPaint* paint) override;
		void
		drawImage(RenderImage* image, BlendMode value, float opacity) override;
		void clipPath(RenderPath* path) override;
	};
} // namespace rive
#endif