summaryrefslogtreecommitdiff
path: root/cairomm
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2016-12-07 11:41:41 +0100
committerMurray Cumming <murrayc@murrayc.com>2016-12-07 11:50:56 +0100
commit3bf93d7303811b98b76270c9faf6706a43053b63 (patch)
tree87dce4a602d443c0d4c01effc587f14046840b5b /cairomm
parent6d2efa707f33cc70e8c33da901b598efd0465e1d (diff)
Add and use make_refptr_for_instance().
Diffstat (limited to 'cairomm')
-rw-r--r--cairomm/context.cc32
-rw-r--r--cairomm/context_surface_quartz.cc4
-rw-r--r--cairomm/context_surface_win32.cc4
-rw-r--r--cairomm/context_surface_xlib.cc4
-rw-r--r--cairomm/fontface.cc18
-rw-r--r--cairomm/fontface.h2
-rw-r--r--cairomm/pattern.cc12
-rw-r--r--cairomm/quartz_font.cc4
-rw-r--r--cairomm/quartz_surface.cc4
-rw-r--r--cairomm/refptr.h8
-rw-r--r--cairomm/region.cc10
-rw-r--r--cairomm/scaledfont.cc6
-rw-r--r--cairomm/script.cc4
-rw-r--r--cairomm/script_surface.cc4
-rw-r--r--cairomm/surface.cc34
-rw-r--r--cairomm/win32_font.cc8
-rw-r--r--cairomm/win32_surface.cc8
-rw-r--r--cairomm/xlib_surface.cc6
18 files changed, 89 insertions, 83 deletions
diff --git a/cairomm/context.cc b/cairomm/context.cc
index 5f761d1..02336cd 100644
--- a/cairomm/context.cc
+++ b/cairomm/context.cc
@@ -51,7 +51,7 @@ Context::Context(const RefPtr<Surface>& target)
RefPtr<Context> Context::create(const RefPtr<Surface>& target)
{
- return RefPtr<Context>(new Context(target));
+ return make_refptr_for_instance<Context>(new Context(target));
}
Context::Context(cairo_t* cobject, bool has_reference)
@@ -511,7 +511,7 @@ RefPtr<ScaledFont> Context::get_scaled_font()
{
auto font = cairo_get_scaled_font(cobj());
check_object_status_and_throw_exception(*this);
- return RefPtr<ScaledFont>(new ScaledFont(font, false /* does not have reference */));
+ return make_refptr_for_instance<ScaledFont>(new ScaledFont(font, false /* does not have reference */));
}
void Context::show_text(const std::string& utf8)
@@ -546,14 +546,14 @@ RefPtr<FontFace> Context::get_font_face()
{
auto cfontface = cairo_get_font_face(cobj());
check_object_status_and_throw_exception(*this);
- return RefPtr<FontFace>(new FontFace(cfontface, false /* does not have reference */));
+ return make_refptr_for_instance<FontFace>(new FontFace(cfontface, false /* does not have reference */));
}
RefPtr<const FontFace> Context::get_font_face() const
{
auto cfontface = cairo_get_font_face(const_cast<cobject*>(cobj()));
check_object_status_and_throw_exception(*this);
- return RefPtr<const FontFace>(new FontFace(cfontface, false /* does not have reference */));
+ return make_refptr_for_instance<const FontFace>(new FontFace(cfontface, false /* does not have reference */));
}
void Context::get_font_extents(FontExtents& extents) const
@@ -610,19 +610,19 @@ static RefPtr<Pattern> get_pattern_wrapper (cairo_pattern_t* pattern)
switch (pattern_type)
{
case CAIRO_PATTERN_TYPE_SOLID:
- return RefPtr<SolidPattern>(new SolidPattern(pattern, false /* does not have reference */));
+ return make_refptr_for_instance<SolidPattern>(new SolidPattern(pattern, false /* does not have reference */));
break;
case CAIRO_PATTERN_TYPE_SURFACE:
- return RefPtr<SurfacePattern>(new SurfacePattern(pattern, false /* does not have reference */));
+ return make_refptr_for_instance<SurfacePattern>(new SurfacePattern(pattern, false /* does not have reference */));
break;
case CAIRO_PATTERN_TYPE_LINEAR:
- return RefPtr<LinearGradient>(new LinearGradient(pattern, false /* does not have reference */));
+ return make_refptr_for_instance<LinearGradient>(new LinearGradient(pattern, false /* does not have reference */));
break;
case CAIRO_PATTERN_TYPE_RADIAL:
- return RefPtr<RadialGradient>(new RadialGradient(pattern, false /* does not have reference */));
+ return make_refptr_for_instance<RadialGradient>(new RadialGradient(pattern, false /* does not have reference */));
break;
default:
- return RefPtr<Pattern>(new Pattern(pattern, false /* does not have reference */));
+ return make_refptr_for_instance<Pattern>(new Pattern(pattern, false /* does not have reference */));
}
}
@@ -735,16 +735,16 @@ RefPtr<Surface> get_surface_wrapper (cairo_surface_t* surface)
switch (surface_type)
{
case CAIRO_SURFACE_TYPE_IMAGE:
- return RefPtr<ImageSurface>(new ImageSurface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<ImageSurface>(new ImageSurface(surface, false /* does not have reference */));
break;
#if CAIRO_HAS_PDF_SURFACE
case CAIRO_SURFACE_TYPE_PDF:
- return RefPtr<PdfSurface>(new PdfSurface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<PdfSurface>(new PdfSurface(surface, false /* does not have reference */));
break;
#endif
#if CAIRO_HAS_PS_SURFACE
case CAIRO_SURFACE_TYPE_PS:
- return RefPtr<PsSurface>(new PsSurface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<PsSurface>(new PsSurface(surface, false /* does not have reference */));
break;
#endif
#if CAIRO_HAS_XLIB_SURFACE
@@ -754,7 +754,7 @@ RefPtr<Surface> get_surface_wrapper (cairo_surface_t* surface)
#endif
#if CAIRO_HAS_GLITZ_SURFACE
case CAIRO_SURFACE_TYPE_GLITZ:
- return RefPtr<GlitzSurface>(new GlitzSurface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<GlitzSurface>(new GlitzSurface(surface, false /* does not have reference */));
break;
#endif
#if CAIRO_HAS_QUARTZ_SURFACE
@@ -764,7 +764,7 @@ RefPtr<Surface> get_surface_wrapper (cairo_surface_t* surface)
#endif
#if CAIRO_HAS_SCRIPT_SURFACE
case CAIRO_SURFACE_TYPE_SCRIPT:
- return RefPtr<ScriptSurface>(new ScriptSurface(surface, false));
+ return make_refptr_for_instance<ScriptSurface>(new ScriptSurface(surface, false));
break;
#endif
#if CAIRO_HAS_WIN32_SURFACE
@@ -774,7 +774,7 @@ RefPtr<Surface> get_surface_wrapper (cairo_surface_t* surface)
#endif
#if CAIRO_HAS_SVG_SURFACE
case CAIRO_SURFACE_TYPE_SVG:
- return RefPtr<SvgSurface>(new SvgSurface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<SvgSurface>(new SvgSurface(surface, false /* does not have reference */));
break;
#endif
// the following surfaces are not directly supported in cairomm yet
@@ -783,7 +783,7 @@ RefPtr<Surface> get_surface_wrapper (cairo_surface_t* surface)
case CAIRO_SURFACE_TYPE_BEOS:
case CAIRO_SURFACE_TYPE_XCB:
default:
- return RefPtr<Surface>(new Surface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<Surface>(new Surface(surface, false /* does not have reference */));
}
}
diff --git a/cairomm/context_surface_quartz.cc b/cairomm/context_surface_quartz.cc
index face06d..aa09763 100644
--- a/cairomm/context_surface_quartz.cc
+++ b/cairomm/context_surface_quartz.cc
@@ -29,9 +29,9 @@ namespace Private
RefPtr<Surface> wrap_surface_quartz(cairo_surface_t* surface)
{
#if CAIRO_HAS_QUARTZ_SURFACE
- return RefPtr<QuartzSurface>(new QuartzSurface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<QuartzSurface>(new QuartzSurface(surface, false /* does not have reference */));
#else
- return RefPtr<Surface>(new Surface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<Surface>(new Surface(surface, false /* does not have reference */));
#endif
}
diff --git a/cairomm/context_surface_win32.cc b/cairomm/context_surface_win32.cc
index 845d5d1..6c520bb 100644
--- a/cairomm/context_surface_win32.cc
+++ b/cairomm/context_surface_win32.cc
@@ -29,9 +29,9 @@ namespace Private
RefPtr<Surface> wrap_surface_win32(cairo_surface_t* surface)
{
#if CAIRO_HAS_WIN32_SURFACE
- return RefPtr<Win32Surface>(new Win32Surface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<Win32Surface>(new Win32Surface(surface, false /* does not have reference */));
#else
- return RefPtr<Surface>(new Surface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<Surface>(new Surface(surface, false /* does not have reference */));
#endif
}
diff --git a/cairomm/context_surface_xlib.cc b/cairomm/context_surface_xlib.cc
index 9834f26..846d13e 100644
--- a/cairomm/context_surface_xlib.cc
+++ b/cairomm/context_surface_xlib.cc
@@ -29,9 +29,9 @@ namespace Private
RefPtr<Surface> wrap_surface_xlib(cairo_surface_t* surface)
{
#if CAIRO_HAS_XLIB_SURFACE
- return RefPtr<XlibSurface>(new XlibSurface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<XlibSurface>(new XlibSurface(surface, false /* does not have reference */));
#else
- return RefPtr<Surface>(new Surface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<Surface>(new Surface(surface, false /* does not have reference */));
#endif
}
diff --git a/cairomm/fontface.cc b/cairomm/fontface.cc
index fc29636..caa2e81 100644
--- a/cairomm/fontface.cc
+++ b/cairomm/fontface.cc
@@ -83,7 +83,7 @@ FontType FontFace::get_type() const
RefPtr<ToyFontFace>
ToyFontFace::create(const std::string& family, FontSlant slant, FontWeight weight)
{
- return RefPtr<ToyFontFace>(new ToyFontFace(family, slant, weight));
+ return make_refptr_for_instance<ToyFontFace>(new ToyFontFace(family, slant, weight));
}
ToyFontFace::ToyFontFace(const std::string& family, FontSlant slant, FontWeight weight) :
@@ -142,8 +142,8 @@ UserFontFace::init_cb(cairo_scaled_font_t* scaled_font,
{
try
{
- return instance->init(RefPtr<ScaledFont>(new ScaledFont(scaled_font)),
- RefPtr<Context>(new Context(cr)),
+ return instance->init(make_refptr_for_instance<ScaledFont>(new ScaledFont(scaled_font)),
+ make_refptr_for_instance<Context>(new Context(cr)),
static_cast<FontExtents&>(*metrics));
}
catch(const std::exception& ex)
@@ -189,7 +189,7 @@ UserFontFace::unicode_to_glyph_cb(cairo_scaled_font_t *scaled_font,
{
try
{
- return instance->unicode_to_glyph(RefPtr<ScaledFont>(new ScaledFont(scaled_font)),
+ return instance->unicode_to_glyph(make_refptr_for_instance<ScaledFont>(new ScaledFont(scaled_font)),
unicode, *glyph);
}
catch(const std::exception& ex)
@@ -242,7 +242,7 @@ UserFontFace::text_to_glyphs_cb(cairo_scaled_font_t *scaled_font,
auto local_flags = static_cast<TextClusterFlags>(0);
auto status =
- instance->text_to_glyphs(RefPtr<ScaledFont>(new
+ instance->text_to_glyphs(make_refptr_for_instance<ScaledFont>(new
ScaledFont(scaled_font)),
utf8_str, glyph_v, cluster_v, local_flags);
@@ -335,8 +335,8 @@ UserFontFace::render_glyph_cb(cairo_scaled_font_t *scaled_font,
{
try
{
- return instance->render_glyph(RefPtr<ScaledFont>(new ScaledFont(scaled_font)),
- glyph, RefPtr<Context>(new Context(cr)),
+ return instance->render_glyph(make_refptr_for_instance<ScaledFont>(new ScaledFont(scaled_font)),
+ glyph, make_refptr_for_instance<Context>(new Context(cr)),
static_cast<TextExtents&>(*metrics));
}
catch(const std::exception& ex)
@@ -380,7 +380,7 @@ UserFontFace::~UserFontFace()
RefPtr<FtFontFace>
FtFontFace::create(FT_Face face, int load_flags)
{
- return RefPtr<FtFontFace>(new FtFontFace(face, load_flags));
+ return make_refptr_for_instance<FtFontFace>(new FtFontFace(face, load_flags));
}
FtFontFace::FtFontFace(FT_Face face, int load_flags) :
@@ -394,7 +394,7 @@ FtFontFace::FtFontFace(FT_Face face, int load_flags) :
RefPtr<FtFontFace>
FtFontFace::create(FcPattern* pattern)
{
- return RefPtr<FtFontFace>(new FtFontFace(pattern));
+ return make_refptr_for_instance<FtFontFace>(new FtFontFace(pattern));
}
FtFontFace::FtFontFace(FcPattern* pattern) :
diff --git a/cairomm/fontface.h b/cairomm/fontface.h
index 4243b09..902cf71 100644
--- a/cairomm/fontface.h
+++ b/cairomm/fontface.h
@@ -164,7 +164,7 @@ protected:
*
* public:
* static Cairo::RefPtr<MyUserFont> create() {
- * return Cairo::RefPtr<MyUserFont>(new MyUserFont);
+ * return Cairo::make_refptr_for_instance<MyUserFont>(new MyUserFont);
*
* protected:
* // implement render_glyph() and any other virtual functions you want to override
diff --git a/cairomm/pattern.cc b/cairomm/pattern.cc
index e6ab2e6..4834ad7 100644
--- a/cairomm/pattern.cc
+++ b/cairomm/pattern.cc
@@ -114,14 +114,14 @@ RefPtr<SolidPattern> SolidPattern::create_rgb(double red, double green, double b
{
auto cobject = cairo_pattern_create_rgb(red, green, blue);
check_status_and_throw_exception(cairo_pattern_status(cobject));
- return RefPtr<SolidPattern>(new SolidPattern(cobject, true /* has reference */));
+ return make_refptr_for_instance<SolidPattern>(new SolidPattern(cobject, true /* has reference */));
}
RefPtr<SolidPattern> SolidPattern::create_rgba(double red, double green, double blue, double alpha)
{
cairo_pattern_t* cobject = cairo_pattern_create_rgba(red, green, blue, alpha);
check_status_and_throw_exception(cairo_pattern_status(cobject));
- return RefPtr<SolidPattern>(new SolidPattern(cobject, true /* has reference */));
+ return make_refptr_for_instance<SolidPattern>(new SolidPattern(cobject, true /* has reference */));
}
@@ -138,7 +138,7 @@ SurfacePattern::get_surface()
// we can ignore the return value since we know this is a surface pattern
cairo_pattern_get_surface(const_cast<cairo_pattern_t*>(m_cobject), &surface);
check_object_status_and_throw_exception(*this);
- return RefPtr<Surface>(new Surface(surface, false /* does not have reference */));
+ return make_refptr_for_instance<Surface>(new Surface(surface, false /* does not have reference */));
}
RefPtr<const Surface>
@@ -149,7 +149,7 @@ SurfacePattern::get_surface() const
RefPtr<SurfacePattern> SurfacePattern::create(const RefPtr<Surface>& surface)
{
- return RefPtr<SurfacePattern>(new SurfacePattern(surface));
+ return make_refptr_for_instance<SurfacePattern>(new SurfacePattern(surface));
}
SurfacePattern::SurfacePattern(cairo_pattern_t* cobject, bool has_reference)
@@ -242,7 +242,7 @@ LinearGradient::get_linear_points(double &x0, double &y0,
RefPtr<LinearGradient> LinearGradient::create(double x0, double y0, double x1, double y1)
{
- return RefPtr<LinearGradient>(new LinearGradient(x0, y0, x1, y1));
+ return make_refptr_for_instance<LinearGradient>(new LinearGradient(x0, y0, x1, y1));
}
LinearGradient::LinearGradient(cairo_pattern_t* cobject, bool has_reference)
@@ -275,7 +275,7 @@ RadialGradient::get_radial_circles(double& x0, double& y0, double& r0,
RefPtr<RadialGradient> RadialGradient::create(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1)
{
- return RefPtr<RadialGradient>(new RadialGradient(cx0, cy0, radius0, cx1, cy1, radius1));
+ return make_refptr_for_instance<RadialGradient>(new RadialGradient(cx0, cy0, radius0, cx1, cy1, radius1));
}
RadialGradient::RadialGradient(cairo_pattern_t* cobject, bool has_reference)
diff --git a/cairomm/quartz_font.cc b/cairomm/quartz_font.cc
index 662d941..b30d1c5 100644
--- a/cairomm/quartz_font.cc
+++ b/cairomm/quartz_font.cc
@@ -32,7 +32,7 @@ QuartzFontFace::QuartzFontFace(CGFontRef font) :
RefPtr<QuartzFontFace> QuartzFontFace::create(CGFontRef font)
{
- return RefPtr<QuartzFontFace>(new QuartzFontFace(font));
+ return make_refptr_for_instance<QuartzFontFace>(new QuartzFontFace(font));
}
@@ -45,7 +45,7 @@ QuartzFontFace::QuartzFontFace(ATSUFontID font_id) :
RefPtr<QuartzFontFace> QuartzFontFace::create(ATSUFontID font_id)
{
- return RefPtr<QuartzFontFace>(new QuartzFontFace(font_id));
+ return make_refptr_for_instance<QuartzFontFace>(new QuartzFontFace(font_id));
}
#endif
diff --git a/cairomm/quartz_surface.cc b/cairomm/quartz_surface.cc
index 006ef9f..2d7bfbc 100644
--- a/cairomm/quartz_surface.cc
+++ b/cairomm/quartz_surface.cc
@@ -43,14 +43,14 @@ RefPtr<QuartzSurface> QuartzSurface::create(CGContextRef cg_context, int width,
auto cobject = cairo_quartz_surface_create_for_cg_context(cg_context,
width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<QuartzSurface>(new QuartzSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<QuartzSurface>(new QuartzSurface(cobject, true /* has reference */));
}
RefPtr<QuartzSurface> QuartzSurface::create(Format format, int width, int height)
{
auto cobject = cairo_quartz_surface_create((cairo_format_t)format, width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<QuartzSurface>(new QuartzSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<QuartzSurface>(new QuartzSurface(cobject, true /* has reference */));
}
#endif // CAIRO_HAS_QUARTZ_SURFACE
diff --git a/cairomm/refptr.h b/cairomm/refptr.h
index eb458f2..7faae4b 100644
--- a/cairomm/refptr.h
+++ b/cairomm/refptr.h
@@ -460,8 +460,14 @@ void swap(RefPtr<T_CppObject>& lhs, RefPtr<T_CppObject>& rhs) noexcept
lhs.swap(rhs);
}
-} // namespace Cairo
+template <class T_CppObject>
+RefPtr<T_CppObject>
+make_refptr_for_instance(T_CppObject* object)
+{
+ return RefPtr<T_CppObject>(object);
+}
+} // namespace Cairo
#endif /* _cairo_REFPTR_H */
diff --git a/cairomm/region.cc b/cairomm/region.cc
index e86f5ef..1a7ea56 100644
--- a/cairomm/region.cc
+++ b/cairomm/region.cc
@@ -68,27 +68,27 @@ Region::Region(cairo_region_t* cobject, bool has_reference)
RefPtr<Region> Region::create()
{
- return RefPtr<Region>(new Region());
+ return make_refptr_for_instance<Region>(new Region());
}
RefPtr<Region> Region::create(const RectangleInt& rectangle)
{
- return RefPtr<Region>(new Region(rectangle));
+ return make_refptr_for_instance<Region>(new Region(rectangle));
}
RefPtr<Region> Region::create(const std::vector<RectangleInt>& rects)
{
- return RefPtr<Region>(new Region(rects));
+ return make_refptr_for_instance<Region>(new Region(rects));
}
RefPtr<Region> Region::create(const RectangleInt *rects, int count)
{
- return RefPtr<Region>(new Region(rects, count));
+ return make_refptr_for_instance<Region>(new Region(rects, count));
}
RefPtr<Region> Region::copy() const
{
- return RefPtr<Region> (new Region (cairo_region_copy (m_cobject), true));
+ return make_refptr_for_instance<Region>(new Region (cairo_region_copy (m_cobject), true));
}
Region::~Region()
diff --git a/cairomm/scaledfont.cc b/cairomm/scaledfont.cc
index 46d970b..c9c6b99 100644
--- a/cairomm/scaledfont.cc
+++ b/cairomm/scaledfont.cc
@@ -53,7 +53,7 @@ ScaledFont::~ScaledFont()
RefPtr<ScaledFont> ScaledFont::create(const RefPtr<FontFace>& font_face, const Matrix& font_matrix,
const Matrix& ctm, const FontOptions& options)
{
- return RefPtr<ScaledFont>(new ScaledFont(font_face, font_matrix, ctm, options));
+ return make_refptr_for_instance<ScaledFont>(new ScaledFont(font_face, font_matrix, ctm, options));
}
void ScaledFont::get_extents(FontExtents& extents) const
@@ -66,7 +66,7 @@ RefPtr<FontFace> ScaledFont::get_font_face() const
{
auto face = cairo_scaled_font_get_font_face(m_cobject);
check_object_status_and_throw_exception(*this);
- return RefPtr<FontFace>(new FontFace(face, false /* returned face doesn't have a reference */));
+ return make_refptr_for_instance<FontFace>(new FontFace(face, false /* returned face doesn't have a reference */));
}
void ScaledFont::get_font_options(FontOptions& options) const
@@ -148,7 +148,7 @@ FtScaledFont::create(const RefPtr<FtFontFace>& font_face,
const Matrix& font_matrix, const Matrix& ctm,
const FontOptions& options)
{
- return RefPtr<FtScaledFont>(new FtScaledFont(font_face, font_matrix, ctm, options));
+ return make_refptr_for_instance<FtScaledFont>(new FtScaledFont(font_face, font_matrix, ctm, options));
}
FT_Face FtScaledFont::lock_face()
diff --git a/cairomm/script.cc b/cairomm/script.cc
index c13c595..1caaf31 100644
--- a/cairomm/script.cc
+++ b/cairomm/script.cc
@@ -58,7 +58,7 @@ RefPtr<Script> Script::create(const std::string& filename)
{
auto cobject = cairo_script_create(filename.c_str());
check_status_and_throw_exception(cairo_device_status(cobject));
- return RefPtr<Script>(new Script(cobject, true /* has reference */));
+ return make_refptr_for_instance<Script>(new Script(cobject, true /* has reference */));
}
static cairo_user_data_key_t USER_DATA_KEY_DEVICE_WRITE_FUNC = {0};
@@ -95,7 +95,7 @@ RefPtr<Script> Script::create_for_stream(const Surface::SlotWriteFunc& write_fun
slot_copy);
check_status_and_throw_exception(cairo_device_status(cobject));
set_write_slot(cobject, slot_copy);
- return RefPtr<Script>(new Script(cobject, true /* has reference */));
+ return make_refptr_for_instance<Script>(new Script(cobject, true /* has reference */));
}
#endif // CAIRO_HAS_SCRIPT_SURFACE
diff --git a/cairomm/script_surface.cc b/cairomm/script_surface.cc
index cb3cdc1..6de10b0 100644
--- a/cairomm/script_surface.cc
+++ b/cairomm/script_surface.cc
@@ -40,7 +40,7 @@ RefPtr<ScriptSurface> ScriptSurface::create(const RefPtr<Script>& script,
cairo_script_surface_create(script->cobj(), static_cast<cairo_content_t>(content),
width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<ScriptSurface>(new ScriptSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<ScriptSurface>(new ScriptSurface(cobject, true /* has reference */));
}
RefPtr<ScriptSurface>
@@ -50,7 +50,7 @@ RefPtr<ScriptSurface>
auto cobject =
cairo_script_surface_create_for_target(script->cobj(), target->cobj());
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<ScriptSurface>(new ScriptSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<ScriptSurface>(new ScriptSurface(cobject, true /* has reference */));
}
#endif // CAIRO_HAS_SCRIPT_SURFACE
diff --git a/cairomm/surface.cc b/cairomm/surface.cc
index aee394e..bf3fe73 100644
--- a/cairomm/surface.cc
+++ b/cairomm/surface.cc
@@ -246,11 +246,11 @@ RefPtr<Device> Surface::get_device()
{
#if CAIRO_HAS_SCRIPT_SURFACE
case CAIRO_SURFACE_TYPE_SCRIPT:
- return RefPtr<Script>(new Script(d, true /* has reference */));
+ return make_refptr_for_instance<Script>(new Script(d, true /* has reference */));
break;
#endif
default:
- return RefPtr<Device>(new Device(d, true /* has reference */));
+ return make_refptr_for_instance<Device>(new Device(d, true /* has reference */));
}
}
@@ -268,14 +268,14 @@ RefPtr<Surface> Surface::create(const RefPtr<Surface> other, Content content, in
{
auto cobject = cairo_surface_create_similar(other->cobj(), (cairo_content_t)content, width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<Surface>(new Surface(cobject, true /* has reference */));
+ return make_refptr_for_instance<Surface>(new Surface(cobject, true /* has reference */));
}
RefPtr<Surface> Surface::create(const RefPtr<Surface>& target, double x, double y, double width, double height)
{
auto cobject = cairo_surface_create_for_rectangle(target->cobj(), x, y, width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<Surface>(new Surface(cobject, true /* has reference */));
+ return make_refptr_for_instance<Surface>(new Surface(cobject, true /* has reference */));
}
@@ -292,14 +292,14 @@ RefPtr<ImageSurface> ImageSurface::create(Format format, int width, int height)
{
auto cobject = cairo_image_surface_create((cairo_format_t)format, width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
}
RefPtr<ImageSurface> ImageSurface::create(unsigned char* data, Format format, int width, int height, int stride)
{
auto cobject = cairo_image_surface_create_for_data(data, (cairo_format_t)format, width, height, stride);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
}
#ifdef CAIRO_HAS_PNG_FUNCTIONS
@@ -308,7 +308,7 @@ RefPtr<ImageSurface> ImageSurface::create_from_png(std::string filename)
{
auto cobject = cairo_image_surface_create_from_png(filename.c_str());
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
}
RefPtr<ImageSurface> ImageSurface::create_from_png_stream(const SlotReadFunc& read_func)
@@ -318,7 +318,7 @@ RefPtr<ImageSurface> ImageSurface::create_from_png_stream(const SlotReadFunc& re
cairo_image_surface_create_from_png_stream(&read_func_wrapper, slot_copy);
check_status_and_throw_exception(cairo_surface_status(cobject));
set_read_slot(cobject, slot_copy);
- return RefPtr<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<ImageSurface>(new ImageSurface(cobject, true /* has reference */));
}
#endif // CAIRO_HAS_PNG_FUNCTIONS
@@ -378,14 +378,14 @@ RefPtr<RecordingSurface> RecordingSurface::create(Content content)
{
auto cobject = cairo_recording_surface_create((cairo_content_t)content, NULL);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<RecordingSurface>(new RecordingSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<RecordingSurface>(new RecordingSurface(cobject, true /* has reference */));
}
RefPtr<RecordingSurface> RecordingSurface::create(const Rectangle& extents, Content content)
{
auto cobject = cairo_recording_surface_create((cairo_content_t)content, &extents);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<RecordingSurface>(new RecordingSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<RecordingSurface>(new RecordingSurface(cobject, true /* has reference */));
}
Rectangle RecordingSurface::ink_extents() const
@@ -425,7 +425,7 @@ RefPtr<PdfSurface> PdfSurface::create(std::string filename, double width_in_poin
{
auto cobject = cairo_pdf_surface_create(filename.c_str(), width_in_points, height_in_points);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<PdfSurface>(new PdfSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<PdfSurface>(new PdfSurface(cobject, true /* has reference */));
}
RefPtr<PdfSurface> PdfSurface::create_for_stream(const SlotWriteFunc& write_func, double
@@ -437,7 +437,7 @@ RefPtr<PdfSurface> PdfSurface::create_for_stream(const SlotWriteFunc& write_func
width_in_points, height_in_points);
check_status_and_throw_exception(cairo_surface_status(cobject));
set_write_slot(cobject, slot_copy);
- return RefPtr<PdfSurface>(new PdfSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<PdfSurface>(new PdfSurface(cobject, true /* has reference */));
}
void PdfSurface::set_size(double width_in_points, double height_in_points)
@@ -493,7 +493,7 @@ RefPtr<PsSurface> PsSurface::create(std::string filename, double width_in_points
{
auto cobject = cairo_ps_surface_create(filename.c_str(), width_in_points, height_in_points);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<PsSurface>(new PsSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<PsSurface>(new PsSurface(cobject, true /* has reference */));
}
RefPtr<PsSurface> PsSurface::create_for_stream(const SlotWriteFunc& write_func, double
@@ -505,7 +505,7 @@ RefPtr<PsSurface> PsSurface::create_for_stream(const SlotWriteFunc& write_func,
width_in_points, height_in_points);
check_status_and_throw_exception(cairo_surface_status(cobject));
set_write_slot(cobject, slot_copy);
- return RefPtr<PsSurface>(new PsSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<PsSurface>(new PsSurface(cobject, true /* has reference */));
}
void PsSurface::set_size(double width_in_points, double height_in_points)
@@ -594,7 +594,7 @@ RefPtr<SvgSurface> SvgSurface::create(std::string filename, double width_in_poin
{
auto cobject = cairo_svg_surface_create(filename.c_str(), width_in_points, height_in_points);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<SvgSurface>(new SvgSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<SvgSurface>(new SvgSurface(cobject, true /* has reference */));
}
RefPtr<SvgSurface> SvgSurface::create_for_stream(const SlotWriteFunc& write_func,
@@ -607,7 +607,7 @@ RefPtr<SvgSurface> SvgSurface::create_for_stream(const SlotWriteFunc& write_func
width_in_points, height_in_points);
check_status_and_throw_exception(cairo_surface_status(cobject));
set_write_slot(cobject, slot_copy);
- return RefPtr<SvgSurface>(new SvgSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<SvgSurface>(new SvgSurface(cobject, true /* has reference */));
}
void SvgSurface::restrict_to_version(SvgVersion version)
@@ -658,7 +658,7 @@ RefPtr<GlitzSurface> GlitzSurface::create(glitz_surface_t *surface)
{
auto cobject = cairo_glitz_surface_create(surface);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<GlitzSurface>(new GlitzSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<GlitzSurface>(new GlitzSurface(cobject, true /* has reference */));
}
#endif // CAIRO_HAS_GLITZ_SURFACE
diff --git a/cairomm/win32_font.cc b/cairomm/win32_font.cc
index 201bf3c..e923109 100644
--- a/cairomm/win32_font.cc
+++ b/cairomm/win32_font.cc
@@ -44,17 +44,17 @@ Win32FontFace::Win32FontFace(LOGFONTW* logfont, HFONT font) :
RefPtr<Win32FontFace> Win32FontFace::create(LOGFONTW* logfont)
{
- return RefPtr<Win32FontFace>(new Win32FontFace(logfont));
+ return make_refptr_for_instance<Win32FontFace>(new Win32FontFace(logfont));
}
RefPtr<Win32FontFace> Win32FontFace::create(HFONT font)
{
- return RefPtr<Win32FontFace>(new Win32FontFace(font));
+ return make_refptr_for_instance<Win32FontFace>(new Win32FontFace(font));
}
RefPtr<Win32FontFace> Win32FontFace::create(LOGFONTW* logfont, HFONT font)
{
- return RefPtr<Win32FontFace>(new Win32FontFace(logfont, font));
+ return make_refptr_for_instance<Win32FontFace>(new Win32FontFace(logfont, font));
}
// ScaledFont
@@ -72,7 +72,7 @@ Win32ScaledFont::create(const RefPtr<Win32FontFace>& font_face,
const Matrix& font_matrix, const Matrix& ctm,
const FontOptions& options)
{
- return RefPtr<Win32ScaledFont>(new Win32ScaledFont(font_face, font_matrix,
+ return make_refptr_for_instance<Win32ScaledFont>(new Win32ScaledFont(font_face, font_matrix,
ctm, options));
}
diff --git a/cairomm/win32_surface.cc b/cairomm/win32_surface.cc
index 30a6197..75e6d58 100644
--- a/cairomm/win32_surface.cc
+++ b/cairomm/win32_surface.cc
@@ -50,7 +50,7 @@ RefPtr<Win32Surface> Win32Surface::create(HDC hdc)
{
auto cobject = cairo_win32_surface_create(hdc);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
+ return make_refptr_for_instance<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
}
RefPtr<Win32Surface> Win32Surface::create(Format format, int width, int height)
@@ -62,7 +62,7 @@ RefPtr<Win32Surface> Win32Surface::create_with_dib(Format format, int width, int
{
auto cobject = cairo_win32_surface_create_with_dib((cairo_format_t)format, width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
+ return make_refptr_for_instance<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
}
RefPtr<Win32Surface> Win32Surface::create_with_ddb(HDC hdc, Format format, int width, int height)
@@ -70,7 +70,7 @@ RefPtr<Win32Surface> Win32Surface::create_with_ddb(HDC hdc, Format format, int w
auto cobject =
cairo_win32_surface_create_with_ddb(hdc, (cairo_format_t)format, width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
+ return make_refptr_for_instance<Win32Surface>(new Win32Surface(cobject, true /* has reference */));
}
Win32PrintingSurface::Win32PrintingSurface(cairo_surface_t* cobject, bool has_reference)
@@ -87,7 +87,7 @@ RefPtr<Win32PrintingSurface> Win32PrintingSurface::create(HDC hdc)
{
auto cobject = cairo_win32_surface_create(hdc);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<Win32PrintingSurface>(new Win32PrintingSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<Win32PrintingSurface>(new Win32PrintingSurface(cobject, true /* has reference */));
}
#endif // CAIRO_HAS_WIN32_SURFACE
diff --git a/cairomm/xlib_surface.cc b/cairomm/xlib_surface.cc
index 12c3ae2..69c0fcc 100644
--- a/cairomm/xlib_surface.cc
+++ b/cairomm/xlib_surface.cc
@@ -38,14 +38,14 @@ RefPtr<XlibSurface> XlibSurface::create(Display* dpy, Drawable drawable, Visual*
{
auto cobject = cairo_xlib_surface_create(dpy, drawable, visual, width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
}
RefPtr<XlibSurface> XlibSurface::create(Display* dpy, Pixmap bitmap, Screen* screen, int width, int height)
{
auto cobject = cairo_xlib_surface_create_for_bitmap(dpy, bitmap, screen, width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
}
void XlibSurface::set_size(int width, int height)
@@ -144,7 +144,7 @@ XlibSurface::create_with_xrender_format (Display *dpy,
screen, format,
width, height);
check_status_and_throw_exception(cairo_surface_status(cobject));
- return RefPtr<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
+ return make_refptr_for_instance<XlibSurface>(new XlibSurface(cobject, true /* has reference */));
}
XRenderPictFormat*