mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	render: Flip textures in case of inverted_y
This commit is contained in:
		
							parent
							
								
									6c7e1c867c
								
							
						
					
					
						commit
						2d0db16942
					
				
					 4 changed files with 10 additions and 2 deletions
				
			
		| 
						 | 
					@ -85,6 +85,7 @@ struct wlr_texture {
 | 
				
			||||||
	bool valid;
 | 
						bool valid;
 | 
				
			||||||
	uint32_t format;
 | 
						uint32_t format;
 | 
				
			||||||
	int width, height;
 | 
						int width, height;
 | 
				
			||||||
 | 
						bool inverted_y;
 | 
				
			||||||
	struct wl_signal destroy_signal;
 | 
						struct wl_signal destroy_signal;
 | 
				
			||||||
	struct wl_resource *resource;
 | 
						struct wl_resource *resource;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -179,7 +179,8 @@ static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_texture_bind(texture);
 | 
						wlr_texture_bind(texture);
 | 
				
			||||||
	GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
 | 
						GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
 | 
				
			||||||
	GL_CALL(glUniform1f(2, alpha));
 | 
						GL_CALL(glUniform1i(1, texture->inverted_y));
 | 
				
			||||||
 | 
						GL_CALL(glUniform1f(3, alpha));
 | 
				
			||||||
	draw_quad();
 | 
						draw_quad();
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,6 +50,7 @@ const GLchar ellipse_fragment_src[] =
 | 
				
			||||||
// Textured quads
 | 
					// Textured quads
 | 
				
			||||||
const GLchar vertex_src[] =
 | 
					const GLchar vertex_src[] =
 | 
				
			||||||
"uniform mat4 proj;"
 | 
					"uniform mat4 proj;"
 | 
				
			||||||
 | 
					"uniform bool invert_y;"
 | 
				
			||||||
"attribute vec2 pos;"
 | 
					"attribute vec2 pos;"
 | 
				
			||||||
"attribute vec2 texcoord;"
 | 
					"attribute vec2 texcoord;"
 | 
				
			||||||
"varying vec2 v_texcoord;"
 | 
					"varying vec2 v_texcoord;"
 | 
				
			||||||
| 
						 | 
					@ -69,7 +70,11 @@ const GLchar vertex_src[] =
 | 
				
			||||||
"}"
 | 
					"}"
 | 
				
			||||||
"void main() {"
 | 
					"void main() {"
 | 
				
			||||||
"	gl_Position = transpose(proj) * vec4(pos, 0.0, 1.0);"
 | 
					"	gl_Position = transpose(proj) * vec4(pos, 0.0, 1.0);"
 | 
				
			||||||
 | 
					"  if (invert_y) {"
 | 
				
			||||||
 | 
					"    v_texcoord = vec2(texcoord.s, 1.0 - texcoord.t);"
 | 
				
			||||||
 | 
					"  } else {"
 | 
				
			||||||
"    v_texcoord = texcoord;"
 | 
					"    v_texcoord = texcoord;"
 | 
				
			||||||
 | 
					"  }"
 | 
				
			||||||
"}";
 | 
					"}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const GLchar fragment_src_rgba[] =
 | 
					const GLchar fragment_src_rgba[] =
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -164,6 +164,7 @@ static bool gles2_texture_upload_drm(struct wlr_texture *_tex,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	EGLint inverted_y;
 | 
						EGLint inverted_y;
 | 
				
			||||||
	wlr_egl_query_buffer(tex->egl, buf, EGL_WAYLAND_Y_INVERTED_WL, &inverted_y);
 | 
						wlr_egl_query_buffer(tex->egl, buf, EGL_WAYLAND_Y_INVERTED_WL, &inverted_y);
 | 
				
			||||||
 | 
						tex->wlr_texture.inverted_y = !!inverted_y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	GLenum target;
 | 
						GLenum target;
 | 
				
			||||||
	const struct pixel_format *pf;
 | 
						const struct pixel_format *pf;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue