mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 09:58:12 +02:00
gl: Add _cairo_gl_surface_is_texture()
It's more explicit then just checking surface->fb != 0 Also, it makes improving that check easier.
This commit is contained in:
parent
e4cb46b500
commit
26e8e506b6
3 changed files with 14 additions and 7 deletions
|
|
@ -190,7 +190,7 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx,
|
|||
if (ctx->current_target != surface) {
|
||||
ctx->current_target = surface;
|
||||
|
||||
if (surface->fb) {
|
||||
if (_cairo_gl_surface_is_texture (surface)) {
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, surface->fb);
|
||||
glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer (GL_COLOR_ATTACHMENT0_EXT);
|
||||
|
|
@ -206,7 +206,7 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx,
|
|||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
if (surface->fb)
|
||||
if (_cairo_gl_surface_is_texture (surface))
|
||||
glOrtho (0, surface->width, 0, surface->height, -1.0, 1.0);
|
||||
else
|
||||
glOrtho (0, surface->width, surface->height, 0, -1.0, 1.0);
|
||||
|
|
|
|||
|
|
@ -228,6 +228,12 @@ _cairo_gl_surface_init (cairo_device_t *device,
|
|||
cairo_content_t content,
|
||||
int width, int height);
|
||||
|
||||
static cairo_always_inline cairo_bool_t cairo_warn
|
||||
_cairo_gl_surface_is_texture (cairo_gl_surface_t *surface)
|
||||
{
|
||||
return surface->fb != 0;
|
||||
}
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
|
||||
cairo_image_surface_t *src,
|
||||
|
|
|
|||
|
|
@ -400,7 +400,8 @@ cairo_gl_surface_set_size (cairo_surface_t *abstract_surface,
|
|||
if (unlikely (abstract_surface->status))
|
||||
return;
|
||||
|
||||
if (! _cairo_surface_is_gl (abstract_surface) || surface->fb) {
|
||||
if (! _cairo_surface_is_gl (abstract_surface) ||
|
||||
! _cairo_gl_surface_is_texture (surface)) {
|
||||
status = _cairo_surface_set_error (abstract_surface,
|
||||
CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return;
|
||||
|
|
@ -447,7 +448,7 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface)
|
|||
return;
|
||||
}
|
||||
|
||||
if (! surface->fb) {
|
||||
if (! _cairo_gl_surface_is_texture (surface)) {
|
||||
cairo_gl_context_t *ctx;
|
||||
|
||||
if (_cairo_gl_context_acquire (surface->base.device, &ctx))
|
||||
|
|
@ -536,7 +537,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
|
|||
|
||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, src->stride / cpp);
|
||||
if (dst->fb) {
|
||||
if (_cairo_gl_surface_is_texture (dst)) {
|
||||
glBindTexture (ctx->tex_target, dst->tex);
|
||||
glTexParameteri (ctx->tex_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri (ctx->tex_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
|
@ -666,12 +667,12 @@ _cairo_gl_surface_get_image (cairo_gl_surface_t *surface,
|
|||
|
||||
glPixelStorei (GL_PACK_ALIGNMENT, 1);
|
||||
glPixelStorei (GL_PACK_ROW_LENGTH, image->stride / cpp);
|
||||
if (surface->fb == 0 && GLEW_MESA_pack_invert)
|
||||
if (! _cairo_gl_surface_is_texture (surface) && GLEW_MESA_pack_invert)
|
||||
glPixelStorei (GL_PACK_INVERT_MESA, 1);
|
||||
glReadPixels (interest->x, interest->y,
|
||||
interest->width, interest->height,
|
||||
format, type, image->data);
|
||||
if (surface->fb == 0 && GLEW_MESA_pack_invert)
|
||||
if (! _cairo_gl_surface_is_texture (surface) && GLEW_MESA_pack_invert)
|
||||
glPixelStorei (GL_PACK_INVERT_MESA, 0);
|
||||
|
||||
_cairo_gl_context_release (ctx);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue