* optimization by Ondrej Pokorny, add const in front of TFPColor arguments where possible (bug ID 35131)

git-svn-id: trunk@41550 -
This commit is contained in:
michael 2019-03-02 12:13:31 +00:00
parent 158224a808
commit 5ce75e42df
5 changed files with 24 additions and 24 deletions

View File

@ -19,11 +19,11 @@ interface
uses classes, FPImage, FPCanvas;
procedure DrawSolidEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; c:TFPColor);
procedure DrawSolidEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; Width:integer; c:TFPColor);
procedure DrawPatternEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; Pattern:TPenPattern; c:TFPColor);
procedure FillEllipseColor (Canv:TFPCustomCanvas; const Bounds:TRect; c:TFPColor);
procedure FillEllipsePattern (Canv:TFPCustomCanvas; const Bounds:TRect; Pattern:TBrushPattern; c:TFPColor);
procedure DrawSolidEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; const c:TFPColor);
procedure DrawSolidEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; Width:integer; const c:TFPColor);
procedure DrawPatternEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; Pattern:TPenPattern; const c:TFPColor);
procedure FillEllipseColor (Canv:TFPCustomCanvas; const Bounds:TRect; const c:TFPColor);
procedure FillEllipsePattern (Canv:TFPCustomCanvas; const Bounds:TRect; Pattern:TBrushPattern; const c:TFPColor);
procedure FillEllipseHashHorizontal (Canv:TFPCustomCanvas; const Bounds:TRect; width:integer; const c:TFPColor);
procedure FillEllipseHashVertical (Canv:TFPCustomCanvas; const Bounds:TRect; width:integer; const c:TFPColor);
procedure FillEllipseHashDiagonal (Canv:TFPCustomCanvas; const Bounds:TRect; width:integer; const c:TFPColor);
@ -317,7 +317,7 @@ end;
{ The drawing routines }
type
TPutPixelProc = procedure (Canv:TFPCustomCanvas; x,y:integer; color:TFPColor);
TPutPixelProc = procedure (Canv:TFPCustomCanvas; x,y:integer; const color:TFPColor);
TLinePoints = array[0..PatternBitCount-1] of boolean;
PLinePoints = ^TLinePoints;
@ -334,31 +334,31 @@ begin
LinePoints^[0] := (APattern and i) <> 0;
end;
procedure PutPixelCopy(Canv:TFPCustomCanvas; x,y:integer; color:TFPColor);
procedure PutPixelCopy(Canv:TFPCustomCanvas; x,y:integer; const color:TFPColor);
begin
with Canv do
DrawPixel(x,y,color);
end;
procedure PutPixelXor(Canv:TFPCustomCanvas; x,y:integer; color:TFPColor);
procedure PutPixelXor(Canv:TFPCustomCanvas; x,y:integer; const color:TFPColor);
begin
with Canv do
Colors[x,y] := Colors[x,y] xor color;
end;
procedure PutPixelOr(Canv:TFPCustomCanvas; x,y:integer; color:TFPColor);
procedure PutPixelOr(Canv:TFPCustomCanvas; x,y:integer; const color:TFPColor);
begin
with Canv do
Colors[x,y] := Colors[x,y] or color;
end;
procedure PutPixelAnd(Canv:TFPCustomCanvas; x,y:integer; color:TFPColor);
procedure PutPixelAnd(Canv:TFPCustomCanvas; x,y:integer; const color:TFPColor);
begin
with Canv do
Colors[x,y] := Colors[x,y] and color;
end;
procedure DrawSolidEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; c:TFPColor);
procedure DrawSolidEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; const c:TFPColor);
var info : TEllipseInfo;
r, y : integer;
MyPutPix : TPutPixelProc;
@ -387,7 +387,7 @@ begin
end;
end;
procedure DrawSolidEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; Width:integer; c:TFPColor);
procedure DrawSolidEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; Width:integer; const c:TFPColor);
var infoOut, infoIn : TEllipseInfo;
r, y : integer;
id : PEllipseInfoData;
@ -430,7 +430,7 @@ begin
end;
end;
procedure DrawPatternEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; Pattern:TPenPattern; c:TFPColor);
procedure DrawPatternEllipse (Canv:TFPCustomCanvas; const Bounds:TRect; Pattern:TPenPattern; const c:TFPColor);
var info : TEllipseInfo;
xx, y : integer;
LinePoints : TLinePoints;
@ -496,7 +496,7 @@ begin
end;
end;
procedure FillEllipseColor (Canv:TFPCustomCanvas; const Bounds:TRect; c:TFPColor);
procedure FillEllipseColor (Canv:TFPCustomCanvas; const Bounds:TRect; const c:TFPColor);
var info : TEllipseInfo;
r, y : integer;
id : PEllipseInfoData;
@ -514,7 +514,7 @@ begin
end;
end;
procedure FillEllipsePattern (Canv:TFPCustomCanvas; const Bounds:TRect; Pattern:TBrushPattern; c:TFPColor);
procedure FillEllipsePattern (Canv:TFPCustomCanvas; const Bounds:TRect; Pattern:TBrushPattern; const c:TFPColor);
begin
end;

