unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Small improvement of emacs 23 display on win32
@ 2008-04-08  3:03 Kyle M. Lee
  2008-04-08  8:35 ` Jason Rumney
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle M. Lee @ 2008-04-08  3:03 UTC (permalink / raw)
  To: emacs-devel

Hi all,
I found that emacs using HDC to draw everything on win32.
Maybe using double buffering with HDC would help the emacs display
faster on win32.

So I tried some minor modifications on w32_fill_rect (max fan-in ?)
which is frequently called by other w32_xx function to test it.

After that I found the emacs 23 flashes much lesser as running *without*
--disable-font-backend. And I want to optimize w32_text_out function too
which is called when --disable-font-backend, but I can't calculate the
text rectangle on screen with magic struct glyph_string.

The following is my stupid code. I think that to avoid using static vars
in function, maybe using double buffering on a higher level is better,
such as hold a mem hdc in struct glyph_string or get a mem hdc from the
get_frame_dc function, if that is not too heavy.

<code>
void
w32_fill_rect (f, hdc, pix, lprect)
     FRAME_PTR f;
     HDC hdc;
     COLORREF pix;
     RECT * lprect;
{
  /* w32 double buffering vars. */
  static HDC     hdcMem = NULL;
  static HBITMAP bmpMem = NULL;
  static HBITMAP bmpOld = NULL;
  static RECT    clientRect = {0};

  HBRUSH hb = CreateSolidBrush (pix);
  int width =  lprect->right - lprect->left;
  int height = lprect->bottom - lprect->top;

  // check for creating hdcMemFillRect & bmpMemFillRect
  if ((clientRect.right - clientRect.left) < width ||
      (clientRect.bottom - clientRect.top) < height)
  {
      if (bmpMem)
      {
          SelectObject(hdcMem, bmpOld);
          DeleteObject(bmpMem);
      }
      if (hdcMem)
      {
          DeleteDC(hdcMem);
      }
      clientRect.left = clientRect.top = 0;
      clientRect.right = width;
      clientRect.bottom = height;
      hdcMem = CreateCompatibleDC(hdc);
      bmpMem = CreateCompatibleBitmap(hdc, width, height);
      bmpOld = SelectObject(hdcMem, bmpMem);
  }
  xassert (hdcMem);
  xassert (bmpMem);

  RECT rect;
  rect.top = rect.left = 0;
  rect.bottom = height;
  rect.right = width;

  FillRect (hdcMem, &rect, hb);
  BitBlt (hdc,
          lprect->left, lprect->top, width, height,
          hdcMem, 0, 0, SRCCOPY);

  DeleteObject(hb);
}
</code>

I think the emacs 23 display would be very smooth on win32, if it used
double buffering fully.




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

end of thread, other threads:[~2008-04-08 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-08  3:03 Small improvement of emacs 23 display on win32 Kyle M. Lee
2008-04-08  8:35 ` Jason Rumney
2008-04-08 10:03   ` Kyle M. Lee

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).