~darkxst/ubuntu/raring/cogl/lp1163025

« back to all changes in this revision

Viewing changes to cogl/cogl-spans.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-03-13 19:11:11 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120313191111-3hgk529qkh9m6uk2
Tags: 1.9.8-0ubuntu1
* New upstream release (LP: #941617)
* Updated symbols & library name for soname update
* debian/control.in: Bump minimum glib to 2.28
* debian/patches/02_disable_armv5t_specific_optimization.patch: Disabled

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include "math.h"
29
29
 
30
 
#include "cogl.h"
 
30
#include "cogl-util.h"
31
31
#include "cogl-internal.h"
32
32
#include "cogl-spans.h"
33
33
 
35
35
_cogl_span_iter_update (CoglSpanIter *iter)
36
36
{
37
37
  /* Pick current span */
38
 
  iter->span = &g_array_index (iter->array, CoglSpan, iter->index);
 
38
  iter->span = &iter->spans[iter->index];
39
39
 
40
40
  /* Offset next position by span size */
41
 
  iter->next_pos = iter->pos +
42
 
    (float)(iter->span->size - iter->span->waste);
 
41
  iter->next_pos = iter->pos + iter->span->size - iter->span->waste;
43
42
 
44
43
  /* Check if span intersects the area to cover */
45
44
  if (iter->next_pos <= iter->cover_start ||
67
66
 
68
67
void
69
68
_cogl_span_iter_begin (CoglSpanIter *iter,
70
 
                       GArray       *spans,
71
 
                       float         normalize_factor,
72
 
                       float         cover_start,
73
 
                       float         cover_end)
 
69
                       const CoglSpan *spans,
 
70
                       int n_spans,
 
71
                       float normalize_factor,
 
72
                       float cover_start,
 
73
                       float cover_end,
 
74
                       CoglPipelineWrapMode wrap_mode)
74
75
{
75
 
  float cover_start_normalized;
 
76
  /* XXX: If CLAMP_TO_EDGE needs to be emulated then it needs to be
 
77
   * done at a higher level than here... */
 
78
  _COGL_RETURN_IF_FAIL (wrap_mode == COGL_PIPELINE_WRAP_MODE_REPEAT ||
 
79
                        wrap_mode == COGL_PIPELINE_WRAP_MODE_MIRRORED_REPEAT);
76
80
 
77
 
  iter->index = 0;
78
81
  iter->span = NULL;
79
82
 
80
 
  iter->array = spans;
 
83
  iter->spans = spans;
 
84
  iter->n_spans = n_spans;
81
85
 
82
86
  /* We always iterate in a positive direction from the origin. If
83
87
   * iter->flipped == TRUE that means whoever is using this API should
98
102
   * iteration of any range so we need to relate the start of the range to the
99
103
   * nearest point equivalent to 0.
100
104
   */
101
 
  cover_start_normalized = cover_start / normalize_factor;
102
 
  iter->origin = floorf (cover_start_normalized) * normalize_factor;
 
105
  if (normalize_factor != 1.0)
 
106
    {
 
107
      float cover_start_normalized = cover_start / normalize_factor;
 
108
      iter->origin = floorf (cover_start_normalized) * normalize_factor;
 
109
    }
 
110
  else
 
111
    iter->origin = floorf (cover_start);
 
112
 
 
113
  iter->wrap_mode = wrap_mode;
 
114
 
 
115
  if (wrap_mode == COGL_PIPELINE_WRAP_MODE_REPEAT)
 
116
    iter->index = 0;
 
117
  else if (wrap_mode == COGL_PIPELINE_WRAP_MODE_MIRRORED_REPEAT)
 
118
    {
 
119
      if ((int)iter->origin % 2)
 
120
        {
 
121
          iter->index = iter->n_spans - 1;
 
122
          iter->mirror_direction = -1;
 
123
          iter->flipped = !iter->flipped;
 
124
        }
 
125
      else
 
126
        {
 
127
          iter->index = 0;
 
128
          iter->mirror_direction = 1;
 
129
        }
 
130
    }
 
131
  else
 
132
    g_warn_if_reached ();
103
133
 
104
134
  iter->cover_start = cover_start;
105
135
  iter->cover_end = cover_end;
107
137
 
108
138
  /* Update intersection */
109
139
  _cogl_span_iter_update (iter);
 
140
 
 
141
  while (iter->next_pos <= iter->cover_start)
 
142
    _cogl_span_iter_next (iter);
110
143
}
111
144
 
112
145
void
115
148
  /* Move current position */
116
149
  iter->pos = iter->next_pos;
117
150
 
118
 
  /* Pick next slice (wrap when last reached) */
119
 
  iter->index = (iter->index + 1) % iter->array->len;
 
151
  if (iter->wrap_mode == COGL_PIPELINE_WRAP_MODE_REPEAT)
 
152
    iter->index = (iter->index + 1) % iter->n_spans;
 
153
  else if (iter->wrap_mode == COGL_PIPELINE_WRAP_MODE_MIRRORED_REPEAT)
 
154
    {
 
155
      iter->index += iter->mirror_direction;
 
156
      if (iter->index == iter->n_spans || iter->index == -1)
 
157
        {
 
158
          iter->mirror_direction = -iter->mirror_direction;
 
159
          iter->index += iter->mirror_direction;
 
160
          iter->flipped = !iter->flipped;
 
161
        }
 
162
    }
 
163
  else
 
164
    g_warn_if_reached ();
120
165
 
121
166
  /* Update intersection */
122
167
  _cogl_span_iter_update (iter);