Skip to content

Commit

Permalink
winit and webrender decouple
Browse files Browse the repository at this point in the history
relocate crates out dir

wip

fix

decouple winit/webrender

set surfman size

fmt

decouple input_processor

decouple window from output

cleanup

wr_render_init

move scale_factor to display_info

move color bits to display info

new canvas from frame directly

some clean up

window id usin raw handle

wr output decouput font

wip

wip

wr output decouput font

build: use rust --cfg

Fixed Cargo nonsense

rust-lang/cargo#7463

rework winit_term configuration
  • Loading branch information
declantsien committed Feb 11, 2023
1 parent b71ad70 commit c71770f
Show file tree
Hide file tree
Showing 81 changed files with 2,945 additions and 2,230 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.in
@@ -0,0 +1,2 @@
[build]
rustflags = [@RUSTFLAGS_CFG@]
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -348,3 +348,4 @@ lib-src/seccomp-filter-exec.pfc
# GDB history
.gdb_history
_gdb_history
/.cargo/config.toml
19 changes: 6 additions & 13 deletions Cargo.in
Expand Up @@ -36,7 +36,8 @@ lsp_json = { version = "0.1.0", path = "rust_src/crates/lsp_json" }
git = { version = "0.1.0", path = "rust_src/crates/git", optional = true }
ng_module = { version = "0.1.0", path = "rust_src/crates/ng_module", optional = true }
js = { version = "0.1.0", path = "rust_src/crates/js", optional = true }
wrterm = { version = "0.1.0", path = "rust_src/crates/webrender", optional = true }
winit_term = { version = "0.1.0", path = "rust_src/crates/winit-term", optional = true }
webrender_bindings = { version = "0.1.0", path = "rust_src/crates/webrender", optional = true }
clippy = { version = "*", optional = true }
log = "0.4.17"
tracing = "0.1"
Expand All @@ -57,19 +58,11 @@ default = [

# Compile with C xml2 library support.
use-xml2 = []
# Use a window system
window-system = ["emacs/window-system"]
# Use the x11 window system
window-system-x11 = []
# Use the nextstep window system
window-system-nextstep = []
# Use the w32 window system
window-system-w32 = []
# Build with git2rs support
libgit = ["git", "ng-bindgen/libgit"]
# Use the webrender window system
webrender = ["dep:wrterm"]
window-system-webrender = ["ng-bindgen/window-system-webrender", "webrender"]
# Use the webrender renderer
webrender = ["dep:webrender_bindings"]
window-system-winit = ["dep:winit_term", "webrender"]
# Treat warnings as a build error on Travis.
strict = []
# Use JavaScript and Deno
Expand All @@ -96,7 +89,7 @@ rev = "0a53c767463e13346221ad23fa6dd50cd787cd72"

[patch.crates-io.surfman]
git ="https://github.com/declantsien/surfman.git"
rev = "ad2bf7faacb5b240a47ce280f72e914d1590712f"
rev = "caddee293e1f6ec8b33caec6170585a89c2674b8"

[patch.crates-io.surfman-chains]
git = "https://github.com/declantsien/surfman-chains.git"
Expand Down
123 changes: 72 additions & 51 deletions configure.ac
Expand Up @@ -536,10 +536,13 @@ otherwise for the first of 'inotify', 'kqueue' or 'gfile' that is usable.])
OPTION_DEFAULT_OFF([xwidgets],
[enable use of xwidgets in Emacs buffers (requires gtk3 or macOS Cocoa)])

OPTION_DEFAULT_OFF([webrender],
[enable use of webrender(written in Rust) as GUI backend on
OPTION_DEFAULT_OFF([winit],
[enable use of winit(written in Rust) as GUI backend on
multiple platforms(Linux, Windows and MacOS) (experimental)])

OPTION_DEFAULT_OFF([webrender],
[enable use of webrender(written in Rust) as rendering engine])

## Based on Deno 1.9.1
## Update the above when upgrading Deno
OPTION_DEFAULT_OFF([javascript],
Expand Down Expand Up @@ -1315,8 +1318,8 @@ AC_ARG_ENABLE(rust-debug,
Useful for debugging rust component of emacs-ng.])],
[ac_enable_rust_debug="${enableval}"],[])

