Skip to content

Commit e7aeb71

Browse files
cqundefineawesomekling
authored andcommitted
LibWeb: Move WebGL error variable to WebGLRenderingContextBase
Implementations in both WebGL1 and WebGL2 were the same and most probably will stay the same.
1 parent f6f238d commit e7aeb71

File tree

7 files changed

+15
-27
lines changed

7 files changed

+15
-27
lines changed

Libraries/LibWeb/WebGL/WebGL2RenderingContext.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,6 @@ void WebGL2RenderingContext::needs_to_present()
109109
m_canvas_element->paintable()->set_needs_display();
110110
}
111111

112-
void WebGL2RenderingContext::set_error(GLenum error)
113-
{
114-
auto context_error = glGetError();
115-
if (context_error != GL_NO_ERROR)
116-
m_error = context_error;
117-
else
118-
m_error = error;
119-
}
120-
121112
bool WebGL2RenderingContext::is_context_lost() const
122113
{
123114
dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContext::is_context_lost()");

Libraries/LibWeb/WebGL/WebGL2RenderingContext.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ class WebGL2RenderingContext final : public Bindings::PlatformObject
8282
// - clear, drawArrays, or drawElements has been called while the drawing buffer is the currently bound framebuffer
8383
bool m_should_present { true };
8484

85-
GLenum m_error { 0 };
86-
8785
Vector<WebIDL::UnsignedLong> m_enabled_compressed_texture_formats;
8886

8987
// Extensions
@@ -94,8 +92,6 @@ class WebGL2RenderingContext final : public Bindings::PlatformObject
9492
GC::Ptr<Extensions::EXTTextureNorm16> m_ext_texture_norm16;
9593
GC::Ptr<Extensions::WebGLCompressedTextureS3tc> m_webgl_compressed_texture_s3tc_extension;
9694
GC::Ptr<Extensions::WebGLCompressedTextureS3tcSrgb> m_webgl_compressed_texture_s3tc_srgb_extension;
97-
98-
virtual void set_error(GLenum error) override;
9995
};
10096

10197
}

Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,6 @@ void WebGLRenderingContext::needs_to_present()
127127
m_canvas_element->paintable()->set_needs_display();
128128
}
129129

130-
void WebGLRenderingContext::set_error(GLenum error)
131-
{
132-
auto context_error = glGetError();
133-
if (context_error != GL_NO_ERROR)
134-
m_error = context_error;
135-
else
136-
m_error = error;
137-
}
138-
139130
bool WebGLRenderingContext::is_context_lost() const
140131
{
141132
dbgln_if(WEBGL_CONTEXT_DEBUG, "WebGLRenderingContext::is_context_lost()");

Libraries/LibWeb/WebGL/WebGLRenderingContext.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ class WebGLRenderingContext final : public Bindings::PlatformObject
8181
// - clear, drawArrays, or drawElements has been called while the drawing buffer is the currently bound framebuffer
8282
bool m_should_present { true };
8383

84-
GLenum m_error { 0 };
85-
8684
Vector<WebIDL::UnsignedLong> m_enabled_compressed_texture_formats;
8785

8886
// Extensions
@@ -94,8 +92,6 @@ class WebGLRenderingContext final : public Bindings::PlatformObject
9492
GC::Ptr<Extensions::WebGLCompressedTextureS3tc> m_webgl_compressed_texture_s3tc_extension;
9593
GC::Ptr<Extensions::WebGLCompressedTextureS3tcSrgb> m_webgl_compressed_texture_s3tc_srgb_extension;
9694
GC::Ptr<Extensions::WebGLDrawBuffers> m_webgl_draw_buffers_extension;
97-
98-
virtual void set_error(GLenum error) override;
9995
};
10096

10197
void fire_webgl_context_event(HTML::HTMLCanvasElement& canvas_element, FlyString const& type);

Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,13 @@ Optional<WebGLRenderingContextBase::ConvertedTexture> WebGLRenderingContextBase:
195195
};
196196
}
197197

198+
void WebGLRenderingContextBase::set_error(GLenum error)
199+
{
200+
auto context_error = glGetError();
201+
if (context_error != GL_NO_ERROR)
202+
m_error = context_error;
203+
else
204+
m_error = error;
205+
}
206+
198207
}

Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ class WebGLRenderingContextBase {
138138
return result;
139139
}
140140

141+
void set_error(GLenum error);
142+
141143
// UNPACK_FLIP_Y_WEBGL of type boolean
142144
// If set, then during any subsequent calls to texImage2D or texSubImage2D, the source data is flipped along
143145
// the vertical axis, so that conceptually the last row is the first one transferred. The initial value is false.
@@ -149,6 +151,9 @@ class WebGLRenderingContextBase {
149151
// if present, is multiplied into the color channels during the data transfer. The initial value is false.
150152
// Any non-zero value is interpreted as true.
151153
bool m_unpack_premultiply_alpha { false };
154+
155+
private:
156+
GLenum m_error { 0 };
152157
};
153158

154159
}

Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class WebGLRenderingContextImpl : public WebGLRenderingContextBase {
2828

2929
virtual void present() = 0;
3030
virtual void needs_to_present() = 0;
31-
virtual void set_error(GLenum) = 0;
31+
3232
void active_texture(WebIDL::UnsignedLong texture);
3333
void attach_shader(GC::Root<WebGLProgram> program, GC::Root<WebGLShader> shader);
3434
void bind_attrib_location(GC::Root<WebGLProgram> program, WebIDL::UnsignedLong index, String name);

0 commit comments

Comments
 (0)