diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 533a05655..deb302267 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -58,7 +58,9 @@ namespace mapnik const unsigned int *in_end = in_ptr + pixels; unsigned int *out_ptr; - out_ptr = data_ = new unsigned int[pixels]; + surface_ = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, data.width(), data.height()); + + out_ptr = reinterpret_cast(surface_->get_data()); while (in_ptr < in_end) { @@ -74,14 +76,13 @@ namespace mapnik *out_ptr++ = (a << 24) | (r << 16) | (g << 8) | b; } - - surface_ = Cairo::ImageSurface::create(reinterpret_cast(data_), Cairo::FORMAT_ARGB32, data.width(), data.height(), data.width() * 4); + // mark the surface as dirty as we've modified it behind cairo's back + surface_->mark_dirty(); pattern_ = Cairo::SurfacePattern::create(surface_); } ~cairo_pattern(void) { - delete [] data_; } void set_matrix(Cairo::Matrix const& matrix) @@ -117,7 +118,6 @@ namespace mapnik } private: - unsigned int *data_; Cairo::RefPtr surface_; Cairo::RefPtr pattern_; };