예제 #1
0
static void
reset_stipple_counter(struct draw_stage *stage)
{
   struct stipple_stage *stipple = stipple_stage(stage);
   stipple->counter = 0;
   stage->next->reset_stipple_counter( stage->next );
}
예제 #2
0
static void
stipple_reset_tri(struct draw_stage *stage, struct prim_header *header)
{
   struct stipple_stage *stipple = stipple_stage(stage);
   stipple->counter = 0;
   stage->next->tri(stage->next, header);
}
static void
stipple_line(struct draw_stage *stage, struct prim_header *header)
{
   struct stipple_stage *stipple = stipple_stage(stage);
   struct vertex_header *v0 = header->v[0];
   struct vertex_header *v1 = header->v[1];
   const unsigned pos = draw_current_shader_position_output(stage->draw);
   const float *pos0 = v0->data[pos];
   const float *pos1 = v1->data[pos];
   float start = 0;
   bool state = 0;

   float x0 = pos0[0];
   float x1 = pos1[0];
   float y0 = pos0[1];
   float y1 = pos1[1];

   float length;
   int i;

   if (stipple->smooth) {
      float dx = x1 - x0;
      float dy = y1 - y0;
      length = sqrtf(dx*dx + dy*dy);
   } else {
      float dx = x0 > x1 ? x0 - x1 : x1 - x0;
      float dy = y0 > y1 ? y0 - y1 : y1 - y0;
      length = MAX2(dx, dy);
   }

   if (header->flags & DRAW_PIPE_RESET_STIPPLE)
      stipple->counter = 0;

   /* XXX ToDo: instead of iterating pixel-by-pixel, use a look-up table.
    */
   for (i = 0; i < length; i++) {
      bool result = stipple_test((int)stipple->counter + i,
                                 (ushort)stipple->pattern, stipple->factor);
      if (result != state) {
         /* changing from "off" to "on" or vice versa */
         if (state) {
            if (start != i) {
               /* finishing an "on" segment */
               emit_segment(stage, header, start / length, i / length);
            }
         }
         else {
            /* starting an "on" segment */
            start = (float)i;
         }
         state = result;
      }
   }

   if (state && start < length)
      emit_segment(stage, header, start / length, 1.0);

   stipple->counter += length;
}
예제 #4
0
static void
stipple_first_line(struct draw_stage *stage, 
		   struct prim_header *header)
{
   struct stipple_stage *stipple = stipple_stage(stage);
   struct draw_context *draw = stage->draw;

   stipple->pattern = draw->rasterizer->line_stipple_pattern;
   stipple->factor = draw->rasterizer->line_stipple_factor + 1;

   stage->line = stipple_line;
   stage->line( stage, header );
}