Skip to content

Commit

Permalink
merge gs renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
henkwiedig committed Dec 28, 2024
1 parent 7dd36c8 commit 43c264e
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 474 deletions.
36 changes: 16 additions & 20 deletions osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
// #include <X11/Xatom.h>
// #include <stdio.h>
// #include <stdbool.h>
#if defined(_x86)
#include "osd/util/Render_x86.c"
#elif defined(__ROCKCHIP__)
#include "osd/util/Render_Rockchip.c"
#endif
#include "osd/util/Render_gs.c"
#else
#include "bmp/region.h"
#include "bmp/common.h"
Expand Down Expand Up @@ -686,7 +682,7 @@ int y_end = 500;
void LineDirect(uint8_t* bmpData, uint32_t width, uint32_t height, int x0, int y0, int x1, int y1, uint8_t color, int thickness) {
#if defined(_x86) || defined(__ROCKCHIP__)

drawLine_x86(x0, y0, x1, y1, getcolor(color), thickness, false);
drawLineGS(x0, y0, x1, y1, getcolor(color), thickness, false);
#else
drawLineI4( bmpData, width, height, x0, y0, x1, y1, color, thickness);
#endif
Expand All @@ -695,7 +691,7 @@ int y_end = 500;

void LineTranspose(uint8_t* bmpData, int posX0, int posY0, int posX1, int posY1, uint8_t color, int thickness) {
#if defined(_x86) || defined(__ROCKCHIP__)
drawLine_x86(posX0, posY0, posX1, posY1, getcolor(color), thickness, true);
drawLine(posX0, posY0, posX1, posY1, getcolor(color), thickness, true);
#else
drawLine( bmpData, posX0, posY0, posX1, posY1, color, thickness);
#endif
Expand Down Expand Up @@ -956,7 +952,7 @@ void LineTranspose(uint8_t* bmpData, int posX0, int posY0, int posX1, int posY1,
uint32_t color = getcolor(COLOR_YELLOW);
if ((-50 < last_pitch) && (last_pitch <50))
color = getcolor(COLOR_WHITE);
drawText_x86(buffer, start_x + width_ladder*2.5 - spacing/3, y + osd_font_size/2 - 4, color, osd_font_size, true,1);
drawText(buffer, start_x + width_ladder*2.5 - spacing/3, y + osd_font_size/2 - 4, color, osd_font_size, true,1);
#endif

if (AHI_Enabled==3){//Draw home
Expand Down Expand Up @@ -1026,7 +1022,7 @@ void LineTranspose(uint8_t* bmpData, int posX0, int posY0, int posX1, int posY1,
}
}
#if defined(_x86) || defined(__ROCKCHIP__)
Render_x86_rect(bmpBuff.pData,bmpBuff.u32Width, bmpBuff.u32Height,xR,yR,xR,yR,s_width,s_height);
Render_rect(bmpBuff.pData,bmpBuff.u32Width, bmpBuff.u32Height,xR,yR,xR,yR,s_width,s_height);
#endif

}
Expand Down Expand Up @@ -1703,8 +1699,8 @@ static void draw_screenBMP(){
bmp_x86=bmpBuff.pData;

if (DrawOSD){
//ClearScreen_x86();
Render_x86(bmp_x86,bmpBuff.u32Width, bmpBuff.u32Height);
//ClearScreen();
Render(bmp_x86,bmpBuff.u32Width, bmpBuff.u32Height);

if (AHI_Enabled==2)
draw_AHI();
Expand All @@ -1717,7 +1713,7 @@ static void draw_screenBMP(){
if (strlen(air_unit_info_msg)>1){
int osd_font_size=osds[FULL_OVERLAY_ID].size - 6; //Some offset needed to keep the same with air rendering
uint64_t timems=get_time_ms();
int width=getTextWidth_x86(air_unit_info_msg,osd_font_size);
int width=getTextWidth(air_unit_info_msg,osd_font_size);

int posX=0,posY=0;
if (msg_layout%4==0)// left
Expand All @@ -1730,10 +1726,10 @@ static void draw_screenBMP(){
posX=20 + ((timems/16)%(bmpBuff.u32Width - width - 40))& ~1;
posY=(msg_layout/4)== 0 ? osd_font_size : (bmpBuff.u32Height ) - 6;//Uppper or lower line

drawText_x86(air_unit_info_msg, posX , posY, getcolor(msg_colour), /*font_size*/ osd_font_size, false,0);
drawText(air_unit_info_msg, posX , posY, getcolor(msg_colour), /*font_size*/ osd_font_size, false,0);
}

FlushDrawing_x86();
FlushDrawing();
}


Expand Down Expand Up @@ -1782,7 +1778,7 @@ static void clear_screen()
{
if (cntr++<0 )
return ;
//ClearScreen_x86();
//ClearScreen();
//BetaFlight needs this. INAV can be configured to skip it
if (!DrawOSD || font_pages == 1 || font_pages>2 || (get_time_ms() - LastCleared)>300) {//no faster than 0.5 per second
memset(character_map, 0, sizeof(character_map));
Expand Down Expand Up @@ -2076,7 +2072,7 @@ static void InitMSPHook(){
majestic_height=height;
#if defined(_x86) || defined(__ROCKCHIP__)
if (DrawOSD)
Init_x86(&OVERLAY_WIDTH, &OVERLAY_HEIGHT);
Init(&OVERLAY_WIDTH, &OVERLAY_HEIGHT);
height=OVERLAY_HEIGHT;
printf("OSD is %ix%i pixels\n",OVERLAY_WIDTH,OVERLAY_HEIGHT);
#endif
Expand Down Expand Up @@ -2248,9 +2244,9 @@ On sigmastar the BMP row stride is aligned to 8 bytes, that is 16 pixels in PIXE
else
Convert1555ToRGBA( bitmap.pData, rgbaData, bitmap.u32Width, bitmap.u32Height);

Render_x86(rgbaData,bitmap.u32Width, bitmap.u32Height);
//Render_x86(bitmapFnt.pData,bitmapFnt.u32Width,700);//test
FlushDrawing_x86();
Render(rgbaData,bitmap.u32Width, bitmap.u32Height);
//Render(bitmapFnt.pData,bitmapFnt.u32Width,700);//test
FlushDrawing();
free(rgbaData);
//cairo_surface_destroy(image_surface);
//image_surface = NULL;
Expand Down Expand Up @@ -2300,7 +2296,7 @@ static void CloseMSP(){
printf("[%s:%d]RGN_DeInit failed with %#x!\n", __func__, __LINE__, s32Ret);
#endif
#if defined(_x86) || defined(__ROCKCHIP__)
Close_x86();
Close();
#endif

munmap(osds, sizeof(*osds) * MAX_OSD);
Expand Down
Loading

0 comments on commit 43c264e

Please sign in to comment.