Skip to content

Commit

Permalink
Different pixel formats are handled by different draw target
Browse files Browse the repository at this point in the history
implementations
  • Loading branch information
thesourcehim committed Feb 14, 2024
1 parent 21cceaf commit 7529f6b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
29 changes: 22 additions & 7 deletions desmume/src/frontend/modules/osd/agg/aggdraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,34 @@ static void Agg_init_fonts()

AggDraw_Desmume aggDraw;

T_AGG_RGBA agg_targetScreen(0, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT*2, 1024);
T_AGG_RGBA agg_targetScreen_32bit(0, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT*2, GPU_FRAMEBUFFER_NATIVE_WIDTH*4);
T_AGG_RGB555 agg_targetScreen_16bit(0, GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT*2, GPU_FRAMEBUFFER_NATIVE_WIDTH*2);

static std::vector<u32> luaBuffer(GPU_FRAMEBUFFER_NATIVE_WIDTH*GPU_FRAMEBUFFER_NATIVE_HEIGHT*2);
T_AGG_RGBA agg_targetLua((u8*)luaBuffer.data(), GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT*2, 1024);
T_AGG_RGBA agg_targetLua((u8*)luaBuffer.data(), GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT*2, GPU_FRAMEBUFFER_NATIVE_WIDTH*4);

static std::vector<u32> hudBuffer(GPU_FRAMEBUFFER_NATIVE_WIDTH*GPU_FRAMEBUFFER_NATIVE_HEIGHT*2);
T_AGG_RGBA agg_targetHud((u8*)hudBuffer.data(), GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT*2, 1024);
T_AGG_RGBA agg_targetHud((u8*)hudBuffer.data(), GPU_FRAMEBUFFER_NATIVE_WIDTH, GPU_FRAMEBUFFER_NATIVE_HEIGHT*2, GPU_FRAMEBUFFER_NATIVE_WIDTH*4);

static AggDrawTarget* targets[] = {
&agg_targetScreen,
&agg_targetScreen_32bit,
&agg_targetHud,
&agg_targetLua,
};

void Agg_init()
{
Agg_init_fonts();
aggDraw.screenBytesPerPixel = 4;
switch(aggDraw.screenBytesPerPixel)
{
case 2:
targets[0]=&agg_targetScreen_16bit;
break;
case 4:
targets[0]=&agg_targetScreen_32bit;
break;
}

aggDraw.screen = targets[0];
aggDraw.hud = targets[1];
aggDraw.lua = targets[2];
Expand All @@ -146,14 +156,19 @@ void Agg_init()
//and the more clever compositing isnt supported in non-windows
#ifdef WIN32
if(CommonSettings.single_core())
aggDraw.hud = &agg_targetScreen;
aggDraw.hud = aggDraw.screen;
#else
aggDraw.hud = &agg_targetScreen;
aggDraw.hud = aggDraw.screen;
#endif

aggDraw.hud->setFont("verdana18_bold");
}

AggDraw_Desmume::AggDraw_Desmume()
{
screenBytesPerPixel = 4;
}

void AggDraw_Desmume::setTarget(AggTarget newTarget)
{
target = targets[newTarget];
Expand Down
1 change: 1 addition & 0 deletions desmume/src/frontend/modules/osd/agg/aggdraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ enum AggTarget
class AggDraw_Desmume : public AggDraw
{
public:
AggDraw_Desmume();
void setTarget(AggTarget newTarget);
//void composite(void* dest);

Expand Down
7 changes: 4 additions & 3 deletions desmume/src/frontend/posix/gtk/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3086,6 +3086,10 @@ common_gtk_main(GApplication *app, gpointer user_data)

/* Init the hud / osd stuff */
#ifdef HAVE_LIBAGG
SDL_DisplayMode cur_mode;
if(!SDL_GetCurrentDisplayMode(0, &cur_mode))
aggDraw.screenBytesPerPixel = SDL_BYTESPERPIXEL(cur_mode.format);

Desmume_InitOnce();
Hud.reset();
osd = new OSDCLASS(-1);
Expand Down Expand Up @@ -3165,9 +3169,6 @@ common_gtk_main(GApplication *app, gpointer user_data)
else
osd->useVectorFonts=false;
#endif
SDL_DisplayMode cur_mode;
if(!SDL_GetCurrentDisplayMode(0, &cur_mode))
aggDraw.screenBytesPerPixel = SDL_BYTESPERPIXEL(cur_mode.format);
Agg_setCustomSize(real_framebuffer_width, real_framebuffer_height*2);
osd->scale=gpu_scale_factor;
HudLoadLayout();
Expand Down

0 comments on commit 7529f6b

Please sign in to comment.