compress file when saving, using bbox, dirty flags and PNG compression

This commit is contained in:
2017-05-10 01:27:57 +01:00
parent 6548ac3748
commit fbb73ccbbb
7 changed files with 100 additions and 30 deletions

View File

@@ -13,13 +13,18 @@ class Layer
{
public:
RTT m_rtt[6];
glm::vec4 m_dirty_box[6];
bool m_dirty_face[6];
bool m_visible = true;
bool m_alpha_locked = false;
float m_opacity = 1.f;
std::string m_name;
int w, h;
struct Snapshot
{
std::unique_ptr<uint8_t[]> image[6];
glm::vec4 m_dirty_box[6];
bool m_dirty_face[6];
void create(int w, int h)
{
for (int i = 0; i < 6; i++)
@@ -103,7 +108,7 @@ public:
void snapshot_save(std::string data_path);
void snapshot_restore();
void clear_context();
void save(std::string data_path);
void export_equirectangular(std::string data_path);
void project_save(std::string data_path);
void project_open(std::string data_path);
ui::Image thumbnail_generate(int w, int h);
@@ -125,6 +130,8 @@ class ActionStroke : public Action
public:
std::unique_ptr<Stroke> m_stroke;
std::unique_ptr<uint8_t[]> m_image[6];
glm::ivec4 m_old_box[6];
bool m_old_dirty[6];
glm::ivec4 m_box[6];
bool m_dirty[6];
int m_layer_idx;
@@ -141,6 +148,9 @@ public:
if (!m_image[i])
continue;
m_canvas->m_layers[m_layer_idx].m_dirty_box[i] = m_old_box[i];
m_canvas->m_layers[m_layer_idx].m_dirty_face[i] = m_old_dirty[i];
m_canvas->m_layers[m_layer_idx].m_rtt[i].bindTexture();
glm::vec2 box_sz = m_box[i].zw() - m_box[i].xy();
glTexSubImage2D(GL_TEXTURE_2D, 0, m_box[i].x, m_box[i].y, box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, m_image[i].get());