GNU bug report logs -
#31288
27.0.50; [PATCH] Make cairo build somewhat usable
Previous Next
Reported by: Ari Roponen <ari.roponen <at> gmail.com>
Date: Fri, 27 Apr 2018 13:20:02 UTC
Severity: normal
Tags: patch
Found in version 27.0.50
Done: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31288 in the body.
You can then email your comments to 31288 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31288
; Package
emacs
.
(Fri, 27 Apr 2018 13:20:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ari Roponen <ari.roponen <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 27 Apr 2018 13:20:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Attached are two patches to make --with-cairo builds more usable.
First patch tries to fix screen corruption, and the second patch allows
cairo builds to display images.
These patches are only slightly tested, but I hope they will be useful.
In GNU Emacs 27.0.50 (build 10, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
of 2018-04-27 built on arirop
Repository revision: caa93364d47bd28633cc065e31dd5972a1e916d5
Windowing system distributor 'Fedora Project', version 11.0.11906000
System Description: Fedora 28 (Twenty Eight)
[0001-Fix-cairo-problems.patch (text/x-patch, inline)]
From 3e93c1a5290bbed7a9b923e1a16f930ec0fbd74a Mon Sep 17 00:00:00 2001
From: Ari Roponen <ari.roponen <at> gmail.com>
Date: Fri, 27 Apr 2018 15:13:12 +0300
Subject: [PATCH 1/2] Fix cairo problems
* src/xterm.c (x_begin_cr_clip): Create image surface.
(x_update_end) [USE_CAIRO]: Disable GTK3-specific code for now.
(x_scroll_run) [USE_CAIRO]: Implement scrolling.
---
src/xterm.c | 41 ++++++++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index 6ab4a03002..52fe24e0fb 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -360,17 +360,12 @@ x_begin_cr_clip (struct frame *f, GC gc)
if (! FRAME_CR_SURFACE (f))
{
- cairo_surface_t *surface;
- surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f),
- FRAME_X_DRAWABLE (f),
- FRAME_DISPLAY_INFO (f)->visual,
- FRAME_PIXEL_WIDTH (f),
- FRAME_PIXEL_HEIGHT (f));
- cr = cairo_create (surface);
- cairo_surface_destroy (surface);
- }
- else
- cr = cairo_create (FRAME_CR_SURFACE (f));
+ FRAME_CR_SURFACE (f) =
+ cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ FRAME_PIXEL_WIDTH (f),
+ FRAME_PIXEL_HEIGHT (f));
+ }
+ cr = cairo_create (FRAME_CR_SURFACE (f));
FRAME_CR_CONTEXT (f) = cr;
}
cairo_save (cr);
@@ -1236,7 +1231,8 @@ x_update_end (struct frame *f)
{
cairo_t *cr = 0;
block_input();
-#if defined (USE_GTK) && defined (HAVE_GTK3)
+ /* FIXME */
+#if 0 && defined (USE_GTK) && defined (HAVE_GTK3)
if (FRAME_GTK_WIDGET (f))
{
GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
@@ -4271,7 +4267,26 @@ x_scroll_run (struct window *w, struct run *run)
x_clear_cursor (w);
#ifdef USE_CAIRO
- SET_FRAME_GARBAGED (f);
+ if (FRAME_CR_CONTEXT (f))
+ {
+ cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ width, height);
+ cairo_t *cr = cairo_create (s);
+ cairo_set_source_surface (cr, cairo_get_target (FRAME_CR_CONTEXT (f)),
+ -x, -from_y);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ cr = FRAME_CR_CONTEXT (f);
+ cairo_save (cr);
+ cairo_set_source_surface (cr, s, 0, to_y);
+ cairo_rectangle (cr, x, to_y, width, height);
+ cairo_fill (cr);
+ cairo_restore (cr);
+ cairo_surface_destroy (s);
+ } else {
+ SET_FRAME_GARBAGED (f);
+ }
#else
XCopyArea (FRAME_X_DISPLAY (f),
FRAME_X_DRAWABLE (f), FRAME_X_DRAWABLE (f),
--
2.17.0
[0002-Add-partial-image-support-for-cairo-builds.patch (text/x-patch, inline)]
From 6a379d983544b3e1b241860854646ca039724151 Mon Sep 17 00:00:00 2001
From: Ari Roponen <ari.roponen <at> gmail.com>
Date: Fri, 27 Apr 2018 15:14:36 +0300
Subject: [PATCH 2/2] Add partial image support for cairo builds
* src/image.c (lookup_rgb_color): Add cairo support.
(jpeg_load_body): Fix preprocessor symbol. Move colors definition
into non-cairo part.
(imagemagick_load_image) [USE_CAIRO]: Add partial support for
cairo.
---
src/image.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/image.c b/src/image.c
index 37416c1616..4c3f6c5ab0 100644
--- a/src/image.c
+++ b/src/image.c
@@ -4629,6 +4629,8 @@ lookup_rgb_color (struct frame *f, int r, int g, int b)
return PALETTERGB (r >> 8, g >> 8, b >> 8);
#elif defined HAVE_NS
return RGB_TO_ULONG (r >> 8, g >> 8, b >> 8);
+#elif defined USE_CAIRO
+ return (0xffu << 24) | (r << 16) | (g << 8) | b;
#else
xsignal1 (Qfile_error,
build_string ("This Emacs mishandles this image file type"));
@@ -6702,10 +6704,10 @@ jpeg_load_body (struct frame *f, struct image *img,
FILE *volatile fp = NULL;
JSAMPARRAY buffer;
int row_stride, x, y;
- unsigned long *colors;
int width, height;
int i, ir, ig, ib;
#ifndef USE_CAIRO
+ unsigned long *colors;
XImagePtr ximg = NULL;
#endif
@@ -6823,7 +6825,7 @@ jpeg_load_body (struct frame *f, struct image *img,
else
ir = 0, ig = 0, ib = 0;
-#ifndef CAIRO
+#ifndef USE_CAIRO
/* Use the color table mechanism because it handles colors that
cannot be allocated nicely. Such colors will be replaced with
a default color, and we don't have to care about which colors
@@ -8551,6 +8553,9 @@ imagemagick_load_image (struct frame *f, struct image *img,
double rotation;
char hint_buffer[MaxTextExtent];
char *filename_hint = NULL;
+#ifdef USE_CAIRO
+ void *data;
+#endif
/* Initialize the ImageMagick environment. */
static bool imagemagick_initialized;
@@ -8751,6 +8756,19 @@ imagemagick_load_image (struct frame *f, struct image *img,
/* We can now get a valid pixel buffer from the imagemagick file, if all
went ok. */
+#ifdef USE_CAIRO
+ data = xmalloc (width * height * 4);
+#ifdef HAVE_MAGICKEXPORTIMAGEPIXELS
+ MagickExportImagePixels (image_wand, 0, 0, width, height,
+ "BGRA", CharPixel, data);
+#else
+ /* FIXME: Implement this. For now, make it white. */
+ memset(data, 0xff, width * height * 4);
+#endif
+ create_cairo_image_surface (img, data, width, height);
+ goto done;
+#endif /* USE_CAIRO */
+
init_color_table ();
#if defined (HAVE_MAGICKEXPORTIMAGEPIXELS) && ! defined (HAVE_NS)
@@ -8861,6 +8879,9 @@ imagemagick_load_image (struct frame *f, struct image *img,
/* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0);
+#ifdef USE_CAIRO
+ done:
+#endif
/* Final cleanup. image_wand should be the only resource left. */
DestroyMagickWand (image_wand);
if (bg_wand) DestroyPixelWand (bg_wand);
--
2.17.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31288
; Package
emacs
.
(Fri, 27 Apr 2018 14:16:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 31288 <at> debbugs.gnu.org (full text, mbox):
> From: Ari Roponen <ari.roponen <at> gmail.com>
> Date: Fri, 27 Apr 2018 16:19:16 +0300
>
> Attached are two patches to make --with-cairo builds more usable.
>
> First patch tries to fix screen corruption, and the second patch allows
> cairo builds to display images.
Thank you for working on this.
Please allow me a couple of minor comments on the changes:
> @@ -1236,7 +1231,8 @@ x_update_end (struct frame *f)
> {
> cairo_t *cr = 0;
> block_input();
> -#if defined (USE_GTK) && defined (HAVE_GTK3)
> + /* FIXME */
> +#if 0 && defined (USE_GTK) && defined (HAVE_GTK3)
> if (FRAME_GTK_WIDGET (f))
> {
> GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
This hunk doesn't look right. If the code in question causes some
trouble to a Cairo build, please ifdef it out only when USE_CAIRO is
defined, not unconditionally. And if that still needs a FIXME
comment, please add some description of what needs to be fixed and
why.
> + cairo_surface_destroy (s);
> + } else {
> + SET_FRAME_GARBAGED (f);
Please use GNU style of braces.
Thanks again.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31288
; Package
emacs
.
(Fri, 27 Apr 2018 14:37:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 31288 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>
> Please allow me a couple of minor comments on the changes:
>
>> @@ -1236,7 +1231,8 @@ x_update_end (struct frame *f)
>> {
>> cairo_t *cr = 0;
>> block_input();
>> -#if defined (USE_GTK) && defined (HAVE_GTK3)
>> + /* FIXME */
>> +#if 0 && defined (USE_GTK) && defined (HAVE_GTK3)
>> if (FRAME_GTK_WIDGET (f))
>> {
>> GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
>
> This hunk doesn't look right. If the code in question causes some
> trouble to a Cairo build, please ifdef it out only when USE_CAIRO is
> defined, not unconditionally. And if that still needs a FIXME
> comment, please add some description of what needs to be fixed and
> why.
>
That hunk is inside #ifdef USE_CAIRO, like almost the whole body of
x_update_end.
>> + cairo_surface_destroy (s);
>> + } else {
>> + SET_FRAME_GARBAGED (f);
>
> Please use GNU style of braces.
>
Done. New patch attached.
[0001-Fix-cairo-problems.patch (text/x-patch, inline)]
From dd7b085d569be5f1eb4412e28ac73f3f304eeb0f Mon Sep 17 00:00:00 2001
From: Ari Roponen <ari.roponen <at> gmail.com>
Date: Fri, 27 Apr 2018 15:13:12 +0300
Subject: [PATCH 1/2] Fix cairo problems
* src/xterm.c (x_begin_cr_clip): Create image surface.
(x_update_end) [USE_CAIRO]: Disable GTK3-specific code for now.
(x_scroll_run) [USE_CAIRO]: Implement scrolling.
---
src/xterm.c | 43 ++++++++++++++++++++++++++++++-------------
1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index 6ab4a03002..2a1c7e9edc 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -360,17 +360,12 @@ x_begin_cr_clip (struct frame *f, GC gc)
if (! FRAME_CR_SURFACE (f))
{
- cairo_surface_t *surface;
- surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f),
- FRAME_X_DRAWABLE (f),
- FRAME_DISPLAY_INFO (f)->visual,
- FRAME_PIXEL_WIDTH (f),
- FRAME_PIXEL_HEIGHT (f));
- cr = cairo_create (surface);
- cairo_surface_destroy (surface);
- }
- else
- cr = cairo_create (FRAME_CR_SURFACE (f));
+ FRAME_CR_SURFACE (f) =
+ cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ FRAME_PIXEL_WIDTH (f),
+ FRAME_PIXEL_HEIGHT (f));
+ }
+ cr = cairo_create (FRAME_CR_SURFACE (f));
FRAME_CR_CONTEXT (f) = cr;
}
cairo_save (cr);
@@ -1236,7 +1231,8 @@ x_update_end (struct frame *f)
{
cairo_t *cr = 0;
block_input();
-#if defined (USE_GTK) && defined (HAVE_GTK3)
+ /* FIXME */
+#if 0 && defined (USE_GTK) && defined (HAVE_GTK3)
if (FRAME_GTK_WIDGET (f))
{
GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
@@ -4271,7 +4267,28 @@ x_scroll_run (struct window *w, struct run *run)
x_clear_cursor (w);
#ifdef USE_CAIRO
- SET_FRAME_GARBAGED (f);
+ if (FRAME_CR_CONTEXT (f))
+ {
+ cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ width, height);
+ cairo_t *cr = cairo_create (s);
+ cairo_set_source_surface (cr, cairo_get_target (FRAME_CR_CONTEXT (f)),
+ -x, -from_y);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ cr = FRAME_CR_CONTEXT (f);
+ cairo_save (cr);
+ cairo_set_source_surface (cr, s, 0, to_y);
+ cairo_rectangle (cr, x, to_y, width, height);
+ cairo_fill (cr);
+ cairo_restore (cr);
+ cairo_surface_destroy (s);
+ }
+ else
+ {
+ SET_FRAME_GARBAGED (f);
+ }
#else
XCopyArea (FRAME_X_DISPLAY (f),
FRAME_X_DRAWABLE (f), FRAME_X_DRAWABLE (f),
--
2.17.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31288
; Package
emacs
.
(Fri, 27 Apr 2018 14:57:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 31288 <at> debbugs.gnu.org (full text, mbox):
> From: Ari Roponen <ari.roponen <at> gmail.com>
> Cc: 31288 <at> debbugs.gnu.org
> Date: Fri, 27 Apr 2018 17:35:58 +0300
>
> >> -#if defined (USE_GTK) && defined (HAVE_GTK3)
> >> + /* FIXME */
> >> +#if 0 && defined (USE_GTK) && defined (HAVE_GTK3)
> >> if (FRAME_GTK_WIDGET (f))
> >> {
> >> GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
> >
> > This hunk doesn't look right. If the code in question causes some
> > trouble to a Cairo build, please ifdef it out only when USE_CAIRO is
> > defined, not unconditionally. And if that still needs a FIXME
> > comment, please add some description of what needs to be fixed and
> > why.
> >
>
> That hunk is inside #ifdef USE_CAIRO, like almost the whole body of
> x_update_end.
Ah, sorry I missed that. Still, what is the FIXME there? why not
simply remove that part?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31288
; Package
emacs
.
(Fri, 27 Apr 2018 15:53:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 31288 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
> Ah, sorry I missed that. Still, what is the FIXME there? why not
> simply remove that part?
Ok. Now it's removed. New patch attached.
Thank you for your comments.
[0001-Fix-cairo-problems.patch (text/x-patch, inline)]
From d54819cb834fddce7488e8f6ebb392a53978b421 Mon Sep 17 00:00:00 2001
From: Ari Roponen <ari.roponen <at> gmail.com>
Date: Fri, 27 Apr 2018 15:13:12 +0300
Subject: [PATCH 1/2] Fix cairo problems
* src/xterm.c (x_begin_cr_clip): Create image surface.
(x_update_end) [USE_CAIRO]: Remove GTK3-specific code.
(x_scroll_run) [USE_CAIRO]: Implement scrolling.
---
src/xterm.c | 83 +++++++++++++++++++++++++++++------------------------
1 file changed, 45 insertions(+), 38 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index 6ab4a03002..2f3fe58c2a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -360,17 +360,12 @@ x_begin_cr_clip (struct frame *f, GC gc)
if (! FRAME_CR_SURFACE (f))
{
- cairo_surface_t *surface;
- surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f),
- FRAME_X_DRAWABLE (f),
- FRAME_DISPLAY_INFO (f)->visual,
- FRAME_PIXEL_WIDTH (f),
- FRAME_PIXEL_HEIGHT (f));
- cr = cairo_create (surface);
- cairo_surface_destroy (surface);
- }
- else
- cr = cairo_create (FRAME_CR_SURFACE (f));
+ FRAME_CR_SURFACE (f) =
+ cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ FRAME_PIXEL_WIDTH (f),
+ FRAME_PIXEL_HEIGHT (f));
+ }
+ cr = cairo_create (FRAME_CR_SURFACE (f));
FRAME_CR_CONTEXT (f) = cr;
}
cairo_save (cr);
@@ -1232,40 +1227,31 @@ x_update_end (struct frame *f)
MOUSE_HL_INFO (f)->mouse_face_defer = false;
#ifdef USE_CAIRO
+ block_input();
+
if (FRAME_CR_SURFACE (f))
{
cairo_t *cr = 0;
- block_input();
-#if defined (USE_GTK) && defined (HAVE_GTK3)
- if (FRAME_GTK_WIDGET (f))
- {
- GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
- cr = gdk_cairo_create (w);
- }
- else
-#endif
- {
- cairo_surface_t *surface;
- int width = FRAME_PIXEL_WIDTH (f);
- int height = FRAME_PIXEL_HEIGHT (f);
- if (! FRAME_EXTERNAL_TOOL_BAR (f))
- height += FRAME_TOOL_BAR_HEIGHT (f);
- if (! FRAME_EXTERNAL_MENU_BAR (f))
- height += FRAME_MENU_BAR_HEIGHT (f);
- surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f),
- FRAME_X_DRAWABLE (f),
- FRAME_DISPLAY_INFO (f)->visual,
- width,
- height);
- cr = cairo_create (surface);
- cairo_surface_destroy (surface);
- }
+ cairo_surface_t *surface;
+ int width = FRAME_PIXEL_WIDTH (f);
+ int height = FRAME_PIXEL_HEIGHT (f);
+ if (! FRAME_EXTERNAL_TOOL_BAR (f))
+ height += FRAME_TOOL_BAR_HEIGHT (f);
+ if (! FRAME_EXTERNAL_MENU_BAR (f))
+ height += FRAME_MENU_BAR_HEIGHT (f);
+ surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f),
+ FRAME_X_DRAWABLE (f),
+ FRAME_DISPLAY_INFO (f)->visual,
+ width,
+ height);
+ cr = cairo_create (surface);
+ cairo_surface_destroy (surface);
cairo_set_source_surface (cr, FRAME_CR_SURFACE (f), 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
- unblock_input ();
}
+ unblock_input ();
#endif
#ifndef XFlush
@@ -4271,7 +4257,28 @@ x_scroll_run (struct window *w, struct run *run)
x_clear_cursor (w);
#ifdef USE_CAIRO
- SET_FRAME_GARBAGED (f);
+ if (FRAME_CR_CONTEXT (f))
+ {
+ cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ width, height);
+ cairo_t *cr = cairo_create (s);
+ cairo_set_source_surface (cr, cairo_get_target (FRAME_CR_CONTEXT (f)),
+ -x, -from_y);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ cr = FRAME_CR_CONTEXT (f);
+ cairo_save (cr);
+ cairo_set_source_surface (cr, s, 0, to_y);
+ cairo_rectangle (cr, x, to_y, width, height);
+ cairo_fill (cr);
+ cairo_restore (cr);
+ cairo_surface_destroy (s);
+ }
+ else
+ {
+ SET_FRAME_GARBAGED (f);
+ }
#else
XCopyArea (FRAME_X_DISPLAY (f),
FRAME_X_DRAWABLE (f), FRAME_X_DRAWABLE (f),
--
2.17.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31288
; Package
emacs
.
(Sat, 28 Apr 2018 07:34:03 GMT)
Full text and
rfc822 format available.
Message #20 received at 31288 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi,
attached are new versions of patches. This time, the cairo support for
imagemagick is better integrated into existing code.
[0001-Fix-cairo-problems.patch (text/x-patch, inline)]
From d197ca49c2f0ff6b73e4410ba8e3414f3bbf2e1d Mon Sep 17 00:00:00 2001
From: Ari Roponen <ari.roponen <at> gmail.com>
Date: Fri, 27 Apr 2018 15:13:12 +0300
Subject: [PATCH 1/2] Fix cairo problems
* src/xterm.c (x_begin_cr_clip): Create image surface.
(x_update_end) [USE_CAIRO]: Remove GTK3-specific code.
(x_scroll_run) [USE_CAIRO]: Implement scrolling.
---
src/xterm.c | 84 +++++++++++++++++++++++++++++------------------------
1 file changed, 46 insertions(+), 38 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index 6ab4a03002..35e10568fa 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -360,17 +360,12 @@ x_begin_cr_clip (struct frame *f, GC gc)
if (! FRAME_CR_SURFACE (f))
{
- cairo_surface_t *surface;
- surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f),
- FRAME_X_DRAWABLE (f),
- FRAME_DISPLAY_INFO (f)->visual,
- FRAME_PIXEL_WIDTH (f),
- FRAME_PIXEL_HEIGHT (f));
- cr = cairo_create (surface);
- cairo_surface_destroy (surface);
- }
- else
- cr = cairo_create (FRAME_CR_SURFACE (f));
+ FRAME_CR_SURFACE (f) =
+ cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ FRAME_PIXEL_WIDTH (f),
+ FRAME_PIXEL_HEIGHT (f));
+ }
+ cr = cairo_create (FRAME_CR_SURFACE (f));
FRAME_CR_CONTEXT (f) = cr;
}
cairo_save (cr);
@@ -1234,32 +1229,24 @@ x_update_end (struct frame *f)
#ifdef USE_CAIRO
if (FRAME_CR_SURFACE (f))
{
- cairo_t *cr = 0;
- block_input();
-#if defined (USE_GTK) && defined (HAVE_GTK3)
- if (FRAME_GTK_WIDGET (f))
- {
- GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
- cr = gdk_cairo_create (w);
- }
- else
-#endif
- {
- cairo_surface_t *surface;
- int width = FRAME_PIXEL_WIDTH (f);
- int height = FRAME_PIXEL_HEIGHT (f);
- if (! FRAME_EXTERNAL_TOOL_BAR (f))
- height += FRAME_TOOL_BAR_HEIGHT (f);
- if (! FRAME_EXTERNAL_MENU_BAR (f))
- height += FRAME_MENU_BAR_HEIGHT (f);
- surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f),
- FRAME_X_DRAWABLE (f),
- FRAME_DISPLAY_INFO (f)->visual,
- width,
- height);
- cr = cairo_create (surface);
- cairo_surface_destroy (surface);
- }
+ cairo_t *cr;
+ cairo_surface_t *surface;
+ int width, height;
+
+ block_input ();
+ width = FRAME_PIXEL_WIDTH (f);
+ height = FRAME_PIXEL_HEIGHT (f);
+ if (! FRAME_EXTERNAL_TOOL_BAR (f))
+ height += FRAME_TOOL_BAR_HEIGHT (f);
+ if (! FRAME_EXTERNAL_MENU_BAR (f))
+ height += FRAME_MENU_BAR_HEIGHT (f);
+ surface = cairo_xlib_surface_create (FRAME_X_DISPLAY (f),
+ FRAME_X_DRAWABLE (f),
+ FRAME_DISPLAY_INFO (f)->visual,
+ width,
+ height);
+ cr = cairo_create (surface);
+ cairo_surface_destroy (surface);
cairo_set_source_surface (cr, FRAME_CR_SURFACE (f), 0, 0);
cairo_paint (cr);
@@ -4271,7 +4258,28 @@ x_scroll_run (struct window *w, struct run *run)
x_clear_cursor (w);
#ifdef USE_CAIRO
- SET_FRAME_GARBAGED (f);
+ if (FRAME_CR_CONTEXT (f))
+ {
+ cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ width, height);
+ cairo_t *cr = cairo_create (s);
+ cairo_set_source_surface (cr, cairo_get_target (FRAME_CR_CONTEXT (f)),
+ -x, -from_y);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ cr = FRAME_CR_CONTEXT (f);
+ cairo_save (cr);
+ cairo_set_source_surface (cr, s, 0, to_y);
+ cairo_rectangle (cr, x, to_y, width, height);
+ cairo_fill (cr);
+ cairo_restore (cr);
+ cairo_surface_destroy (s);
+ }
+ else
+ {
+ SET_FRAME_GARBAGED (f);
+ }
#else
XCopyArea (FRAME_X_DISPLAY (f),
FRAME_X_DRAWABLE (f), FRAME_X_DRAWABLE (f),
--
2.17.0
[0002-Fix-image-support-for-cairo-builds.patch (text/x-patch, inline)]
From 3bcf9bb961bbe42ea02191ac22f3ed3bb681c771 Mon Sep 17 00:00:00 2001
From: Ari Roponen <ari.roponen <at> gmail.com>
Date: Fri, 27 Apr 2018 15:14:36 +0300
Subject: [PATCH 2/2] Fix image support for cairo builds
* src/image.c (lookup_rgb_color): Add cairo support.
(jpeg_load_body): Fix preprocessor symbol. Move colors definition
into non-cairo part.
(imagemagick_load_image) [USE_CAIRO]: Add support for cairo.
---
src/image.c | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/src/image.c b/src/image.c
index 37416c1616..4d5a1bf5e6 100644
--- a/src/image.c
+++ b/src/image.c
@@ -4629,6 +4629,8 @@ lookup_rgb_color (struct frame *f, int r, int g, int b)
return PALETTERGB (r >> 8, g >> 8, b >> 8);
#elif defined HAVE_NS
return RGB_TO_ULONG (r >> 8, g >> 8, b >> 8);
+#elif defined USE_CAIRO
+ return (0xffu << 24) | (r << 16) | (g << 8) | b;
#else
xsignal1 (Qfile_error,
build_string ("This Emacs mishandles this image file type"));
@@ -6702,10 +6704,10 @@ jpeg_load_body (struct frame *f, struct image *img,
FILE *volatile fp = NULL;
JSAMPARRAY buffer;
int row_stride, x, y;
- unsigned long *colors;
int width, height;
int i, ir, ig, ib;
#ifndef USE_CAIRO
+ unsigned long *colors;
XImagePtr ximg = NULL;
#endif
@@ -6823,7 +6825,7 @@ jpeg_load_body (struct frame *f, struct image *img,
else
ir = 0, ig = 0, ib = 0;
-#ifndef CAIRO
+#ifndef USE_CAIRO
/* Use the color table mechanism because it handles colors that
cannot be allocated nicely. Such colors will be replaced with
a default color, and we don't have to care about which colors
@@ -8537,7 +8539,9 @@ imagemagick_load_image (struct frame *f, struct image *img,
int width, height;
size_t image_width, image_height;
MagickBooleanType status;
+#ifndef USE_CAIRO
XImagePtr ximg;
+#endif
int x, y;
MagickWand *image_wand;
PixelIterator *iterator;
@@ -8551,6 +8555,9 @@ imagemagick_load_image (struct frame *f, struct image *img,
double rotation;
char hint_buffer[MaxTextExtent];
char *filename_hint = NULL;
+#ifdef USE_CAIRO
+ void *data = NULL;
+#endif
/* Initialize the ImageMagick environment. */
static bool imagemagick_initialized;
@@ -8759,6 +8766,12 @@ imagemagick_load_image (struct frame *f, struct image *img,
/* Magicexportimage is normally faster than pixelpushing. This
method is also well tested. Some aspects of this method are
ad-hoc and needs to be more researched. */
+ void *dataptr;
+#ifdef USE_CAIRO
+ data = xmalloc (width * height * 4);
+ const char *exportdepth = "BGRA";
+ dataptr = data;
+#else
int imagedepth = 24; /*MagickGetImageDepth(image_wand);*/
const char *exportdepth = imagedepth <= 8 ? "I" : "BGRP"; /*"RGBP";*/
/* Try to create a x pixmap to hold the imagemagick pixmap. */
@@ -8771,6 +8784,8 @@ imagemagick_load_image (struct frame *f, struct image *img,
image_error ("Imagemagick X bitmap allocation failure");
goto imagemagick_error;
}
+ dataptr = ximg->data;
+#endif /* not USE_CAIRO */
/* Oddly, the below code doesn't seem to work:*/
/* switch(ximg->bitmap_unit){ */
@@ -8793,14 +8808,17 @@ imagemagick_load_image (struct frame *f, struct image *img,
*/
int pixelwidth = CharPixel; /*??? TODO figure out*/
MagickExportImagePixels (image_wand, 0, 0, width, height,
- exportdepth, pixelwidth, ximg->data);
+ exportdepth, pixelwidth, dataptr);
}
else
#endif /* HAVE_MAGICKEXPORTIMAGEPIXELS */
{
size_t image_height;
MagickRealType color_scale = 65535.0 / QuantumRange;
-
+#ifdef USE_CAIRO
+ data = xmalloc (width * height * 4);
+ color_scale /= 256;
+#else
/* Try to create a x pixmap to hold the imagemagick pixmap. */
if (!image_create_x_image_and_pixmap (f, img, width, height, 0,
&ximg, 0))
@@ -8811,6 +8829,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
image_error ("Imagemagick X bitmap allocation failure");
goto imagemagick_error;
}
+#endif
/* Copy imagemagick image to x with primitive yet robust pixel
pusher loop. This has been tested a lot with many different
@@ -8823,7 +8842,9 @@ imagemagick_load_image (struct frame *f, struct image *img,
#ifdef COLOR_TABLE_SUPPORT
free_color_table ();
#endif
+#ifndef USE_CAIRO
x_destroy_x_image (ximg);
+#endif
image_error ("Imagemagick pixel iterator creation failed");
goto imagemagick_error;
}
@@ -8839,16 +8860,27 @@ imagemagick_load_image (struct frame *f, struct image *img,
for (x = 0; x < xlim; x++)
{
PixelGetMagickColor (pixels[x], &pixel);
+#ifdef USE_CAIRO
+ ((uint32_t *)data)[width * y + x] =
+ lookup_rgb_color (f,
+ color_scale * pixel.red,
+ color_scale * pixel.green,
+ color_scale * pixel.blue);
+#else
XPutPixel (ximg, x, y,
lookup_rgb_color (f,
color_scale * pixel.red,
color_scale * pixel.green,
color_scale * pixel.blue));
+#endif
}
}
DestroyPixelIterator (iterator);
}
+#ifdef USE_CAIRO
+ create_cairo_image_surface (img, data, width, height);
+#else
#ifdef COLOR_TABLE_SUPPORT
/* Remember colors allocated for this image. */
img->colors = colors_in_color_table (&img->ncolors);
@@ -8860,6 +8892,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
/* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0);
+#endif
/* Final cleanup. image_wand should be the only resource left. */
DestroyMagickWand (image_wand);
--
2.17.0
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sat, 05 May 2018 09:36:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Ari Roponen <ari.roponen <at> gmail.com>
:
bug acknowledged by developer.
(Sat, 05 May 2018 09:36:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 31288-done <at> debbugs.gnu.org (full text, mbox):
> From: Ari Roponen <ari.roponen <at> gmail.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>
> Date: Sat, 28 Apr 2018 10:33:40 +0300
>
> attached are new versions of patches. This time, the cairo support for
> imagemagick is better integrated into existing code.
Thanks, pushed to the master branch.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31288
; Package
emacs
.
(Sun, 06 May 2018 12:38:01 GMT)
Full text and
rfc822 format available.
Message #28 received at 31288-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
> Thanks, pushed to the master branch.
Thank you very much. However, I just noticed that my patch doesn't work
with side-by-side split windows. The following patch should fix that.
[0001-Fix-cairo-scrolling-for-side-by-side-windows.patch (text/x-patch, inline)]
From 788f0fc62881152b03043057fe98178d77a6bb3a Mon Sep 17 00:00:00 2001
From: Ari Roponen <ari.roponen <at> gmail.com>
Date: Sun, 6 May 2018 15:29:28 +0300
Subject: [PATCH] Fix cairo scrolling for side-by-side windows
* src/xterm.c (x_scroll_run) [USE_CAIRO]: Fix scrolling for
side-by-side split windows.
---
src/xterm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index 35e10568fa..3f956d950d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -4260,6 +4260,7 @@ x_scroll_run (struct window *w, struct run *run)
#ifdef USE_CAIRO
if (FRAME_CR_CONTEXT (f))
{
+ int wx = WINDOW_LEFT_EDGE_X (w);
cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
width, height);
cairo_t *cr = cairo_create (s);
@@ -4270,8 +4271,8 @@ x_scroll_run (struct window *w, struct run *run)
cr = FRAME_CR_CONTEXT (f);
cairo_save (cr);
- cairo_set_source_surface (cr, s, 0, to_y);
- cairo_rectangle (cr, x, to_y, width, height);
+ cairo_set_source_surface (cr, s, wx, to_y);
+ cairo_rectangle (cr, wx, to_y, width, height);
cairo_fill (cr);
cairo_restore (cr);
cairo_surface_destroy (s);
--
2.17.0
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31288
; Package
emacs
.
(Sun, 06 May 2018 18:30:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 31288 <at> debbugs.gnu.org (full text, mbox):
> From: Ari Roponen <ari.roponen <at> gmail.com>
> Cc: 31288-done <at> debbugs.gnu.org
> Date: Sun, 06 May 2018 15:36:55 +0300
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > Thanks, pushed to the master branch.
>
> Thank you very much. However, I just noticed that my patch doesn't work
> with side-by-side split windows. The following patch should fix that.
Thanks, pushed.
Please in the future always mention the bug number in the commit
message, otherwise I need top "git commit --amend" after "git am", to
fix the commit message.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 04 Jun 2018 11:24:05 GMT)
Full text and
rfc822 format available.
bug unarchived.
Request was from
YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
to
control <at> debbugs.gnu.org
.
(Tue, 26 Mar 2019 01:26:02 GMT)
Full text and
rfc822 format available.
Did not alter fixed versions and reopened.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 26 Mar 2019 01:26:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#31288
; Package
emacs
.
(Tue, 26 Mar 2019 06:15:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 31288 <at> debbugs.gnu.org (full text, mbox):
YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp> writes:
> It causes display corruption when scroll bars are on the left. I
> think the patch below will fix it.
>
> YAMAMOTO Mitsuharu
> mituharu <at> math.s.chiba-u.ac.jp
Yes, I can see the corruption too, and your patch fixes it. Thank you.
Reply sent
to
YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
:
You have taken responsibility.
(Tue, 26 Mar 2019 07:46:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Ari Roponen <ari.roponen <at> gmail.com>
:
bug acknowledged by developer.
(Tue, 26 Mar 2019 07:46:02 GMT)
Full text and
rfc822 format available.
Message #45 received at 31288-done <at> debbugs.gnu.org (full text, mbox):
On Tue, 26 Mar 2019 15:13:58 +0900,
Ari Roponen wrote:
>
> YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp> writes:
>
> > It causes display corruption when scroll bars are on the left. I
> > think the patch below will fix it.
> >
> > YAMAMOTO Mitsuharu
> > mituharu <at> math.s.chiba-u.ac.jp
>
> Yes, I can see the corruption too, and your patch fixes it. Thank you.
Thanks for checking. I pushed the following to master.
YAMAMOTO Mitsuharu
mituharu <at> math.s.chiba-u.ac.jp
commit 9a6cba2bd397414c68217f4f5a9ea2888293ae1c
Author: YAMAMOTO Mitsuharu <mituharu <at> math.s.chiba-u.ac.jp>
Date: Tue Mar 26 16:39:07 2019 +0900
Fix cairo scrolling for left scroll bars case
* src/xterm.c (x_scroll_run) [USE_CAIRO]: Fix scrolling by unusing
WINDOW_LEFT_EDGE_X. (Bug#31288)
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 23 Apr 2019 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 6 years and 117 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.