summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2023-04-02 10:55:15 +0000
committerMatthias Clasen <mclasen@redhat.com>2023-04-02 10:55:15 +0000
commit33b1624a9f809162c878cf43cb7efd6311118746 (patch)
tree52dab690935ef596631c102059787130c38add32
parentf20e6a81d2da02dafe5cdae8a9869f797cad9157 (diff)
parent76ac91512b4cfd03f0b839f32f7771e7f5030e2e (diff)
downloadgtk+-33b1624a9f809162c878cf43cb7efd6311118746.tar.gz
Merge branch 'deprecate-similar-surface' into 'main'
popover: Stop using gdk_surface_create_similar_surface See merge request GNOME/gtk!5771
-rw-r--r--gdk/gdksurface.c2
-rw-r--r--gdk/gdksurface.h2
-rw-r--r--gdk/win32/gdkcairocontext-win32.c2
-rw-r--r--gdk/x11/gdkcairocontext-x11.c3
-rw-r--r--gtk/gtkpopover.c12
5 files changed, 15 insertions, 6 deletions
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 6aeba0bee8..b7e285f2ae 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2382,6 +2382,8 @@ _gdk_windowing_got_event (GdkDisplay *display,
* Returns: a pointer to the newly allocated surface. The caller
* owns the surface and should call cairo_surface_destroy() when done
* with it.
+ *
+ * Deprecated: 4.12: Create a suitable cairo image surface yourself
*/
cairo_surface_t *
gdk_surface_create_similar_surface (GdkSurface *surface,
diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h
index 6936ff7d33..5e215b52d5 100644
--- a/gdk/gdksurface.h
+++ b/gdk/gdksurface.h
@@ -107,7 +107,7 @@ gboolean gdk_surface_get_device_position (GdkSurface *surface,
double *y,
GdkModifierType *mask);
-GDK_AVAILABLE_IN_ALL
+GDK_DEPRECATED_IN_4_12
cairo_surface_t *
gdk_surface_create_similar_surface (GdkSurface *surface,
cairo_content_t content,
diff --git a/gdk/win32/gdkcairocontext-win32.c b/gdk/win32/gdkcairocontext-win32.c
index 480baf7802..e6cfb66c4d 100644
--- a/gdk/win32/gdkcairocontext-win32.c
+++ b/gdk/win32/gdkcairocontext-win32.c
@@ -88,10 +88,12 @@ gdk_win32_cairo_context_begin_frame (GdkDrawContext *draw_context,
g_clear_pointer (&self->db_surface, cairo_surface_destroy);
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
self->db_surface = gdk_surface_create_similar_surface (surface,
cairo_surface_get_content (self->window_surface),
self->db_width,
self->db_height);
+G_GNUC_END_IGNORE_DEPRECATIONS
}
/* Double-buffered windows paint on a DB surface.
diff --git a/gdk/x11/gdkcairocontext-x11.c b/gdk/x11/gdkcairocontext-x11.c
index e25ec197a7..6a9a3fdc84 100644
--- a/gdk/x11/gdkcairocontext-x11.c
+++ b/gdk/x11/gdkcairocontext-x11.c
@@ -67,10 +67,13 @@ gdk_x11_cairo_context_begin_frame (GdkDrawContext *draw_context,
cairo_region_get_extents (region, &clip_box);
self->window_surface = create_cairo_surface_for_surface (surface);
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
self->paint_surface = gdk_surface_create_similar_surface (surface,
cairo_surface_get_content (self->window_surface),
MAX (clip_box.width, 1),
MAX (clip_box.height, 1));
+G_GNUC_END_IGNORE_DEPRECATIONS
sx = sy = 1;
cairo_surface_get_device_scale (self->paint_surface, &sx, &sy);
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 9b62721fac..cf90a3bd7d 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -1360,15 +1360,17 @@ gtk_popover_update_shape (GtkPopover *popover)
cairo_t *cr;
graphene_point_t p;
double native_x, native_y;
+ int width, height, scale;
gtk_native_get_surface_transform (GTK_NATIVE (popover), &native_x, &native_y);
gtk_css_boxes_init (&content_css_boxes, priv->contents_widget);
- cairo_surface =
- gdk_surface_create_similar_surface (priv->surface,
- CAIRO_CONTENT_COLOR_ALPHA,
- gdk_surface_get_width (priv->surface),
- gdk_surface_get_height (priv->surface));
+ width = gdk_surface_get_width (priv->surface);
+ height = gdk_surface_get_height (priv->surface);
+ scale = gdk_surface_get_scale_factor (priv->surface);
+
+ cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width * scale, height * scale);
+ cairo_surface_set_device_scale (cairo_surface, scale, scale);
cr = cairo_create (cairo_surface);