[gtkmm] Gdk::Window::create_similar_image_surface(): Return an image surface
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gdk::Window::create_similar_image_surface(): Return an image surface
- Date: Mon, 5 Mar 2018 12:42:39 +0000 (UTC)
commit ef7c1a15836500411684240319d1a4f404d5043b
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Mar 5 13:38:31 2018 +0100
Gdk::Window::create_similar_image_surface(): Return an image surface
* gdk/gdkmm/cairoutils.[cc|h]:
Make wrap(cairo_surface_t* cobject, bool has_reference) a template function.
* gdk/src/window.hg: create_similar_image_surface():
Return a Cairo::RefPtr<Cairo::ImageSurface>, not just a plain
Cairo::RefPtr<Cairo::Surface>.
* tools/m4/convert_gdk.m4: Add a conversion for cairo_surface_t*.
Bug 793572
gdk/gdkmm/cairoutils.cc | 5 -----
gdk/gdkmm/cairoutils.h | 7 ++++++-
gdk/src/window.hg | 2 +-
tools/m4/convert_gdk.m4 | 1 +
4 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gdk/gdkmm/cairoutils.cc b/gdk/gdkmm/cairoutils.cc
index 3e3cbe9..afcd867 100644
--- a/gdk/gdkmm/cairoutils.cc
+++ b/gdk/gdkmm/cairoutils.cc
@@ -32,11 +32,6 @@ namespace Cairo
return ::Cairo::make_refptr_for_instance< ::Cairo::Region>(cobject ? new ::Cairo::Region(cobject,
has_reference) : nullptr);
}
-::Cairo::RefPtr< ::Cairo::Surface> wrap(cairo_surface_t* cobject, bool has_reference)
-{
- return ::Cairo::make_refptr_for_instance< ::Cairo::Surface>(cobject ? new ::Cairo::Surface(cobject,
has_reference) : nullptr);
-}
-
} // namespace Cairo
} // namespace Gdk
diff --git a/gdk/gdkmm/cairoutils.h b/gdk/gdkmm/cairoutils.h
index e10f513..d34a41b 100644
--- a/gdk/gdkmm/cairoutils.h
+++ b/gdk/gdkmm/cairoutils.h
@@ -57,6 +57,7 @@ namespace Cairo
/** Creates a Cairo::RefPtr with a C++ wrapper for the C instance.
*
+ * @tparam T Cairo::Surface or a subclass of Cairo::Surface.
* @param cobject The C instance.
* @param has_reference Whether we already have a reference. Otherwise, the
* function will take an extra reference.
@@ -65,7 +66,11 @@ namespace Cairo
*
* @newin{3,92}
*/
-::Cairo::RefPtr< ::Cairo::Surface> wrap(cairo_surface_t* cobject, bool has_reference = true);
+template <typename T = ::Cairo::Surface, typename = std::enable_if<std::is_base_of< ::Cairo::Surface,
T>::value>>
+::Cairo::RefPtr<T> wrap(cairo_surface_t* cobject, bool has_reference = true)
+{
+ return ::Cairo::make_refptr_for_instance<T>(cobject ? new T(cobject, has_reference) : nullptr);
+}
} //namespace Cairo
} //namespace Gdk
diff --git a/gdk/src/window.hg b/gdk/src/window.hg
index 52ac3b8..42d6257 100644
--- a/gdk/src/window.hg
+++ b/gdk/src/window.hg
@@ -219,7 +219,7 @@ public:
_WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Surface> create_similar_surface(::Cairo::Content content, int
width, int height), gdk_window_create_similar_surface )
#m4 _CONVERSION(`::Cairo::Surface::Format',`cairo_format_t',`(cairo_format_t)($3)')
- _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Surface> create_similar_image_surface(::Cairo::Surface::Format
format, int width, int height, int scale), gdk_window_create_similar_image_surface )
+ _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::ImageSurface>
create_similar_image_surface(::Cairo::Surface::Format format, int width, int height, int scale),
gdk_window_create_similar_image_surface )
_WRAP_METHOD(void beep(), gdk_window_beep)
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index b0f2d26..342f796 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -112,6 +112,7 @@ _CONVERSION(`const ::Cairo::RefPtr<const ::Cairo::Region>&',`const cairo_region_
_CONVERSION(`cairo_region_t*',`::Cairo::RefPtr< ::Cairo::Region>',`Gdk::Cairo::wrap($3)')
_CONVERSION(`const ::Cairo::RefPtr< ::Cairo::Surface>&',`cairo_surface_t*',`(($3) ? ($3)->cobj() : nullptr)')
_CONVERSION(`cairo_surface_t*',`::Cairo::RefPtr< ::Cairo::Surface>',`Gdk::Cairo::wrap($3)')
+_CONVERSION(`cairo_surface_t*',`::Cairo::RefPtr< ::Cairo::ImageSurface>',`Gdk::Cairo::wrap<
::Cairo::ImageSurface>($3)')
_CONVERSION(`const Glib::RefPtr<Cursor>&',`GdkCursor*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<const Cursor>&',`GdkCursor*',__CONVERT_CONST_REFPTR_TO_P)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]