Rename gles2-renderer to gl-renderer.

John Kåre Alsaker 12 years ago committed by Kristian Høgsberg
parent 30d2b1fd4b
commit 779b52ac3a
  1. 2
      src/Makefile.am
  2. 18
      src/compositor-android.c
  3. 20
      src/compositor-drm.c
  4. 24
      src/compositor-rpi.c
  5. 22
      src/compositor-wayland.c
  6. 14
      src/compositor-x11.c
  7. 171
      src/gl-renderer.c
  8. 18
      src/gl-renderer.h

@ -35,7 +35,7 @@ weston_SOURCES = \
matrix.c \ matrix.c \
matrix.h \ matrix.h \
gl-renderer.h \ gl-renderer.h \
gles2-renderer.c \ gl-renderer.c \
noop-renderer.c \ noop-renderer.c \
weston-launch.h \ weston-launch.h \
weston-egl-ext.h weston-egl-ext.h

@ -109,7 +109,7 @@ android_output_destroy(struct weston_output *base)
wl_list_remove(&output->base.link); wl_list_remove(&output->base.link);
weston_output_destroy(&output->base); weston_output_destroy(&output->base);
gles2_renderer_output_destroy(base); gl_renderer_output_destroy(base);
android_framebuffer_destroy(output->fb); android_framebuffer_destroy(output->fb);
@ -288,14 +288,14 @@ android_init_egl(struct android_compositor *compositor,
{ {
EGLint visual_id = output->fb->format; EGLint visual_id = output->fb->format;
if (gles2_renderer_create(&compositor->base, if (gl_renderer_create(&compositor->base,
EGL_DEFAULT_DISPLAY, gles2_renderer_opaque_attribs, EGL_DEFAULT_DISPLAY, gl_renderer_opaque_attribs,
&visual_id) < 0) &visual_id) < 0)
return -1; return -1;
if (gles2_renderer_output_create(&output->base, if (gl_renderer_output_create(&output->base,
output->fb->native_window) < 0) { output->fb->native_window) < 0) {
gles2_renderer_destroy(&compositor->base); gl_renderer_destroy(&compositor->base);
return -1; return -1;
} }
@ -309,7 +309,7 @@ android_compositor_destroy(struct weston_compositor *base)
android_seat_destroy(compositor->seat); android_seat_destroy(compositor->seat);
gles2_renderer_destroy(base); gl_renderer_destroy(base);
/* destroys outputs, too */ /* destroys outputs, too */
weston_compositor_shutdown(&compositor->base); weston_compositor_shutdown(&compositor->base);
@ -349,12 +349,12 @@ android_compositor_create(struct wl_display *display, int argc, char *argv[],
compositor->seat = android_seat_create(compositor); compositor->seat = android_seat_create(compositor);
if (!compositor->seat) if (!compositor->seat)
goto err_gles2; goto err_gl;
return &compositor->base; return &compositor->base;
err_gles2: err_gl:
gles2_renderer_destroy(&compositor->base); gl_renderer_destroy(&compositor->base);
err_output: err_output:
android_output_destroy(&output->base); android_output_destroy(&output->base);
err_compositor: err_compositor:

@ -830,7 +830,7 @@ drm_output_destroy(struct weston_output *output_base)
c->crtc_allocator &= ~(1 << output->crtc_id); c->crtc_allocator &= ~(1 << output->crtc_id);
c->connector_allocator &= ~(1 << output->connector_id); c->connector_allocator &= ~(1 << output->connector_id);
gles2_renderer_output_destroy(output_base); gl_renderer_output_destroy(output_base);
gbm_surface_destroy(output->surface); gbm_surface_destroy(output->surface);
@ -936,9 +936,9 @@ drm_output_switch_mode(struct weston_output *output_base, struct weston_mode *mo
return -1; return -1;
} }
gles2_renderer_output_destroy(&output->base); gl_renderer_output_destroy(&output->base);
if (!gles2_renderer_output_create(&output->base, surface)) { if (!gl_renderer_output_create(&output->base, surface)) {
weston_log("failed to create renderer output\n"); weston_log("failed to create renderer output\n");
goto err_gbm; goto err_gbm;
} }
@ -949,7 +949,7 @@ drm_output_switch_mode(struct weston_output *output_base, struct weston_mode *mo
&output->connector_id, 1, &drm_mode->mode_info); &output->connector_id, 1, &drm_mode->mode_info);
if (ret) { if (ret) {
weston_log("failed to set mode\n"); weston_log("failed to set mode\n");
goto err_gles2; goto err_gl;
} }
/* reset rendering stuff. */ /* reset rendering stuff. */
@ -980,8 +980,8 @@ drm_output_switch_mode(struct weston_output *output_base, struct weston_mode *mo
weston_output_move(&output->base, output->base.x, output->base.y); weston_output_move(&output->base, output->base.x, output->base.y);
return 0; return 0;
err_gles2: err_gl:
gles2_renderer_output_destroy(&output->base); gl_renderer_output_destroy(&output->base);
err_gbm: err_gbm:
gbm_surface_destroy(surface); gbm_surface_destroy(surface);
return -1; return -1;
@ -1029,7 +1029,7 @@ init_egl(struct drm_compositor *ec, struct udev_device *device)
ec->drm.fd = fd; ec->drm.fd = fd;
ec->gbm = gbm_create_device(ec->drm.fd); ec->gbm = gbm_create_device(ec->drm.fd);
if (gles2_renderer_create(&ec->base, ec->gbm, gles2_renderer_opaque_attribs, if (gl_renderer_create(&ec->base, ec->gbm, gl_renderer_opaque_attribs,
NULL) < 0) { NULL) < 0) {
gbm_device_destroy(ec->gbm); gbm_device_destroy(ec->gbm);
return -1; return -1;
@ -1368,7 +1368,7 @@ create_output_for_connector(struct drm_compositor *ec,
connector->mmWidth, connector->mmHeight, connector->mmWidth, connector->mmHeight,
o ? o->transform : WL_OUTPUT_TRANSFORM_NORMAL); o ? o->transform : WL_OUTPUT_TRANSFORM_NORMAL);
if (gles2_renderer_output_create(&output->base, output->surface) < 0) if (gl_renderer_output_create(&output->base, output->surface) < 0)
goto err_output; goto err_output;
output->cursor_bo[0] = output->cursor_bo[0] =
@ -1948,7 +1948,7 @@ drm_destroy(struct weston_compositor *ec)
weston_compositor_shutdown(ec); weston_compositor_shutdown(ec);
gles2_renderer_destroy(ec); gl_renderer_destroy(ec);
destroy_sprites(d); destroy_sprites(d);
gbm_device_destroy(d->gbm); gbm_device_destroy(d->gbm);
@ -2233,7 +2233,7 @@ err_drm_source:
wl_list_for_each_safe(weston_seat, next, &ec->base.seat_list, link) wl_list_for_each_safe(weston_seat, next, &ec->base.seat_list, link)
evdev_input_destroy(weston_seat); evdev_input_destroy(weston_seat);
err_sprite: err_sprite:
gles2_renderer_destroy(&ec->base); gl_renderer_destroy(&ec->base);
gbm_device_destroy(ec->gbm); gbm_device_destroy(ec->gbm);
destroy_sprites(ec); destroy_sprites(ec);
err_udev_dev: err_udev_dev:

@ -971,7 +971,7 @@ rpi_output_destroy(struct weston_output *base)
vc_dispmanx_element_remove(update, output->egl_element); vc_dispmanx_element_remove(update, output->egl_element);
vc_dispmanx_update_submit_sync(update); vc_dispmanx_update_submit_sync(update);
gles2_renderer_output_destroy(base); gl_renderer_output_destroy(base);
wl_list_for_each_safe(element, tmp, &output->element_list, link) wl_list_for_each_safe(element, tmp, &output->element_list, link)
rpi_element_destroy(element); rpi_element_destroy(element);
@ -1086,16 +1086,16 @@ rpi_output_create(struct rpi_compositor *compositor)
0, 0, round(mm_width), round(mm_height), 0, 0, round(mm_width), round(mm_height),
WL_OUTPUT_TRANSFORM_NORMAL); WL_OUTPUT_TRANSFORM_NORMAL);
if (gles2_renderer_output_create(&output->base, if (gl_renderer_output_create(&output->base,
(EGLNativeWindowType)&output->egl_window) < 0) (EGLNativeWindowType)&output->egl_window) < 0)
goto out_output; goto out_output;
if (!eglSurfaceAttrib(gles2_renderer_display(&compositor->base), if (!eglSurfaceAttrib(gl_renderer_display(&compositor->base),
gles2_renderer_output_surface(&output->base), gl_renderer_output_surface(&output->base),
EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED)) { EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED)) {
print_egl_error_state(); print_egl_error_state();
weston_log("Failed to set swap behaviour to preserved.\n"); weston_log("Failed to set swap behaviour to preserved.\n");
goto out_gles2; goto out_gl;
} }
wl_list_insert(compositor->base.output_list.prev, &output->base.link); wl_list_insert(compositor->base.output_list.prev, &output->base.link);
@ -1107,8 +1107,8 @@ rpi_output_create(struct rpi_compositor *compositor)
return 0; return 0;
out_gles2: out_gl:
gles2_renderer_output_destroy(&output->base); gl_renderer_output_destroy(&output->base);
out_output: out_output:
weston_output_destroy(&output->base); weston_output_destroy(&output->base);
update = vc_dispmanx_update_start(0); update = vc_dispmanx_update_start(0);
@ -1368,7 +1368,7 @@ rpi_compositor_destroy(struct weston_compositor *base)
/* destroys outputs, too */ /* destroys outputs, too */
weston_compositor_shutdown(&compositor->base); weston_compositor_shutdown(&compositor->base);
gles2_renderer_destroy(&compositor->base); gl_renderer_destroy(&compositor->base);
tty_destroy(compositor->tty); tty_destroy(compositor->tty);
bcm_host_deinit(); bcm_host_deinit();
@ -1510,19 +1510,19 @@ rpi_compositor_create(struct wl_display *display, int argc, char *argv[],
*/ */
bcm_host_init(); bcm_host_init();
if (gles2_renderer_create(&compositor->base, EGL_DEFAULT_DISPLAY, if (gl_renderer_create(&compositor->base, EGL_DEFAULT_DISPLAY,
config_attrs, NULL) < 0) config_attrs, NULL) < 0)
goto out_tty; goto out_tty;
if (rpi_output_create(compositor) < 0) if (rpi_output_create(compositor) < 0)
goto out_gles2; goto out_gl;
evdev_input_create(&compositor->base, compositor->udev, seat); evdev_input_create(&compositor->base, compositor->udev, seat);
return &compositor->base; return &compositor->base;
out_gles2: out_gl:
gles2_renderer_destroy(&compositor->base); gl_renderer_destroy(&compositor->base);
out_tty: out_tty:
tty_destroy(compositor->tty); tty_destroy(compositor->tty);

@ -105,7 +105,7 @@ create_border(struct wayland_compositor *c)
edges[2] = c->border.top; edges[2] = c->border.top;
edges[3] = c->border.bottom; edges[3] = c->border.bottom;
gles2_renderer_set_border(&c->base, pixman_image_get_width(image), gl_renderer_set_border(&c->base, pixman_image_get_width(image),
pixman_image_get_height(image), pixman_image_get_height(image),
pixman_image_get_data(image), edges); pixman_image_get_data(image), edges);
@ -144,7 +144,7 @@ wayland_output_destroy(struct weston_output *output_base)
{ {
struct wayland_output *output = (struct wayland_output *) output_base; struct wayland_output *output = (struct wayland_output *) output_base;
gles2_renderer_output_destroy(output_base); gl_renderer_output_destroy(output_base);
wl_egl_window_destroy(output->parent.egl_window); wl_egl_window_destroy(output->parent.egl_window);
free(output); free(output);
@ -195,7 +195,7 @@ wayland_compositor_create_output(struct wayland_compositor *c,
goto cleanup_output; goto cleanup_output;
} }
if (gles2_renderer_output_create(&output->base, if (gl_renderer_output_create(&output->base,
output->parent.egl_window) < 0) output->parent.egl_window) < 0)
goto cleanup_window; goto cleanup_window;
@ -607,7 +607,7 @@ wayland_restore(struct weston_compositor *ec)
static void static void
wayland_destroy(struct weston_compositor *ec) wayland_destroy(struct weston_compositor *ec)
{ {
gles2_renderer_destroy(ec); gl_renderer_destroy(ec);
weston_compositor_shutdown(ec); weston_compositor_shutdown(ec);
@ -646,8 +646,8 @@ wayland_compositor_create(struct wl_display *display,
wl_display_dispatch(c->parent.wl_display); wl_display_dispatch(c->parent.wl_display);
c->base.wl_display = display; c->base.wl_display = display;
if (gles2_renderer_create(&c->base, c->parent.wl_display, if (gl_renderer_create(&c->base, c->parent.wl_display,
gles2_renderer_alpha_attribs, gl_renderer_alpha_attribs,
NULL) < 0) NULL) < 0)
goto err_display; goto err_display;
@ -661,9 +661,9 @@ wayland_compositor_create(struct wl_display *display,
/* requires border fields */ /* requires border fields */
if (wayland_compositor_create_output(c, width, height) < 0) if (wayland_compositor_create_output(c, width, height) < 0)
goto err_gles2; goto err_gl;
/* requires gles2_renderer_output_state_create called /* requires gl_renderer_output_state_create called
* by wayland_compositor_create_output */ * by wayland_compositor_create_output */
create_border(c); create_border(c);
@ -674,14 +674,14 @@ wayland_compositor_create(struct wl_display *display,
wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE, wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE,
wayland_compositor_handle_event, c); wayland_compositor_handle_event, c);
if (c->parent.wl_source == NULL) if (c->parent.wl_source == NULL)
goto err_gles2; goto err_gl;
wl_event_source_check(c->parent.wl_source); wl_event_source_check(c->parent.wl_source);
return &c->base; return &c->base;
err_gles2: err_gl:
gles2_renderer_destroy(&c->base); gl_renderer_destroy(&c->base);
err_display: err_display:
wl_display_disconnect(c->parent.wl_display); wl_display_disconnect(c->parent.wl_display);
err_compositor: err_compositor:

@ -341,7 +341,7 @@ x11_output_destroy(struct weston_output *output_base)
wl_list_remove(&output->base.link); wl_list_remove(&output->base.link);
wl_event_source_remove(output->finish_frame_timer); wl_event_source_remove(output->finish_frame_timer);
gles2_renderer_output_destroy(output_base); gl_renderer_output_destroy(output_base);
xcb_destroy_window(compositor->conn, output->window); xcb_destroy_window(compositor->conn, output->window);
@ -570,7 +570,7 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
weston_output_init(&output->base, &c->base, weston_output_init(&output->base, &c->base,
x, y, width, height, transform); x, y, width, height, transform);
if (gles2_renderer_output_create(&output->base, output->window) < 0) if (gl_renderer_output_create(&output->base, output->window) < 0)
return NULL; return NULL;
loop = wl_display_get_event_loop(c->base.wl_display); loop = wl_display_get_event_loop(c->base.wl_display);
@ -1104,7 +1104,7 @@ x11_destroy(struct weston_compositor *ec)
weston_compositor_shutdown(ec); /* destroys outputs, too */ weston_compositor_shutdown(ec); /* destroys outputs, too */
gles2_renderer_destroy(ec); gl_renderer_destroy(ec);
XCloseDisplay(compositor->dpy); XCloseDisplay(compositor->dpy);
free(ec); free(ec);
@ -1152,7 +1152,7 @@ x11_compositor_create(struct wl_display *display,
x11_compositor_get_resources(c); x11_compositor_get_resources(c);
c->base.wl_display = display; c->base.wl_display = display;
if (gles2_renderer_create(&c->base, c->dpy, gles2_renderer_opaque_attribs, if (gl_renderer_create(&c->base, c->dpy, gl_renderer_opaque_attribs,
NULL) < 0) NULL) < 0)
goto err_xdisplay; goto err_xdisplay;
@ -1160,7 +1160,7 @@ x11_compositor_create(struct wl_display *display,
c->base.restore = x11_restore; c->base.restore = x11_restore;
if (x11_input_create(c, no_input) < 0) if (x11_input_create(c, no_input) < 0)
goto err_gles2; goto err_gl;
width = option_width ? option_width : 1024; width = option_width ? option_width : 1024;
height = option_height ? option_height : 640; height = option_height ? option_height : 640;
@ -1204,8 +1204,8 @@ x11_compositor_create(struct wl_display *display,
err_x11_input: err_x11_input:
x11_input_destroy(c); x11_input_destroy(c);
err_gles2: err_gl:
gles2_renderer_destroy(&c->base); gl_renderer_destroy(&c->base);
err_xdisplay: err_xdisplay:
XCloseDisplay(c->dpy); XCloseDisplay(c->dpy);
err_free: err_free:

@ -37,7 +37,7 @@
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include "weston-egl-ext.h" #include "weston-egl-ext.h"
struct gles2_shader { struct gl_shader {
GLuint program; GLuint program;
GLuint vertex_shader, fragment_shader; GLuint vertex_shader, fragment_shader;
GLint proj_uniform; GLint proj_uniform;
@ -46,13 +46,13 @@ struct gles2_shader {
GLint color_uniform; GLint color_uniform;
}; };
struct gles2_output_state { struct gl_output_state {
EGLSurface egl_surface; EGLSurface egl_surface;
}; };
struct gles2_surface_state { struct gl_surface_state {
GLfloat color[4]; GLfloat color[4];
struct gles2_shader *shader; struct gl_shader *shader;
GLuint textures[3]; GLuint textures[3];
int num_textures; int num_textures;
@ -62,7 +62,7 @@ struct gles2_surface_state {
int num_images; int num_images;
}; };
struct gles2_renderer { struct gl_renderer {
struct weston_renderer base; struct weston_renderer base;
int fragment_shader_debug; int fragment_shader_debug;
@ -89,33 +89,33 @@ struct gles2_renderer {
int has_egl_image_external; int has_egl_image_external;
struct gles2_shader texture_shader_rgba; struct gl_shader texture_shader_rgba;
struct gles2_shader texture_shader_rgbx; struct gl_shader texture_shader_rgbx;
struct gles2_shader texture_shader_egl_external; struct gl_shader texture_shader_egl_external;
struct gles2_shader texture_shader_y_uv; struct gl_shader texture_shader_y_uv;
struct gles2_shader texture_shader_y_u_v; struct gl_shader texture_shader_y_u_v;
struct gles2_shader texture_shader_y_xuxv; struct gl_shader texture_shader_y_xuxv;
struct gles2_shader invert_color_shader; struct gl_shader invert_color_shader;
struct gles2_shader solid_shader; struct gl_shader solid_shader;
struct gles2_shader *current_shader; struct gl_shader *current_shader;
}; };
static inline struct gles2_output_state * static inline struct gl_output_state *
get_output_state(struct weston_output *output) get_output_state(struct weston_output *output)
{ {
return (struct gles2_output_state *)output->renderer_state; return (struct gl_output_state *)output->renderer_state;
} }
static inline struct gles2_surface_state * static inline struct gl_surface_state *
get_surface_state(struct weston_surface *surface) get_surface_state(struct weston_surface *surface)
{ {
return (struct gles2_surface_state *)surface->renderer_state; return (struct gl_surface_state *)surface->renderer_state;
} }
static inline struct gles2_renderer * static inline struct gl_renderer *
get_renderer(struct weston_compositor *ec) get_renderer(struct weston_compositor *ec)
{ {
return (struct gles2_renderer *)ec->renderer; return (struct gl_renderer *)ec->renderer;
} }
static const char * static const char *
@ -585,7 +585,7 @@ static void
triangle_fan_debug(struct weston_surface *surface, int first, int count) triangle_fan_debug(struct weston_surface *surface, int first, int count)
{ {
struct weston_compositor *compositor = surface->compositor; struct weston_compositor *compositor = surface->compositor;
struct gles2_renderer *gr = get_renderer(compositor); struct gl_renderer *gr = get_renderer(compositor);
int i; int i;
GLushort *buffer; GLushort *buffer;
GLushort *index; GLushort *index;
@ -669,8 +669,8 @@ static int
use_output(struct weston_output *output) use_output(struct weston_output *output)
{ {
static int errored; static int errored;
struct gles2_output_state *go = get_output_state(output); struct gl_output_state *go = get_output_state(output);
struct gles2_renderer *gr = get_renderer(output->compositor); struct gl_renderer *gr = get_renderer(output->compositor);
EGLBoolean ret; EGLBoolean ret;
ret = eglMakeCurrent(gr->egl_display, go->egl_surface, ret = eglMakeCurrent(gr->egl_display, go->egl_surface,
@ -689,8 +689,8 @@ use_output(struct weston_output *output)
} }
static void static void
use_shader(struct gles2_renderer *gr, use_shader(struct gl_renderer *gr,
struct gles2_shader *shader) struct gl_shader *shader)
{ {
if (gr->current_shader == shader) if (gr->current_shader == shader)
return; return;
@ -700,12 +700,12 @@ use_shader(struct gles2_renderer *gr,
} }
static void static void
shader_uniforms(struct gles2_shader *shader, shader_uniforms(struct gl_shader *shader,
struct weston_surface *surface, struct weston_surface *surface,
struct weston_output *output) struct weston_output *output)
{ {
int i; int i;
struct gles2_surface_state *gs = get_surface_state(surface); struct gl_surface_state *gs = get_surface_state(surface);
glUniformMatrix4fv(shader->proj_uniform, glUniformMatrix4fv(shader->proj_uniform,
1, GL_FALSE, output->matrix.d); 1, GL_FALSE, output->matrix.d);
@ -721,8 +721,8 @@ draw_surface(struct weston_surface *es, struct weston_output *output,
pixman_region32_t *damage) /* in global coordinates */ pixman_region32_t *damage) /* in global coordinates */
{ {
struct weston_compositor *ec = es->compositor; struct weston_compositor *ec = es->compositor;
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
struct gles2_surface_state *gs = get_surface_state(es); struct gl_surface_state *gs = get_surface_state(es);
/* repaint bounding region in global coordinates: */ /* repaint bounding region in global coordinates: */
pixman_region32_t repaint; pixman_region32_t repaint;
/* non-opaque region in surface coordinates: */ /* non-opaque region in surface coordinates: */
@ -816,7 +816,7 @@ static int
texture_border(struct weston_output *output) texture_border(struct weston_output *output)
{ {
struct weston_compositor *ec = output->compositor; struct weston_compositor *ec = output->compositor;
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
GLfloat *d; GLfloat *d;
unsigned int *p; unsigned int *p;
int i, j, k, n; int i, j, k, n;
@ -892,8 +892,8 @@ static void
draw_border(struct weston_output *output) draw_border(struct weston_output *output)
{ {
struct weston_compositor *ec = output->compositor; struct weston_compositor *ec = output->compositor;
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
struct gles2_shader *shader = &gr->texture_shader_rgba; struct gl_shader *shader = &gr->texture_shader_rgba;
GLfloat *v; GLfloat *v;
int n; int n;
@ -928,12 +928,12 @@ draw_border(struct weston_output *output)
} }
static void static void
gles2_renderer_repaint_output(struct weston_output *output, gl_renderer_repaint_output(struct weston_output *output,
pixman_region32_t *output_damage) pixman_region32_t *output_damage)
{ {
struct gles2_output_state *go = get_output_state(output); struct gl_output_state *go = get_output_state(output);
struct weston_compositor *compositor = output->compositor; struct weston_compositor *compositor = output->compositor;
struct gles2_renderer *gr = get_renderer(compositor); struct gl_renderer *gr = get_renderer(compositor);
EGLBoolean ret; EGLBoolean ret;
static int errored; static int errored;
int32_t width, height, i; int32_t width, height, i;
@ -989,7 +989,7 @@ gles2_renderer_repaint_output(struct weston_output *output,
} }
static int static int
gles2_renderer_read_pixels(struct weston_output *output, gl_renderer_read_pixels(struct weston_output *output,
pixman_format_code_t format, void *pixels, pixman_format_code_t format, void *pixels,
uint32_t x, uint32_t y, uint32_t x, uint32_t y,
uint32_t width, uint32_t height) uint32_t width, uint32_t height)
@ -1018,10 +1018,10 @@ gles2_renderer_read_pixels(struct weston_output *output,
} }
static void static void
gles2_renderer_flush_damage(struct weston_surface *surface) gl_renderer_flush_damage(struct weston_surface *surface)
{ {
struct gles2_renderer *gr = get_renderer(surface->compositor); struct gl_renderer *gr = get_renderer(surface->compositor);
struct gles2_surface_state *gs = get_surface_state(surface); struct gl_surface_state *gs = get_surface_state(surface);
#ifdef GL_UNPACK_ROW_LENGTH #ifdef GL_UNPACK_ROW_LENGTH
pixman_box32_t *rectangles; pixman_box32_t *rectangles;
@ -1074,7 +1074,7 @@ done:
} }
static void static void
ensure_textures(struct gles2_surface_state *gs, int num_textures) ensure_textures(struct gl_surface_state *gs, int num_textures)
{ {
int i; int i;
@ -1094,11 +1094,11 @@ ensure_textures(struct gles2_surface_state *gs, int num_textures)
} }
static void static void
gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer) gl_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
{ {
struct weston_compositor *ec = es->compositor; struct weston_compositor *ec = es->compositor;
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
struct gles2_surface_state *gs = get_surface_state(es); struct gl_surface_state *gs = get_surface_state(es);
EGLint attribs[3], format; EGLint attribs[3], format;
int i, num_planes; int i, num_planes;
@ -1186,11 +1186,11 @@ gles2_renderer_attach(struct weston_surface *es, struct wl_buffer *buffer)
} }
static void static void
gles2_renderer_surface_set_color(struct weston_surface *surface, gl_renderer_surface_set_color(struct weston_surface *surface,
float red, float green, float blue, float alpha) float red, float green, float blue, float alpha)
{ {
struct gles2_surface_state *gs = get_surface_state(surface); struct gl_surface_state *gs = get_surface_state(surface);
struct gles2_renderer *gr = get_renderer(surface->compositor); struct gl_renderer *gr = get_renderer(surface->compositor);
gs->color[0] = red; gs->color[0] = red;
gs->color[1] = green; gs->color[1] = green;
@ -1201,9 +1201,9 @@ gles2_renderer_surface_set_color(struct weston_surface *surface,
} }
static int static int
gles2_renderer_create_surface(struct weston_surface *surface) gl_renderer_create_surface(struct weston_surface *surface)
{ {
struct gles2_surface_state *gs; struct gl_surface_state *gs;
gs = calloc(1, sizeof *gs); gs = calloc(1, sizeof *gs);
@ -1216,10 +1216,10 @@ gles2_renderer_create_surface(struct weston_surface *surface)
} }
static void static void
gles2_renderer_destroy_surface(struct weston_surface *surface) gl_renderer_destroy_surface(struct weston_surface *surface)
{ {
struct gles2_surface_state *gs = get_surface_state(surface); struct gl_surface_state *gs = get_surface_state(surface);
struct gles2_renderer *gr = get_renderer(surface->compositor); struct gl_renderer *gr = get_renderer(surface->compositor);
int i; int i;
glDeleteTextures(gs->num_textures, gs->textures); glDeleteTextures(gs->num_textures, gs->textures);
@ -1359,15 +1359,14 @@ compile_shader(GLenum type, int count, const char **sources)
} }
static int static int
shader_init(struct gles2_shader *shader, struct weston_compositor *ec, shader_init(struct gl_shader *shader, struct weston_compositor *ec,
const char *vertex_source, const char *fragment_source) const char *vertex_source, const char *fragment_source)
{ {
char msg[512]; char msg[512];
GLint status; GLint status;
int count; int count;
const char *sources[3]; const char *sources[3];
struct gles2_renderer *renderer = struct gl_renderer *renderer = get_renderer(ec);
(struct gles2_renderer *) ec->renderer;
shader->vertex_shader = shader->vertex_shader =
compile_shader(GL_VERTEX_SHADER, 1, &vertex_source); compile_shader(GL_VERTEX_SHADER, 1, &vertex_source);
@ -1411,7 +1410,7 @@ shader_init(struct gles2_shader *shader, struct weston_compositor *ec,
} }
static void static void
shader_release(struct gles2_shader *shader) shader_release(struct gl_shader *shader)
{ {
glDeleteShader(shader->vertex_shader); glDeleteShader(shader->vertex_shader);
glDeleteShader(shader->fragment_shader); glDeleteShader(shader->fragment_shader);
@ -1503,7 +1502,7 @@ log_egl_config_info(EGLDisplay egldpy, EGLConfig eglconfig)
} }
static void static void
output_apply_border(struct weston_output *output, struct gles2_renderer *gr) output_apply_border(struct weston_output *output, struct gl_renderer *gr)
{ {
output->border.top = gr->border.top; output->border.top = gr->border.top;
output->border.bottom = gr->border.bottom; output->border.bottom = gr->border.bottom;
@ -1512,10 +1511,10 @@ output_apply_border(struct weston_output *output, struct gles2_renderer *gr)
} }
WL_EXPORT void WL_EXPORT void
gles2_renderer_set_border(struct weston_compositor *ec, int32_t width, int32_t height, void *data, gl_renderer_set_border(struct weston_compositor *ec, int32_t width, int32_t height, void *data,
int32_t *edges) int32_t *edges)
{ {
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
struct weston_output *output; struct weston_output *output;
gr->border.left = edges[0]; gr->border.left = edges[0];
@ -1544,15 +1543,15 @@ gles2_renderer_set_border(struct weston_compositor *ec, int32_t width, int32_t h
} }
static int static int
gles2_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface); gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface);
WL_EXPORT int WL_EXPORT int
gles2_renderer_output_create(struct weston_output *output, gl_renderer_output_create(struct weston_output *output,
EGLNativeWindowType window) EGLNativeWindowType window)
{ {
struct weston_compositor *ec = output->compositor; struct weston_compositor *ec = output->compositor;
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
struct gles2_output_state *go = calloc(1, sizeof *go); struct gl_output_state *go = calloc(1, sizeof *go);
if (!go) if (!go)
return -1; return -1;
@ -1569,7 +1568,7 @@ gles2_renderer_output_create(struct weston_output *output,
} }
if (gr->egl_context == NULL) if (gr->egl_context == NULL)
if (gles2_renderer_setup(ec, go->egl_surface) < 0) { if (gl_renderer_setup(ec, go->egl_surface) < 0) {
free(go); free(go);
return -1; return -1;
} }
@ -1582,10 +1581,10 @@ gles2_renderer_output_create(struct weston_output *output,
} }
WL_EXPORT void WL_EXPORT void
gles2_renderer_output_destroy(struct weston_output *output) gl_renderer_output_destroy(struct weston_output *output)
{ {
struct gles2_renderer *gr = get_renderer(output->compositor); struct gl_renderer *gr = get_renderer(output->compositor);
struct gles2_output_state *go = get_output_state(output); struct gl_output_state *go = get_output_state(output);
eglDestroySurface(gr->egl_display, go->egl_surface); eglDestroySurface(gr->egl_display, go->egl_surface);
@ -1593,15 +1592,15 @@ gles2_renderer_output_destroy(struct weston_output *output)
} }
WL_EXPORT EGLSurface WL_EXPORT EGLSurface
gles2_renderer_output_surface(struct weston_output *output) gl_renderer_output_surface(struct weston_output *output)
{ {
return get_output_state(output)->egl_surface; return get_output_state(output)->egl_surface;
} }
WL_EXPORT void WL_EXPORT void
gles2_renderer_destroy(struct weston_compositor *ec) gl_renderer_destroy(struct weston_compositor *ec)
{ {
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
if (gr->has_bind_display) if (gr->has_bind_display)
gr->unbind_display(gr->egl_display, ec->wl_display); gr->unbind_display(gr->egl_display, ec->wl_display);
@ -1616,7 +1615,7 @@ gles2_renderer_destroy(struct weston_compositor *ec)
} }
static int static int
egl_choose_config(struct gles2_renderer *gr, const EGLint *attribs, egl_choose_config(struct gl_renderer *gr, const EGLint *attribs,
const EGLint *visual_id) const EGLint *visual_id)
{ {
EGLint count = 0; EGLint count = 0;
@ -1659,7 +1658,7 @@ out:
return -1; return -1;
} }
WL_EXPORT const EGLint gles2_renderer_opaque_attribs[] = { WL_EXPORT const EGLint gl_renderer_opaque_attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RED_SIZE, 1, EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1, EGL_GREEN_SIZE, 1,
@ -1669,7 +1668,7 @@ WL_EXPORT const EGLint gles2_renderer_opaque_attribs[] = {
EGL_NONE EGL_NONE
}; };
WL_EXPORT const EGLint gles2_renderer_alpha_attribs[] = { WL_EXPORT const EGLint gl_renderer_alpha_attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RED_SIZE, 1, EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1, EGL_GREEN_SIZE, 1,
@ -1680,10 +1679,10 @@ WL_EXPORT const EGLint gles2_renderer_alpha_attribs[] = {
}; };
WL_EXPORT int WL_EXPORT int
gles2_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display, gl_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display,
const EGLint *attribs, const EGLint *visual_id) const EGLint *attribs, const EGLint *visual_id)
{ {
struct gles2_renderer *gr; struct gl_renderer *gr;
EGLint major, minor; EGLint major, minor;
gr = calloc(1, sizeof *gr); gr = calloc(1, sizeof *gr);
@ -1691,13 +1690,13 @@ gles2_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display
if (gr == NULL) if (gr == NULL)
return -1; return -1;
gr->base.read_pixels = gles2_renderer_read_pixels; gr->base.read_pixels = gl_renderer_read_pixels;
gr->base.repaint_output = gles2_renderer_repaint_output; gr->base.repaint_output = gl_renderer_repaint_output;
gr->base.flush_damage = gles2_renderer_flush_damage; gr->base.flush_damage = gl_renderer_flush_damage;
gr->base.attach = gles2_renderer_attach; gr->base.attach = gl_renderer_attach;
gr->base.create_surface = gles2_renderer_create_surface; gr->base.create_surface = gl_renderer_create_surface;
gr->base.surface_set_color = gles2_renderer_surface_set_color; gr->base.surface_set_color = gl_renderer_surface_set_color;
gr->base.destroy_surface = gles2_renderer_destroy_surface; gr->base.destroy_surface = gl_renderer_destroy_surface;
gr->egl_display = eglGetDisplay(display); gr->egl_display = eglGetDisplay(display);
if (gr->egl_display == EGL_NO_DISPLAY) { if (gr->egl_display == EGL_NO_DISPLAY) {
@ -1726,7 +1725,7 @@ err_egl:
} }
WL_EXPORT EGLDisplay WL_EXPORT EGLDisplay
gles2_renderer_display(struct weston_compositor *ec) gl_renderer_display(struct weston_compositor *ec)
{ {
return get_renderer(ec)->egl_display; return get_renderer(ec)->egl_display;
} }
@ -1734,7 +1733,7 @@ gles2_renderer_display(struct weston_compositor *ec)
static int static int
compile_shaders(struct weston_compositor *ec) compile_shaders(struct weston_compositor *ec)
{ {
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
if (shader_init(&gr->texture_shader_rgba, ec, if (shader_init(&gr->texture_shader_rgba, ec,
vertex_shader, texture_fragment_shader_rgba) < 0) vertex_shader, texture_fragment_shader_rgba) < 0)
@ -1767,7 +1766,7 @@ fragment_debug_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
void *data) void *data)
{ {
struct weston_compositor *ec = data; struct weston_compositor *ec = data;
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
struct weston_output *output; struct weston_output *output;
gr->fragment_shader_debug ^= 1; gr->fragment_shader_debug ^= 1;
@ -1787,9 +1786,9 @@ fragment_debug_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
} }
static int static int
gles2_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface) gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
{ {
struct gles2_renderer *gr = get_renderer(ec); struct gl_renderer *gr = get_renderer(ec);
const char *extensions; const char *extensions;
EGLBoolean ret; EGLBoolean ret;

@ -24,23 +24,23 @@
#include <EGL/egl.h> #include <EGL/egl.h>
extern const EGLint gles2_renderer_opaque_attribs[]; extern const EGLint gl_renderer_opaque_attribs[];
extern const EGLint gles2_renderer_alpha_attribs[]; extern const EGLint gl_renderer_alpha_attribs[];
int int
gles2_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display, gl_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display,
const EGLint *attribs, const EGLint *visual_id); const EGLint *attribs, const EGLint *visual_id);
EGLDisplay EGLDisplay
gles2_renderer_display(struct weston_compositor *ec); gl_renderer_display(struct weston_compositor *ec);
int int
gles2_renderer_output_create(struct weston_output *output, gl_renderer_output_create(struct weston_output *output,
EGLNativeWindowType window); EGLNativeWindowType window);
void void
gles2_renderer_output_destroy(struct weston_output *output); gl_renderer_output_destroy(struct weston_output *output);
EGLSurface EGLSurface
gles2_renderer_output_surface(struct weston_output *output); gl_renderer_output_surface(struct weston_output *output);
void void
gles2_renderer_set_border(struct weston_compositor *ec, int32_t width, int32_t height, void *data, gl_renderer_set_border(struct weston_compositor *ec, int32_t width, int32_t height, void *data,
int32_t *edges); int32_t *edges);
void void
gles2_renderer_destroy(struct weston_compositor *ec); gl_renderer_destroy(struct weston_compositor *ec);

Loading…
Cancel
Save