diff --git a/include/mapnik/ctrans.hpp b/include/mapnik/ctrans.hpp index 37e3463ef..bfe761999 100644 --- a/include/mapnik/ctrans.hpp +++ b/include/mapnik/ctrans.hpp @@ -34,21 +34,21 @@ namespace mapnik { template struct MAPNIK_DECL coord_transform { - coord_transform(Transform const& t,Geometry& geom) + coord_transform(Transform const& t, Geometry& geom) : t_(t), geom_(geom) {} - + unsigned vertex(double *x , double *y) const { unsigned command = geom_.vertex(x,y); - *x = t_.forward_x_(x); - *y = t_.forward_y_(y); + t_.forward(x,y); return command; } + void rewind (unsigned pos) { geom_.rewind(pos); } - + private: Transform const& t_; Geometry& geom_; @@ -60,13 +60,13 @@ namespace mapnik { int width; int height; double scale_; - Envelope extent; + Envelope extent_; public: CoordTransform(int width,int height,const Envelope& extent) - :width(width),height(height),extent(extent) + :width(width),height(height),extent_(extent) { - double sx=((double)width)/extent.width(); - double sy=((double)height)/extent.height(); + double sx=((double)width)/extent_.width(); + double sy=((double)height)/extent_.height(); scale_=std::min(sx,sy); } @@ -74,48 +74,29 @@ namespace mapnik { { return scale_; } - - inline void forward_x(double* x) const + + inline void forward(double * x, double * y) const { - *x = (*x - extent.minx() ) * scale_; + + *x = (*x - extent_.minx()) * scale_; + *y = (extent_.maxy() - *y) * scale_; } - - inline void forward_y(double* y) const + + inline void backward(double * x, double * y) const { - *y = (extent.maxy() - *y) * scale_; + *x = extent_.minx() + *x/scale_; + *y = extent_.maxy() - *y/scale_; } - - inline double forward_x_(double* x) const - { - return (*x - extent.minx() ) * scale_; - } - - inline double forward_y_(double* y) const - { - return (extent.maxy() - *y) * scale_; - } - - inline void backward_x(double* x) const - { - *x = extent.minx() + *x/scale_; - } - - inline void backward_y(double* y) const - { - *y = extent.maxy() - *y/scale_; - } - + inline coord2d& forward(coord2d& c) const { - forward_x(&c.x); - forward_y(&c.y); + forward(&c.x,&c.y); return c; } inline coord2d& backward(coord2d& c) const { - backward_x(&c.x); - backward_y(&c.y); + backward(&c.x,&c.y); return c; } @@ -125,10 +106,8 @@ namespace mapnik { double y0 = e.miny(); double x1 = e.maxx(); double y1 = e.maxy(); - forward_x(&x0); - forward_y(&y0); - forward_x(&x1); - forward_y(&y1); + forward(&x0,&y0); + forward(&x1,&y1); return Envelope(x0,y0,x1,y1); } @@ -138,11 +117,8 @@ namespace mapnik { double y0 = e.miny(); double x1 = e.maxx(); double y1 = e.maxy(); - backward_x(&x0); - backward_y(&y0); - backward_x(&x1); - backward_y(&y1); - + backward(&x0,&y0); + backward(&x1,&y1); return Envelope(x0,y0,x1,y1); } diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index f7d5e6855..6550a5357 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -31,7 +31,6 @@ #include // mapnik #include -#include #include #include @@ -83,7 +82,6 @@ namespace mapnik { virtual void label_position(double *x, double *y) const=0; virtual void move_to(value_type x,value_type y)=0; virtual void line_to(value_type x,value_type y)=0; - virtual void transform(const mapnik::CoordTransform& t)=0; virtual unsigned num_points() const = 0; virtual unsigned vertex(double* x, double* y)=0; virtual void rewind(unsigned )=0; @@ -121,13 +119,7 @@ namespace mapnik { } void line_to(value_type ,value_type ) {} - - void transform(const mapnik::CoordTransform& t) - { - t.forward_x(&pt_.x); - t.forward_y(&pt_.y); - } - + unsigned num_points() const { return 1; @@ -193,7 +185,6 @@ namespace mapnik { unsigned i,j; for (i = size-1,j = 0; j < size; i = j, ++j) { - cont_.get_vertex(i,&x0,&y0); cont_.get_vertex(j,&x1,&y1); ai = x0 * y1 - x1 * y0; @@ -221,15 +212,6 @@ namespace mapnik { cont_.push_back(x,y,SEG_MOVETO); } - void transform(mapnik::CoordTransform const& t) - { - unsigned size = cont_.size(); - for (unsigned pos=0; pos < size; ++pos) - { - cont_.transform_at(pos,t); - } - } - unsigned num_points() const { return cont_.size(); @@ -339,16 +321,7 @@ namespace mapnik { { cont_.push_back(x,y,SEG_MOVETO); } - - void transform(mapnik::CoordTransform const& t) - { - unsigned size = cont_.size(); - for (unsigned pos=0; pos < size; ++pos) - { - cont_.transform_at(pos,t); - } - } - + unsigned num_points() const { return cont_.size(); diff --git a/include/mapnik/vertex_transform.hpp b/include/mapnik/vertex_transform.hpp index 420272ec3..6f7469d6a 100644 --- a/include/mapnik/vertex_transform.hpp +++ b/include/mapnik/vertex_transform.hpp @@ -33,34 +33,34 @@ namespace mapnik template struct Shift { - typedef T0 value_type; - typedef T1 return_type; - static return_type apply(value_type val) - { - return static_cast(val*(1<(val*(1< struct Shift { - typedef T0 value_type; - typedef T1 return_type; - static return_type apply(value_type val) - { - return static_cast(val); - } + typedef T0 value_type; + typedef T1 return_type; + static return_type apply(value_type val) + { + return static_cast(val); + } }; template struct Shift { - typedef T value_type; - typedef T return_type; - static T& apply(T& val) - { - return val; - } + typedef T value_type; + typedef T return_type; + static T& apply(T& val) + { + return val; + } }; typedef Shift NO_SHIFT; diff --git a/include/mapnik/vertex_vector.hpp b/include/mapnik/vertex_vector.hpp index 85ce061d4..4e3bb2185 100644 --- a/include/mapnik/vertex_vector.hpp +++ b/include/mapnik/vertex_vector.hpp @@ -110,19 +110,11 @@ namespace mapnik return commands_[block] [pos & block_mask]; } - void transform_at(unsigned pos,const CoordTransform& t) - { - if (pos >= pos_) return; - unsigned block = pos >> block_shift; - value_type* vertex = vertexs_[block] + (( pos & block_mask) << 1); - t.forward_x(vertex); - ++vertex; - t.forward_y(vertex); - } void set_capacity(size_t) { //do nothing } + private: void allocate_block(unsigned block) { @@ -181,13 +173,6 @@ namespace mapnik return cont_.end(); } - void transform_at(unsigned pos,const CoordTransform& t) - { - if (pos >= cont_.size()) return; - vertex_type & c = cont_[pos]; - t.forward_x(&boost::get<0>(c)); - t.forward_y(&boost::get<1>(c)); - } void set_capacity(size_t size) { cont_.reserve(size); diff --git a/src/agg_renderer.cpp b/src/agg_renderer.cpp index 559034bae..0825fd1eb 100644 --- a/src/agg_renderer.cpp +++ b/src/agg_renderer.cpp @@ -96,7 +96,7 @@ namespace mapnik { Color const& bg=m.getBackground(); pixmap_.setBackground(bg); - std::clog << "scale="< @@ -172,7 +172,9 @@ namespace mapnik if (geom && geom->num_points() > 1) { path_type path(t_,*geom); - agg::row_ptr_cache buf(pixmap_.raw_data(),pixmap_.width(),pixmap_.height(), + agg::row_ptr_cache buf(pixmap_.raw_data(), + pixmap_.width(), + pixmap_.height(), pixmap_.width()*4); agg::pixfmt_rgba32 pixf(buf); ren_base renb(pixf); @@ -286,8 +288,7 @@ namespace mapnik if ( data ) { geom->label_position(&x,&y); - t_.forward_x(&x); - t_.forward_y(&y); + t_.forward(&x,&y); int w = data->width(); int h = data->height(); int px=int(floor(x - 0.5 * w)); @@ -435,8 +436,7 @@ namespace mapnik double x; double y; geom->label_position(&x,&y); - t_.forward_x(&x); - t_.forward_y(&y); + t_.forward(&x,&y); face_ptr face = font_manager_.get_face("Bitstream Vera Sans Roman");//TODO //face_ptr face = font_manager_.get_face("Times New Roman Regular");//TODO