Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

sdl: Remove usage of SDL_SoftStretch

SDL 2 lets us take advantage of a fixed logical resolution,
where the renderer scales content up or down automatically.

Relative mouse motion is also affected by renderer scaling
by default (see SDL_HINT_MOUSE_RELATIVE_SCALING).

If window zoom has been enabled from the command line,
set scaling quality to "nearest pixel sampling" instead
of "best" to allow pixel peeping.

Change-Id: I4e5c19d36b55c985c26ac5ae64c4a6b8dd9b308d

+21 -43
+2 -4
firmware/target/hosted/sdl/button-sdl.c
··· 284 284 case SDL_MOUSEMOTION: 285 285 if (event->motion.state & SDL_BUTTON(1)) 286 286 { 287 - int x = event->motion.x / display_zoom; 288 - int y = event->motion.y / display_zoom; 287 + int x = event->motion.x; 288 + int y = event->motion.y; 289 289 touchscreen_event(x, y); 290 290 } 291 291 break; ··· 295 295 case SDL_MOUSEBUTTONDOWN: 296 296 { 297 297 SDL_MouseButtonEvent *mev = &event->button; 298 - mev->x /= display_zoom; 299 - mev->y /= display_zoom; 300 298 mouse_event(mev, event->type == SDL_MOUSEBUTTONUP); 301 299 break; 302 300 }
+2 -6
firmware/target/hosted/sdl/lcd-bitmap.c
··· 183 183 void lcd_init_device(void) 184 184 { 185 185 #if LCD_DEPTH >= 16 186 - lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 187 - SIM_LCD_WIDTH * display_zoom, 188 - SIM_LCD_HEIGHT * display_zoom, 186 + lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, SIM_LCD_WIDTH, SIM_LCD_HEIGHT, 189 187 LCD_DEPTH, 0, 0, 0, 0); 190 188 SDL_SetSurfaceBlendMode(lcd_surface, SDL_BLENDMODE_BLEND); 191 189 #elif LCD_DEPTH <= 8 192 - lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 193 - SIM_LCD_WIDTH * display_zoom, 194 - SIM_LCD_HEIGHT * display_zoom, 190 + lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, SIM_LCD_WIDTH, SIM_LCD_HEIGHT, 195 191 8, 0, 0, 0, 0); 196 192 197 193 #ifdef HAVE_BACKLIGHT
+4 -6
firmware/target/hosted/sdl/lcd-remote-bitmap.c
··· 80 80 { 81 81 if (remote_surface) 82 82 { 83 - if (value > 0) 83 + if (value > 0) 84 84 { 85 85 sdl_set_gradient(remote_surface, &remote_bl_color_dark, 86 86 &remote_bl_color_bright, 0, NUM_SHADES); 87 - } 87 + } 88 88 else 89 89 { 90 90 sdl_set_gradient(remote_surface, &remote_color_dark, ··· 102 102 { 103 103 if (!showremote) 104 104 return; 105 - remote_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 106 - LCD_REMOTE_WIDTH * display_zoom, 107 - LCD_REMOTE_HEIGHT * display_zoom, 108 - 8, 0, 0, 0, 0); 105 + remote_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_REMOTE_WIDTH, 106 + LCD_REMOTE_HEIGHT, 8, 0, 0, 0, 0); 109 107 110 108 sdl_set_gradient(remote_surface, &remote_bl_color_dark, 111 109 &remote_bl_color_bright, 0, NUM_SHADES);
+10 -24
firmware/target/hosted/sdl/lcd-sdl.c
··· 26 26 #include "misc.h" 27 27 28 28 double display_zoom = 1; 29 - 30 29 static bool window_needs_update; 31 30 32 31 void sdl_get_window_dimensions(int *w, int *h) ··· 138 137 src.w = width; 139 138 src.h = height; 140 139 141 - if (display_zoom == 1) { 142 - dest = src; 143 - SDL_BlitSurface(lcd, &src, surface, &dest); 144 - } else { 145 - /* Note: SDL_SoftStretch is currently marked as DO NOT USE 146 - but there are no real alternatives for efficent zooming. */ 147 - dest.x = src.x * display_zoom; 148 - dest.y = src.y * display_zoom; 149 - dest.w = src.w * display_zoom; 150 - dest.h = src.h * display_zoom; 151 - SDL_SoftStretch(lcd, &src, surface, &dest); 152 - } 140 + dest = src; 141 + SDL_BlitSurface(lcd, &src, surface, &dest); 153 142 SDL_FreeSurface(lcd); 154 143 #else 155 144 int x, y; ··· 163 152 if(ymax >= max_y) 164 153 ymax = max_y; 165 154 166 - dest.w = display_zoom; 167 - dest.h = display_zoom; 155 + dest.w = 1; 156 + dest.h = 1; 168 157 169 158 for (x = x_start; x < xmax; x++) { 170 - dest.x = x * display_zoom; 159 + dest.x = x; 171 160 172 161 #ifdef HAVE_LCD_SPLIT 173 162 for (y = y_start; y < MIN(ymax, LCD_SPLIT_POS); y++) { 174 - dest.y = y * display_zoom; 163 + dest.y = y; 175 164 176 165 SDL_FillRect(surface, &dest, (Uint32)(getpixel(x, y) | 0x80)); 177 166 } 178 167 for (y = MAX(y_start, LCD_SPLIT_POS); y < ymax; y++) { 179 - dest.y = (y + LCD_SPLIT_LINES) * display_zoom ; 168 + dest.y = (y + LCD_SPLIT_LINES) ; 180 169 181 170 SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y)); 182 171 } 183 172 #else 184 173 for (y = y_start; y < ymax; y++) { 185 - dest.y = y * display_zoom; 174 + dest.y = y; 186 175 187 176 SDL_FillRect(surface, &dest, (Uint32)getpixel(x, y)); 188 177 } ··· 199 188 if (y_start + height > max_y) 200 189 height = max_y - y_start; 201 190 202 - SDL_Rect src = {x_start * display_zoom, y_start * display_zoom, 203 - width * display_zoom, height * display_zoom}; 204 - SDL_Rect dest= {(ui_x + x_start) * display_zoom, 205 - (ui_y + y_start) * display_zoom, 206 - width * display_zoom, height * display_zoom}; 191 + SDL_Rect src = {x_start, y_start, width, height}; 192 + SDL_Rect dest= {ui_x + x_start, ui_y + y_start, width, height}; 207 193 208 194 uint8_t alpha; 209 195 if (SDL_GetSurfaceAlphaMod(surface,&alpha) == 0 && alpha < 255)
+3 -3
firmware/target/hosted/sdl/system-sdl.c
··· 112 112 if ((sdlRenderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC)) == NULL) 113 113 panicf("%s", SDL_GetError()); 114 114 115 - SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); 116 - SDL_RenderSetLogicalSize(sdlRenderer, width * display_zoom, height * display_zoom); 115 + SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, display_zoom == 1 ? "best" : "nearest"); 116 + SDL_RenderSetLogicalSize(sdlRenderer, width, height); 117 117 118 - if ((gui_surface = SDL_CreateRGBSurface(0, width * display_zoom, height * display_zoom, depth, 118 + if ((gui_surface = SDL_CreateRGBSurface(0, width, height, depth, 119 119 0, 0, 0, 0)) == NULL) 120 120 panicf("%s", SDL_GetError()); 121 121