Skip to content

Commit 7fa2e79

Browse files
gmtabgianfo
authored andcommitted
LibGL: Simplify glDrawPixels checks and reduce debug spam
1 parent a1fb16e commit 7fa2e79

File tree

2 files changed

+14
-45
lines changed

2 files changed

+14
-45
lines changed

Userland/Libraries/LibGL/GL/gl.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ extern "C" {
170170

171171
// Format enums
172172
#define GL_COLOR_INDEX 0x1900
173-
#define GL_LUMINANCE 0x1909
174-
#define GL_LUMINANCE_ALPHA 0x190A
175-
#define GL_BITMAP 0x1A00
176173
#define GL_STENCIL_INDEX 0x1901
177174
#define GL_DEPTH_COMPONENT 0x1902
178175
#define GL_RED 0x1903
@@ -181,6 +178,11 @@ extern "C" {
181178
#define GL_ALPHA 0x1906
182179
#define GL_RGB 0x1907
183180
#define GL_RGBA 0x1908
181+
#define GL_LUMINANCE 0x1909
182+
#define GL_LUMINANCE_ALPHA 0x190A
183+
#define GL_BGR 0x190B
184+
#define GL_BGRA 0x190C
185+
#define GL_BITMAP 0x1A00
184186

185187
// Lighting related defines
186188
#define GL_LIGHTING 0x0B50
@@ -208,12 +210,6 @@ extern "C" {
208210
#define GL_LINE 0x1B01
209211
#define GL_FILL 0x1B02
210212

211-
// Pixel formats
212-
#define GL_RGB 0x1907
213-
#define GL_RGBA 0x1908
214-
#define GL_BGR 0x190B
215-
#define GL_BGRA 0x190C
216-
217213
// Source pixel data format
218214
#define GL_UNSIGNED_BYTE 0x1401
219215
#define GL_UNSIGNED_BYTE_3_3_2 0x8032

Userland/Libraries/LibGL/SoftwareGLContext.cpp

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,41 +2064,11 @@ void SoftwareGLContext::gl_draw_pixels(GLsizei width, GLsizei height, GLenum for
20642064
{
20652065
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_draw_pixels, width, height, format, type, data);
20662066

2067-
RETURN_WITH_ERROR_IF(!(format == GL_COLOR_INDEX
2068-
|| format == GL_STENCIL_INDEX
2069-
|| format == GL_DEPTH_COMPONENT
2070-
|| format == GL_RGBA
2071-
|| format == GL_BGRA
2072-
|| format == GL_RED
2073-
|| format == GL_GREEN
2074-
|| format == GL_BLUE
2075-
|| format == GL_ALPHA
2076-
|| format == GL_RGB
2077-
|| format == GL_BGR
2078-
|| format == GL_LUMINANCE
2079-
|| format == GL_LUMINANCE_ALPHA),
2080-
GL_INVALID_ENUM);
2067+
RETURN_WITH_ERROR_IF(format < GL_COLOR_INDEX || format > GL_BGRA, GL_INVALID_ENUM);
20812068

2082-
RETURN_WITH_ERROR_IF(!(type == GL_UNSIGNED_BYTE
2083-
|| type == GL_BYTE
2084-
|| type == GL_BITMAP
2085-
|| type == GL_UNSIGNED_SHORT
2086-
|| type == GL_SHORT
2087-
|| type == GL_UNSIGNED_INT
2088-
|| type == GL_INT
2089-
|| type == GL_FLOAT
2090-
|| type == GL_UNSIGNED_BYTE_3_3_2
2091-
|| type == GL_UNSIGNED_BYTE_2_3_3_REV
2092-
|| type == GL_UNSIGNED_SHORT_5_6_5
2093-
|| type == GL_UNSIGNED_SHORT_5_6_5_REV
2094-
|| type == GL_UNSIGNED_SHORT_4_4_4_4
2095-
|| type == GL_UNSIGNED_SHORT_4_4_4_4_REV
2096-
|| type == GL_UNSIGNED_SHORT_5_5_5_1
2097-
|| type == GL_UNSIGNED_SHORT_1_5_5_5_REV
2098-
|| type == GL_UNSIGNED_INT_8_8_8_8
2099-
|| type == GL_UNSIGNED_INT_8_8_8_8_REV
2100-
|| type == GL_UNSIGNED_INT_10_10_10_2
2101-
|| type == GL_UNSIGNED_INT_2_10_10_10_REV),
2069+
RETURN_WITH_ERROR_IF((type < GL_BYTE || type > GL_FLOAT)
2070+
&& (type < GL_UNSIGNED_BYTE_3_3_2 || type > GL_UNSIGNED_INT_10_10_10_2)
2071+
&& (type < GL_UNSIGNED_BYTE_2_3_3_REV || type > GL_UNSIGNED_INT_2_10_10_10_REV),
21022072
GL_INVALID_ENUM);
21032073

21042074
RETURN_WITH_ERROR_IF(type == GL_BITMAP && !(format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX), GL_INVALID_ENUM);
@@ -2139,8 +2109,11 @@ void SoftwareGLContext::gl_draw_pixels(GLsizei width, GLsizei height, GLenum for
21392109
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
21402110

21412111
// FIXME: we only support RGBA + GL_UNSIGNED_BYTE, implement all the others!
2142-
if (format != GL_RGBA || type != GL_UNSIGNED_BYTE) {
2143-
dbgln("gl_draw_pixels: unsupported format {:#x} or type {:#x}", format, type);
2112+
if (format != GL_RGBA) {
2113+
dbgln_if(GL_DEBUG, "gl_draw_pixels(): support for format {:#x} not implemented", format);
2114+
return;
2115+
} else if (type != GL_UNSIGNED_BYTE) {
2116+
dbgln_if(GL_DEBUG, "gl_draw_pixels(): support for type {:#x} not implemented", type);
21442117
return;
21452118
}
21462119

0 commit comments

Comments
 (0)