osgEarth 2.1.1
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

agg::rasterizer Class Reference

#include <AGG.h>

Collaboration diagram for agg::rasterizer:

List of all members.

Public Types

enum  {
  aa_shift = scanline::aa_shift, aa_num = 1 << aa_shift, aa_mask = aa_num - 1, aa_2num = aa_num * 2,
  aa_2mask = aa_2num - 1
}

Public Member Functions

 rasterizer ()
void reset ()
void filling_rule (filling_rule_e filling_rule)
void gamma (double g)
void gamma (const int8u *g)
void move_to (int x, int y)
void line_to (int x, int y)
void move_to_d (double x, double y)
void line_to_d (double x, double y)
int min_x () const
int min_y () const
int max_x () const
int max_y () const
unsigned calculate_alpha (int area) const
template<class Renderer >
void render (Renderer &r, const rgba8 &c, int dx=0, int dy=0)
bool hit_test (int tx, int ty)

Private Member Functions

 rasterizer (const rasterizer &)
const rasterizeroperator= (const rasterizer &)

Private Attributes

outline m_outline
scanline m_scanline
filling_rule_e m_filling_rule
int8u m_gamma [256]

Static Private Attributes

static const int8u s_default_gamma [256]

Detailed Description

Definition at line 631 of file AGG.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
aa_shift 
aa_num 
aa_mask 
aa_2num 
aa_2mask 

Definition at line 634 of file AGG.h.

        {
            aa_shift = scanline::aa_shift,
            aa_num   = 1 << aa_shift,
            aa_mask  = aa_num - 1,
            aa_2num  = aa_num * 2,
            aa_2mask = aa_2num - 1
        };

Constructor & Destructor Documentation

agg::rasterizer::rasterizer ( ) [inline]

Definition at line 643 of file AGG.h.

agg::rasterizer::rasterizer ( const rasterizer ) [private]

Member Function Documentation

unsigned agg::rasterizer::calculate_alpha ( int  area) const [inline]

Definition at line 679 of file AGG.h.

        {
            int cover = area >> (poly_base_shift*2 + 1 - aa_shift);

            if(cover < 0) cover = -cover;
            if(m_filling_rule == fill_even_odd)
            {
                cover &= aa_2mask;
                if(cover > aa_num)
                {
                    cover = aa_2num - cover;
                }
            }
            if(cover > aa_mask) cover = aa_mask;
            return cover;
        }

Here is the caller graph for this function:

void agg::rasterizer::filling_rule ( filling_rule_e  filling_rule) [inline]

Definition at line 653 of file AGG.h.

Here is the caller graph for this function:

void agg::rasterizer::gamma ( const int8u g)

Definition at line 2047 of file AGG.h.

    {
        memcpy(m_gamma, g, sizeof(m_gamma));
    }
void agg::rasterizer::gamma ( double  g)

Definition at line 2036 of file AGG.h.

    {
        unsigned i;
        for(i = 0; i < 256; i++)
        {
            m_gamma[i] = (unsigned char)(pow(double(i) / 255.0, g) * 255.0);
        }
    }

Here is the caller graph for this function:

bool agg::rasterizer::hit_test ( int  tx,
int  ty 
)

Definition at line 2054 of file AGG.h.

    {
        const cell* const* cells = m_outline.cells();
        if(m_outline.num_cells() == 0) return false;

        int x, y;
        int cover;
        int alpha;
        int area;

        cover = 0;
        const cell* cur_cell = *cells++;
        for(;;)
        {
            const cell* start_cell = cur_cell;

            int coord  = cur_cell->packed_coord;
            x = cur_cell->x;
            y = cur_cell->y;

            if(y > ty) return false;

            area   = start_cell->area;
            cover += start_cell->cover;

            while((cur_cell = *cells++) != 0)
            {
                if(cur_cell->packed_coord != coord) break;
                area  += cur_cell->area;
                cover += cur_cell->cover;
            }

            if(area)
            {
                alpha = calculate_alpha((cover << (poly_base_shift + 1)) - area);
                if(alpha)
                {
                    if(tx == x && ty == y) return true;
                }
                x++;
            }

            if(!cur_cell) break;

            if(cur_cell->x > x)
            {
                alpha = calculate_alpha(cover << (poly_base_shift + 1));
                if(alpha)
                {
                    if(ty == y && tx >= x && tx <= cur_cell->x) return true;
                }
            }
        }
        return false;
    }

Here is the call graph for this function:

void agg::rasterizer::line_to ( int  x,
int  y 
) [inline]

Definition at line 664 of file AGG.h.

{ m_outline.line_to(x, y); }

Here is the call graph for this function:

void agg::rasterizer::line_to_d ( double  x,
double  y 
) [inline]

Definition at line 669 of file AGG.h.

                                           { m_outline.line_to(poly_coord(x), 
                                                               poly_coord(y)); }

Here is the call graph for this function:

Here is the caller graph for this function:

int agg::rasterizer::max_x ( ) const [inline]

Definition at line 675 of file AGG.h.

