This commit is contained in:
Romain Vimont 2020-04-25 00:34:44 +02:00
parent 06fe067786
commit 482b2defb5

View File

@ -210,6 +210,8 @@ update_content_rect(struct screen *screen) {
/ content_size.height; / content_size.height;
rect->x = (drawable_size.width - rect->w) / 2; rect->x = (drawable_size.width - rect->w) / 2;
} }
LOGI("== update_content_rect: %d,%d %dx%d", rect->x, rect->y, rect->w, rect->h);
} }
void void
@ -344,6 +346,7 @@ screen_init_rendering(struct screen *screen, const char *window_title,
return false; return false;
} }
LOGI("# init");
update_content_rect(screen); update_content_rect(screen);
screen->windowed_window_size = window_size; screen->windowed_window_size = window_size;
@ -421,6 +424,7 @@ prepare_for_frame(struct screen *screen, struct size new_frame_size) {
screen->frame_size = new_frame_size; screen->frame_size = new_frame_size;
screen->content_size = new_content_size; screen->content_size = new_content_size;
LOGI("# prepare_for_frame");
update_content_rect(screen); update_content_rect(screen);
LOGI("New texture: %" PRIu16 "x%" PRIu16, LOGI("New texture: %" PRIu16 "x%" PRIu16,
@ -509,6 +513,7 @@ screen_switch_fullscreen(struct screen *screen) {
apply_windowed_size(screen); apply_windowed_size(screen);
LOGD("Switched to %s mode", screen->fullscreen ? "fullscreen" : "windowed"); LOGD("Switched to %s mode", screen->fullscreen ? "fullscreen" : "windowed");
LOGI("# screen_switch_fullscreen");
update_content_rect(screen); update_content_rect(screen);
screen_render(screen); screen_render(screen);
} }
@ -553,6 +558,7 @@ screen_handle_window_event(struct screen *screen,
const SDL_WindowEvent *event) { const SDL_WindowEvent *event) {
switch (event->event) { switch (event->event) {
case SDL_WINDOWEVENT_EXPOSED: case SDL_WINDOWEVENT_EXPOSED:
LOGI("SDL_WINDOW_EVENT_EXPOSED");
update_content_rect(screen); update_content_rect(screen);
screen_render(screen); screen_render(screen);
break; break;
@ -569,6 +575,7 @@ screen_handle_window_event(struct screen *screen,
// window is maximized or fullscreen is enabled. // window is maximized or fullscreen is enabled.
screen->windowed_window_size = get_window_size(screen->window); screen->windowed_window_size = get_window_size(screen->window);
} }
LOGI("SDL_WINDOW_EVENT_SIZE_CHANGED");
update_content_rect(screen); update_content_rect(screen);
screen_render(screen); screen_render(screen);
break; break;
@ -597,6 +604,9 @@ screen_convert_to_frame_coords(struct screen *screen, int32_t x, int32_t y) {
unsigned rotation = screen->rotation; unsigned rotation = screen->rotation;
assert(rotation < 4); assert(rotation < 4);
int old_x = x;
int old_y = y;
int32_t w = screen->content_size.width; int32_t w = screen->content_size.width;
int32_t h = screen->content_size.height; int32_t h = screen->content_size.height;
@ -609,6 +619,11 @@ screen_convert_to_frame_coords(struct screen *screen, int32_t x, int32_t y) {
x = (int64_t) (x - screen->rect.x) * w * dw / (screen->rect.w * ww); x = (int64_t) (x - screen->rect.x) * w * dw / (screen->rect.w * ww);
y = (int64_t) (y - screen->rect.y) * h * dh / (screen->rect.h * wh); y = (int64_t) (y - screen->rect.y) * h * dh / (screen->rect.h * wh);
LOGI("content=%dx%d, rect={%d, %d, %dx%d}: (%d, %d) -> (%d, %d)",
(int) w, (int) h,
screen->rect.x, screen->rect.y, screen->rect.w, screen->rect.h,
old_x, old_y, (int) x, (int) y);
// rotate // rotate
struct point result; struct point result;
switch (rotation) { switch (rotation) {