AC_ARG_ENABLE(webrender-self-contained,
[AS_HELP_STRING([--disable-webrender-self-contained],
AC_ARG_ENABLE(winit-self-contained,
[AS_HELP_STRING([--disable-winit-self-contained],
[disable self contained Webrender build under NeXTstep])],
EN_NS_SELF_CONTAINED=$enableval,
EN_NS_SELF_CONTAINED=yes)
Expand All @@ -1326,10 +1329,10 @@ AC_ARG_ENABLE(webrender-capture,
[enable WebRender capture infrastructure.])],
[ac_enable_webrender_capture="${enableval}"],[])

AC_ARG_ENABLE(webrender-x11,
[AS_HELP_STRING([--enable-webrender-x11],
[enable WebRender X11 support.])],
[ac_enable_webrender_x11="${enableval}"],[])
AC_ARG_ENABLE(winit-x11,
[AS_HELP_STRING([--enable-winit-x11],
[enable Winit X11 support.])],
[ac_enable_winit_x11="${enableval}"],[])

AC_SUBST([AM_DEFAULT_VERBOSITY])
AC_CONFIG_FILES([src/verbose.mk])
Expand Down Expand Up @@ -2012,10 +2015,15 @@ AC_SUBST([AUTO_DEPEND])

window_system=none

if test "${with_webrender}" = "yes"; then
if test "${with_winit}" = "yes"; then
no_x=yes
with_ns=no
window_system=webrender
window_system=winit
with_webrender=yes
fi

if test "${with_webrender}" = "yes"; then
with_cairo=no
fi

if test "${with_pgtk}" = "yes"; then
Expand Down Expand Up @@ -2506,7 +2514,7 @@ dnl use the toolkit if we have gtk, or X11R5 or newer.
w32 )
term_header=w32term.h
;;
webrender )
winit )
term_header=wrterm.h
;;
pgtk )
Expand Down Expand Up @@ -6282,39 +6290,30 @@ AC_SUBST([XMENU_OBJ])
AC_SUBST([XOBJ])
AC_SUBST([FONT_OBJ])

WEBRENDER_LIBS=
WEBRENDER_IMPL_COCOA=no
if test "${window_system}" = "webrender" ; then
WINIT_LIBS=
WINIT_IMPL_COCOA=no
if test "${window_system}" = "winit" ; then

AC_DEFINE(USE_WEBRENDER, 1,
[Define to 1 if you want to use the webrender.])

AC_DEFINE(HAVE_NATIVE_IMAGE_API, 1, [Define to use native OS APIs for images.])
NATIVE_IMAGE_API="yes (webrender)"
AC_DEFINE(HAVE_WINIT, 1,
[Define to 1 if you want to use the Winit.])

if test "${opsys}" = gnu-linux; then
EMACS_CHECK_MODULES([FREETYPE], [freetype2])
test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(webrender requires libfreetype)

EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
test "$HAVE_FONTCONFIG" = "no" && AC_MSG_ERROR(webrender requires libfontconfig)

EMACS_CHECK_MODULES([XCB], [xcb >= 1.0.0])
test "$HAVE_XCB" = "no" && AC_MSG_ERROR(WebRender Unix build requires libxcb)
test "$HAVE_XCB" = "no" && AC_MSG_ERROR(Winit Unix build requires libxcb)

WEBRENDER_LIBS="$WEBRENDER_LIBS -lxcb -lxcb-xfixes -lxcb-shape -lxcb-render"
WINIT_LIBS="$WINIT_LIBS -lxcb -lxcb-xfixes -lxcb-shape -lxcb-render"

if test x$ac_enable_webrender_x11 != x; then
WEBRENDER_LIBS="-lX11 -lX11-xcb $WEBRENDER_LIBS"
if test x$ac_enable_winit_x11 != x; then
WINIT_LIBS="-lX11 -lX11-xcb $WINIT_LIBS"
fi
fi

if test "${opsys}" = darwin; then
WEBRENDER_IMPL_COCOA=yes
WINIT_IMPL_COCOA=yes
fi

