image - update shallow
constructor to take raw bytes pointer
detail::buffer - inline data() size() methods update unit test
This commit is contained in:
parent
c4e0516ba6
commit
acb8feea01
3 changed files with 8 additions and 29 deletions
|
@ -38,22 +38,16 @@ struct MAPNIK_DECL buffer
|
||||||
buffer(buffer && rhs) noexcept;
|
buffer(buffer && rhs) noexcept;
|
||||||
buffer(buffer const& rhs);
|
buffer(buffer const& rhs);
|
||||||
~buffer();
|
~buffer();
|
||||||
|
|
||||||
buffer& operator=(buffer rhs);
|
buffer& operator=(buffer rhs);
|
||||||
inline bool operator!() const
|
inline bool operator!() const {return (data_ == nullptr)? true : false;}
|
||||||
{
|
inline unsigned char* data() {return data_;}
|
||||||
return (data_ == nullptr)? true : false;
|
inline unsigned char const* data() const {return data_;}
|
||||||
}
|
inline std::size_t size() const {return size_;}
|
||||||
|
|
||||||
void swap(buffer & rhs);
|
|
||||||
unsigned char* data();
|
|
||||||
unsigned char const* data() const;
|
|
||||||
std::size_t size() const;
|
|
||||||
private:
|
private:
|
||||||
|
void swap(buffer & rhs);
|
||||||
std::size_t size_;
|
std::size_t size_;
|
||||||
unsigned char* data_;
|
unsigned char* data_;
|
||||||
bool owns_;
|
bool owns_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <std::size_t max_size>
|
template <std::size_t max_size>
|
||||||
|
@ -97,7 +91,7 @@ public:
|
||||||
bool painted = false);
|
bool painted = false);
|
||||||
image(int width,
|
image(int width,
|
||||||
int height,
|
int height,
|
||||||
detail::buffer && buf,
|
unsigned char* data,
|
||||||
bool premultiplied = false,
|
bool premultiplied = false,
|
||||||
bool painted = false);
|
bool painted = false);
|
||||||
image(image<T> const& rhs);
|
image(image<T> const& rhs);
|
||||||
|
|
|
@ -78,9 +78,9 @@ image<T>::image()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
image<T>::image(int width, int height, detail::buffer && buf, bool premultiplied, bool painted)
|
image<T>::image(int width, int height, unsigned char* data, bool premultiplied, bool painted)
|
||||||
: dimensions_(width, height),
|
: dimensions_(width, height),
|
||||||
buffer_(std::move(buf)),
|
buffer_(data, width * height * sizeof(pixel_size)),
|
||||||
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
pData_(reinterpret_cast<pixel_type*>(buffer_.data())),
|
||||||
offset_(0.0),
|
offset_(0.0),
|
||||||
scaling_(1.0),
|
scaling_(1.0),
|
||||||
|
|
|
@ -82,21 +82,6 @@ void buffer::swap(buffer & rhs)
|
||||||
std::swap(owns_, rhs.owns_);
|
std::swap(owns_, rhs.owns_);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* buffer::data()
|
|
||||||
{
|
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char const* buffer::data() const
|
|
||||||
{
|
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t buffer::size() const
|
|
||||||
{
|
|
||||||
return size_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template struct MAPNIK_DECL image_dimensions<65535>;
|
template struct MAPNIK_DECL image_dimensions<65535>;
|
||||||
|
|
||||||
} // end ns detail
|
} // end ns detail
|
||||||
|
|
Loading…
Reference in a new issue