Codechange: Simplify some CodeQL-flagged trivial switches

This commit is contained in:
Tyler Trahan
2023-03-25 15:40:59 -04:00
parent a15e584e40
commit 066ae6f3fb
5 changed files with 25 additions and 44 deletions

View File

@@ -955,14 +955,10 @@ bool OpenGLBackend::Resize(int w, int h, bool force)
_glActiveTexture(GL_TEXTURE0);
_glBindTexture(GL_TEXTURE_2D, this->vid_texture);
switch (bpp) {
case 8:
_glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, nullptr);
break;
default:
_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
break;
if (bpp == 8) {
_glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, nullptr);
} else {
_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, nullptr);
}
_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
@@ -1224,14 +1220,10 @@ void OpenGLBackend::ReleaseVideoBuffer(const Rect &update_rect)
_glActiveTexture(GL_TEXTURE0);
_glBindTexture(GL_TEXTURE_2D, this->vid_texture);
_glPixelStorei(GL_UNPACK_ROW_LENGTH, _screen.pitch);
switch (BlitterFactory::GetCurrentBlitter()->GetScreenDepth()) {
case 8:
_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_RED, GL_UNSIGNED_BYTE, (GLvoid *)(size_t)(update_rect.top * _screen.pitch + update_rect.left));
break;
default:
_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (GLvoid *)(size_t)(update_rect.top * _screen.pitch * 4 + update_rect.left * 4));
break;
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 8) {
_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_RED, GL_UNSIGNED_BYTE, (GLvoid*)(size_t)(update_rect.top * _screen.pitch + update_rect.left));
} else {
_glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (GLvoid*)(size_t)(update_rect.top * _screen.pitch * 4 + update_rect.left * 4));
}
#ifndef NO_GL_BUFFER_SYNC