compositor: Move gl-renderer vertex arrays into gl-renderer.c

They were still sitting in struct weston_compositor.
Kristian Høgsberg 12 years ago
parent 659f2adacf
commit 7b9195f9d6
  1. 4
      src/compositor.c
  2. 3
      src/compositor.h
  3. 35
      src/gl-renderer.c

@ -2072,10 +2072,6 @@ weston_compositor_shutdown(struct weston_compositor *ec)
weston_plane_release(&ec->primary_plane); weston_plane_release(&ec->primary_plane);
wl_array_release(&ec->vertices);
wl_array_release(&ec->indices);
wl_array_release(&ec->vtxcnt);
wl_event_loop_destroy(ec->input_loop); wl_event_loop_destroy(ec->input_loop);
} }

@ -523,9 +523,6 @@ struct weston_compositor {
int idle_time; /* timeout, s */ int idle_time; /* timeout, s */
/* Repaint state. */ /* Repaint state. */
struct wl_array vertices;
struct wl_array indices; /* only used in compositor-wayland */
struct wl_array vtxcnt;
struct weston_plane primary_plane; struct weston_plane primary_plane;
uint32_t focus; uint32_t focus;

@ -84,6 +84,10 @@ struct gl_renderer {
int32_t width, height; int32_t width, height;
} border; } border;
struct wl_array vertices;
struct wl_array indices; /* only used in compositor-wayland */
struct wl_array vtxcnt;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d; PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
PFNEGLCREATEIMAGEKHRPROC create_image; PFNEGLCREATEIMAGEKHRPROC create_image;
PFNEGLDESTROYIMAGEKHRPROC destroy_image; PFNEGLDESTROYIMAGEKHRPROC destroy_image;
@ -531,6 +535,7 @@ texture_region(struct weston_surface *es, pixman_region32_t *region,
{ {
struct gl_surface_state *gs = get_surface_state(es); struct gl_surface_state *gs = get_surface_state(es);
struct weston_compositor *ec = es->compositor; struct weston_compositor *ec = es->compositor;
struct gl_renderer *gr = get_renderer(ec);
GLfloat *v, inv_width, inv_height; GLfloat *v, inv_width, inv_height;
unsigned int *vtxcnt, nvtx = 0; unsigned int *vtxcnt, nvtx = 0;
pixman_box32_t *rects, *surf_rects; pixman_box32_t *rects, *surf_rects;
@ -542,8 +547,8 @@ texture_region(struct weston_surface *es, pixman_region32_t *region,
/* worst case we can have 8 vertices per rect (ie. clipped into /* worst case we can have 8 vertices per rect (ie. clipped into
* an octagon): * an octagon):
*/ */
v = wl_array_add(&ec->vertices, nrects * nsurf * 8 * 4 * sizeof *v); v = wl_array_add(&gr->vertices, nrects * nsurf * 8 * 4 * sizeof *v);
vtxcnt = wl_array_add(&ec->vtxcnt, nrects * nsurf * sizeof *vtxcnt); vtxcnt = wl_array_add(&gr->vtxcnt, nrects * nsurf * sizeof *vtxcnt);
inv_width = 1.0 / gs->pitch; inv_width = 1.0 / gs->pitch;
@ -660,12 +665,12 @@ repaint_region(struct weston_surface *es, pixman_region32_t *region,
* coordinates. texture_region() will iterate over all pairs of * coordinates. texture_region() will iterate over all pairs of
* rectangles from both regions, compute the intersection * rectangles from both regions, compute the intersection
* polygon for each pair, and store it as a triangle fan if * polygon for each pair, and store it as a triangle fan if
* it has a non-zero area (at least 3 vertices, actually). * it has a non-zero area (at least 3 vertices1, actually).
*/ */
nfans = texture_region(es, region, surf_region); nfans = texture_region(es, region, surf_region);
v = ec->vertices.data; v = gr->vertices.data;
vtxcnt = ec->vtxcnt.data; vtxcnt = gr->vtxcnt.data;
/* position: */ /* position: */
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]);
@ -685,8 +690,8 @@ repaint_region(struct weston_surface *es, pixman_region32_t *region,
glDisableVertexAttribArray(1); glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0); glDisableVertexAttribArray(0);
ec->vertices.size = 0; gr->vertices.size = 0;
ec->vtxcnt.size = 0; gr->vtxcnt.size = 0;
} }
static int static int
@ -863,8 +868,8 @@ texture_border(struct weston_output *output)
v[3] = 1.0; v[3] = 1.0;
n = 8; n = 8;
d = wl_array_add(&ec->vertices, n * 16 * sizeof *d); d = wl_array_add(&gr->vertices, n * 16 * sizeof *d);
p = wl_array_add(&ec->indices, n * 6 * sizeof *p); p = wl_array_add(&gr->indices, n * 6 * sizeof *p);
k = 0; k = 0;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
@ -931,20 +936,20 @@ draw_border(struct weston_output *output)
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, gr->border.texture); glBindTexture(GL_TEXTURE_2D, gr->border.texture);
v = ec->vertices.data; v = gr->vertices.data;
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[0]);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[2]); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof *v, &v[2]);
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1); glEnableVertexAttribArray(1);
glDrawElements(GL_TRIANGLES, n * 6, glDrawElements(GL_TRIANGLES, n * 6,
GL_UNSIGNED_INT, ec->indices.data); GL_UNSIGNED_INT, gr->indices.data);
glDisableVertexAttribArray(1); glDisableVertexAttribArray(1);
glDisableVertexAttribArray(0); glDisableVertexAttribArray(0);
ec->vertices.size = 0; gr->vertices.size = 0;
ec->indices.size = 0; gr->indices.size = 0;
} }
static void static void
@ -1710,6 +1715,10 @@ gl_renderer_destroy(struct weston_compositor *ec)
eglTerminate(gr->egl_display); eglTerminate(gr->egl_display);
eglReleaseThread(); eglReleaseThread();
wl_array_release(&gr->vertices);
wl_array_release(&gr->indices);
wl_array_release(&gr->vtxcnt);
free(gr); free(gr);
} }

Loading…
Cancel
Save