summaryrefslogtreecommitdiff
path: root/src/cairo-gl-private.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-gl-private.h')
-rw-r--r--src/cairo-gl-private.h101
1 files changed, 83 insertions, 18 deletions
diff --git a/src/cairo-gl-private.h b/src/cairo-gl-private.h
index 54f226f..ace4032 100644
--- a/src/cairo-gl-private.h
+++ b/src/cairo-gl-private.h
@@ -42,6 +42,8 @@
#ifndef CAIRO_GL_PRIVATE_H
#define CAIRO_GL_PRIVATE_H
+#define GL_GLEXT_PROTOTYPES
+
#include "cairoint.h"
#include "cairo-gl-gradient-private.h"
@@ -52,13 +54,11 @@
#include <assert.h>
-#include <GL/glew.h>
-
#include "cairo-gl.h"
#include <GL/gl.h>
-#define GL_GLEXT_PROTOTYPES
#include <GL/glext.h>
+#include "cairo-gl-ext-def-private.h"
#define DEBUG_GL 0
@@ -73,6 +73,10 @@
#define UNSUPPORTED(reason) CAIRO_INT_STATUS_UNSUPPORTED
#endif
+#define CAIRO_GL_VERSION_ENCODE(major, minor) ( \
+ ((major) * 256) \
+ + ((minor) * 1))
+
/* maximal number of shaders we keep in the cache.
* Random number that is hopefully big enough to not cause many cache evictions. */
#define CAIRO_GL_MAX_SHADERS_PER_CONTEXT 64
@@ -89,6 +93,7 @@ typedef struct _cairo_gl_surface {
GLuint fb; /* GL framebuffer object wrapping our data. */
GLuint depth; /* GL framebuffer object holding depth */
int owns_tex;
+ cairo_bool_t needs_update;
} cairo_gl_surface_t;
typedef struct cairo_gl_glyph_cache {
@@ -107,7 +112,9 @@ typedef enum cairo_gl_operand_type {
CAIRO_GL_OPERAND_CONSTANT,
CAIRO_GL_OPERAND_TEXTURE,
CAIRO_GL_OPERAND_LINEAR_GRADIENT,
- CAIRO_GL_OPERAND_RADIAL_GRADIENT,
+ CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0,
+ CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE,
+ CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT,
CAIRO_GL_OPERAND_SPANS,
CAIRO_GL_OPERAND_COUNT
@@ -154,23 +161,67 @@ typedef struct cairo_gl_operand {
struct {
cairo_gl_gradient_t *gradient;
cairo_matrix_t m;
- float segment_x;
- float segment_y;
- cairo_extend_t extend;
- } linear;
- struct {
- cairo_gl_gradient_t *gradient;
- cairo_matrix_t m;
- float circle_1_x;
- float circle_1_y;
- float radius_0;
- float radius_1;
- cairo_extend_t extend;
- } radial;
+ cairo_circle_double_t circle_d;
+ double radius_0, a;
+ cairo_extend_t extend;
+ } gradient;
};
unsigned int vertex_offset;
} cairo_gl_operand_t;
+typedef void (*cairo_gl_generic_func_t)(void);
+typedef cairo_gl_generic_func_t (*cairo_gl_get_proc_addr_func_t)(const char *procname);
+
+typedef struct _cairo_gl_dispatch {
+ /* Buffers */
+ void (*GenBuffers) (GLsizei n, GLuint *buffers);
+ void (*BindBuffer) (GLenum target, GLuint buffer);
+ void (*BufferData) (GLenum target, GLsizeiptr size,
+ const GLvoid* data, GLenum usage);
+ GLvoid *(*MapBuffer) (GLenum target, GLenum access);
+ GLboolean (*UnmapBuffer) (GLenum target);
+
+ /* Shaders */
+ GLuint (*CreateShader) (GLenum type);
+ void (*ShaderSource) (GLuint shader, GLsizei count,
+ const GLchar** string, const GLint* length);
+ void (*CompileShader) (GLuint shader);
+ void (*GetShaderiv) (GLuint shader, GLenum pname, GLint *params);
+ void (*GetShaderInfoLog) (GLuint shader, GLsizei bufSize,
+ GLsizei *length, GLchar *infoLog);
+ void (*DeleteShader) (GLuint shader);
+
+ /* Programs */
+ GLuint (*CreateProgram) (void);
+ void (*AttachShader) (GLuint program, GLuint shader);
+ void (*DeleteProgram) (GLuint program);
+ void (*LinkProgram) (GLuint program);
+ void (*UseProgram) (GLuint program);
+ void (*GetProgramiv) (GLuint program, GLenum pname, GLint *params);
+ void (*GetProgramInfoLog) (GLuint program, GLsizei bufSize,
+ GLsizei *length, GLchar *infoLog);
+
+ /* Uniforms */
+ GLint (*GetUniformLocation) (GLuint program, const GLchar* name);
+ void (*Uniform1f) (GLint location, GLfloat x);
+ void (*Uniform2f) (GLint location, GLfloat x, GLfloat y);
+ void (*Uniform3f) (GLint location, GLfloat x, GLfloat y, GLfloat z);
+ void (*Uniform4f) (GLint location, GLfloat x, GLfloat y, GLfloat z,
+ GLfloat w);
+ void (*UniformMatrix3fv) (GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *value);
+ void (*Uniform1i) (GLint location, GLint x);
+
+ /* Framebuffer objects */
+ void (*GenFramebuffers) (GLsizei n, GLuint* framebuffers);
+ void (*BindFramebuffer) (GLenum target, GLuint framebuffer);
+ void (*FramebufferTexture2D) (GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture,
+ GLint level);
+ GLenum (*CheckFramebufferStatus) (GLenum target);
+ void (*DeleteFramebuffers) (GLsizei n, const GLuint* framebuffers);
+} cairo_gl_dispatch_t;
+
struct _cairo_gl_context {
cairo_device_t base;
@@ -205,6 +256,9 @@ struct _cairo_gl_context {
unsigned int vertex_size;
cairo_region_t *clip_region;
+ cairo_bool_t has_mesa_pack_invert;
+ cairo_gl_dispatch_t dispatch;
+
void (*acquire) (void *ctx);
void (*release) (void *ctx);
@@ -272,7 +326,7 @@ _cairo_gl_device_has_glsl (cairo_device_t *device)
static cairo_always_inline cairo_bool_t
_cairo_gl_device_requires_power_of_two_textures (cairo_device_t *device)
{
- return ((cairo_gl_context_t *) device)->tex_target == GL_TEXTURE_RECTANGLE_EXT;
+ return ((cairo_gl_context_t *) device)->tex_target == GL_TEXTURE_RECTANGLE;
}
static cairo_always_inline cairo_status_t cairo_warn
@@ -479,6 +533,17 @@ _cairo_gl_set_shader (cairo_gl_context_t *ctx,
cairo_private void
_cairo_gl_shader_fini (cairo_gl_context_t *ctx, cairo_gl_shader_t *shader);
+cairo_private int
+_cairo_gl_get_version (void);
+
+cairo_private cairo_bool_t
+_cairo_gl_has_extension (const char *ext);
+
+cairo_private cairo_status_t
+_cairo_gl_dispatch_init(cairo_gl_dispatch_t *dispatch,
+ cairo_gl_get_proc_addr_func_t get_proc_addr);
+
+
slim_hidden_proto (cairo_gl_surface_create);
slim_hidden_proto (cairo_gl_surface_create_for_texture);