[cairo-commit] cairomm/cairomm context.cc, 1.18, 1.19 context.h,
1.20, 1.21 enums.h, 1.11, 1.12 pattern.cc, 1.10,
1.11 pattern.h, 1.12, 1.13 scaledfont.h, 1.3, 1.4
Murray Cumming
commit at pdx.freedesktop.org
Thu Mar 22 14:21:17 PDT 2007
Committed by: murrayc
Update of /cvs/cairo/cairomm/cairomm
In directory kemper:/tmp/cvs-serv23082/cairomm
Modified Files:
context.cc context.h enums.h pattern.cc pattern.h scaledfont.h
Log Message:
2007-03-22 Murray Cumming <murrayc at murrayc@murrayc.com>
* cairomm/enums.h: Restored FORMAT_RGB16_565 and marked it as deprecated.
Note that CAIRO_FORMAT_RGB16_565 has not really been removed from cairo.
It has just moved from the enum to a #define in cairo-deprecated.
* cairomm/context.cc:
* cairomm/context.h: Made get_dash() const.
Renamed clip_extents() to get_clip_extents(), to match the other get_*_extents() methods
(in Context, if not in other classes), and made it const.
Made copy_clip_rectangle_list() const.
* cairomm/pattern.cc:
* cairomm/pattern.h: Make the RadialGradient::get_radial_circles(), LinearGradient::get_linear_points(),
and Gradient::get_color_stops() methods const.
Added a non-const method overload of get_surface().
Correc the get_color_stops() implementation to match the declaration.
Index: context.cc
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/context.cc,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- context.cc 22 Mar 2007 15:19:46 -0000 1.18
+++ context.cc 22 Mar 2007 21:21:09 -0000 1.19
@@ -405,18 +405,18 @@
check_object_status_and_throw_exception(*this);
}
-void Context::clip_extents(double& x1, double& y1, double& x2, double& y2)
+void Context::get_clip_extents(double& x1, double& y1, double& x2, double& y2) const
{
- cairo_clip_extents(m_cobject, &x1, &y1, &x2, &y2);
+ cairo_clip_extents(const_cast<cairo_t*>(m_cobject), &x1, &y1, &x2, &y2);
check_object_status_and_throw_exception(*this);
}
-void Context::copy_clip_rectangle_list(std::vector<Rectangle>& rectangles)
+void Context::copy_clip_rectangle_list(std::vector<Rectangle>& rectangles) const
{
cairo_rectangle_list_t* c_list = 0;
// 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);
+ c_list = cairo_copy_clip_rectangle_list(const_cast<cairo_t*>(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
// FIXME: do we want to throw an exception if the clip can't be represented by
@@ -433,7 +433,7 @@
void Context::select_font_face(const std::string& family, FontSlant slant, FontWeight weight)
{
- cairo_select_font_face (m_cobject, family.c_str(),
+ cairo_select_font_face(m_cobject, family.c_str(),
static_cast<cairo_font_slant_t>(slant),
static_cast<cairo_font_weight_t>(weight));
check_object_status_and_throw_exception(*this);
@@ -602,14 +602,14 @@
}
void
-Context::get_dash(std::vector<double>& dashes, double& offset)
+Context::get_dash(std::vector<double>& dashes, double& offset) const
{
// 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 compile-time constant...
const int cnt = cairo_get_dash_count(m_cobject);
double dash_array[cnt];
- cairo_get_dash(m_cobject, dash_array, &offset);
+ cairo_get_dash(const_cast<cairo_t*>(m_cobject), dash_array, &offset);
check_object_status_and_throw_exception(*this);
dashes.assign(dash_array, dash_array + cnt);
}
@@ -683,11 +683,12 @@
{
cairo_surface_t* surface = cairo_get_group_target(m_cobject);
// surface can be NULL if you're not between push/pop group calls
- if (surface == NULL)
+ if(!surface)
{
// FIXME: is this really the right way to handle this?
throw_exception(CAIRO_STATUS_NULL_POINTER);
}
+
return RefPtr<Surface>(new Surface(surface, false));
}
@@ -695,11 +696,12 @@
{
cairo_surface_t* surface = cairo_get_group_target(m_cobject);
// surface can be NULL if you're not between push/pop group calls
- if (surface == NULL)
+ if(!surface)
{
// FIXME: is this really the right way to handle this?
throw_exception(CAIRO_STATUS_NULL_POINTER);
}
+
return RefPtr<const Surface>(new Surface(surface, false));
}
Index: context.h
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/context.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- context.h 21 Mar 2007 20:56:39 -0000 1.20
+++ context.h 22 Mar 2007 21:21:09 -0000 1.21
@@ -683,7 +683,7 @@
*
* @since 1.4
**/
- void clip_extents(double& x1, double& y1, double& x2, double& y2);
+ void get_clip_extents(double& x1, double& y1, double& x2, double& y2) const;
/**
* Returns the current clip region as a list of rectangles in user coordinates.
@@ -693,7 +693,7 @@
*
* @Since 1.4
**/
- void copy_clip_rectangle_list(std::vector<Rectangle>& rectangles);
+ void copy_clip_rectangle_list(std::vector<Rectangle>& rectangles) const;
void select_font_face(const std::string& family, FontSlant slant, FontWeight weight);
void set_font_size(double size);
@@ -772,7 +772,7 @@
*
* Since: 1.4
**/
- void get_dash(std::vector<double>& dashes, double& offset);
+ void get_dash(std::vector<double>& dashes, double& offset) const;
/** Stores the current transformation matrix (CTM) into matrix.
Index: enums.h
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/enums.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- enums.h 21 Mar 2007 20:56:39 -0000 1.11
+++ enums.h 22 Mar 2007 21:21:09 -0000 1.12
@@ -110,9 +110,8 @@
FORMAT_ARGB32 = CAIRO_FORMAT_ARGB32,
FORMAT_RGB24 = CAIRO_FORMAT_RGB24,
FORMAT_A8 = CAIRO_FORMAT_A8,
- FORMAT_A1 = CAIRO_FORMAT_A1
- // this enumeration has been deprecated
- //FORMAT_RGB16_565 = CAIRO_FORMAT_RGB16_565
+ FORMAT_A1 = CAIRO_FORMAT_A1,
+ FORMAT_RGB16_565 = CAIRO_FORMAT_RGB16_565 /* @< @deprecated This format value is deprecated. It has never been properly implemented in cairo and is unnecessary. */
} Format;
Index: pattern.cc
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/pattern.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- pattern.cc 22 Mar 2007 15:19:46 -0000 1.10
+++ pattern.cc 22 Mar 2007 21:21:09 -0000 1.11
@@ -78,7 +78,7 @@
{
}
void
-SolidPattern::get_rgba (double& red, double& green,
+SolidPattern::get_rgba(double& red, double& green,
double& blue, double& alpha) const
{
// ignore the return value since we know that this is a solid color pattern
@@ -112,7 +112,7 @@
}
RefPtr<Surface>
-SurfacePattern::get_surface () const
+SurfacePattern::get_surface()
{
cairo_surface_t* surface = 0;
// we can ignore the return value since we know this is a surface pattern
@@ -121,6 +121,12 @@
return RefPtr<Surface>(new Surface(surface, false /* does not have reference */));
}
+RefPtr<const Surface>
+SurfacePattern::get_surface() const
+{
+ return const_cast<SurfacePattern*>(this)->get_surface();
+}
+
RefPtr<SurfacePattern> SurfacePattern::create(const RefPtr<Surface>& surface)
{
return RefPtr<SurfacePattern>(new SurfacePattern(surface));
@@ -188,27 +194,24 @@
check_object_status_and_throw_exception(*this);
}
-void
-Gradient::get_color_stops (std::vector<ColorStop>& stops)
+std::vector<ColorStop>
+Gradient::get_color_stops() const
{
- // 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 ();
+ std::vector<ColorStop> stops;
- int num_stops;
+ int num_stops = 0;
// 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 by pre-allocating the required number
stops.reserve(num_stops);
- for (int i = 0; i < num_stops; ++i)
+ for(int i = 0; i < num_stops; ++i)
{
ColorStop stop;
cairo_pattern_get_color_stop_rgba(m_cobject, i, &stop.offset, &stop.red,
&stop.green, &stop.blue, &stop.alpha);
stops.push_back(stop);
}
- return stops;
}
@@ -219,7 +222,7 @@
}
void
-LinearGradient::get_linear_points (double &x0, double &y0,
+LinearGradient::get_linear_points(double &x0, double &y0,
double &x1, double &y1) const
{
// ignore the return value since we know that this is a linear gradient
@@ -251,12 +254,12 @@
}
void
-RadialGradient::get_radial_circles (double& x0, double& y0, double& r0,
+RadialGradient::get_radial_circles(double& x0, double& y0, double& r0,
double& x1, double& y1, double& r1) const
{
// ignore the return value since we know that this is a radial gradient
// pattern
- cairo_pattern_get_radial_circles (const_cast<cairo_pattern_t*>(m_cobject),
+ cairo_pattern_get_radial_circles(const_cast<cairo_pattern_t*>(m_cobject),
&x0, &y0, &r0, &x1, &y1, &r1);
check_object_status_and_throw_exception(*this);
}
Index: pattern.h
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/pattern.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- pattern.h 21 Mar 2007 20:56:39 -0000 1.12
+++ pattern.h 22 Mar 2007 21:21:09 -0000 1.13
@@ -101,7 +101,10 @@
void get_rgba (double& red, double& green,
double& blue, double& alpha) const;
+ //TODO: Documentation
static RefPtr<SolidPattern> create_rgb(double red, double green, double blue);
+
+ //TODO: Documentation
static RefPtr<SolidPattern> create_rgba(double red, double green,
double blue, double alpha);
@@ -130,7 +133,14 @@
*
* @since 1.4
**/
- RefPtr<Surface> get_surface () const;
+ RefPtr<const Surface> get_surface () const;
+
+ /**
+ * Gets the surface associated with this pattern
+ *
+ * @since 1.4
+ **/
+ RefPtr<Surface> get_surface ();
virtual ~SurfacePattern();
@@ -197,7 +207,7 @@
*
* @since 1.4
*/
- std::vector<ColorStop> get_color_stops ();
+ std::vector<ColorStop> get_color_stops() const;
protected:
@@ -228,7 +238,7 @@
*
* @since 1.4
**/
- void get_linear_points (double &x0, double &y0,
+ void get_linear_points(double &x0, double &y0,
double &x1, double &y1) const;
//TODO?: LinearGradient(cairo_pattern_t *target);
@@ -264,7 +274,7 @@
*
* @since 1.4
**/
- void get_radial_circles (double& x0, double& y0, double& r0,
+ void get_radial_circles(double& x0, double& y0, double& r0,
double& x1, double& y1, double& r1) const;
//TODO?: RadialGradient(cairo_pattern_t *target);
Index: scaledfont.h
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/scaledfont.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- scaledfont.h 5 Jul 2006 15:17:21 -0000 1.3
+++ scaledfont.h 22 Mar 2007 21:21:09 -0000 1.4
@@ -77,9 +77,11 @@
static RefPtr<ScaledFont> create(FontFace& font_face, const Matrix& font_matrix,
const Matrix& ctm, const FontOptions& options);
+ //TODO: This should really be get_extents().
/** Gets the metrics for a ScaledFont */
void extents(FontExtents& extents) const;
+ //TODO: This should really be get_text_extents().
/** Gets the extents for a string of text. The extents describe a user-space
* rectangle that encloses the "inked" portion of the text drawn at the origin
* (0,0) (as it would be drawn by Context::show_text() if the cairo graphics
@@ -102,6 +104,7 @@
*/
void text_extents(const std::string& utf8, TextExtents& extents) const;
+ //TODO: This should really be get_glyph_extents().
/** Gets the extents for an array of glyphs. The extents describe a user-space
* rectangle that encloses the "inked" portion of the glyphs, (as they would
* be drawn by Context::show_glyphs() if the cairo graphics state were set to the
More information about the cairo-commit
mailing list