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

* Re: Small improvement of emacs 23 display on win32
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Rumney @ 2008-04-08  8:35 UTC (permalink / raw)
  To: Kyle M. Lee; +Cc: emacs-devel

Kyle M. Lee wrote:
> After that I found the emacs 23 flashes much lesser as running *without*
> --disable-font-backend.

I appreciate the effort you put in to try to help, but the flickering is
a bug (which was fixed late last week), and using double buffering to
hide the bug is not the right solution.

Double buffering is useful to hide flickering when it cannot be avoided,
but in Emacs we have always tuned the redisplay to eliminate the need
for such tricks. Avoiding double buffering improves performance overall,
even if you sometime perceive Emacs to be slower because you see the
drawing progress instead of being forced to wait until drawing is
complete before it appears on screen.





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

* Re: Small improvement of emacs 23 display on win32
  2008-04-08  8:35 ` Jason Rumney
@ 2008-04-08 10:03   ` Kyle M. Lee
  0 siblings, 0 replies; 3+ messages in thread
From: Kyle M. Lee @ 2008-04-08 10:03 UTC (permalink / raw)
  To: Jason Rumney; +Cc: emacs-devel

Jason Rumney 写道:
> Kyle M. Lee wrote:
>> After that I found the emacs 23 flashes much lesser as running *without*
>> --disable-font-backend.
> 
> I appreciate the effort you put in to try to help, but the flickering is
> a bug (which was fixed late last week), and using double buffering to
> hide the bug is not the right solution.
I see, that's a bug.

> 
> Double buffering is useful to hide flickering when it cannot be avoided,
The emacs on win32 flickers usually,not like a modern application but
ancient sword. :) And I have to work on WinXP not Ubuntu. :(

> but in Emacs we have always tuned the redisplay to eliminate the need
> for such tricks. Avoiding double buffering improves performance overall,
> even if you sometime perceive Emacs to be slower because you see the
> drawing progress instead of being forced to wait until drawing is
> complete before it appears on screen.
Yap, double buffering has performance issue.

I found something insteresting about this:
[http://java.sun.com/docs/books/tutorial/extra/fullscreen/doublebuf.html]

perceived performance vs. numerical performance ?






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