summaryrefslogtreecommitdiff
path: root/src/egl/drivers/android/droid.h
blob: bed5e8cd7579f4fcf1b3c0c4adc88a43ee62e2c9 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
 *
 * This is based on the work of eagle, by
 * Copyright © 2008, 2009 Kristian Høgsberg
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#ifndef _DROID_H_
#define _DROID_H_

#include "GL/gl.h"
#include "GL/internal/dri_interface.h"

#include "eglcurrent.h"
#include "egldisplay.h"
#include "eglcontext.h"
#include "eglsurface.h"
#include "eglconfig.h"

/* opaque types */
struct droid_loader;
struct droid_context;
struct droid_drawable;
struct droid_surface;

struct droid_backend {
   /* these are usually used by a loader */
   const char *driver_name;
   int (*initialize)(struct droid_backend *backend, int *fd, int *screen_number);
   void (*destroy)(struct droid_backend *backend);

   __DRIbuffer *(*get_native_buffer)(struct droid_backend *backend,
                                     struct droid_surface *surf,
                                     int *width, int *height);
   __DRIbuffer *(*get_surface_buffers)(struct droid_backend *backend,
                                       struct droid_surface *surf,
                                       int *width, int *height,
                                       unsigned int *attachments, int count,
                                       int *out_count, int has_format);

   /* public methods */
   struct droid_surface *(*create_window_surface)(struct droid_backend *backend,
                                                  _EGLSurface *surf,
                                                  NativeWindowType win);
   void (*destroy_surface)(struct droid_backend *backend, struct droid_surface *surf);
   void (*swap_native_buffers)(struct droid_backend *backend,
                               struct droid_surface *surf);
};

struct droid_screen {
   struct droid_loader *loader;

   __DRIscreen *dri_screen;
   __DRItexBufferExtension *tex_buffer;
   __DRIcopyBufferExtension *copy_buffer;

   const __DRIconfig **dri_configs;
   int num_dri_configs;
};

struct droid_backend *
droid_backend_create_intel(const char *dev);

void
droid_backend_destroy(struct droid_backend *backend);

struct droid_screen *
droid_screen_create(struct droid_backend *backend);

void
droid_screen_destroy(struct droid_screen *screen);

void
droid_screen_convert_config(struct droid_screen *screen,
                            const __DRIconfig *conf, _EGLConfig *egl_conf);

struct droid_context *
droid_screen_create_context(struct droid_screen *screen,
                            const __DRIconfig *conf,
                            struct droid_context *shared);

void
droid_screen_destroy_context(struct droid_screen *screen,
                             struct droid_context *ctx);

struct droid_drawable *
droid_screen_create_drawable(struct droid_screen *screen,
                             const __DRIconfig *conf,
                             struct droid_surface *surf);

void
droid_screen_destroy_drawable(struct droid_screen *screen,
                              struct droid_drawable *drawable);

int
droid_screen_bind_context(struct droid_screen *screen,
                          struct droid_drawable *draw,
                          struct droid_drawable *read,
                          struct droid_context *ctx);

int
droid_screen_swap_buffers(struct droid_screen *screen,
                          struct droid_context *ctx,
                          struct droid_drawable *drawable);

#endif /* _DROID_H_ */