implement action redo
This commit is contained in:
@@ -160,6 +160,35 @@ void ui::Canvas::snap_history(const std::vector<int>& planes)
|
||||
action->clear_layer = true;
|
||||
ActionManager::add(action);
|
||||
}
|
||||
ui::ActionStroke* ui::Canvas::create_action(int layer)
|
||||
{
|
||||
auto action = new ActionStroke;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (!m_layers[layer].m_dirty_face[i])
|
||||
continue; // no stroke on this face, skip it
|
||||
|
||||
m_layers[layer].m_rtt[i].bindFramebuffer();
|
||||
|
||||
// save image before commit
|
||||
glm::vec2 box_or = xy(m_layers[layer].m_dirty_box[i]);
|
||||
glm::vec2 box_sz = zw(m_layers[layer].m_dirty_box[i]) - xy(m_layers[layer].m_dirty_box[i]);
|
||||
action->m_image[i] = std::make_unique<uint8_t[]>(box_sz.x * box_sz.y * 4);
|
||||
glReadPixels(box_or.x, box_or.y, box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, action->m_image[i].get());
|
||||
|
||||
action->m_box[i] = m_layers[layer].m_dirty_box[i];
|
||||
action->m_old_box[i] = m_layers[layer].m_dirty_box[i];
|
||||
action->m_old_dirty[i] = m_layers[layer].m_dirty_face[i];
|
||||
|
||||
m_layers[layer].m_rtt[i].unbindFramebuffer();
|
||||
}
|
||||
// save history
|
||||
action->m_layer_idx = layer;
|
||||
action->m_canvas = this;
|
||||
action->m_stroke = std::move(m_current_stroke);
|
||||
action->clear_layer = true;
|
||||
return action;
|
||||
}
|
||||
void ui::Canvas::stroke_end()
|
||||
{
|
||||
if (!m_current_stroke)
|
||||
|
||||
Reference in New Issue
Block a user