if test "${EN_NS_SELF_CONTAINED}" = yes && test "${opsys}" = darwin; then
AC_DEFINE(NS_SELF_CONTAINED, 1, [Build an Webrender NS bundled app])
AC_DEFINE(NS_SELF_CONTAINED, 1, [Build an Winit NS bundled app])
ns_self_contained=yes
ns_appdir=`pwd`/nextstep/Emacs.app
ns_appbindir=${ns_appdir}/Contents/MacOS
Expand All @@ -6341,8 +6340,28 @@ if test "${window_system}" = "webrender" ; then
fi

fi
AC_SUBST(WINIT_OBJ)
AC_SUBST(WINIT_LIBS)
AC_SUBST(WINIT_IMPL_COCOA)

WEBRENDER_LIBS=
if test "${with_webrender}" = "yes" ; then
RUSTFLAGS_CFG="\"--cfg=use_webrender\", ${RUSTFLAGS_CFG}"
AC_DEFINE(USE_WEBRENDER, 1,
[Define to 1 if you want to use the webrender.])

AC_DEFINE(HAVE_NATIVE_IMAGE_API, 1, [Define to use native OS APIs for images.])
NATIVE_IMAGE_API="yes (webrender)"

if test "${opsys}" = gnu-linux; then
EMACS_CHECK_MODULES([FREETYPE], [freetype2])
test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(webrender requires libfreetype)

EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
test "$HAVE_FONTCONFIG" = "no" && AC_MSG_ERROR(webrender requires libfontconfig)
fi
fi
AC_SUBST(WEBRENDER_LIBS)
AC_SUBST(WEBRENDER_IMPL_COCOA)

WIDGET_OBJ=
MOTIF_LIBW=
Expand Down Expand Up @@ -7017,33 +7036,29 @@ fi || AC_MSG_ERROR(['src/epaths.h' could not be made.])
window_system="$window_system" EN_NS_SELF_CONTAINED="$EN_NS_SELF_CONTAINED"])

CARGO_DEFAULT_FEATURES=""
WINIT_DEFAULT_FEATURES=""
WEBRENDER_DEFAULT_FEATURES=""
if test "$HAVE_LIBXML2" = "yes"; then
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"use-xml2\", "
fi
if test "$window_system" != "none"; then
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system\", "
fi
dnl if test "$window_system" != "none"; then
RUSTFLAGS_CFG="\"--cfg=have_window_system\", ${RUSTFLAGS_CFG}"
dnl fi
RUSTFLAGS_CFG="\"--cfg=window_system=\\\"$window_system\\\"\", ${RUSTFLAGS_CFG}"
case "$window_system" in
x11)
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-x11\", "
;;
nextstep)
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-nextstep\", "
;;
w32)
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-w32\", "
;;
webrender)
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-webrender\", "
if test x$ac_enable_webrender_capture != x ; then
WEBRENDER_DEFAULT_FEATURES="\"wr_capture\", ${WEBRENDER_DEFAULT_FEATURES}"
fi
if test x$ac_enable_webrender_x11 != x ; then
WEBRENDER_DEFAULT_FEATURES="\"wr_x11\", ${WEBRENDER_DEFAULT_FEATURES}"
winit)
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-winit\", "
if test x$ac_enable_winit_x11 != x ; then
WINIT_DEFAULT_FEATURES="\"x11\", ${WINIT_DEFAULT_FEATURES}"
fi
;;
esac
if test "${with_webrender}" = "yes" ; then
if test x$ac_enable_webrender_capture != x ; then
WEBRENDER_DEFAULT_FEATURES="\"wr_capture\", ${WINIT_DEFAULT_FEATURES}"
fi
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"webrender\", "
fi
if test "$HAVE_LIBGIT" = "yes"; then
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"libgit\", "
fi
Expand All @@ -7054,11 +7069,17 @@ fi
if test "${HAVE_MODULES}" = "yes"; then
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"ng-module\", "
fi

