sync with tizen_2.2
[sdk/emulator/qemu.git] / gl / dgles2 / src / EGL / context.h
1 /* Copyright (C) 2010  Nokia Corporation All Rights Reserved.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a
4  * copy of this software and associated documentation files (the "Software"),
5  * to deal in the Software without restriction, including without limitation
6  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7  * and/or sell copies of the Software, and to permit persons to whom the
8  * Software is furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included
11  * in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
16  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20
21 #ifndef CONTEXT_H_
22 #define CONTEXT_H_
23
24 #include <pthread.h>
25 #include "common.h"
26 #if(CONFIG_OSMESA == 1)
27 #       include "hosmesa.h"
28 #endif // (CONFIG_OSMESA == 1)
29 #if(CONFIG_GLX == 1)
30 #       include "hglx.h"
31 #endif // (CONFIG_GLX == 1)
32 #if(CONFIG_COCOA == 1)
33 #       include "hcocoa.h"
34 #endif // (CONFIG_COCOA == 1)
35 #if(CONFIG_WGL == 1)
36 #       include "hwgl.h"
37 #endif // (CONFIG_WGL == 1)
38 #include "surface.h"
39
40 typedef struct GLESFuncs
41 {
42         void (*dglReadPixels)(void *pixels, unsigned *pbo, unsigned x, unsigned y,
43                 unsigned width, unsigned height, unsigned format, unsigned type,
44                 unsigned flags);
45         void (*glFlush)(void);
46         void (*glFinish)(void);
47         void (*dglBindTexImage)(unsigned width, unsigned height, char* pixels);
48 #       if(CONFIG_OFFSCREEN == 1)
49         void (*dglDeletePBO)(unsigned pbo);
50 #       endif // CONFIG_OFFSCREEN == 1
51 } GLESFuncs;
52
53 struct degl_ebo_s;
54
55 typedef struct DEGLContext
56 {
57         EGLDisplay display;
58         EGLConfig config;
59         int version;
60         void* clientlib;
61         void* clientdata;
62         GLESFuncs* glesfuncs;
63         int bound;
64         int destroy;
65         DEGLSurface* draw;
66         DEGLSurface* read;
67         pthread_mutex_t lock;
68         struct degl_ebo_s *ebo_bound;
69
70 #       if(CONFIG_OSMESA == 1)
71         struct
72         {
73                 OSMesaContext ctx;
74         } osmesa;
75 #       endif // (CONFIG_OSMESA == 1)
76
77 #       if(CONFIG_GLX == 1)
78         struct 
79         {
80                 GLXContext ctx;
81                 GLXFBConfig *config;
82         } glx;
83 #       endif // (CONFIG_GLX == 1)
84
85 #       if(CONFIG_COCOA == 1)
86         struct
87         {
88                 CGLContextObj ctx;
89                 void *nsctx; // NSOpenGLContext*
90                 int pbuffer_mode;
91         } cocoa;
92 #       endif // (CONFIG_COCOA == 1)
93
94 #       if(CONFIG_WGL == 1)
95         struct
96         {
97                 HGLRC ctx;
98                 HDC   haxdc;
99                 HPBUFFERARB haxbuf;
100                 int haxown;
101                 int config;
102         } wgl;
103 #       endif // (CONFIG_WGL == 1)
104 } DEGLContext;
105
106 #endif // CONTEXT_H_