framebuffers: cogl_offscreen_new_to_texture should take a ref on the texture
We weren't taking a reference on the texture to be used as the color buffer for offscreen rendering, so it was possible to free the texture leaving the framebuffer in an inconsistent state.
This commit is contained in:
parent
fbad0a75b6
commit
05ce533fc8
@ -57,6 +57,7 @@ typedef struct _CoglOffscreen
|
|||||||
CoglFramebuffer _parent;
|
CoglFramebuffer _parent;
|
||||||
GLuint fbo_handle;
|
GLuint fbo_handle;
|
||||||
GLuint gl_stencil_handle;
|
GLuint gl_stencil_handle;
|
||||||
|
CoglHandle texture;
|
||||||
} CoglOffscreen;
|
} CoglOffscreen;
|
||||||
|
|
||||||
#define COGL_OFFSCREEN(X) ((CoglOffscreen *)(X))
|
#define COGL_OFFSCREEN(X) ((CoglOffscreen *)(X))
|
||||||
|
@ -339,6 +339,7 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
|||||||
|
|
||||||
offscreen->fbo_handle = fbo_gl_handle;
|
offscreen->fbo_handle = fbo_gl_handle;
|
||||||
offscreen->gl_stencil_handle = gl_stencil_handle;
|
offscreen->gl_stencil_handle = gl_stencil_handle;
|
||||||
|
offscreen->texture = cogl_handle_ref (texhandle);
|
||||||
|
|
||||||
/* XXX: Can we get a away with removing this? It wasn't documented, and most
|
/* XXX: Can we get a away with removing this? It wasn't documented, and most
|
||||||
* users of the API are hopefully setting up the modelview from scratch
|
* users of the API are hopefully setting up the modelview from scratch
|
||||||
@ -362,6 +363,8 @@ _cogl_offscreen_free (CoglOffscreen *offscreen)
|
|||||||
|
|
||||||
if (offscreen->gl_stencil_handle)
|
if (offscreen->gl_stencil_handle)
|
||||||
GE (glDeleteRenderbuffers (1, &offscreen->gl_stencil_handle));
|
GE (glDeleteRenderbuffers (1, &offscreen->gl_stencil_handle));
|
||||||
|
if (offscreen->texture != COGL_INVALID_HANDLE)
|
||||||
|
cogl_handle_unref (offscreen->texture);
|
||||||
GE (glDeleteFramebuffers (1, &offscreen->fbo_handle));
|
GE (glDeleteFramebuffers (1, &offscreen->fbo_handle));
|
||||||
g_free (offscreen);
|
g_free (offscreen);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user