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,
|
||||
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());
|
||||
int stride = sizeof(typename T2::pixel_type) * im.width();
|
||||
for (unsigned y = 0; y < image.height(); ++y)
|
||||
{
|
||||
typename T2::pixel_type const * row_from = image.getRow(y);
|
||||
|
@ -88,11 +109,12 @@ inline int import_image_data(T2 const& image,
|
|||
}
|
||||
else
|
||||
{
|
||||
#if (WEBP_ENCODER_ABI_VERSION >> 8) >= 1
|
||||
#if (WEBP_ENCODER_ABI_VERSION >> 8) >= 1
|
||||
return WebPPictureImportRGBX(&pic, im.getBytes(), stride);
|
||||
#else
|
||||
#else
|
||||
return WebPPictureImportRGBA(&pic, im.getBytes(), stride);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue