summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boilerplate/cairo-boilerplate-cogl.c32
-rw-r--r--build/configure.ac.warnings2
-rw-r--r--configure.ac2
-rw-r--r--src/cairo-cogl-gradient-private.h2
-rw-r--r--src/cairo-cogl-gradient.c31
-rw-r--r--src/cairo-cogl-private.h4
-rw-r--r--src/cairo-cogl-surface.c309
-rw-r--r--src/cairo-cogl-utils-private.h5
-rw-r--r--src/cairo-cogl-utils.c5
-rw-r--r--src/cairo-cogl.h2
-rw-r--r--src/cairo-composite-rectangles-private.h11
-rw-r--r--src/cairo-composite-rectangles.c4
12 files changed, 250 insertions, 159 deletions
diff --git a/boilerplate/cairo-boilerplate-cogl.c b/boilerplate/cairo-boilerplate-cogl.c
index 8dda3172..a9b0c757 100644
--- a/boilerplate/cairo-boilerplate-cogl.c
+++ b/boilerplate/cairo-boilerplate-cogl.c
@@ -33,7 +33,7 @@
#include "cairo-boilerplate-private.h"
#include <cairo-cogl.h>
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
typedef struct _cogl_closure {
cairo_device_t *device;
@@ -71,7 +71,7 @@ _cairo_boilerplate_cogl_create_offscreen_color_surface (const char *name,
{
cairo_device_t *device;
CoglTexture *tex;
- CoglHandle offscreen;
+ CoglOffscreen *offscreen;
CoglFramebuffer *fb;
cogl_closure_t *closure;
cairo_status_t status;
@@ -80,18 +80,20 @@ _cairo_boilerplate_cogl_create_offscreen_color_surface (const char *name,
context = cogl_context_new (NULL, NULL);
device = cairo_cogl_device_create (context);
- tex = cogl_texture_new_with_size (width, height,
+ tex = cogl_texture_new_with_size (context,
+ width, height,
COGL_TEXTURE_NO_SLICING,
- COGL_PIXEL_FORMAT_BGRA_8888_PRE);
+ COGL_PIXEL_FORMAT_BGRA_8888_PRE,
+ NULL);
offscreen = cogl_offscreen_new_to_texture (tex);
fb = COGL_FRAMEBUFFER (offscreen);
cogl_framebuffer_allocate (fb, NULL);
- cogl_push_framebuffer (fb);
- cogl_ortho (0, cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb), 0,
- -1, 100);
- cogl_pop_framebuffer ();
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1, 100);
closure = malloc (sizeof (cogl_closure_t));
*abstract_closure = closure;
@@ -134,11 +136,11 @@ _cairo_boilerplate_cogl_create_onscreen_color_surface (const char *name,
cogl_onscreen_show (onscreen);
- cogl_push_framebuffer (fb);
- cogl_ortho (0, cogl_framebuffer_get_width (fb),
- cogl_framebuffer_get_height (fb), 0,
- -1, 100);
- cogl_pop_framebuffer ();
+ cogl_framebuffer_orthographic (fb,
+ 0, 0,
+ cogl_framebuffer_get_width (fb),
+ cogl_framebuffer_get_height (fb),
+ -1, 100);
closure = malloc (sizeof (cogl_closure_t));
*abstract_closure = closure;
@@ -162,7 +164,7 @@ _cairo_boilerplate_cogl_finish_onscreen (cairo_surface_t *surface)
cairo_cogl_surface_end_frame (surface);
- cogl_framebuffer_swap_buffers (closure->fb);
+ cogl_onscreen_swap_buffers (COGL_ONSCREEN (closure->fb));
return CAIRO_STATUS_SUCCESS;
}
diff --git a/build/configure.ac.warnings b/build/configure.ac.warnings
index 3eb0104b..f161d323 100644
--- a/build/configure.ac.warnings
+++ b/build/configure.ac.warnings
@@ -10,7 +10,7 @@ dnl MAYBE_WARN in an ignorable way (like adding whitespace)
# -Wlogical-op causes too much noise from strcmp("literal", str)
-MAYBE_WARN="-Wall -Wextra \
+MAYBE_WARN="-Wall -Wextra \
-Wold-style-definition -Wdeclaration-after-statement \
-Wmissing-declarations -Werror-implicit-function-declaration \
-Wnested-externs -Wpointer-arith -Wwrite-strings \
diff --git a/configure.ac b/configure.ac
index 3a438ee3..92747f0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -329,7 +329,7 @@ CAIRO_ENABLE_SURFACE_BACKEND(glesv2, OpenGLESv2, no, [
dnl ===========================================================================
CAIRO_ENABLE_SURFACE_BACKEND(cogl, Cogl, no, [
- cogl_REQUIRES="cogl-2.0-experimental"
+ cogl_REQUIRES="cogl2"
PKG_CHECK_MODULES(cogl, $cogl_REQUIRES,, [use_cogl="no"])
])
diff --git a/src/cairo-cogl-gradient-private.h b/src/cairo-cogl-gradient-private.h
index 9589b078..61ce704b 100644
--- a/src/cairo-cogl-gradient-private.h
+++ b/src/cairo-cogl-gradient-private.h
@@ -35,7 +35,7 @@
#include "cairoint.h"
#include "cairo-pattern-private.h"
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
#define CAIRO_COGL_LINEAR_GRADIENT_CACHE_SIZE (1024 * 1024)
diff --git a/src/cairo-cogl-gradient.c b/src/cairo-cogl-gradient.c
index 2dc07072..19430c30 100644
--- a/src/cairo-cogl-gradient.c
+++ b/src/cairo-cogl-gradient.c
@@ -34,7 +34,7 @@
#include "cairo-cogl-gradient-private.h"
#include "cairo-image-surface-private.h"
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
#include <glib.h>
#define DUMP_GRADIENTS_TO_PNG
@@ -372,9 +372,10 @@ _cairo_cogl_get_linear_gradient (cairo_cogl_device_t *device,
cairo_color_stop_t right_padding_color;
CoglPixelFormat format;
CoglTexture2D *tex;
- GError *error = NULL;
+ CoglError *error = NULL;
int un_padded_width;
- CoglHandle offscreen;
+ CoglOffscreen *offscreen;
+ CoglFramebuffer *fb;
cairo_int_status_t status;
int n_quads;
int n_vertices;
@@ -383,6 +384,7 @@ _cairo_cogl_get_linear_gradient (cairo_cogl_device_t *device,
CoglVertexP2C4 *vertices;
CoglVertexP2C4 *p;
CoglPrimitive *prim;
+ CoglPipeline *pipeline;
hash = _cairo_cogl_linear_gradient_hash (n_stops, stops);
@@ -562,7 +564,7 @@ _cairo_cogl_get_linear_gradient (cairo_cogl_device_t *device,
format,
&error);
if (!tex)
- g_error_free (error);
+ cogl_error_free (error);
} while (tex == NULL && width >> 1);
if (!tex) {
@@ -582,10 +584,10 @@ _cairo_cogl_get_linear_gradient (cairo_cogl_device_t *device,
if (left_padding)
entry->translate_x += (entry->scale_x / (float)un_padded_width) * (float)left_padding;
- offscreen = cogl_offscreen_new_to_texture (tex);
- cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
- cogl_ortho (0, width, 1, 0, -1, 100);
- cogl_framebuffer_clear4f (COGL_FRAMEBUFFER (offscreen),
+ offscreen = cogl_offscreen_new_to_texture (COGL_TEXTURE (tex));
+ fb = COGL_FRAMEBUFFER (offscreen);
+ cogl_framebuffer_orthographic (fb, 0, 0, width, 1, -1, 100);
+ cogl_framebuffer_clear4f (fb,
COGL_BUFFER_BIT_COLOR,
0, 0, 0, 0);
@@ -604,15 +606,18 @@ _cairo_cogl_get_linear_gradient (cairo_cogl_device_t *device,
if (right_padding)
emit_stop (&p, prev, width, &right_padding_color, &right_padding_color);
- prim = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES,
+ prim = cogl_primitive_new_p2c4 (device->cogl_context,
+ COGL_VERTICES_MODE_TRIANGLES,
n_vertices,
vertices);
- /* Just use this as the simplest way to setup a default pipeline... */
- cogl_set_source_color4f (0, 0, 0, 0);
- cogl_primitive_draw (prim);
+
+ pipeline = cogl_pipeline_new (device->cogl_context);
+
+ cogl_framebuffer_draw_primitive (fb, pipeline, prim);
cogl_object_unref (prim);
- cogl_pop_framebuffer ();
+ cogl_object_unref (pipeline);
+
cogl_object_unref (offscreen);
gradient->textures = g_list_prepend (gradient->textures, entry);
diff --git a/src/cairo-cogl-private.h b/src/cairo-cogl-private.h
index 188cdc0d..94049695 100644
--- a/src/cairo-cogl-private.h
+++ b/src/cairo-cogl-private.h
@@ -38,7 +38,7 @@
#include "cairo-default-context-private.h"
#include "cairo-surface-private.h"
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
typedef enum _cairo_cogl_template_type {
CAIRO_COGL_TEMPLATE_TYPE_SOLID,
@@ -84,6 +84,8 @@ typedef struct _cairo_cogl_device {
cairo_cache_t path_fill_prim_cache;
cairo_cache_t path_stroke_staging_cache;
cairo_cache_t path_stroke_prim_cache;
+
+ CoglSnippet *layer_transform_snippet[3];
} cairo_cogl_device_t;
typedef struct _cairo_cogl_clip_primitives {
diff --git a/src/cairo-cogl-surface.c b/src/cairo-cogl-surface.c
index 6f93771c..0d3e54ad 100644
--- a/src/cairo-cogl-surface.c
+++ b/src/cairo-cogl-surface.c
@@ -51,7 +51,7 @@
#include "cairo-cogl.h"
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
#include <glib.h>
#define CAIRO_COGL_DEBUG 0
@@ -332,14 +332,14 @@ _cairo_matrix_preserves_scale_and_aspect (cairo_matrix_t *matrix)
static cairo_status_t
_cairo_cogl_surface_ensure_framebuffer (cairo_cogl_surface_t *surface)
{
- GError *error = NULL;
+ CoglError *error = NULL;
if (surface->framebuffer)
return CAIRO_STATUS_SUCCESS;
surface->framebuffer = COGL_FRAMEBUFFER (cogl_offscreen_new_to_texture (surface->texture));
if (!cogl_framebuffer_allocate (surface->framebuffer, &error)) {
- g_error_free (error);
+ cogl_error_free (error);
cogl_object_unref (surface->framebuffer);
surface->framebuffer = NULL;
return CAIRO_STATUS_NO_MEMORY;
@@ -365,14 +365,14 @@ _cairo_cogl_surface_create_similar (void *abstract_surface,
CoglPixelFormat format = cogl_framebuffer_get_color_format (reference_surface->framebuffer);
CoglTexture2D *texture;
cairo_status_t status;
- GError *error;
+ CoglError *error;
texture = cogl_texture_2d_new_with_size (reference_surface->dev->cogl_context,
width, height,
format,
&error);
if (!texture) {
- g_error_free (error);
+ cogl_error_free (error);
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
@@ -617,7 +617,7 @@ _cairo_cogl_surface_allocate_buffer_space (cairo_cogl_surface_t *surface,
void **pointer)
{
/* XXX: In the Cogl journal we found it more efficient to have a pool of
- * buffers that we re-cycle but for now we simply thow away our stack
+ * buffers that we re-cycle but for now we simply throw away our stack
* buffer each time we flush. */
if (unlikely (surface->buffer_stack &&
(surface->buffer_stack_size - surface->buffer_stack_offset) < size)) {
@@ -631,11 +631,14 @@ _cairo_cogl_surface_allocate_buffer_space (cairo_cogl_surface_t *surface,
surface->buffer_stack_size = size * 2;
if (unlikely (surface->buffer_stack == NULL)) {
- surface->buffer_stack = cogl_attribute_buffer_new (surface->buffer_stack_size, NULL);
+ CoglContext *ctx = surface->dev->cogl_context;
+ surface->buffer_stack =
+ cogl_attribute_buffer_new_with_size (ctx, surface->buffer_stack_size);
surface->buffer_stack_pointer =
cogl_buffer_map (COGL_BUFFER (surface->buffer_stack),
COGL_BUFFER_ACCESS_WRITE,
- COGL_BUFFER_MAP_HINT_DISCARD);
+ COGL_BUFFER_MAP_HINT_DISCARD,
+ NULL); /* FIXME: handle mapping errors gracefully somehow */
surface->buffer_stack_offset = 0;
}
@@ -666,14 +669,19 @@ _cairo_cogl_traps_to_triangles_buffer (cairo_cogl_surface_t *surface,
if (!buffer)
return NULL;
} else {
- buffer = cogl_attribute_buffer_new (n_traps * sizeof (CoglVertexP2) * 6, NULL);
+ CoglContext *ctx = surface->dev->cogl_context;
+ CoglError *ignore_error = NULL;
+ buffer = cogl_attribute_buffer_new_with_size (ctx, n_traps * sizeof (CoglVertexP2) * 6);
if (!buffer)
return NULL;
triangles = cogl_buffer_map (COGL_BUFFER (buffer),
COGL_BUFFER_ACCESS_WRITE,
- COGL_BUFFER_MAP_HINT_DISCARD);
- if (!triangles)
+ COGL_BUFFER_MAP_HINT_DISCARD,
+ &ignore_error);
+ if (!triangles) {
+ cogl_error_free (ignore_error);
return NULL;
+ }
*offset = 0;
}
@@ -844,17 +852,19 @@ BAIL:
}
static void
-_cairo_cogl_clip_push_box (const cairo_box_t *box)
+_cairo_cogl_clip_push_box (CoglFramebuffer *fb,
+ const cairo_box_t *box)
{
if (_cairo_box_is_pixel_aligned (box)) {
cairo_rectangle_int_t rect;
_cairo_box_round_to_rectangle (box, &rect);
- cogl_clip_push_window_rectangle (rect.x, rect.y,
- rect.width, rect.height);
+ cogl_framebuffer_push_scissor_clip (fb,
+ rect.x, rect.y,
+ rect.width, rect.height);
} else {
double x1, y1, x2, y2;
_cairo_box_to_doubles (box, &x1, &y1, &x2, &y2);
- cogl_clip_push_rectangle (x1, y1, x2, y2);
+ cogl_framebuffer_push_rectangle_clip (fb, x1, y1, x2, y2);
}
}
@@ -874,9 +884,7 @@ _cairo_cogl_journal_flush (cairo_cogl_surface_t *surface)
surface->buffer_stack = NULL;
}
- cogl_set_framebuffer (surface->framebuffer);
-
- cogl_push_matrix ();
+ cogl_framebuffer_push_matrix (surface->framebuffer);
for (l = surface->journal->head; l; l = l->next) {
cairo_cogl_journal_entry_t *entry = l->data;
@@ -893,7 +901,7 @@ _cairo_cogl_journal_flush (cairo_cogl_surface_t *surface)
#endif
for (i = 0; i < clip_stack_depth; i++)
- cogl_clip_pop ();
+ cogl_framebuffer_pop_clip (surface->framebuffer);
clip_stack_depth = 0;
for (path = clip_entry->clip->path, i = 0; path; path = path->prev, i++) {
@@ -929,16 +937,17 @@ _cairo_cogl_journal_flush (cairo_cogl_surface_t *surface)
continue;
}
clip_stack_depth++;
- cogl_clip_push_primitive (prim,
- extents.x, extents.y,
- extents.x + extents.width,
- extents.y + extents.height);
+ cogl_framebuffer_push_primitive_clip (surface->framebuffer,
+ prim,
+ extents.x, extents.y,
+ extents.x + extents.width,
+ extents.y + extents.height);
cogl_object_unref (prim);
}
for (i = 0; i < clip_entry->clip->num_boxes; i++) {
clip_stack_depth++;
- _cairo_cogl_clip_push_box (&clip_entry->clip->boxes[i]);
+ _cairo_cogl_clip_push_box (surface->framebuffer, &clip_entry->clip->boxes[i]);
}
surface->n_clip_updates_per_frame++;
@@ -962,13 +971,14 @@ _cairo_cogl_journal_flush (cairo_cogl_surface_t *surface)
cogl_matrix_init_from_array (&transform, ctmfv);
- cogl_set_source (rect_entry->pipeline);
- cogl_push_matrix ();
- cogl_transform (&transform);
- cogl_rectangle_with_multitexture_coords (x1, y1, x2, y2,
- rect_entry->tex_coords,
- 4 * rect_entry->n_layers);
- cogl_pop_matrix ();
+ cogl_framebuffer_push_matrix (surface->framebuffer);
+ cogl_framebuffer_transform (surface->framebuffer, &transform);
+ cogl_framebuffer_draw_multitextured_rectangle (surface->framebuffer,
+ rect_entry->pipeline,
+ x1, y1, x2, y2,
+ rect_entry->tex_coords,
+ 4 * rect_entry->n_layers);
+ cogl_framebuffer_pop_matrix (surface->framebuffer);
break;
}
case CAIRO_COGL_JOURNAL_ENTRY_TYPE_PRIMITIVE: {
@@ -976,7 +986,7 @@ _cairo_cogl_journal_flush (cairo_cogl_surface_t *surface)
(cairo_cogl_journal_prim_entry_t *)entry;
CoglMatrix transform;
- cogl_push_matrix ();
+ cogl_framebuffer_push_matrix (surface->framebuffer);
if (prim_entry->has_transform) {
cairo_matrix_t *ctm = &prim_entry->transform;
float ctmfv[16] = {
@@ -986,23 +996,26 @@ _cairo_cogl_journal_flush (cairo_cogl_surface_t *surface)
ctm->x0, ctm->y0, 0, 1
};
cogl_matrix_init_from_array (&transform, ctmfv);
- cogl_transform (&transform);
+ cogl_framebuffer_transform (surface->framebuffer, &transform);
} else {
cogl_matrix_init_identity (&transform);
- cogl_set_modelview_matrix (&transform);
+ cogl_framebuffer_set_modelview_matrix (surface->framebuffer,
+ &transform);
}
- cogl_set_source (prim_entry->pipeline);
- cogl_primitive_draw (prim_entry->primitive);
- cogl_pop_matrix ();
+ cogl_framebuffer_draw_primitive (surface->framebuffer,
+ prim_entry->pipeline,
+ prim_entry->primitive);
+ cogl_framebuffer_pop_matrix (surface->framebuffer);
break;
}
case CAIRO_COGL_JOURNAL_ENTRY_TYPE_PATH: {
cairo_cogl_journal_path_entry_t *path_entry =
(cairo_cogl_journal_path_entry_t *)entry;
- cogl_set_source (path_entry->pipeline);
- cogl_path_fill (path_entry->path);
+ cogl_framebuffer_fill_path (surface->framebuffer,
+ path_entry->pipeline,
+ path_entry->path);
break;
}
default:
@@ -1010,10 +1023,10 @@ _cairo_cogl_journal_flush (cairo_cogl_surface_t *surface)
}
}
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (surface->framebuffer);
for (i = 0; i < clip_stack_depth; i++)
- cogl_clip_pop ();
+ cogl_framebuffer_pop_clip (surface->framebuffer);
_cairo_cogl_journal_discard (surface);
}
@@ -1127,13 +1140,10 @@ _cairo_cogl_surface_read_rect_to_image_surface (cairo_cogl_surface_t *surface,
if (image->base.status)
return image->base.status;
- /* TODO: Add cogl_framebuffer_read_pixels() API */
- cogl_push_framebuffer (surface->framebuffer);
- cogl_read_pixels (0, 0, surface->width, surface->height,
- COGL_READ_PIXELS_COLOR_BUFFER,
- cogl_format,
- image->data);
- cogl_pop_framebuffer ();
+ cogl_framebuffer_read_pixels (surface->framebuffer,
+ 0, 0, surface->width, surface->height,
+ cogl_format,
+ image->data);
*image_out = image;
@@ -1273,9 +1283,10 @@ _cairo_cogl_get_pot_texture (CoglContext *context,
int height = cogl_texture_get_height (texture);
int pot_width;
int pot_height;
- CoglHandle offscreen = NULL;
+ CoglOffscreen *offscreen = NULL;
CoglTexture2D *pot = NULL;
- GError *error;
+ CoglError *error;
+ CoglPipeline *pipeline;
pot_width = _cairo_cogl_util_next_p2 (width);
pot_height = _cairo_cogl_util_next_p2 (height);
@@ -1295,7 +1306,7 @@ _cairo_cogl_get_pot_texture (CoglContext *context,
if (pot)
break;
else
- g_error_free (error);
+ cogl_error_free (error);
if (pot_width > pot_height)
pot_width >>= 1;
@@ -1317,17 +1328,19 @@ _cairo_cogl_get_pot_texture (CoglContext *context,
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (offscreen), &error)) {
/* NB: if we don't pass an error then Cogl is allowed to simply abort
* automatically. */
- g_error_free (error);
+ cogl_error_free (error);
cogl_object_unref (pot);
*pot_texture = NULL;
return CAIRO_INT_STATUS_NO_MEMORY;
}
- cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
- cogl_set_source_texture (texture);
- cogl_rectangle (-1, 1, 1, -1);
- cogl_pop_framebuffer ();
+ pipeline = cogl_pipeline_new (context);
+ cogl_pipeline_set_layer_texture (pipeline, 0, texture);
+ cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen),
+ pipeline,
+ -1, 1, 1, -1);
+ cogl_object_unref (pipeline);
cogl_object_unref (offscreen);
*pot_scale_x = width / (float)pot_width;
@@ -1369,7 +1382,7 @@ _cairo_cogl_acquire_surface_texture (cairo_cogl_surface_t *reference_surface
CoglPixelFormat format;
cairo_image_surface_t *image_clone = NULL;
CoglTexture *texture;
- GError *error = NULL;
+ CoglError *error = NULL;
cairo_surface_t *clone;
int width;
int height;
@@ -1432,7 +1445,8 @@ _cairo_cogl_acquire_surface_texture (cairo_cogl_surface_t *reference_surface
image->data,
&error));
if (!texture) {
- g_error_free (error);
+ cogl_error_free (error);
+ error = NULL;
/* If we fail to upload our image to a CoglTexture2D then we guess the
* problem was because we exceeded the gpu texture limits or because
@@ -1451,19 +1465,18 @@ _cairo_cogl_acquire_surface_texture (cairo_cogl_surface_t *reference_surface
&error));
if (!texture) {
g_warning ("Failed to allocate texture: %s", error->message);
- g_error_free (error);
+ cogl_error_free (error);
goto BAIL;
}
- if (!cogl_texture_set_region (texture,
- 0, 0, /* src x/y */
- 0, 0, /* dst x/y */
- image->width, image->height, /* dst region */
- image->width, image->height, /* src region */
- format,
- image->stride,
- image->data))
+ if (!cogl_texture_set_data (texture,
+ format,
+ image->stride,
+ image->data,
+ 0, /* mipmap level */
+ &error))
{
+ cogl_error_free (error);
cogl_object_unref (texture);
texture = NULL;
g_warning ("Failed to upload data to sliced texture");
@@ -1550,20 +1563,24 @@ ACQUIRED:
cogl_texture_get_format (texture),
&error);
if (new) {
+ CoglPipeline *pipeline;
- CoglHandle offscreen = cogl_offscreen_new_to_texture (COGL_TEXTURE (new));
+ CoglOffscreen *offscreen = cogl_offscreen_new_to_texture (COGL_TEXTURE (new));
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (offscreen), &error)) {
- g_error_free (error);
+ cogl_error_free (error);
cogl_object_unref (new);
cogl_object_unref (texture);
texture = NULL;
goto BAIL;
}
- cogl_push_framebuffer (COGL_FRAMEBUFFER (offscreen));
- cogl_set_source_texture (texture);
- cogl_rectangle (-1, 1, 1, -1);
- cogl_pop_framebuffer ();
+ pipeline = cogl_pipeline_new (ctx);
+ cogl_pipeline_set_layer_texture (pipeline, 0, texture);
+
+ cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen),
+ pipeline,
+ -1, 1, 1, -1);
+ cogl_object_unref (pipeline);
cogl_object_unref (offscreen);
cogl_object_unref (texture);
@@ -1574,7 +1591,7 @@ ACQUIRED:
CoglTexture *pot_texture;
cairo_int_status_t status;
- g_error_free (error);
+ cogl_error_free (error);
status = _cairo_cogl_get_pot_texture (ctx, texture, &pot_texture,
pot_scale_x_out,
@@ -2039,7 +2056,8 @@ _cairo_cogl_layers_deinit (cairo_cogl_layers_t *layers)
}
static void
-_cairo_cogl_pipeline_add_texture_layer (CoglPipeline *pipeline,
+_cairo_cogl_pipeline_add_texture_layer (cairo_cogl_device_t *device,
+ CoglPipeline *pipeline,
int layer_index,
const cairo_cogl_layer_t *layer)
{
@@ -2053,9 +2071,35 @@ _cairo_cogl_pipeline_add_texture_layer (CoglPipeline *pipeline,
0, 0, 1, 0,
m->x0, m->y0, 0, 1
};
- CoglMatrix texture_matrix;
- cogl_matrix_init_from_array (&texture_matrix, texture_matrixfv);
- cogl_pipeline_set_layer_matrix (pipeline, layer_index, &texture_matrix);
+ const char *uniform;
+ int location;
+
+ g_return_if_fail (layer_index <= 2);
+
+ cogl_pipeline_add_layer_snippet (pipeline,
+ layer_index,
+ device->layer_transform_snippet[layer_index]);
+
+ switch (layer_index)
+ {
+ case 0:
+ uniform = "layer0_transform";
+ break;
+ case 1:
+ uniform = "layer1_transform";
+ break;
+ case 2:
+ uniform = "layer2_transform";
+ break;
+ }
+
+ location = cogl_pipeline_get_uniform_location (pipeline, uniform);
+ cogl_pipeline_set_uniform_matrix (pipeline,
+ location,
+ 4, /* dimensions */
+ 1, /* count */
+ FALSE, /* no transpose */
+ texture_matrixfv);
}
if (layer->s_wrap != layer->t_wrap) {
@@ -2087,7 +2131,7 @@ _cairo_cogl_layers_to_pipeline (cairo_cogl_device_t *device,
for (i = 0; i < layers->n_layers; i++) {
cairo_cogl_layer_t *layer = &layers->layer[i];
if (layer->texture)
- _cairo_cogl_pipeline_add_texture_layer (pipeline, i, layer);
+ _cairo_cogl_pipeline_add_texture_layer (device, pipeline, i, layer);
else
cogl_pipeline_set_color (pipeline, &layer->color);
}
@@ -2626,10 +2670,14 @@ _cairo_cogl_path_stroke_meta_lookup (cairo_cogl_device_t *ctx,
}
static void
-_cairo_cogl_path_stroke_meta_set_prim_size (cairo_cogl_surface_t *surface,
- cairo_cogl_path_stroke_meta_t *meta,
- size_t size)
+_cairo_cogl_path_stroke_meta_set_prim (cairo_cogl_path_stroke_meta_t *meta,
+ cairo_cogl_surface_t *surface,
+ CoglPrimitive *prim,
+ size_t size)
{
+ meta->prim = cogl_object_ref (prim);
+ meta->ctm_inverse = *surface->ctm_inverse;
+
/* now that we know the meta structure is associated with a primitive
* we promote it from the staging cache into the primitive cache.
*/
@@ -2700,7 +2748,6 @@ _cairo_cogl_get_path_stroke_meta (cairo_cogl_surface_t *surface,
if (unlikely (status))
goto BAIL;
meta->user_path = meta_path;
- meta->ctm_inverse = *surface->ctm_inverse;
status = _cairo_stroke_style_init_copy (&meta->style, style);
if (unlikely (status)) {
@@ -2818,17 +2865,16 @@ _cairo_cogl_surface_stroke (void *abstract_surface,
return status;
#ifdef ENABLE_PATH_CACHE
- /* FIXME: we are currently leaking the meta state if we don't reach
- * the cache_insert at the end. */
- if (side_band_state_valid)
+ if (side_band_state_valid) {
meta = _cairo_cogl_get_path_stroke_meta (surface, style, tolerance);
- if (meta) {
- prim = meta->prim;
- if (prim) {
- cairo_matrix_multiply (&transform_matrix, &meta->ctm_inverse, surface->ctm);
- transform = &transform_matrix;
- } else if (meta->counter++ > 10)
- one_shot = FALSE;
+ if (meta) {
+ prim = meta->prim;
+ if (prim) {
+ cairo_matrix_multiply (&transform_matrix, &meta->ctm_inverse, surface->ctm);
+ transform = &transform_matrix;
+ } else if (meta->counter++ > 10)
+ one_shot = FALSE;
+ }
}
#endif
@@ -2843,10 +2889,8 @@ _cairo_cogl_surface_stroke (void *abstract_surface,
return status;
new_prim = TRUE;
#if defined (ENABLE_PATH_CACHE)
- if (meta && !one_shot) {
- meta->prim = cogl_object_ref (prim);
- _cairo_cogl_path_stroke_meta_set_prim_size (surface, meta, prim_size);
- }
+ if (meta && !one_shot)
+ _cairo_cogl_path_stroke_meta_set_prim (meta, surface, prim, prim_size);
#endif
}
@@ -2925,10 +2969,14 @@ _cairo_cogl_path_fill_meta_lookup (cairo_cogl_device_t *ctx,
}
static void
-_cairo_cogl_path_fill_meta_set_prim_size (cairo_cogl_surface_t *surface,
- cairo_cogl_path_fill_meta_t *meta,
- size_t size)
+_cairo_cogl_path_fill_meta_set_prim (cairo_cogl_path_fill_meta_t *meta,
+ cairo_cogl_surface_t *surface,
+ CoglPrimitive *prim,
+ size_t size)
{
+ meta->prim = cogl_object_ref (prim);
+ meta->ctm_inverse = *surface->ctm_inverse;
+
/* now that we know the meta structure is associated with a primitive
* we promote it from the staging cache into the primitive cache.
*/
@@ -2978,7 +3026,6 @@ _cairo_cogl_get_path_fill_meta (cairo_cogl_surface_t *surface)
if (unlikely (status))
goto BAIL;
meta->user_path = meta_path;
- meta->ctm_inverse = *surface->ctm_inverse;
/* To start with - until we associate a CoglPrimitive with the meta
* structure - we keep the meta in a staging structure until we
@@ -3053,15 +3100,17 @@ _cairo_cogl_surface_fill (void *abstract_surface,
#ifndef FILL_WITH_COGL_PATH
#ifdef ENABLE_PATH_CACHE
- if (side_band_state_valid)
+ if (side_band_state_valid) {
meta = _cairo_cogl_get_path_fill_meta (surface);
- if (meta) {
- prim = meta->prim;
- if (prim) {
- cairo_matrix_multiply (&transform_matrix, &meta->ctm_inverse, surface->ctm);
- transform = &transform_matrix;
- } else if (meta->counter++ > 10)
- one_shot = FALSE;
+ if (meta) {
+ prim = meta->prim;
+ if (prim) {
+ cairo_matrix_multiply (&transform_matrix,
+ &meta->ctm_inverse, surface->ctm);
+ transform = &transform_matrix;
+ } else if (meta->counter++ > 10)
+ one_shot = FALSE;
+ }
}
#endif /* ENABLE_PATH_CACHE */
@@ -3075,10 +3124,8 @@ _cairo_cogl_surface_fill (void *abstract_surface,
return status;
new_prim = TRUE;
#ifdef ENABLE_PATH_CACHE
- if (meta && !one_shot) {
- meta->prim = cogl_object_ref (prim);
- _cairo_cogl_path_fill_meta_set_prim_size (surface, meta, prim_size);
- }
+ if (meta && !one_shot)
+ _cairo_cogl_path_fill_meta_set_prim (meta, surface, prim, prim_size);
#endif /* ENABLE_PATH_CACHE */
}
@@ -3110,7 +3157,8 @@ _cairo_cogl_surface_fill (void *abstract_surface,
if (new_prim)
cogl_object_unref (prim);
#else
- CoglPath * cogl_path = _cairo_cogl_util_path_from_cairo (path, fill_rule, tolerance);
+ CoglPath * cogl_path = _cairo_cogl_util_path_from_cairo (surface->device->cogl_context,
+ path, fill_rule, tolerance);
_cairo_cogl_journal_log_path (surface, pipeline, cogl_path);
cogl_object_unref (cogl_path);
#endif
@@ -3444,9 +3492,13 @@ static void
_cairo_cogl_device_destroy (void *device)
{
cairo_cogl_device_t *dev = device;
+ int i;
/* FIXME: Free stuff! */
+ for (i = 0; i < 3; i++)
+ cogl_object_unref (dev->layer_transform_snippet[i]);
+
g_free (dev);
}
@@ -3464,10 +3516,10 @@ static const cairo_device_backend_t _cairo_cogl_device_backend = {
static cairo_bool_t
set_blend (CoglPipeline *pipeline, const char *blend_string)
{
- GError *error = NULL;
+ CoglError *error = NULL;
if (!cogl_pipeline_set_blend (pipeline, blend_string, &error)) {
g_warning ("Unsupported blend string with current gpu/driver: %s", blend_string);
- g_error_free (error);
+ cogl_error_free (error);
return FALSE;
}
return TRUE;
@@ -3506,7 +3558,7 @@ _cairo_cogl_setup_op_state (CoglPipeline *pipeline, cairo_operator_t op)
static void
create_templates_for_op (cairo_cogl_device_t *dev, cairo_operator_t op)
{
- CoglPipeline *base = cogl_pipeline_new ();
+ CoglPipeline *base = cogl_pipeline_new (dev->cogl_context);
CoglPipeline *pipeline;
CoglColor color;
@@ -3542,16 +3594,22 @@ cairo_cogl_device_create (CoglContext *cogl_context)
{
cairo_cogl_device_t *dev = g_new0 (cairo_cogl_device_t, 1);
cairo_status_t status;
+ CoglError *error = NULL;
+ int i;
dev->backend_vtable_initialized = FALSE;
dev->cogl_context = cogl_context;
- dev->dummy_texture = cogl_texture_new_with_size (1, 1,
+ dev->dummy_texture = cogl_texture_new_with_size (dev->cogl_context,
+ 1, 1,
COGL_TEXTURE_NO_SLICING,
- COGL_PIXEL_FORMAT_ANY);
- if (!dev->dummy_texture)
+ COGL_PIXEL_FORMAT_ANY,
+ &error);
+ if (!dev->dummy_texture){
+ cogl_error_free (error);
goto ERROR;
+ }
memset (dev->template_pipelines, 0, sizeof (dev->template_pipelines));
create_templates_for_op (dev, CAIRO_OPERATOR_SOURCE);
@@ -3593,6 +3651,17 @@ cairo_cogl_device_create (CoglContext *cogl_context)
(cairo_destroy_func_t) _cairo_cogl_path_stroke_meta_destroy,
CAIRO_COGL_PATH_META_CACHE_SIZE);
+ for (i = 0; i < 3; i++) {
+ char *uniform = g_strdup_printf ("layer%d_transform", i);
+ char *code = g_strdup_printf ("cogl_tex_coord = cogl_tex_coord * layer%d_transform;\n", i);
+ dev->layer_transform_snippet[i] =
+ cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM,
+ uniform,
+ code);
+ g_free (uniform);
+ g_free (code);
+ }
+
_cairo_device_init (&dev->base, &_cairo_cogl_device_backend);
return &dev->base;
diff --git a/src/cairo-cogl-utils-private.h b/src/cairo-cogl-utils-private.h
index ee77f303..1bfb7ee1 100644
--- a/src/cairo-cogl-utils-private.h
+++ b/src/cairo-cogl-utils-private.h
@@ -33,10 +33,11 @@
#define CAIRO_COGL_UTILS_PRIVATE_H
#include "cairo-path-fixed-private.h"
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
CoglPath *
-_cairo_cogl_util_path_from_cairo (const cairo_path_fixed_t *path,
+_cairo_cogl_util_path_from_cairo (CoglContext *ctx,
+ const cairo_path_fixed_t *path,
cairo_fill_rule_t fill_rule,
float tolerance);
diff --git a/src/cairo-cogl-utils.c b/src/cairo-cogl-utils.c
index 4f02aaa5..e401710e 100644
--- a/src/cairo-cogl-utils.c
+++ b/src/cairo-cogl-utils.c
@@ -79,11 +79,12 @@ _cogl_close_path (void *closure)
}
CoglPath *
-_cairo_cogl_util_path_from_cairo (const cairo_path_fixed_t *path,
+_cairo_cogl_util_path_from_cairo (CoglContext *ctx,
+ const cairo_path_fixed_t *path,
cairo_fill_rule_t fill_rule,
float tolerance)
{
- CoglPath *cogl_path = cogl_path_new ();
+ CoglPath *cogl_path = cogl_path_new (ctx);
cairo_status_t status;
if (fill_rule == CAIRO_FILL_RULE_EVEN_ODD)
diff --git a/src/cairo-cogl.h b/src/cairo-cogl.h
index f270d74d..708a619b 100644
--- a/src/cairo-cogl.h
+++ b/src/cairo-cogl.h
@@ -40,7 +40,7 @@
#if CAIRO_HAS_COGL_SURFACE
-#include <cogl/cogl2-experimental.h>
+#include <cogl/cogl.h>
CAIRO_BEGIN_DECLS
diff --git a/src/cairo-composite-rectangles-private.h b/src/cairo-composite-rectangles-private.h
index fd772899..f9b00981 100644
--- a/src/cairo-composite-rectangles-private.h
+++ b/src/cairo-composite-rectangles-private.h
@@ -75,6 +75,13 @@ struct _cairo_composite_rectangles {
cairo_clip_t *clip; /* clip will be reduced to the minimal container */
};
+cairo_private cairo_bool_t
+_cairo_composite_rectangles_init (cairo_composite_rectangles_t *extents,
+ cairo_surface_t *surface,
+ cairo_operator_t op,
+ const cairo_pattern_t *source,
+ const cairo_clip_t *clip);
+
cairo_private cairo_int_status_t
_cairo_composite_rectangles_init_for_paint (cairo_composite_rectangles_t *extents,
cairo_surface_t *surface,
@@ -143,6 +150,10 @@ cairo_private cairo_int_status_t
_cairo_composite_rectangles_intersect_mask_extents (cairo_composite_rectangles_t *extents,
const cairo_box_t *box);
+cairo_private cairo_int_status_t
+_cairo_composite_rectangles_intersect (cairo_composite_rectangles_t *extents,
+ const cairo_clip_t *clip);
+
cairo_private cairo_bool_t
_cairo_composite_rectangles_can_reduce_clip (cairo_composite_rectangles_t *composite,
cairo_clip_t *clip);
diff --git a/src/cairo-composite-rectangles.c b/src/cairo-composite-rectangles.c
index 7fc0f5fe..e73fab1a 100644
--- a/src/cairo-composite-rectangles.c
+++ b/src/cairo-composite-rectangles.c
@@ -68,7 +68,7 @@ _cairo_composite_reduce_pattern (const cairo_pattern_t *src,
}
}
-static inline cairo_bool_t
+cairo_bool_t
_cairo_composite_rectangles_init (cairo_composite_rectangles_t *extents,
cairo_surface_t *surface,
cairo_operator_t op,
@@ -136,7 +136,7 @@ _cairo_composite_rectangles_init_for_paint (cairo_composite_rectangles_t *extent
return CAIRO_STATUS_SUCCESS;
}
-static cairo_int_status_t
+cairo_int_status_t
_cairo_composite_rectangles_intersect (cairo_composite_rectangles_t *extents,
const cairo_clip_t *clip)
{