[cogl] journal: don't reference global context



commit b5c8ec5db52a6cb71f29b338a59fb3772506fef7
Author: Robert Bragg <robert linux intel com>
Date:   Fri Nov 9 00:57:14 2012 +0000

    journal: don't reference global context
    
    This removes all use of _COGL_GET_CONTEXT from cogl-journal.c
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl/cogl-journal.c |   47 +++++++++++++++++++----------------------------
 1 files changed, 19 insertions(+), 28 deletions(-)
---
diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c
index a774003..f20ec21 100644
--- a/cogl/cogl-journal.c
+++ b/cogl/cogl-journal.c
@@ -94,6 +94,8 @@
 
 typedef struct _CoglJournalFlushState
 {
+  CoglContext *ctx;
+
   CoglJournal *journal;
 
   CoglAttributeBuffer *attribute_buffer;
@@ -162,8 +164,6 @@ _cogl_journal_dump_logged_quad (uint8_t *data, int n_layers)
   size_t stride = GET_JOURNAL_ARRAY_STRIDE_FOR_N_LAYERS (n_layers);
   int i;
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   g_print ("n_layers = %d; rgba=0x%02X%02X%02X%02X\n",
            n_layers, data[0], data[1], data[2], data[3]);
 
@@ -191,8 +191,6 @@ _cogl_journal_dump_quad_vertices (uint8_t *data, int n_layers)
   size_t stride = GET_JOURNAL_VB_STRIDE_FOR_N_LAYERS (n_layers);
   int i;
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   g_print ("n_layers = %d; stride = %d; pos stride = %d; color stride = %d; "
            "tex stride = %d; stride in bytes = %d\n",
            n_layers, (int)stride, POS_STRIDE, COLOR_STRIDE,
@@ -273,6 +271,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
                                            void             *data)
 {
   CoglJournalFlushState *state = data;
+  CoglContext *ctx = state->ctx;
   CoglFramebuffer *framebuffer = state->journal->framebuffer;
   CoglAttribute **attributes;
   CoglDrawFlags draw_flags = (COGL_DRAW_SKIP_JOURNAL_FLUSH |
@@ -285,8 +284,6 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
                      "The time spent flushing modelview + entries",
                      0 /* no application private data */);
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   COGL_TIMER_START (_cogl_uprof_context, time_flush_modelview_and_entries);
 
   if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_BATCHING)))
@@ -355,10 +352,8 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
       int i;
       CoglAttribute *loop_attributes[1];
 
-      _COGL_GET_CONTEXT (ctxt, NO_RETVAL);
-
       if (outline == NULL)
-        outline = cogl_pipeline_new (ctxt);
+        outline = cogl_pipeline_new (ctx);
 
       /* The least significant three bits represent the three
          components so that the order of colours goes red, green,
@@ -367,13 +362,13 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
          in the order 0xff, 0xcc, 0x99, and 0x66. This gives a total
          of 24 colours. If there are more than 24 batches on the stage
          then it will wrap around */
-      color_intensity = 0xff - 0x33 * (ctxt->journal_rectangles_color >> 3);
+      color_intensity = 0xff - 0x33 * (ctx->journal_rectangles_color >> 3);
       cogl_pipeline_set_color4ub (outline,
-                                  (ctxt->journal_rectangles_color & 1) ?
+                                  (ctx->journal_rectangles_color & 1) ?
                                   color_intensity : 0,
-                                  (ctxt->journal_rectangles_color & 2) ?
+                                  (ctx->journal_rectangles_color & 2) ?
                                   color_intensity : 0,
-                                  (ctxt->journal_rectangles_color & 4) ?
+                                  (ctx->journal_rectangles_color & 4) ?
                                   color_intensity : 0,
                                   0xff);
 
@@ -389,11 +384,11 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
 
       /* Go to the next color */
       do
-        ctxt->journal_rectangles_color = ((ctxt->journal_rectangles_color + 1) &
-                                          ((1 << 5) - 1));
+        ctx->journal_rectangles_color = ((ctx->journal_rectangles_color + 1) &
+                                         ((1 << 5) - 1));
       /* We don't want to use black or white */
-      while ((ctxt->journal_rectangles_color & 0x07) == 0
-             || (ctxt->journal_rectangles_color & 0x07) == 0x07);
+      while ((ctx->journal_rectangles_color & 0x07) == 0
+             || (ctx->journal_rectangles_color & 0x07) == 0x07);
     }
 
   state->current_vertex += (4 * batch_len);
@@ -423,8 +418,6 @@ _cogl_journal_flush_pipeline_and_entries (CoglJournalEntry *batch_start,
                      "The time spent flushing pipeline + entries",
                      0 /* no application private data */);
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   COGL_TIMER_START (_cogl_uprof_context, time_flush_pipeline_entries);
 
   if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_BATCHING)))
@@ -544,8 +537,6 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries (
                      "+ entries",
                      0 /* no application private data */);
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   COGL_TIMER_START (_cogl_uprof_context, time_flush_texcoord_pipeline_entries);
 
   /* NB: attributes 0 and 1 are position and color */
@@ -939,12 +930,11 @@ maybe_software_clip_entries (CoglJournalEntry      *batch_start,
                              int                    batch_len,
                              CoglJournalFlushState *state)
 {
-  CoglJournal *journal = state->journal;
+  CoglContext *ctx;
+  CoglJournal *journal;
   CoglClipStack *clip_stack, *clip_entry;
   int entry_num;
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   /* This tries to find cases where the entry is logged with a clip
      but it would be faster to modify the vertex and texture
      coordinates rather than flush the clip so that it can batch
@@ -966,6 +956,9 @@ maybe_software_clip_entries (CoglJournalEntry      *batch_start,
     if (clip_entry->type != COGL_CLIP_STACK_RECT)
       return;
 
+  ctx = state->ctx;
+  journal = state->journal;
+
   /* This scratch buffer is used to store the translation for each
      entry in the journal. We store it in a separate buffer because
      it's expensive to calculate but at this point we still don't know
@@ -1020,8 +1013,6 @@ _cogl_journal_maybe_software_clip_entries (CoglJournalEntry *batch_start,
                      "Time spent software clipping",
                      0 /* no application private data */);
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   COGL_TIMER_START (_cogl_uprof_context,
                     time_check_software_clip);
 
@@ -1044,8 +1035,7 @@ create_attribute_buffer (CoglJournal *journal,
                          size_t n_bytes)
 {
   CoglAttributeBuffer *vbo;
-
-  _COGL_GET_CONTEXT (ctx, NULL);
+  CoglContext *ctx = journal->framebuffer->context;
 
   /* If CoglBuffers are being emulated with malloc then there's not
      really any point in using the pool so we'll just allocate the
@@ -1318,6 +1308,7 @@ _cogl_journal_flush (CoglJournal *journal)
                                  ~(COGL_FRAMEBUFFER_STATE_MODELVIEW |
                                    COGL_FRAMEBUFFER_STATE_CLIP));
 
+  state.ctx = ctx;
   state.journal = journal;
 
   state.attributes = ctx->journal_flush_attributes_array;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]