Code Monkey home page Code Monkey logo

skia4delphi / skia4delphi Goto Github PK

View Code? Open in Web Editor NEW
650.0 650.0 129.0 583.68 MB

Skia4Delphi is a cross-platform 2D graphics API for Delphi platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.

Home Page: https://skia4delphi.org

License: MIT License

Pascal 98.49% Batchfile 0.01% Inno Setup 0.49% PowerShell 0.06% PHP 0.80% POV-Ray SDL 0.15%
android console delphi firemonkey fmx graphics ios macos pascal skia vcl windows

skia4delphi's People

Contributors

eugenekryukov avatar paulocesarbot avatar viniciusfbb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skia4delphi's Issues

Error on Mac ARM 64-bit

priv

I get "Privileged Instruction" in Global_Sub_L_Sk4DStream.cpp

Can you please provide an update for the Mac Arm 64-bit Binary

App modelo com erro no Android

Olá, instalei o Skia4Delphi pelo executável e tentei compilar no meu Android 11, mas está ocorrendo erro e o app não executa como pode ser visto no print em anexo.

Existe algo que eu tenha que configurar para que ele execute?

Erro Skia4Delphi

Add examples of using the GPU as render target

The current examples focuses on using the CPU based rasterizer only.

As the Skia documentation is a bit thin around using a GPU render target, I would encourage to include examples of using the Skia library to render its surface with the GPU (OpenGL and/or Vulkan). 😃

I might be able to submit an example too, if time allows to dig through the Skia documentation.

Installation problem: Tried again

Well tried again to install by hand
Downloaded last version
and it could not find Skia.Package.RTL250.bpl
on my D10.2.3 even if the search is correct
What I suggest for you to check
Delete all your BPL from your computer
and try to install I am sure it will not work.
And lastly, I gave up with this component

Color problem

TCameraComponent of Android and iOS (without GlobalUseMetal) is wrong.

IMG_3024

Weight of SO

Thanks for skia4delphi — looks great!

