[PATCH weston 6/8] compositor: move pitch into renderer private

Pekka Paalanen ppaalanen at gmail.com
Fri Nov 23 05:56:55 PST 2012


It is not used by anything but the gl-renderer.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 src/compositor.c  |    1 -
 src/compositor.h  |    1 -
 src/gl-renderer.c |   14 ++++++++------
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 224e30d..2b55b1e 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -232,7 +232,6 @@ weston_surface_create(struct weston_compositor *compositor)
 
 	surface->compositor = compositor;
 	surface->alpha = 1.0;
-	surface->pitch = 1;
 
 	if (compositor->renderer->create_surface(surface) < 0) {
 		free(surface);
diff --git a/src/compositor.h b/src/compositor.h
index ed518b4..4a8e5df 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -381,7 +381,6 @@ struct weston_surface {
 	pixman_region32_t damage;
 	pixman_region32_t opaque;
 	pixman_region32_t input;
-	int32_t pitch;
 	struct wl_list link;
 	struct wl_list layer_link;
 	float alpha;
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index e56fd28..8b68dc6 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -65,6 +65,7 @@ struct gl_surface_state {
 
 	struct wl_buffer *buffer;
 	struct wl_listener buffer_destroy_listener;
+	int pitch; /* in pixels */
 };
 
 struct gl_renderer {
@@ -524,6 +525,7 @@ static int
 texture_region(struct weston_surface *es, pixman_region32_t *region,
 		pixman_region32_t *surf_region)
 {
+	struct gl_surface_state *gs = get_surface_state(es);
 	struct weston_compositor *ec = es->compositor;
 	GLfloat *v, inv_width, inv_height;
 	unsigned int *vtxcnt, nvtx = 0;
@@ -539,7 +541,7 @@ texture_region(struct weston_surface *es, pixman_region32_t *region,
 	v = wl_array_add(&ec->vertices, nrects * nsurf * 8 * 4 * sizeof *v);
 	vtxcnt = wl_array_add(&ec->vtxcnt, nrects * nsurf * sizeof *vtxcnt);
 
-	inv_width = 1.0 / es->pitch;
+	inv_width = 1.0 / gs->pitch;
 	inv_height = 1.0 / es->geometry.height;
 
 	for (i = 0; i < nrects; i++) {
@@ -1057,7 +1059,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)
 
 	if (!gr->has_unpack_subimage) {
 		glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
-			     surface->pitch, gs->buffer->height, 0,
+			     gs->pitch, gs->buffer->height, 0,
 			     GL_BGRA_EXT, GL_UNSIGNED_BYTE,
 			     wl_shm_buffer_get_data(gs->buffer));
 
@@ -1066,7 +1068,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)
 
 #ifdef GL_UNPACK_ROW_LENGTH
 	/* Mesa does not define GL_EXT_unpack_subimage */
-	glPixelStorei(GL_UNPACK_ROW_LENGTH, surface->pitch);
+	glPixelStorei(GL_UNPACK_ROW_LENGTH, gs->pitch);
 	data = wl_shm_buffer_get_data(gs->buffer);
 	rectangles = pixman_region32_rectangles(&surface->texture_damage, &n);
 	for (i = 0; i < n; i++) {
@@ -1132,13 +1134,13 @@ gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
 	}
 
 	if (wl_buffer_is_shm(buffer)) {
-		es->pitch = wl_shm_buffer_get_stride(buffer) / 4;
+		gs->pitch = wl_shm_buffer_get_stride(buffer) / 4;
 		gs->target = GL_TEXTURE_2D;
 
 		ensure_textures(gs, 1);
 		glBindTexture(GL_TEXTURE_2D, gs->textures[0]);
 		glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
-			     es->pitch, buffer->height, 0,
+			     gs->pitch, buffer->height, 0,
 			     GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
 		if (wl_shm_buffer_get_format(buffer) == WL_SHM_FORMAT_XRGB8888)
 			gs->shader = &gr->texture_shader_rgbx;
@@ -1197,7 +1199,7 @@ gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
 						    gs->images[i]);
 		}
 
-		es->pitch = buffer->width;
+		gs->pitch = buffer->width;
 	} else {
 		weston_log("unhandled buffer type!\n");
 		weston_buffer_reference(&gs->buffer, NULL,
-- 
1.7.8.6



More information about the wayland-devel mailing list