#include "frame.h"

#include <cstring>

Frame::Frame(uint32_t width, uint32_t height) : width(width), height(height) {
    data = new Pixel[width * height];
}

Frame::Frame(const Frame& other) : Frame(other.width, other.height) {
    std::memcpy(data, other.data, width * height * sizeof(Pixel));
}

Frame& Frame::operator=(const Frame& other) {
    width = other.width;
    height = other.height;
    delete[] data;
    data = new Pixel[width * height];
    std::memcpy(data, other.data, width * height * sizeof(Pixel));
    return *this;
}

Frame::Frame(Frame&& other) {
    width = other.width;
    height = other.height;
    data = other.data;
    other.data = nullptr;
}

Frame::~Frame() {
    delete[] data;
}

void Frame::fill(uint8_t p) {
    std::memset(data, p, width * height * sizeof(Pixel));
}
