implement layer bounds optminize function, add history to draw_objects with the right bounds.

This commit is contained in:
2019-01-18 19:03:53 +01:00
parent ff4ce5f379
commit e0bb60980a
6 changed files with 146 additions and 6 deletions

View File

@@ -48,6 +48,29 @@ public:
std::fill_n(image[i].get(), width*height*4, 0);
}
}
void optimize()
{
for (int i = 0; i < 6; i++)
{
if (!m_dirty_face[i] || !image[i])
continue;
auto data = reinterpret_cast<glm::i8vec4*>(image[i].get());
glm::ivec2 bbmin(width, height);
glm::ivec2 bbmax(0);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
if (data[x + y * width].a > 0)
{
bbmin = glm::min(bbmin, { x, y });
bbmax = glm::max(bbmax, { x + 1, y + 1 });
}
}
}
glm::vec2 bbsz = bbmax - bbmin;
}
}
};
void resize(int width, int height);
bool create(int width, int height, std::string name);
@@ -55,6 +78,7 @@ public:
Snapshot snapshot();
void restore(const Snapshot& snap);
void destroy();
void optimize();
};
struct PPIThumb
@@ -155,6 +179,7 @@ public:
static glm::mat4 m_plane_transform[6];
glm::vec2 stencil_offset;
Sampler m_sampler;
Sampler m_sampler_nearest;
Sampler m_sampler_linear;
Sampler m_sampler_brush;
Sampler m_sampler_bg;