implement load/unload frames
This commit is contained in:
@@ -118,7 +118,7 @@ void Canvas::clear(const glm::vec4& c/*={0,0,0,1}*/)
|
||||
auto a = new ActionLayerClear;
|
||||
a->m_layer = m_layers[m_current_layer_idx];
|
||||
a->m_frame = layer().m_frame_index;
|
||||
a->m_snap = std::make_shared<Layer::Snapshot>(a->m_layer->snapshot());
|
||||
a->m_snap = std::make_shared<LayerFrame::Snapshot>(a->m_layer->snapshot());
|
||||
a->m_color = c;
|
||||
ActionManager::add(a);
|
||||
|
||||
@@ -1703,7 +1703,7 @@ void Canvas::import_equirectangular_thread(std::string file_path, std::shared_pt
|
||||
auto a = new ActionImportEquirect;
|
||||
a->m_layer = layer;
|
||||
a->m_frame = frame;
|
||||
a->m_snap = std::make_shared<Layer::Snapshot>(layer->snapshot(frame));
|
||||
a->m_snap = std::make_shared<LayerFrame::Snapshot>(layer->snapshot(frame));
|
||||
a->m_path = file_path;
|
||||
ActionManager::add(a);
|
||||
|
||||
@@ -2137,7 +2137,7 @@ bool Canvas::project_save_thread(std::string file_path, bool show_progress)
|
||||
fwrite(&n_layers, sizeof(int), 1, fp);
|
||||
|
||||
int n_frames = std::accumulate(m_layers.begin(), m_layers.end(), 0,
|
||||
[](int tot, auto& l) { return tot + l->m_frames.size(); });
|
||||
[](int tot, auto& l) { return tot + l->frames_count(); });
|
||||
if (ppi_header.doc_version.minor >= 3)
|
||||
fwrite(&n_frames, sizeof(int), 1, fp);
|
||||
|
||||
@@ -2166,14 +2166,17 @@ bool Canvas::project_save_thread(std::string file_path, bool show_progress)
|
||||
int frames = 1;
|
||||
if (ppi_header.doc_version.minor >= 3)
|
||||
{
|
||||
frames = (int)m_layers[i]->m_frames.size();
|
||||
frames = (int)m_layers[i]->frames_count();
|
||||
fwrite(&frames, sizeof(int), 1, fp);
|
||||
}
|
||||
|
||||
for (int fi = 0; fi < frames; fi++)
|
||||
{
|
||||
if (ppi_header.doc_version.minor >= 3)
|
||||
fwrite(&m_layers[i]->m_frames[fi].m_duration, sizeof(int), 1, fp);
|
||||
{
|
||||
int duration = m_layers[i]->frame_duration(fi);
|
||||
fwrite(&duration, sizeof(int), 1, fp);
|
||||
}
|
||||
|
||||
m_layers[i]->optimize(fi);
|
||||
auto snap = m_layers[i]->snapshot(fi);
|
||||
@@ -2315,7 +2318,7 @@ bool Canvas::project_open_thread(std::string file_path)
|
||||
fread(&n_frames, sizeof(int), 1, fp);
|
||||
|
||||
const int bytes = m_width * m_height * 4;
|
||||
Layer::Snapshot snap;
|
||||
LayerFrame::Snapshot snap;
|
||||
snap.create(m_width, m_height); // allocate single data, no box should be bigger
|
||||
|
||||
int progress = 0;
|
||||
@@ -2365,7 +2368,10 @@ bool Canvas::project_open_thread(std::string file_path)
|
||||
if (fi > 0)
|
||||
layer->add_frame();
|
||||
if (ppi_header.doc_version.minor >= 3)
|
||||
fread(&layer->m_frames[fi].m_duration, sizeof(int), 1, fp);
|
||||
{
|
||||
int duration = layer->frame_duration(fi);
|
||||
fread(&duration, sizeof(int), 1, fp);
|
||||
}
|
||||
snap.clear();
|
||||
for (int plane_index = 0; plane_index < 6; plane_index++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user