* remove inline where not necessary: this fix a logic bug that was leading to wrongly painting

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1714 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blikblum
2011-06-20 20:35:07 +00:00
parent 5fb894cb27
commit 112cbe25cb

View File

@ -4,6 +4,8 @@
{$H+} {$H+}
{$DEFINE SPKGUITOOLS} {$DEFINE SPKGUITOOLS}
{.$define EnhancedRecordSupport} {.$define EnhancedRecordSupport}
//the fpcbugworkaround is only necessary when using inline for DrawRoundRect
{.$define FpcBugWorkAround}
interface interface
@ -33,21 +35,21 @@ type
class procedure DrawHLine(ABitmap : TBitmap; class procedure DrawHLine(ABitmap : TBitmap;
x1, x2 : integer; x1, x2 : integer;
y : integer; y : integer;
Color : TColor); overload; inline; Color : TColor); overload;
class procedure DrawHLine(ABitmap : TBitmap; class procedure DrawHLine(ABitmap : TBitmap;
x1, x2 : integer; x1, x2 : integer;
y : integer; y : integer;
Color : TColor; Color : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure DrawHLine(ACanvas : TCanvas; class procedure DrawHLine(ACanvas : TCanvas;
x1, x2 : integer; x1, x2 : integer;
y : integer; y : integer;
Color : TColor); overload; inline; Color : TColor); overload;
class procedure DrawHLine(ACanvas : TCanvas; class procedure DrawHLine(ACanvas : TCanvas;
x1, x2 : integer; x1, x2 : integer;
y : integer; y : integer;
Color : TColor; Color : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
// Performance: // Performance:
@ -56,21 +58,21 @@ type
class procedure DrawVLine(ABitmap : TBitmap; class procedure DrawVLine(ABitmap : TBitmap;
x : integer; x : integer;
y1, y2 : integer; y1, y2 : integer;
Color : TColor); overload; inline; Color : TColor); overload;
class procedure DrawVLine(ABitmap : TBitmap; class procedure DrawVLine(ABitmap : TBitmap;
x : integer; x : integer;
y1, y2 : integer; y1, y2 : integer;
Color : TColor; Color : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure DrawVLine(ACanvas : TCanvas; class procedure DrawVLine(ACanvas : TCanvas;
x : integer; x : integer;
y1, y2 : integer; y1, y2 : integer;
Color : TColor); overload; inline; Color : TColor); overload;
class procedure DrawVLine(ACanvas : TCanvas; class procedure DrawVLine(ACanvas : TCanvas;
x : integer; x : integer;
y1, y2 : integer; y1, y2 : integer;
Color : TColor; Color : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
// *** Background and frame tools *** // *** Background and frame tools ***
@ -81,24 +83,24 @@ type
Point : T2DIntVector; Point : T2DIntVector;
Radius : integer; Radius : integer;
CornerPos : TCornerPos; CornerPos : TCornerPos;
Color : TColor); overload; inline; Color : TColor); overload;
class procedure DrawAARoundCorner(ABitmap : TBitmap; class procedure DrawAARoundCorner(ABitmap : TBitmap;
Point : T2DIntVector; Point : T2DIntVector;
Radius : integer; Radius : integer;
CornerPos : TCornerPos; CornerPos : TCornerPos;
Color : TColor; Color : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure DrawAARoundCorner(ACanvas : TCanvas; class procedure DrawAARoundCorner(ACanvas : TCanvas;
Point : T2DIntVector; Point : T2DIntVector;
Radius : integer; Radius : integer;
CornerPos : TCornerPos; CornerPos : TCornerPos;
Color : TColor); overload; inline; Color : TColor); overload;
class procedure DrawAARoundCorner(ACanvas : TCanvas; class procedure DrawAARoundCorner(ACanvas : TCanvas;
Point : T2DIntVector; Point : T2DIntVector;
Radius : integer; Radius : integer;
CornerPos : TCornerPos; CornerPos : TCornerPos;
Color : TColor; Color : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
// Performance: // Performance:
// w/ClipRect: Bitmap is faster (extremely) // w/ClipRect: Bitmap is faster (extremely)
@ -106,26 +108,26 @@ type
class procedure DrawAARoundFrame(ABitmap : TBitmap; class procedure DrawAARoundFrame(ABitmap : TBitmap;
Rect : T2DIntRect; Rect : T2DIntRect;
Radius : integer; Radius : integer;
Color : TColor); overload; inline; Color : TColor); overload;
class procedure DrawAARoundFrame(ABitmap : TBitmap; class procedure DrawAARoundFrame(ABitmap : TBitmap;
Rect : T2DIntRect; Rect : T2DIntRect;
Radius : integer; Radius : integer;
Color : TColor; Color : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure DrawAARoundFrame(ACanvas : TCanvas; class procedure DrawAARoundFrame(ACanvas : TCanvas;
Rect : T2DIntRect; Rect : T2DIntRect;
Radius : integer; Radius : integer;
Color : TColor); overload; inline; Color : TColor); overload;
class procedure DrawAARoundFrame(ACanvas : TCanvas; class procedure DrawAARoundFrame(ACanvas : TCanvas;
Rect : T2DIntRect; Rect : T2DIntRect;
Radius : integer; Radius : integer;
Color : TColor; Color : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure RenderBackground(ABuffer : TBitmap; class procedure RenderBackground(ABuffer : TBitmap;
Rect : T2DIntRect; Rect : T2DIntRect;
Color1, Color2 : TColor; Color1, Color2 : TColor;
BackgroundKind : TBackgroundKind); inline; BackgroundKind : TBackgroundKind);
class procedure CopyRoundCorner(ABuffer : TBitmap; class procedure CopyRoundCorner(ABuffer : TBitmap;
ABitmap : TBitmap; ABitmap : TBitmap;
@ -133,7 +135,7 @@ type
DstPoint : T2DIntVector; DstPoint : T2DIntVector;
Radius : integer; Radius : integer;
CornerPos : TCornerPos; CornerPos : TCornerPos;
Convex : boolean = true); overload; inline; Convex : boolean = true); overload;
class procedure CopyRoundCorner(ABuffer : TBitmap; class procedure CopyRoundCorner(ABuffer : TBitmap;
ABitmap : TBitmap; ABitmap : TBitmap;
SrcPoint : T2DIntVector; SrcPoint : T2DIntVector;
@ -141,7 +143,7 @@ type
Radius : integer; Radius : integer;
CornerPos : TCornerPos; CornerPos : TCornerPos;
ClipRect : T2DIntRect; ClipRect : T2DIntRect;
Convex : boolean = true); overload; inline; Convex : boolean = true); overload;
class procedure CopyCorner(ABuffer : TBitmap; class procedure CopyCorner(ABuffer : TBitmap;
ABitmap: TBitmap; ABitmap: TBitmap;
@ -160,21 +162,21 @@ type
SrcPoint : T2DIntVector; SrcPoint : T2DIntVector;
DstPoint: T2DIntVector; DstPoint: T2DIntVector;
Width: integer; Width: integer;
Height : integer); overload; inline; Height : integer); overload;
class procedure CopyRectangle(ABuffer : TBitmap; class procedure CopyRectangle(ABuffer : TBitmap;
ABitmap : TBitmap; ABitmap : TBitmap;
SrcPoint : T2DIntVector; SrcPoint : T2DIntVector;
DstPoint : T2DIntVector; DstPoint : T2DIntVector;
Width : integer; Width : integer;
Height : integer; Height : integer;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure CopyMaskRectangle(ABuffer : TBitmap; class procedure CopyMaskRectangle(ABuffer : TBitmap;
AMask : TBitmap; AMask : TBitmap;
ABitmap : TBitmap; ABitmap : TBitmap;
SrcPoint : T2DIntVector; SrcPoint : T2DIntVector;
DstPoint : T2DIntVector; DstPoint : T2DIntVector;
Width : integer; Width : integer;
Height : integer); overload; inline; Height : integer); overload;
class procedure CopyMaskRectangle(ABuffer : TBitmap; class procedure CopyMaskRectangle(ABuffer : TBitmap;
AMask : TBitmap; AMask : TBitmap;
ABitmap : TBitmap; ABitmap : TBitmap;
@ -182,7 +184,7 @@ type
DstPoint : T2DIntVector; DstPoint : T2DIntVector;
Width : integer; Width : integer;
Height : integer; Height : integer;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
// Performance (RenderBackground + CopyRoundRect vs DrawRoundRect): // Performance (RenderBackground + CopyRoundRect vs DrawRoundRect):
// w/ClipRect : Bitmap faster for smaller radiuses, Canvas faster for larger // w/ClipRect : Bitmap faster for smaller radiuses, Canvas faster for larger
@ -196,7 +198,7 @@ type
LeftTopRound : boolean = true; LeftTopRound : boolean = true;
RightTopRound : boolean = true; RightTopRound : boolean = true;
LeftBottomRound : boolean = true; LeftBottomRound : boolean = true;
RightBottomRound : boolean = true); overload; inline; RightBottomRound : boolean = true); overload;
class procedure CopyRoundRect(ABuffer : TBitmap; class procedure CopyRoundRect(ABuffer : TBitmap;
ABitmap : TBitmap; ABitmap : TBitmap;
SrcPoint : T2DIntVector; SrcPoint : T2DIntVector;
@ -207,7 +209,7 @@ type
LeftTopRound : boolean = true; LeftTopRound : boolean = true;
RightTopRound : boolean = true; RightTopRound : boolean = true;
LeftBottomRound : boolean = true; LeftBottomRound : boolean = true;
RightBottomRound : boolean = true); overload; inline; RightBottomRound : boolean = true); overload;
class procedure DrawRoundRect(ACanvas : TCanvas; class procedure DrawRoundRect(ACanvas : TCanvas;
@ -219,7 +221,7 @@ type
LeftTopRound : boolean = true; LeftTopRound : boolean = true;
RightTopRound : boolean = true; RightTopRound : boolean = true;
LeftBottomRound : boolean = true; LeftBottomRound : boolean = true;
RightBottomRound : boolean = true); overload; inline; RightBottomRound : boolean = true); overload;
class procedure DrawRoundRect(ACanvas : TCanvas; class procedure DrawRoundRect(ACanvas : TCanvas;
Rect : T2DIntRect; Rect : T2DIntRect;
Radius : integer; Radius : integer;
@ -230,21 +232,21 @@ type
LeftTopRound : boolean = true; LeftTopRound : boolean = true;
RightTopRound : boolean = true; RightTopRound : boolean = true;
LeftBottomRound : boolean = true; LeftBottomRound : boolean = true;
RightBottomRound : boolean = true); overload; inline; RightBottomRound : boolean = true); overload;
class procedure DrawRegion(ACanvas : TCanvas; class procedure DrawRegion(ACanvas : TCanvas;
Region : HRGN; Region : HRGN;
Rect : T2DIntRect; Rect : T2DIntRect;
ColorFrom : TColor; ColorFrom : TColor;
ColorTo : TColor; ColorTo : TColor;
GradientKind : TBackgroundKind); overload; inline; GradientKind : TBackgroundKind); overload;
class procedure DrawRegion(ACanvas : TCanvas; class procedure DrawRegion(ACanvas : TCanvas;
Region : HRGN; Region : HRGN;
Rect : T2DIntRect; Rect : T2DIntRect;
ColorFrom : TColor; ColorFrom : TColor;
ColorTo : TColor; ColorTo : TColor;
GradientKind : TBackgroundKind; GradientKind : TBackgroundKind;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
// Imagelist tools // Imagelist tools
class procedure DrawImage(ABitmap : TBitmap; class procedure DrawImage(ABitmap : TBitmap;
@ -264,7 +266,7 @@ type
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector; Point : T2DIntVector;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure DrawDisabledImage(ABitmap : TBitmap; class procedure DrawDisabledImage(ABitmap : TBitmap;
Imagelist : TImageList; Imagelist : TImageList;
@ -278,7 +280,7 @@ type
class procedure DrawDisabledImage(ACanvas : TCanvas; class procedure DrawDisabledImage(ACanvas : TCanvas;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
Point : T2DIntVector); overload; inline; Point : T2DIntVector); overload;
class procedure DrawDisabledImage(ACanvas : TCanvas; class procedure DrawDisabledImage(ACanvas : TCanvas;
Imagelist : TImageList; Imagelist : TImageList;
ImageIndex : integer; ImageIndex : integer;
@ -289,87 +291,87 @@ type
class procedure DrawText(ABitmap : TBitmap; class procedure DrawText(ABitmap : TBitmap;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor); overload; inline; TextColor : TColor); overload;
class procedure DrawText(ABitmap : TBitmap; class procedure DrawText(ABitmap : TBitmap;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure DrawMarkedText(ACanvas : TCanvas; class procedure DrawMarkedText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
const AText, AMarkPhrase : string; const AText, AMarkPhrase : string;
TextColor : TColor; TextColor : TColor;
CaseSensitive : boolean = false); overload; inline; CaseSensitive : boolean = false); overload;
class procedure DrawMarkedText(ACanvas : TCanvas; class procedure DrawMarkedText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
const AText, AMarkPhrase : string; const AText, AMarkPhrase : string;
TextColor : TColor; TextColor : TColor;
ClipRect : T2DIntRect; ClipRect : T2DIntRect;
CaseSensitive : boolean = false); overload; inline; CaseSensitive : boolean = false); overload;
class procedure DrawText(ACanvas : TCanvas; class procedure DrawText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor); overload; inline; TextColor : TColor); overload;
class procedure DrawText(ACanvas : TCanvas; class procedure DrawText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure DrawFitWText(ABitmap : TBitmap; class procedure DrawFitWText(ABitmap : TBitmap;
x1, x2 : integer; x1, x2 : integer;
y : integer; y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
Align : TAlignment); overload; inline; Align : TAlignment); overload;
class procedure DrawFitWText(ACanvas : TCanvas; class procedure DrawFitWText(ACanvas : TCanvas;
x1, x2 : integer; x1, x2 : integer;
y : integer; y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
Align : TAlignment); overload; inline; Align : TAlignment); overload;
class procedure DrawOutlinedText(ABitmap : TBitmap; class procedure DrawOutlinedText(ABitmap : TBitmap;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
OutlineColor : TColor); overload; inline; OutlineColor : TColor); overload;
class procedure DrawOutlinedText(ABitmap : TBitmap; class procedure DrawOutlinedText(ABitmap : TBitmap;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
OutlineColor : TColor; OutlineColor : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure DrawOutlinedText(ACanvas : TCanvas; class procedure DrawOutlinedText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
OutlineColor : TColor); overload; inline; OutlineColor : TColor); overload;
class procedure DrawOutlinedText(ACanvas : TCanvas; class procedure DrawOutlinedText(ACanvas : TCanvas;
x, y : integer; x, y : integer;
AText : string; AText : string;
TextColor : TColor; TextColor : TColor;
OutlineColor : TColor; OutlineColor : TColor;
ClipRect : T2DIntRect); overload; inline; ClipRect : T2DIntRect); overload;
class procedure DrawFitWOutlinedText(ABitmap: TBitmap; class procedure DrawFitWOutlinedText(ABitmap: TBitmap;
x1, x2 : integer; x1, x2 : integer;
y: integer; y: integer;
AText: string; AText: string;
TextColor, TextColor,
OutlineColor: TColor; OutlineColor: TColor;
Align: TAlignment); overload; inline; Align: TAlignment); overload;
class procedure DrawFitWOutlinedText(ACanvas: TCanvas; class procedure DrawFitWOutlinedText(ACanvas: TCanvas;
x1, x2 : integer; x1, x2 : integer;
y: integer; y: integer;
AText: string; AText: string;
TextColor, TextColor,
OutlineColor: TColor; OutlineColor: TColor;
Align: TAlignment); overload; inline; Align: TAlignment); overload;
end; end;
implementation implementation
uses uses
LCLIntf, IntfGraphics; LCLIntf, IntfGraphics, Math;
{ TSpkGUITools } { TSpkGUITools }
@ -2238,8 +2240,17 @@ begin
if Radius<1 then if Radius<1 then
exit; exit;
//WriteLn('Radius: ', Radius, ' Rect.Width: ', Rect.Width, ' Rect.Height: ', Rect.Height);
//there's a bug in fpc that evaluates the expression below erroneous when using inline
// Radius = 3 and Rect.Width >=128 and <= 261 will evaluate to true
{$ifdef FpcBugWorkAround}
if (CompareValue(Radius*2, Rect.width) > 0) and (CompareValue(Radius*2, Rect.Height) > 0) then
exit;
{$else}
if (Radius*2>Rect.width) or (Radius*2>Rect.height) then if (Radius*2>Rect.width) or (Radius*2>Rect.height) then
exit; exit;
{$endif}
// Zapamiêtywanie oryginalnego ClipRgn i ustawianie nowego // Zapamiêtywanie oryginalnego ClipRgn i ustawianie nowego
SaveClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); SaveClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn);
@ -2835,6 +2846,7 @@ class procedure TGUITools.DrawDisabledImage(ACanvas: TCanvas;
var DCStackPos : integer; var DCStackPos : integer;
begin begin
//todo: see if is necessary to save the DC
DcStackPos:=SaveDC(ACanvas.Handle); DcStackPos:=SaveDC(ACanvas.Handle);
ImageList.Draw(ACanvas, Point.x, Point.y, ImageIndex, false); ImageList.Draw(ACanvas, Point.x, Point.y, ImageIndex, false);
RestoreDC(ACanvas.Handle, DcStackPos); RestoreDC(ACanvas.Handle, DcStackPos);