[PATCH 4/9] compositor: Add per output and per surface renderer state.
John Kåre Alsaker
john.kare.alsaker at gmail.com
Sat Sep 15 11:34:02 PDT 2012
---
src/compositor.h | 4 ++++
src/gles2-renderer.c | 44 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/src/compositor.h b/src/compositor.h
index 9ad1753..3a9f4bc 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -149,6 +149,8 @@ enum dpms_enum {
struct weston_output {
uint32_t id;
+ void *renderer_state;
+
EGLSurface egl_surface;
struct wl_list link;
struct wl_list resource_list;
@@ -413,6 +415,8 @@ struct weston_surface {
GLfloat alpha;
struct weston_plane *plane;
+ void *renderer_state;
+
/* Surface geometry state, mutable.
* If you change anything, set dirty = 1.
* That includes the transformations referenced from the list.
diff --git a/src/gles2-renderer.c b/src/gles2-renderer.c
index cd36167..abd2a37 100644
--- a/src/gles2-renderer.c
+++ b/src/gles2-renderer.c
@@ -30,6 +30,34 @@
#include "compositor.h"
+struct gles2_output_state {
+};
+
+struct gles2_surface_state {
+};
+
+struct gles2_renderer {
+ struct weston_renderer base;
+};
+
+static struct gles2_output_state *
+get_output_state(struct weston_output *output)
+{
+ return (struct gles2_output_state *)output->renderer_state;
+}
+
+static struct gles2_surface_state *
+get_surface_state(struct weston_surface *surface)
+{
+ return (struct gles2_surface_state *)surface->renderer_state;
+}
+
+static struct gles2_renderer *
+get_renderer(struct weston_compositor *ec)
+{
+ return (struct gles2_renderer *)ec->renderer;
+}
+
static const char *
egl_error_string(EGLint code)
{
@@ -910,12 +938,22 @@ gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
static int
gles2_renderer_create_surface(struct weston_surface *surface)
{
+ struct gles2_surface_state *state;
+
+ state = calloc(1, sizeof *state);
+
+ if(!state)
+ return -1;
+
+ surface->renderer_state = state;
+
return 0;
}
static void
gles2_renderer_destroy_surface(struct weston_surface *surface)
{
+ struct gles2_surface_state *state = get_surface_state(surface);
struct weston_compositor *ec = surface->compositor;
int i;
@@ -923,6 +961,8 @@ gles2_renderer_destroy_surface(struct weston_surface *surface)
for (i = 0; i < surface->num_images; i++)
ec->destroy_image(ec->egl_display, surface->images[i]);
+
+ free(state);
}
static const char vertex_shader[] =
@@ -1139,10 +1179,6 @@ log_egl_gl_info(EGLDisplay egldpy)
log_extensions("GL extensions", str ? str : "(null)");
}
-struct gles2_renderer {
- struct weston_renderer base;
-};
-
static int
create_renderer(struct weston_compositor *ec)
{
--
1.7.12
More information about the wayland-devel
mailing list