optimize case where image_view is used but is not a subset - refs #2024
This commit is contained in:
parent
44807673a3
commit
90dd6b9d61
1 changed files with 38 additions and 16 deletions
|
@ -73,9 +73,30 @@ inline int import_image_data(T2 const& image,
|
||||||
WebPPicture & pic,
|
WebPPicture & pic,
|
||||||
bool alpha)
|
bool alpha)
|
||||||
{
|
{
|
||||||
// Reason for copy: https://github.com/mapnik/mapnik/issues/2024
|
ImageData<typename T2::pixel_type> const& data = image.data();
|
||||||
|
int stride = sizeof(typename T2::pixel_type) * image.width();
|
||||||
|
if (data.width() == image.width() &&
|
||||||
|
data.height() == image.height())
|
||||||
|
{
|
||||||
|
std::clog << "opt\n";
|
||||||
|
if (alpha)
|
||||||
|
{
|
||||||
|
return WebPPictureImportRGBA(&pic, data.getBytes(), stride);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if (WEBP_ENCODER_ABI_VERSION >> 8) >= 1
|
||||||
|
return WebPPictureImportRGBX(&pic, data.getBytes(), stride);
|
||||||
|
#else
|
||||||
|
return WebPPictureImportRGBA(&pic, data.getBytes(), stride);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// need to copy: https://github.com/mapnik/mapnik/issues/2024
|
||||||
|
std::clog << "copy\n";
|
||||||
image_data_32 im(image.width(),image.height());
|
image_data_32 im(image.width(),image.height());
|
||||||
int stride = sizeof(typename T2::pixel_type) * im.width();
|
|
||||||
for (unsigned y = 0; y < image.height(); ++y)
|
for (unsigned y = 0; y < image.height(); ++y)
|
||||||
{
|
{
|
||||||
typename T2::pixel_type const * row_from = image.getRow(y);
|
typename T2::pixel_type const * row_from = image.getRow(y);
|
||||||
|
@ -95,6 +116,7 @@ inline int import_image_data(T2 const& image,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline int import_image_data(image_data_32 const& im,
|
inline int import_image_data(image_data_32 const& im,
|
||||||
|
|
Loading…
Reference in a new issue