[cairo-commit] rendertest/src Makefile.am, 1.5, 1.6 glitz_egl.c, NONE, 1.1

Jon Smirl commit at pdx.freedesktop.org
Thu May 19 18:26:14 PDT 2005


Committed by: jonsmirl

Update of /cvs/cairo/rendertest/src
In directory gabe:/tmp/cvs-serv6400/src

Modified Files:
	Makefile.am 
Added Files:
	glitz_egl.c 
Log Message:
Added egl version of rendertest.
EGL passes with 172 success, 32 not support, zero failed.


Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/rendertest/src/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am	11 Nov 2004 20:54:44 -0000	1.5
+++ Makefile.am	20 May 2005 01:26:11 -0000	1.6
@@ -14,7 +14,7 @@
 
 # automake does not use <program-name>_CFLAGS
 # so apply all CFLAGS needed to all programs
-INCLUDES = $(GLITZ_GLX_CFLAGS) $(GLITZ_AGL_CFLAGS) $(XCB_CFLAGS) \
+INCLUDES = $(GLITZ_GLX_CFLAGS) $(GLITZ_EGL_CFLAGS) $(GLITZ_AGL_CFLAGS) $(XCB_CFLAGS) \
 $(PIXMAN_CFLAGS) $(LIBPNG_CFLAGS)
 
 if RENDER_GLITZ_GLX_BACKEND
@@ -27,6 +27,16 @@
 rendertest_glitz_glx_LDADD = $(GLITZ_GLX_LIBS) $(LIBPNG_LIBS) -lm
 endif
 
+if RENDER_GLITZ_EGL_BACKEND
+glitz_egl_program = rendertest_glitz_egl
+
+rendertest_glitz_egl_SOURCES = \
+	$(glitz_common_sources) \
+	glitz_egl.c
+
+rendertest_glitz_egl_LDADD = $(GLITZ_EGL_LIBS) $(LIBPNG_LIBS) -lm
+endif
+
 if RENDER_GLITZ_AGL_BACKEND
 glitz_agl_program = rendertest_glitz_agl
 
@@ -59,6 +69,7 @@
 
 bin_PROGRAMS = \
 	$(glitz_glx_program) \
+	$(glitz_egl_program) \
 	$(glitz_agl_program) \
 	$(xcb_program) \
 	$(pixman_program)

--- NEW FILE: glitz_egl.c ---
/*
 * Copyright  2004 David Reveman
 * 
 * Permission to use, copy, modify, distribute, and sell this software
 * and its documentation for any purpose is hereby granted without
 * fee, provided that the above copyright notice appear in all copies
 * and that both that copyright notice and this permission notice
 * appear in supporting documentation, and that the names of
 * David Reveman not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 * David Reveman makes no representations about the suitability of this
 * software for any purpose. It is provided "as is" without express or
 * implied warranty.
 *
 * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 * Author: David Reveman <davidr at freedesktop.org>
 */

#ifdef HAVE_CONFIG_H
#  include "../config.h"
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <assert.h>

#include "rendertest.h"
#include "glitz_common.h"

#include <glitz-egl.h>

static const render_backend_t _glitz_egl_render_backend = {
  _glitz_render_create_similar,
  _glitz_render_destroy,
  _glitz_render_composite,
  _glitz_render_set_pixels,
  _glitz_render_show,
  _glitz_render_set_fill,
  _glitz_render_set_component_alpha,
  _glitz_render_set_transform,
  _glitz_render_set_filter,
  _glitz_render_set_clip_rectangles,
  _glitz_render_set_clip_trapezoids
};

typedef struct egl_options {
  char *display;
  char *geometry;
  int samples;
  int db;
} egl_options_t;

static const render_option_t _egl_options[] = {
  { "display", 'd', "DISPLAY", 0, "   X display to use" },
  { "geometry", 'g', "GEOMETRY", 0, " X geometry specification" },
  { "single-buffer", 'l', NULL, 0, "    use single buffered format" },
  { "samples", 'p', "SAMPLES", 0, "   use this hardware multi-sample format" },
  { 0 }
};

