Skip to content

Commit

Permalink
avoid copy of image data by using new, more efficient mapnik::raster …
Browse files Browse the repository at this point in the history
…constructor - closes #1516
  • Loading branch information
Dane Springmeyer committed Oct 3, 2012
1 parent f4ead94 commit 4bc6b0c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions plugins/input/gdal/gdal_featureset.cpp
Expand Up @@ -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 << ")";
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions plugins/input/raster/raster_featureset.cpp
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 4bc6b0c

Please sign in to comment.