1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2009 Eric Anholt
4 * Copyright © 2009 Chris Wilson
5 * Copyright © 2005,2010 Red Hat, Inc
6 * Copyright © 2011 Linaro Limited
8 * This library is free software; you can redistribute it and/or
9 * modify it either under the terms of the GNU Lesser General Public
10 * License version 2.1 as published by the Free Software Foundation
11 * (the "LGPL") or, at your option, under the terms of the Mozilla
12 * Public License Version 1.1 (the "MPL"). If you do not alter this
13 * notice, a recipient may use your version of this file under either
14 * the MPL or the LGPL.
16 * You should have received a copy of the LGPL along with this library
17 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
19 * You should have received a copy of the MPL along with this library
20 * in the file COPYING-MPL-1.1
22 * The contents of this file are subject to the Mozilla Public License
23 * Version 1.1 (the "License"); you may not use this file except in
24 * compliance with the License. You may obtain a copy of the License at
25 * http://www.mozilla.org/MPL/
27 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
28 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
29 * the specific language governing rights and limitations.
31 * The Original Code is the cairo graphics library.
33 * The Initial Developer of the Original Code is Red Hat, Inc.
36 * Benjamin Otte <otte@gnome.org>
37 * Carl Worth <cworth@cworth.org>
38 * Chris Wilson <chris@chris-wilson.co.uk>
39 * Eric Anholt <eric@anholt.net>
40 * T. Zachary Laine <whatwasthataddress@gmail.com>
41 * Alexandros Frantzis <alexandros.frantzis@linaro.org>
44 #ifndef CAIRO_GL_PRIVATE_H
45 #define CAIRO_GL_PRIVATE_H
47 #define GL_GLEXT_PROTOTYPES
52 #include "cairo-gl-gradient-private.h"
54 #include "cairo-device-private.h"
55 #include "cairo-error-private.h"
56 #include "cairo-rtree-private.h"
57 #include "cairo-scaled-font-private.h"
58 #include "cairo-spans-compositor-private.h"
59 #include "cairo-array-private.h"
60 #include "cairo-stroke-dash-private.h"
64 #if CAIRO_HAS_GL_SURFACE
67 #elif CAIRO_HAS_GLESV2_SURFACE
68 #include <GLES2/gl2.h>
69 #include <GLES2/gl2ext.h>
72 #include "cairo-gl-ext-def-private.h"
76 #if DEBUG_GL && __GNUC__
77 #define UNSUPPORTED(reason) ({ \
79 "cairo-gl: hit unsupported operation in %s(), line %d: %s\n", \
80 __FUNCTION__, __LINE__, reason); \
81 CAIRO_INT_STATUS_UNSUPPORTED; \
84 #define UNSUPPORTED(reason) CAIRO_INT_STATUS_UNSUPPORTED
87 #define CAIRO_GL_VERSION_ENCODE(major, minor) ( \
91 /* maximal number of shaders we keep in the cache.
92 * Random number that is hopefully big enough to not cause many cache evictions. */
93 #define CAIRO_GL_MAX_SHADERS_PER_CONTEXT 64
95 /* VBO size that we allocate, smaller size means we gotta flush more often */
96 #define CAIRO_GL_VBO_SIZE 16384
98 #define IMAGE_CACHE_WIDTH 2048
99 #define IMAGE_CACHE_HEIGHT 2048
100 #define IMAGE_CACHE_MIN_SIZE 1
101 #define IMAGE_CACHE_MAX_SIZE 256
103 typedef struct _cairo_gl_surface cairo_gl_surface_t;
106 typedef enum cairo_gl_flavor {
107 CAIRO_GL_FLAVOR_NONE = 0,
108 CAIRO_GL_FLAVOR_DESKTOP = 1,
109 CAIRO_GL_FLAVOR_ES = 2
112 /* Indices for vertex attributes used by BindAttribLocation etc */
114 CAIRO_GL_VERTEX_ATTRIB_INDEX = 0,
115 CAIRO_GL_COLOR_ATTRIB_INDEX = 1,
116 CAIRO_GL_COVERAGE_ATTRIB_INDEX = 2,
117 CAIRO_GL_TEXCOORD0_ATTRIB_INDEX = 3,
118 CAIRO_GL_TEXCOORD1_ATTRIB_INDEX = 4,
119 CAIRO_GL_START_COORD0_ATTRIB_INDEX = 5,
120 CAIRO_GL_START_COORD1_ATTRIB_INDEX = 6,
121 CAIRO_GL_STOP_COORD0_ATTRIB_INDEX = 7,
122 CAIRO_GL_STOP_COORD1_ATTRIB_INDEX = 8
125 typedef enum cairo_gl_operand_type {
126 CAIRO_GL_OPERAND_NONE,
127 CAIRO_GL_OPERAND_CONSTANT,
128 CAIRO_GL_OPERAND_TEXTURE,
129 CAIRO_GL_OPERAND_LINEAR_GRADIENT,
130 CAIRO_GL_OPERAND_RADIAL_GRADIENT_A0,
131 CAIRO_GL_OPERAND_RADIAL_GRADIENT_NONE,
132 CAIRO_GL_OPERAND_RADIAL_GRADIENT_EXT,
134 CAIRO_GL_OPERAND_COUNT
135 } cairo_gl_operand_type_t;
137 typedef enum cairo_gl_draw_mode {
141 } cairo_gl_draw_mode_t;
143 /* This union structure describes a potential source or mask operand to the
144 * compositing equation.
146 typedef struct cairo_gl_operand {
147 cairo_gl_operand_type_t type;
151 cairo_gl_surface_t *surface;
152 cairo_gl_surface_t *owns_surface;
153 cairo_surface_attributes_t attributes;
154 cairo_bool_t use_atlas;
155 cairo_extend_t extend;
156 struct { float x, y; } p1, p2;
162 cairo_gl_gradient_t *gradient;
164 cairo_circle_double_t circle_d;
166 cairo_extend_t extend;
169 unsigned int vertex_offset;
170 cairo_bool_t use_color_attribute;
171 } cairo_gl_operand_t;
173 typedef struct cairo_gl_source {
174 cairo_surface_t base;
175 cairo_gl_operand_t operand;
178 struct _cairo_gl_surface {
179 cairo_surface_t base;
180 cairo_gl_operand_t operand;
184 GLuint tex; /* GL texture object containing our data. */
185 GLuint fb; /* GL framebuffer object wrapping our data. */
186 GLuint depth_stencil; /* GL renderbuffer object for holding stencil buffer clip. */
188 #if CAIRO_HAS_GL_SURFACE
189 GLuint msaa_rb; /* The ARB MSAA path uses a renderbuffer. */
192 GLuint msaa_depth_stencil;
194 cairo_bool_t stencil_and_msaa_caps_initialized;
195 cairo_bool_t supports_stencil; /* Stencil support for for non-texture surfaces. */
196 cairo_bool_t supports_msaa;
197 cairo_bool_t msaa_active; /* Whether the multisampling
198 framebuffer is active or not. */
201 cairo_bool_t needs_update;
203 cairo_region_t *clip_region;
204 GLuint bounded_tex; /* bounded tex for non-texture surface */
206 /* Indicate whether we need to cache it in image_cache. */
207 cairo_bool_t needs_to_cache;
208 /* Damage is too expensive to check, we use this flag. */
209 cairo_bool_t content_changed;
212 typedef struct cairo_gl_glyph_cache {
214 cairo_gl_surface_t *surface;
215 } cairo_gl_glyph_cache_t;
217 typedef enum cairo_gl_tex {
218 CAIRO_GL_TEX_SOURCE = 0,
219 CAIRO_GL_TEX_MASK = 1,
220 CAIRO_GL_TEX_TEMP = 2
223 typedef struct cairo_gl_shader_impl cairo_gl_shader_impl_t;
225 typedef struct cairo_gl_shader {
226 GLuint fragment_shader;
228 cairo_hash_table_t *uniform_cache;
231 typedef struct cairo_gl_image_cache {
233 cairo_gl_surface_t *surface;
234 } cairo_gl_image_cache_t;
236 typedef struct cairo_gl_image {
237 cairo_rtree_node_t node;
238 cairo_surface_t *original_surface;
239 struct { float x, y; } p1, p2;
240 cairo_gl_context_t *ctx;
241 cairo_bool_t node_removed;
242 cairo_bool_t user_data_removed;
245 typedef enum cairo_gl_shader_in {
246 CAIRO_GL_SHADER_IN_NORMAL,
247 CAIRO_GL_SHADER_IN_CA_SOURCE,
248 CAIRO_GL_SHADER_IN_CA_SOURCE_ALPHA,
250 CAIRO_GL_SHADER_IN_COUNT
251 } cairo_gl_shader_in_t;
254 typedef struct _cairo_gl_hairline_closure
256 cairo_gl_context_t *ctx;
258 cairo_stroker_dash_t dash;
260 cairo_matrix_t *ctm_inverse;
261 cairo_point_t current_point;
263 cairo_point_t stroke_first_point; /* First stroke point at move_to. */
264 double stroke_first_dx;
265 double stroke_first_dy;
266 cairo_bool_t stroke_first_capped;
267 cairo_bool_t moved_to_stroke_first_point;
269 cairo_line_cap_t cap_style;
271 cairo_bool_t line_last_capped;
273 cairo_point_t line_last_point;
277 cairo_bool_t initialized;
278 } cairo_gl_hairline_closure_t;
280 typedef enum cairo_gl_var_type {
283 CAIRO_GL_VAR_TEXCOORDS,
284 } cairo_gl_var_type_t;
286 #define cairo_gl_var_type_hash(src,mask,src_atlas_extend,mask_atlas_extend,src_use_atlas,mask_use_atlas, spans,dest) ((spans) << 11) | ((mask) << 9 | (src << 7) | (mask_atlas_extend << 5) | (src_atlas_extend << 3) | (mask_use_atlas << 2) | (src_use_atlas << 1) | (dest))
287 #define CAIRO_GL_VAR_TYPE_MAX ((CAIRO_GL_VAR_TEXCOORDS << 11) | (CAIRO_GL_VAR_TEXCOORDS << 9) | (CAIRO_GL_VAR_TEXCOORDS << 5) | CAIRO_GL_VAR_TEXCOORDS)
289 typedef void (*cairo_gl_generic_func_t)(void);
290 typedef cairo_gl_generic_func_t (*cairo_gl_get_proc_addr_func_t)(const char *procname);
292 typedef struct _cairo_gl_dispatch {
294 void (*GenBuffers) (GLsizei n, GLuint *buffers);
295 void (*BindBuffer) (GLenum target, GLuint buffer);
296 void (*BufferData) (GLenum target, GLsizeiptr size,
297 const GLvoid* data, GLenum usage);
298 GLvoid *(*MapBuffer) (GLenum target, GLenum access);
299 GLboolean (*UnmapBuffer) (GLenum target);
302 GLuint (*CreateShader) (GLenum type);
303 void (*ShaderSource) (GLuint shader, GLsizei count,
304 const GLchar** string, const GLint* length);
305 void (*CompileShader) (GLuint shader);
306 void (*GetShaderiv) (GLuint shader, GLenum pname, GLint *params);
307 void (*GetShaderInfoLog) (GLuint shader, GLsizei bufSize,
308 GLsizei *length, GLchar *infoLog);
309 void (*DeleteShader) (GLuint shader);
312 GLuint (*CreateProgram) (void);
313 void (*AttachShader) (GLuint program, GLuint shader);
314 void (*DeleteProgram) (GLuint program);
315 void (*LinkProgram) (GLuint program);
316 void (*UseProgram) (GLuint program);
317 void (*GetProgramiv) (GLuint program, GLenum pname, GLint *params);
318 void (*GetProgramInfoLog) (GLuint program, GLsizei bufSize,
319 GLsizei *length, GLchar *infoLog);
322 GLint (*GetUniformLocation) (GLuint program, const GLchar* name);
323 void (*Uniform1f) (GLint location, GLfloat x);
324 void (*Uniform2f) (GLint location, GLfloat x, GLfloat y);
325 void (*Uniform3f) (GLint location, GLfloat x, GLfloat y, GLfloat z);
326 void (*Uniform4f) (GLint location, GLfloat x, GLfloat y, GLfloat z,
328 void (*UniformMatrix3fv) (GLint location, GLsizei count,
329 GLboolean transpose, const GLfloat *value);
330 void (*UniformMatrix4fv) (GLint location, GLsizei count,
331 GLboolean transpose, const GLfloat *value);
332 void (*Uniform1i) (GLint location, GLint x);
335 void (*BindAttribLocation) (GLuint program, GLuint index,
337 void (*VertexAttribPointer) (GLuint index, GLint size, GLenum type,
338 GLboolean normalized, GLsizei stride,
339 const GLvoid *pointer);
340 void (*EnableVertexAttribArray) (GLuint index);
341 void (*DisableVertexAttribArray) (GLuint index);
343 /* Framebuffer objects */
344 void (*GenFramebuffers) (GLsizei n, GLuint* framebuffers);
345 void (*BindFramebuffer) (GLenum target, GLuint framebuffer);
346 void (*FramebufferTexture2D) (GLenum target, GLenum attachment,
347 GLenum textarget, GLuint texture,
349 GLenum (*CheckFramebufferStatus) (GLenum target);
350 void (*DeleteFramebuffers) (GLsizei n, const GLuint* framebuffers);
351 void (*GenRenderbuffers) (GLsizei n, GLuint *renderbuffers);
352 void (*BindRenderbuffer) (GLenum target, GLuint renderbuffer);
353 void (*RenderbufferStorage) (GLenum target, GLenum internal_format,
354 GLsizei width, GLsizei height);
355 void (*FramebufferRenderbuffer) (GLenum target, GLenum attachment,
356 GLenum renderbuffer_ttarget, GLuint renderbuffer);
357 void (*DeleteRenderbuffers) (GLsizei n, GLuint *renderbuffers);
358 void (*BlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
359 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
360 GLbitfield mask, GLenum filter);
361 void (*RenderbufferStorageMultisample) (GLenum target, GLsizei samples,
362 GLenum internalformat,
363 GLsizei width, GLsizei height);
364 void (*FramebufferTexture2DMultisample) (GLenum target, GLenum attachment,
365 GLenum textarget, GLuint texture,
366 GLint level, GLsizei samples);
367 } cairo_gl_dispatch_t;
369 struct _cairo_gl_context {
372 const cairo_compositor_t *compositor;
374 GLuint texture_load_pbo;
376 GLint max_framebuffer_size;
377 GLint max_texture_size;
382 cairo_bool_t supports_msaa;
384 const cairo_gl_shader_impl_t *shader_impl;
386 GLuint vertex_shaders[CAIRO_GL_VAR_TYPE_MAX + 1];
387 cairo_gl_shader_t fill_rectangles_shader;
388 cairo_cache_t shaders;
390 cairo_cache_t gradients;
392 cairo_gl_glyph_cache_t glyph_cache[2];
395 cairo_gl_surface_t *current_target;
396 cairo_operator_t current_operator;
397 cairo_gl_shader_t *pre_shader; /* for component alpha */
398 cairo_gl_shader_t *current_shader;
400 cairo_gl_operand_t operands[2];
405 unsigned int vb_offset;
406 unsigned int vertex_size;
407 cairo_region_t *clip_region;
409 cairo_array_t tristrip_indices;
411 cairo_bool_t has_mesa_pack_invert;
412 cairo_gl_dispatch_t dispatch;
413 GLfloat modelviewprojection_matrix[16];
414 cairo_gl_flavor_t gl_flavor;
415 cairo_bool_t has_map_buffer;
416 cairo_bool_t has_packed_depth_stencil;
417 cairo_bool_t has_npot_repeat;
419 cairo_bool_t thread_aware;
421 /* GL stencil and depth buffers are shared among all surfaces
422 to preserve memory. In the future this could be a pool of renderbuffers
423 with an eviction policy. */
424 GLuint shared_depth_stencil;
425 int shared_depth_stencil_width;
426 int shared_depth_stencil_height;
427 GLuint shared_msaa_depth_stencil;
428 int shared_msaa_depth_stencil_width;
429 int shared_msaa_depth_stencil_height;
431 cairo_gl_image_cache_t image_cache;
432 cairo_gl_draw_mode_t draw_mode;
434 void (*acquire) (void *ctx);
435 void (*release) (void *ctx);
437 void (*make_current) (void *ctx, cairo_gl_surface_t *surface);
438 void (*swap_buffers)(void *ctx, cairo_gl_surface_t *surface);
439 void (*destroy) (void *ctx);
442 typedef struct _cairo_gl_composite {
443 cairo_gl_surface_t *dst;
445 cairo_region_t *clip_region;
447 cairo_gl_operand_t src;
448 cairo_gl_operand_t mask;
452 } cairo_gl_composite_t;
454 typedef struct _cairo_gl_font {
455 cairo_scaled_font_private_t base;
456 cairo_device_t *device;
460 static cairo_always_inline GLenum
461 _cairo_gl_get_error (void)
463 GLenum err = glGetError();
466 while (glGetError ());
471 static inline cairo_device_t *
472 _cairo_gl_context_create_in_error (cairo_status_t status)
474 return (cairo_device_t *) _cairo_device_create_in_error (status);
477 cairo_private cairo_status_t
478 _cairo_gl_context_init (cairo_gl_context_t *ctx);
481 _cairo_gl_surface_init (cairo_device_t *device,
482 cairo_gl_surface_t *surface,
483 cairo_content_t content,
484 int width, int height);
486 static cairo_always_inline cairo_bool_t cairo_warn
487 _cairo_gl_surface_is_texture (cairo_gl_surface_t *surface)
489 return surface->tex != 0;
492 cairo_private cairo_status_t
493 _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst,
494 cairo_image_surface_t *src,
495 int src_x, int src_y,
496 int width, int height,
497 int dst_x, int dst_y);
499 static cairo_always_inline cairo_bool_t
500 _cairo_gl_device_has_glsl (cairo_device_t *device)
502 return ((cairo_gl_context_t *) device)->shader_impl != NULL;
505 static cairo_always_inline cairo_bool_t
506 _cairo_gl_device_requires_power_of_two_textures (cairo_device_t *device)
508 return ((cairo_gl_context_t *) device)->tex_target == GL_TEXTURE_RECTANGLE;
511 static cairo_always_inline cairo_status_t cairo_warn
512 _cairo_gl_context_acquire (cairo_device_t *device,
513 cairo_gl_context_t **ctx)
515 cairo_status_t status;
517 status = cairo_device_acquire (device);
518 if (unlikely (status))
521 /* clear potential previous GL errors */
522 _cairo_gl_get_error ();
524 *ctx = (cairo_gl_context_t *) device;
525 return CAIRO_STATUS_SUCCESS;
528 static cairo_always_inline cairo_warn cairo_status_t
529 _cairo_gl_context_release (cairo_gl_context_t *ctx, cairo_status_t status)
533 err = _cairo_gl_get_error ();
535 if (unlikely (err)) {
536 cairo_status_t new_status;
537 new_status = _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
538 if (status == CAIRO_STATUS_SUCCESS)
542 cairo_device_release (&(ctx)->base);
548 _cairo_gl_activate_surface_as_nonmultisampling (cairo_gl_context_t *ctx,
549 cairo_gl_surface_t *surface);
552 _cairo_gl_context_set_destination (cairo_gl_context_t *ctx,
553 cairo_gl_surface_t *surface,
554 cairo_bool_t multisampling);
557 _cairo_gl_context_activate (cairo_gl_context_t *ctx,
558 cairo_gl_tex_t tex_unit);
560 cairo_private cairo_bool_t
561 _cairo_gl_operator_is_supported (cairo_operator_t op);
563 cairo_private cairo_bool_t
564 _cairo_gl_ensure_stencil (cairo_gl_context_t *ctx,
565 cairo_gl_surface_t *surface);
568 _disable_scissor_buffer (void);
571 _disable_stencil_buffer (void);
573 cairo_private cairo_status_t
574 _cairo_gl_composite_init (cairo_gl_composite_t *setup,
576 cairo_gl_surface_t *dst,
577 cairo_bool_t has_component_alpha);
580 _cairo_gl_composite_fini (cairo_gl_composite_t *setup);
583 _cairo_gl_composite_set_clip_region (cairo_gl_composite_t *setup,
584 cairo_region_t *clip_region);
587 _cairo_gl_composite_set_clip(cairo_gl_composite_t *setup,
590 cairo_private cairo_int_status_t
591 _cairo_gl_composite_set_source (cairo_gl_composite_t *setup,
592 const cairo_pattern_t *pattern,
593 const cairo_rectangle_int_t *sample,
594 const cairo_rectangle_int_t *extents,
595 cairo_bool_t use_color_attribute);
598 _cairo_gl_composite_set_solid_source (cairo_gl_composite_t *setup,
599 const cairo_color_t *color);
602 _cairo_gl_composite_set_source_operand (cairo_gl_composite_t *setup,
603 const cairo_gl_operand_t *source);
605 cairo_private cairo_int_status_t
606 _cairo_gl_composite_set_mask (cairo_gl_composite_t *setup,
607 const cairo_pattern_t *pattern,
608 const cairo_rectangle_int_t *sample,
609 const cairo_rectangle_int_t *extents);
612 _cairo_gl_composite_set_mask_operand (cairo_gl_composite_t *setup,
613 const cairo_gl_operand_t *mask);
616 _cairo_gl_composite_set_spans (cairo_gl_composite_t *setup);
618 cairo_private cairo_status_t
619 _cairo_gl_composite_begin (cairo_gl_composite_t *setup,
620 cairo_gl_context_t **ctx);
622 cairo_private cairo_status_t
623 _cairo_gl_composite_begin_multisample (cairo_gl_composite_t *setup,
624 cairo_gl_context_t **ctx_out,
625 cairo_bool_t multisampling);
628 _cairo_gl_composite_emit_rect (cairo_gl_context_t *ctx,
636 _cairo_gl_composite_emit_glyph (cairo_gl_context_t *ctx,
647 _cairo_gl_composite_flush (cairo_gl_context_t *ctx);
649 cairo_private cairo_int_status_t
650 _cairo_gl_composite_emit_quad_as_tristrip (cairo_gl_context_t *ctx,
651 cairo_gl_composite_t *setup,
652 const cairo_point_t quad[4]);
654 cairo_private cairo_int_status_t
655 _cairo_gl_composite_emit_triangle_as_tristrip (cairo_gl_context_t *ctx,
656 cairo_gl_composite_t *setup,
657 const cairo_point_t triangle[3]);
659 cairo_private cairo_int_status_t
660 _cairo_gl_composite_emit_point_as_tristrip_line (cairo_gl_context_t *ctx,
661 const cairo_point_t point[2],
662 cairo_bool_t start_point);
664 cairo_private cairo_int_status_t
665 _cairo_gl_composite_emit_point_as_single_line (cairo_gl_context_t *ctx,
666 const cairo_point_t point[2]);
669 _cairo_gl_context_destroy_operand (cairo_gl_context_t *ctx,
670 cairo_gl_tex_t tex_unit);
672 cairo_private cairo_bool_t
673 _cairo_gl_get_image_format_and_type (cairo_gl_flavor_t flavor,
674 pixman_format_code_t pixman_format,
675 GLenum *internal_format, GLenum *format,
676 GLenum *type, cairo_bool_t *has_alpha,
677 cairo_bool_t *needs_swap);
680 _cairo_gl_glyph_cache_init (cairo_gl_glyph_cache_t *cache);
683 _cairo_gl_glyph_cache_fini (cairo_gl_context_t *ctx,
684 cairo_gl_glyph_cache_t *cache);
686 cairo_private cairo_int_status_t
687 _cairo_gl_surface_show_glyphs (void *abstract_dst,
689 const cairo_pattern_t *source,
690 cairo_glyph_t *glyphs,
692 cairo_scaled_font_t *scaled_font,
693 const cairo_clip_t *clip,
694 int *remaining_glyphs);
696 cairo_private cairo_status_t
697 _cairo_gl_context_init_shaders (cairo_gl_context_t *ctx);
700 _cairo_gl_context_fini_shaders (cairo_gl_context_t *ctx);
702 static cairo_always_inline cairo_bool_t
703 _cairo_gl_context_is_flushed (cairo_gl_context_t *ctx)
705 return ctx->vb == NULL;
708 cairo_private cairo_status_t
709 _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx,
710 cairo_gl_operand_t *source,
711 cairo_gl_operand_t *mask,
712 cairo_bool_t use_coverage,
713 cairo_gl_shader_in_t in,
714 cairo_gl_shader_t **shader);
717 _cairo_gl_shader_bind_float (cairo_gl_context_t *ctx,
722 _cairo_gl_shader_bind_vec2 (cairo_gl_context_t *ctx,
724 float value0, float value1);
727 _cairo_gl_shader_bind_vec3 (cairo_gl_context_t *ctx,
734 _cairo_gl_shader_bind_vec4 (cairo_gl_context_t *ctx,
736 float value0, float value1,
737 float value2, float value3);
740 _cairo_gl_shader_bind_matrix (cairo_gl_context_t *ctx,
745 _cairo_gl_shader_bind_matrix4f (cairo_gl_context_t *ctx,
750 _cairo_gl_set_shader (cairo_gl_context_t *ctx,
751 cairo_gl_shader_t *shader);
754 _cairo_gl_shader_fini (cairo_gl_context_t *ctx, cairo_gl_shader_t *shader);
757 _cairo_gl_get_version (void);
759 cairo_private cairo_gl_flavor_t
760 _cairo_gl_get_flavor (void);
762 cairo_private cairo_bool_t
763 _cairo_gl_has_extension (const char *ext);
765 cairo_private cairo_status_t
766 _cairo_gl_dispatch_init(cairo_gl_dispatch_t *dispatch,
767 cairo_gl_get_proc_addr_func_t get_proc_addr);
769 cairo_private cairo_int_status_t
770 _cairo_gl_operand_init (cairo_gl_operand_t *operand,
771 const cairo_pattern_t *pattern,
772 cairo_gl_surface_t *dst,
773 const cairo_rectangle_int_t *sample,
774 const cairo_rectangle_int_t *extents,
775 cairo_bool_t use_color_attribute);
778 _cairo_gl_solid_operand_init (cairo_gl_operand_t *operand,
779 const cairo_color_t *color);
781 cairo_private cairo_filter_t
782 _cairo_gl_operand_get_filter (cairo_gl_operand_t *operand);
785 _cairo_gl_operand_get_gl_filter (cairo_gl_operand_t *operand);
787 cairo_private cairo_extend_t
788 _cairo_gl_operand_get_extend (cairo_gl_operand_t *operand);
790 cairo_private cairo_extend_t
791 _cairo_gl_operand_get_atlas_extend (cairo_gl_operand_t *operand);
793 cairo_private unsigned int
794 _cairo_gl_operand_get_vertex_size (cairo_gl_operand_t *operand);
796 cairo_private cairo_bool_t
797 _cairo_gl_operand_get_use_atlas (cairo_gl_operand_t *operand);
799 cairo_private cairo_bool_t
800 _cairo_gl_operand_needs_setup (cairo_gl_operand_t *dest,
801 cairo_gl_operand_t *source,
802 unsigned int vertex_offset,
803 cairo_bool_t *needs_flush);
806 _cairo_gl_operand_bind_to_shader (cairo_gl_context_t *ctx,
807 cairo_gl_operand_t *operand,
808 cairo_gl_tex_t tex_unit);
811 _cairo_gl_operand_copy (cairo_gl_operand_t *dst,
812 const cairo_gl_operand_t *src);
815 _cairo_gl_operand_translate (cairo_gl_operand_t *operand,
816 double tx, double ty);
819 _cairo_gl_operand_destroy (cairo_gl_operand_t *operand);
821 cairo_private const cairo_compositor_t *
822 _cairo_gl_msaa_compositor_get (void);
824 cairo_private const cairo_compositor_t *
825 _cairo_gl_span_compositor_get (void);
827 cairo_private const cairo_compositor_t *
828 _cairo_gl_traps_compositor_get (void);
830 cairo_private cairo_int_status_t
831 _cairo_gl_check_composite_glyphs (const cairo_composite_rectangles_t *extents,
832 cairo_scaled_font_t *scaled_font,
833 cairo_glyph_t *glyphs,
836 cairo_private cairo_int_status_t
837 _cairo_gl_composite_glyphs (void *_dst,
839 cairo_surface_t *_src,
844 cairo_composite_glyphs_info_t *info);
847 _cairo_gl_composite_glyphs_with_clip (void *_dst,
849 cairo_surface_t *_src,
854 cairo_composite_glyphs_info_t *info,
856 cairo_bool_t via_msaa_compositor);
859 _cairo_gl_image_node_destroy (cairo_rtree_node_t *node);
862 _cairo_gl_image_node_fini (void *data);
865 _cairo_gl_image_cache_unlock (cairo_gl_context_t *ctx);
868 _cairo_gl_image_cache_init (cairo_gl_context_t *ctx);
871 _cairo_gl_ensure_framebuffer (cairo_gl_context_t *ctx,
872 cairo_gl_surface_t *surface);
874 cairo_private cairo_surface_t *
875 _cairo_gl_surface_create_scratch (cairo_gl_context_t *ctx,
876 cairo_content_t content,
879 cairo_bool_t true_alpha);
881 cairo_private cairo_surface_t *
882 _cairo_gl_pattern_to_source (cairo_surface_t *dst,
883 const cairo_pattern_t *pattern,
884 cairo_bool_t is_mask,
885 const cairo_rectangle_int_t *extents,
886 const cairo_rectangle_int_t *sample,
887 int *src_x, int *src_y);
889 cairo_private cairo_int_status_t
890 _cairo_gl_msaa_compositor_draw_clip (cairo_gl_context_t *ctx,
891 cairo_gl_composite_t *setup,
893 cairo_traps_t *traps);
895 cairo_private cairo_surface_t *
896 _cairo_gl_white_source (void);
898 static inline cairo_gl_operand_t *
899 source_to_operand (cairo_surface_t *surface)
901 cairo_gl_source_t *source = (cairo_gl_source_t *)surface;
902 return source ? &source->operand : NULL;
906 _cairo_gl_glyph_cache_unlock (cairo_gl_glyph_cache_t *cache)
908 _cairo_rtree_unpin (&cache->rtree);
912 _cairo_gl_scissor_to_extents (cairo_gl_surface_t *surface,
913 const cairo_rectangle_int_t *extents);
916 cairo_private cairo_bool_t
917 _cairo_gl_hairline_style_is_hairline (const cairo_stroke_style_t *style,
918 const cairo_matrix_t *ctm);
920 cairo_private cairo_status_t
921 _cairo_gl_hairline_move_to (void *closure,
922 const cairo_point_t *point);
924 cairo_private cairo_status_t
925 _cairo_gl_hairline_line_to (void *closure,
926 const cairo_point_t *point);
928 cairo_private cairo_status_t
929 _cairo_gl_hairline_line_to_dashed (void *closure,
930 const cairo_point_t *point);
932 cairo_private cairo_status_t
933 _cairo_gl_hairline_curve_to (void *closure,
934 const cairo_point_t *p0,
935 const cairo_point_t *p1,
936 const cairo_point_t *p2);
938 cairo_private cairo_status_t
939 _cairo_gl_hairline_close_path (void *closure);
941 cairo_private cairo_status_t
942 _cairo_gl_path_fixed_stroke_to_hairline (const cairo_path_fixed_t *path,
943 cairo_gl_hairline_closure_t *closure,
944 const cairo_stroke_style_t *style,
945 const cairo_matrix_t *ctm,
946 const cairo_matrix_t *ctm_inverse,
947 cairo_path_fixed_move_to_func_t *move_to,
948 cairo_path_fixed_line_to_func_t *line_to,
949 cairo_path_fixed_curve_to_func_t *curve_to,
950 cairo_path_fixed_close_path_func_t *close_path);
952 slim_hidden_proto (cairo_gl_surface_create);
953 slim_hidden_proto (cairo_gl_surface_create_for_texture);
955 #endif /* CAIRO_GL_PRIVATE_H */