Opensource Compliance Issue.
[platform/core/graphics/cairo.git] / test / gl-oversized-surface.c
1 /*
2  * Copyright © 2012 Igalia S.L.
3  * Copyright © 2009 Eric Anholt
4  * Copyright © 2009 Chris Wilson
5  * Copyright © 2005 Red Hat, Inc
6  *
7  * Permission to use, copy, modify, distribute, and sell this software
8  * and its documentation for any purpose is hereby granted without
9  * fee, provided that the above copyright notice appear in all copies
10  * and that both that copyright notice and this permission notice
11  * appear in supporting documentation, and that the name of
12  * Chris Wilson not be used in advertising or publicity pertaining to
13  * distribution of the software without specific, written prior
14  * permission. Chris Wilson makes no representations about the
15  * suitability of this software for any purpose.  It is provided "as
16  * is" without express or implied warranty.
17  *
18  * IGALIA S.L. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
19  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
21  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
22  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
23  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
24  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25  *
26  * Author: Martin Robinson <mrobinson@igalia.com>
27  */
28
29 #include "cairo-test.h"
30 #include <cairo-gl.h>
31 #include <assert.h>
32 #include <limits.h>
33
34 static cairo_test_status_t
35 preamble (cairo_test_context_t *test_ctx)
36 {
37     int rgba_attribs[] = {
38         GLX_RGBA,
39         GLX_RED_SIZE, 1,
40         GLX_GREEN_SIZE, 1,
41         GLX_BLUE_SIZE, 1,
42         GLX_ALPHA_SIZE, 1,
43         GLX_DOUBLEBUFFER,
44         None
45     };
46
47     Display *display;
48     XVisualInfo *visual_info;
49     GLXContext glx_context;
50     cairo_device_t *device;
51     cairo_surface_t *oversized_surface;
52     cairo_test_status_t test_status = CAIRO_TEST_SUCCESS;
53
54     display = XOpenDisplay (NULL);
55     if (display == NULL)
56         return CAIRO_TEST_UNTESTED;
57
58     visual_info = glXChooseVisual (display, DefaultScreen (display), rgba_attribs);
59     if (visual_info == NULL) {
60         XCloseDisplay (display);
61         return CAIRO_TEST_UNTESTED;
62     }
63
64     glx_context = glXCreateContext (display, visual_info, NULL, True);
65     if (glx_context == NULL) {
66         XCloseDisplay (display);
67         return CAIRO_TEST_UNTESTED;
68     }
69
70     device = cairo_glx_device_create (display, glx_context);
71
72     oversized_surface = cairo_gl_surface_create (device, CAIRO_CONTENT_COLOR_ALPHA, INT_MAX, INT_MAX);
73     if (cairo_surface_status (oversized_surface) != CAIRO_STATUS_INVALID_SIZE)
74         test_status = CAIRO_TEST_FAILURE;
75
76     cairo_device_destroy (device);
77     glXDestroyContext(display, glx_context);
78     XCloseDisplay (display);
79
80     return test_status;
81 }
82
83 CAIRO_TEST (gl_oversized_surface,
84             "Test that creating a surface beyond texture limits results in an error surface",
85             "gl", /* keywords */
86             NULL, /* requirements */
87             0, 0,
88             preamble, NULL)