One question: is there a way to reduce the size of SO-files if I only need Lottie support for Android? I have an app ~15MB. Now with SO-files its weight is ~20+MB :(

Incorrect SVG rendering

reactor.zip

Incorrect SVG rendering of the attached SVG document in TSkSvg:

image

This is the correct rendering of the same SVG document in Edge browser:

image

Erro na instalação

Boa tarde.

Eu instalei o Skia para teste, no entanto, ele está apresentando o seguinte erro:
Skia4Delphi

Já fiz a instalação pelos três métodos (Skia4Delphi_2.0.1_Setup.exe, Manual e via GetIt).

Nota: A versão do delphi: 10.4 Update 2 Community Edition.

Atenciosamente.

Possível problema com SkLottieAnimation

Gravar_2022_02_01_00_06_10_843.mp4

XE11.zip

Olá, estou achando os componentes fantásticos, mas tenho uma dúvida/problema.
Se eu coloco o SkLottieAnimation dentro de um TPanel ele tem um comportamento estranho de "flash", é assim mesmo? O componente só funciona bem se estiver dentro do Form?

Installation problem

Hello I received the following error whilst attempting to install SKIA
Skia

Microsoft (R) Build Engine version 4.8.4084.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 2022/02/17 08:26:29.
Project "C:\Users\BAAK\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj" on node 1 (default targets).
C:\Users\BAAK\AppData\Roaming\Embarcadero\BDS\22.0\environment.proj(44,9): error MSB5016: The name "settingsS400400C00941.ifsp" contains an invalid character ".". [C:\Users\BAAK\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj]
Done Building Project "C:\Users\BAAK\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj" (default targets) -- FAILED.

Build FAILED.

"C:\Users\BAAK\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj" (default target) (1) ->
C:\Users\BAAK\AppData\Roaming\Embarcadero\BDS\22.0\environment.proj(44,9): error MSB5016: The name "settingsS400400C00941.ifsp" contains an invalid character ".". [C:\Users\BAAK\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.07

Solicitação de econtato

viniciusfbb como consigo entrar em contato com você? me chama no zap pf (75 9 91926685)
Ramon Souza.

Improve Installation Process

Some people have reported difficulties during installation. It is necessary to review the entire installation process and ensure greater reliability and simplicity to the process.

Problems rendering many SVG Images

First of all I want to congratulate you on the excellent work done with version 3.
While I was integrating it into the SVGIconImageList project, I noticed several rendering problems of SVG images, maybe I am doing something wrong in the implementation but I also tried with your demo using a different file from "gorilla" and it doesn't work.
I am attaching a zip containing a series of SVG files that are not fully or partially rendered.
svg_examples.zip
Thank you.

SVG Incompatibilities solved

I was having a lot of problems with SVGs produced by CorelDraw showing up as entirely black until I found

https://github.com/sk1project/sk1-wx

which is an open source SVG editor which produces amazingly 100% compatible SVGs for Skia, including gradients and much more. I would have posted this in your wiki but there isn't one and I thought I really should share this information.

Compile in Delphi 11 and 10.4 fails

In both, get the following error

**Build FAILED.

"C:\Users\Neil\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj" (default target) (1) ->
C:\Users\Neil\AppData\Roaming\Embarcadero\BDS\22.0\environment.proj(7,9): error MSB5016: The name "asl.log" contains an invalid character ".". [C:\Users\Neil\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj]**

Did try running install program as administrator with same result

PNG decoding

Some PNG files don’t get decoded correctly with Skia4Delphi 2.0.1 on Windows.
Images have been loaded and saved with the following method:

procedure DecodeEncodePng(const AFileNameIn, AFileNameOut: string);
var
    LStreamIn, LStreamOut: TStream;
    LImage: ISkImage;
begin
    LStreamOut := nil;
    LStreamIn := TFileStream.Create(AFileNameIn, fmOpenRead or fmShareDenyWrite);
    try
        LStreamOut := TFileStream.Create(AFileNameOut, fmOpenWrite or fmCreate);

        LImage := TSkImage.MakeFromEncoded(LStreamIn);
        LImage.EncodeToStream(LStreamOut, TSkEncodedImageFormat.PNG);
    finally
        LStreamIn.Free;
        LStreamOut.Free;
    end;
end;

DecodeEncodePng('World_time.png', 'World_time_skia.png');

World_time.png
World_time

World_time_skia.png
World_time_skia

Performance issue?

Looks like an awesome project! It shows lot of potential.

On Windows, I was testing the included FmxFPS project and I see that I get on the standard canvas 84fps and on Skia I get only max 54 fps. That looks not right.

Is this something you also see?

Thanks, Edward

Add more ISkParagraph features

Feature request: ISkParagraph does not expose all C++ Paragraph APIs. APIs that are currently missing are:

  • getMinIntrinsicWidth
  • getMaxIntrinsicWidth
  • getAlphabeticBaseline
  • getIdeographicBaseline
  • getLongestLine
  • didExceedMaxLines
  • getGlyphPositionAtCoordinate (important)
  • getLineMetrics
  • lineNumber
  • markDirty
  • unresolvedGlyphs
  • visit (not important)

In particular, I am missing then getGlyphPositionAtCoordinate API.

Adding these in a future version would be greatly appreciated.

Projeto

Boa noite.

O projeto ainda está em desenvolvimento.

Atenciosamente.

SVG Stream from string

Hi, I'm trying to include skia4delphi as another SVG rendering engine into my project:
https://github.com/EtheaDev/SVGIconImageList
I've found how to load an SVG file into a TSKFileStream and then assigned it to FDOM: ISKSVGDOM.
But If I have the SVG content into a string, how can I prepare a valid stream to pass to FDOM?
I can use only TSKMemoryStream or you can add a TSKStringStream to simplify the work?
Thanks.
Carlo

Conflict with "unneccessary" TBitmap Helper

The Issue:

Delphi only allows one helper for each object type so if you've created your own TBitmap Helper, as I have, then including Skia.FMX.pas will override that with the one if it comes later in the uses clause than the unit that contains your own bitmap helper.

As the functionality offered by the TSkBitmapHelper is so minimal I propose the following changes:

  1. Remove the current TSkBitmapHelper (or at the very least wrap it in an $IFDEF)
  2. Replace it with a tskImageHelper which won't conflict with anything, and
  3. Add a separate SkiaDraw procedure that takes a bitmap as its first parameter
{$IFDEF SKIA_BITMAP_HELPER}
  TSkBitmapHelper = class helper for TBitmap
  public
    procedure SkiaDraw(const AProc: TSkDrawProc; const AStartClean: Boolean = True);
    function ToSkImage: ISkImage;
  end;
{$ELSE SKIA_BITMAP_HELPER}

  TSkImageHelper = class helper for TSkImage
  public
    class function MakeFromBitmap(const inBitmap:TBitmap): ISkImage; static;
  end;

procedure SkiaDraw(ToBitmap:TBitmap; const AProc: TSkDrawProc; const AStartClean: Boolean = True);
{$ENDIF SKIA_BITMAP_HELPER}

implementation

class function TSkImageHelper.MakeFromBitmap(const inBitmap:TBitmap): ISkImage;
var
  LColorType: TSkColorType;
  LData: TBitmapData;
begin
  if (inBitmap=nil) or inBitmap.IsEmpty then
    raise ESkFMX.Create('Invalid bitmap');
  case InBitmap.PixelFormat of
    TPixelFormat.RGBA: LColorType := TSkColorType.RGBA8888;
    TPixelFormat.BGRA: LColorType := TSkColorType.BGRA8888;
  else
    raise ESkFMX.Create('Invalid pixelformat');
  end;
  if not Inbitmap.Map(TMapAccess.Read, LData) then
    raise ESkFMX.Create('Could not map the bitmap');
  try
    Result := TSkImage.MakeRaster(TSkImageInfo.Create(Inbitmap.Width, Inbitmap.Height, LColorType), LData.Data, LData.Pitch);
  finally
    Inbitmap.Unmap(LData);
  end;
end;

procedure SkiaDraw(ToBitmap:TBitmap; const AProc: TSkDrawProc; const AStartClean: Boolean);
var
  LColorType: TSkColorType;
  LImageInfo: TSkImageInfo;
  LSurface: ISkSurface;
  LData: TBitmapData;
begin
  if (ToBitmap=Nil) or ToBitmap.IsEmpty then
    raise ESkFMX.Create('Invalid bitmap');
  case ToBitmap.PixelFormat of
    TPixelFormat.RGBA: LColorType := TSkColorType.RGBA8888;
    TPixelFormat.BGRA: LColorType := TSkColorType.BGRA8888;
  else
    raise ESkFMX.Create('Invalid pixelformat');
  end;
  LImageInfo := TSkImageInfo.Create(ToBitmap.Width, ToBitmap.Height, LColorType);
  if ToBitmap.Map(TMapAccess.ReadWrite, LData) then
    try
      LSurface := TSkSurface.MakeRasterDirect(LImageInfo, LData.Data, LData.Pitch);
      if AStartClean then
        LSurface.Canvas.Clear(TAlphaColors.Null);
      AProc(LSurface.Canvas);
    finally
      ToBitmap.Unmap(LData);
    end;
end;

procedure TskCustomControl.paint; 
begin
...
{$IFDEF SKIA_BITMAP_HELPER}
    FBuffer.SkiaDraw(
{$ELSE SKIA_BITMAP_HELPER}
    SkiaDraw(FBuffer,
{$ENDIF SKIA_BITMAP_HELPER}
...

Missing Linux support (Delphi 11 Alexandria - Enterprise)

Skia4Delphi Ver. 3.0.0.0

There is no define about TGrCanvasGL (or something like TSkCanvasRasterLinux) in line 1263 of Skia.FMX.Graphics when define Linux64 as target OS:

" {$IF defined(MSWINDOWS)}
if GlobalUseSkiaRasterWhenAvailable then
Result := TSkCanvasRasterWindows
else
Result := TGrCanvasGL;
{$ELSEIF DEFINED(MACOS)}
if GlobalUseMetal then
Exit(TGrCanvasMetal)
else
{$IFDEF IOS}
Result := TGrCanvasGL;
{$ELSE}
Result := TSkCanvasRasterMacOS;
{$ENDIF}
{$ELSE}
Result := TGrCanvasGL; <----------------------- THIS if LINUX64 DEFINED
{$ENDIF}
"
TGrCanvasGL is defined in Skia.FMX.Canvas.GL, but for Linux nothing is declared.

Demo is not compiled for Linux64 (FMXLinux is installed), I miss something ?

Dont Work after compile in Windows 11, but in Android works... | Não funciona após compilar para o Windows 11, mas nos Android funciona.

[en]
I installed Skia4Delphi following the documentation, including using the latest version, and after some tests it worked without problems, however after a while of use it didn't work anymore.

The "SKLABEL" Component displays the text at design time, but after compiling (on windows 11) the text doesn't show anything. However if you do the same process on android, it works without problems.

I do not know what to do. I don't know if I'm doing something wrong, or it's something on my computer that is suddenly missing some windows libraries.

[pt]
Eu instalei o Skia4Delphi seguindo a documentação, inclusive usando a última versão, e após alguns testes funcionou sem problemas, entretanto depois de um tempo de uso não funcionou mais.

O Componente "SKLABEL" exibe o texto em tempo de design, mas após compilar (no windows 11) o texto não mostra nada. Entretanto se fizer o mesmo processo no android, funciona sem problemas.

Não sei o que fazer. Não sei se eu estou fazendo algo errado, ou é algo no meu computador que falta, de repente algumas bibliotecas do windows.

Problem | Problema:

Recording 2022-02-15 at 15 32 18

[Android32] Could not load sk4d.so

Some manufacturer and android versions (looks like just in android 6), just in 32 bits, can't find the sk4d.so because they don't look at the folder "lib\armeabi-v7a". Need more investigate.

Edit: Anyway, switching to static compilation would solve the problem (though not supported yet).

Problems with Text Measuring

I am trying to draw text in the center of a box using SKIA and the values I'm getting for the measurement don't seem to be right.

Here is an example:

image

The image on the left is pure Skia -- the image on the right is an autosizing Tlabel set to use the same font/size etc. and which is then centered by its reported dimensions. As you can see it is centered correctly while the skia one isn't .

procedure TForm41.SkPaintBox1Draw(ASender: TObject; const ACanvas: ISkCanvas;
  const ADest: TRectF; const AOpacity: Single);
var
  Paint:ISKPaint;
  LFont1:ISkFont;
  LPaint1:ISkPaint;
  LBlob1,LBlob2:ISkTextBlob;
  LTypeface:ISkTypeface;
  TargetBoundsRect:TRectF;
  LocalScale:TPointF;
  TextToDraw:String;
  begin
  LPaint1 := TSkPaint.Create;
  LPaint1.AntiAlias := True;
  LPaint1.SetColorF(TAlphaColorF.Create(TALphaColorRec.Blue));
//draw frame around the destination rectangles
  ACanvas.DrawLine(ADest.TopLeft,PointF(0,ADest.Height),LPaint1);
  ACanvas.DrawLine(ADest.TopLeft,PointF(ADest.Width,ADest.Top),LPaint1);
  ACanvas.DrawLine(ADest.TopLeft,PointF(0,ADest.Height),LPaint1);
  ACanvas.DrawLine(PointF(ADest.Left,ADest.Height),ADest.BottomRight,LPaint1);
  ACanvas.DrawLine(PointF(ADest.Width,ADest.Height),PointF(ADest.Width,ADest.Top),LPaint1);

//create the font setup
  LTypeface := TSkTypeface.MakeFromName('Sans',tskFontStyle.Bold);
  LFont1 := TSkFont.Create(LTypeface, 18, 1);
  LFont1.Edging := TSkFontEdging.AntiAlias;
  TargetBoundsRect:=ADest;
  TextToDraw:='Skia Rules';


  if not (ASender = SkPaintBox2) then
    begin
     //if we are on the first box then lets measure the text using skia code 
      LFont1.MeasureText(TextToDraw,TargetBoundsRect,LPaint1);
      LBlob1 := TSkTextBlob.Make(TextToDraw, LFont1);
//draw the text centered based on its reported dimensions
      ACanvas.DrawTextBlob(LBlob1, (ADest.Width-TargetBoundsRect.Width)/2,(ADest.Height
      - TargetBoundsRect.Height)/2, LPaint1);
    end;

  //make a smaller font
  LFont1 := TSkFont.Create(LTypeface, 12, 1);
  LFont1.Edging := TSkFontEdging.AntiAlias;
  if ASender = SkPaintBox2 then
  begin
    //Since we are on the second box then we want to center the label based on its reported size
     Label1.SetBounds(ADest.Left+(ADest.Width-Label1.Width)/2,
       ADest.Top+(ADest.Height-Label1.Height)/2,Label1.Width,Label1.Height);
//report its bounds
     LBlob2 := TSkTextBlob.Make('Reported Bounds: '+FloatToStr(Label1.width)+'w vs '+
        FloatToStr(Label1.Height)+'h', LFont1)
  end
 else //report the Skia TExt's bounds
  LBlob2 := TSkTextBlob.Make('Reported Bounds: '+FloatToStr(TargetBoundsRect.width)+'w vs '+
     FloatToStr(TargetBoundsRect.Height)+'h', LFont1);
  ACanvas.DrawTextBlob(LBlob2, 2,(ADest.Height-18), LPaint1);
end;

demo pas and fmx.zip

Hatching

Hi,

i try make rect with hatching like this: https://fiddle.skia.org/c/57c0f67fb27f797e987f8e2994e9515e
can you help me please, why i get bad output?

procedure Hatching(const ACanvas: ISkCanvas);
var
  paint: ISkPaint;
  lattice: TMatrix;
  bounds: TRectF;
begin
  paint := TSkPaint.Create();
  paint.Color := $FF00FF00;
//  paint.StrokeWidth := 1;
//  paint.Style := TSkPaintStyle.Stroke;
  lattice := lattice.CreateScaling(8, 8);
  lattice := lattice.CreateRotation(45);
  paint.PathEffect := TSkPathEffect.Make2DLine(0, lattice);
  paint.AntiAlias := True;
  bounds :=  TRect.Create(0, 0, 250, 250);
  ACanvas.Clear($FFFF00FF);
  ACanvas.DrawRect(bounds, paint);
end;

TJ.

Error compiling for RAD Studio 11.0 Alexandria

Error compiling for RAD Studio 11.0 Alexandria - Skia.Package.RTL.dproj - Win21 (code1).

This message was shown when the installation of skia4delphi finished

Screenshot 2022-02-16 005511

Build.Logs.txt

Microsoft (R) Build Engine version 4.8.4084.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 16-02-22 12:59:42 AM.
Project "C:\Users\hamza\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj" on node 1 (default targets).
C:\Users\hamza\AppData\Roaming\Embarcadero\BDS\22.0\environment.proj(5,9): error MSB5016: The name "asl.log" contains an invalid character ".". [C:\Users\hamza\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj]
Done Building Project "C:\Users\hamza\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj" (default targets) -- FAILED.

Build FAILED.

"C:\Users\hamza\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj" (default target) (1) ->
C:\Users\hamza\AppData\Roaming\Embarcadero\BDS\22.0\environment.proj(5,9): error MSB5016: The name "asl.log" contains an invalid character ".". [C:\Users\hamza\Documents\Skia4Delphi\Packages\RAD Studio 11.0 Alexandria\Skia.Package.RTL.dproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.32

Windows 11 Delphi 11 Apparent Incompatibilities

I just tried to setup my Delphi 11 to work on a project using Skia4Delphi on a Windows 11 laptop with an Intel Iris Graphics card, and unfortunately the display is completely unusable within the IDE--it seems to be a redraw problem of some sort that makes it so that where the Skia SVG should be is just a mishmash of underlying code and repeated image fragments that makes it impossible to work within the IDE using a Skia Enabled project.

I did do a test build and while the IDE's display is completely unusable, it does appear that the built app runs okay. Still this is a major issue for me. I can attach screen shots if that would be helpful.

Rotation of TSkCustomControl causes access violation

I get an invalid Bitmap error if I try to set the rotationangle of the TSKSVG in the IDE when it has an SVG loaded in it.

I have a solution, though it is perhaps a bit more of a hack than a true solution, but I thought I'd offer it regardless.

The fix is as follows:

In Skia.FMX

TSkSvg = class(TSkCustomControl)
  strict private
    FSvg: TSkSvgBrush;
    procedure SetSvg(const AValue: TSkSvgBrush);
    procedure SvgChanged(ASender: TObject);
  private
    fRotationAngle: Single;
    procedure SetRotationAngle(const Value: Single);
  protected
    procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property Svg: TSkSvgBrush read FSvg write SetSvg;
//KJS Added to fix access violation
    property RotationAngle:Single read fRotationAngle write SetRotationAngle;
  end;

implementation

procedure TSkSvg.SetRotationAngle(const Value: Single);
begin
  if Abs(fRotationAngle-Value) > 0.01 then
  begin
    fRotationAngle:=Value;
    Redraw;
  end;
end;

procedure TSkSvg.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single);
begin
  inherited;
  //KJS Added to put rotation in without causing access violation
  ACanvas.Rotate(fRotationAngle,RotationCenter.X*ADest.Width,RotationCenter.Y*ADest.Height);
  FSvg.Render(ACanvas, ADest, AOpacity);
  //KJS Added though I must confess I don't know Skia well enough to know whether it's needed.  But hey
 //it's always good to cleanup, right?
  ACanvas.Rotate(-fRotationAngle,RotationCenter.X*ADest.Width,RotationCenter.Y*ADest.Height);
end;

Skia library may be unloaded too soon

First of all, this Skia library is designed very well. Congratulations! I have created a Skia wrapper before using the SkiaSharp C API, but this one has more features. Impressive!

I small thing I encountered is that I get access violations on shutdown if I have custom FMX controls that contain a Skia object (like an ISkCanvas). In that case, the Skia library may be unloaded before the custom FMX control is destroyed. That is, the TSkiaApi.Destroy class destructor is called before FMX.Forms.Finalization is called. FMX.Forms.Finalization frees any forms and thus FMX controls. Then, when custom FMX control is destroyed, it will also destroy the Skia object. But because the Skia library has already been unloaded, this results in an access violation.

A workaround is to add the Skia.Api or Skia unit to the DPR as the very first unit. That way, the class destructor gets called after the FMX forms are destroyed. But it would be nice if this is not needed.

install problems

D10.2.3 trying to install
C:\Program Files (x86)\Embarcadero\Studio\19.0\LimLib\Skia\Packages\RAD Studio 10.2 Tokyo\Skia.Package.VCL.dproj

as a matter of fact all installations same problem

All bpl compile OK but
Directory is OK C:\Program Files (x86)\Embarcadero\Studio\19.0\LimLib\Skia\Library\RAD Studio 10.2 Tokyo\Win32\Debug\Bpl and units too.

All files are correct and still and I get Skia.Package.RTL250.bpl is missing
I had to move Skia.Package.RTL250.bpl to C:\Users\Public\Documents\Embarcadero\Studio\19.0\Bpl
but now I get rtl250.bpl error
In short, cannot install ver 3

Stretch Parameter Suggestion

I wanted to stretch the SVG to fill the target rectangle so I added the following minor edits which might be of use to someone else.

In the TSKVGBrush class I added a parameter Stretch to the Render function with a default of false to (modifications shown in ALL CAPS

TSkSvgBrush = class(TPersistent)
     procedure Render(const ACanvas: ISkCanvas; const ADestRect: TRectF; const AOpacity: Single; STRETCH:BOOLEAN = FALSE);
end;

procedure TSkSvgBrush.Render(const ACanvas: ISkCanvas; const ADestRect: TRectF;  const AOpacity: Single; STRETCH:BOOLEAN = FALSE);
. . .
    if STRETCH then
       LWRAPPEDDEST = ADESTRECT
  ELSE
       LWrappedDest := LSvgRect.FitInto(ADestRect);
. . .

 TSkSvg = class(TSkCustomControl)
 private
    FSTRETCH:BOOLEAN:
    PROCEDURE SETSTRETCH(CONST VALUE:BOOLEAN);
  published
     PROPERTY STRETCH:BOOLEAN READ FSTRETCH WRITE SETSTRETCH;
  end;

PROCEDURE TSKVG.SETSTRETCH(CONST VALUE:BOOLEAN);
BEGIN
  IF FSTRETCH<> VALUE THEN
    BEGIN
       FSTRETCH := VALUE ;
       REPAINT;
    END;
END;

procedure TSkSvg.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single);
begin
  inherited;
//ADDED FSTRETCH PARAMETER
  FSvg.Render(ACanvas, ADest, AOpacity, FSTRETCH);
end;


 

Installation Fails on Delphi 11 Professional

Using the Skia4Delphi Setup.exe installation method, the setup wizard halts with the following error...

image

As I have Delphi 11 Professional, my machine has no FMX Linux capabilities :-( so it looks like the installation program assumes Delphi Exterprise / Architect Edition is installed.

The same error occurs on several Delphi 11 installs - in VMs and on a physical machine.

Iterate through path

How can i iterate through path object? In the example below, the verb always returns "out of bounds".

var
  LElem : TSkPathIteratorElem;
begin
   for LElem in APath.GetIterator(False) do
   begin
      case LElem.Verb of **<-- out of bounds**
      ...
end;

Thanks in advance for the answer

Enable Vulkan support in the Skia library

I noticed that Vulkan has been disabled in the build files.

Are there any particular reason why it has been disabled?

If not, I would encourage to ship the library with Vulkan support enabled by default 😃

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.