[Cogl] [PATCH 2/2] Remove lots of legacy api depending on the default context

Robert Bragg robert at sixbynine.org
Mon May 14 16:23:10 PDT 2012


From: Robert Bragg <robert at linux.intel.com>

This removes lots of old cogl api that depends on having a global
context and that also expose an overly stateful api that makes it
harder to write orthogonal components that can be re-used together.
---
 cogl/cogl-blit.c                       |   31 +-
 cogl/cogl-blit.h                       |    5 +
 cogl/cogl-clip-state.c                 |   90 ----
 cogl/cogl-context-private.h            |    1 -
 cogl/cogl-context.c                    |    3 -
 cogl/cogl-debug.c                      |   65 ---
 cogl/cogl-primitives.c                 |  359 --------------
 cogl/cogl-texture.c                    |   66 ++--
 cogl/cogl.c                            |  454 -----------------
 cogl/cogl1-context.h                   |  839 --------------------------------
 doc/reference/cogl2/cogl2-sections.txt |   47 --
 examples/cogl-crate.c                  |   13 +-
 examples/cogl-x11-tfp.c                |    7 +-
 examples/cogland.c                     |   25 +-
 tests/conform/test-custom-attributes.c |    2 +-
 tests/conform/test-depth-test.c        |   54 +--
 tests/conform/test-pipeline-uniforms.c |    2 +-
 tests/conform/test-snippets.c          |    2 +-
 18 files changed, 93 insertions(+), 1972 deletions(-)

diff --git a/cogl/cogl-blit.c b/cogl/cogl-blit.c
index 8eaf8a5..1562990 100644
--- a/cogl/cogl-blit.c
+++ b/cogl/cogl-blit.c
@@ -63,8 +63,7 @@ _cogl_blit_texture_render_begin (CoglBlitData *data)
       return FALSE;
     }
 
-  cogl_push_framebuffer (fb);
-  cogl_object_unref (fb);
+  data->fb = fb;
 
   dst_width = cogl_texture_get_width (data->dst_tex);
   dst_height = cogl_texture_get_height (data->dst_tex);
@@ -97,7 +96,7 @@ _cogl_blit_texture_render_begin (CoglBlitData *data)
 
   cogl_pipeline_set_layer_texture (pipeline, 0, data->src_tex);
 
-  cogl_push_source (pipeline);
+  data->pipeline = pipeline;
 
   return TRUE;
 }
@@ -111,15 +110,17 @@ _cogl_blit_texture_render_blit (CoglBlitData *data,
                                 unsigned int width,
                                 unsigned int height)
 {
-  cogl_rectangle_with_texture_coords (dst_x, dst_y,
-                                      dst_x + width,
-                                      dst_y + height,
-                                      src_x / (float) data->src_width,
-                                      src_y / (float) data->src_height,
-                                      (src_x + width) /
-                                      (float) data->src_width,
-                                      (src_y + height) /
-                                      (float) data->src_height);
+  cogl_framebuffer_draw_textured_rectangle (data->fb,
+                                            data->pipeline,
+                                            dst_x, dst_y,
+                                            dst_x + width,
+                                            dst_y + height,
+                                            src_x / (float) data->src_width,
+                                            src_y / (float) data->src_height,
+                                            (src_x + width) /
+                                            (float) data->src_width,
+                                            (src_y + height) /
+                                            (float) data->src_height);
 }
 
 static void
@@ -127,9 +128,6 @@ _cogl_blit_texture_render_end (CoglBlitData *data)
 {
   _COGL_GET_CONTEXT (ctx, NO_RETVAL);
 
-  cogl_pop_source ();
-  cogl_pop_framebuffer ();
-
   /* Attach the target texture to the texture render pipeline so that
      we don't keep a reference to the source texture forever. This is
      assuming that the destination texture will live for a long time
@@ -420,5 +418,8 @@ _cogl_blit (CoglBlitData *data,
 void
 _cogl_blit_end (CoglBlitData *data)
 {
+  cogl_object_unref (data->fb);
+  cogl_object_unref (data->pipeline);
+
   data->blit_mode->end_func (data);
 }
diff --git a/cogl/cogl-blit.h b/cogl/cogl-blit.h
index d56137a..364e9b1 100644
--- a/cogl/cogl-blit.h
+++ b/cogl/cogl-blit.h
@@ -27,6 +27,7 @@
 #include <glib.h>
 #include "cogl-object-private.h"
 #include "cogl-texture.h"
+#include "cogl-framebuffer.h"
 
 /* This structures and functions are used when a series of blits needs
    to be performed between two textures. In this case there are
@@ -67,7 +68,11 @@ struct _CoglBlitData
      complete texture data in */
   unsigned char *image_data;
   CoglPixelFormat format;
+
   int bpp;
+
+  CoglFramebuffer *fb;
+  CoglPipeline *pipeline;
 };
 
 void
diff --git a/cogl/cogl-clip-state.c b/cogl/cogl-clip-state.c
index 0ab9c5f..8325e96 100644
--- a/cogl/cogl-clip-state.c
+++ b/cogl/cogl-clip-state.c
@@ -42,98 +42,8 @@
 #include "cogl1-context.h"
 
 void
