[gtk+/wip/window-scales: 99/108] gdk: Add gdk_cairo_surface_create_similar
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/window-scales: 99/108] gdk: Add gdk_cairo_surface_create_similar
- Date: Thu, 20 Jun 2013 09:44:01 +0000 (UTC)
commit 6f90173e010eb14a1ecab71b69e2fbfaa3e46f44
Author: Alexander Larsson <alexl redhat com>
Date: Mon Jun 3 17:01:36 2013 +0200
gdk: Add gdk_cairo_surface_create_similar
We track the window that each cairo surface is created for, which
allows us to use gdk_window_create_similar_surface() when creating
similar surfaces, even when you don't have access to the GdkWindow.
This will be extra important when we need to create larger surfaces
on HiDPI displays.
gdk/gdkcairo.c | 37 +++++++++++++++++++++++++++++++++++++
gdk/gdkcairo.h | 6 ++++++
gdk/gdkinternals.h | 2 ++
gdk/gdkwindow.c | 7 ++++++-
4 files changed, 51 insertions(+), 1 deletions(-)
---
diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c
index 19bed04..1b0e83b 100644
--- a/gdk/gdkcairo.c
+++ b/gdk/gdkcairo.c
@@ -459,3 +459,40 @@ gdk_cairo_region_create_from_surface (cairo_surface_t *surface)
return region;
}
+
+static const cairo_user_data_key_t window_key;
+
+static GdkWindow *
+_gdk_cairo_surface_get_window (cairo_surface_t *surface)
+{
+ return cairo_surface_get_user_data (surface, &window_key);
+}
+
+void
+_gdk_cairo_surface_set_window (cairo_surface_t *surface,
+ GdkWindow *window)
+{
+ cairo_surface_set_user_data (surface, &window_key,
+ window, NULL);
+}
+
+cairo_surface_t *
+gdk_cairo_surface_create_similar (cairo_surface_t *surface,
+ cairo_content_t content,
+ int width,
+ int height)
+{
+ GdkWindow *window;
+
+ window = _gdk_cairo_surface_get_window (surface);
+ if (window)
+ return gdk_window_create_similar_surface (window,
+ content,
+ width,
+ height);
+ else
+ return cairo_surface_create_similar (surface,
+ content,
+ width,
+ height);
+}
diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h
index 9cb601d..0b22c51 100644
--- a/gdk/gdkcairo.h
+++ b/gdk/gdkcairo.h
@@ -66,6 +66,12 @@ GDK_DEPRECATED_IN_3_4_FOR(gdk_cairo_set_source_rgba)
void gdk_cairo_set_source_color (cairo_t *cr,
const GdkColor *color);
+GDK_AVAILABLE_IN_3_10
+cairo_surface_t * gdk_cairo_surface_create_similar (cairo_surface_t *surface,
+ cairo_content_t content,
+ int width,
+ int height);
+
G_END_DECLS
#endif /* __GDK_CAIRO_H__ */
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index e7eb9d5..ee5c7c4 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -318,6 +318,8 @@ void gdk_synthesize_window_state (GdkWindow *window,
gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
GdkRectangle *extents);
+void _gdk_cairo_surface_set_window (cairo_surface_t *surface,
+ GdkWindow *window);
/*************************************
* Interfaces used by windowing code *
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index e0aa7e3..ae4223f 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -3094,8 +3094,9 @@ gdk_window_create_cairo_surface (GdkWindow *window,
subsurface = cairo_surface_create_for_rectangle (surface,
window->abs_x,
window->abs_y,
- width,
+ width ,
height);
+ _gdk_cairo_surface_set_window (subsurface, window);
cairo_surface_destroy (surface);
return subsurface;
}
@@ -3120,6 +3121,7 @@ _gdk_window_ref_cairo_surface (GdkWindow *window)
window->abs_y,
window->width,
window->height);
+ _gdk_cairo_surface_set_window (surface, window);
}
else
{
@@ -3128,6 +3130,7 @@ _gdk_window_ref_cairo_surface (GdkWindow *window)
window->cairo_surface = gdk_window_create_cairo_surface (window,
window->width,
window->height);
+ _gdk_cairo_surface_set_window (window->cairo_surface, window);
if (window->cairo_surface)
{
@@ -9202,6 +9205,8 @@ gdk_window_create_similar_surface (GdkWindow * window,
cairo_surface_destroy (window_surface);
+ _gdk_cairo_surface_set_window (surface, window);
+
return surface;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]