[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unifying code for drawing on a cairo context
From: |
Pfrommer, Julius |
Subject: |
Unifying code for drawing on a cairo context |
Date: |
Sat, 23 Apr 2022 11:06:16 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 |
The X and the PGTK toolkits both support a cairo "glass". Their code for
drawing on a cairo context is virtually identical. Yet the
implementations have started to diverge.
As an example, x_draw_horizontal_wave and pgtk_draw_horizontal_wave are
virtually the same. But the X implementation takes a "GC" graphics
context, whereas the PGTK implementation now takes a "color" integer
argument.
https://git.savannah.gnu.org/cgit/emacs.git/tree/src/xterm.c#n5155
https://git.savannah.gnu.org/cgit/emacs.git/tree/src/pgtkterm.c#n1995
Obviously maintaining duplicate code is an anti-pattern. I'd like to
pull out common cairo functionality bit-by-bit into methods to be used
by both the X and the PGTK toolkit.
With the cairo primitives unified between X and PGTK, adding a cairo
"glass" for more toolkits should also become easier as a future option
(ns, haiku, w32).
But I'm unsure about how this fits with ongoing development and which
conventions to follow.
- Would the unified cairo function be called cairo_draw_horizontal_wave,
establishing a new cairo_ prefix convention?
- Should such functions generally take an immediate cairo_t context as
input or some "larger" struct that includes that cairo_t and can be
extended in the future (e.g. with foreground and background color
information).
- Is it okay to create the files cairoterm.h/.c or can we expect
functionality beyond "term" to be added over time as well?
Regards,
Julius
- Unifying code for drawing on a cairo context,
Pfrommer, Julius <=
- Re: Unifying code for drawing on a cairo context, Eli Zaretskii, 2022/04/23
- Re: Unifying code for drawing on a cairo context, Po Lu, 2022/04/23
- Re: Unifying code for drawing on a cairo context, Eli Zaretskii, 2022/04/23
- Re: Unifying code for drawing on a cairo context, Pfrommer, Julius, 2022/04/29
- Re: Unifying code for drawing on a cairo context, Po Lu, 2022/04/29
- Re: Unifying code for drawing on a cairo context, Po Lu, 2022/04/29
- Re: Unifying code for drawing on a cairo context, Pfrommer, Julius, 2022/04/29
- Re: Unifying code for drawing on a cairo context, Po Lu, 2022/04/29
- Re: Unifying code for drawing on a cairo context, Eli Zaretskii, 2022/04/29
Re: Unifying code for drawing on a cairo context, Po Lu, 2022/04/23