#ifndef DEFINDED_SOURCE
#define DEFINDED_SOURCE

#include <stdlib.h>
#include "../../source/inout/XFrameSource.hpp"


USING_NS_GAODING_MEDIA

class Source {
    public:
        Source() {
            source = std::make_shared<XFrameSource>();
        }

        ~Source() {
            source.reset();
        }

        void setFillType(int type) {
            source->setFillType(static_cast<XFillType>(type));
        }

        void setClipRatio(float ratio) {
            source->setClipRatio(ratio);
        }

        void translate(float x, float y, float z) {
            source->translate({ x, y, z });
        }

        void scale(float x, float y, float z) {
            source->scale({ x, y, z});
        }

        void rotate(float x, float y, float z) {
            source->rotate({ x, y, z });
        }

        void setPixels(long pixels, int width, int height) {
            if (pixels == -1) {
                source->setPixels(nullptr, 0, 0);
            } else {
                uint8_t *castPixels = reinterpret_cast<uint8_t *>(pixels);
                std::shared_ptr<uint8_t> sharedPixels = std::shared_ptr<uint8_t>(castPixels);
                source->setPixels(sharedPixels, width, height);
            }
        }

        void notifyRefresh() {
            source->notifyRefresh();
        }

        std::shared_ptr<XFrameSource> getInstance() {
            return source;
        }
    private:
        std::shared_ptr<XFrameSource> source;
};
#endif