diff --git a/Source/README.txt b/Source/README.txt index e195613e..bd89101c 100644 --- a/Source/README.txt +++ b/Source/README.txt @@ -4,9 +4,17 @@ To build devcpp a recent Delphi version is required (10.4 and onwards). The main executable devcpp.exe can be built using the following steps: - 1) Install - VCL Style - Windows10BlueWhale from GetIt in the IDE. - https://getitnow.embarcadero.com/VCLStyle-Windows10BlueWhale-1.0/ + 1) Install VCL Style Files: + You need to install the following package(s) by "Tools" - "GetIt Package Manager..." in the IDE. + Search them using the search box in the upper right corner: + VCL Style - Calypso 2.0 + VCL Style - FlatUILight 2.0 + VCL Style - Windows10BlackPearl 2.0 + VCL Style - Windows10BlueWhale 2.0 + + VCL Windows Style - Material Patterns Blue 2.0(https://getitnow.embarcadero.com/vcl-windows-style-material-patterns-blue/), Unfortunately, you can't search and install it in Delphi IDE, so you can only delete the line when compiling errors. + + 1) Compile and install the following package(s): Source\VCL\DevCpp.dpk Source\VCL\SynEdit\Packages\Sydney\Delphi\SynEditDelphi.groupproj @@ -15,6 +23,8 @@ The main executable devcpp.exe can be built using the following steps: 2) Compile resources by running the following script(s): Source\CompileResources.bat + Source\VCL\vcl-styles-utils\Common\CompileResources.bat + Source\VCL\vcl-styles-utils\Common\CompileResources_zip.bat 3) Open the project file devcpp.dpr. Your IDE should not produce any 'Module Not Found' or 'Resource Not Found' errors when opening files, diff --git a/Source/VCL/SVGIconImageList/Cairo/cairo.inc b/Source/VCL/SVGIconImageList/Cairo/cairo.inc index 87f7ebf7..be1d301f 100644 --- a/Source/VCL/SVGIconImageList/Cairo/cairo.inc +++ b/Source/VCL/SVGIconImageList/Cairo/cairo.inc @@ -16,7 +16,7 @@ {$DEFINE CAIRO_HAS_FT_FONT} {$ENDIF} -{$ifdef MSWINDOWS} +{$ifdef WIN32} {$define CAIRO_HAS_WIN32_SURFACE} {$define CAIRO_HAS_WIN32_FONT} {$endif} diff --git a/Source/VCL/SVGIconImageList/Cairo/cairo.pas b/Source/VCL/SVGIconImageList/Cairo/cairo.pas index f1e571f3..be3e2fb9 100644 --- a/Source/VCL/SVGIconImageList/Cairo/cairo.pas +++ b/Source/VCL/SVGIconImageList/Cairo/cairo.pas @@ -28,7 +28,6 @@ *) unit cairo; - {$IFDEF FPC} {$MODE OBJFPC}{$H+} {$ENDIF} @@ -37,7 +36,7 @@ interface uses sysutils, classes, cairolib -{$IFDEF MSWINDOWS} +{$IFDEF WIN32} , windows {$ENDIF} {$IFDEF CAIRO_HAS_RSVG_FUNCTIONS} @@ -2860,4 +2859,3 @@ function TCairoRegion.XorRegion(other: ICairoRegion): TCairoStatus; end; end. - diff --git a/Source/VCL/SVGIconImageList/Cairo/cairolib.pas b/Source/VCL/SVGIconImageList/Cairo/cairolib.pas index 3738ab0a..4071918b 100644 --- a/Source/VCL/SVGIconImageList/Cairo/cairolib.pas +++ b/Source/VCL/SVGIconImageList/Cairo/cairolib.pas @@ -47,9 +47,9 @@ interface -{$IFDEF MSWINDOWS} +{$ifdef WIN32} uses windows; -{$ENDIF} +{$endif} {$ifdef UNIX} uses x, xlib, xrender, freetypeh; diff --git a/Source/VCL/SVGIconImageList/Demo/Benchmark/Benchmark.dpr b/Source/VCL/SVGIconImageList/Demo/Benchmark/Benchmark.dpr index d1156c7f..218f1dd6 100644 --- a/Source/VCL/SVGIconImageList/Demo/Benchmark/Benchmark.dpr +++ b/Source/VCL/SVGIconImageList/Demo/Benchmark/Benchmark.dpr @@ -8,7 +8,6 @@ uses begin Application.Initialize; - Application.Title := 'SVG Icons - Factories Benchmark'; Application.MainFormOnTaskbar := True; Application.CreateForm(TfrmBenchmark, frmBenchmark); Application.Run; diff --git a/Source/VCL/SVGIconImageList/Demo/Benchmark/Benchmark_Icon.ico b/Source/VCL/SVGIconImageList/Demo/Benchmark/Benchmark_Icon.ico deleted file mode 100644 index feeaac14..00000000 Binary files a/Source/VCL/SVGIconImageList/Demo/Benchmark/Benchmark_Icon.ico and /dev/null differ diff --git a/Source/VCL/SVGIconImageList/Demo/Benchmark/UBenchmark.dfm b/Source/VCL/SVGIconImageList/Demo/Benchmark/UBenchmark.dfm index 67bd4b19..f626c7e7 100644 --- a/Source/VCL/SVGIconImageList/Demo/Benchmark/UBenchmark.dfm +++ b/Source/VCL/SVGIconImageList/Demo/Benchmark/UBenchmark.dfm @@ -2,227 +2,102 @@ object frmBenchmark: TfrmBenchmark Left = 0 Top = 0 Caption = 'Benchmark' - ClientHeight = 545 - ClientWidth = 784 + ClientHeight = 342 + ClientWidth = 719 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText - Font.Height = -12 - Font.Name = 'Segoe UI' + Font.Height = -11 + Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate + OnDestroy = FormDestroy PixelsPerInch = 96 - TextHeight = 15 - object splHorizontal: TSplitter - Left = 0 - Top = 421 - Width = 784 - Height = 4 - Cursor = crVSplit - Align = alBottom - AutoSnap = False - Beveled = True - MinSize = 100 - ExplicitTop = 422 + TextHeight = 13 + object lblLoops: TLabel + Left = 304 + Top = 316 + Width = 28 + Height = 13 + Caption = '&Loops' + FocusControl = speLoops end object memOutput: TMemo - Left = 0 - Top = 425 - Width = 784 - Height = 120 - Align = alBottom + Left = 24 + Top = 24 + Width = 385 + Height = 281 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Consolas' Font.Style = [] ParentFont = False - ReadOnly = True - ScrollBars = ssVertical TabOrder = 0 end + object btnClear: TButton + Left = 24 + Top = 311 + Width = 100 + Height = 25 + Caption = '&Clear' + TabOrder = 1 + OnClick = btnClearClick + end + object btnLoad: TButton + Left = 130 + Top = 311 + Width = 100 + Height = 25 + Caption = 'L&oad Image' + TabOrder = 2 + OnClick = btnLoadClick + end object SVGIconImage: TSVGIconImage - Left = 0 - Top = 0 - Width = 634 - Height = 421 + Left = 424 + Top = 24 + Width = 281 + Height = 281 AutoSize = False - ParentDoubleBuffered = False - DoubleBuffered = True - ImageList = SVGIconVirtualImageList - Align = alClient + ImageList = imlIcons end - object pnlButtons: TPanel - Left = 634 - Top = 0 - Width = 150 - Height = 421 - Align = alRight - BevelOuter = bvNone - TabOrder = 2 - object btnClear: TButton - AlignWithMargins = True - Left = 10 - Top = 386 - Width = 130 - Height = 30 - Margins.Left = 10 - Margins.Top = 5 - Margins.Right = 10 - Margins.Bottom = 5 - Align = alBottom - Caption = '&Clear Output' - TabOrder = 0 - OnClick = btnClearClick - end - object btnLoad: TButton - AlignWithMargins = True - Left = 10 - Top = 5 - Width = 130 - Height = 30 - Margins.Left = 10 - Margins.Top = 5 - Margins.Right = 10 - Margins.Bottom = 5 - Align = alTop - Caption = 'L&oad Image' - TabOrder = 1 - OnClick = btnLoadClick - end - object btnRunBenchmark: TButton - AlignWithMargins = True - Left = 10 - Top = 346 - Width = 130 - Height = 30 - Margins.Left = 10 - Margins.Top = 5 - Margins.Right = 10 - Margins.Bottom = 5 - Align = alBottom - Caption = '&Benchmark' - TabOrder = 2 - OnClick = btnRunBenchmarkClick - end - object chkGrayScale: TCheckBox - AlignWithMargins = True - Left = 10 - Top = 256 - Width = 130 - Height = 20 - Margins.Left = 10 - Margins.Top = 5 - Margins.Right = 10 - Margins.Bottom = 5 - Align = alBottom - Caption = '&Grayscale' - Checked = True - State = cbChecked - TabOrder = 3 - end - object chkFixedColor: TCheckBox - AlignWithMargins = True - Left = 10 - Top = 286 - Width = 130 - Height = 20 - Margins.Left = 10 - Margins.Top = 5 - Margins.Right = 10 - Margins.Bottom = 5 - Align = alBottom - Caption = '&Fixed Color' - Checked = True - State = cbChecked - TabOrder = 4 - end - object pnlLoops: TPanel - Left = 0 - Top = 311 - Width = 150 - Height = 30 - Align = alBottom - BevelOuter = bvNone - TabOrder = 5 - object lblLoops: TLabel - AlignWithMargins = True - Left = 10 - Top = 8 - Width = 32 - Height = 17 - Margins.Left = 10 - Margins.Top = 8 - Margins.Right = 5 - Margins.Bottom = 5 - Align = alLeft - Caption = '&Loops' - FocusControl = speLoops - ExplicitHeight = 15 - end - object speLoops: TSpinEdit - AlignWithMargins = True - Left = 52 - Top = 5 - Width = 88 - Height = 24 - Margins.Left = 5 - Margins.Top = 5 - Margins.Right = 10 - Margins.Bottom = 5 - MaxValue = 999 - MinValue = 1 - TabOrder = 0 - Value = 50 - end - end - object grpFactory: TRadioGroup - AlignWithMargins = True - Left = 10 - Top = 45 - Width = 130 - Height = 105 - Margins.Left = 10 - Margins.Top = 5 - Margins.Right = 10 - Margins.Bottom = 5 - Align = alTop - Caption = 'SVG Factory' - TabOrder = 6 - OnClick = grpFactoryClick - end - object chkDrawVisible: TCheckBox - AlignWithMargins = True - Left = 10 - Top = 227 - Width = 130 - Height = 20 - Margins.Left = 10 - Margins.Top = 5 - Margins.Right = 10 - Margins.Bottom = 5 - Align = alBottom - Caption = '&Draw visible' - Checked = True - State = cbChecked - TabOrder = 7 - ExplicitTop = 230 - end + object btnRunBenchmark: TButton + Left = 447 + Top = 309 + Width = 100 + Height = 25 + Caption = '&Benchmark' + TabOrder = 4 + OnClick = btnRunBenchmarkClick + end + object speLoops: TSpinEdit + Left = 360 + Top = 311 + Width = 81 + Height = 22 + MaxValue = 999 + MinValue = 10 + TabOrder = 5 + Value = 100 end object SVGIconImageCollection: TSVGIconImageCollection SVGIconItems = <> Left = 48 Top = 40 end + object imlIcons: TVirtualImageList + AutoFill = True + DisabledGrayscale = False + DisabledSuffix = '_Disabled' + Images = <> + ImageCollection = SVGIconImageCollection + Left = 48 + Top = 88 + end object OpenDialog: TOpenDialog DefaultExt = '*.svg' Left = 48 Top = 136 end - object SVGIconVirtualImageList: TSVGIconVirtualImageList - ImageCollection = SVGIconImageCollection - Left = 48 - Top = 88 - end end diff --git a/Source/VCL/SVGIconImageList/Demo/Benchmark/UBenchmark.pas b/Source/VCL/SVGIconImageList/Demo/Benchmark/UBenchmark.pas index 65da3d67..da96f01b 100644 --- a/Source/VCL/SVGIconImageList/Demo/Benchmark/UBenchmark.pas +++ b/Source/VCL/SVGIconImageList/Demo/Benchmark/UBenchmark.pas @@ -1,25 +1,18 @@ -{----------------------------------------------------------------------------- - Unit Name: UBenchmark - Author: Lübbe Onken - Purpose: Main form for SVG Factories Benchmark - History: ------------------------------------------------------------------------------} unit UBenchmark; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, - Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, - System.ImageList, //if you are compiling with older version than XE7 remove this line - Vcl.ImgList, + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.ImageList, + Vcl.ImgList, Vcl.VirtualImageList, Vcl.BaseImageCollection, SVGInterfaces, - SVGIconImageCollection, SVGIconImage, Vcl.Samples.Spin, Vcl.ExtCtrls, - SVGIconImageListBase, SVGIconVirtualImageList; + SVGIconImageCollection, SVGIconImage, Vcl.Samples.Spin; type TfrmBenchmark = class(TForm) SVGIconImageCollection: TSVGIconImageCollection; + imlIcons: TVirtualImageList; memOutput: TMemo; btnClear: TButton; btnLoad: TButton; @@ -28,38 +21,19 @@ TfrmBenchmark = class(TForm) btnRunBenchmark: TButton; speLoops: TSpinEdit; lblLoops: TLabel; - pnlButtons: TPanel; - chkGrayScale: TCheckBox; - chkFixedColor: TCheckBox; - splHorizontal: TSplitter; - pnlLoops: TPanel; - grpFactory: TRadioGroup; - chkDrawVisible: TCheckBox; - SVGIconVirtualImageList: TSVGIconVirtualImageList; procedure btnClearClick(Sender: TObject); procedure btnLoadClick(Sender: TObject); - procedure btnRunBenchmarkClick(Sender: TObject); procedure FormCreate(Sender: TObject); - procedure grpFactoryClick(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure btnRunBenchmarkClick(Sender: TObject); private - FSvgSource : string; + FImageStream: TMemoryStream; FStartTick : Int64; FLastTick : Int64; - FLine : string; - FInBenchmark: boolean; - - function GetFactoryName: string; - procedure SetFactory(AIndex: integer); - - procedure BenchmarkLoad; - procedure BenchmarkGrayScale; - procedure BenchmarkFixedColor; - procedure BenchmarkDraw; - - procedure LogTicks(var AMessage: string; ATick: Int64); - procedure PrepareBenchmark(ACaption: string); - procedure ReloadImage; - procedure RunBenchmark(AIndex: integer); + procedure LogTicks(var AMessage: string; const ASuffix: string; ATick: Int64); + procedure RunBenchmark(AFactoryName: string; AFactory: ISVGFactory); + public + { Public-Deklarationen } end; var @@ -71,97 +45,15 @@ implementation CairoSVGFactory, D2DSVGFactory, PasSVGFactory, - System.IOUtils, - System.Math, - System.StrUtils, - System.TypInfo, System.Types; {$R *.dfm} -type - TCanvasImage = class(TSVGIconImage) // Just to have something to paint on - public - property Canvas; - end; - -procedure TfrmBenchmark.BenchmarkDraw; - - procedure DrawOnCanvas(ACanvas: TCanvas); - var - I : integer; - LStep: real; - LSize: real; - LRect: TRect; - begin - LStep := Min(ACanvas.ClipRect.Width, ACanvas.ClipRect.Height) / speLoops.Value; - LSize := 0; - - for I := 1 to speLoops.Value do - begin - LSize := LSize + LStep; - LRect := TRect.Create(0, 0, Round(LSize), Round(LSize)); - - SvgIconImageCollection.Draw(ACanvas, LRect, 0, true); - end; - end; - -var - LBitmap: TBitmap; -begin - // Benchmark Draw - if chkDrawVisible.Checked then - DrawOnCanvas(TCanvasImage(SVGIconImage).Canvas) - else - begin - LBitmap := TBitmap.Create; - try - LBitmap.Width := SvgIconImage.Height; - LBitmap.Width := SvgIconImage.Width; - - DrawOnCanvas(LBitmap.Canvas); - finally - LBitmap.Free; - end; - end; -end; - -procedure TfrmBenchmark.BenchmarkFixedColor; -begin - SVGIconImageCollection.FixedColor := clLime; -end; - -procedure TfrmBenchmark.BenchmarkGrayScale; -begin - SVGIconImageCollection.GrayScale := true; -end; - -procedure TfrmBenchmark.BenchmarkLoad; -var - I : integer; - LSvg: ISvg; -begin - SVGIconImageCollection.SVGIconItems.BeginUpdate; - try - SVGIconImageCollection.SVGIconItems.Clear; - SVGIconImageCollection.FixedColor := clDefault; - SVGIconImageCollection.GrayScale := false; - - for I := 1 to speLoops.Value do - begin - LSvg := GlobalSvgFactory.NewSvg; - LSvg.Source := FSvgSource; - SVGIconImageCollection.Add(LSvg, ''); - end; - finally - SVGIconImageCollection.SVGIconItems.EndUpdate; - end; -end; - procedure TfrmBenchmark.btnClearClick(Sender: TObject); begin memOutput.Clear; + SVGIconImageCollection.ClearIcons; end; procedure TfrmBenchmark.btnLoadClick(Sender: TObject); @@ -170,172 +62,101 @@ procedure TfrmBenchmark.btnLoadClick(Sender: TObject); begin if OpenDialog.Execute then begin - FSvgSource := TFile.ReadAllText(OpenDialog.FileName); - - PrepareBenchmark('Factory | Load | Draw | Total'); - - LSvg := GlobalSvgFactory.NewSvg; - LSvg.Source := FSvgSource; - LogTicks(FLine, FLastTick); + FImageStream.LoadFromFile(OpenDialog.FileName); + FImageStream.Position := 0; SVGIconImageCollection.SVGIconItems.Clear; + LSvg := GlobalSvgFactory.NewSvg; + LSvg.LoadFromStream(FImageStream); SVGIconImageCollection.Add(LSvg, ''); SVGIconImage.ImageIndex := 0; - - LogTicks(FLine, FLastTick); - LogTicks(FLine, FStartTick); end; end; procedure TfrmBenchmark.btnRunBenchmarkClick(Sender: TObject); -var - LLine: string; begin - if (FSvgSource = '') then + if (FImageStream.Size = 0) then memOutput.Lines.Add('Please load a SVG image first') else begin - FInBenchmark := true; - try - SVGIconImage.ImageIndex := -1; - - LLine := 'Factory | Load | Draw '; - if chkGrayScale.Checked then - LLine := LLine + '| Gray | Draw '; - if chkFixedColor.Checked then - LLine := LLine + '| Fixed | Draw '; - LLine := LLine + '| Total'; - - memOutput.Lines.Add(''); - memOutput.Lines.Add(Format('Benchmark: Repeat %d times. Draw %svisible.', [speLoops.Value, IfThen(chkDrawVisible.Checked, '', 'in')])); + SVGIconImage.ImageIndex := -1; - memOutput.Lines.Add(LLine); - RunBenchmark(0); - RunBenchmark(1); - RunBenchmark(2); + memOutput.Lines.Add(Format('Factory | Load %3d | Draw %3d | Total |', [speLoops.Value, speLoops.Value])); + RunBenchmark('Direct 2D', GetD2DSVGFactory); + RunBenchmark('Pascal', GetPasSVGFactory); + RunBenchmark('Cairo', GetCairoSVGFactory); - SVGIconImage.ImageIndex := 0; - finally - FInBenchmark := false; - end; + SVGIconImage.ImageIndex := 0; end; end; procedure TfrmBenchmark.FormCreate(Sender: TObject); begin - Caption := Application.Title; - FInBenchmark := false; - grpFactory.Items.Add('Pascal'); - grpFactory.Items.Add('Direct 2D'); - grpFactory.Items.Add('Cairo'); - SetFactory(0); + FImageStream := TMemoryStream.Create; end; -function TfrmBenchmark.GetFactoryName: string; +procedure TfrmBenchmark.FormDestroy(Sender: TObject); begin - if grpFactory.ItemIndex > -1 then - Result := grpFactory.Items[grpFactory.ItemIndex] - else - Result := ''; + FImageStream.Free; end; -procedure TfrmBenchmark.grpFactoryClick(Sender: TObject); -begin - if not FInBenchmark then - begin - SetFactory(grpFactory.ItemIndex); - ReloadImage; - end; -end; - -procedure TfrmBenchmark.LogTicks(var AMessage: string; ATick: Int64); +procedure TfrmBenchmark.LogTicks(var AMessage: string; const ASuffix: string; ATick: Int64); var LCurrentTick: Int64; begin LCurrentTick := GetTickCount; - AMessage := Format('%s | %6d', [AMessage, LCurrentTick - ATick]); + AMessage := Format('%s | %8d%s', [AMessage, LCurrentTick - ATick, ASuffix]); memOutput.Lines[memOutput.Lines.Count - 1] := AMessage; FLastTick := LCurrentTick; end; -procedure TfrmBenchmark.PrepareBenchmark(ACaption: string); -begin - if ACaption <> '' then - memOutput.Lines.Add(ACaption); - - FLine := Format('%-10s', [GetFactoryName]); - memOutput.Lines.Add(FLine); - - FStartTick := GetTickCount; - FLastTick := FStartTick; -end; +type + TCanvasImage = class(TSVGIconImage) + public + property Canvas; + end; -procedure TfrmBenchmark.ReloadImage; +procedure TfrmBenchmark.RunBenchmark(AFactoryName: string; AFactory: ISVGFactory); var - LSvg: ISvg; + LSvg : ISvg; + I : integer; + LStep: real; + LSize: real; + LRect: TRect; + LLine: string; begin - if FSvgSource <> '' then - begin - PrepareBenchmark('Factory | Load | Draw | Total'); - - LSvg := GlobalSvgFactory.NewSvg; - LSvg.Source := FSvgSource; - LogTicks(FLine, FLastTick); + LLine := Format('%-10s', [AFactoryName]); + memOutput.Lines.Add(LLine); - SVGIconImage.ImageIndex := -1; - SVGIconImageCollection.SVGIconItems.Clear; - SVGIconImageCollection.Add(LSvg, ''); - SVGIconImage.ImageIndex := 0; - LogTicks(FLine, FLastTick); - LogTicks(FLine, FStartTick); - end; -end; - -procedure TfrmBenchmark.RunBenchmark(AIndex: integer); + FStartTick := GetTickCount; + FLastTick := FStartTick; - procedure Benchmark(AProc: TPRoc); - begin - if Assigned(AProc) then + SVGIconImageCollection.SVGIconItems.BeginUpdate; + try + SVGIconImageCollection.SVGIconItems.Clear; + for I := 1 to speLoops.Value do begin - AProc; - LogTicks(FLine, FLastTick); + LSvg := AFactory.NewSvg; + FImageStream.Position := 0; + LSvg.LoadFromStream(FImageStream); + SVGIconImageCollection.Add(LSvg, ''); end; + finally + SVGIconImageCollection.SVGIconItems.EndUpdate; end; -begin - SetFactory(AIndex); - - PrepareBenchmark(''); + LogTicks(LLine, '', FLastTick); - Benchmark(BenchmarkLoad); - Benchmark(BenchmarkDraw); - - if chkGrayScale.Checked then + LStep := SvgIconImage.Height / 100; + LSize := 0; + for I := 1 to speLoops.Value do begin - Benchmark(BenchmarkGrayScale); - Benchmark(BenchmarkDraw); + LSize := LSize + LStep; + LRect := TRect.Create(0, 0, Round(LSize), Round(LSize)); + SvgIconImageCollection.Draw(TCanvasImage(SVGIconImage).Canvas, LRect, 0); end; - - if chkFixedColor.Checked then - begin - Benchmark(BenchmarkFixedColor); - Benchmark(BenchmarkDraw); - end; - - LogTicks(FLine, FStartTick); -end; - -procedure TfrmBenchmark.SetFactory(AIndex: integer); -begin - case AIndex of - 0: - SetGlobalSvgFactory(GetPasSVGFactory); - 1: - SetGlobalSvgFactory(GetD2DSVGFactory); - 2: - SetGlobalSvgFactory(GetCairoSVGFactory); - end; - grpFactory.ItemIndex := AIndex; + LogTicks(LLine, '', FLastTick); + LogTicks(LLine, ' |', FStartTick); end; end. diff --git a/Source/VCL/SVGIconImageList/Demo/Images/ComponentEditor.jpg b/Source/VCL/SVGIconImageList/Demo/Images/ComponentEditor.jpg index 2f156276..335c76d9 100644 Binary files a/Source/VCL/SVGIconImageList/Demo/Images/ComponentEditor.jpg and b/Source/VCL/SVGIconImageList/Demo/Images/ComponentEditor.jpg differ diff --git a/Source/VCL/SVGIconImageList/Demo/Source/UIconPickerFMX.pas b/Source/VCL/SVGIconImageList/Demo/Source/UIconPickerFMX.pas index 9d3fea46..ace0a422 100644 --- a/Source/VCL/SVGIconImageList/Demo/Source/UIconPickerFMX.pas +++ b/Source/VCL/SVGIconImageList/Demo/Source/UIconPickerFMX.pas @@ -92,7 +92,6 @@ procedure PaintToBitmap(const ABitmap: TBitmap; const ASVG: TSVG); GPGraphics := TGPGraphics.Create(GPBitmap); try GPGraphics.SetSmoothingMode(SmoothingModeAntiAlias); - GPGraphics.SetPixelOffsetMode(PixelOffsetModeHalf); GPRectF.X := 0; GPRectF.Y := 0; GPRectF.Width := ABitmap.Width; diff --git a/Source/VCL/SVGIconImageList/Source/CairoSVGFactory.pas b/Source/VCL/SVGIconImageList/Source/CairoSVGFactory.pas index 8c59192f..d92db391 100644 --- a/Source/VCL/SVGIconImageList/Source/CairoSVGFactory.pas +++ b/Source/VCL/SVGIconImageList/Source/CairoSVGFactory.pas @@ -38,13 +38,10 @@ TCairoSVG = class(TInterfacedObject, ISVG) private const cEmptySvg = ''; private - FSource : string; - FSvgObject : IRSVGObject; - FWidth : Single; - FHeight : Single; - FFixedColor: TColor; - FGrayScale : Boolean; - FOpacity : Single; + FSource : string; + FSvgObject: IRSVGObject; + FHeight : Single; + FWidth : Single; // property access methods function GetWidth: Single; function GetHeight: Single; @@ -59,15 +56,12 @@ TCairoSVG = class(TInterfacedObject, ISVG) // procedures and functions function IsEmpty: Boolean; procedure Clear; - procedure PaintTo(DC: HDC; R: TRectF; KeepAspectRatio: Boolean = True); - procedure LoadFromSource(const ASource: string); - procedure LoadFromFile(const AFileName: string); + procedure SaveToStream(AStream: TStream); + procedure SaveToFile(const AFileName: string); + procedure LoadFromSource; procedure LoadFromStream(AStream: TStream); - procedure SaveToFile(const AFileName: string); overload; - procedure SaveToStream(AStream: TStream); overload; - procedure SaveToStream(AStream: TStream; const ASource: string); overload; - procedure SourceFromStream(AStream: TStream); - procedure SvgFromStream(AStream: TStream); + procedure LoadFromFile(const AFileName: string); + procedure PaintTo(DC: HDC; R: TRectF; KeepAspectRatio: Boolean = True); public constructor Create; end; @@ -99,19 +93,16 @@ procedure TCairoSVG.Clear; constructor TCairoSVG.Create; begin FSvgObject := TRSVGObject.Create; - FFixedColor := TColors.SysDefault; // clDefault - FGrayScale := false; - FOpacity := 1.0; end; function TCairoSVG.GetFixedColor: TColor; begin - Result := FFixedColor; + end; function TCairoSVG.GetGrayScale: Boolean; begin - Result := FGrayScale; + end; function TCairoSVG.GetHeight: Single; @@ -121,7 +112,7 @@ function TCairoSVG.GetHeight: Single; function TCairoSVG.GetOpacity: Single; begin - Result := FOpacity; + end; function TCairoSVG.GetSource: string; @@ -151,34 +142,33 @@ procedure TCairoSVG.LoadFromFile(const AFileName: string); end; end; -procedure TCairoSVG.LoadFromSource(const ASource: string); +procedure TCairoSVG.LoadFromSource; var - LMemoryStream: TMemoryStream; + LStream: TMemoryStream; begin - if ASource = '' then + if FSource = '' then Clear; - LMemoryStream := TMemoryStream.Create; + LStream := TMemoryStream.Create; try - SaveToStream(LMemoryStream, ASource); - LMemoryStream.Position := 0; - SvgFromStream(LMemoryStream); + SaveToStream(LStream); + LStream.Position := 0; + LoadFromStream(LStream); finally - LMemoryStream.Free; + LStream.Free; end; end; procedure TCairoSVG.LoadFromStream(AStream: TStream); -Var - LStreamPos: Int64; begin - // read and save the Source - LStreamPos := AStream.Position; - SourceFromStream(AStream); - // Restore Position - AStream.Position := LStreamPos; - // Now create the SVG - SvgFromStream(AStream); + try + FSvgObject := TRSVGObject.Create(AStream); + FHeight := FSvgObject.Dimensions.height; + FWidth := FSvgObject.Dimensions.width; + except + on E: Exception do + raise Exception.CreateFmt(CAIRO_ERROR_PARSING_SVG_TEXT, [E.Message]); + end; end; procedure TCairoSVG.PaintTo(DC: HDC; R: TRectF; KeepAspectRatio: Boolean); @@ -224,32 +214,27 @@ procedure TCairoSVG.SaveToFile(const AFileName: string); end; end; -procedure TCairoSVG.SaveToStream(AStream: TStream; const ASource: string); +procedure TCairoSVG.SaveToStream(AStream: TStream); var LBuffer: TBytes; begin - LBuffer := TEncoding.UTF8.GetBytes(ASource); + LBuffer := TEncoding.UTF8.GetBytes(FSource); AStream.WriteBuffer(LBuffer, Length(LBuffer)) end; -procedure TCairoSVG.SaveToStream(AStream: TStream); -begin - SaveToStream(AStream, FSource); -end; - procedure TCairoSVG.SetFixedColor(const AColor: TColor); begin - // TODO: Implement recoloring + end; procedure TCairoSVG.SetGrayScale(const IsGrayScale: Boolean); begin - // TODO: Implement recoloring + end; procedure TCairoSVG.SetOpacity(const AOpacity: Single); begin - // TODO: Implement setting opacity + end; procedure TCairoSVG.SetSource(const ASource: string); @@ -257,31 +242,8 @@ procedure TCairoSVG.SetSource(const ASource: string); if FSource <> ASource then begin FSource := ASource; - LoadFromSource(ASource); + LoadFromSource; end; end; -procedure TCairoSVG.SourceFromStream(AStream: TStream); -var - LSize : Integer; - LBuffer: TBytes; -begin - LSize := AStream.Size - AStream.Position; - SetLength(LBuffer, LSize); - AStream.Read(LBuffer, 0, LSize); - FSource := TEncoding.UTF8.GetString(LBuffer); -end; - -procedure TCairoSVG.SvgFromStream(AStream: TStream); -begin - try - FSvgObject := TRSVGObject.Create(AStream); - FHeight := FSvgObject.Dimensions.height; - FWidth := FSvgObject.Dimensions.width; - except - on E: Exception do - raise Exception.CreateFmt(CAIRO_ERROR_PARSING_SVG_TEXT, [E.Message]); - end; -end; - end. diff --git a/Source/VCL/SVGIconImageList/Source/D2DSVGFactory.pas b/Source/VCL/SVGIconImageList/Source/D2DSVGFactory.pas index 0fc5593a..bbdc07db 100644 --- a/Source/VCL/SVGIconImageList/Source/D2DSVGFactory.pas +++ b/Source/VCL/SVGIconImageList/Source/D2DSVGFactory.pas @@ -18,6 +18,9 @@ function RenderTarget: ID2D1DCRenderTarget; // Support functions function WinSvgSupported: Boolean; +resourcestring + D2D_ERROR_PARSING_SVG_TEXT = 'Error parsing SVG Text: %s'; + implementation Uses @@ -30,13 +33,10 @@ implementation System.UITypes, System.UIConsts, System.SysUtils, - System.Classes, - System.RegularExpressions; + System.Classes; resourcestring - D2D_ERROR_NOT_AVAILABLE = 'Windows SVG support is not available'; - D2D_ERROR_PARSING_SVG_TEXT = 'Error parsing SVG Text: %s'; - D2D_ERROR_UNSUPPORTED_SVG = '