AC_SUBST(RUSTFLAGS_CFG)
AC_SUBST(CARGO_DEFAULT_FEATURES)
AC_SUBST(WINIT_DEFAULT_FEATURES)
AC_SUBST(WEBRENDER_DEFAULT_FEATURES)
AC_CONFIG_FILES([Cargo.toml:Cargo.in])
webrender_src=$srcdir/rust_src/crates/webrender
AC_CONFIG_FILES([$webrender_src/Cargo.toml:$webrender_src/Cargo.in])
winit_term_src=$srcdir/rust_src/crates/winit-term
AC_CONFIG_FILES([$winit_term_src/Cargo.toml:$winit_term_src/Cargo.in])
AC_CONFIG_FILES([$srcdir/.cargo/config.toml:$srcdir/.cargo/config.in])
AC_CONFIG_FILES([$srcdir/rust_src/crates/emacs/build.rs])

dnl NB we have to cheat and use the ac_... version because abs_top_srcdir
Expand Down
10 changes: 5 additions & 5 deletions lisp/cus-edit.el
Expand Up @@ -2209,15 +2209,15 @@ and `face'."
;;; The `custom' Widget.

(defface custom-button
'((((type x w32 ns haiku pgtk wr) (class color)) ; Like default mode line
'((((type x w32 ns haiku pgtk winit) (class color)) ; Like default mode line
:box (:line-width 2 :style released-button)
:background "lightgrey" :foreground "black"))
"Face for custom buffer buttons if `custom-raised-buttons' is non-nil."
:version "21.1"
:group 'custom-faces)

(defface custom-button-mouse
'((((type x w32 ns haiku pgtk wr) (class color))
'((((type x w32 ns haiku pgtk winit) (class color))
:box (:line-width 2 :style released-button)
:background "grey90" :foreground "black")
(t
Expand All @@ -2242,7 +2242,7 @@ and `face'."
(if custom-raised-buttons 'custom-button-mouse 'highlight))

(defface custom-button-pressed
'((((type x w32 ns haiku pgtk wr) (class color))
'((((type x w32 ns haiku pgtk winit) (class color))
:box (:line-width 2 :style pressed-button)
:background "lightgrey" :foreground "black")
(t :inverse-video t))
Expand Down Expand Up @@ -3534,10 +3534,10 @@ GNUstep or Macintosh OS Cocoa interface.")
:sibling-args (:help-echo "\
Pure-GTK interface.")
ns)
(const :format "WR "
(const :format "winit"
:sibling-args (:help-echo "\
WebRender interface.")
ns)
winit)
(const :format "DOS "
:sibling-args (:help-echo "\
Plain MS-DOS.")
Expand Down
2 changes: 1 addition & 1 deletion lisp/emacs-lisp/icons.el
Expand Up @@ -33,7 +33,7 @@
:group 'customize)

(defface icon-button
'((((type x w32 ns haiku pgtk wr) (class color))
'((((type x w32 ns haiku pgtk winit) (class color))
:inherit icon
:box (:line-width (3 . -1) :color "#404040" :style flat-button)
:background "#808080"
Expand Down
6 changes: 3 additions & 3 deletions lisp/faces.el
Expand Up @@ -1224,7 +1224,7 @@ an integer value."
(:height
'integerp)
(:stipple
(and (memq (window-system frame) '(x ns pgtk haiku wr)) ; No stipple on w32
(and (memq (window-system frame) '(x ns pgtk haiku winit)) ; No stipple on w32
(mapcar (lambda (item)
(cons item item))
(apply #'nconc
Expand Down Expand Up @@ -1569,7 +1569,7 @@ If FRAME is nil, the current FRAME is used."
match (cond ((eq req 'type)
(or (memq (window-system frame) options)
(and (memq 'graphic options)
(memq (window-system frame) '(x w32 ns pgtk wr)))
(memq (window-system frame) '(x w32 ns pgtk winit)))
;; FIXME: This should be revisited to use
;; display-graphic-p, provided that the
;; color selection depends on the number
Expand Down Expand Up @@ -2920,7 +2920,7 @@ Note: Other faces cannot inherit from the cursor face."
(((type haiku))
:foreground "B_MENU_ITEM_TEXT_COLOR"
:background "B_MENU_BACKGROUND_COLOR")
(((type x w32 ns pgtk wr) (class color))
(((type x w32 ns pgtk winit) (class color))
:background "grey75")
(((type x) (class mono))
:background "grey"))
Expand Down

0 comments on commit c71770f

Please sign in to comment.