Explorar o código

LibGL: Remove `TextureUnit::unbind_texture()`

Jelle Raaijmakers %!s(int64=3) %!d(string=hai) anos
pai
achega
bed0f3466a

+ 2 - 2
Userland/Libraries/LibGL/SoftwareGLContext.cpp

@@ -685,7 +685,7 @@ void SoftwareGLContext::gl_delete_textures(GLsizei n, const GLuint* textures)
         // Check all texture units
         for (auto& texture_unit : m_texture_units) {
             if (texture_object->value == texture_unit.bound_texture())
-                texture_unit.unbind_texture(GL_TEXTURE_2D);
+                texture_unit.bind_texture_to_target(GL_TEXTURE_2D, nullptr);
         }
 
         m_allocated_textures.remove(name);
@@ -1386,7 +1386,7 @@ void SoftwareGLContext::gl_bind_texture(GLenum target, GLuint texture)
     if (texture == 0) {
         switch (target) {
         case GL_TEXTURE_2D:
-            m_active_texture_unit->unbind_texture(target);
+            m_active_texture_unit->bind_texture_to_target(target, nullptr);
             return;
         default:
             VERIFY_NOT_REACHED();

+ 7 - 14
Userland/Libraries/LibGL/Tex/TextureUnit.cpp

@@ -11,6 +11,13 @@ namespace GL {
 
 void TextureUnit::bind_texture_to_target(GLenum texture_target, const RefPtr<Texture>& texture)
 {
+    if (!texture) {
+        m_texture_target_2d = nullptr;
+        m_currently_bound_target = GL_NONE;
+        m_currently_bound_texture = nullptr;
+        return;
+    }
+
     switch (texture_target) {
     case GL_TEXTURE_2D:
         m_texture_target_2d = static_ptr_cast<Texture2D>(texture);
@@ -22,18 +29,4 @@ void TextureUnit::bind_texture_to_target(GLenum texture_target, const RefPtr<Tex
     }
 }
 
-void TextureUnit::unbind_texture(GLenum texture_target)
-{
-    switch (texture_target) {
-    case GL_TEXTURE_2D:
-        m_texture_target_2d = nullptr;
-        m_currently_bound_target = GL_NONE;
-        break;
-    default:
-        VERIFY_NOT_REACHED();
-    }
-
-    m_currently_bound_texture = nullptr;
-}
-
 }

+ 0 - 1
Userland/Libraries/LibGL/Tex/TextureUnit.h

@@ -16,7 +16,6 @@ public:
     TextureUnit() = default;
 
     void bind_texture_to_target(GLenum texture_target, const RefPtr<Texture>& texture);
-    void unbind_texture(GLenum texture_target);
 
     RefPtr<Texture2D>& bound_texture_2d() const { return m_texture_target_2d; }
     RefPtr<Texture>& bound_texture() const { return m_currently_bound_texture; }