Qt 4.8
Public Functions | Public Variables | Private Types | Properties | List of all members
QTessellatorPrivate::Scanline Class Reference

Public Functions

void clearMarks ()
 
void done ()
 
int findEdge (int edge) const
 
int findEdgePosition (Q27Dot5 x, Q27Dot5 y) const
 
int findEdgePosition (const Edge &e) const
 
void init (int maxActiveEdges)
 
void insert (int pos, const Edge &e)
 
void lineDone ()
 
void markEdges (int pos1, int pos2)
 
void prepareLine ()
 
void removeAt (int pos)
 
 Scanline ()
 
void swap (int p1, int p2)
 
 ~Scanline ()
 

Public Variables

Edge ** edges
 
Edge ** old
 
int old_size
 
int size
 

Private Types

enum  { default_alloc = 32 }
 

Properties

Edgeedge_table
 
int first_unused
 
int max_edges
 

Detailed Description

Definition at line 137 of file qtessellator.cpp.

Enumerations

◆ anonymous enum

anonymous enum
private
Enumerator
default_alloc 

Definition at line 172 of file qtessellator.cpp.

Constructors and Destructors

◆ Scanline()

QTessellatorPrivate::Scanline::Scanline ( )

Definition at line 396 of file qtessellator.cpp.

397 {
398  edges = 0;
399  edge_table = 0;
400  old = 0;
401 }

◆ ~Scanline()

QTessellatorPrivate::Scanline::~Scanline ( )

Definition at line 433 of file qtessellator.cpp.

434 {
435  free(edges);
436  free(old);
437  free(edge_table);
438 }

Functions

◆ clearMarks()

void QTessellatorPrivate::Scanline::clearMarks ( )

Definition at line 485 of file qtessellator.cpp.

Referenced by QTessellatorPrivate::addIntersections().

486 {
487  for (int i = 0; i < size; ++i) {
488  edges[i]->mark = false;
489  edges[i]->intersect_left = false;
490  edges[i]->intersect_right = false;
491  }
492 }

◆ done()

void QTessellatorPrivate::Scanline::done ( )

Definition at line 421 of file qtessellator.cpp.

422 {
423  if (max_edges > default_alloc) {
424  free(edges);
425  free(old);
426  free(edge_table);
427  edges = 0;
428  old = 0;
429  edge_table = 0;
430  }
431 }

◆ findEdge()

int QTessellatorPrivate::Scanline::findEdge ( int  edge) const

Definition at line 474 of file qtessellator.cpp.

Referenced by QTessellatorPrivate::processIntersections(), and QTessellatorPrivate::removeEdges().

475 {
476  for (int i = 0; i < size; ++i) {
477  int item_edge = edges[i]->edge;
478  if (item_edge == edge)
479  return i;
480  }
481  //Q_ASSERT(false);
482  return -1;
483 }

◆ findEdgePosition() [1/2]

int QTessellatorPrivate::Scanline::findEdgePosition ( Q27Dot5  x,
Q27Dot5  y 
) const

Definition at line 440 of file qtessellator.cpp.

Referenced by QTessellatorPrivate::addEdges().

441 {
442  int min = 0;
443  int max = size - 1;
444  while (min < max) {
445  int pos = min + ((max - min + 1) >> 1);
446  Q27Dot5 ax = edges[pos]->positionAt(y);
447  if (ax > x) {
448  max = pos - 1;
449  } else {
450  min = pos;
451  }
452  }
453  return min;
454 }
Q27Dot5 positionAt(Q27Dot5 y) const
int Q27Dot5

◆ findEdgePosition() [2/2]

int QTessellatorPrivate::Scanline::findEdgePosition ( const Edge e) const

Definition at line 456 of file qtessellator.cpp.

457 {
458 // qDebug() << ">> findEdgePosition";
459  int min = 0;
460  int max = size;
461  while (min < max) {
462  int pos = min + ((max - min) >> 1);
463 // qDebug() << " " << min << max << pos << edges[pos]->isLeftOf(e, e.y0);
464  if (edges[pos]->isLeftOf(e, e.v0->y)) {
465  min = pos + 1;
466  } else {
467  max = pos;
468  }
469  }
470 // qDebug() << "<< findEdgePosition got" << min;
471  return min;
472 }

◆ init()

void QTessellatorPrivate::Scanline::init ( int  maxActiveEdges)

