mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
gpu: Add support for MacOS default framebuffer
This adds the same code as the GL renderer used to allow backends to redirect rendering to a different framebuffer. Related: #6363
This commit is contained in:
parent
1994e1940c
commit
3a93d52718
@ -43,7 +43,7 @@ gsk_gl_image_finalize (GObject *object)
|
||||
{
|
||||
GskGLImage *self = GSK_GL_IMAGE (object);
|
||||
|
||||
if (self->framebuffer_id)
|
||||
if (self->texture_id && self->framebuffer_id)
|
||||
glDeleteFramebuffers (1, &self->framebuffer_id);
|
||||
|
||||
if (self->owns_texture)
|
||||
@ -70,6 +70,7 @@ gsk_gl_image_init (GskGLImage *self)
|
||||
|
||||
GskGpuImage *
|
||||
gsk_gl_image_new_backbuffer (GskGLDevice *device,
|
||||
GdkGLContext *context,
|
||||
GdkMemoryFormat format,
|
||||
gsize width,
|
||||
gsize height)
|
||||
@ -95,6 +96,13 @@ gsk_gl_image_new_backbuffer (GskGLDevice *device,
|
||||
|
||||
/* texture_id == 0 means backbuffer */
|
||||
|
||||
/* Check for non-standard framebuffer binding as we might not be using
|
||||
* the default framebuffer on systems like macOS where we've bound an
|
||||
* IOSurface to a GL_TEXTURE_RECTANGLE. Otherwise, no scissor clip will
|
||||
* be applied in the command queue causing overdrawing.
|
||||
*/
|
||||
self->framebuffer_id = GDK_GL_CONTEXT_GET_CLASS (context)->get_default_framebuffer (context);
|
||||
|
||||
return GSK_GPU_IMAGE (self);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ G_BEGIN_DECLS
|
||||
G_DECLARE_FINAL_TYPE (GskGLImage, gsk_gl_image, GSK, GL_IMAGE, GskGpuImage)
|
||||
|
||||
GskGpuImage * gsk_gl_image_new_backbuffer (GskGLDevice *device,
|
||||
GdkGLContext *context,
|
||||
GdkMemoryFormat format,
|
||||
gsize width,
|
||||
gsize height);
|
||||
|
@ -99,6 +99,7 @@ gsk_ngl_renderer_get_backbuffer (GskGpuRenderer *renderer)
|
||||
{
|
||||
gsk_ngl_renderer_free_backbuffer (self);
|
||||
self->backbuffer = gsk_gl_image_new_backbuffer (GSK_GL_DEVICE (gsk_gpu_renderer_get_device (renderer)),
|
||||
GDK_GL_CONTEXT (context),
|
||||
GDK_MEMORY_DEFAULT /* FIXME */,
|
||||
ceil (gdk_surface_get_width (surface) * scale),
|
||||
ceil (gdk_surface_get_height (surface) * scale));
|
||||
|
Loading…
Reference in New Issue
Block a user