-cogl_clip_push_window_rectangle (int x_offset,
-                                 int y_offset,
-                                 int width,
-                                 int height)
-{
-  cogl_framebuffer_push_scissor_clip (cogl_get_draw_framebuffer (),
-                                      x_offset, y_offset, width, height);
-}
-
-/* XXX: This is deprecated API */
-void
-cogl_clip_push_window_rect (float x_offset,
-                            float y_offset,
-                            float width,
-                            float height)
-{
-  cogl_clip_push_window_rectangle (x_offset, y_offset, width, height);
-}
-
-void
-cogl_clip_push_rectangle (float x_1,
-                          float y_1,
-                          float x_2,
-                          float y_2)
-{
-  cogl_framebuffer_push_rectangle_clip (cogl_get_draw_framebuffer (),
-                                        x_1, y_1, x_2, y_2);
-}
-
-/* XXX: Deprecated API */
-void
-cogl_clip_push (float x_offset,
-                float y_offset,
-                float width,
-                float height)
-{
-  cogl_clip_push_rectangle (x_offset,
-                            y_offset,
-                            x_offset + width,
-                            y_offset + height);
-}
-
-void
-cogl_clip_push_primitive (CoglPrimitive *primitive,
-                          float bounds_x1,
-                          float bounds_y1,
-                          float bounds_x2,
-                          float bounds_y2)
-{
-  cogl_framebuffer_push_primitive_clip (cogl_get_draw_framebuffer (),
-                                        primitive,
-                                        bounds_x1,
-                                        bounds_y1,
-                                        bounds_x2,
-                                        bounds_y2);
-}
-
-void
-cogl_clip_pop (void)
-{
-  cogl_framebuffer_pop_clip (cogl_get_draw_framebuffer ());
-}
-
-void
-cogl_clip_stack_save (void)
-{
-  _cogl_framebuffer_save_clip_stack (cogl_get_draw_framebuffer ());
-}
-
-void
-cogl_clip_stack_restore (void)
-{
-  _cogl_framebuffer_restore_clip_stack (cogl_get_draw_framebuffer ());
-}
-
-/* XXX: This should never have been made public API! */
-void
-cogl_clip_ensure (void)
-{
-  /* Do nothing.
-   *
-   * This API shouldn't be used by anyone and the documented semantics
-   * are basically vague enough that we can get away with doing
-   * nothing here.
-   */
-}
-
-void
 _cogl_clip_state_init (CoglClipState *clip_state)
 {
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   clip_state->stacks = NULL;
 
   /* Add an intial stack */
diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h
index cb5057e..bc0e8ec 100644
--- a/cogl/cogl-context-private.h
+++ b/cogl/cogl-context-private.h
@@ -130,7 +130,6 @@ struct _CoglContext
   CoglPipeline     *texture_pipeline; /* used for set_source_texture */
   GString          *codegen_header_buffer;
   GString          *codegen_source_buffer;
-  GList            *source_stack;
 
   CoglPipelineCache *pipeline_cache;
 
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 8806174..25dba6e 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -291,7 +291,6 @@ cogl_context_new (CoglDisplay *display,
   context->texture_pipeline = cogl_pipeline_new (context);
   context->codegen_header_buffer = g_string_new ("");
   context->codegen_source_buffer = g_string_new ("");
-  context->source_stack = NULL;
 
   context->default_gl_texture_2d_tex = NULL;
   context->default_gl_texture_3d_tex = NULL;
@@ -420,8 +419,6 @@ cogl_context_new (CoglDisplay *display,
 
   cogl_object_unref (default_texture_bitmap);
 
-  cogl_push_source (context->opaque_color_pipeline);
-
   context->atlases = NULL;
   g_hook_list_init (&context->atlas_reorganize_callbacks, sizeof (GHook));
 
diff --git a/cogl/cogl-debug.c b/cogl/cogl-debug.c
index 9836133..5161b4c 100644
--- a/cogl/cogl-debug.c
+++ b/cogl/cogl-debug.c
@@ -197,40 +197,6 @@ _cogl_parse_debug_string (const char *value,
     }
 }
 
-#ifdef COGL_ENABLE_DEBUG
-static CoglBool
-cogl_arg_debug_cb (const char *key,
-                   const char *value,
-                   void *user_data)
-{
-  _cogl_parse_debug_string (value,
-                            TRUE /* enable the flags */,
-                            FALSE /* don't ignore help */);
-  return TRUE;
-}
-
-static CoglBool
-cogl_arg_no_debug_cb (const char *key,
-                      const char *value,
-                      void *user_data)
-{
-  _cogl_parse_debug_string (value,
-                            FALSE, /* disable the flags */
-                            TRUE /* ignore help */);
-  return TRUE;
-}
-#endif /* COGL_ENABLE_DEBUG */
-
-static GOptionEntry cogl_args[] = {
-#ifdef COGL_ENABLE_DEBUG
-  { "cogl-debug", 0, 0, G_OPTION_ARG_CALLBACK, cogl_arg_debug_cb,
-    N_("Cogl debugging flags to set"), "FLAGS" },
-  { "cogl-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, cogl_arg_no_debug_cb,
-    N_("Cogl debugging flags to unset"), "FLAGS" },
-#endif /* COGL_ENABLE_DEBUG */
-  { NULL, },
-};
-
 void
 _cogl_debug_check_environment (void)
 {
@@ -254,34 +220,3 @@ _cogl_debug_check_environment (void)
       env_string = NULL;
     }
 }
-
-static CoglBool
-pre_parse_hook (GOptionContext *context,
-                GOptionGroup *group,
-                void *data,
-                GError **error)
-{
-  _cogl_init ();
-
-  return TRUE;
-}
-
-/* XXX: GOption based library initialization is not reliable because the
- * GOption API has no way to represent dependencies between libraries.
- */
-GOptionGroup *
-cogl_get_option_group (void)
-{
-  GOptionGroup *group;
-
-  group = g_option_group_new ("cogl",
-                              _("Cogl Options"),
-                              _("Show Cogl options"),
-                              NULL, NULL);
-
-  g_option_group_set_parse_hooks (group, pre_parse_hook, NULL);
-  g_option_group_add_entries (group, cogl_args);
-  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
-
-  return group;
-}
diff --git a/cogl/cogl-primitives.c b/cogl/cogl-primitives.c
index 85c0ea3..ef48d2f 100644
--- a/cogl/cogl-primitives.c
+++ b/cogl/cogl-primitives.c
@@ -708,135 +708,6 @@ _cogl_framebuffer_draw_multitextured_rectangles (
     cogl_object_unref (pipeline);
 }
 
-static void
-_cogl_rectangles_with_multitexture_coords (
-                                        CoglMultiTexturedRect *rects,
-                                        int n_rects)
-{
-  _cogl_framebuffer_draw_multitextured_rectangles (cogl_get_draw_framebuffer (),
-                                                   cogl_get_source (),
-                                                   rects,
-                                                   n_rects);
-}
-
-void
-cogl_rectangles (const float *verts,
-                 unsigned int n_rects)
-{
-  CoglMultiTexturedRect *rects;
-  int i;
-
-  /* XXX: All the cogl_rectangle* APIs normalize their input into an array of
-   * CoglMultiTexturedRect rectangles and pass these on to our work horse;
-   * _cogl_rectangles_with_multitexture_coords.
-   */
-
-  rects = g_alloca (n_rects * sizeof (CoglMultiTexturedRect));
-
-  for (i = 0; i < n_rects; i++)
-    {
-      rects[i].position = &verts[i * 4];
-      rects[i].tex_coords = NULL;
-      rects[i].tex_coords_len = 0;
-    }
-
-  _cogl_rectangles_with_multitexture_coords (rects, n_rects);
-}
-
-void
-cogl_rectangles_with_texture_coords (const float *verts,
-                                     unsigned int n_rects)
-{
-  CoglMultiTexturedRect *rects;
-  int i;
-
-  /* XXX: All the cogl_rectangle* APIs normalize their input into an array of
-   * CoglMultiTexturedRect rectangles and pass these on to our work horse;
-   * _cogl_rectangles_with_multitexture_coords.
-   */
-
-  rects = g_alloca (n_rects * sizeof (CoglMultiTexturedRect));
-
-  for (i = 0; i < n_rects; i++)
-    {
-      rects[i].position = &verts[i * 8];
-      rects[i].tex_coords = &verts[i * 8 + 4];
-      rects[i].tex_coords_len = 4;
-    }
-
-  _cogl_rectangles_with_multitexture_coords (rects, n_rects);
-}
-
-void
-cogl_rectangle_with_texture_coords (float x_1,
-			            float y_1,
-			            float x_2,
-			            float y_2,
-			            float tx_1,
-			            float ty_1,
-			            float tx_2,
-			            float ty_2)
-{
-  const float position[4] = {x_1, y_1, x_2, y_2};
-  const float tex_coords[4] = {tx_1, ty_1, tx_2, ty_2};
-  CoglMultiTexturedRect rect;
-
-  /* XXX: All the cogl_rectangle* APIs normalize their input into an array of
-   * CoglMultiTexturedRect rectangles and pass these on to our work horse;
-   * _cogl_rectangles_with_multitexture_coords.
-   */
-
-  rect.position = position;
-  rect.tex_coords = tex_coords;
-  rect.tex_coords_len = 4;
-
-  _cogl_rectangles_with_multitexture_coords (&rect, 1);
-}
-
-void
-cogl_rectangle_with_multitexture_coords (float        x_1,
-			                 float        y_1,
-			                 float        x_2,
-			                 float        y_2,
-			                 const float *user_tex_coords,
-                                         int          user_tex_coords_len)
-{
-  const float position[4] = {x_1, y_1, x_2, y_2};
-  CoglMultiTexturedRect rect;
-
-  /* XXX: All the cogl_rectangle* APIs normalize their input into an array of
-   * CoglMultiTexturedRect rectangles and pass these on to our work horse;
-   * _cogl_rectangles_with_multitexture_coords.
-   */
-
-  rect.position = position;
-  rect.tex_coords = user_tex_coords;
-  rect.tex_coords_len = user_tex_coords_len;
-
-  _cogl_rectangles_with_multitexture_coords (&rect, 1);
-}
-
-void
-cogl_rectangle (float x_1,
-                float y_1,
-                float x_2,
-                float y_2)
-{
-  const float position[4] = {x_1, y_1, x_2, y_2};
-  CoglMultiTexturedRect rect;
-
-  /* XXX: All the cogl_rectangle* APIs normalize their input into an array of
-   * CoglMultiTexturedRect rectangles and pass these on to our work horse;
-   * _cogl_rectangles_with_multitexture_coords.
-   */
-
-  rect.position = position;
-  rect.tex_coords = NULL;
-  rect.tex_coords_len = 0;
-
-  _cogl_rectangles_with_multitexture_coords (&rect, 1);
-}
-
 void
 _cogl_rectangle_immediate (CoglFramebuffer *framebuffer,
                            CoglPipeline *pipeline,
@@ -884,233 +755,3 @@ _cogl_rectangle_immediate (CoglFramebuffer *framebuffer,
   cogl_object_unref (attributes[0]);
   cogl_object_unref (attribute_buffer);
 }
-
-typedef struct _AppendTexCoordsState
-{
-  const CoglTextureVertex *vertices_in;
-  int vertex;
-  int layer;
-  float *vertices_out;
-} AppendTexCoordsState;
-
-static CoglBool
-append_tex_coord_attributes_cb (CoglPipeline *pipeline,
-                                int layer_index,
-                                void *user_data)
-{
-  AppendTexCoordsState *state = user_data;
-  CoglTexture *texture;
-  float tx, ty;
-  float *t;
-
-  tx = state->vertices_in[state->vertex].tx;
-  ty = state->vertices_in[state->vertex].ty;
-
-  /* NULL textures will be handled in
-   * _cogl_pipeline_flush_layers_gl_state but there is no need to worry
-   * about scaling texture coordinates in this case */
-  texture = cogl_pipeline_get_layer_texture (pipeline, layer_index);
-  if (texture != NULL)
-    _cogl_texture_transform_coords_to_gl (texture, &tx, &ty);
-
-  /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
-  t = state->vertices_out + 3 + 2 * state->layer;
-  t[0] = tx;
-  t[1] = ty;
-
-  state->layer++;
-
-  return TRUE;
-}
-
-typedef struct _ValidateState
-{
-  CoglPipeline *original_pipeline;
-  CoglPipeline *pipeline;
-} ValidateState;
-
-static CoglBool
-_cogl_polygon_validate_layer_cb (CoglPipeline *pipeline,
-                                 int layer_index,
-                                 void *user_data)
-{
-  ValidateState *state = user_data;
-
-  /* By default COGL_PIPELINE_WRAP_MODE_AUTOMATIC becomes
-   * GL_CLAMP_TO_EDGE but we want the polygon API to use GL_REPEAT to
-   * maintain compatibility with previous releases
-   */
-
-  if (cogl_pipeline_get_layer_wrap_mode_s (pipeline, layer_index) ==
-      COGL_PIPELINE_WRAP_MODE_AUTOMATIC)
-    {
-      if (state->original_pipeline == state->pipeline)
-        state->pipeline = cogl_pipeline_copy (pipeline);
-
-      cogl_pipeline_set_layer_wrap_mode_s (state->pipeline, layer_index,
-                                           COGL_PIPELINE_WRAP_MODE_REPEAT);
-    }
-
-  if (cogl_pipeline_get_layer_wrap_mode_t (pipeline, layer_index) ==
-      COGL_PIPELINE_WRAP_MODE_AUTOMATIC)
-    {
-      if (state->original_pipeline == state->pipeline)
-        state->pipeline = cogl_pipeline_copy (pipeline);
-
-      cogl_pipeline_set_layer_wrap_mode_t (state->pipeline, layer_index,
-                                           COGL_PIPELINE_WRAP_MODE_REPEAT);
-    }
-
-  return TRUE;
-}
-
-void
-cogl_polygon (const CoglTextureVertex *vertices,
-              unsigned int n_vertices,
-	      CoglBool use_color)
-{
-  CoglPipeline *pipeline;
-  ValidateState validate_state;
-  int n_layers;
-  int n_attributes;
-  CoglAttribute **attributes;
-  int i;
-  unsigned int stride;
-  size_t stride_bytes;
-  CoglAttributeBuffer *attribute_buffer;
-  float *v;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  pipeline = cogl_get_source ();
-
-  validate_state.original_pipeline = pipeline;
-  validate_state.pipeline = pipeline;
-  cogl_pipeline_foreach_layer (pipeline,
-                               _cogl_polygon_validate_layer_cb,
-                               &validate_state);
-  pipeline = validate_state.pipeline;
-
-  n_layers = cogl_pipeline_get_n_layers (pipeline);
-
-  n_attributes = 1 + n_layers + (use_color ? 1 : 0);
-  attributes = g_alloca (sizeof (CoglAttribute *) * n_attributes);
-
-  /* Our data is arranged like:
-   * [X, Y, Z, TX0, TY0, TX1, TY1..., R, G, B, A,...] */
-  stride = 3 + (2 * n_layers) + (use_color ? 1 : 0);
-  stride_bytes = stride * sizeof (float);
-
-  /* Make sure there is enough space in the global vertex array. This
-   * is used so we can render the polygon with a single call to OpenGL
-   * but still support any number of vertices */
-  g_array_set_size (ctx->polygon_vertices, n_vertices * stride);
-
-  attribute_buffer =
-    cogl_attribute_buffer_new (ctx, n_vertices * stride_bytes, NULL);
-
-  attributes[0] = cogl_attribute_new (attribute_buffer,
-                                      "cogl_position_in",
-                                      stride_bytes,
-                                      0,
-                                      3,
-                                      COGL_ATTRIBUTE_TYPE_FLOAT);
-
-  for (i = 0; i < n_layers; i++)
-    {
-      static const char *names[] = {
-          "cogl_tex_coord0_in",
-          "cogl_tex_coord1_in",
-          "cogl_tex_coord2_in",
-          "cogl_tex_coord3_in",
-          "cogl_tex_coord4_in",
-          "cogl_tex_coord5_in",
-          "cogl_tex_coord6_in",
-          "cogl_tex_coord7_in"
-      };
-      char *allocated_name = NULL;
-      const char *name;
-
-      if (i < 8)
-        name = names[i];
-      else
-        name = allocated_name = g_strdup_printf ("cogl_tex_coord%d_in", i);
-
-      attributes[i + 1] = cogl_attribute_new (attribute_buffer,
-                                              name,
-                                              stride_bytes,
-                                              /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
-                                              12 + 8 * i,
-                                              2,
-                                              COGL_ATTRIBUTE_TYPE_FLOAT);
-
-      g_free (allocated_name);
-    }
-
-  if (use_color)
-    {
-      attributes[n_attributes - 1] =
-        cogl_attribute_new (attribute_buffer,
-                            "cogl_color_in",
-                            stride_bytes,
-                            /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
-                            12 + 8 * n_layers,
-                            4,
-                            COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
-    }
-
-  /* Convert the vertices into an array of float vertex attributes */
-  v = (float *)ctx->polygon_vertices->data;
-  for (i = 0; i < n_vertices; i++)
-    {
-      AppendTexCoordsState append_tex_coords_state;
-      uint8_t *c;
-
-      /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
-      v[0] = vertices[i].x;
-      v[1] = vertices[i].y;
-      v[2] = vertices[i].z;
-
-      append_tex_coords_state.vertices_in = vertices;
-      append_tex_coords_state.vertex = i;
-      append_tex_coords_state.layer = 0;
-      append_tex_coords_state.vertices_out = v;
-      cogl_pipeline_foreach_layer (pipeline,
-                                   append_tex_coord_attributes_cb,
-                                   &append_tex_coords_state);
-
-      if (use_color)
-        {
-          /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
-          c = (uint8_t *) (v + 3 + 2 * n_layers);
-          c[0] = cogl_color_get_red_byte (&vertices[i].color);
-          c[1] = cogl_color_get_green_byte (&vertices[i].color);
-          c[2] = cogl_color_get_blue_byte (&vertices[i].color);
-          c[3] = cogl_color_get_alpha_byte (&vertices[i].color);
-        }
-
-      v += stride;
-    }
-
-  v = (float *)ctx->polygon_vertices->data;
-  cogl_buffer_set_data (COGL_BUFFER (attribute_buffer),
-                        0,
-                        v,
-                        ctx->polygon_vertices->len * sizeof (float));
-
-  _cogl_framebuffer_draw_attributes (cogl_get_draw_framebuffer (),
-                                     pipeline,
-                                     COGL_VERTICES_MODE_TRIANGLE_FAN,
-                                     0, n_vertices,
-                                     attributes,
-                                     n_attributes,
-                                     0 /* no draw flags */);
-
-  if (pipeline != validate_state.original_pipeline)
-    cogl_object_unref (pipeline);
-
-  cogl_object_unref (attribute_buffer);
-
-  for (i = 0; i < n_attributes; i++)
-    cogl_object_unref (attributes[i]);
-}
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index e78ba92..d01072e 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -767,19 +767,20 @@ cogl_texture_set_region (CoglTexture *texture,
  * glGetTexImage, but may be used as a fallback in some circumstances.
  */
 static void
-do_texture_draw_and_read (CoglTexture *texture,
-                          CoglBitmap  *target_bmp,
-                          float       *viewport)
+do_texture_draw_and_read (CoglFramebuffer *fb,
+                          CoglPipeline *pipeline,
+                          CoglTexture *texture,
+                          CoglBitmap *target_bmp,
+                          float *viewport)
 {
-  float       rx1, ry1;
-  float       rx2, ry2;
-  float       tx1, ty1;
-  float       tx2, ty2;
-  int         bw,  bh;
-  CoglBitmap  *rect_bmp;
-  unsigned int  tex_width, tex_height;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  float rx1, ry1;
+  float rx2, ry2;
+  float tx1, ty1;
+  float tx2, ty2;
+  int bw,  bh;
+  CoglBitmap *rect_bmp;
+  unsigned int tex_width, tex_height;
+  CoglContext *ctx = fb->context;
 
   tex_width = cogl_texture_get_width (texture);
   tex_height = cogl_texture_get_height (texture);
@@ -819,11 +820,13 @@ do_texture_draw_and_read (CoglTexture *texture,
           tx2 = (rx2 / (float) tex_width);
 
           /* Draw a portion of texture */
-          cogl_rectangle_with_texture_coords (0, 0,
-                                              rx2 - rx1,
-                                              ry2 - ry1,
-                                              tx1, ty1,
-                                              tx2, ty2);
+          cogl_framebuffer_draw_textured_rectangle (fb,
+                                                    pipeline,
+                                                    0, 0,
+                                                    rx2 - rx1,
+                                                    ry2 - ry1,
+                                                    tx1, ty1,
+                                                    tx2, ty2);
 
           /* Read into a temporary bitmap */
           rect_bmp = _cogl_bitmap_new_with_malloc_buffer
@@ -832,7 +835,7 @@ do_texture_draw_and_read (CoglTexture *texture,
                                                COGL_PIXEL_FORMAT_RGBA_8888_PRE);
 
           cogl_framebuffer_read_pixels_into_bitmap
-                                   (cogl_get_draw_framebuffer (),
+                                   (fb,
                                     viewport[0], viewport[1],
                                     COGL_READ_PIXELS_COLOR_BUFFER,
                                     rect_bmp);
@@ -859,23 +862,21 @@ do_texture_draw_and_read (CoglTexture *texture,
  */
 CoglBool
 _cogl_texture_draw_and_read (CoglTexture *texture,
-                             CoglBitmap  *target_bmp,
-                             GLuint       target_gl_format,
-                             GLuint       target_gl_type)
+                             CoglBitmap *target_bmp,
+                             GLuint target_gl_format,
+                             GLuint target_gl_type)
 {
-  int        bpp;
-  CoglFramebuffer *framebuffer;
+  int bpp;
+  CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
   float viewport[4];
   CoglBitmap *alpha_bmp;
   int target_width = cogl_bitmap_get_width (target_bmp);
   int target_height = cogl_bitmap_get_height (target_bmp);
   int target_rowstride = cogl_bitmap_get_rowstride (target_bmp);
-
-  _COGL_GET_CONTEXT (ctx, FALSE);
+  CoglContext *ctx = framebuffer->context;
 
   bpp = _cogl_pixel_format_get_bytes_per_pixel (COGL_PIXEL_FORMAT_RGBA_8888);
 
-  framebuffer = cogl_get_draw_framebuffer ();
   /* Viewport needs to have some size and be inside the window for this */
   cogl_framebuffer_get_viewport4fv (framebuffer, viewport);
   if (viewport[0] <  0 || viewport[1] <  0 ||
@@ -906,8 +907,6 @@ _cogl_texture_draw_and_read (CoglTexture *texture,
                                NULL);
     }
 
-  cogl_push_source (ctx->texture_download_pipeline);
-
   cogl_pipeline_set_layer_texture (ctx->texture_download_pipeline, 0, texture);
 
   cogl_pipeline_set_layer_combine (ctx->texture_download_pipeline,
@@ -919,7 +918,9 @@ _cogl_texture_draw_and_read (CoglTexture *texture,
                                    COGL_PIPELINE_FILTER_NEAREST,
                                    COGL_PIPELINE_FILTER_NEAREST);
 
-  do_texture_draw_and_read (texture, target_bmp, viewport);
+  do_texture_draw_and_read (framebuffer,
+                            ctx->texture_download_pipeline,
+                            texture, target_bmp, viewport);
 
   /* Check whether texture has alpha and framebuffer not */
   /* FIXME: For some reason even if ALPHA_BITS is 8, the framebuffer
@@ -961,7 +962,9 @@ _cogl_texture_draw_and_read (CoglTexture *texture,
                                        "RGBA = REPLACE (TEXTURE[A])",
                                        NULL);
 
-      do_texture_draw_and_read (texture, alpha_bmp, viewport);
+      do_texture_draw_and_read (framebuffer,
+                                ctx->texture_download_pipeline,
+                                texture, alpha_bmp, viewport);
 
       /* Copy temp R to target A */
 
@@ -992,9 +995,6 @@ _cogl_texture_draw_and_read (CoglTexture *texture,
   cogl_framebuffer_pop_matrix (framebuffer);
   _cogl_framebuffer_pop_projection (framebuffer);
 
-  /* restore the original pipeline */
-  cogl_pop_source ();
-
   return TRUE;
 }
 
diff --git a/cogl/cogl.c b/cogl/cogl.c
index 49520d8..6dff1c1 100644
--- a/cogl/cogl.c
+++ b/cogl/cogl.c
@@ -89,14 +89,6 @@ _cogl_gl_error_to_string (GLenum error_code)
 }
 #endif /* COGL_GL_DEBUG */
 
-CoglFuncPtr
-cogl_get_proc_address (const char* name)
-{
-  _COGL_GET_CONTEXT (ctx, NULL);
-
-  return _cogl_renderer_get_proc_address (ctx->display->renderer, name);
-}
-
 CoglBool
 _cogl_check_extension (const char *name, const gchar *ext)
 {
@@ -122,88 +114,6 @@ _cogl_check_extension (const char *name, const gchar *ext)
   return FALSE;
 }
 
-/* XXX: This has been deprecated as public API */
-CoglBool
-cogl_check_extension (const char *name, const char *ext)
-{
-  return _cogl_check_extension (name, ext);
-}
-
-/* XXX: it's expected that we'll deprecated this with
- * cogl_framebuffer_clear at some point. */
-void
-cogl_clear (const CoglColor *color, unsigned long buffers)
-{
-  cogl_framebuffer_clear (cogl_get_draw_framebuffer (), buffers, color);
-}
-
-void
-cogl_set_source_color (const CoglColor *color)
-{
-  CoglPipeline *pipeline;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  if (cogl_color_get_alpha_byte (color) == 0xff)
-    {
-      cogl_pipeline_set_color (ctx->opaque_color_pipeline, color);
-      pipeline = ctx->opaque_color_pipeline;
-    }
-  else
-    {
-      CoglColor premultiplied = *color;
-      cogl_color_premultiply (&premultiplied);
-      cogl_pipeline_set_color (ctx->blended_color_pipeline, &premultiplied);
-      pipeline = ctx->blended_color_pipeline;
-    }
-
-  cogl_set_source (pipeline);
-}
-
-void
-cogl_set_viewport (int x,
-                   int y,
-                   int width,
-                   int height)
-{
-  CoglFramebuffer *framebuffer;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  framebuffer = cogl_get_draw_framebuffer ();
-
-  cogl_framebuffer_set_viewport (framebuffer,
-                                 x,
-                                 y,
-                                 width,
-                                 height);
-}
-
-/* XXX: This should be deprecated, and we should expose a way to also
- * specify an x and y viewport offset */
-void
-cogl_viewport (unsigned int width,
-	       unsigned int height)
-{
-  cogl_set_viewport (0, 0, width, height);
-}
-
-CoglFeatureFlags
-cogl_get_features (void)
-{
-  _COGL_GET_CONTEXT (ctx, 0);
-
-  return ctx->feature_flags;
-}
-
-CoglBool
-cogl_features_available (CoglFeatureFlags features)
-{
-  _COGL_GET_CONTEXT (ctx, 0);
-
-  return (ctx->feature_flags & features) == features;
-}
-
 CoglBool
 cogl_has_feature (CoglContext *ctx, CoglFeatureID feature)
 {
@@ -236,44 +146,6 @@ cogl_foreach_feature (CoglContext *ctx,
       callback (i, user_data);
 }
 
-/* XXX: This function should either be replaced with one returning
- * integers, or removed/deprecated and make the
- * _cogl_framebuffer_get_viewport* functions public.
- */
-void
-cogl_get_viewport (float viewport[4])
-{
-  CoglFramebuffer *framebuffer;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  framebuffer = cogl_get_draw_framebuffer ();
-  cogl_framebuffer_get_viewport4fv (framebuffer, viewport);
-}
-
-void
-cogl_get_bitmasks (int *red,
-                   int *green,
-                   int *blue,
-                   int *alpha)
-{
-  CoglFramebuffer *framebuffer;
-
-  framebuffer = cogl_get_draw_framebuffer ();
-
-  if (red)
-    *red = cogl_framebuffer_get_red_bits (framebuffer);
-
-  if (green)
-    *green = cogl_framebuffer_get_green_bits (framebuffer);
-
-  if (blue)
-    *blue = cogl_framebuffer_get_blue_bits (framebuffer);
-
-  if (alpha)
-    *alpha = cogl_framebuffer_get_alpha_bits (framebuffer);
-}
-
 void
 cogl_flush (void)
 {
@@ -285,338 +157,12 @@ cogl_flush (void)
     _cogl_framebuffer_flush_journal (l->data);
 }
 
-void
-cogl_read_pixels (int x,
-                  int y,
-                  int width,
-                  int height,
-                  CoglReadPixelsFlags source,
-                  CoglPixelFormat format,
-                  uint8_t *pixels)
-{
-  int bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
-  CoglBitmap *bitmap;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  bitmap = cogl_bitmap_new_for_data (ctx,
-                                     width, height,
-                                     format,
-                                     bpp * width, /* rowstride */
-                                     pixels);
-  cogl_framebuffer_read_pixels_into_bitmap (_cogl_get_read_framebuffer (),
-                                            x, y,
-                                            source,
-                                            bitmap);
-  cogl_object_unref (bitmap);
-}
-
-void
-cogl_begin_gl (void)
-{
-  CoglPipeline *pipeline;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  if (ctx->in_begin_gl_block)
-    {
-      static CoglBool shown = FALSE;
-      if (!shown)
-        g_warning ("You should not nest cogl_begin_gl/cogl_end_gl blocks");
-      shown = TRUE;
-      return;
-    }
-  ctx->in_begin_gl_block = TRUE;
-
-  /* Flush all batched primitives */
-  cogl_flush ();
-
-  /* Flush framebuffer state, including clip state, modelview and
-   * projection matrix state
-   *
-   * NB: _cogl_framebuffer_flush_state may disrupt various state (such
-   * as the pipeline state) when flushing the clip stack, so should
-   * always be done first when preparing to draw. */
-  _cogl_framebuffer_flush_state (cogl_get_draw_framebuffer (),
-                                 _cogl_get_read_framebuffer (),
-                                 COGL_FRAMEBUFFER_STATE_ALL);
-
-  /* Setup the state for the current pipeline */
-
-  /* We considered flushing a specific, minimal pipeline here to try and
-   * simplify the GL state, but decided to avoid special cases and second
-   * guessing what would be actually helpful.
-   *
-   * A user should instead call cogl_set_source_color4ub() before
-   * cogl_begin_gl() to simplify the state flushed.
-   *
-   * XXX: note defining n_tex_coord_attribs using
-   * cogl_pipeline_get_n_layers is a hack, but the problem is that
-   * n_tex_coord_attribs is usually defined when drawing a primitive
-   * which isn't happening here.
-   *
-   * Maybe it would be more useful if this code did flush the
-   * opaque_color_pipeline and then call into cogl-pipeline-opengl.c to then
-   * restore all state for the material's backend back to default OpenGL
-   * values.
-   */
-  pipeline = cogl_get_source ();
-  _cogl_pipeline_flush_gl_state (pipeline,
-                                 cogl_get_draw_framebuffer (),
-                                 FALSE,
-                                 cogl_pipeline_get_n_layers (pipeline));
-
-  /* Disable any cached vertex arrays */
-  _cogl_attribute_disable_cached_arrays ();
-}
-
-void
-cogl_end_gl (void)
-{
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  if (!ctx->in_begin_gl_block)
-    {
-      static CoglBool shown = FALSE;
-      if (!shown)
-        g_warning ("cogl_end_gl is being called before cogl_begin_gl");
-      shown = TRUE;
-      return;
-    }
-  ctx->in_begin_gl_block = FALSE;
-}
-
-void
-cogl_push_matrix (void)
-{
-  cogl_framebuffer_push_matrix (cogl_get_draw_framebuffer ());
-}
-
-void
-cogl_pop_matrix (void)
-{
-  cogl_framebuffer_pop_matrix (cogl_get_draw_framebuffer ());
-}
-
-void
-cogl_scale (float x, float y, float z)
-{
-  cogl_framebuffer_scale (cogl_get_draw_framebuffer (), x, y, z);
-}
-
-void
-cogl_translate (float x, float y, float z)
-{
-  cogl_framebuffer_translate (cogl_get_draw_framebuffer (), x, y, z);
-}
-
-void
-cogl_rotate (float angle, float x, float y, float z)
-{
-  cogl_framebuffer_rotate (cogl_get_draw_framebuffer (), angle, x, y, z);
-}
-
-void
-cogl_transform (const CoglMatrix *matrix)
-{
-  cogl_framebuffer_transform (cogl_get_draw_framebuffer (), matrix);
-}
-
-void
-cogl_perspective (float fov_y,
-		  float aspect,
-		  float z_near,
-		  float z_far)
-{
-  cogl_framebuffer_perspective (cogl_get_draw_framebuffer (),
-                                fov_y, aspect, z_near, z_far);
-}
-
-void
-cogl_frustum (float        left,
-	      float        right,
-	      float        bottom,
-	      float        top,
-	      float        z_near,
-	      float        z_far)
-{
-  cogl_framebuffer_frustum (cogl_get_draw_framebuffer (),
-                            left, right, bottom, top, z_near, z_far);
-}
-
-void
-cogl_ortho (float left,
-	    float right,
-	    float bottom,
-	    float top,
-	    float near,
-	    float far)
-{
-  cogl_framebuffer_orthographic (cogl_get_draw_framebuffer (),
-                                 left, top, right, bottom, near, far);
-}
-
-void
-cogl_get_modelview_matrix (CoglMatrix *matrix)
-{
-  cogl_framebuffer_get_modelview_matrix (cogl_get_draw_framebuffer (), matrix);
-}
-
-void
-cogl_set_modelview_matrix (CoglMatrix *matrix)
-{
-  cogl_framebuffer_set_modelview_matrix (cogl_get_draw_framebuffer (), matrix);
-}
-
-void
-cogl_get_projection_matrix (CoglMatrix *matrix)
-{
-  cogl_framebuffer_get_projection_matrix (cogl_get_draw_framebuffer (), matrix);
-}
-
-void
-cogl_set_projection_matrix (CoglMatrix *matrix)
-{
-  cogl_framebuffer_set_projection_matrix (cogl_get_draw_framebuffer (), matrix);
-}
-
 GQuark
 _cogl_driver_error_quark (void)
 {
   return g_quark_from_static_string ("cogl-driver-error-quark");
 }
 
-typedef struct _CoglSourceState
-{
-  CoglPipeline *pipeline;
-  int push_count;
-} CoglSourceState;
-
-/* FIXME: This should take a context pointer for Cogl 2.0 Technically
- * we could make it so we can retrieve a context reference from the
- * pipeline, but this would not by symmetric with cogl_pop_source. */
-void
-cogl_push_source (CoglPipeline *pipeline)
-{
-  CoglSourceState *top;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
-
-  if (ctx->source_stack &&
-      (top = ctx->source_stack->data)->pipeline == pipeline)
-    top->push_count++;
-  else
-    {
-      top = g_slice_new (CoglSourceState);
-      top->pipeline = cogl_object_ref (pipeline);
-      top->push_count = 1;
-
-      ctx->source_stack = g_list_prepend (ctx->source_stack, top);
-    }
-}
-
-/* FIXME: This needs to take a context pointer for Cogl 2.0 */
-void
-cogl_pop_source (void)
-{
-  CoglSourceState *top;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  _COGL_RETURN_IF_FAIL (ctx->source_stack);
-
-  top = ctx->source_stack->data;
-  top->push_count--;
-  if (top->push_count == 0)
-    {
-      cogl_object_unref (top->pipeline);
-      g_slice_free (CoglSourceState, top);
-      ctx->source_stack = g_list_delete_link (ctx->source_stack,
-                                              ctx->source_stack);
-    }
-}
-
-/* FIXME: This needs to take a context pointer for Cogl 2.0 */
-void *
-cogl_get_source (void)
-{
-  CoglSourceState *top;
-
-  _COGL_GET_CONTEXT (ctx, NULL);
-
-  _COGL_RETURN_VAL_IF_FAIL (ctx->source_stack, NULL);
-
-  top = ctx->source_stack->data;
-  return top->pipeline;
-}
-
-void
-cogl_set_source (void *material_or_pipeline)
-{
-  CoglSourceState *top;
-  CoglPipeline *pipeline = COGL_PIPELINE (material_or_pipeline);
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
-  _COGL_RETURN_IF_FAIL (ctx->source_stack);
-
-  top = ctx->source_stack->data;
-  if (top->pipeline == pipeline)
-    return;
-
-  if (top->push_count == 1)
-    {
-      /* NB: top->pipeline may be only thing keeping pipeline
-       * alive currently so ref pipeline first... */
-      cogl_object_ref (pipeline);
-      cogl_object_unref (top->pipeline);
-      top->pipeline = pipeline;
-    }
-  else
-    {
-      top->push_count--;
-      cogl_push_source (pipeline);
-    }
-}
-
-void
-cogl_set_source_texture (CoglTexture *texture)
-{
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
-  _COGL_RETURN_IF_FAIL (texture != NULL);
-
-  cogl_pipeline_set_layer_texture (ctx->texture_pipeline, 0, texture);
-  cogl_set_source (ctx->texture_pipeline);
-}
-
-void
-cogl_set_source_color4ub (uint8_t red,
-                          uint8_t green,
-                          uint8_t blue,
-                          uint8_t alpha)
-{
-  CoglColor c = { 0, };
-
-  cogl_color_init_from_4ub (&c, red, green, blue, alpha);
-  cogl_set_source_color (&c);
-}
-
-void
-cogl_set_source_color4f (float red,
-                         float green,
-                         float blue,
-                         float alpha)
-{
-  CoglColor c = { 0, };
-
-  cogl_color_init_from_4f (&c, red, green, blue, alpha);
-  cogl_set_source_color (&c);
-}
-
 /* Scale from OpenGL normalized device coordinates (ranging from -1 to 1)
  * to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with
  * (0,0) being top left. */
diff --git a/cogl/cogl1-context.h b/cogl/cogl1-context.h
index fc381bb..eba4220 100644
--- a/cogl/cogl1-context.h
+++ b/cogl/cogl1-context.h
@@ -40,727 +40,6 @@
 G_BEGIN_DECLS
 
 /**
- * cogl_get_option_group:
- *
- * Retrieves the #GOptionGroup used by Cogl to parse the command
- * line options. Clutter uses this to handle the Cogl command line
- * options during its initialization process.
- *
- * Return value: a #GOptionGroup
- *
- * Since: 1.0
- */
-GOptionGroup *
-cogl_get_option_group (void);
-
-/* Misc */
-/**
- * cogl_get_features:
- *
- * Returns all of the features supported by COGL.
- *
- * Return value: A logical OR of all the supported COGL features.
- *
- * Since: 0.8
- */
-CoglFeatureFlags
-cogl_get_features (void);
-
-/**
- * cogl_features_available:
- * @features: A bitmask of features to check for
- *
- * Checks whether the given COGL features are available. Multiple
- * features can be checked for by or-ing them together with the '|'
- * operator. %TRUE is only returned if all of the requested features
- * are available.
- *
- * Return value: %TRUE if the features are available, %FALSE otherwise.
- */
-CoglBool
-cogl_features_available (CoglFeatureFlags features);
-
-/**
- * cogl_get_proc_address:
- * @name: the name of the function.
- *
- * Gets a pointer to a given GL or GL ES extension function. This acts
- * as a wrapper around glXGetProcAddress() or whatever is the
- * appropriate function for the current backend.
- *
- * Return value: a pointer to the requested function or %NULL if the
- *   function is not available.
- */
-CoglFuncPtr
-cogl_get_proc_address (const char *name);
-
-#ifndef COGL_DISABLE_DEPRECATED
-
-/**
- * cogl_check_extension:
- * @name: extension to check for
- * @ext: list of extensions
- *
- * Check whether @name occurs in list of extensions in @ext.
- *
- * Return value: %TRUE if the extension occurs in the list, %FALSE otherwise.
- *
- * Deprecated: 1.2: OpenGL is an implementation detail for Cogl and so it's
- *   not appropriate to expose OpenGL extensions through the Cogl API. This
- *   function can be replaced by the following equivalent code:
- * |[
- *   CoglBool retval = (strstr (ext, name) != NULL) ? TRUE : FALSE;
- * ]|
- */
-CoglBool
-cogl_check_extension (const char *name,
-                      const char *ext) G_GNUC_DEPRECATED;
-
-#endif /* COGL_DISABLE_DEPRECATED */
-
-/**
- * cogl_get_bitmasks:
- * @red: (out): Return location for the number of red bits or %NULL
- * @green: (out): Return location for the number of green bits or %NULL
- * @blue: (out): Return location for the number of blue bits or %NULL
- * @alpha: (out): Return location for the number of alpha bits or %NULL
- *
- * Gets the number of bitplanes used for each of the color components
- * in the color buffer. Pass %NULL for any of the arguments if the
- * value is not required.
- */
-void
-cogl_get_bitmasks (int *red,
-                   int *green,
-                   int *blue,
-                   int *alpha);
-
-/**
- * cogl_perspective:
- * @fovy: Vertical field of view angle in degrees.
- * @aspect: The (width over height) aspect ratio for display
- * @z_near: The distance to the near clipping plane (Must be positive)
- * @z_far: The distance to the far clipping plane (Must be positive)
- *
- * Replaces the current projection matrix with a perspective matrix
- * based on the provided values.
- *
- * <note>You should be careful not to have to great a @z_far / @z_near
- * ratio since that will reduce the effectiveness of depth testing
- * since there wont be enough precision to identify the depth of
- * objects near to each other.</note>
- */
-void
-cogl_perspective (float fovy,
-                  float aspect,
-                  float z_near,
-                  float z_far);
-
-/**
- * cogl_frustum:
- * @left: X position of the left clipping plane where it
- *   intersects the near clipping plane
- * @right: X position of the right clipping plane where it
- *   intersects the near clipping plane
- * @bottom: Y position of the bottom clipping plane where it
- *   intersects the near clipping plane
- * @top: Y position of the top clipping plane where it intersects
- *   the near clipping plane
- * @z_near: The distance to the near clipping plane (Must be positive)
- * @z_far: The distance to the far clipping plane (Must be positive)
- *
- * Replaces the current projection matrix with a perspective matrix
- * for a given viewing frustum defined by 4 side clip planes that
- * all cross through the origin and 2 near and far clip planes.
- *
- * Since: 0.8.2
- */
-void
-cogl_frustum (float left,
-              float right,
-              float bottom,
-              float top,
-              float z_near,
-              float z_far);
-
-/**
- * cogl_ortho:
- * @left: The coordinate for the left clipping plane
- * @right: The coordinate for the right clipping plane
- * @bottom: The coordinate for the bottom clipping plane
- * @top: The coordinate for the top clipping plane
- * @near: The <emphasis>distance</emphasis> to the near clipping
- *   plane (negative if the plane is behind the viewer)
- * @far: The <emphasis>distance</emphasis> for the far clipping
- *   plane (negative if the plane is behind the viewer)
- *
- * Replaces the current projection matrix with an orthographic projection
- * matrix. See <xref linkend="cogl-ortho-matrix"/> to see how the matrix is
- * calculated.
- *
- * <figure id="cogl-ortho-matrix">
- *   <title></title>
- *   <graphic fileref="cogl_ortho.png" format="PNG"/>
- * </figure>
- *
- * <note>This function copies the arguments from OpenGL's glOrtho() even
- * though they are unnecessarily confusing due to the z near and z far
- * arguments actually being a "distance" from the origin, where
- * negative values are behind the viewer, instead of coordinates for
- * the z clipping planes which would have been consistent with the
- * left, right bottom and top arguments.</note>
- *
- * Since: 1.0
- */
-void
-cogl_ortho (float left,
-            float right,
-            float bottom,
-            float top,
-            float near,
-            float far);
-
-#ifndef COGL_DISABLE_DEPRECATED
-
-/**
- * cogl_viewport:
- * @width: Width of the viewport
- * @height: Height of the viewport
- *
- * Replace the current viewport with the given values.
- *
- * Since: 0.8.2
- *
- * Deprecated: 1.2: Use cogl_set_viewport() instead
- */
-void
-cogl_viewport (unsigned int width,
-	       unsigned int height) G_GNUC_DEPRECATED;
-
-#endif /* COGL_DISABLE_DEPRECATED */
-
-/**
- * cogl_set_viewport:
- * @x: X offset of the viewport
- * @y: Y offset of the viewport
- * @width: Width of the viewport
- * @height: Height of the viewport
- *
- * Replaces the current viewport with the given values.
- *
- * Since: 1.2
- */
-void
-cogl_set_viewport (int x,
-                   int y,
-                   int width,
-                   int height);
-
-/**
- * cogl_push_matrix:
- *
- * Stores the current model-view matrix on the matrix stack. The matrix
- * can later be restored with cogl_pop_matrix().
- */
-void
-cogl_push_matrix (void);
-
-/**
- * cogl_pop_matrix:
- *
- * Restores the current model-view matrix from the matrix stack.
- */
-void
-cogl_pop_matrix (void);
-
-/**
- * cogl_scale:
- * @x: Amount to scale along the x-axis
- * @y: Amount to scale along the y-axis
- * @z: Amount to scale along the z-axis
- *
- * Multiplies the current model-view matrix by one that scales the x,
- * y and z axes by the given values.
- */
-void
-cogl_scale (float x,
-            float y,
-            float z);
-
-/**
- * cogl_translate:
- * @x: Distance to translate along the x-axis
- * @y: Distance to translate along the y-axis
- * @z: Distance to translate along the z-axis
- *
- * Multiplies the current model-view matrix by one that translates the
- * model along all three axes according to the given values.
- */
-void
-cogl_translate (float x,
-                float y,
-                float z);
-
-/**
- * cogl_rotate:
- * @angle: Angle in degrees to rotate.
- * @x: X-component of vertex to rotate around.
- * @y: Y-component of vertex to rotate around.
- * @z: Z-component of vertex to rotate around.
- *
- * Multiplies the current model-view matrix by one that rotates the
- * model around the vertex specified by @x, @y and @z. The rotation
- * follows the right-hand thumb rule so for example rotating by 10
- * degrees about the vertex (0, 0, 1) causes a small counter-clockwise
- * rotation.
- */
-void
-cogl_rotate (float angle,
-             float x,
-             float y,
-             float z);
-
-/**
- * cogl_transform:
- * @matrix: the matrix to multiply with the current model-view
- *
- * Multiplies the current model-view matrix by the given matrix.
- *
- * Since: 1.4
- */
-void
-cogl_transform (const CoglMatrix *matrix);
-
-/**
- * cogl_get_modelview_matrix:
- * @matrix: (out): return location for the model-view matrix
- *
- * Stores the current model-view matrix in @matrix.
- */
-void
-cogl_get_modelview_matrix (CoglMatrix *matrix);
-
-/**
- * cogl_set_modelview_matrix:
- * @matrix: the new model-view matrix
- *
- * Loads @matrix as the new model-view matrix.
- */
-void
-cogl_set_modelview_matrix (CoglMatrix *matrix);
-
-/**
- * cogl_get_projection_matrix:
- * @matrix: (out): return location for the projection matrix
- *
- * Stores the current projection matrix in @matrix.
- */
-void
-cogl_get_projection_matrix (CoglMatrix *matrix);
-
-/**
- * cogl_set_projection_matrix:
- * @matrix: the new projection matrix
- *
- * Loads matrix as the new projection matrix.
- */
-void
-cogl_set_projection_matrix (CoglMatrix *matrix);
-
-/**
- * cogl_get_viewport:
- * @v: (out) (array fixed-size=4): pointer to a 4 element array
- *   of #float<!-- -->s to receive the viewport dimensions.
- *
- * Stores the current viewport in @v. @v[0] and @v[1] get the x and y
- * position of the viewport and @v[2] and @v[3] get the width and
- * height.
- */
-void
-cogl_get_viewport (float v[4]);
-
-/**
- * cogl_clear:
- * @color: Background color to clear to
- * @buffers: A mask of #CoglBufferBit<!-- -->'s identifying which auxiliary
- *   buffers to clear
- *
- * Clears all the auxiliary buffers identified in the @buffers mask, and if
- * that includes the color buffer then the specified @color is used.
- */
-void
-cogl_clear (const CoglColor *color,
-            unsigned long buffers);
-
-/**
- * cogl_set_source:
- * @material: A #CoglMaterial
- *
- * This function changes the material at the top of the source stack.
- * The material at the top of this stack defines the GPU state used to
- * process subsequent primitives, such as rectangles drawn with
- * cogl_rectangle() or vertices drawn using cogl_vertex_buffer_draw().
- *
- * Since: 1.0
- */
-void
-cogl_set_source (void *material);
-
-/**
- * cogl_get_source:
- *
- * Returns the current source material as previously set using
- * cogl_set_source().
- *
- * <note>You should typically consider the returned material immutable
- * and not try to change any of its properties unless you own a
- * reference to that material. At times you may be able to get a
- * reference to an internally managed materials and the result of
- * modifying such materials is undefined.</note>
- *
- * Return value: The current source material.
- *
- * Since: 1.6
- */
-void *
-cogl_get_source (void);
-
-/**
- * cogl_push_source:
- * @material: A #CoglPipeline
- *
- * Pushes the given @pipeline to the top of the source stack. The
- * pipeline at the top of this stack defines the GPU state used to
- * process later primitives as defined by cogl_set_source().
- *
- * Since: 1.6
- */
-void
-cogl_push_source (CoglPipeline *pipeline);
-
-/**
- * cogl_pop_source:
- *
- * Removes the pipeline at the top of the source stack. The pipeline
- * at the top of this stack defines the GPU state used to process
- * later primitives as defined by cogl_set_source().
- *
- * Since: 1.6
- */
-void
-cogl_pop_source (void);
-
-/**
- * cogl_set_source_color:
- * @color: a #CoglColor
- *
- * This is a convenience function for creating a solid fill source material
- * from the given color. This color will be used for any subsequent drawing
- * operation.
- *
- * The color will be premultiplied by Cogl, so the color should be
- * non-premultiplied. For example: use (1.0, 0.0, 0.0, 0.5) for
- * semi-transparent red.
- *
- * See also cogl_set_source_color4ub() and cogl_set_source_color4f()
- * if you already have the color components.
- *
- * Since: 1.0
- */
-void
-cogl_set_source_color (const CoglColor *color);
-
-/**
- * cogl_set_source_color4ub:
- * @red: value of the red channel, between 0 and 255
- * @green: value of the green channel, between 0 and 255
- * @blue: value of the blue channel, between 0 and 255
- * @alpha: value of the alpha channel, between 0 and 255
- *
- * This is a convenience function for creating a solid fill source material
- * from the given color using unsigned bytes for each component. This
- * color will be used for any subsequent drawing operation.
- *
- * The value for each component is an unsigned byte in the range
- * between 0 and 255.
- *
- * Since: 1.0
- */
-void
-cogl_set_source_color4ub (uint8_t red,
-                          uint8_t green,
-                          uint8_t blue,
-                          uint8_t alpha);
-
-/**
- * cogl_set_source_color4f:
- * @red: value of the red channel, between 0 and %1.0
- * @green: value of the green channel, between 0 and %1.0
- * @blue: value of the blue channel, between 0 and %1.0
- * @alpha: value of the alpha channel, between 0 and %1.0
- *
- * This is a convenience function for creating a solid fill source material
- * from the given color using normalized values for each component. This color
- * will be used for any subsequent drawing operation.
- *
- * The value for each component is a fixed point number in the range
- * between 0 and %1.0. If the values passed in are outside that
- * range, they will be clamped.
- *
- * Since: 1.0
- */
-void
-cogl_set_source_color4f (float red,
-                         float green,
-                         float blue,
-                         float alpha);
-
-/**
- * cogl_set_source_texture:
- * @texture: The #CoglTexture you want as your source
- *
- * This is a convenience function for creating a material with the first
- * layer set to @texture and setting that material as the source with
- * cogl_set_source.
- *
- * Note: There is no interaction between calls to cogl_set_source_color
- * and cogl_set_source_texture. If you need to blend a texture with a color then
- * you can create a simple material like this:
- * <programlisting>
- * material = cogl_material_new ();
- * cogl_material_set_color4ub (material, 0xff, 0x00, 0x00, 0x80);
- * cogl_material_set_layer (material, 0, tex_handle);
- * cogl_set_source (material);
- * </programlisting>
- *
- * Since: 1.0
- */
-void
-cogl_set_source_texture (CoglTexture *texture);
-
-
-/**
- * SECTION:cogl-clipping
- * @short_description: Fuctions for manipulating a stack of clipping regions
- *
- * To support clipping your geometry to rectangles or paths Cogl exposes a
- * stack based API whereby each clip region you push onto the stack is
- * intersected with the previous region.
- */
-
-#ifndef COGL_DISABLE_DEPRECATED
-
-/**
- * cogl_clip_push_window_rect:
- * @x_offset: left edge of the clip rectangle in window coordinates
- * @y_offset: top edge of the clip rectangle in window coordinates
- * @width: width of the clip rectangle
- * @height: height of the clip rectangle
- *
- * Specifies a rectangular clipping area for all subsequent drawing
- * operations. Any drawing commands that extend outside the rectangle
- * will be clipped so that only the portion inside the rectangle will
- * be displayed. The rectangle dimensions are not transformed by the
- * current model-view matrix.
- *
- * The rectangle is intersected with the current clip region. To undo
- * the effect of this function, call cogl_clip_pop().
- *
- * Deprecated: 1.2: Use cogl_clip_push_window_rectangle() instead
- */
-void
-cogl_clip_push_window_rect (float x_offset,
-                            float y_offset,
-                            float width,
-                            float height) G_GNUC_DEPRECATED;
-
-#endif /* COGL_DISABLE_DEPRECATED */
-
-/**
- * cogl_clip_push_window_rectangle:
- * @x_offset: left edge of the clip rectangle in window coordinates
- * @y_offset: top edge of the clip rectangle in window coordinates
- * @width: width of the clip rectangle
- * @height: height of the clip rectangle
- *
- * Specifies a rectangular clipping area for all subsequent drawing
- * operations. Any drawing commands that extend outside the rectangle
- * will be clipped so that only the portion inside the rectangle will
- * be displayed. The rectangle dimensions are not transformed by the
- * current model-view matrix.
- *
- * The rectangle is intersected with the current clip region. To undo
- * the effect of this function, call cogl_clip_pop().
- *
- * Since: 1.2
- */
-void
-cogl_clip_push_window_rectangle (int x_offset,
-                                 int y_offset,
-                                 int width,
-                                 int height);
-
-#ifndef COGL_DISABLE_DEPRECATED
-
-/**
- * cogl_clip_push:
- * @x_offset: left edge of the clip rectangle
- * @y_offset: top edge of the clip rectangle
- * @width: width of the clip rectangle
- * @height: height of the clip rectangle
- *
- * Specifies a rectangular clipping area for all subsequent drawing
- * operations. Any drawing commands that extend outside the rectangle
- * will be clipped so that only the portion inside the rectangle will
- * be displayed. The rectangle dimensions are transformed by the
- * current model-view matrix.
- *
- * The rectangle is intersected with the current clip region. To undo
- * the effect of this function, call cogl_clip_pop().
- *
- * Deprecated: 1.2: The x, y, width, height arguments are inconsistent
- *   with other API that specify rectangles in model space, and when used
- *   with a coordinate space that puts the origin at the center and y+
- *   extending up, it's awkward to use. Please use cogl_clip_push_rectangle()
- *   instead
- */
-void
-cogl_clip_push (float x_offset,
-                float y_offset,
-                float width,
-                float height) G_GNUC_DEPRECATED;
-
-#endif /* COGL_DISABLE_DEPRECATED */
-
-/**
- * cogl_clip_push_rectangle:
- * @x0: x coordinate for top left corner of the clip rectangle
- * @y0: y coordinate for top left corner of the clip rectangle
- * @x1: x coordinate for bottom right corner of the clip rectangle
- * @y1: y coordinate for bottom right corner of the clip rectangle
- *
- * Specifies a rectangular clipping area for all subsequent drawing
- * operations. Any drawing commands that extend outside the rectangle
- * will be clipped so that only the portion inside the rectangle will
- * be displayed. The rectangle dimensions are transformed by the
- * current model-view matrix.
- *
- * The rectangle is intersected with the current clip region. To undo
- * the effect of this function, call cogl_clip_pop().
- *
- * Since: 1.2
- */
-void
-cogl_clip_push_rectangle (float x0,
-                          float y0,
-                          float x1,
-                          float y1);
-
-#ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API
-/**
- * cogl_clip_push_primitive:
- * @primitive: A #CoglPrimitive describing a flat 2D shape
- * @bounds_x1: x coordinate for the top-left corner of the primitives
- *             bounds
- * @bounds_y1: y coordinate for the top-left corner of the primitives
- *             bounds
- * @bounds_x2: x coordinate for the top-left corner of the primitives
- *             bounds
- * @bounds_y2: x coordinate for the bottom-right corner of the
- *             primitives bounds.
- * @bounds_x1: y coordinate for the bottom-right corner of the
- *             primitives bounds.
- *
- * Sets a new clipping area using a 2D shaped described with a
- * #CoglPrimitive. The shape must not contain self overlapping
- * geometry and must lie on a single 2D plane. A bounding box of the
- * 2D shape in local coordinates (the same coordinates used to
- * describe the shape) must be given. It is acceptable for the bounds
- * to be larger than the true bounds but behaviour is undefined if the
- * bounds are smaller than the true bounds.
- *
- * The primitive is transformed by the current model-view matrix and
- * the silhouette is intersected with the previous clipping area.  To
- * restore the previous clipping area, call
- * cogl_clip_pop().
- *
- * Since: 1.10
- * Stability: unstable
- */
-void
-cogl_clip_push_primitive (CoglPrimitive *primitive,
-                          float bounds_x1,
-                          float bounds_y1,
-                          float bounds_x2,
-                          float bounds_y2);
-#endif
-
-/**
- * cogl_clip_pop:
- *
- * Reverts the clipping region to the state before the last call to
- * cogl_clip_push().
- */
-void
-cogl_clip_pop (void);
-
-#ifndef COGL_DISABLE_DEPRECATED
-
-/**
- * cogl_clip_ensure:
- *
- * Ensures that the current clipping region has been set in GL. This
- * will automatically be called before any Cogl primitives but it
- * maybe be neccessary to call if you are using raw GL calls with
- * clipping.
- *
- * Deprecated: 1.2: Calling this function has no effect
- *
- * Since: 1.0
- */
-void
-cogl_clip_ensure (void) G_GNUC_DEPRECATED;
-
-/**
- * cogl_clip_stack_save:
- *
- * Save the entire state of the clipping stack and then clear all
- * clipping. The previous state can be returned to with
- * cogl_clip_stack_restore(). Each call to cogl_clip_push() after this
- * must be matched by a call to cogl_clip_pop() before calling
- * cogl_clip_stack_restore().
- *
- * Deprecated: 1.2: This was originally added to allow us to save the
- *   clip stack when switching to an offscreen framebuffer, but it's
- *   not necessary anymore given that framebuffers now own separate
- *   clip stacks which will be automatically switched between when a
- *   new buffer is set. Calling this function has no effect
- *
- * Since: 0.8.2
- */
-void
-cogl_clip_stack_save (void) G_GNUC_DEPRECATED;
-
-/**
- * cogl_clip_stack_restore:
- *
- * Restore the state of the clipping stack that was previously saved
- * by cogl_clip_stack_save().
- *
- * Deprecated: 1.2: This was originally added to allow us to restore
- *   the clip stack when switching back from an offscreen framebuffer,
- *   but it's not necessary anymore given that framebuffers now own
- *   separate clip stacks which will be automatically switched between
- *   when a new buffer is set. Calling this function has no effect
- *
- * Since: 0.8.2
- */
-void
-cogl_clip_stack_restore (void) G_GNUC_DEPRECATED;
-
-#endif /* COGL_DISABLE_DEPRECATED */
-
-/**
  * cogl_set_framebuffer:
  * @buffer: A #CoglFramebuffer object, either onscreen or offscreen.
  *
@@ -890,37 +169,6 @@ cogl_pop_draw_buffer (void) G_GNUC_DEPRECATED;
 #endif /* COGL_DISABLE_DEPRECATED */
 
 /**
- * cogl_read_pixels:
- * @x: The window x position to start reading from
- * @y: The window y position to start reading from
- * @width: The width of the rectangle you want to read
- * @height: The height of the rectangle you want to read
- * @source: Identifies which auxillary buffer you want to read
- *          (only COGL_READ_PIXELS_COLOR_BUFFER supported currently)
- * @format: The pixel format you want the result in
- *          (only COGL_PIXEL_FORMAT_RGBA_8888 supported currently)
- * @pixels: The location to write the pixel data.
- *
- * This reads a rectangle of pixels from the current framebuffer where
- * position (0, 0) is the top left. The pixel at (x, y) is the first
- * read, and the data is returned with a rowstride of (width * 4).
- *
- * Currently Cogl assumes that the framebuffer is in a premultiplied
- * format so if @format is non-premultiplied it will convert it. To
- * read the pixel values without any conversion you should either
- * specify a format that doesn't use an alpha channel or use one of
- * the formats ending in PRE.
- */
-void
-cogl_read_pixels (int x,
-                  int y,
-                  int width,
-                  int height,
-                  CoglReadPixelsFlags source,
-                  CoglPixelFormat format,
-                  uint8_t *pixels);
-
-/**
  * cogl_flush:
  *
  * This function should only need to be called in exceptional circumstances.
@@ -949,93 +197,6 @@ cogl_read_pixels (int x,
 void
 cogl_flush (void);
 
-/**
- * cogl_begin_gl:
- *
- * We do not advise nor reliably support the interleaving of raw GL drawing and
- * Cogl drawing functions, but if you insist, cogl_begin_gl() and cogl_end_gl()
- * provide a simple mechanism that may at least give you a fighting chance of
- * succeeding.
- *
- * Note: this doesn't help you modify the behaviour of Cogl drawing functions
- * through the modification of GL state; that will never be reliably supported,
- * but if you are trying to do something like:
- *
- * |[
- * {
- *    - setup some OpenGL state.
- *    - draw using OpenGL (e.g. glDrawArrays() )
- *    - reset modified OpenGL state.
- *    - continue using Cogl to draw
- * }
- * ]|
- *
- * You should surround blocks of drawing using raw GL with cogl_begin_gl()
- * and cogl_end_gl():
- *
- * |[
- * {
- *    cogl_begin_gl ();
- *    - setup some OpenGL state.
- *    - draw using OpenGL (e.g. glDrawArrays() )
- *    - reset modified OpenGL state.
- *    cogl_end_gl ();
- *    - continue using Cogl to draw
- * }
- * ]|
- *
- * Don't ever try and do:
- *
- * |[
- * {
- *    - setup some OpenGL state.
- *    - use Cogl to draw
- *    - reset modified OpenGL state.
- * }
- * ]|
- *
- * When the internals of Cogl evolves, this is very liable to break.
- *
- * This function will flush all batched primitives, and subsequently flush
- * all internal Cogl state to OpenGL as if it were going to draw something
- * itself.
- *
- * The result is that the OpenGL modelview matrix will be setup; the state
- * corresponding to the current source material will be set up and other world
- * state such as backface culling, depth and fogging enabledness will be sent
- * to OpenGL.
- *
- * <note>No special material state is flushed, so if you want Cogl to setup a
- * simplified material state it is your responsibility to set a simple source
- * material before calling cogl_begin_gl(). E.g. by calling
- * cogl_set_source_color4ub().</note>
- *
- * <note>It is your responsibility to restore any OpenGL state that you modify
- * to how it was after calling cogl_begin_gl() if you don't do this then the
- * result of further Cogl calls is undefined.</note>
- *
- * <note>You can not nest begin/end blocks.</note>
- *
- * Again we would like to stress, we do not advise the use of this API and if
- * possible we would prefer to improve Cogl than have developers require raw
- * OpenGL.
- *
- * Since: 1.0
- */
-void
-cogl_begin_gl (void);
-
-/**
- * cogl_end_gl:
- *
- * This is the counterpart to cogl_begin_gl() used to delimit blocks of drawing
- * code using raw OpenGL. Please refer to cogl_begin_gl() for full details.
- *
- * Since: 1.0
- */
-void
-cogl_end_gl (void);
-
 G_END_DECLS
 
 #endif /* __COGL_1_CONTEXT_H__ */
diff --git a/doc/reference/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index 3a7fe48..01d2d63 100644
--- a/doc/reference/cogl2/cogl2-sections.txt
+++ b/doc/reference/cogl2/cogl2-sections.txt
@@ -85,41 +85,10 @@ CoglFeatureCallback
 cogl_foreach_feature
 
 <SUBSECTION>
-cogl_push_matrix
-cogl_pop_matrix
-cogl_scale
-cogl_translate
-cogl_rotate
-cogl_transform
-cogl_frustum
-cogl_perspective
-cogl_ortho
-
-<SUBSECTION>
-cogl_get_modelview_matrix
-cogl_set_modelview_matrix
-cogl_get_projection_matrix
-cogl_set_projection_matrix
-cogl_set_viewport
-cogl_get_viewport
-
-<SUBSECTION>
-cogl_set_source
-cogl_set_source_color
-cogl_set_source_color4ub
-cogl_set_source_color4f
-cogl_set_source_texture
-cogl_get_source
-cogl_push_source
-cogl_pop_source
-
-<SUBSECTION>
 COGL_TYPE_BUFFER_BIT
-cogl_clear
 
 <SUBSECTION>
 CoglReadPixelsFlags
-cogl_read_pixels
 
 <SUBSECTION>
 cogl_flush
@@ -227,16 +196,6 @@ cogl_primitive_foreach_attribute
 </SECTION>
 
 <SECTION>
-<FILE>cogl-rectangle</FILE>
-<TITLE>Rectangles</TITLE>
-cogl_rectangle
-cogl_rectangles
-cogl_rectangle_with_texture_coords
-cogl_rectangles_with_texture_coords
-cogl_rectangle_with_multitexture_coords
-</SECTION>
-
-<SECTION>
 <FILE>cogl-snippet</FILE>
 <TITLE>Shader snippets</TITLE>
 CoglSnippet
@@ -255,12 +214,6 @@ cogl_snippet_get_post
 </SECTION>
 
 <SECTION>
-<FILE>cogl-primitives-deprecated</FILE>
-<TITLE>Primitives (Deprecated)</TITLE>
-cogl_polygon
-</SECTION>
-
-<SECTION>
 <FILE>cogl-paths</FILE>
 <TITLE>Path Primitives</TITLE>
 cogl_is_path
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c
index f6b67f3..6b3c4aa 100644
--- a/examples/cogl-crate.c
+++ b/examples/cogl-crate.c
@@ -168,8 +168,10 @@ main (int argc, char **argv)
 
   cogl_onscreen_show (onscreen);
 
-  cogl_push_framebuffer (fb);
-  cogl_set_viewport (0, 0, data.framebuffer_width, data.framebuffer_height);
+  cogl_framebuffer_set_viewport (fb,
+                                 0, 0,
+                                 data.framebuffer_width,
+                                 data.framebuffer_height);
 
   fovy = 60; /* y-axis field of view */
   aspect = (float)data.framebuffer_width/(float)data.framebuffer_height;
@@ -177,7 +179,7 @@ main (int argc, char **argv)
   z_2d = 1000; /* position to 2d plane */
   z_far = 2000; /* distance to far clipping plane */
 
-  cogl_perspective (fovy, aspect, z_near, z_far);
+  cogl_framebuffer_perspective (fb, fovy, aspect, z_near, z_far);
 
   /* Since the pango renderer emits geometry in pixel/device coordinates
    * and the anti aliasing is implemented with the assumption that the
@@ -194,8 +196,7 @@ main (int argc, char **argv)
   cogl_matrix_view_2d_in_perspective (&data.view, fovy, aspect, z_near, z_2d,
                                       data.framebuffer_width,
                                       data.framebuffer_height);
-  cogl_set_modelview_matrix (&data.view);
-  cogl_pop_framebuffer ();
+  cogl_framebuffer_set_modelview_matrix (fb, &data.view);
 
   /* Initialize some convenient constants */
   cogl_matrix_init_identity (&identity);
@@ -265,8 +266,6 @@ main (int argc, char **argv)
   data.hello_label_width = PANGO_PIXELS (hello_label_size.width);
   data.hello_label_height = PANGO_PIXELS (hello_label_size.height);
 
-  cogl_push_framebuffer (fb);
-
   data.swap_ready = TRUE;
 
   has_swap_notify =
diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c
index d42bcb1..f71bf2a 100644
--- a/examples/cogl-x11-tfp.c
+++ b/examples/cogl-x11-tfp.c
@@ -195,6 +195,7 @@ main (int argc, char **argv)
   for (;;)
     {
       unsigned long pixel;
+      CoglPipeline *pipeline;
 
       while (XPending (xdpy))
         {
@@ -221,8 +222,10 @@ main (int argc, char **argv)
       XFlush (xdpy);
 
       cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
-      cogl_set_source_texture (COGL_TEXTURE (tfp));
-      cogl_rectangle (-0.8, 0.8, 0.8, -0.8);
+      pipeline = cogl_pipeline_new (ctx);
+      cogl_pipeline_set_layer_texture (pipeline, 0, COGL_TEXTURE (tfp));
+      cogl_framebuffer_draw_rectangle (fb, pipeline, -0.8, 0.8, 0.8, -0.8);
+      cogl_object_unref (pipeline);
       cogl_onscreen_swap_buffers (onscreen);
     }
 
diff --git a/examples/cogland.c b/examples/cogland.c
index d6f7bf8..849ec9a 100644
--- a/examples/cogland.c
+++ b/examples/cogland.c
@@ -477,15 +477,10 @@ cogland_compositor_create_output (CoglandCompositor *compositor,
     g_error ("Failed to allocate framebuffer: %s\n", error->message);
 
   cogl_onscreen_show (output->onscreen);
-#if 0
-  cogl_framebuffer_set_viewport (fb, x, y, width, height);
-#else
-  cogl_push_framebuffer (fb);
-  cogl_set_viewport (-x, -y,
-                     compositor->virtual_width,
-                     compositor->virtual_height);
-  cogl_pop_framebuffer ();
-#endif
+  cogl_framebuffer_set_viewport (fb,
+                                 -x, -y,
+                                 compositor->virtual_width,
+                                 compositor->virtual_height);
 
   mode = g_slice_new0 (CoglandMode);
   mode->flags = 0;
@@ -510,8 +505,6 @@ paint_cb (void *user_data)
       CoglFramebuffer *fb = COGL_FRAMEBUFFER (output->onscreen);
       GList *l2;
 
-      cogl_push_framebuffer (fb);
-
       cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
 
       cogl_framebuffer_draw_primitive (fb, compositor->triangle_pipeline,
@@ -524,13 +517,15 @@ paint_cb (void *user_data)
           if (surface->buffer)
             {
               CoglTexture2D *texture = surface->buffer->texture;
-              cogl_set_source_texture (COGL_TEXTURE (texture));
-              cogl_rectangle (-1, 1, 1, -1);
+              CoglPipeline *pipeline =
+                cogl_pipeline_new (compositor->cogl_context);
+              cogl_pipeline_set_layer_texture (pipeline, 0,
+                                               COGL_TEXTURE (texture));
+              cogl_framebuffer_draw_rectangle (fb, pipeline, -1, 1, 1, -1);
+              cogl_object_unref (pipeline);
             }
         }
       cogl_onscreen_swap_buffers (COGL_ONSCREEN (fb));
-
-      cogl_pop_framebuffer ();
     }
 
   while (!g_queue_is_empty (&compositor->frame_callbacks))
diff --git a/tests/conform/test-custom-attributes.c b/tests/conform/test-custom-attributes.c
index 7c75149..e726488 100644
--- a/tests/conform/test-custom-attributes.c
+++ b/tests/conform/test-custom-attributes.c
@@ -271,7 +271,7 @@ void
 test_custom_attributes (void)
 {
   /* If shaders aren't supported then we can't run the test */
-  if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
+  if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_GLSL))
     {
       CoglSnippet *snippet;
       TestState state;
diff --git a/tests/conform/test-depth-test.c b/tests/conform/test-depth-test.c
index 8e9eb1f..7dca65f 100644
--- a/tests/conform/test-depth-test.c
+++ b/tests/conform/test-depth-test.c
@@ -36,8 +36,7 @@ static CoglBool
 draw_rectangle (TestState *state,
                 int x,
                 int y,
-                TestDepthState *rect_state,
-                CoglBool legacy_mode)
+                TestDepthState *rect_state)
 {
   uint8_t Cr = MASK_RED (rect_state->color);
   uint8_t Cg = MASK_GREEN (rect_state->color);
@@ -61,33 +60,17 @@ draw_rectangle (TestState *state,
       return FALSE;
     }
 
-  if (!legacy_mode)
-    {
-      cogl_pipeline_set_color4ub (pipeline, Cr, Cg, Cb, Ca);
-
-      cogl_framebuffer_push_matrix (test_fb);
-      cogl_framebuffer_translate (test_fb, 0, 0, rect_state->depth);
-      cogl_framebuffer_draw_rectangle (test_fb,
-                                       pipeline,
-                                       x * QUAD_WIDTH,
-                                       y * QUAD_WIDTH,
-                                       x * QUAD_WIDTH + QUAD_WIDTH,
-                                       y * QUAD_WIDTH + QUAD_WIDTH);
-      cogl_framebuffer_pop_matrix (test_fb);
-    }
-  else
-    {
-      cogl_push_framebuffer (test_fb);
-      cogl_push_matrix ();
-      cogl_set_source_color4ub (Cr, Cg, Cb, Ca);
-      cogl_translate (0, 0, rect_state->depth);
-      cogl_rectangle (x * QUAD_WIDTH,
-                      y * QUAD_WIDTH,
-                      x * QUAD_WIDTH + QUAD_WIDTH,
-                      y * QUAD_WIDTH + QUAD_WIDTH);
-      cogl_pop_matrix ();
-      cogl_pop_framebuffer ();
-    }
+  cogl_pipeline_set_color4ub (pipeline, Cr, Cg, Cb, Ca);
+
+  cogl_framebuffer_push_matrix (test_fb);
+  cogl_framebuffer_translate (test_fb, 0, 0, rect_state->depth);
+  cogl_framebuffer_draw_rectangle (test_fb,
+                                   pipeline,
+                                   x * QUAD_WIDTH,
+                                   y * QUAD_WIDTH,
+                                   x * QUAD_WIDTH + QUAD_WIDTH,
+                                   y * QUAD_WIDTH + QUAD_WIDTH);
+  cogl_framebuffer_pop_matrix (test_fb);
 
   cogl_object_unref (pipeline);
 
@@ -101,17 +84,16 @@ test_depth (TestState *state,
             TestDepthState *rect0_state,
             TestDepthState *rect1_state,
             TestDepthState *rect2_state,
-            CoglBool legacy_mode,
             uint32_t expected_result)
 {
   CoglBool missing_feature = FALSE;
 
   if (rect0_state)
-    missing_feature |= !draw_rectangle (state, x, y, rect0_state, legacy_mode);
+    missing_feature |= !draw_rectangle (state, x, y, rect0_state);
   if (rect1_state)
-    missing_feature |= !draw_rectangle (state, x, y, rect1_state, legacy_mode);
+    missing_feature |= !draw_rectangle (state, x, y, rect1_state);
   if (rect2_state)
-    missing_feature |= !draw_rectangle (state, x, y, rect2_state, legacy_mode);
+    missing_feature |= !draw_rectangle (state, x, y, rect2_state);
 
   /* We don't consider it an error that we can't test something
    * the driver doesn't support. */
@@ -161,32 +143,27 @@ paint (TestState *state)
 
     test_depth (state, 0, 0, /* position */
                 &rect0_state, &rect1_state, &rect2_state,
-                FALSE, /* legacy mode */
                 0x00ff00ff); /* expected */
 
     rect2_state.test_function = COGL_DEPTH_TEST_FUNCTION_ALWAYS;
     test_depth (state, 1, 0, /* position */
                 &rect0_state, &rect1_state, &rect2_state,
-                FALSE, /* legacy mode */
                 0x0000ffff); /* expected */
 
     rect2_state.test_function = COGL_DEPTH_TEST_FUNCTION_LESS;
     test_depth (state, 2, 0, /* position */
                 &rect0_state, &rect1_state, &rect2_state,
-                FALSE, /* legacy mode */
                 0x0000ffff); /* expected */
 
     rect2_state.test_function = COGL_DEPTH_TEST_FUNCTION_GREATER;
     test_depth (state, 3, 0, /* position */
                 &rect0_state, &rect1_state, &rect2_state,
-                FALSE, /* legacy mode */
                 0x00ff00ff); /* expected */
 
     rect0_state.test_enable = TRUE;
     rect1_state.write_enable = FALSE;
     test_depth (state, 4, 0, /* position */
                 &rect0_state, &rect1_state, &rect2_state,
-                FALSE, /* legacy mode */
                 0x0000ffff); /* expected */
   }
 
@@ -215,7 +192,6 @@ paint (TestState *state)
 
     test_depth (state, 0, 1, /* position */
                 &rect0_state, &rect1_state, NULL,
-                FALSE, /* legacy mode */
                 0xff0000ff); /* expected */
   }
 }
diff --git a/tests/conform/test-pipeline-uniforms.c b/tests/conform/test-pipeline-uniforms.c
index c7aba23..d174550 100644
--- a/tests/conform/test-pipeline-uniforms.c
+++ b/tests/conform/test-pipeline-uniforms.c
@@ -375,7 +375,7 @@ void
 test_pipeline_uniforms (void)
 {
   /* If shaders aren't supported then we can't run the test */
-  if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
+  if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_GLSL))
     {
       TestState state;
 
diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c
index 072303f..c14ed58 100644
--- a/tests/conform/test-snippets.c
+++ b/tests/conform/test-snippets.c
@@ -692,7 +692,7 @@ void
 test_snippets (void)
 {
   /* If shaders aren't supported then we can't run the test */
-  if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
+  if (cogl_has_feature (test_ctx, COGL_FEATURE_ID_GLSL))
     {
       TestState state;
 
-- 
1.7.7.6



More information about the Cogl mailing list