diff options
author | Jonathon Jongsma <jjongsma@gnome.org> | 2008-04-11 11:06:42 -0500 |
---|---|---|
committer | Jonathon Jongsma <jjongsma@gnome.org> | 2008-04-11 11:10:25 -0500 |
commit | e507cb5713c6a16393ffd0af3fe38e99fa71acbc (patch) | |
tree | 15d3659eafd94b00f5a7c2e2155a668dedc97549 | |
parent | 68690df213b8f6e589d6cc9362432d9f41145a36 (diff) |
Wrap cairo_format_stride_for_width()
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | cairomm/surface.cc | 5 | ||||
-rw-r--r-- | cairomm/surface.h | 23 |
3 files changed, 34 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2008-04-11 Jonathon Jongsma <jjongsma@gnome.org> + + * cairomm/surface.cc: + * cairomm/surface.h: wrap cairo_format_stride_for_width() as a static + function in Cairo::ImageSurface + 2008-04-11 Murray Cumming <murrayc@murrayc.com> * Add autoheader to autogen.sh, to create cairommconfig.h.in, to fix diff --git a/cairomm/surface.cc b/cairomm/surface.cc index d3dece5..f7393ac 100644 --- a/cairomm/surface.cc +++ b/cairomm/surface.cc @@ -214,6 +214,11 @@ int ImageSurface::get_stride() const return cairo_image_surface_get_stride(m_cobject); } +int ImageSurface::format_stride_for_width (Cairo::Format format, int width) +{ + return cairo_format_stride_for_width(static_cast<cairo_format_t>(format), width); +} + /******************************************************************************* * THE FOLLOWING SURFACE TYPES ARE EXPERIMENTAL AND NOT FULLY SUPPORTED diff --git a/cairomm/surface.h b/cairomm/surface.h index a6f3404..7043fc0 100644 --- a/cairomm/surface.h +++ b/cairomm/surface.h @@ -295,6 +295,29 @@ public: */ int get_stride() const; + /** + * This function provides a stride value that will respect all + * alignment requirements of the accelerated image-rendering code + * within cairo. Typical usage will be of the form: + * + * @code + * int stride; + * unsigned char *data; + * Cairo::RefPtr<Cairo::ImageSurface> surface; + * + * stride = Cairo::ImageSurface::format_stride_for_width (format, width); + * data = malloc (stride * height); + * surface = Cairo::ImageSurface::create (data, format, width, height); + * @endcode + * + * @param format A Cairo::Format value + * @param width The desired width of an image surface to be created. + * @return the appropriate stride to use given the desired format and width, or + * -1 if either the format is invalid or the width too large. + * + * @since 1.6 + **/ + static int format_stride_for_width (Cairo::Format format, int width); /** Creates an image surface of the specified format and dimensions. The * initial contents of the surface is undefined; you must explicitely clear |