diff --git a/src/canvas.cpp b/src/canvas.cpp index 7281f58..0e6c74c 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -3216,10 +3216,10 @@ void Layer::optimize() void Layer::restore(const Snapshot& snap) { - //clear({ 0, 0, 0, 0 }); + clear({ 0, 0, 0, 0 }); for (int i = 0; i < 6; i++) { - if (snap.image[i] == nullptr || snap.m_dirty_face[i] == false) + if (snap.image[i] == nullptr) continue; m_dirty_box[i] = snap.m_dirty_box[i]; @@ -3242,7 +3242,7 @@ void Layer::restore(const Snapshot& snap) } } -Layer::Snapshot Layer::snapshot(glm::vec4 dirty_box[6] /*= nullptr*/, bool dirty_face[6] /*= nullptr*/) +Layer::Snapshot Layer::snapshot(std::array * dirty_box /*= nullptr*/, std::array * dirty_face /*= nullptr*/) { Snapshot snap; static int counter = 0; @@ -3250,8 +3250,8 @@ Layer::Snapshot Layer::snapshot(glm::vec4 dirty_box[6] /*= nullptr*/, bool dirty //glBindFramebuffer(GL_FRAMEBUFFER, 0); for (int i = 0; i < 6; i++) { - snap.m_dirty_box[i] = dirty_box ? dirty_box[i] : m_dirty_box[i]; - snap.m_dirty_face[i] = dirty_face ? dirty_face[i] : m_dirty_face[i]; + snap.m_dirty_box[i] = dirty_box ? dirty_box->at(i) : m_dirty_box[i]; + snap.m_dirty_face[i] = dirty_face ? dirty_face->at(i) : m_dirty_face[i]; if (!snap.m_dirty_face[i]) continue; diff --git a/src/canvas.h b/src/canvas.h index 4711c99..c326fa0 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -71,7 +71,7 @@ public: std::shared_ptr layer; std::unique_ptr mask[6]; std::unique_ptr rgb[6] = SIXPLETTE(0); - bool dirty[6] = SIXPLETTE(false); + std::array dirty = SIXPLETTE(false); glm::vec4 bb[6]; void apply(); }; diff --git a/src/canvas_layer.h b/src/canvas_layer.h index 052da29..213d69d 100644 --- a/src/canvas_layer.h +++ b/src/canvas_layer.h @@ -16,8 +16,8 @@ public: ~Layer() { LOG("LAYER AUTO DESTROY"); destroy(); } uint32_t id; RTT m_rtt[6]; - glm::vec4 m_dirty_box[6] = SIXPLETTE(glm::vec4(0)); - bool m_dirty_face[6] = SIXPLETTE(false); + std::array m_dirty_box = SIXPLETTE(glm::vec4(0)); + std::array m_dirty_face = SIXPLETTE(false); bool m_visible = true; bool m_alpha_locked = false; float m_opacity = 1.f; @@ -29,8 +29,8 @@ public: struct Snapshot { std::unique_ptr image[6] = SIXPLETTE(0); - glm::vec4 m_dirty_box[6] = SIXPLETTE(glm::vec4(0)); - bool m_dirty_face[6] = SIXPLETTE(false); + std::array m_dirty_box = SIXPLETTE(glm::vec4(0)); + std::array m_dirty_face = SIXPLETTE(false); int width = 0; int height = 0; void create(int w, int h); @@ -41,7 +41,7 @@ public: void resize(int width, int height); bool create(int width, int height, std::string name); void clear(const glm::vec4& c); - Snapshot snapshot(glm::vec4 dirty_box[6] = nullptr, bool dirty_face[6] = nullptr); + Snapshot snapshot(std::array* dirty_box = nullptr, std::array* dirty_face = nullptr); void restore(const Snapshot& snap); void destroy(); void optimize(); diff --git a/src/canvas_modes.cpp b/src/canvas_modes.cpp index b34fe7b..56ce510 100644 --- a/src/canvas_modes.cpp +++ b/src/canvas_modes.cpp @@ -1565,6 +1565,8 @@ void CanvasModeFloodFill::on_MouseEvent(MouseEvent* me, glm::vec2& loc) { std::shared_ptr m_layer; std::shared_ptr m_snap; + std::array m_dirty_face = SIXPLETTE(false); + std::array m_dirty_box = SIXPLETTE(glm::vec4(0)); glm::ivec2 m_pos; glm::vec4 m_color; float m_threshold; @@ -1583,6 +1585,8 @@ void CanvasModeFloodFill::on_MouseEvent(MouseEvent* me, glm::vec2& loc) a->m_layer_index = m_layer_index; a->m_threshold = m_threshold; a->m_plane = m_plane; + a->m_dirty_box = m_dirty_box; + a->m_dirty_face = m_dirty_face; return a; } virtual void undo() override @@ -1625,6 +1629,8 @@ void CanvasModeFloodFill::on_MouseEvent(MouseEvent* me, glm::vec2& loc) a->m_layer_index = Canvas::I->m_current_layer_idx; a->m_threshold = m_tool->get_threshold(); a->m_plane = plane; + a->m_dirty_box = plane_data.layer->m_dirty_box; + a->m_dirty_face = plane_data.layer->m_dirty_face; ActionManager::add(a); plane_data.apply(); diff --git a/src/node_panel_layer.cpp b/src/node_panel_layer.cpp index a7709a7..79bf937 100644 --- a/src/node_panel_layer.cpp +++ b/src/node_panel_layer.cpp @@ -400,7 +400,7 @@ void NodePanelLayer::merge(int src_index, int dst_index, bool create_history) } a->m_snap = std::make_shared(); *a->m_snap = Canvas::I->m_layers[dst_index]->snapshot( - Canvas::I->m_layers[src_index]->m_dirty_box, Canvas::I->m_layers[src_index]->m_dirty_face); + &Canvas::I->m_layers[src_index]->m_dirty_box, &Canvas::I->m_layers[src_index]->m_dirty_face); a->m_layer = Canvas::I->m_layers[src_index]; a->m_layer_node = std::static_pointer_cast(m_layers_container->m_children[src_index]); a->m_layer_node->m_selected = false;