diff options
author | David Reveman <davidr@novell.com> | 2005-07-04 10:33:00 +0000 |
---|---|---|
committer | David Reveman <davidr@novell.com> | 2005-07-04 10:33:00 +0000 |
commit | e5a75e4b8433403e6ad5aab5c3a67df2f2b8cc98 (patch) | |
tree | 47b91d9eb08e58a5186e22681a5213e3d7591090 /src | |
parent | c3d95a5eef97f2762ff83a30fca3c39971b38e87 (diff) |
Fix GL_EXT_framebuffer_object support
Diffstat (limited to 'src')
-rw-r--r-- | src/agl/glitz_agl_context.c | 10 | ||||
-rw-r--r-- | src/glitz.c | 19 | ||||
-rw-r--r-- | src/glitz.h | 2 | ||||
-rw-r--r-- | src/glitz_framebuffer.c | 4 | ||||
-rw-r--r-- | src/glitz_geometry.c | 21 | ||||
-rw-r--r-- | src/glitz_pixel.c | 15 | ||||
-rw-r--r-- | src/glitz_rect.c | 158 | ||||
-rw-r--r-- | src/glitz_surface.c | 36 | ||||
-rw-r--r-- | src/glitz_texture.c | 9 | ||||
-rw-r--r-- | src/glitzint.h | 4 | ||||
-rw-r--r-- | src/glx/glitz_glx_context.c | 13 |
11 files changed, 187 insertions, 104 deletions
diff --git a/src/agl/glitz_agl_context.c b/src/agl/glitz_agl_context.c index 34cd199..f917dca 100644 --- a/src/agl/glitz_agl_context.c +++ b/src/agl/glitz_agl_context.c @@ -192,6 +192,14 @@ _glitz_agl_make_current (void *abstract_context, if (update) { + if (drawable->thread_info->cctx) + { + glitz_context_t *ctx = drawable->thread_info->cctx; + + if (ctx->lose_current) + ctx->lose_current (ctx->closure); + } + if (drawable->pbuffer) { aglSetPBuffer (context->context, drawable->pbuffer, 0, 0, aglGetVirtualScreen (context->context)); @@ -205,7 +213,7 @@ _glitz_agl_make_current (void *abstract_context, } aglSetDrawable (context->context, drawable->drawable); } - + aglSetCurrentContext (context->context); } diff --git a/src/glitz.c b/src/glitz.c index 98a47d4..7bdaade 100644 --- a/src/glitz.c +++ b/src/glitz.c @@ -397,7 +397,10 @@ glitz_copy_area (glitz_surface_t *src, status = GLITZ_STATUS_NOT_SUPPORTED; if (glitz_surface_push_current (dst, GLITZ_DRAWABLE_CURRENT)) { - if (src->attached == dst->attached) + int target_height = SURFACE_DRAWABLE_HEIGHT (dst); + int source_height = SURFACE_DRAWABLE_HEIGHT (src); + + if (src == dst || (dst->attached && src->attached == dst->attached)) { glitz_box_t box, *clip = dst->clip; int n_clip = dst->n_clip; @@ -435,16 +438,15 @@ glitz_copy_area (glitz_surface_t *src, { glitz_set_raster_pos (gl, dst->x + box.x1, - dst->attached->height - - (dst->y + box.y2)); + target_height - (dst->y + box.y2)); gl->scissor (dst->x + box.x1, - dst->attached->height - (dst->y + box.y2), + target_height - (dst->y + box.y2), box.x2 - box.x1, box.y2 - box.y1); gl->copy_pixels (x_src + (box.x1 - x_dst), - src->attached->height - + source_height - (y_src + (box.y2 - y_dst)), box.x2 - box.x1, box.y2 - box.y1, GLITZ_GL_COLOR); @@ -489,7 +491,7 @@ glitz_copy_area (glitz_surface_t *src, int vertices = 0; glitz_box_t box, *clip = dst->clip; int n_clip = dst->n_clip; - + ptr = malloc (n_clip * 8 * sizeof (glitz_float_t)); if (!ptr) { glitz_surface_pop_current (dst); @@ -538,8 +540,7 @@ glitz_copy_area (glitz_surface_t *src, if (vertices) { gl->scissor (bounds.x1 + dst->x, - dst->attached->height - dst->y - - bounds.y2, + (target_height - dst->y) - bounds.y2, bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); @@ -568,7 +569,7 @@ glitz_copy_area (glitz_surface_t *src, glitz_surface_pop_current (dst); - if (status) + if (status && src->attached) { if (glitz_surface_push_current (src, GLITZ_DRAWABLE_CURRENT)) { diff --git a/src/glitz.h b/src/glitz.h index 0d6d30b..53dbcec 100644 --- a/src/glitz.h +++ b/src/glitz.h @@ -38,7 +38,7 @@ #define GLITZ_MAJOR 0 #define GLITZ_MINOR 4 -#define GLITZ_REVISION 3 +#define GLITZ_REVISION 4 #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/src/glitz_framebuffer.c b/src/glitz_framebuffer.c index 24a214f..87edbe4 100644 --- a/src/glitz_framebuffer.c +++ b/src/glitz_framebuffer.c @@ -39,7 +39,8 @@ void glitz_framebuffer_fini (glitz_gl_proc_address_list_t *gl, glitz_framebuffer_t *framebuffer) { - gl->delete_framebuffers (1, &framebuffer->name); + if (framebuffer->name) + gl->delete_framebuffers (1, &framebuffer->name); } void @@ -59,6 +60,7 @@ glitz_framebuffer_complete (glitz_gl_proc_address_list_t *gl, glitz_texture_allocate (gl, texture); gl->gen_framebuffers (1, &framebuffer->name); + gl->bind_framebuffer (GLITZ_GL_FRAMEBUFFER, framebuffer->name); gl->framebuffer_texture_2d (GLITZ_GL_FRAMEBUFFER, diff --git a/src/glitz_geometry.c b/src/glitz_geometry.c index 1ac1108..9c16aa9 100644 --- a/src/glitz_geometry.c +++ b/src/glitz_geometry.c @@ -360,9 +360,10 @@ _glitz_draw_rectangle (glitz_gl_proc_address_list_t *gl, glitz_box_t *bounds, int damage) { - glitz_box_t *clip = dst->clip; - int n_clip = dst->n_clip; - glitz_box_t box; + glitz_box_t *clip = dst->clip; + int n_clip = dst->n_clip; + glitz_box_t box; + int target_height = SURFACE_DRAWABLE_HEIGHT (dst); while (n_clip--) { @@ -382,7 +383,7 @@ _glitz_draw_rectangle (glitz_gl_proc_address_list_t *gl, if (box.x1 < box.x2 && box.y1 < box.y2) { gl->scissor (box.x1 + dst->x, - dst->attached->height - dst->y - box.y2, + target_height - dst->y - box.y2, box.x2 - box.x1, box.y2 - box.y1); gl->draw_arrays (GLITZ_GL_QUADS, 0, 4); @@ -409,6 +410,7 @@ _glitz_draw_vertex_arrays (glitz_gl_proc_address_list_t *gl, glitz_box_t *clip = dst->clip; int i, n_clip = dst->n_clip; glitz_box_t box; + int target_height = SURFACE_DRAWABLE_HEIGHT (dst); while (n_clip--) { @@ -428,7 +430,7 @@ _glitz_draw_vertex_arrays (glitz_gl_proc_address_list_t *gl, if (box.x1 < box.x2 && box.y1 < box.y2) { gl->scissor (box.x1 + dst->x, - dst->attached->height - dst->y - box.y2, + target_height - dst->y - box.y2, box.x2 - box.x1, box.y2 - box.y1); gl->push_matrix (); @@ -532,6 +534,7 @@ _glitz_draw_bitmap_arrays (glitz_gl_proc_address_list_t *gl, int byte_offset, pixel_offset = 0; glitz_float_t x_off, y_off; glitz_box_t box; + int target_height = SURFACE_DRAWABLE_HEIGHT (dst); if (dst->geometry.u.b.top_down) { @@ -597,7 +600,7 @@ _glitz_draw_bitmap_arrays (glitz_gl_proc_address_list_t *gl, if (box.x1 < box.x2 && box.y1 < box.y2) { gl->scissor (box.x1 + dst->x, - dst->attached->height - dst->y - box.y2, + target_height - dst->y - box.y2, box.x2 - box.x1, box.y2 - box.y1); x_off = dst->x + dst->geometry.off.v[0]; @@ -608,8 +611,7 @@ _glitz_draw_bitmap_arrays (glitz_gl_proc_address_list_t *gl, x_off += array->off->v[0]; y_off += array->off->v[1]; - glitz_set_raster_pos (gl, x_off, - dst->attached->height - y_off); + glitz_set_raster_pos (gl, x_off, target_height - y_off); for (i = 0, n = array->n_arrays; n--; i++) { @@ -633,8 +635,7 @@ _glitz_draw_bitmap_arrays (glitz_gl_proc_address_list_t *gl, } else { - glitz_set_raster_pos (gl, x_off, - dst->attached->height - y_off); + glitz_set_raster_pos (gl, x_off, target_height - y_off); BITMAP_SETUP (dst, dst->geometry.first, diff --git a/src/glitz_pixel.c b/src/glitz_pixel.c index ddd7f03..56f16c1 100644 --- a/src/glitz_pixel.c +++ b/src/glitz_pixel.c @@ -725,7 +725,7 @@ glitz_set_pixels (glitz_surface_t *dst, &dst->format->color, feature_mask); } - + glitz_surface_push_current (dst, GLITZ_ANY_CONTEXT_CURRENT); texture = glitz_surface_get_texture (dst, 1); @@ -973,13 +973,12 @@ glitz_get_pixels (glitz_surface_t *src, return; } - if (glitz_surface_push_current (src, GLITZ_DRAWABLE_CURRENT)) { - from_drawable = 1; - color = &src->attached->format->color; + color = &src->format->color; + from_drawable = glitz_surface_push_current (src, GLITZ_DRAWABLE_CURRENT); + if (from_drawable) { + if (src->attached) + color = &src->attached->format->color; } else { - from_drawable = 0; - color = &src->format->color; - texture = glitz_surface_get_texture (src, 0); if (!texture) { glitz_surface_pop_current (src); @@ -1065,7 +1064,7 @@ glitz_get_pixels (glitz_surface_t *src, gl->disable (GLITZ_GL_SCISSOR_TEST); gl->read_pixels (x_src + src->x, - src->attached->height - (y_src + src->y) - height, + SURFACE_DRAWABLE_HEIGHT (src) - (y_src + src->y) - height, width, height, gl_format->format, gl_format->type, pixels); diff --git a/src/glitz_rect.c b/src/glitz_rect.c index 48ec839..360c635 100644 --- a/src/glitz_rect.c +++ b/src/glitz_rect.c @@ -39,7 +39,7 @@ static glitz_buffer_t * _glitz_minimum_buffer (glitz_surface_t *surface, const glitz_rectangle_t *rects, int n_rects, - unsigned int pixel) + unsigned int *pixel) { glitz_buffer_t *buffer; int i, size = 0; @@ -53,7 +53,10 @@ _glitz_minimum_buffer (glitz_surface_t *surface, rects++; } - + + if (size <= 1) + return glitz_buffer_create_for_data (pixel); + buffer = glitz_pixel_buffer_create (surface->drawable, NULL, size * sizeof (unsigned int), GLITZ_BUFFER_HINT_STATIC_DRAW); @@ -63,7 +66,7 @@ _glitz_minimum_buffer (glitz_surface_t *surface, data = glitz_buffer_map (buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY); while (size--) - *data++ = pixel; + *data++ = *pixel; glitz_buffer_unmap (buffer); @@ -153,15 +156,76 @@ glitz_set_rectangles (glitz_surface_t *dst, }; glitz_buffer_t *buffer = NULL; glitz_box_t box; - glitz_bool_t drawable; - - drawable = glitz_surface_push_current (dst, GLITZ_DRAWABLE_CURRENT); + glitz_bool_t drawable = 0; + + if (n_rects == 1 && rects->width <= 1 && rects->height <= 1) + { + glitz_surface_push_current (dst, GLITZ_ANY_CONTEXT_CURRENT); + } + else + { + drawable = glitz_surface_push_current (dst, + GLITZ_DRAWABLE_CURRENT); + } + if (drawable) { + glitz_box_t *clip; + int n_clip; + int target_height = SURFACE_DRAWABLE_HEIGHT (dst); + gl->clear_color (color->red / (glitz_gl_clampf_t) 0xffff, color->green / (glitz_gl_clampf_t) 0xffff, color->blue / (glitz_gl_clampf_t) 0xffff, color->alpha / (glitz_gl_clampf_t) 0xffff); + + while (n_rects--) + { + clip = dst->clip; + n_clip = dst->n_clip; + while (n_clip--) + { + box.x1 = clip->x1 + dst->x_clip; + box.y1 = clip->y1 + dst->y_clip; + box.x2 = clip->x2 + dst->x_clip; + box.y2 = clip->y2 + dst->y_clip; + + if (dst->box.x1 > box.x1) + box.x1 = dst->box.x1; + if (dst->box.y1 > box.y1) + box.y1 = dst->box.y1; + if (dst->box.x2 < box.x2) + box.x2 = dst->box.x2; + if (dst->box.y2 < box.y2) + box.y2 = dst->box.y2; + + if (rects->x > box.x1) + box.x1 = rects->x; + if (rects->y > box.y1) + box.y1 = rects->y; + if (rects->x + rects->width < box.x2) + box.x2 = rects->x + rects->width; + if (rects->y + rects->height < box.y2) + box.y2 = rects->y + rects->height; + + if (box.x1 < box.x2 && box.y1 < box.y2) + { + gl->scissor (box.x1, + target_height - dst->y - box.y2, + box.x2 - box.x1, + box.y2 - box.y1); + + gl->clear (GLITZ_GL_COLOR_BUFFER_BIT); + + glitz_surface_damage (dst, &box, + GLITZ_DAMAGE_TEXTURE_MASK | + GLITZ_DAMAGE_SOLID_MASK); + } + + clip++; + } + rects++; + } } else { @@ -170,75 +234,43 @@ glitz_set_rectangles (glitz_surface_t *dst, ((((unsigned int) color->red * 0xff) / 0xffff) << 16) | ((((unsigned int) color->green * 0xff) / 0xffff) << 8) | ((((unsigned int) color->blue * 0xff) / 0xffff)); + int x1, y1, x2, y2; - buffer = _glitz_minimum_buffer (dst, rects, n_rects, pixel); + buffer = _glitz_minimum_buffer (dst, rects, n_rects, &pixel); if (!buffer) { glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK); return; } - } - - while (n_rects--) - { - glitz_box_t *clip = dst->clip; - int n_clip = dst->n_clip; - while (n_clip--) + while (n_rects--) { - box.x1 = clip->x1 + dst->x_clip; - box.y1 = clip->y1 + dst->y_clip; - box.x2 = clip->x2 + dst->x_clip; - box.y2 = clip->y2 + dst->y_clip; + x1 = rects->x; + y1 = rects->y; + x2 = x1 + rects->width; + y2 = y1 + rects->height; + + if (x1 < 0) + x1 = 0; + if (y1 < 0) + y1 = 0; + if (x2 > dst->box.x2) + x2 = dst->box.x2; + if (y2 > dst->box.y2) + y2 = dst->box.y2; - if (dst->box.x1 > box.x1) - box.x1 = dst->box.x1; - if (dst->box.y1 > box.y1) - box.y1 = dst->box.y1; - if (dst->box.x2 < box.x2) - box.x2 = dst->box.x2; - if (dst->box.y2 < box.y2) - box.y2 = dst->box.y2; - - if (rects->x > box.x1) - box.x1 = rects->x; - if (rects->y > box.y1) - box.y1 = rects->y; - if (rects->x + rects->width < box.x2) - box.x2 = rects->x + rects->width; - if (rects->y + rects->height < box.y2) - box.y2 = rects->y + rects->height; + if (x1 < x2 && y1 < y2) + glitz_set_pixels (dst, + x1, y1, + x2 - x1, y2 - y1, + &pf, buffer); - if (box.x1 < box.x2 && box.y1 < box.y2) - { - if (drawable) - { - gl->scissor (box.x1, - dst->attached->height - dst->y - box.y2, - box.x2 - box.x1, - box.y2 - box.y1); - gl->clear (GLITZ_GL_COLOR_BUFFER_BIT); - - glitz_surface_damage (dst, &box, - GLITZ_DAMAGE_TEXTURE_MASK | - GLITZ_DAMAGE_SOLID_MASK); - } - else - { - glitz_set_pixels (dst, - box.x1, box.y1, - box.x2 - box.x1, box.y2 - box.y1, - &pf, buffer); - } - } - clip++; + rects++; } - rects++; - } - if (buffer) - glitz_buffer_destroy (buffer); - + if (buffer) + glitz_buffer_destroy (buffer); + } glitz_surface_pop_current (dst); } } diff --git a/src/glitz_surface.c b/src/glitz_surface.c index 99e7cd7..eff07ba 100644 --- a/src/glitz_surface.c +++ b/src/glitz_surface.c @@ -124,9 +124,9 @@ glitz_surface_destroy (glitz_surface_t *surface) if (surface->texture.name) { glitz_surface_push_current (surface, GLITZ_ANY_CONTEXT_CURRENT); - if (surface->framebuffer.name) - glitz_framebuffer_fini (&surface->drawable->backend->gl, - &surface->framebuffer); + + glitz_framebuffer_fini (&surface->drawable->backend->gl, + &surface->framebuffer); glitz_texture_fini (&surface->drawable->backend->gl, &surface->texture); glitz_surface_pop_current (surface); @@ -390,7 +390,7 @@ glitz_surface_damage (glitz_surface_t *surface, if (what & GLITZ_DAMAGE_DRAWABLE_MASK) REGION_UNION (&surface->drawable_damage, box); - if (what & GLITZ_DAMAGE_TEXTURE_MASK) + if (surface->attached && (what & GLITZ_DAMAGE_TEXTURE_MASK)) REGION_UNION (&surface->texture_damage, box); } else @@ -401,7 +401,7 @@ glitz_surface_damage (glitz_surface_t *surface, REGION_INIT (&surface->drawable_damage, &surface->box); } - if (what & GLITZ_DAMAGE_TEXTURE_MASK) + if (surface->attached && (what & GLITZ_DAMAGE_TEXTURE_MASK)) { REGION_EMPTY (&surface->texture_damage); REGION_INIT (&surface->texture_damage, &surface->box); @@ -594,13 +594,26 @@ glitz_surface_pop_current (glitz_surface_t *surface) { glitz_surface_t *other; - if (surface->attached) + if (surface->attached) { other = surface->attached->backend->pop_current (surface->attached); - else + } else { + if (surface->framebuffer.name) + glitz_framebuffer_unbind (&surface->drawable->backend->gl); + other = surface->drawable->backend->pop_current (surface->drawable); + } - if (other) + if (other) { + if ((!other->attached) && + (other->drawable->backend->feature_mask & + GLITZ_FEATURE_FRAMEBUFFER_OBJECT_MASK)) + { + glitz_framebuffer_complete (&other->drawable->backend->gl, + &other->framebuffer, + &other->texture); + } _glitz_surface_update_state (other); + } } void @@ -905,5 +918,10 @@ slim_hidden_def(glitz_surface_set_clip_region); glitz_bool_t glitz_surface_valid_target (glitz_surface_t *surface) { - return glitz_surface_push_current (surface, GLITZ_DRAWABLE_CURRENT); + glitz_bool_t valid; + + valid = glitz_surface_push_current (surface, GLITZ_DRAWABLE_CURRENT); + glitz_surface_pop_current (surface); + + return valid; } diff --git a/src/glitz_texture.c b/src/glitz_texture.c index 4722c81..6f65588 100644 --- a/src/glitz_texture.c +++ b/src/glitz_texture.c @@ -166,6 +166,15 @@ glitz_texture_allocate (glitz_gl_proc_address_list_t *gl, texture->width, texture->height, 0, GLITZ_GL_ALPHA, GLITZ_GL_UNSIGNED_BYTE, data); + gl->tex_parameter_i (texture->target, + GLITZ_GL_TEXTURE_MAG_FILTER, + GLITZ_GL_NEAREST); + gl->tex_parameter_i (texture->target, + GLITZ_GL_TEXTURE_MIN_FILTER, + GLITZ_GL_NEAREST); + + texture->filter = GLITZ_GL_NEAREST; + glitz_texture_unbind (gl, texture); if (data) diff --git a/src/glitzint.h b/src/glitzint.h index 0d76afb..54fa891 100644 --- a/src/glitzint.h +++ b/src/glitzint.h @@ -538,6 +538,10 @@ typedef struct _glitz_geometry { #define SURFACE_PROJECTIVE_TRANSFORM(surface) \ ((surface)->flags & GLITZ_SURFACE_FLAG_PROJECTIVE_TRANSFORM_MASK) +#define SURFACE_DRAWABLE_HEIGHT(surface) \ + (((surface)->attached) ? \ + (surface)->attached->height: surface->texture.height) + typedef struct _glitz_filter_params_t glitz_filter_params_t; typedef struct _glitz_matrix { diff --git a/src/glx/glitz_glx_context.c b/src/glx/glitz_glx_context.c index 767f0db..5d6caad 100644 --- a/src/glx/glitz_glx_context.c +++ b/src/glx/glitz_glx_context.c @@ -180,8 +180,17 @@ _glitz_glx_make_current (void *abstract_context, if ((glXGetCurrentContext () != context->context) || (glXGetCurrentDrawable () != drawable->drawable)) - glXMakeCurrent (display_info->display, drawable->drawable, - context->context); + { + if (display_info->thread_info->cctx) + { + glitz_context_t *ctx = display_info->thread_info->cctx; + + if (ctx->lose_current) + ctx->lose_current (ctx->closure); + } + glXMakeCurrent (display_info->display, drawable->drawable, + context->context); + } display_info->thread_info->cctx = &context->base; } |