1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-03 20:11:00 +00:00

unix: support backgrounds for models T and 1

This commit is contained in:
Pavol Rusnak 2018-09-11 16:38:47 +02:00
parent f23f751ab0
commit 8874925fb8
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 21 additions and 13 deletions

View File

@ -22,13 +22,21 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <SDL2/SDL_image.h> #include <SDL2/SDL_image.h>
#define DISPLAY_EMULATOR_BORDER 16 #define EMULATOR_BORDER 16
#define DISPLAY_TOUCH_OFFSET_X 180 #if TREZOR_MODEL == T
#define DISPLAY_TOUCH_OFFSET_Y 120 #define WINDOW_WIDTH 400
#define WINDOW_HEIGHT 600
#define WINDOW_WIDTH 600 #define TOUCH_OFFSET_X 80
#define WINDOW_HEIGHT 800 #define TOUCH_OFFSET_Y 110
#elif TREZOR_MODEL == 1
#define WINDOW_WIDTH 200
#define WINDOW_HEIGHT 340
#define TOUCH_OFFSET_X 36
#define TOUCH_OFFSET_Y 92
#else
#error Unknown TREZOR model
#endif
static SDL_Renderer *RENDERER; static SDL_Renderer *RENDERER;
static SDL_Surface *BUFFER; static SDL_Surface *BUFFER;
@ -94,12 +102,12 @@ void display_init(void)
BACKGROUND = IMG_LoadTexture(RENDERER, "../embed/unix/background_" XSTR(TREZOR_MODEL) ".jpg"); BACKGROUND = IMG_LoadTexture(RENDERER, "../embed/unix/background_" XSTR(TREZOR_MODEL) ".jpg");
if (BACKGROUND) { if (BACKGROUND) {
SDL_SetTextureBlendMode(BACKGROUND, SDL_BLENDMODE_NONE); SDL_SetTextureBlendMode(BACKGROUND, SDL_BLENDMODE_NONE);
sdl_touch_offset_x = DISPLAY_TOUCH_OFFSET_X; sdl_touch_offset_x = TOUCH_OFFSET_X;
sdl_touch_offset_y = DISPLAY_TOUCH_OFFSET_Y; sdl_touch_offset_y = TOUCH_OFFSET_Y;
} else { } else {
SDL_SetWindowSize(win, DISPLAY_RESX + 2 * DISPLAY_EMULATOR_BORDER, DISPLAY_RESY + 2 * DISPLAY_EMULATOR_BORDER); SDL_SetWindowSize(win, DISPLAY_RESX + 2 * EMULATOR_BORDER, DISPLAY_RESY + 2 * EMULATOR_BORDER);
sdl_touch_offset_x = DISPLAY_EMULATOR_BORDER; sdl_touch_offset_x = EMULATOR_BORDER;
sdl_touch_offset_y = DISPLAY_EMULATOR_BORDER; sdl_touch_offset_y = EMULATOR_BORDER;
} }
DISPLAY_BACKLIGHT = 0; DISPLAY_BACKLIGHT = 0;
DISPLAY_ORIENTATION = 0; DISPLAY_ORIENTATION = 0;
@ -133,10 +141,10 @@ void display_refresh(void)
#define BACKLIGHT_NORMAL 150 #define BACKLIGHT_NORMAL 150
SDL_SetTextureAlphaMod(TEXTURE, MIN(255, 255 * DISPLAY_BACKLIGHT / BACKLIGHT_NORMAL)); SDL_SetTextureAlphaMod(TEXTURE, MIN(255, 255 * DISPLAY_BACKLIGHT / BACKLIGHT_NORMAL));
if (BACKGROUND) { if (BACKGROUND) {
const SDL_Rect r = {DISPLAY_TOUCH_OFFSET_X, DISPLAY_TOUCH_OFFSET_Y, DISPLAY_RESX, DISPLAY_RESY}; const SDL_Rect r = {TOUCH_OFFSET_X, TOUCH_OFFSET_Y, DISPLAY_RESX, DISPLAY_RESY};
SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0); SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0);
} else { } else {
const SDL_Rect r = {DISPLAY_EMULATOR_BORDER, DISPLAY_EMULATOR_BORDER, DISPLAY_RESX, DISPLAY_RESY}; const SDL_Rect r = {EMULATOR_BORDER, EMULATOR_BORDER, DISPLAY_RESX, DISPLAY_RESY};
SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0); SDL_RenderCopyEx(RENDERER, TEXTURE, NULL, &r, DISPLAY_ORIENTATION, NULL, 0);
} }
SDL_RenderPresent(RENDERER); SDL_RenderPresent(RENDERER);

BIN
embed/unix/background_1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 36 KiB