mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 04:35:57 +02:00
LCL: removed duplicate IntersectRect
git-svn-id: trunk@27870 -
This commit is contained in:
parent
c10f6e5365
commit
cdabc1ddbf
@ -29,7 +29,7 @@ unit GraphType;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
FPCAdds, Classes, SysUtils, LCLType, LCLProc;
|
FPCAdds, Classes, SysUtils, LCLType, LCLProc, types;
|
||||||
|
|
||||||
{$ifdef Trace}
|
{$ifdef Trace}
|
||||||
{$ASSERTIONS ON}
|
{$ASSERTIONS ON}
|
||||||
@ -276,8 +276,6 @@ function CopyImageData(AWidth, AHeight, ARowStride: Integer; ABPP: Word;
|
|||||||
ADestinationOrder: TRawImageLineOrder; ADestinationEnd: TRawImageLineEnd;
|
ADestinationOrder: TRawImageLineOrder; ADestinationEnd: TRawImageLineEnd;
|
||||||
out ADestination: Pointer; out ASize: PtrUInt): Boolean;
|
out ADestination: Pointer; out ASize: PtrUInt): Boolean;
|
||||||
|
|
||||||
function GetRectIntersect(var DestRect: TRect; const SrcRect1, SrcRect2: TRect): Boolean;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
MissingBits: array[0..15] of array[0..7] of word;
|
MissingBits: array[0..15] of array[0..7] of word;
|
||||||
|
|
||||||
@ -564,37 +562,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
Function: GetRectIntersect
|
|
||||||
Params: var DestRect: TRect; const SrcRect1, SrcRect2: TRect
|
|
||||||
Returns: Boolean
|
|
||||||
|
|
||||||
Intersects SrcRect1 and SrcRect2 into DestRect.
|
|
||||||
Intersecting means that DestRect will be the overlapping area of SrcRect1 and
|
|
||||||
SrcRect2. If SrcRect1 and SrcRect2 do not overlapp the Result is false, else
|
|
||||||
true.
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
function GetRectIntersect(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
|
|
||||||
FillChar(DestRect,SizeOf(DestRect),0);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TRawImageDescription }
|
{ TRawImageDescription }
|
||||||
|
|
||||||
procedure TRawImageDescription.Init;
|
procedure TRawImageDescription.Init;
|
||||||
@ -1421,7 +1388,7 @@ begin
|
|||||||
ADst.ReleaseData;
|
ADst.ReleaseData;
|
||||||
|
|
||||||
// get intersection
|
// get intersection
|
||||||
GetRectIntersect(R, Rect(0, 0, Description.Width, Description.Height), ARect);
|
IntersectRect(R, Rect(0, 0, Description.Width, Description.Height), ARect);
|
||||||
ADst.Description.Width := R.Right - R.Left;
|
ADst.Description.Width := R.Right - R.Left;
|
||||||
ADst.Description.Height := R.Bottom - R.Top;
|
ADst.Description.Height := R.Bottom - R.Top;
|
||||||
if (ADst.Description.Width <= 0)
|
if (ADst.Description.Width <= 0)
|
||||||
|
@ -1313,7 +1313,7 @@ end;
|
|||||||
function IntersectRect(var DestRect: TRect;
|
function IntersectRect(var DestRect: TRect;
|
||||||
const SrcRect1, SrcRect2: TRect): Boolean;
|
const SrcRect1, SrcRect2: TRect): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := GetRectIntersect(DestRect,SrcRect1,SrcRect2);
|
Result := Types.IntersectRect(DestRect,SrcRect1,SrcRect2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user