[gnome-games] snapshot-row: Clip instead of masking
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] snapshot-row: Clip instead of masking
- Date: Tue, 16 Jun 2020 15:27:07 +0000 (UTC)
commit 90726675b1b85a9673345d96c165f61bb3a6c4e3
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Jun 16 20:26:35 2020 +0500
snapshot-row: Clip instead of masking
src/ui/snapshot-row.vala | 35 +++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)
---
diff --git a/src/ui/snapshot-row.vala b/src/ui/snapshot-row.vala
index 8cca1725..c7be1602 100644
--- a/src/ui/snapshot-row.vala
+++ b/src/ui/snapshot-row.vala
@@ -48,7 +48,7 @@ private class Games.SnapshotRow : Gtk.ListBoxRow {
Gdk.Pixbuf.get_file_info (screenshot_path, out screenshot_width, out screenshot_height);
- var aspect_ratio = snapshot.screenshot_aspect_ratio;
+ var aspect_ratio = 1.0;//snapshot.screenshot_aspect_ratio;
// A fallback for migrated snapshots
if (aspect_ratio == 0)
@@ -121,44 +121,27 @@ private class Games.SnapshotRow : Gtk.ListBoxRow {
if (pixbuf == null)
return Gdk.EVENT_PROPAGATE;
+ var flags = image.get_state_flags ();
+ var border_radius = (int) style.get_property (Gtk.STYLE_PROPERTY_BORDER_RADIUS, flags);
+ border_radius = border_radius.clamp (0, int.max (width / 2, height / 2));
+
+ rounded_rectangle (cr, 0.5, 0.5, width - 1, height - 1, border_radius);
+ cr.clip ();
+
cr.save ();
cr.scale (1.0 / scale_factor, 1.0 / scale_factor);
- var mask = get_mask ();
-
var x_offset = (width * scale_factor - pixbuf.width) / 2;
var y_offset = (height * scale_factor - pixbuf.height) / 2;
Gdk.cairo_set_source_pixbuf (cr, pixbuf, x_offset, y_offset);
-
- cr.mask_surface (mask, 0, 0);
+ cr.paint ();
cr.restore ();
return Gdk.EVENT_PROPAGATE;
}
- // TODO: Share this with GameThumbnail
- private Cairo.Surface get_mask () {
- var width = image.get_allocated_width ();
- var height = image.get_allocated_height ();
-
- var mask = new Cairo.ImageSurface (Cairo.Format.A8, width * scale_factor, height *
scale_factor);
-
- var style = image.get_style_context ();
- var flags = image.get_state_flags ();
- var border_radius = (int) style.get_property (Gtk.STYLE_PROPERTY_BORDER_RADIUS, flags);
- border_radius = border_radius.clamp (0, int.max (width / 2, height / 2));
-
- var cr = new Cairo.Context (mask);
- cr.scale (scale_factor, scale_factor);
- cr.set_source_rgb (0, 0, 0);
- rounded_rectangle (cr, 0.5, 0.5, width - 1, height - 1, border_radius);
- cr.fill ();
-
- return mask;
- }
-
// TODO: Share this with GameThumbnail
private void rounded_rectangle (Cairo.Context cr, double x, double y, double width, double height,
double radius) {
const double ARC_0 = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]