2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 * Author: Kristian Høgsberg <krh@bitplanet.net>
26 /** @file egl-nok-swap-region.c
28 * Test EGL_NOK_swap_region.
31 #include "piglit-util.h"
34 #ifdef EGL_NOK_swap_region
36 const char *extensions
[] = { "EGL_NOK_swap_region" };
38 static enum piglit_result
39 draw(struct egl_state
*state
)
47 PFNEGLSWAPBUFFERSREGIONNOK swap_buffers_region
;
48 float red
[] = { 1.0, 0.0, 0.0, 1.0};
51 swap_buffers_region
= (PFNEGLSWAPBUFFERSREGIONNOK
)
52 eglGetProcAddress("eglSwapBuffersRegionNOK");
54 if (swap_buffers_region
== NULL
) {
55 fprintf(stderr
, "could not getproc eglSwapBuffersRegionNOK");
56 piglit_report_result(PIGLIT_SUCCESS
);
59 /* Clear background to green */
60 glClearColor(0.0, 1.0, 0.0, 1.0);
61 glClear(GL_COLOR_BUFFER_BIT
);
62 eglSwapBuffers(state
->egl_dpy
, state
->surf
);
63 glClearColor(1.0, 0.0, 0.0, 1.0);
64 glClear(GL_COLOR_BUFFER_BIT
);
65 swap_buffers_region(state
->egl_dpy
, state
->surf
, 4, rects
);
67 for (i
= 0; i
< 16; i
+= 4)
68 if (!piglit_probe_pixel_rgba(rects
[i
] + 5,
69 rects
[i
+ 1] + 5, red
))
70 return PIGLIT_FAILURE
;
72 return PIGLIT_SUCCESS
;
75 static const struct egl_test test
= {
76 .extensions
= extensions
,
81 main(int argc
, char *argv
[])
83 return egl_util_run(&test
, argc
, argv
);
89 main(int argc
, char *argv
[])
91 piglit_report_result(PIGLIT_SKIP
);