Merge pull request #37475 from azagaya/3.2

Fixed images in black margins
This commit is contained in:
Rémi Verschelde 2020-07-03 13:09:22 +02:00 committed by GitHub
commit 22863363a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -250,7 +250,8 @@ void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *blac
if (black_image[MARGIN_LEFT].is_valid()) { if (black_image[MARGIN_LEFT].is_valid()) {
_bind_canvas_texture(black_image[MARGIN_LEFT], RID()); _bind_canvas_texture(black_image[MARGIN_LEFT], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_LEFT]), storage->texture_get_height(black_image[MARGIN_LEFT])); Size2 sz(storage->texture_get_width(black_image[MARGIN_LEFT]), storage->texture_get_height(black_image[MARGIN_LEFT]));
draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, sz.x, sz.y)); draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h),
Rect2(0, 0, (float)black_margin[MARGIN_LEFT] / sz.x, (float)(window_h) / sz.y));
} else if (black_margin[MARGIN_LEFT]) { } else if (black_margin[MARGIN_LEFT]) {
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
@ -261,7 +262,8 @@ void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *blac
if (black_image[MARGIN_RIGHT].is_valid()) { if (black_image[MARGIN_RIGHT].is_valid()) {
_bind_canvas_texture(black_image[MARGIN_RIGHT], RID()); _bind_canvas_texture(black_image[MARGIN_RIGHT], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_RIGHT]), storage->texture_get_height(black_image[MARGIN_RIGHT])); Size2 sz(storage->texture_get_width(black_image[MARGIN_RIGHT]), storage->texture_get_height(black_image[MARGIN_RIGHT]));
draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, sz.x, sz.y)); draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h),
Rect2(0, 0, (float)black_margin[MARGIN_RIGHT] / sz.x, (float)window_h / sz.y));
} else if (black_margin[MARGIN_RIGHT]) { } else if (black_margin[MARGIN_RIGHT]) {
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
@ -273,7 +275,8 @@ void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *blac
_bind_canvas_texture(black_image[MARGIN_TOP], RID()); _bind_canvas_texture(black_image[MARGIN_TOP], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_TOP]), storage->texture_get_height(black_image[MARGIN_TOP])); Size2 sz(storage->texture_get_width(black_image[MARGIN_TOP]), storage->texture_get_height(black_image[MARGIN_TOP]));
draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, sz.x, sz.y)); draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]),
Rect2(0, 0, (float)window_w / sz.x, (float)black_margin[MARGIN_TOP] / sz.y));
} else if (black_margin[MARGIN_TOP]) { } else if (black_margin[MARGIN_TOP]) {
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
@ -287,7 +290,8 @@ void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *blac
_bind_canvas_texture(black_image[MARGIN_BOTTOM], RID()); _bind_canvas_texture(black_image[MARGIN_BOTTOM], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM])); Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM]));
draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y)); draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]),
Rect2(0, 0, (float)window_w / sz.x, (float)black_margin[MARGIN_BOTTOM] / sz.y));
} else if (black_margin[MARGIN_BOTTOM]) { } else if (black_margin[MARGIN_BOTTOM]) {

View File

@ -2143,7 +2143,9 @@ void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_im
if (black_image[MARGIN_LEFT].is_valid()) { if (black_image[MARGIN_LEFT].is_valid()) {
_bind_canvas_texture(black_image[MARGIN_LEFT], RID()); _bind_canvas_texture(black_image[MARGIN_LEFT], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_LEFT]), storage->texture_get_height(black_image[MARGIN_LEFT])); Size2 sz(storage->texture_get_width(black_image[MARGIN_LEFT]), storage->texture_get_height(black_image[MARGIN_LEFT]));
draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h), Rect2(0, 0, sz.x, sz.y));
draw_generic_textured_rect(Rect2(0, 0, black_margin[MARGIN_LEFT], window_h),
Rect2(0, 0, (float)black_margin[MARGIN_LEFT] / sz.x, (float)(window_h) / sz.y));
} else if (black_margin[MARGIN_LEFT]) { } else if (black_margin[MARGIN_LEFT]) {
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
@ -2154,7 +2156,8 @@ void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_im
if (black_image[MARGIN_RIGHT].is_valid()) { if (black_image[MARGIN_RIGHT].is_valid()) {
_bind_canvas_texture(black_image[MARGIN_RIGHT], RID()); _bind_canvas_texture(black_image[MARGIN_RIGHT], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_RIGHT]), storage->texture_get_height(black_image[MARGIN_RIGHT])); Size2 sz(storage->texture_get_width(black_image[MARGIN_RIGHT]), storage->texture_get_height(black_image[MARGIN_RIGHT]));
draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h), Rect2(0, 0, sz.x, sz.y)); draw_generic_textured_rect(Rect2(window_w - black_margin[MARGIN_RIGHT], 0, black_margin[MARGIN_RIGHT], window_h),
Rect2(0, 0, (float)black_margin[MARGIN_RIGHT] / sz.x, (float)window_h / sz.y));
} else if (black_margin[MARGIN_RIGHT]) { } else if (black_margin[MARGIN_RIGHT]) {
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex); glBindTexture(GL_TEXTURE_2D, storage->resources.black_tex);
@ -2166,7 +2169,8 @@ void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_im
_bind_canvas_texture(black_image[MARGIN_TOP], RID()); _bind_canvas_texture(black_image[MARGIN_TOP], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_TOP]), storage->texture_get_height(black_image[MARGIN_TOP])); Size2 sz(storage->texture_get_width(black_image[MARGIN_TOP]), storage->texture_get_height(black_image[MARGIN_TOP]));
draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]), Rect2(0, 0, sz.x, sz.y)); draw_generic_textured_rect(Rect2(0, 0, window_w, black_margin[MARGIN_TOP]),
Rect2(0, 0, (float)window_w / sz.x, (float)black_margin[MARGIN_TOP] / sz.y));
} else if (black_margin[MARGIN_TOP]) { } else if (black_margin[MARGIN_TOP]) {
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
@ -2180,7 +2184,8 @@ void RasterizerCanvasGLES3::draw_window_margins(int *black_margin, RID *black_im
_bind_canvas_texture(black_image[MARGIN_BOTTOM], RID()); _bind_canvas_texture(black_image[MARGIN_BOTTOM], RID());
Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM])); Size2 sz(storage->texture_get_width(black_image[MARGIN_BOTTOM]), storage->texture_get_height(black_image[MARGIN_BOTTOM]));
draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]), Rect2(0, 0, sz.x, sz.y)); draw_generic_textured_rect(Rect2(0, window_h - black_margin[MARGIN_BOTTOM], window_w, black_margin[MARGIN_BOTTOM]),
Rect2(0, 0, (float)window_w / sz.x, (float)black_margin[MARGIN_BOTTOM] / sz.y));
} else if (black_margin[MARGIN_BOTTOM]) { } else if (black_margin[MARGIN_BOTTOM]) {