cogl-texture-2d: Add an internal wrapper around glCopyTexSubImage2D
This adds a function called _cogl_texture_2d_copy_from_framebuffer which is a simple wrapper around glCopyTexSubImage2D. It is currently specific to the texture 2D backend.
This commit is contained in:
parent
9d242b62a9
commit
bc86db1057
@ -87,4 +87,26 @@ _cogl_texture_2d_new_from_foreign (GLuint gl_handle,
|
|||||||
void
|
void
|
||||||
_cogl_texture_2d_externally_modified (CoglHandle handle);
|
_cogl_texture_2d_externally_modified (CoglHandle handle);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* _cogl_texture_2d_copy_from_framebuffer:
|
||||||
|
* @handle: A handle to a 2D texture
|
||||||
|
* @dst_x: X-position to store the image within the texture
|
||||||
|
* @dst_y: Y-position to store the image within the texture
|
||||||
|
* @src_x: X-position to within the framebuffer to read from
|
||||||
|
* @src_y: Y-position to within the framebuffer to read from
|
||||||
|
* @width: width of the rectangle to copy
|
||||||
|
* @height: height of the rectangle to copy
|
||||||
|
*
|
||||||
|
* This copies a portion of the current read framebuffer into the
|
||||||
|
* texture.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_cogl_texture_2d_copy_from_framebuffer (CoglHandle handle,
|
||||||
|
int dst_x,
|
||||||
|
int dst_y,
|
||||||
|
int src_x,
|
||||||
|
int src_y,
|
||||||
|
int width,
|
||||||
|
int height);
|
||||||
|
|
||||||
#endif /* __COGL_TEXTURE_2D_H */
|
#endif /* __COGL_TEXTURE_2D_H */
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "cogl-handle.h"
|
#include "cogl-handle.h"
|
||||||
#include "cogl-journal-private.h"
|
#include "cogl-journal-private.h"
|
||||||
#include "cogl-pipeline-opengl-private.h"
|
#include "cogl-pipeline-opengl-private.h"
|
||||||
|
#include "cogl-framebuffer-private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -441,6 +442,40 @@ _cogl_texture_2d_externally_modified (CoglHandle handle)
|
|||||||
COGL_TEXTURE_2D (handle)->mipmaps_dirty = TRUE;
|
COGL_TEXTURE_2D (handle)->mipmaps_dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_cogl_texture_2d_copy_from_framebuffer (CoglHandle handle,
|
||||||
|
int dst_x,
|
||||||
|
int dst_y,
|
||||||
|
int src_x,
|
||||||
|
int src_y,
|
||||||
|
int width,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
CoglTexture2D *tex_2d;
|
||||||
|
|
||||||
|
g_return_if_fail (_cogl_is_texture_2d (handle));
|
||||||
|
|
||||||
|
tex_2d = COGL_TEXTURE_2D (handle);
|
||||||
|
|
||||||
|
/* Make sure the current framebuffers are bound. We explicitly avoid
|
||||||
|
flushing the clip state so we can bind our own empty state */
|
||||||
|
_cogl_framebuffer_flush_state (_cogl_get_draw_buffer (),
|
||||||
|
_cogl_get_read_buffer (),
|
||||||
|
0);
|
||||||
|
|
||||||
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
||||||
|
tex_2d->gl_texture,
|
||||||
|
tex_2d->is_foreign);
|
||||||
|
|
||||||
|
glCopyTexSubImage2D (GL_TEXTURE_2D,
|
||||||
|
0, /* level */
|
||||||
|
dst_x, dst_y,
|
||||||
|
src_x, src_y,
|
||||||
|
width, height);
|
||||||
|
|
||||||
|
tex_2d->mipmaps_dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_cogl_texture_2d_get_max_waste (CoglTexture *tex)
|
_cogl_texture_2d_get_max_waste (CoglTexture *tex)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user