mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
gsk gl: Make it possible to clear a rectangle
Add a blend mode to the draw command, so it can draw transparent black. This will be used to erase the area on top of a subsurface when we do passthrough.
This commit is contained in:
parent
b7c2528ad1
commit
c636baf6f5
@ -609,6 +609,7 @@ gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
|
||||
batch->any.next_batch_index = -1;
|
||||
batch->any.viewport.width = width;
|
||||
batch->any.viewport.height = height;
|
||||
batch->draw.blend = 1;
|
||||
batch->draw.framebuffer = 0;
|
||||
batch->draw.uniform_count = 0;
|
||||
batch->draw.uniform_offset = self->batch_uniforms.len;
|
||||
@ -685,6 +686,7 @@ gsk_gl_command_queue_end_draw (GskGLCommandQueue *self)
|
||||
last_batch->any.program == batch->any.program &&
|
||||
last_batch->any.viewport.width == batch->any.viewport.width &&
|
||||
last_batch->any.viewport.height == batch->any.viewport.height &&
|
||||
last_batch->draw.blend == batch->draw.blend &&
|
||||
last_batch->draw.framebuffer == batch->draw.framebuffer &&
|
||||
last_batch->draw.vbo_offset + last_batch->draw.vbo_count == batch->draw.vbo_offset &&
|
||||
last_batch->draw.vbo_count + batch->draw.vbo_count <= 0xffff &&
|
||||
@ -1247,8 +1249,13 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self,
|
||||
n_uniforms += batch->draw.uniform_count;
|
||||
}
|
||||
|
||||
if (batch->draw.blend == 0)
|
||||
glDisable (GL_BLEND);
|
||||
|
||||
glDrawArrays (GL_TRIANGLES, batch->draw.vbo_offset, batch->draw.vbo_count);
|
||||
|
||||
if (batch->draw.blend == 0)
|
||||
glEnable (GL_BLEND);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -101,13 +101,15 @@ typedef struct _GskGLCommandDraw
|
||||
{
|
||||
GskGLCommandBatchAny head;
|
||||
|
||||
guint blend : 1;
|
||||
|
||||
/* There doesn't seem to be a limit on the framebuffer identifier that
|
||||
* can be returned, so we have to use a whole unsigned for the framebuffer
|
||||
* we are drawing to. When processing batches, we check to see if this
|
||||
* changes and adjust the render target accordingly. Some sorting is
|
||||
* performed to reduce the amount we change framebuffers.
|
||||
*/
|
||||
guint framebuffer;
|
||||
guint framebuffer : 31;
|
||||
|
||||
/* The number of uniforms to change. This must be less than or equal to
|
||||
* GL_MAX_UNIFORM_LOCATIONS but only guaranteed up to 1024 by any OpenGL
|
||||
|
Loading…
Reference in New Issue
Block a user