emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Small improvement of emacs 23 display on win32


From: Kyle M. Lee
Subject: Small improvement of emacs 23 display on win32
Date: Tue, 08 Apr 2008 11:03:45 +0800
User-agent: Thunderbird 2.0.0.12 (Windows/20080213)

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]