fix usage of i8vec4 instead of u8vec4, fix grid commit bounds

This commit is contained in:
2019-01-20 11:57:09 +01:00
parent c66bc1f1d7
commit 2154396c6b
5 changed files with 44 additions and 21 deletions

View File

@@ -54,7 +54,7 @@ public:
{
if (!m_dirty_face[i] || !image[i])
continue;
auto data = reinterpret_cast<glm::i8vec4*>(image[i].get());
auto data = reinterpret_cast<glm::u8vec4*>(image[i].get());
glm::ivec2 bbmin(width, height);
glm::ivec2 bbmax(0);
for (int y = 0; y < height; y++)
@@ -287,6 +287,7 @@ public:
bool clear_layer = false;
int m_layer_idx;
Canvas* m_canvas;
ActionStroke() = default;
virtual void run() override
{
@@ -309,10 +310,17 @@ public:
m_canvas->m_layers[m_layer_idx].m_dirty_box[i] = m_old_box[i];
m_canvas->m_layers[m_layer_idx].m_dirty_face[i] = m_old_dirty[i];
m_canvas->m_layers[m_layer_idx].m_rtt[i].bindTexture();
glm::vec2 box_sz = zw(m_box[i]) - xy(m_box[i]);
glTexSubImage2D(GL_TEXTURE_2D, 0, (int)m_box[i].x, (int)m_box[i].y, (int)box_sz.x, (int)box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, m_image[i].get());
m_canvas->m_layers[m_layer_idx].m_rtt[i].unbindTexture();
if (box_sz.x > 0 && box_sz.y > 0 && box_sz.x <= m_canvas->m_layers[m_layer_idx].w && box_sz.y <= m_canvas->m_layers[m_layer_idx].h)
{
m_canvas->m_layers[m_layer_idx].m_rtt[i].bindTexture();
glTexSubImage2D(GL_TEXTURE_2D, 0, (int)m_box[i].x, (int)m_box[i].y, (int)box_sz.x, (int)box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, m_image[i].get());
m_canvas->m_layers[m_layer_idx].m_rtt[i].unbindTexture();
}
else
{
LOG("undo invalid box size (%d, %d)", (int)box_sz.x, (int)box_sz.y);
}
}
}
virtual size_t memory() override