store Transformer by value in conv_transform

This commit is contained in:
Artem Pavlenko 2012-04-18 09:38:17 +01:00
parent 9af11c5ef2
commit ba270e07f2

View file

@ -29,10 +29,14 @@ namespace agg
template<class VertexSource, class Transformer=trans_affine> class conv_transform template<class VertexSource, class Transformer=trans_affine> class conv_transform
{ {
public: public:
explicit conv_transform(VertexSource& source) :
m_source(&source), m_trans() {}
conv_transform(VertexSource& source, const Transformer& tr) : conv_transform(VertexSource& source, const Transformer& tr) :
m_source(&source), m_trans(&tr) {} m_source(&source), m_trans(tr) {}
void attach(VertexSource& source) { m_source = &source; } void attach(VertexSource& source) { m_source = &source; }
void rewind(unsigned path_id) void rewind(unsigned path_id)
{ {
m_source->rewind(path_id); m_source->rewind(path_id);
@ -43,14 +47,14 @@ namespace agg
unsigned cmd = m_source->vertex(x, y); unsigned cmd = m_source->vertex(x, y);
if(is_vertex(cmd)) if(is_vertex(cmd))
{ {
m_trans->transform(x, y); m_trans.transform(x, y);
} }
return cmd; return cmd;
} }
void transformer(const Transformer& tr) void transformer(const Transformer& tr)
{ {
m_trans = &tr; m_trans = tr;
} }
private: private:
@ -59,7 +63,7 @@ namespace agg
operator = (const conv_transform<VertexSource>&); operator = (const conv_transform<VertexSource>&);
VertexSource* m_source; VertexSource* m_source;
const Transformer* m_trans; Transformer m_trans;
}; };