1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:27:43 +00:00

LibGL: Remove image storage from MipMap

Images are stored on the device side. Texture2D and MipMap are now only
used to store imformation about the texture and reference to the device
image.
This commit is contained in:
Stephan Unverwerth 2021-12-23 13:52:19 +01:00 committed by Brian Gianforcaro
parent 4c944eaa41
commit 5e9d99474d
3 changed files with 34 additions and 114 deletions

View file

@ -7,43 +7,19 @@
#pragma once
#include <AK/Vector.h>
#include <LibGL/GL/gl.h>
#include <LibGfx/Vector4.h>
namespace GL {
class MipMap {
public:
MipMap() = default;
~MipMap() = default;
void set_width(GLsizei width) { m_width = width; }
void set_height(GLsizei height) { m_height = height; }
GLsizei width() const { return m_width; }
GLsizei height() const { return m_height; }
Vector<u32>& pixel_data() { return m_pixel_data; }
const Vector<u32>& pixel_data() const { return m_pixel_data; }
FloatVector4 texel(unsigned x, unsigned y) const
{
if (x >= (unsigned)m_width || y >= (unsigned)m_height)
return { 0, 0, 0, 0 };
u32 texel = m_pixel_data.at(y * m_width + x);
return {
((texel >> 16) & 0xff) / 255.f,
((texel >> 8) & 0xff) / 255.f,
(texel & 0xff) / 255.f,
((texel >> 24) & 0xff) / 255.f
};
}
private:
GLsizei m_width { 0 };
GLsizei m_height { 0 };
Vector<u32> m_pixel_data;
};
}