[Cogl] [PATCH] blit: avoid using _COGL_GET_CONTEXT

Robert Bragg robert at sixbynine.org
Mon Sep 24 07:48:24 PDT 2012


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

As part of an on-going effort to avoid depending on a global Cogl
context cogl-blit.c now finds the context by looking at
data->src_text->context instead of using the _COGL_GET_CONTEXT macro.
---
 cogl/cogl-blit.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/cogl/cogl-blit.c b/cogl/cogl-blit.c
index 8039b66..50bdf9a 100644
--- a/cogl/cogl-blit.c
+++ b/cogl/cogl-blit.c
@@ -34,6 +34,7 @@
 #include "cogl-blit.h"
 #include "cogl-context-private.h"
 #include "cogl-framebuffer-private.h"
+#include "cogl-texture-private.h"
 #include "cogl-texture-2d-private.h"
 #include "cogl-private.h"
 #include "cogl1-context.h"
@@ -43,13 +44,12 @@ static const CoglBlitMode *_cogl_blit_default_mode = NULL;
 static CoglBool
 _cogl_blit_texture_render_begin (CoglBlitData *data)
 {
+  CoglContext *ctx = data->src_tex->context;
   CoglOffscreen *offscreen;
   CoglFramebuffer *fb;
   CoglPipeline *pipeline;
   unsigned int dst_width, dst_height;
 
-  _COGL_GET_CONTEXT (ctx, FALSE);
-
   offscreen = _cogl_offscreen_new_to_texture_full
     (data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */);
 
@@ -126,7 +126,7 @@ _cogl_blit_texture_render_blit (CoglBlitData *data,
 static void
 _cogl_blit_texture_render_end (CoglBlitData *data)
 {
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = data->src_tex->context;
 
   /* Attach the target texture to the texture render pipeline so that
      we don't keep a reference to the source texture forever. This is
@@ -145,11 +145,10 @@ _cogl_blit_texture_render_end (CoglBlitData *data)
 static CoglBool
 _cogl_blit_framebuffer_begin (CoglBlitData *data)
 {
+  CoglContext *ctx = data->src_tex->context;
   CoglOffscreen *dst_offscreen = NULL, *src_offscreen = NULL;
   CoglFramebuffer *dst_fb, *src_fb;
 
-  _COGL_GET_CONTEXT (ctx, FALSE);
-
   /* We can only blit between FBOs if both textures are the same
      format and the blit framebuffer extension is supported */
   if ((cogl_texture_get_format (data->src_tex) & ~COGL_A_BIT) !=
@@ -218,8 +217,6 @@ _cogl_blit_copy_tex_sub_image_begin (CoglBlitData *data)
   CoglOffscreen *offscreen;
   CoglFramebuffer *fb;
 
-  _COGL_GET_CONTEXT (ctx, FALSE);
-
   /* This will only work if the target texture is a CoglTexture2D */
   if (!cogl_is_texture_2d (data->dst_tex))
     return FALSE;
-- 
1.7.7.6



More information about the Cogl mailing list