Skip to content
Browse files

avoid copy of image data by using new, more efficient mapnik::raster …

…constructor - closes #1516
  • Loading branch information...
1 parent f4ead94 commit 4bc6b0c800fd29bc4181888bf30fc3f137acc346 @springmeyer springmeyer committed Oct 3, 2012
Showing with 9 additions and 5 deletions.
  1. +2 −0 CHANGELOG.md
  2. +3 −2 plugins/input/gdal/gdal_featureset.cpp
  3. +4 −3 plugins/input/raster/raster_featureset.cpp
View
2 CHANGELOG.md
@@ -8,6 +8,8 @@ For a complete change history, see the git log.
## Future
+- Faster rendering of rasters by reducing memory allocation of temporary buffers (#1516)
+
- Added ability to pass a pre-created collision detector to the cairo renderer (#1444)
- Tolerance parameter is now supported for querying datasources at a given point (#503/#1499)
View
5 plugins/input/gdal/gdal_featureset.cpp
@@ -223,7 +223,8 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
if (im_width > 0 && im_height > 0)
{
- mapnik::image_data_32 image(im_width, im_height);
+ mapnik::raster_ptr raster = boost::make_shared<mapnik::raster>(intersect, im_width, im_height);
+ mapnik::image_data_32 & image = raster->data_;
image.set(0xffffffff);
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Image Size=(" << im_width << "," << im_height << ")";
@@ -489,7 +490,7 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
image.width(), image.height(), GDT_Byte, 4, 4 * image.width());
}
- feature->set_raster(boost::make_shared<mapnik::raster>(intersect, image));
+ feature->set_raster(raster);
}
return feature;
}
View
7 plugins/input/raster/raster_featureset.cpp
@@ -111,9 +111,10 @@ feature_ptr raster_featureset<LookupPolicy>::next()
rem.maxy() + y_off + height);
intersect = t.backward(feature_raster_extent);
- image_data_32 image(width,height);
- reader->read(x_off, y_off, image);
- feature->set_raster(boost::make_shared<raster>(intersect, image,reader->premultiplied_alpha()));
+ mapnik::raster_ptr raster = boost::make_shared<mapnik::raster>(intersect, width, height);
+ reader->read(x_off, y_off, raster->data_);
+ raster->premultiplied_alpha_ = reader->premultiplied_alpha();
+ feature->set_raster(raster);
}
}
}

0 comments on commit 4bc6b0c

Please sign in to comment.
Something went wrong with that request. Please try again.