Go to the source code of this file.
Data Structures | |
struct | stipple_stage |
Subclass of draw_stage. More... | |
Functions | |
static struct stipple_stage * | stipple_stage (struct draw_stage *stage) |
static void | screen_interp (struct draw_context *draw, struct vertex_header *dst, float t, const struct vertex_header *v0, const struct vertex_header *v1) |
Compute interpolated vertex attributes for 'dst' at position 't' between 'v0' and 'v1'. | |
static void | emit_segment (struct draw_stage *stage, struct prim_header *header, float t0, float t1) |
static unsigned | stipple_test (int counter, ushort pattern, int factor) |
static void | stipple_line (struct draw_stage *stage, struct prim_header *header) |
static void | reset_stipple_counter (struct draw_stage *stage) |
static void | stipple_reset_point (struct draw_stage *stage, struct prim_header *header) |
static void | stipple_reset_tri (struct draw_stage *stage, struct prim_header *header) |
static void | stipple_first_line (struct draw_stage *stage, struct prim_header *header) |
static void | stipple_flush (struct draw_stage *stage, unsigned flags) |
static void | stipple_destroy (struct draw_stage *stage) |
struct draw_stage * | draw_stipple_stage (struct draw_context *draw) |
Create line stippler stage. |
struct draw_stage* draw_stipple_stage | ( | struct draw_context * | draw | ) | [read] |
Create line stippler stage.
Definition at line 234 of file draw_pipe_stipple.c.
References CALLOC_STRUCT, draw_stage::destroy, draw_stage::draw, draw_alloc_temp_verts(), draw_stage::flush, draw_stage::line, draw_stage::next, draw_stage::point, reset_stipple_counter(), draw_stage::reset_stipple_counter, stipple_stage::stage, stipple_destroy(), stipple_first_line(), stipple_flush(), stipple_reset_point(), stipple_reset_tri(), and draw_stage::tri.
00235 { 00236 struct stipple_stage *stipple = CALLOC_STRUCT(stipple_stage); 00237 00238 draw_alloc_temp_verts( &stipple->stage, 2 ); 00239 00240 stipple->stage.draw = draw; 00241 stipple->stage.next = NULL; 00242 stipple->stage.point = stipple_reset_point; 00243 stipple->stage.line = stipple_first_line; 00244 stipple->stage.tri = stipple_reset_tri; 00245 stipple->stage.reset_stipple_counter = reset_stipple_counter; 00246 stipple->stage.flush = stipple_flush; 00247 stipple->stage.destroy = stipple_destroy; 00248 00249 return &stipple->stage; 00250 }
static void emit_segment | ( | struct draw_stage * | stage, | |
struct prim_header * | header, | |||
float | t0, | |||
float | t1 | |||
) | [static] |
Definition at line 89 of file draw_pipe_stipple.c.
References draw_stage::draw, dup_vert(), draw_stage::line, draw_stage::next, screen_interp(), and prim_header::v.
00091 { 00092 struct vertex_header *v0new = dup_vert(stage, header->v[0], 0); 00093 struct vertex_header *v1new = dup_vert(stage, header->v[1], 1); 00094 struct prim_header newprim = *header; 00095 00096 if (t0 > 0.0) { 00097 screen_interp( stage->draw, v0new, t0, header->v[0], header->v[1] ); 00098 newprim.v[0] = v0new; 00099 } 00100 00101 if (t1 < 1.0) { 00102 screen_interp( stage->draw, v1new, t1, header->v[0], header->v[1] ); 00103 newprim.v[1] = v1new; 00104 } 00105 00106 stage->next->line( stage->next, &newprim ); 00107 }
static void reset_stipple_counter | ( | struct draw_stage * | stage | ) | [static] |
Definition at line 174 of file draw_pipe_stipple.c.
References stipple_stage::counter, draw_stage::next, draw_stage::reset_stipple_counter, and stipple_stage().
00175 { 00176 struct stipple_stage *stipple = stipple_stage(stage); 00177 stipple->counter = 0; 00178 stage->next->reset_stipple_counter( stage->next ); 00179 }
static void screen_interp | ( | struct draw_context * | draw, | |
struct vertex_header * | dst, | |||
float | t, | |||
const struct vertex_header * | v0, | |||
const struct vertex_header * | v1 | |||
) | [static] |
Compute interpolated vertex attributes for 'dst' at position 't' between 'v0' and 'v1'.
XXX using linear interpolation for all attribs at this time.
Definition at line 69 of file draw_pipe_stipple.c.
References vertex_header::data, draw_context::num_vs_outputs, and draw_context::vs.
00074 { 00075 uint attr; 00076 for (attr = 0; attr < draw->vs.num_vs_outputs; attr++) { 00077 const float *val0 = v0->data[attr]; 00078 const float *val1 = v1->data[attr]; 00079 float *newv = dst->data[attr]; 00080 uint i; 00081 for (i = 0; i < 4; i++) { 00082 newv[i] = val0[i] + t * (val1[i] - val0[i]); 00083 } 00084 } 00085 }
static void stipple_destroy | ( | struct draw_stage * | stage | ) | [static] |
Definition at line 224 of file draw_pipe_stipple.c.
References draw_free_temp_verts(), and FREE.
00225 { 00226 draw_free_temp_verts( stage ); 00227 FREE( stage ); 00228 }
static void stipple_first_line | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 199 of file draw_pipe_stipple.c.
References draw_stage::draw, draw, stipple_stage::factor, draw_stage::line, pipe_rasterizer_state::line_stipple_factor, pipe_rasterizer_state::line_stipple_pattern, stipple_stage::pattern, draw_context::rasterizer, stipple_line(), and stipple_stage().
00201 { 00202 struct stipple_stage *stipple = stipple_stage(stage); 00203 struct draw_context *draw = stage->draw; 00204 00205 stipple->pattern = draw->rasterizer->line_stipple_pattern; 00206 stipple->factor = draw->rasterizer->line_stipple_factor + 1; 00207 00208 stage->line = stipple_line; 00209 stage->line( stage, header ); 00210 }
static void stipple_flush | ( | struct draw_stage * | stage, | |
unsigned | flags | |||
) | [static] |
Definition at line 214 of file draw_pipe_stipple.c.
References draw_stage::flush, draw_stage::line, draw_stage::next, and stipple_first_line().
00215 { 00216 stage->line = stipple_first_line; 00217 stage->next->flush( stage->next, flags ); 00218 }
static void stipple_line | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 119 of file draw_pipe_stipple.c.
References stipple_stage::counter, vertex_header::data, draw_stage::draw, DRAW_PIPE_RESET_STIPPLE, emit_segment(), stipple_stage::factor, prim_header::flags, MAX2, stipple_stage::pattern, draw_context::position_output, stipple_stage(), stipple_test(), prim_header::v, and draw_context::vs.
00120 { 00121 struct stipple_stage *stipple = stipple_stage(stage); 00122 struct vertex_header *v0 = header->v[0]; 00123 struct vertex_header *v1 = header->v[1]; 00124 const unsigned pos = stage->draw->vs.position_output; 00125 const float *pos0 = v0->data[pos]; 00126 const float *pos1 = v1->data[pos]; 00127 float start = 0; 00128 int state = 0; 00129 00130 float x0 = pos0[0]; 00131 float x1 = pos1[0]; 00132 float y0 = pos0[1]; 00133 float y1 = pos1[1]; 00134 00135 float dx = x0 > x1 ? x0 - x1 : x1 - x0; 00136 float dy = y0 > y1 ? y0 - y1 : y1 - y0; 00137 00138 float length = MAX2(dx, dy); 00139 int i; 00140 00141 if (header->flags & DRAW_PIPE_RESET_STIPPLE) 00142 stipple->counter = 0; 00143 00144 00145 /* XXX ToDo: intead of iterating pixel-by-pixel, use a look-up table. 00146 */ 00147 for (i = 0; i < length; i++) { 00148 int result = stipple_test( (int) stipple->counter+i, 00149 (ushort) stipple->pattern, stipple->factor ); 00150 if (result != state) { 00151 /* changing from "off" to "on" or vice versa */ 00152 if (state) { 00153 if (start != i) { 00154 /* finishing an "on" segment */ 00155 emit_segment( stage, header, start / length, i / length ); 00156 } 00157 } 00158 else { 00159 /* starting an "on" segment */ 00160 start = (float) i; 00161 } 00162 state = result; 00163 } 00164 } 00165 00166 if (state && start < length) 00167 emit_segment( stage, header, start / length, 1.0 ); 00168 00169 stipple->counter += length; 00170 }
static void stipple_reset_point | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 182 of file draw_pipe_stipple.c.
References stipple_stage::counter, draw_stage::next, draw_stage::point, and stipple_stage().
00183 { 00184 struct stipple_stage *stipple = stipple_stage(stage); 00185 stipple->counter = 0; 00186 stage->next->point(stage->next, header); 00187 }
static void stipple_reset_tri | ( | struct draw_stage * | stage, | |
struct prim_header * | header | |||
) | [static] |
Definition at line 190 of file draw_pipe_stipple.c.
References stipple_stage::counter, draw_stage::next, stipple_stage(), and draw_stage::tri.
00191 { 00192 struct stipple_stage *stipple = stipple_stage(stage); 00193 stipple->counter = 0; 00194 stage->next->tri(stage->next, header); 00195 }
static struct stipple_stage* stipple_stage | ( | struct draw_stage * | stage | ) | [static, read] |
Definition at line 57 of file draw_pipe_stipple.c.
00058 { 00059 return (struct stipple_stage *) stage; 00060 }
static unsigned stipple_test | ( | int | counter, | |
ushort | pattern, | |||
int | factor | |||
) | [static] |