diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2013-04-25 16:47:53 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2013-04-25 16:47:53 +0100 |
commit | d35125d429f04dd16837ae7a798a9fbf1cc4c62e (patch) | |
tree | 4018e6af69c99f7ea0e4996d14d526b2fd9e2d20 /docview/components | |
parent | 89a657dfe03d81f5c6b44d5e7a9722fdeb8fef4c (diff) | |
download | fpGUI-d35125d429f04dd16837ae7a798a9fbf1cc4c62e.tar.xz |
docview: greatly improve scrolling speed when help topic contains images
We always did StretchDraw() which is rather CPU intensive. Now we check
the image dimensions first, then decide if StretchDraw() is really
needed or not. If not, then do the much faster DrawImage() call.
Diffstat (limited to 'docview/components')
-rw-r--r-- | docview/components/richtext/RichTextDisplayUnit.pas | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/docview/components/richtext/RichTextDisplayUnit.pas b/docview/components/richtext/RichTextDisplayUnit.pas index 2e62a511..482a587b 100644 --- a/docview/components/richtext/RichTextDisplayUnit.pas +++ b/docview/components/richtext/RichTextDisplayUnit.pas @@ -231,10 +231,19 @@ ProfileEvent('DEBUG: DrawRichTextLine >>>'); BitmapRect.Bottom := Trunc(BitmapRect.Top + Bitmap.Height * Layout.VerticalImageScale); - FontManager.Canvas.StretchDraw(BitmapRect.Left, BitMapRect.Top, - BitmapRect.Right-BitMapRect.Left, BitMapRect.Bottom-BitMapRect.Top, Bitmap); - - inc( X, trunc( Bitmap.Width * Layout.HorizontalImageScale ) ); + if ((BitMapRect.Right - BitMapRect.Left) = Bitmap.Width) and + ((BitMapRect.Bottom - BitMapRect.Top) = Bitmap.Height) then + begin + // no stretching required + FontManager.Canvas.DrawImage(BitmapRect.Left, BitMapRect.Top, Bitmap); + inc(X, Bitmap.Width); + end + else + begin + FontManager.Canvas.StretchDraw(BitmapRect.Left, BitMapRect.Top, + BitmapRect.Right-BitMapRect.Left, BitMapRect.Bottom-BitMapRect.Top, Bitmap); + inc(X, trunc(Bitmap.Width * Layout.HorizontalImageScale)); + end; end; end else |