From 584dd6f78645732873059bc3e6b1d7bdf1f83527 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 25 Oct 2010 08:32:44 +0000 Subject: [PATCH] LCL: combined duplicate code IntersectRect git-svn-id: trunk@27848 - --- lcl/graphtype.pp | 8 +++++--- lcl/include/winapi.inc | 17 +---------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/lcl/graphtype.pp b/lcl/graphtype.pp index f4452f086e..207f00984c 100644 --- a/lcl/graphtype.pp +++ b/lcl/graphtype.pp @@ -276,6 +276,8 @@ function CopyImageData(AWidth, AHeight, ARowStride: Integer; ABPP: Word; ADestinationOrder: TRawImageLineOrder; ADestinationEnd: TRawImageLineEnd; out ADestination: Pointer; out ASize: PtrUInt): Boolean; +function GetRectIntersect(var DestRect: TRect; const SrcRect1, SrcRect2: TRect): Boolean; + var MissingBits: array[0..15] of array[0..7] of word; @@ -563,7 +565,7 @@ begin end; {------------------------------------------------------------------------------ - Function: IntersectRect + Function: GetRectIntersect Params: var DestRect: TRect; const SrcRect1, SrcRect2: TRect Returns: Boolean @@ -572,7 +574,7 @@ end; SrcRect2. If SrcRect1 and SrcRect2 do not overlapp the Result is false, else true. ------------------------------------------------------------------------------} -function IntersectRect(var DestRect: TRect; +function GetRectIntersect(var DestRect: TRect; const SrcRect1, SrcRect2: TRect): Boolean; begin Result := False; @@ -1419,7 +1421,7 @@ begin ADst.ReleaseData; // get intersection - IntersectRect(R, Rect(0, 0, Description.Width, Description.Height), ARect); + GetRectIntersect(R, Rect(0, 0, Description.Width, Description.Height), ARect); ADst.Description.Width := R.Right - R.Left; ADst.Description.Height := R.Bottom - R.Top; if (ADst.Description.Width <= 0) diff --git a/lcl/include/winapi.inc b/lcl/include/winapi.inc index 132268aae6..f3a85162e7 100644 --- a/lcl/include/winapi.inc +++ b/lcl/include/winapi.inc @@ -1313,22 +1313,7 @@ end; function IntersectRect(var DestRect: TRect; const SrcRect1, SrcRect2: TRect): Boolean; begin - Result := False; - - // test if rectangles intersects - Result:=(SrcRect2.Left < SrcRect1.Right) - and (SrcRect2.Right > SrcRect1.Left) - and (SrcRect2.Top < SrcRect1.Bottom) - and (SrcRect2.Bottom > SrcRect1.Top); - - if Result then begin - DestRect.Left:=Max(SrcRect1.Left,SrcRect2.Left); - DestRect.Top:=Max(SrcRect1.Top,SrcRect2.Top); - DestRect.Right:=Min(SrcRect1.Right,SrcRect2.Right); - DestRect.Bottom:=Min(SrcRect1.Bottom,SrcRect2.Bottom); - end else begin - SetRectEmpty(DestRect); - end; + Result := GetRectIntersect(DestRect,SrcRect1,SrcRect2); end; {------------------------------------------------------------------------------