From ff4a3e0a5cde9b8ebf3d377f86fd780719d0729d Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 3 Oct 2017 15:16:18 -0700 Subject: [PATCH] Linux Port (CLI and GTK-Glade): Add support for rendering the backlight intensity on the CPU-based display methods. (Related to commits f5c9a36 and 74ba49e.) --- desmume/src/frontend/posix/cli/main.cpp | 14 ++++++++------ .../src/frontend/posix/gtk-glade/callbacks_IO.cpp | 8 +++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/desmume/src/frontend/posix/cli/main.cpp b/desmume/src/frontend/posix/cli/main.cpp index 8c6932a3a..4767683d1 100644 --- a/desmume/src/frontend/posix/cli/main.cpp +++ b/desmume/src/frontend/posix/cli/main.cpp @@ -381,7 +381,7 @@ opengl_Draw(GLuint *texture) { /* Draw the main screen as a textured quad */ glBindTexture(GL_TEXTURE_2D, texture[NDSDisplayID_Main]); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, displayInfo.renderedBuffer[NDSDisplayID_Main]); @@ -397,7 +397,7 @@ opengl_Draw(GLuint *texture) { /* Draw the touch screen as a textured quad */ glBindTexture(GL_TEXTURE_2D, texture[NDSDisplayID_Touch]); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 192, + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, displayInfo.renderedBuffer[NDSDisplayID_Touch]); @@ -429,16 +429,18 @@ resizeWindow_stub (u16 width, u16 height, void *screen_texture) { static void Draw( void) { - SDL_Surface *rawImage; + const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo(); + const size_t pixCount = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT; + ColorspaceApplyIntensityToBuffer16((u16 *)displayInfo.masterNativeBuffer, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]); + ColorspaceApplyIntensityToBuffer16((u16 *)displayInfo.masterNativeBuffer + pixCount, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]); - rawImage = SDL_CreateRGBSurfaceFrom(GPU->GetDisplayInfo().masterNativeBuffer, 256, 384, 16, 512, 0x001F, 0x03E0, 0x7C00, 0); + SDL_Surface *rawImage = SDL_CreateRGBSurfaceFrom(displayInfo.masterNativeBuffer, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2, 16, GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16), 0x001F, 0x03E0, 0x7C00, 0); if(rawImage == NULL) return; SDL_BlitSurface(rawImage, 0, surface, 0); - SDL_UpdateRect(surface, 0, 0, 0, 0); - SDL_FreeSurface(rawImage); + return; } diff --git a/desmume/src/frontend/posix/gtk-glade/callbacks_IO.cpp b/desmume/src/frontend/posix/gtk-glade/callbacks_IO.cpp index 5af33f5e0..ce800142c 100755 --- a/desmume/src/frontend/posix/gtk-glade/callbacks_IO.cpp +++ b/desmume/src/frontend/posix/gtk-glade/callbacks_IO.cpp @@ -117,8 +117,14 @@ static void decode_screen () { int x,y, m, W,H,L,BL; u32 image[RAW_H*2][RAW_W], pix; - u16 * pixel = (u16 *)GPU->GetDisplayInfo().masterNativeBuffer; + + const NDSDisplayInfo &displayInfo = GPU->GetDisplayInfo(); + const size_t pixCount = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT; + u16 * pixel = (u16 *)displayInfo.masterNativeBuffer; u32 * rgb32 = &on_screen_image32[0]; + + ColorspaceApplyIntensityToBuffer16(pixel, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Main]); + ColorspaceApplyIntensityToBuffer16(pixel + pixCount, pixCount, displayInfo.backlightIntensity[NDSDisplayID_Touch]); /* decode colors */ init_pix_col_map();