[planner: 15/61] eel-canvas-rect: Port gdk_draw_rectangle to cairo
- From: Mart Raudsepp <mraudsepp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [planner: 15/61] eel-canvas-rect: Port gdk_draw_rectangle to cairo
- Date: Sat, 12 Jun 2021 17:30:22 +0000 (UTC)
commit dccd409ed3706691d94afd880bc6fdce432dd271
Author: Mart Raudsepp <leio gentoo org>
Date: Sat Mar 7 00:24:07 2020 +0200
eel-canvas-rect: Port gdk_draw_rectangle to cairo
One usage is simply dropped by not bothering to special-case
non-alpha use case, as it shouldn't be necessary for more than
some small performance benefits, and planner doesn't use it
without alpha anyways.
src/eel-canvas-rect.c | 39 +++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)
---
diff --git a/src/eel-canvas-rect.c b/src/eel-canvas-rect.c
index 0692d0a4..d9d62ea3 100644
--- a/src/eel-canvas-rect.c
+++ b/src/eel-canvas-rect.c
@@ -495,6 +495,7 @@ eel_canvas_rect_draw (GnomeCanvasItem *item,
double x1, y1, x2, y2;
int cx1, cy1, cx2, cy2;
double width_lt, width_rb;
+ cairo_t *cr;
rect = EEL_CANVAS_RECT (item);
details = rect->details;
@@ -521,34 +522,28 @@ eel_canvas_rect_draw (GnomeCanvasItem *item,
cx2 = MIN (width, cx2 - x);
cy2 = MIN (height, cy2 - y);
- if ((details->fill_color & 0xff) != 255) {
- render_rect_alpha (rect,
- drawable,
- cx1, cy1,
- cx2 - cx1, cy2 - cy1,
- details->fill_color);
- } else {
- if (details->fill_gc == NULL) {
- eel_canvas_rect_update_fill_gc (rect, TRUE);
- }
- gdk_draw_rectangle (drawable,
- details->fill_gc,
- TRUE,
- cx1, cy1,
- cx2, cy2);
- }
+ render_rect_alpha (rect,
+ drawable,
+ cx1, cy1,
+ cx2 - cx1, cy2 - cy1,
+ details->fill_color);
/* Box outline: */
gnome_canvas_w2c (item->canvas, x1, y1, &cx1, &cy1);
gnome_canvas_w2c (item->canvas, x2, y2, &cx2, &cy2);
- /* FIXME: Doesn't handle alpha for outline. Nautilus doesn't currently use this */
- gdk_draw_rectangle (drawable,
- details->outline_gc,
- FALSE,
- cx1 - x, cy1 - y,
- cx2 - cx1, cy2 - cy1);
+ cr = gdk_cairo_create (drawable);
+ cairo_set_line_width (cr, details->width_pixels);
+ cairo_set_source_rgb (cr,
+ ((details->outline_color >> 24) & 0xff) / 255,
+ ((details->outline_color >> 16) & 0xff) / 255,
+ ((details->outline_color >> 8) & 0xff) / 255);
+ cairo_rectangle (cr,
+ cx1 - x + 0.5, cy1 - y + 0.5,
+ cx2 - cx1, cy2 - cy1);
+ cairo_stroke (cr);
+ cairo_destroy (cr);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]