Re: [PATCH] test: Add test for egl-surface-source

Bryce Harrington <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On Mon, Sep 22, 2014 at 11:40:05AM +0530, RAVI NANJUNDAPPA wrote:
> hi, 
> 
> PFA the patch along with the reference images used for the test file.
> Please review the same.
> 
> Thanks and Best Regards, 
> N Ravi
> 
> PS: Unicode problem with the patch is still persisting. Will fix the issue
> while sending the next patches. Please bear with the attachement of the
> patch as of now.

Thanks, looks good to me, I've applied it to trunk.

Bryce


> >From 9539e33a638f320c47d2bc55c415c4b464793e62 Mon Sep 17 00:00:00 2001
> From: Ravi Nanjundappa <[email protected]>
> Date: Mon, 22 Sep 2014 10:19:17 +0530
> Subject: [PATCH] test: Add test for egl-surface-source
> 
> This test file attempts to use a EGL backend surface as a source
> surface for all other backends.
> 
> Signed-off-by: Ravi Nanjundappa <[email protected]>
> ---
>  test/Makefile.sources                              |    3 +-
>  test/egl-surface-source.c                          |  135 ++++++++++++++++++++
>  test/reference/egl-surface-source.argb32.ref.png   |  Bin 0 -> 377 bytes
>  .../egl-surface-source.base.argb32.ref.png         |  Bin 0 -> 377 bytes
>  .../egl-surface-source.base.rgb24.ref.png          |  Bin 0 -> 301 bytes
>  test/reference/egl-surface-source.image16.ref.png  |  Bin 0 -> 305 bytes
>  test/reference/egl-surface-source.rgb24.ref.png    |  Bin 0 -> 301 bytes
>  7 files changed, 137 insertions(+), 1 deletion(-)
>  create mode 100644 test/egl-surface-source.c
>  create mode 100644 test/reference/egl-surface-source.argb32.ref.png
>  create mode 100644 test/reference/egl-surface-source.base.argb32.ref.png
>  create mode 100644 test/reference/egl-surface-source.base.rgb24.ref.png
>  create mode 100644 test/reference/egl-surface-source.image16.ref.png
>  create mode 100644 test/reference/egl-surface-source.rgb24.ref.png
> 
> diff --git a/test/Makefile.sources b/test/Makefile.sources
> index 689645c..66d4a26 100644
> --- a/test/Makefile.sources
> +++ b/test/Makefile.sources
> @@ -402,7 +402,8 @@ gl_surface_test_sources = \
>  	gl-surface-source.c
>  
>  egl_surface_test_sources = \
> -       egl-oversized-surface.c
> +       egl-oversized-surface.c \
> +       egl-surface-source.c
>  
>  quartz_surface_test_sources = quartz-surface-source.c
>  
> diff --git a/test/egl-surface-source.c b/test/egl-surface-source.c
> new file mode 100644
> index 0000000..4a84d70
> --- /dev/null
> +++ b/test/egl-surface-source.c
> @@ -0,0 +1,135 @@
> +/*
> + * Copyright © 2014 Samsung Electronics
> + *
> + * Permission is hereby granted, free of charge, to any person
> + * obtaining a copy of this software and associated documentation
> + * files (the "Software"), to deal in the Software without
> + * restriction, including without limitation the rights to use, copy,
> + * modify, merge, publish, distribute, sublicense, and/or sell copies
> + * of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> + * included in all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
> + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
> + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> + * SOFTWARE.
> + *
> + * Author: Ravi Nanjundappa <[email protected]>
> + */
> +
> +/*
> + * This case tests using a EGL surface as the source
> + *
> + */
> +
> +#include "cairo-test.h"
> +#include <cairo-gl.h>
> +
> +#include "surface-source.c"
> +
> +struct closure {
> +    EGLDisplay dpy;
> +    EGLContext ctx;
> +};
> +
> +static void
> +cleanup (void *data)
> +{
> +    struct closure *arg = data;
> +
> +    eglDestroyContext (arg->dpy, arg->ctx);
> +    eglMakeCurrent (arg->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
> +    eglTerminate (arg->dpy);
> +
> +    free (arg);
> +}
> +
> +static cairo_surface_t *
> +create_source_surface (int size)
> +{
> +    EGLint config_attribs[] = {
> +	EGL_RED_SIZE, 8,
> +	EGL_GREEN_SIZE, 8,
> +	EGL_BLUE_SIZE, 8,
> +	EGL_ALPHA_SIZE, 8,
> +	EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
> +#if CAIRO_HAS_GL_SURFACE
> +	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
> +#elif CAIRO_HAS_GLESV2_SURFACE
> +	EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
> +#endif
> +	EGL_NONE
> +    };
> +    const EGLint ctx_attribs[] = {
> +#if CAIRO_HAS_GLESV2_SURFACE
> +	EGL_CONTEXT_CLIENT_VERSION, 2,
> +#endif
> +	EGL_NONE
> +    };
> +
> +    struct closure *arg;
> +    cairo_device_t *device;
> +    cairo_surface_t *surface;
> +    EGLConfig config;
> +    EGLint numConfigs;
> +    EGLDisplay dpy;
> +    EGLContext ctx;
> +    int major, minor;
> +
> +    dpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
> +    if (! eglInitialize (dpy, &major, &minor)) {
> +	return NULL;
> +    }
> +
> +    eglChooseConfig (dpy, config_attribs, &config, 1, &numConfigs);
> +    if (numConfigs == 0) {
> +	return NULL;
> +    }
> +
> +#if CAIRO_HAS_GL_SURFACE
> +    eglBindAPI (EGL_OPENGL_API);
> +#elif CAIRO_HAS_GLESV2_SURFACE
> +    eglBindAPI (EGL_OPENGL_ES_API);
> +#endif
> +
> +   ctx = eglCreateContext (dpy, config, EGL_NO_CONTEXT,
> +				  ctx_attribs);
> +    if (ctx == EGL_NO_CONTEXT) {
> +	eglTerminate (dpy);
> +	return NULL;
> +    }
> +
> +    arg = xmalloc (sizeof (struct closure));
> +    arg->dpy = dpy;
> +    arg->ctx = ctx;
> +    device = cairo_egl_device_create (dpy, ctx);
> +    if (cairo_device_set_user_data (device,
> +				    (cairo_user_data_key_t *) cleanup,
> +				    arg,
> +				    cleanup))
> +    {
> +	cleanup (arg);
> +	return NULL;
> +    }
> +
> +    surface = cairo_gl_surface_create (device,
> +				       CAIRO_CONTENT_COLOR_ALPHA,
> +				       size, size);
> +    cairo_device_destroy (device);
> +
> +    return surface;
> +}
> +
> +CAIRO_TEST (egl_surface_source,
> +	    "Test using a EGL surface as the source",
> +	    "source", /* keywords */
> +	    NULL, /* requirements */
> +	    SIZE, SIZE,
> +	    preamble, draw)
> diff --git a/test/reference/egl-surface-source.argb32.ref.png b/test/reference/egl-surface-source.argb32.ref.png
> new file mode 100644
> index 0000000000000000000000000000000000000000..018297208e7e69c63dc671094b4659d2f64f26b6
> GIT binary patch
> literal 377
> zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGoY)RhkE)4%caKYZ?lNlHo^*mi1
> zLn`LHz3Z5D#6W<-(f7pu>3i-}Ht{#FI9zr&S8|pm$LWf5mghM?FP49BTa-bYA&g-S
> zLj>anrUcdlTn#7!`)^Cz@Yl^XNS+=acb^4C{zjGjhqPyZVq+hCGJ7)f^UliuYIu#p
> zFq`$jwdYOGp0@n?yPo~sx({{#>c6)-2&3AMMH89}i?^|7e~CZQW`E$-D>Mgu``xg{
> hgb};PU<QBVuRp<iM0Mdk31C<<c)I$ztaD0e0sx;ke`){#
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/test/reference/egl-surface-source.base.argb32.ref.png b/test/reference/egl-surface-source.base.argb32.ref.png
> new file mode 100644
> index 0000000000000000000000000000000000000000..018297208e7e69c63dc671094b4659d2f64f26b6
> GIT binary patch
> literal 377
> zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGoY)RhkE)4%caKYZ?lNlHo^*mi1
> zLn`LHz3Z5D#6W<-(f7pu>3i-}Ht{#FI9zr&S8|pm$LWf5mghM?FP49BTa-bYA&g-S
> zLj>anrUcdlTn#7!`)^Cz@Yl^XNS+=acb^4C{zjGjhqPyZVq+hCGJ7)f^UliuYIu#p
> zFq`$jwdYOGp0@n?yPo~sx({{#>c6)-2&3AMMH89}i?^|7e~CZQW`E$-D>Mgu``xg{
> hgb};PU<QBVuRp<iM0Mdk31C<<c)I$ztaD0e0sx;ke`){#
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/test/reference/egl-surface-source.base.rgb24.ref.png b/test/reference/egl-surface-source.base.rgb24.ref.png
> new file mode 100644
> index 0000000000000000000000000000000000000000..0d68a82cc27532aa78fc12af7646f6821a730a2b
> GIT binary patch
> literal 301
> zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1SE5RJ;(=AY)RhkE)4%caKYZ?lYt_SJY5_^
> zD(1Ysy^*iUK*S+1>rej2(}h=B@0d(;Js;WVUVNE%S1wQ;!=K59zYi43gs*v=>!Y8U
> z_vgvq?cQM@omse;SR0!h92Y1A>{u^la;*65g4(k)k}t|wYjB7lNebZM8vKpTne!)c
> zbN%i~M<*ZqX0g}kFdxELd^!~Z1T@ab2krlH<ByqM{lP1D%YXuKdqK|r@Q}6kF=t0)
> R<@7`l*VEO{Wt~$(698O(XEy)<
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/test/reference/egl-surface-source.image16.ref.png b/test/reference/egl-surface-source.image16.ref.png
> new file mode 100644
> index 0000000000000000000000000000000000000000..2a7460e284f3ed8ad59e28c1498357559937e421
> GIT binary patch
> literal 305
> zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1SE5RJ;(=AY)RhkE)4%caKYZ?lYt`7JY5_^
> zD(1Ysy^*iUK*S+1>rb{Y`{Mh(i}ju@+o)4@j>~4&?7R!P%s{0N=J(uW|5j_CB&(lX
> z<yrh#{k^^HrY?D<009jS5f&~c*2Y7XR~Hz{WwYJA)^l@x_Oly~jtdkJvP}-SxvekX
> zCp|taZ}xrt^i5@#Zs^IcKeM43p9a=OWZBQ{SNQGB_V*r+Hz?gM3vmosUI6HBhCP)`
> XvmH4neBSVCGl=Wy>gTe~DWM4fL|kN5
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/test/reference/egl-surface-source.rgb24.ref.png b/test/reference/egl-surface-source.rgb24.ref.png
> new file mode 100644
> index 0000000000000000000000000000000000000000..0d68a82cc27532aa78fc12af7646f6821a730a2b
> GIT binary patch
> literal 301
> zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1SE5RJ;(=AY)RhkE)4%caKYZ?lYt_SJY5_^
> zD(1Ysy^*iUK*S+1>rej2(}h=B@0d(;Js;WVUVNE%S1wQ;!=K59zYi43gs*v=>!Y8U
> z_vgvq?cQM@omse;SR0!h92Y1A>{u^la;*65g4(k)k}t|wYjB7lNebZM8vKpTne!)c
> zbN%i~M<*ZqX0g}kFdxELd^!~Z1T@ab2krlH<ByqM{lP1D%YXuKdqK|r@Q}6kF=t0)
> R<@7`l*VEO{Wt~$(698O(XEy)<
> 
> literal 0
> HcmV?d00001
> 
> -- 
> 1.7.9.5
> 

> -- 
> cairo mailing list
> [email protected]
> http://lists.cairographics.org/mailman/listinfo/cairo

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.