diff options
author | Jonathon Jongsma <jjongsma@gnome.org> | 2007-03-22 15:19:46 +0000 |
---|---|---|
committer | Jonathon Jongsma <jjongsma@gnome.org> | 2007-03-22 15:19:46 +0000 |
commit | 5928d59affa1f72ca92b6748f3334f11ae603cc7 (patch) | |
tree | 95cb50c5561952450cbaad430e48f538fa36eddb | |
parent | 0979205a3e0b8b6c36f62a211d19c7c1be9cf711 (diff) |
2007-03-22 Jonathon Jongsma <jjongsma@gnome.org>
* cairomm/context.cc: Minor comment cleanups
* cairomm/pattern.cc: get the gradient stops by reference parameter instead
of returning by value. This saves an extra copy of the vector.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | cairomm/context.cc | 6 | ||||
-rw-r--r-- | cairomm/pattern.cc | 13 |
3 files changed, 16 insertions, 9 deletions
@@ -1,3 +1,9 @@ +2007-03-22 Jonathon Jongsma <jjongsma@gnome.org> + + * cairomm/context.cc: Minor comment cleanups + * cairomm/pattern.cc: get the gradient stops by reference parameter instead + of returning by value. This saves an extra copy of the vector. + 2007-03-21 Jonathon Jongsma <jjongsma@gnome.org> * cairomm/context.cc: diff --git a/cairomm/context.cc b/cairomm/context.cc index b9ac881..271f7a5 100644 --- a/cairomm/context.cc +++ b/cairomm/context.cc @@ -414,8 +414,8 @@ void Context::clip_extents(double& x1, double& y1, double& x2, double& y2) void Context::copy_clip_rectangle_list(std::vector<Rectangle>& rectangles) { cairo_rectangle_list_t* c_list = 0; - // FIXME: It would be nice if the cairo interface didn't copy it into a - // C array first and just let us do the copying... + // It would be nice if the cairo interface didn't copy it into a C array first + // and just let us do the copying... c_list = cairo_copy_clip_rectangle_list(m_cobject); // the rectangle list contains a status field that we need to check and the // cairo context also has a status that we need to check @@ -606,7 +606,7 @@ Context::get_dash(std::vector<double>& dashes, double& offset) { // FIXME: do we need to allocate this array dynamically? I seem to remember // some compilers have trouble with allocating arrays on the stack when the - // array size isn't a compiler constant... + // array size isn't a compile-time constant... const int cnt = cairo_get_dash_count(m_cobject); double dash_array[cnt]; cairo_get_dash(m_cobject, dash_array, &offset); diff --git a/cairomm/pattern.cc b/cairomm/pattern.cc index 3c30948..c1bb3f8 100644 --- a/cairomm/pattern.cc +++ b/cairomm/pattern.cc @@ -188,17 +188,18 @@ void Gradient::add_color_stop_rgba(double offset, double red, double green, doub check_object_status_and_throw_exception(*this); } -std::vector<ColorStop> -Gradient::get_color_stops () +void +Gradient::get_color_stops (std::vector<ColorStop>& stops) { - // we could save a copy here by returning it as an output reference parameter - // instead of returning the array by value. - std::vector<ColorStop> stops; + // clear any existing values from the passed array since we'll be adding them + // on to the end of the array one-by-one + stops.clear (); + int num_stops; // we can ignore the return value since we know this is a gradient pattern cairo_pattern_get_color_stop_count(m_cobject, &num_stops); // since we know the total number of stops, we can avoid re-allocation with - // each addition to the vector + // each addition to the vector by pre-allocating the required number stops.reserve(num_stops); for (int i = 0; i < num_stops; ++i) { |