[gtkmm] Remove Gdk::DrawingContext, add Gdk::CairoContext
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Remove Gdk::DrawingContext, add Gdk::CairoContext
- Date: Mon, 30 Apr 2018 08:45:08 +0000 (UTC)
commit d13c4171485caefda0b96454de73eb2d4e16b1ee
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Apr 30 10:42:14 2018 +0200
Remove Gdk::DrawingContext, add Gdk::CairoContext
* gdk/src/cairocontext.[ccg|hg]: New files.
* gdk/src/drawcontext.[ccg|hg]: Add begin_frame(), end_frame(), is_in_frame()
and get_frame_region().
* gdk/src/drawingcontext.[ccg|hg]: Removed files.
* gdk/src/glcontext.hg: Remove get_damage().
* gdk/src/surface.[ccg|hg]: Remove begin_draw_frame() and end_draw_frame().
They have been moved to DrawContext.
Add queue_expose() and create_cairo_context().
* gtk/src/snapshot.[ccg|hg]: Remove push() and clips_rect(). Add create()
and push_debug(). Add append_texture() and append_cairo(). Only push_debug()
has a 'name' parameter.
.gitignore | 4 +-
gdk/gdkmm.h | 2 +-
gdk/src/{drawingcontext.ccg => cairocontext.ccg} | 5 +-
gdk/src/cairocontext.hg | 49 +++++++++++++
gdk/src/drawcontext.ccg | 1 +
gdk/src/drawcontext.hg | 6 ++-
gdk/src/drawingcontext.hg | 67 ------------------
gdk/src/filelist.am | 2 +-
gdk/src/glcontext.hg | 2 -
gdk/src/surface.ccg | 2 +-
gdk/src/surface.hg | 6 +-
gtk/src/snapshot.ccg | 34 ++--------
gtk/src/snapshot.hg | 81 +++++++---------------
tools/m4/convert_gdk.m4 | 2 +
14 files changed, 96 insertions(+), 167 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e643415..e2da85c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,8 @@ demos/pixbuf-demo
gdk/gdkmm-*.pc
gdk/gdkmm/applaunchcontext.cc
gdk/gdkmm/applaunchcontext.h
+gdk/gdkmm/cairocontext.cc
+gdk/gdkmm/cairocontext.h
gdk/gdkmm/clipboard.cc
gdk/gdkmm/clipboard.h
gdk/gdkmm/contentformats.cc
@@ -73,8 +75,6 @@ gdk/gdkmm/dragcontext.cc
gdk/gdkmm/dragcontext.h
gdk/gdkmm/drawcontext.cc
gdk/gdkmm/drawcontext.h
-gdk/gdkmm/drawingcontext.cc
-gdk/gdkmm/drawingcontext.h
gdk/gdkmm/enums.cc
gdk/gdkmm/enums.h
gdk/gdkmm/event.cc
diff --git a/gdk/gdkmm.h b/gdk/gdkmm.h
index 033dd1d..c1076b6 100644
--- a/gdk/gdkmm.h
+++ b/gdk/gdkmm.h
@@ -30,7 +30,6 @@
#include <gdkmm/applaunchcontext.h>
#include <gdkmm/clipboard.h>
#include <gdkmm/cursor.h>
-#include <gdkmm/drawingcontext.h>
#include <gdkmm/events.h>
#include <gdkmm/frameclock.h>
#include <gdkmm/glcontext.h>
@@ -43,6 +42,7 @@
#include <gdkmm/texture.h>
#include <gdkmm/monitor.h>
#include <gdkmm/general.h>
+#include <gdkmm/cairocontext.h>
#include <gdkmm/contentformatsbuilder.h>
#include <gdkmm/paintable.h>
#include <gdkmm/snapshot.h>
diff --git a/gdk/src/drawingcontext.ccg b/gdk/src/cairocontext.ccg
similarity index 86%
rename from gdk/src/drawingcontext.ccg
rename to gdk/src/cairocontext.ccg
index 013dce5..475f3c8 100644
--- a/gdk/src/drawingcontext.ccg
+++ b/gdk/src/cairocontext.ccg
@@ -1,4 +1,4 @@
-/* Copyright (C) 2016 The gtkmm Development Team
+/* Copyright (C) 2018 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -14,6 +14,5 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <gdk/gdk.h>
#include <gdkmm/cairoutils.h>
-#include <gdkmm/drawcontext.h>
-#include <gdkmm/surface.h>
diff --git a/gdk/src/cairocontext.hg b/gdk/src/cairocontext.hg
new file mode 100644
index 0000000..0c2c8ba
--- /dev/null
+++ b/gdk/src/cairocontext.hg
@@ -0,0 +1,49 @@
+/* Copyright (C) 2018 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gdkmm/drawcontext.h>
+#include <cairomm/context.h>
+
+_DEFS(gdkmm,gdk)
+_PINCLUDE(gdkmm/private/drawcontext_p.h)
+
+namespace Gdk
+{
+
+/** Cairo draw context.
+ *
+ * %Gdk::CairoContext is an object representing the platform-specific draw context.
+ *
+ * %Gdk::CairoContexts are created for a Gdk::Display using
+ * Gdk::Surface::create_cairo_context(), and the context can then be used
+ * to draw on that Gdk::Surface.
+ *
+ * @newin{3,94}
+ */
+class CairoContext : public Gdk::DrawContext
+{
+ _CLASS_GOBJECT(CairoContext, GdkCairoContext, GDK_CAIRO_CONTEXT, Gdk::DrawContext, GdkDrawContext)
+
+protected:
+ _CTOR_DEFAULT()
+
+public:
+ _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Context> cairo_create(), gdk_cairo_context_cairo_create)
+
+ // There are no public signals, properties or vfuncs.
+};
+
+} // namespace Gdk
diff --git a/gdk/src/drawcontext.ccg b/gdk/src/drawcontext.ccg
index 0d8e63b..f0fe431 100644
--- a/gdk/src/drawcontext.ccg
+++ b/gdk/src/drawcontext.ccg
@@ -14,5 +14,6 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <gdkmm/cairoutils.h>
#include <gdkmm/display.h>
#include <gdkmm/surface.h>
diff --git a/gdk/src/drawcontext.hg b/gdk/src/drawcontext.hg
index 8fc7445..cc5c50e 100644
--- a/gdk/src/drawcontext.hg
+++ b/gdk/src/drawcontext.hg
@@ -1,4 +1,3 @@
-
/* Copyright (C) 2016 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
@@ -16,6 +15,7 @@
*/
#include <glibmm/object.h>
+#include <cairomm/region.h>
_DEFS(gdkmm,gdk)
_PINCLUDE(glibmm/private/object_p.h)
@@ -48,6 +48,10 @@ public:
_WRAP_METHOD(Glib::RefPtr<const Display> get_display() const, gdk_draw_context_get_display, refreturn,
constversion)
_WRAP_METHOD(Glib::RefPtr<Surface> get_surface(), gdk_draw_context_get_surface, refreturn)
_WRAP_METHOD(Glib::RefPtr<const Surface> get_surface() const, gdk_draw_context_get_surface, refreturn,
constversion)
+ _WRAP_METHOD(void begin_frame(const ::Cairo::RefPtr<const ::Cairo::Region>& region),
gdk_draw_context_begin_frame)
+ _WRAP_METHOD(void end_frame(), gdk_draw_context_end_frame)
+ _WRAP_METHOD(bool is_in_frame() const, gdk_draw_context_is_in_frame)
+ _WRAP_METHOD(::Cairo::RefPtr<const ::Cairo::Region> get_frame_region() const,
gdk_draw_context_get_frame_region, refreturn)
_WRAP_PROPERTY("display", Glib::RefPtr<Display>)
_WRAP_PROPERTY("surface", Glib::RefPtr<Surface>)
diff --git a/gdk/src/filelist.am b/gdk/src/filelist.am
index 7be2ab5..d7a076d 100644
--- a/gdk/src/filelist.am
+++ b/gdk/src/filelist.am
@@ -15,6 +15,7 @@ gdkmm_files_defs = \
gdkmm_files_any_hg = \
applaunchcontext.hg \
+ cairocontext.hg \
clipboard.hg \
contentformats.hg \
contentformatsbuilder.hg \
@@ -26,7 +27,6 @@ gdkmm_files_any_hg = \
displaymanager.hg \
dragcontext.hg \
drawcontext.hg \
- drawingcontext.hg \
enums.hg \
event.hg \
events.hg \
diff --git a/gdk/src/glcontext.hg b/gdk/src/glcontext.hg
index cba9ffb..47eb61c 100644
--- a/gdk/src/glcontext.hg
+++ b/gdk/src/glcontext.hg
@@ -88,8 +88,6 @@ public:
_WRAP_METHOD(bool get_use_es() const, gdk_gl_context_get_use_es)
_WRAP_METHOD(bool realize(), gdk_gl_context_realize, errthrow, newin "3,18")
- // This is const because it returns a newly created Cairo::Region (though that is not very clear from the
C documentation)
- _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Region> get_damage() const, gdk_gl_context_get_damage)
_WRAP_METHOD(void make_current(), gdk_gl_context_make_current, newin "3,18")
_WRAP_METHOD(static Glib::RefPtr<GLContext> get_current(), gdk_gl_context_get_current, refreturn, newin
"3,18")
_WRAP_METHOD(static void clear_current(), gdk_gl_context_clear_current, newin "3,18")
diff --git a/gdk/src/surface.ccg b/gdk/src/surface.ccg
index db744bc..a3a56b1 100644
--- a/gdk/src/surface.ccg
+++ b/gdk/src/surface.ccg
@@ -21,9 +21,9 @@
#include <gdkmm/cursor.h>
#include <gdkmm/device.h>
#include <gdkmm/types.h>
+#include <gdkmm/cairocontext.h>
#include <gdkmm/glcontext.h>
#include <gdkmm/drawcontext.h>
-#include <gdkmm/drawingcontext.h>
#include <gdkmm/frameclock.h>
#include <gdkmm/monitor.h>
diff --git a/gdk/src/surface.hg b/gdk/src/surface.hg
index 812287a..cfd0ffd 100644
--- a/gdk/src/surface.hg
+++ b/gdk/src/surface.hg
@@ -46,9 +46,9 @@ _WRAP_ENUM(FullscreenMode, GdkFullscreenMode,
class ContentProvider;
class Cursor;
+class CairoContext;
class GLContext;
class DrawContext;
-class DrawingContext;
class FrameClock;
class Monitor;
@@ -227,6 +227,7 @@ public:
_WRAP_METHOD(Glib::RefPtr<DragContext> drag_begin_from_point(const Glib::RefPtr<Device>& device,
const Glib::RefPtr<ContentProvider>& content, DragAction actions, int dx, int dy), gdk_drag_begin)
+ _WRAP_METHOD(void queue_expose(), gdk_surface_queue_expose)
_WRAP_METHOD(void invalidate_rect(const Rectangle& rect), gdk_surface_invalidate_rect)
/** A convenience wrapper around invalidate_region() which
@@ -292,8 +293,7 @@ public:
*/
_WRAP_METHOD(Glib::RefPtr<Gdk::GLContext> create_gl_context(), gdk_surface_create_gl_context, errthrow)
- _WRAP_METHOD(Glib::RefPtr<DrawingContext> begin_draw_frame(const Glib::RefPtr<DrawContext>& context{?},
const ::Cairo::RefPtr<const ::Cairo::Region>& region), gdk_surface_begin_draw_frame, refreturn)
- _WRAP_METHOD(void end_draw_frame(const Glib::RefPtr<DrawingContext>& context), gdk_surface_end_draw_frame)
+ _WRAP_METHOD(Glib::RefPtr<Gdk::CairoContext> create_cairo_context(), gdk_surface_create_cairo_context)
_IGNORE_SIGNAL("moved-to-rect")dnl// Private
diff --git a/gtk/src/snapshot.ccg b/gtk/src/snapshot.ccg
index 05a4f9b..032a156 100644
--- a/gtk/src/snapshot.ccg
+++ b/gtk/src/snapshot.ccg
@@ -16,6 +16,8 @@
#include <gtk/gtk.h>
#include <gdkmm/cairoutils.h>
+#include <gdkmm/rgba.h>
+#include <gdkmm/texture.h>
#include <memory>
namespace
@@ -33,38 +35,12 @@ gdk_rect_to_graphene_rect(const Gdk::Rectangle& gdk_rect)
namespace Gtk
{
-void Snapshot::push(bool keep_coordinates, const Glib::ustring& name)
+void Snapshot::push_debug(const Glib::ustring& name)
{
if (name.empty())
- gtk_snapshot_push(gobj(), keep_coordinates, nullptr);
+ gtk_snapshot_push_debug(gobj(), nullptr);
else
- gtk_snapshot_push(gobj(), keep_coordinates, "%s", name.c_str());
-}
-
-void Snapshot::push_cross_fade(double progress, const Glib::ustring& name)
-{
- if (name.empty())
- gtk_snapshot_push_cross_fade(gobj(), progress, nullptr);
- else
- gtk_snapshot_push_cross_fade(gobj(), progress, "%s", name.c_str());
-}
-
-Cairo::RefPtr<Cairo::Context> Snapshot::append_cairo(
- const graphene_rect_t* bounds, const Glib::ustring& name)
-{
- cairo_t* cr = nullptr;
- if (name.empty())
- cr = gtk_snapshot_append_cairo(gobj(), bounds, nullptr);
- else
- cr = gtk_snapshot_append_cairo(gobj(), bounds, "%s", name.c_str());
-
- return Gdk::Cairo::wrap(cr, true /* has_reference */);
-}
-
-Cairo::RefPtr<Cairo::Context> Snapshot::append_cairo(
- const Gdk::Rectangle& bounds, const Glib::ustring& name)
-{
- return append_cairo(gdk_rect_to_graphene_rect(bounds).get(), name);
+ gtk_snapshot_push_debug(gobj(),"%s", name.c_str());
}
} //namespace Gtk
diff --git a/gtk/src/snapshot.hg b/gtk/src/snapshot.hg
index dbf0943..30a0abb 100644
--- a/gtk/src/snapshot.hg
+++ b/gtk/src/snapshot.hg
@@ -25,7 +25,8 @@ typedef struct _graphene_rect_t graphene_rect_t;
namespace Gdk
{
-class Pixbuf;
+class RGBA;
+class Texture;
}
namespace Gtk
@@ -42,8 +43,7 @@ namespace Gtk
* operates on. Use the push() and pop() functions to change the current node.
*
* The typical way to obtain a %Snapshot object is as an argument to
- * Gtk::WidgetCustomSnapshot::snapshot_vfunc(). If you need to create your own
- * %Snapshot, use create().
+ * Gtk::Widget::snapshot_vfunc(). If you need to create your own %Snapshot, use create().
*
* @newin{3,90}
*/
@@ -58,17 +58,18 @@ class Snapshot : public Gdk::Snapshot
public:
//TODO: Add more methods. What shall be done with methods that take Gsk or graphene classes?
- /** Creates a new render node, appends it to the current render
- * node of the snapshot, and makes it the new current render node.
+#m4 _CONVERSION(`GtkSnapshot*',`Glib::RefPtr<Snapshot>', `Glib::wrap_gtk_snapshot($3)')
+ // gtk_snapshot_new() does more than call g_object_new().
+ _WRAP_METHOD(static Glib::RefPtr<Snapshot> create(), gtk_snapshot_new)
+
+ /** Creates a new debug node.
*
- * @newin{3,90}
+ * @newin{3,94}
*
- * @param keep_coordinates If <tt>true</tt>, the current offset and clip will be kept.
- * Otherwise, the clip will be unset and the offset will be reset to (0, 0).
* @param name The name for the new node, or an empty string for no name.
*/
- void push(bool keep_coordinates, const Glib::ustring& name);
- _IGNORE(gtk_snapshot_push)
+ void push_debug(const Glib::ustring& name);
+ _IGNORE(gtk_snapshot_push_debug)
//TODO: These gtk_snapshot_push_*() functions have no documentation.
//TODO: Wrap gtk_snapshot_push_transform()?
@@ -80,22 +81,7 @@ public:
//TODO: Wrap gtk_snapshot_push_shadow()?
//TODO: Wrap gtk_snapshot_push_blend()? Has documentation.
- /** Snapshots a cross-fade operation between two images with the
- * given @a progress.
- *
- * Until the first call to pop(), the start image
- * will be the snapshot. After that call, the end image will be recorded
- * until the second call to pop().
- *
- * Calling this function requires 2 calls to pop().
- *
- * @newin{3,90}
- *
- * @param progress Progress between 0.0 and 1.0.
- * @param name The name of the pushed node, or an empty string for no name.
- */
- void push_cross_fade(double progress, const Glib::ustring& name);
- _IGNORE(gtk_snapshot_push_cross_fade)
+ _WRAP_METHOD(void push_cross_fade(double progress), gtk_snapshot_push_cross_fade)
_WRAP_METHOD(void pop(), gtk_snapshot_pop)
@@ -104,38 +90,19 @@ public:
//TODO: Wrap gtk_snapshot_append_node()?
- /** Creates a new render node and appends it to the current render
- * node of the snapshot, without changing the current node.
- *
- * @newin{3,90}
- *
- * @param bounds The bounds for the new node.
- * @param name The name for the new node, or an empty string for no name.
- * @return A Cairo::Context suitable for drawing the contents of the newly
- * created render node.
- */
- Cairo::RefPtr<Cairo::Context> append_cairo(const graphene_rect_t* bounds,
- const Glib::ustring& name);
+ _WRAP_METHOD(Cairo::RefPtr<Cairo::Context> append_cairo(const graphene_rect_t* bounds),
gtk_snapshot_append_cairo)
+#m4 _CONVERSION(`const Gdk::Rectangle&',`const graphene_rect_t*', `gdk_rect_to_graphene_rect($3).get()')
+ _WRAP_METHOD(Cairo::RefPtr<Cairo::Context> append_cairo(const Gdk::Rectangle& bounds),
gtk_snapshot_append_cairo)
- /** Creates a new render node and appends it to the current render
- * node of the snapshot, without changing the current node.
- *
- * @newin{3,90}
- *
- * @param bounds The bounds for the new node.
- * @param name The name for the new node, or an empty string for no name.
- * @return A Cairo::Context suitable for drawing the contents of the newly
- * created render node.
- */
- Cairo::RefPtr<Cairo::Context> append_cairo(const Gdk::Rectangle& bounds,
- const Glib::ustring& name);
- _IGNORE(gtk_snapshot_append_cairo)
- //TODO: Wrap gtk_snapshot_append_texture()?
- //TODO: Wrap gtk_snapshot_append_color()?
-
- _WRAP_METHOD(bool clips_rect(const graphene_rect_t* bounds) const, gtk_snapshot_clips_rect)
-#m4 _CONVERSION(`const Gdk::Rectangle&', `const graphene_rect_t*', `gdk_rect_to_graphene_rect($3).get()')
- _WRAP_METHOD(bool clips_rect(const Gdk::Rectangle& bounds) const, gtk_snapshot_clips_rect)
+ _WRAP_METHOD(void append_texture(const Glib::RefPtr<Gdk::Texture>& texture,
+ const graphene_rect_t* bounds), gtk_snapshot_append_texture)
+ _WRAP_METHOD(void append_texture(const Glib::RefPtr<Gdk::Texture>& texture,
+ const Gdk::Rectangle& bounds), gtk_snapshot_append_texture)
+
+ _WRAP_METHOD(void append_color(const Gdk::RGBA& color, const graphene_rect_t* bounds),
+ gtk_snapshot_append_color)
+ _WRAP_METHOD(void append_color(const Gdk::RGBA& color, const Gdk::Rectangle& bounds),
+ gtk_snapshot_append_color)
_WRAP_METHOD(void render_backgrount(const Glib::RefPtr<StyleContext>& context,
double x, double y, double width, double height), gtk_snapshot_render_background)
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index e1715a4..a78fcf6 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -109,6 +109,7 @@ _CONVERSION(`const ::Cairo::RefPtr< ::Cairo::Region>&',`const cairo_region_t*',`
_CONVERSION(`const ::Cairo::RefPtr<const
::Cairo::Region>&',`cairo_region_t*',`const_cast<cairo_region_t*>(($3) ? ($3)->cobj() : nullptr)')
_CONVERSION(`const ::Cairo::RefPtr<const ::Cairo::Region>&',`const cairo_region_t*',`(($3) ? ($3)->cobj() :
nullptr)')
_CONVERSION(`cairo_region_t*',`::Cairo::RefPtr< ::Cairo::Region>',`Gdk::Cairo::wrap($3)')
+_CONVERSION(`const cairo_region_t*',`::Cairo::RefPtr<const
::Cairo::Region>',`Gdk::Cairo::wrap(const_cast<cairo_region_t*>($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)')
@@ -181,6 +182,7 @@ _CONVERSION(`GdkSurface*',`Glib::RefPtr<Surface>', `Glib::wrap($3)')
_CONVERSION(`GdkSurface*',`Glib::RefPtr<const Surface>', `Glib::wrap($3)')
_CONVERSION(`GdkSurface*',`Glib::RefPtr<Gdk::Surface>', `Glib::wrap($3)')
_CONVERSION(`GdkSurface*',`Glib::RefPtr<const Gdk::Surface>', `Glib::wrap($3)')
+_CONVERSION(`GdkCairoContext*',`Glib::RefPtr<Gdk::CairoContext>', `Glib::wrap($3)')
_CONVERSION(`GdkGLContext*',`Glib::RefPtr<GLContext>', `Glib::wrap($3)')
_CONVERSION(`GdkGLContext*',`Glib::RefPtr<const GLContext>', `Glib::wrap($3)')
_CONVERSION(`GdkGLContext*',`Glib::RefPtr<Gdk::GLContext>', `Glib::wrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]