From d35125d429f04dd16837ae7a798a9fbf1cc4c62e Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Thu, 25 Apr 2013 16:47:53 +0100 Subject: 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. --- docview/components/richtext/RichTextDisplayUnit.pas | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'docview/components') 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 -- cgit v1.2.3-70-g09d2