summaryrefslogtreecommitdiff
path: root/eagle-internal.h
blob: 98b3b8e8c4499834d503b41e38e29ee2423eb233 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * Copyright © 2008 Kristian Høgsberg
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of the copyright holders not be used in advertising or
 * publicity pertaining to distribution of the software without specific,
 * written prior permission.  The copyright holders make no representations
 * about the suitability of this software for any purpose.  It is provided "as
 * is" without express or implied warranty.
 *
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 * OF THIS SOFTWARE.
 */

#ifndef _EAGLE_INTERNAL_H_
#define _EAGLE_INTERNAL_H_

#include <limits.h>
#include <stdlib.h>
#include <stdint.h>
#include <GL/gl.h>
#include <GL/internal/dri_interface.h>
#include "eagle.h"

struct EGLDisplay {
	int				 next_surface_id;
	EGLBoolean			 initialized;

	int				 fd;
	const char			*driverName;

	EGLConfig			 configs;
	int				 numConfigs;

	__DRIscreen			*driScreen;
	void				*driver;
	__DRIcoreExtension		*core;
	__DRIdri2Extension		*dri2;

	__DRIswapControlExtension	*swapControl;
	__DRItexBufferExtension		*texBuffer;

	int				 width, height;

	__DRIcopyBufferExtension	*copyBuffer;

	const struct EagleBackend	*backend;
	void				*backendPrivate;
};

struct EGLSurface {
	EGLDisplay		 display;
	uint32_t		 id;

	__DRIdrawable		*driDrawable;

	uint32_t		 bufferWidth, bufferHeight;
	__DRIbuffer		 buffers[10];
	int			 count;
	int			 depth;
	int			 width;
	int			 height;
};

struct EGLContext {
	EGLDisplay		 display;
	__DRIcontext		*driContext;
	EGLConfig		 config;
	EGLSurface		 drawSurface;
	EGLSurface		 readSurface;
	unsigned int		 id;
};

struct EGLConfig {
	const __DRIconfig	*driConfig;
	unsigned int		 id;
};

/* This is somewhat arbitrary... */

struct EagleBackend {
	void		(*getBuffers)(EGLSurface surface,
				      uint32_t *attachments,
				      int count);
	EGLBoolean	(*swapBuffers)(EGLDisplay display,
				       EGLSurface surface);
	EGLBoolean	(*destroySurface)(EGLDisplay display,
					  EGLSurface surface);
	EGLSurface	(*createSurfaceForName)(EGLDisplay display, EGLConfig config,
						uint32_t name, uint32_t width,
						uint32_t height, uint32_t stride, const EGLint *attribList);
};

int eglInitDisplay(EGLDisplay display,
		   struct udev_device *device, const char *driver);
void eglInitSurface(EGLSurface surface, EGLDisplay display, EGLConfig fbconfig,
		    int width, int height);

EGLDisplay i915CreateDisplay(struct udev_device *device);
EGLDisplay i965CreateDisplay(struct udev_device *device);
EGLDisplay r300CreateDisplay(struct udev_device *device);

#endif