static int
_parse_option (int key, char *arg, render_arg_state_t *state)
{
  egl_options_t *options = state->pointer;
  
  switch (key) {
  case 'd':
    options->display = arg;
    break;
  case 'g':
    options->geometry = arg;
    break;
  case 'l':
    options->db = 0;
    break;
  case 'p':
    options->samples = atoi (arg);
    break;
  default:
    return 1;
  }
  
  return 0;
}

int
main (int argc, char **argv)
{
  int status, x, y;
  render_surface_t surface;
  EGLDisplay egl_display;
  EGLScreenMESA egl_screen;
  EGLModeMESA egl_mode;
  EGLSurface egl_surface;
  glitz_drawable_format_t templ;
  unsigned long mask;
  glitz_drawable_format_t *dformat;
  glitz_drawable_t *drawable;
  render_arg_state_t state;
  egl_options_t options;
  int maj, min, count;
  EGLint screenAttribs[] = {
    EGL_WIDTH, 1024,
    EGL_HEIGHT, 768,
    EGL_NONE
  };

  options.display = NULL;
  options.geometry = NULL;
  options.samples = 1;
  options.db = 1;
  
  state.pointer = &options;

  if (render_parse_arguments (_parse_option,
                              _egl_options,
                              &state,
                              argc, argv))
    return 1;
    
  surface.backend = &_glitz_egl_render_backend;
  surface.flags = 0;

  if (options.geometry) {
    unsigned int width, height;
    
    surface.width = width;
    surface.height = height;
  } else {
    x = y = 50;
    surface.width = RENDER_DEFAULT_DST_WIDTH;
    surface.height = RENDER_DEFAULT_DST_HEIGHT;
  }
 surface.width = 1024;
 surface.height = 768;

  egl_display = eglGetDisplay("!fb_dri");
  assert(egl_display);
  
  if (!eglInitialize(egl_display, &maj, &min)) {
    printf("demo: eglInitialize failed\n");
    exit(1);
  }
  
  eglGetScreensMESA(egl_display, &egl_screen, 1, &count);
  eglGetModesMESA(egl_display, egl_screen, &egl_mode, 1, &count);

  templ.types.window = 1;
  mask = GLITZ_FORMAT_WINDOW_MASK;

  templ.samples = options.samples;
  mask |= GLITZ_FORMAT_SAMPLES_MASK;

  if (options.db)
    templ.doublebuffer = 1;
  else
    templ.doublebuffer = 0;

  mask |= GLITZ_FORMAT_DOUBLEBUFFER_MASK;
  
  dformat = glitz_egl_find_config (egl_display, egl_screen, mask, &templ, 0);
  if (!dformat) {
    fprintf (stderr, "Error: couldn't find window format\n");
    return 1;
  }

  egl_surface = eglCreateScreenSurfaceMESA(egl_display, dformat->id, screenAttribs);
  if (egl_surface == EGL_NO_SURFACE) {
    printf("failed to create screen surface\n");
    return 0;
  }
   
  eglShowSurfaceMESA(egl_display, egl_screen, egl_surface, egl_mode);
  
  drawable = glitz_egl_create_surface (egl_display, egl_screen, dformat, 
                                       egl_surface, surface.width, surface.height);

  if (!drawable) {
    fprintf (stderr, "Error: couldn't create glitz drawable for window\n");
    return 1;
  }

  surface.surface =
    _glitz_create_and_attach_surface_to_drawable (drawable,
                                                  surface.width,
                                                  surface.height);
  if (!surface.surface)
    return 1;
  
  status = render_run (&surface, &state.settings);

  glitz_surface_destroy ((glitz_surface_t *) surface.surface);
  glitz_drawable_destroy (drawable);

  glitz_egl_fini ();

//eglShowSurfaceMESA(egl_display, egl_screen, EGL_NO_SURFACE, EGL_NO_MODE_MESA);
  eglDestroySurface(egl_display, egl_surface);
  eglTerminate(egl_display);
  
  return 0;
}




More information about the cairo-commit mailing list