Definition at line 403 of file qtessellator.cpp.

404 {
405  maxActiveEdges *= 2;
406  if (!edges || maxActiveEdges > default_alloc) {
407  max_edges = maxActiveEdges;
408  int s = qMax(maxActiveEdges + 1, default_alloc + 1);
409  edges = q_check_ptr((Edge **)realloc(edges, s*sizeof(Edge *)));
410  edge_table = q_check_ptr((Edge *)realloc(edge_table, s*sizeof(Edge)));
411  old = q_check_ptr((Edge **)realloc(old, s*sizeof(Edge *)));
412  }
413  size = 0;
414  old_size = 0;
415  first_unused = 0;
416  for (int i = 0; i < maxActiveEdges; ++i)
417  edge_table[i].edge = i+1;
418  edge_table[maxActiveEdges].edge = -1;
419 }
T * q_check_ptr(T *p)
Definition: qglobal.h:1857
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217

◆ insert()

void QTessellatorPrivate::Scanline::insert ( int  pos,
const Edge e 
)

Definition at line 520 of file qtessellator.cpp.

Referenced by QTessellatorPrivate::addEdges().

521 {
522  Edge *edge = edge_table + first_unused;
523  first_unused = edge->edge;
524  Q_ASSERT(first_unused != -1);
525  *edge = e;
526  memmove(edges + pos + 1, edges + pos, (size - pos)*sizeof(Edge *));
527  edges[pos] = edge;
528  ++size;
529 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ lineDone()

void QTessellatorPrivate::Scanline::lineDone ( )

Definition at line 507 of file qtessellator.cpp.

508 {
509  Edge **end = old + old_size;
510  Edge **e = old;
511  while (e < end) {
512  if ((*e)->free) {
513  (*e)->edge = first_unused;
514  first_unused = (*e - edge_table);
515  }
516  ++e;
517  }
518 }
static const KeyPair *const end

◆ markEdges()

void QTessellatorPrivate::Scanline::markEdges ( int  pos1,
int  pos2 
)

Definition at line 539 of file qtessellator.cpp.

Referenced by QTessellatorPrivate::addEdges().

540 {
541  if (pos2 < pos1)
542  return;
543 
544  for (int i = pos1; i <= pos2; ++i)
545  edges[i]->mark = true;
546 }

◆ prepareLine()

void QTessellatorPrivate::Scanline::prepareLine ( )

Definition at line 494 of file qtessellator.cpp.

495 {
496  Edge **end = edges + size;
497  Edge **e = edges;
498  Edge **o = old;
499  while (e < end) {
500  *o = *e;
501  ++o;
502  ++e;
503  }
504  old_size = size;
505 }
static const KeyPair *const end

◆ removeAt()

void QTessellatorPrivate::Scanline::removeAt ( int  pos)

Definition at line 531 of file qtessellator.cpp.

Referenced by QTessellatorPrivate::removeEdges().

532 {
533  Edge *e = edges[pos];
534  e->free = true;
535  --size;
536  memmove(edges + pos, edges + pos + 1, (size - pos)*sizeof(Edge *));
537 }

◆ swap()

void QTessellatorPrivate::Scanline::swap ( int  p1,
int  p2 
)
inline

Definition at line 150 of file qtessellator.cpp.

150  {
151  Edge *tmp = edges[p1];
152  edges[p1] = edges[p2];
153  edges[p2] = tmp;
154  }

Properties

◆ edge_table

Edge* QTessellatorPrivate::Scanline::edge_table
private

Definition at line 169 of file qtessellator.cpp.

◆ edges

Edge** QTessellatorPrivate::Scanline::edges

◆ first_unused

int QTessellatorPrivate::Scanline::first_unused
private

Definition at line 170 of file qtessellator.cpp.

◆ max_edges

int QTessellatorPrivate::Scanline::max_edges
private

Definition at line 171 of file qtessellator.cpp.

◆ old

Edge** QTessellatorPrivate::Scanline::old

Definition at line 162 of file qtessellator.cpp.

Referenced by QTessellatorPrivate::emitEdges().

◆ old_size

int QTessellatorPrivate::Scanline::old_size

Definition at line 163 of file qtessellator.cpp.

Referenced by QTessellatorPrivate::emitEdges().

◆ size

int QTessellatorPrivate::Scanline::size

The documentation for this class was generated from the following file: