#include "pch.h"

#include "canvas.h"

#include "legacy_canvas_projection_services.h"
#include "legacy_canvas_render_shell_services.h"

// return the 2d shape of the faces based on the current camera
// this can be used for screen space shapes clipping
std::vector<glm::vec2> Canvas::face_to_shape2D(int plane_index)
{
    return pp::panopainter::legacy_canvas_face_to_shape_2d(*this, plane_index);
}

void Canvas::push_camera()
{
    pp::panopainter::legacy_canvas_push_camera(*this);
}

void Canvas::pop_camera()
{
    pp::panopainter::legacy_canvas_pop_camera(*this);
}

CameraData Canvas::get_camera()
{
    return pp::panopainter::legacy_canvas_render_shell_get_camera(*this);
}

void Canvas::set_camera(const CameraData& c)
{
    pp::panopainter::legacy_canvas_render_shell_set_camera(*this, c);
}

void Canvas::timelapse_reset_encoder() noexcept
{
    m_encoder = std::make_unique<MP4Encoder>();
    int res = glm::min<int>(m_width / 2, 1024);
    m_encoder->init(res * 4, res * 2, 30, 2000 << 10);
}
