make gradient movable

This commit is contained in:
artemp 2015-07-21 14:12:47 +02:00
parent d1b39f5841
commit 43b3770a95
2 changed files with 27 additions and 12 deletions

View file

@ -79,7 +79,8 @@ class MAPNIK_DECL gradient
public:
gradient();
gradient(gradient const& other);
gradient& operator=(const gradient& rhs);
gradient(gradient && other);
gradient& operator=(gradient rhs);
void set_gradient_type(gradient_e grad);
gradient_e get_gradient_type() const;
@ -100,7 +101,7 @@ public:
void get_control_points(double &x1, double &y1, double &x2, double &y2) const;
private:
void swap(const gradient& other) throw();
void swap(gradient& other) throw();
};
}

View file

@ -66,10 +66,20 @@ gradient::gradient(gradient const& other)
units_(other.units_),
gradient_type_(other.gradient_type_) {}
gradient & gradient::operator=(const gradient& rhs)
gradient::gradient(gradient && other)
: transform_(std::move(other.transform_)),
x1_(std::move(other.x1_)),
y1_(std::move(other.y1_)),
x2_(std::move(other.x2_)),
y2_(std::move(other.y2_)),
r_(std::move(other.r_)),
stops_(std::move(other.stops_)),
units_(std::move(other.units_)),
gradient_type_(std::move(other.gradient_type_)) {}
gradient & gradient::operator=(gradient rhs)
{
gradient tmp(rhs);
swap(tmp);
swap(rhs);
return *this;
}
@ -108,7 +118,7 @@ void gradient::add_stop(double offset,mapnik::color const& c)
bool gradient::has_stop() const
{
return ! stops_.empty();
return !stops_.empty();
}
stop_array const& gradient::get_stop_array() const
@ -116,13 +126,17 @@ stop_array const& gradient::get_stop_array() const
return stops_;
}
void gradient::swap(const gradient& other) throw()
void gradient::swap(gradient& other) throw()
{
gradient_type_=other.gradient_type_;
stops_=other.stops_;
units_=other.units_;
transform_=other.transform_;
other.get_control_points(x1_,y1_,x2_,y2_,r_);
std::swap(gradient_type_, other.gradient_type_);
std::swap(stops_, other.stops_);
std::swap(units_, other.units_);
std::swap(transform_, other.transform_);
std::swap(x1_, other.x1_);
std::swap(y1_, other.y1_);
std::swap(x2_, other.x2_);
std::swap(y2_, other.y2_);
std::swap(r_, other.r_);
}
void gradient::set_control_points(double x1, double y1, double x2, double y2, double r)