summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Reveman <davidr@novell.com>2004-09-16 23:56:19 +0000
committerDavid Reveman <davidr@novell.com>2004-09-16 23:56:19 +0000
commit73540d4888c46c0b04dab9420741ecf03f050478 (patch)
treececea872540cc4126398516e432f1e89fc46ba47
parentf16b4d54791acebdc7a2f1f2f89aa21205543fee (diff)
A few important pixel transfer fixes
-rw-r--r--ChangeLog12
-rw-r--r--src/glitz_buffer.c15
-rw-r--r--src/glitz_pixel.c59
3 files changed, 60 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 268ff57..e703d26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-09-17 David Reveman <c99drn@cs.umu.se>
+
+ * src/glitz_pixel.c: GLITZ_TRANSFORM_COPY_BOX_MASK is more correct name
+ than GLITZ_TRANSFORM_COPY_REGION_MASK.
+ (glitz_set_pixels): Set GLITZ_GL_UNPACK_ROW_LENGTH.
+ (glitz_get_pixels): Set GLITZ_GL_PACK_ROW_LENGTH.
+ GLITZ_GL_UNPACK_ALIGNMENT should be GLITZ_GL_PACK_ALIGNMENT.
+
+ * src/glitz_buffer.c (_glitz_buffer_init): Unbind buffer after
+ creation.
+ (glitz_pixel_buffer_create): Use buffer hint for choosing target.
+
2004-09-16 David Reveman <c99drn@cs.umu.se>
* src/glitz.c (glitz_composite): Don't set texture wrap mode to
diff --git a/src/glitz_buffer.c b/src/glitz_buffer.c
index 5334561..ea9791d 100644
--- a/src/glitz_buffer.c
+++ b/src/glitz_buffer.c
@@ -78,6 +78,7 @@ _glitz_buffer_init (glitz_buffer_t *buffer,
surface->backend->gl.bind_buffer (buffer->target, buffer->name);
surface->backend->gl.buffer_data (buffer->target, buffer->size,
data, usage);
+ surface->backend->gl.bind_buffer (buffer->target, 0);
}
} else
buffer->surface = NULL;
@@ -141,8 +142,18 @@ glitz_pixel_buffer_create (glitz_surface_t *surface,
buffer->size = size;
buffer->name = 0;
- buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
-
+
+ switch (hint) {
+ case GLITZ_BUFFER_HINT_STREAM_READ:
+ case GLITZ_BUFFER_HINT_STATIC_READ:
+ case GLITZ_BUFFER_HINT_DYNAMIC_READ:
+ buffer->target = GLITZ_GL_PIXEL_PACK_BUFFER;
+ break;
+ default:
+ buffer->target = GLITZ_GL_PIXEL_UNPACK_BUFFER;
+ break;
+ }
+
if (surface->backend->feature_mask & GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK)
status = _glitz_buffer_init (buffer, surface, data, hint);
else
diff --git a/src/glitz_pixel.c b/src/glitz_pixel.c
index 2701f16..0ada900 100644
--- a/src/glitz_pixel.c
+++ b/src/glitz_pixel.c
@@ -273,7 +273,7 @@ _store_32 (glitz_pixel_transform_op_t *op)
#define GLITZ_TRANSFORM_PIXELS_MASK (1L << 0)
#define GLITZ_TRANSFORM_SCANLINE_ORDER_MASK (1L << 1)
-#define GLITZ_TRANSFORM_COPY_REGION_MASK (1L << 2)
+#define GLITZ_TRANSFORM_COPY_BOX_MASK (1L << 2)
typedef struct _glitz_image {
char *data;
@@ -421,7 +421,7 @@ glitz_set_pixels (glitz_surface_t *dst,
char *pixels, *data = NULL;
glitz_gl_pixel_format_t *gl_format = NULL;
unsigned long transform = 0;
- int xoffset, bytes_per_line;
+ int xoffset, bytes_per_line, bpp;
if (x_dst < 0 || x_dst > (dst->width - width) ||
y_dst < 0 || y_dst > (dst->height - height)) {
@@ -457,6 +457,8 @@ glitz_set_pixels (glitz_surface_t *dst,
glitz_surface_pop_current (dst);
return;
}
+
+ glitz_texture_bind (gl, texture);
if (transform) {
glitz_image_t src_image, dst_image;
@@ -466,6 +468,7 @@ glitz_set_pixels (glitz_surface_t *dst,
data = malloc (stride * height);
if (!data) {
+ glitz_texture_unbind (gl, texture);
glitz_surface_pop_current (dst);
glitz_surface_status_add (dst, GLITZ_STATUS_NO_MEMORY_MASK);
return;
@@ -494,18 +497,14 @@ glitz_set_pixels (glitz_surface_t *dst,
pixels = data;
xoffset = 0;
bytes_per_line = stride;
+ bpp = dst_image.format->masks.bpp;
} else {
xoffset = format->xoffset;
bytes_per_line = format->bytes_per_line;
+ bpp = format->masks.bpp;
pixels = glitz_buffer_bind (buffer, GLITZ_GL_PIXEL_UNPACK_BUFFER);
pixels += format->skip_lines * bytes_per_line;
}
-
- glitz_texture_bind (gl, texture);
-
- gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, 0);
- gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_ROWS, 0);
- gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_PIXELS, xoffset);
if (bytes_per_line) {
if ((bytes_per_line % 4) == 0)
@@ -516,8 +515,15 @@ glitz_set_pixels (glitz_surface_t *dst,
gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
else
gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
- } else
+
+ gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, bytes_per_line / (bpp / 8));
+ } else {
gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 1);
+ gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, 0);
+ }
+
+ gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_ROWS, 0);
+ gl->pixel_store_i (GLITZ_GL_UNPACK_SKIP_PIXELS, xoffset);
gl->tex_sub_image_2d (texture->target, 0,
texture->box.x1 + x_dst,
@@ -526,6 +532,9 @@ glitz_set_pixels (glitz_surface_t *dst,
gl_format->format, gl_format->type,
pixels);
+ if (transform == 0)
+ glitz_buffer_unbind (buffer);
+
if (to_drawable) {
glitz_texture_set_tex_gen (gl, texture, x_dst, y_dst, 0);
@@ -556,12 +565,9 @@ glitz_set_pixels (glitz_surface_t *dst,
glitz_texture_unbind (gl, texture);
dst->flags |= GLITZ_SURFACE_FLAG_SOLID_DIRTY_MASK;
-
- if (transform == 0)
- glitz_buffer_unbind (buffer);
glitz_surface_pop_current (dst);
-
+
if (data)
free (data);
}
@@ -582,7 +588,7 @@ glitz_get_pixels (glitz_surface_t *src,
glitz_gl_pixel_format_t *gl_format = NULL;
unsigned long transform = 0;
int src_x = 0, src_y = 0, src_w = width, src_h = height;
- int xoffset, bytes_per_line;
+ int xoffset, bytes_per_line, bpp;
if (x_src < 0 || x_src > (src->width - width) ||
y_src < 0 || y_src > (src->height - height)) {
@@ -603,7 +609,7 @@ glitz_get_pixels (glitz_surface_t *src,
return;
}
- transform |= GLITZ_TRANSFORM_COPY_REGION_MASK;
+ transform |= GLITZ_TRANSFORM_COPY_BOX_MASK;
}
if (format->scanline_order == GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN)
@@ -619,7 +625,7 @@ glitz_get_pixels (glitz_surface_t *src,
if (transform) {
int stride;
- if (transform & GLITZ_TRANSFORM_COPY_REGION_MASK) {
+ if (transform & GLITZ_TRANSFORM_COPY_BOX_MASK) {
src_w = texture->width;
src_h = texture->height;
src_x = x_src + texture->box.x1;
@@ -636,28 +642,33 @@ glitz_get_pixels (glitz_surface_t *src,
pixels = data;
xoffset = 0;
bytes_per_line = stride;
+ bpp = gl_format->pixel.masks.bpp;
} else {
xoffset = format->xoffset;
bytes_per_line = format->bytes_per_line;
+ bpp = format->masks.bpp;
pixels = glitz_buffer_bind (buffer, GLITZ_GL_PIXEL_PACK_BUFFER);
pixels += format->skip_lines * bytes_per_line;
}
- gl->pixel_store_i (GLITZ_GL_PACK_ROW_LENGTH, 0);
gl->pixel_store_i (GLITZ_GL_PACK_SKIP_ROWS, 0);
gl->pixel_store_i (GLITZ_GL_PACK_SKIP_PIXELS, xoffset);
-
+
if (bytes_per_line) {
if ((bytes_per_line % 4) == 0)
- gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 4);
+ gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 4);
else if ((bytes_per_line % 3) == 0)
- gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 3);
+ gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 3);
else if ((bytes_per_line % 2) == 0)
- gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
+ gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 2);
else
- gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 2);
- } else
- gl->pixel_store_i (GLITZ_GL_UNPACK_ALIGNMENT, 1);
+ gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 2);
+
+ gl->pixel_store_i (GLITZ_GL_PACK_ROW_LENGTH, bytes_per_line / (bpp / 8));
+ } else {
+ gl->pixel_store_i (GLITZ_GL_PACK_ALIGNMENT, 1);
+ gl->pixel_store_i (GLITZ_GL_PACK_ROW_LENGTH, 0);
+ }
if (from_drawable) {
gl->read_pixels (x_src, src->height - y_src - height,