compositor: move pitch into renderer private

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

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
dev
Pekka Paalanen 12 years ago committed by Kristian Høgsberg
parent ccfeae2ad7
commit 68033ac353
  1. 1
      src/compositor.c
  2. 1
      src/compositor.h
  3. 21
      src/gl-renderer.c

@ -222,7 +222,6 @@ weston_surface_create(struct weston_compositor *compositor)
surface->compositor = compositor; surface->compositor = compositor;
surface->alpha = 1.0; surface->alpha = 1.0;
surface->pitch = 1;
if (compositor->renderer->create_surface(surface) < 0) { if (compositor->renderer->create_surface(surface) < 0) {
free(surface); free(surface);

@ -388,7 +388,6 @@ struct weston_surface {
pixman_region32_t damage; pixman_region32_t damage;
pixman_region32_t opaque; pixman_region32_t opaque;
pixman_region32_t input; pixman_region32_t input;
int32_t pitch;
struct wl_list link; struct wl_list link;
struct wl_list layer_link; struct wl_list layer_link;
float alpha; float alpha;

@ -64,6 +64,7 @@ struct gl_surface_state {
int num_images; int num_images;
struct weston_buffer_reference buffer_ref; struct weston_buffer_reference buffer_ref;
int pitch; /* in pixels */
}; };
struct gl_renderer { struct gl_renderer {
@ -523,6 +524,7 @@ static int
texture_region(struct weston_surface *es, pixman_region32_t *region, texture_region(struct weston_surface *es, pixman_region32_t *region,
pixman_region32_t *surf_region) pixman_region32_t *surf_region)
{ {
struct gl_surface_state *gs = get_surface_state(es);
struct weston_compositor *ec = es->compositor; struct weston_compositor *ec = es->compositor;
GLfloat *v, inv_width, inv_height; GLfloat *v, inv_width, inv_height;
unsigned int *vtxcnt, nvtx = 0; unsigned int *vtxcnt, nvtx = 0;
@ -538,7 +540,7 @@ texture_region(struct weston_surface *es, pixman_region32_t *region,
v = wl_array_add(&ec->vertices, nrects * nsurf * 8 * 4 * sizeof *v); v = wl_array_add(&ec->vertices, nrects * nsurf * 8 * 4 * sizeof *v);
vtxcnt = wl_array_add(&ec->vtxcnt, nrects * nsurf * sizeof *vtxcnt); vtxcnt = wl_array_add(&ec->vtxcnt, nrects * nsurf * sizeof *vtxcnt);
inv_width = 1.0 / es->pitch; inv_width = 1.0 / gs->pitch;
switch (es->buffer_transform) { switch (es->buffer_transform) {
case WL_OUTPUT_TRANSFORM_90: case WL_OUTPUT_TRANSFORM_90:
@ -1069,7 +1071,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)
if (!gr->has_unpack_subimage) { if (!gr->has_unpack_subimage) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
surface->pitch, buffer->height, 0, gs->pitch, buffer->height, 0,
GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA_EXT, GL_UNSIGNED_BYTE,
wl_shm_buffer_get_data(buffer)); wl_shm_buffer_get_data(buffer));
@ -1078,7 +1080,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)
#ifdef GL_UNPACK_ROW_LENGTH #ifdef GL_UNPACK_ROW_LENGTH
/* Mesa does not define GL_EXT_unpack_subimage */ /* 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(buffer); data = wl_shm_buffer_get_data(buffer);
rectangles = pixman_region32_rectangles(&surface->texture_damage, &n); rectangles = pixman_region32_rectangles(&surface->texture_damage, &n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -1144,13 +1146,13 @@ gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
} }
if (wl_buffer_is_shm(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; gs->target = GL_TEXTURE_2D;
ensure_textures(gs, 1); ensure_textures(gs, 1);
glBindTexture(GL_TEXTURE_2D, gs->textures[0]); glBindTexture(GL_TEXTURE_2D, gs->textures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, 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); GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
if (wl_shm_buffer_get_format(buffer) == WL_SHM_FORMAT_XRGB8888) if (wl_shm_buffer_get_format(buffer) == WL_SHM_FORMAT_XRGB8888)
gs->shader = &gr->texture_shader_rgbx; gs->shader = &gr->texture_shader_rgbx;
@ -1209,7 +1211,7 @@ gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
gs->images[i]); gs->images[i]);
} }
es->pitch = buffer->width; gs->pitch = buffer->width;
} else { } else {
weston_log("unhandled buffer type!\n"); weston_log("unhandled buffer type!\n");
weston_buffer_reference(&gs->buffer_ref, NULL); weston_buffer_reference(&gs->buffer_ref, NULL);
@ -1237,10 +1239,15 @@ gl_renderer_create_surface(struct weston_surface *surface)
struct gl_surface_state *gs; struct gl_surface_state *gs;
gs = calloc(1, sizeof *gs); gs = calloc(1, sizeof *gs);
if (!gs) if (!gs)
return -1; return -1;
/* A buffer is never attached to solid color surfaces, yet
* they still go through texcoord computations. Do not divide
* by zero there.
*/
gs->pitch = 1;
surface->renderer_state = gs; surface->renderer_state = gs;
return 0; return 0;

Loading…
Cancel
Save