unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Unifying code for drawing on a cairo context
@ 2022-04-23  9:06 Pfrommer, Julius
  2022-04-23  9:18 ` Eli Zaretskii
  2022-04-23 11:51 ` Po Lu
  0 siblings, 2 replies; 11+ messages in thread
From: Pfrommer, Julius @ 2022-04-23  9:06 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-04-29 10:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-23  9:06 Unifying code for drawing on a cairo context Pfrommer, Julius
2022-04-23  9:18 ` Eli Zaretskii
2022-04-23 11:58   ` Po Lu
2022-04-23 12:04     ` Eli Zaretskii
2022-04-29  8:01     ` Pfrommer, Julius
2022-04-29  8:33       ` Po Lu
2022-04-29  8:35         ` Po Lu
2022-04-29  9:07           ` Pfrommer, Julius
2022-04-29  9:20             ` Po Lu
2022-04-29 10:43       ` Eli Zaretskii
2022-04-23 11:51 ` Po Lu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).