From: mituharu@math.s.chiba-u.ac.jp
To: "Alex Gramiak" <agrambot@gmail.com>
Cc: 35468@debbugs.gnu.org
Subject: bug#35468: [PATCH] Refactor draw_glyph_string on X and w32
Date: Wed, 1 May 2019 09:14:50 +0900 [thread overview]
Message-ID: <c560b2f02aea5b22d56d3989e3588508.squirrel@weber.math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <8736lznzjf.fsf@gmail.com>
> As for the color manipulation, I went low-level as you said before:
>
> unsigned long foreground, background;
> gdif->get_context_foreground (gc, &foreground);
> gdif->get_context_background (gc, &background);
> gdif->set_context_foreground (gc, background);
> gdif->fill_rectangle (s, gc, x, y, w, h);
> gdif->set_context_foreground (gc, foreground);
>
> which replaces the XGetGCValues section in x_draw_stretch_glyph_string.
> This unfortunately is more work in the w32 case as it manipulates s->gc
> instead of just using the calculated gc->background. I'm not sure how
> one would make a no-op version of setting the context foreground work in
> all fill calls.
>
> If that is unsatisfactory), then instead I could do something like:
>
> gdif->fill_rectangle_with_color (s, gc->background, gc, x, y, w, h);
>
> Which wouldn't touch s->gc for the w32 version and would do the whole
> XGetGCValues dance for the X version.
Unlike the NS port, the terminal code in the Mac port is much like the X11
version.
But there is one notable difference in the above respect.
It defines mac_erase_rectangle, which is like mac_fill_rectangle (the
XFillRectangle counterpart)
but uses the background color of GC and also handles stipples:
/* Mac replacement for XFillRectangle. */
static void
mac_fill_rectangle (struct frame *f, GC gc, int x, int y, int width, int
height)
{
MAC_BEGIN_DRAW_TO_FRAME (f, gc, context);
CGContextSetFillColorWithColor (context, gc->cg_fore_color);
{
CGRect rect = mac_rect_make (f, x, y, width, height);
CGContextFillRects (context, &rect, 1);
}
MAC_END_DRAW_TO_FRAME (f);
}
static void
mac_erase_rectangle (struct frame *f, GC gc, int x, int y,
int width, int height)
{
MAC_BEGIN_DRAW_TO_FRAME (f, gc, context);
{
CGRect rect = mac_rect_make (f, x, y, width, height);
CG_CONTEXT_FILL_RECT_WITH_GC_BACKGROUND (f, context, rect, gc);
if (gc->xgcv.fill_style == FillOpaqueStippled && gc->xgcv.stipple)
{
CGContextClipToRects (context, &rect, 1);
CGContextSetFillColorWithColor (context, gc->cg_fore_color);
int scale = CFArrayGetCount (gc->xgcv.stipple);
if (FRAME_BACKING_SCALE_FACTOR (f) < scale)
scale = FRAME_BACKING_SCALE_FACTOR (f);
CGImageRef image_mask =
(CGImageRef) CFArrayGetValueAtIndex (gc->xgcv.stipple, scale - 1);
rect = CGRectMake (0, 0, CGImageGetWidth (image_mask) / (CGFloat) scale,
CGImageGetHeight (image_mask) / (CGFloat) scale);
CGContextScaleCTM (context, 1, -1);
CGContextSetInterpolationQuality (context, kCGInterpolationNone);
CGContextDrawTiledImage (context, rect, image_mask);
}
}
MAC_END_DRAW_TO_FRAME (f);
}
BTW, the code between MAC_BEGIN_DRAW_TO_FRAME and MAC_END_DRAW_TO_FRAME
is executed in the dedicated drawing thread with the help of Grand Central
Dispatch.
See https://bitbucket.org/mituharu/emacs-mac/src/master/src/macterm.c for
the full source code.
I guess introducing the erase_rectagle handler makes things simpler and
efficient.
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
next prev parent reply other threads:[~2019-05-01 0:14 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-28 1:29 bug#35468: [PATCH] Refactor draw_glyph_string on X and w32 Alex Gramiak
2019-04-28 17:11 ` Eli Zaretskii
2019-04-28 19:46 ` Alex Gramiak
2019-04-29 17:43 ` Alex Gramiak
2019-04-30 4:59 ` Eli Zaretskii
2019-04-30 18:00 ` Alex Gramiak
2019-05-01 0:14 ` mituharu [this message]
2019-05-03 19:01 ` Alex Gramiak
2019-05-03 21:33 ` mituharu
2019-05-04 4:00 ` mituharu
2019-05-01 18:19 ` Eli Zaretskii
2019-05-02 19:41 ` Alex Gramiak
2019-05-02 20:14 ` Eli Zaretskii
2019-05-03 15:26 ` Basil L. Contovounesios
2019-05-04 8:17 ` Eli Zaretskii
2019-05-04 19:29 ` Alex Gramiak
2019-05-05 0:10 ` mituharu
2019-05-05 16:00 ` Eli Zaretskii
2019-05-05 2:34 ` Eli Zaretskii
2019-04-30 20:11 ` Alan Third
2019-05-01 17:38 ` Eli Zaretskii
2019-05-01 21:08 ` Alan Third
2019-05-02 18:14 ` Alex Gramiak
2019-05-03 21:12 ` Alan Third
2021-05-12 14:43 ` Lars Ingebrigtsen
2021-07-22 12:55 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c560b2f02aea5b22d56d3989e3588508.squirrel@weber.math.s.chiba-u.ac.jp \
--to=mituharu@math.s.chiba-u.ac.jp \
--cc=35468@debbugs.gnu.org \
--cc=agrambot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.