View File

@ -296,7 +296,7 @@ begin
end;
*)
function AlphaBlend(color1, color2: TFPColor): TFPColor;
function AlphaBlend(const color1, color2: TFPColor): TFPColor;
var
factor1, factor2: single;
begin

View File

@ -286,7 +286,7 @@ function ConvertColor (const From : TFPColor; Fmt : TColorFormat) : TDeviceColor
function ConvertColor (const From : TDeviceColor; Fmt : TColorFormat) : TDeviceColor;
*)
function AlphaBlend(color1, color2: TFPColor): TFPColor;
function AlphaBlend(const color1, color2: TFPColor): TFPColor;
function FPColor (r,g,b,a:word) : TFPColor;
function FPColor (r,g,b:word) : TFPColor;
@ -561,7 +561,7 @@ FuzzyDepth: word = 4): TFPCustomImage;
{ HTML Color support. RRGGBB or color name. Only W3 color names s are supported}
function TryHtmlToFPColor(const S: String; out FPColor: TFPColor): Boolean;
function HtmlToFPColorDef(const S: String; out FPColor: TFpColor; Def: TFPColor): TFPColor;
function HtmlToFPColorDef(const S: String; out FPColor: TFpColor; const Def: TFPColor): TFPColor;
function HtmlToFPColor(const S: String): TFPColor;
@ -613,12 +613,12 @@ begin
(c.Alpha = d.Alpha);
end;
function GetFullColorData (color:TFPColor) : TColorData;
function GetFullColorData (const color:TFPColor) : TColorData;
begin
result := PColorData(@color)^;
end;
function SetFullColorData (color:TColorData) : TFPColor;
function SetFullColorData (const color:TColorData) : TFPColor;
begin
result := PFPColor (@color)^;
end;
@ -760,7 +760,7 @@ begin
end;
end;
function HtmlToFPColorDef(const S: String; out FPColor: TFpColor; Def: TFPColor): TFPColor;
function HtmlToFPColorDef(const S: String; out FPColor: TFpColor; const Def: TFPColor): TFPColor;
begin
if not TryHtmlToFPColor(S, Result) then
Result := Def;

View File

@ -28,7 +28,7 @@ type
FColorShift : word;
FColorSize : byte;
procedure SetColorSize (AValue : byte);
function ColorToHex (c:TFPColor) : string;
function ColorToHex (const c:TFPColor) : string;
protected
procedure InternalWrite (Str:TStream; Img:TFPCustomImage); override;
public
@ -61,7 +61,7 @@ begin
FColorSize := AValue;
end;
function TFPWriterXPM.ColorToHex (c:TFPColor) : string;
function TFPWriterXPM.ColorToHex (const c:TFPColor) : string;
var r,g,b : word;
begin
with c do

View File

@ -349,7 +349,7 @@ const
procedure TFreeTypeFont.DrawChar (x,y:integer; data:PByteArray; pitch, width, height:integer);
procedure Combine (canv:TFPCustomCanvas; x,y:integer; c : TFPColor; t:longword);
procedure Combine (canv:TFPCustomCanvas; x,y:integer; const c : TFPColor; t:longword);
var
pixelcolor: TFPColor;
begin