improve grid panel
This commit is contained in:
@@ -161,8 +161,11 @@ void Canvas::snap_history(const std::vector<int>& planes)
|
||||
// save image before commit
|
||||
glm::vec2 box_or = xy(m_layers[m_current_layer_idx].m_dirty_box[i]);
|
||||
glm::vec2 box_sz = zw(m_layers[m_current_layer_idx].m_dirty_box[i]) - xy(m_layers[m_current_layer_idx].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());
|
||||
if (box_sz.x > 0 && box_sz.y > 0)
|
||||
{
|
||||
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[m_current_layer_idx].m_dirty_box[i];
|
||||
action->m_old_box[i] = m_layers[m_current_layer_idx].m_dirty_box[i];
|
||||
@@ -190,8 +193,11 @@ ActionStroke* Canvas::create_action(int layer)
|
||||
// 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());
|
||||
if (box_sz.x > 0 && box_sz.y > 0)
|
||||
{
|
||||
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];
|
||||
@@ -2231,15 +2237,16 @@ void Canvas::draw_objects(std::function<void(const glm::mat4& camera, const glm:
|
||||
m_tmp[i].unbindFramebuffer();
|
||||
|
||||
glm::vec4 bounds = m_tmp[i].calc_bounds();
|
||||
glm::vec2 box_sz = zw(bounds) - xy(bounds);
|
||||
if (box_sz.x <= 0 || box_sz.y <= 0)
|
||||
continue;
|
||||
|
||||
layer.m_rtt[i].bindFramebuffer();
|
||||
|
||||
// save image before commit
|
||||
action->m_image[i] = std::make_unique<uint8_t[]>(box_sz.x * box_sz.y * 4);
|
||||
glReadPixels(bounds.x, bounds.y, box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, action->m_image[i].get());
|
||||
glm::vec2 box_sz = zw(bounds) - xy(bounds);
|
||||
if (box_sz.x > 0 && box_sz.y > 0)
|
||||
{
|
||||
action->m_image[i] = std::make_unique<uint8_t[]>(box_sz.x * box_sz.y * 4);
|
||||
glReadPixels(bounds.x, bounds.y, box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, action->m_image[i].get());
|
||||
}
|
||||
|
||||
action->m_box[i] = bounds;
|
||||
action->m_old_box[i] = layer.m_dirty_box[i];
|
||||
|
||||
Reference in New Issue
Block a user