mesa: Don't bind DRAW/READ_FRAMEBUFFER separately without FBO blit support
[mesa.git] / src / gallium / state_trackers / egl / egl_visual.c
1
2 #include "egl_tracker.h"
3
4 #include "egllog.h"
5
6 void
7 drm_visual_modes_destroy(__GLcontextModes *modes)
8 {
9 _eglLog(_EGL_DEBUG, "%s", __FUNCTION__);
10
11 while (modes) {
12 __GLcontextModes * const next = modes->next;
13 free(modes);
14 modes = next;
15 }
16 }
17
18 __GLcontextModes *
19 drm_visual_modes_create(unsigned count, size_t minimum_size)
20 {
21 /* This code copied from libGLX, and modified */
22 const size_t size = (minimum_size > sizeof(__GLcontextModes))
23 ? minimum_size : sizeof(__GLcontextModes);
24 __GLcontextModes * head = NULL;
25 __GLcontextModes ** next;
26 unsigned i;
27
28 _eglLog(_EGL_DEBUG, "%s %d %d", __FUNCTION__, count, minimum_size);
29
30 next = & head;
31 for (i = 0 ; i < count ; i++) {
32 *next = (__GLcontextModes *) calloc(1, size);
33 if (*next == NULL) {
34 drm_visual_modes_destroy(head);
35 head = NULL;
36 break;
37 }
38
39 (*next)->doubleBufferMode = 1;
40 (*next)->visualID = GLX_DONT_CARE;
41 (*next)->visualType = GLX_DONT_CARE;
42 (*next)->visualRating = GLX_NONE;
43 (*next)->transparentPixel = GLX_NONE;
44 (*next)->transparentRed = GLX_DONT_CARE;
45 (*next)->transparentGreen = GLX_DONT_CARE;
46 (*next)->transparentBlue = GLX_DONT_CARE;
47 (*next)->transparentAlpha = GLX_DONT_CARE;
48 (*next)->transparentIndex = GLX_DONT_CARE;
49 (*next)->xRenderable = GLX_DONT_CARE;
50 (*next)->fbconfigID = GLX_DONT_CARE;
51 (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML;
52 (*next)->bindToTextureRgb = GLX_DONT_CARE;
53 (*next)->bindToTextureRgba = GLX_DONT_CARE;
54 (*next)->bindToMipmapTexture = GLX_DONT_CARE;
55 (*next)->bindToTextureTargets = 0;
56 (*next)->yInverted = GLX_DONT_CARE;
57
58 next = & ((*next)->next);
59 }
60
61 return head;
62 }
63
64 __GLcontextModes *
65 drm_visual_from_config(_EGLConfig *conf)
66 {
67 __GLcontextModes *visual;
68 (void)conf;
69
70 visual = drm_visual_modes_create(1, sizeof(*visual));
71 visual->redBits = 8;
72 visual->greenBits = 8;
73 visual->blueBits = 8;
74 visual->alphaBits = 8;
75
76 visual->rgbBits = 32;
77 visual->doubleBufferMode = 1;
78
79 visual->depthBits = 24;
80 visual->haveDepthBuffer = visual->depthBits > 0;
81 visual->stencilBits = 8;
82 visual->haveStencilBuffer = visual->stencilBits > 0;
83
84 return visual;
85 }