{ return m_outline.max_x(); }

Here is the call graph for this function:

int agg::rasterizer::max_y ( ) const [inline]

Definition at line 676 of file AGG.h.

{ return m_outline.max_y(); }

Here is the call graph for this function:

int agg::rasterizer::min_x ( ) const [inline]

Definition at line 673 of file AGG.h.

{ return m_outline.min_x(); }

Here is the call graph for this function:

int agg::rasterizer::min_y ( ) const [inline]

Definition at line 674 of file AGG.h.

{ return m_outline.min_y(); }

Here is the call graph for this function:

void agg::rasterizer::move_to ( int  x,
int  y 
) [inline]

Definition at line 663 of file AGG.h.

{ m_outline.move_to(x, y); }

Here is the call graph for this function:

void agg::rasterizer::move_to_d ( double  x,
double  y 
) [inline]

Definition at line 667 of file AGG.h.

                                           { m_outline.move_to(poly_coord(x), 
                                                               poly_coord(y)); }

Here is the call graph for this function:

Here is the caller graph for this function:

const rasterizer& agg::rasterizer::operator= ( const rasterizer ) [private]
template<class Renderer >
void agg::rasterizer::render ( Renderer &  r,
const rgba8 c,
int  dx = 0,
int  dy = 0 
) [inline]

Definition at line 697 of file AGG.h.

        {
            const cell* const* cells = m_outline.cells();
            if(m_outline.num_cells() == 0) return;

            int x, y;
            int cover;
            int alpha;
            int area;

            m_scanline.reset(m_outline.min_x(), m_outline.max_x(), dx, dy);

            cover = 0;
            const cell* cur_cell = *cells++;
            for(;;)
            {
                const cell* start_cell = cur_cell;

                int coord  = cur_cell->packed_coord;
                x = cur_cell->x;
                y = cur_cell->y;

                area   = start_cell->area;
                cover += start_cell->cover;

                //accumulate all start cells
                while((cur_cell = *cells++) != 0)
                {
                    if(cur_cell->packed_coord != coord) break;
                    area  += cur_cell->area;
                    cover += cur_cell->cover;
                }

                if(area)
                {
                    alpha = calculate_alpha((cover << (poly_base_shift + 1)) - area);
                    if(alpha)
                    {
                        if(m_scanline.is_ready(y))
                        {
                            r.render(m_scanline, c);
                            m_scanline.reset_spans();
                        }
                        m_scanline.add_cell(x, y, m_gamma[alpha]);
                    }
                    x++;
                }

                if(!cur_cell) break;

                if(cur_cell->x > x)
                {
                    alpha = calculate_alpha(cover << (poly_base_shift + 1));
                    if(alpha)
                    {
                        if(m_scanline.is_ready(y))
                        {
                            r.render(m_scanline, c);
                            m_scanline.reset_spans();
                        }
                        m_scanline.add_span(x, y, 
                                            cur_cell->x - x, 
                                            m_gamma[alpha]);
                    }
                }
            } 
        
            if(m_scanline.num_spans())
            {
                r.render(m_scanline, c);
            }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

void agg::rasterizer::reset ( ) [inline]

Definition at line 650 of file AGG.h.

{ m_outline.reset(); }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 784 of file AGG.h.

Definition at line 785 of file AGG.h.

Definition at line 782 of file AGG.h.

Definition at line 783 of file AGG.h.

const int8u agg::rasterizer::s_default_gamma [static, private]
Initial value:
 
    {
          0,  0,  1,  1,  2,  2,  3,  4,  4,  5,  5,  6,  7,  7,  8,  8,
          9, 10, 10, 11, 11, 12, 13, 13, 14, 14, 15, 16, 16, 17, 18, 18,
         19, 19, 20, 21, 21, 22, 22, 23, 24, 24, 25, 25, 26, 27, 27, 28,
         29, 29, 30, 30, 31, 32, 32, 33, 34, 34, 35, 36, 36, 37, 37, 38,
         39, 39, 40, 41, 41, 42, 43, 43, 44, 45, 45, 46, 47, 47, 48, 49,
         49, 50, 51, 51, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 60,
         60, 61, 62, 62, 63, 64, 65, 65, 66, 67, 68, 68, 69, 70, 71, 71,
         72, 73, 74, 74, 75, 76, 77, 78, 78, 79, 80, 81, 82, 83, 83, 84,
         85, 86, 87, 88, 89, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
        100,101,101,102,103,104,105,106,107,108,109,110,111,112,114,115,
        116,117,118,119,120,121,122,123,124,126,127,128,129,130,131,132,
        134,135,136,137,139,140,141,142,144,145,146,147,149,150,151,153,
        154,155,157,158,159,161,162,164,165,166,168,169,171,172,174,175,
        177,178,180,181,183,184,186,188,189,191,192,194,195,197,199,200,
        202,204,205,207,209,210,212,214,215,217,219,220,222,224,225,227,
        229,230,232,234,236,237,239,241,242,244,246,248,249,251,253,255
    }

Definition at line 786 of file AGG.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines