improve dialog browse, wrap ui task for every Node method that modifies the children list, update the ui every time the scene tree changes, restore fps and stylus state on win, fix bucket tool, fix snapshop restore, init in ui thread

This commit is contained in:
2019-07-10 21:08:14 +02:00
parent 4cbf0c47b4
commit 48c39c4ef2
10 changed files with 293 additions and 131 deletions

View File

@@ -1446,6 +1446,7 @@ void Canvas::FloodData::apply()
rtt.unbindTexture();
});
layer->m_dirty_face[plane] = true;
layer->m_dirty_box[plane] = box_union(layer->m_dirty_box[plane], bb[plane]);
}
}
@@ -2413,6 +2414,7 @@ bool Canvas::project_save_thread(std::string file_path)
fwrite(&m_layers[i]->m_visible, sizeof(bool), 1, fp);
}
m_layers[i]->optimize();
auto snap = m_layers[i]->snapshot();
for (int plane_index = 0; plane_index < 6; plane_index++)
{
@@ -2562,6 +2564,9 @@ bool Canvas::project_open_thread(std::string file_path)
int n_order;
fread(&n_order, sizeof(int), 1, fp);
//if (ppi_header.doc_version.minor > 1)
// n_order = i;
tmp_layers[n_order] = std::make_unique<Layer>();
auto& layer = tmp_layers[n_order];
@@ -3085,8 +3090,12 @@ void Layer::restore(const Snapshot& snap)
clear({ 0, 0, 0, 0 });
for (int i = 0; i < 6; i++)
{
if (snap.image[i] == nullptr)
if (snap.image[i] == nullptr || snap.m_dirty_face[i] == false || box_area(snap.m_dirty_box[i]) <= 0)
{
m_dirty_box[i] = glm::vec4(snap.width, snap.height, 0, 0);
m_dirty_face[i] = false;
continue;
}
m_dirty_box[i] = snap.m_dirty_box[i];
m_dirty_face[i] = snap.m_dirty_face[i];
@@ -3115,6 +3124,8 @@ void Layer::restore(const Snapshot& snap)
Layer::Snapshot Layer::snapshot(std::array<glm::vec4, 6> * dirty_box /*= nullptr*/, std::array<bool, 6> * dirty_face /*= nullptr*/)
{
Snapshot snap;
snap.width = w;
snap.height = h;
for (int i = 0; i < 6; i++)
{
snap.m_dirty_box[i] = dirty_box ? dirty_box->at(i) : m_dirty_box[i];