diff --git a/Demo/D10_4/SVGIconImageDemoFMX.dproj b/Demo/D10_4/SVGIconImageDemoFMX.dproj index eca26dd..8dfe7e3 100644 --- a/Demo/D10_4/SVGIconImageDemoFMX.dproj +++ b/Demo/D10_4/SVGIconImageDemoFMX.dproj @@ -6,7 +6,7 @@ SVGIconImageDemoFMX.dpr True Debug - Win32 + Android 19 Application @@ -277,8 +277,35 @@ - - + + + true + + + + + true + + + + + styles.xml + true + + + + + true + + + + + libSVGIconImageDemoFMX.so + true + + + + true @@ -292,12 +319,51 @@ true + + + true + + SVGIconImageDemoFMX.exe true + + + true + + + + + ic_launcher.png + true + + + + + libSVGIconImageDemoFMX.so + true + + + + + libSVGIconImageDemoFMX.so + true + + + + + true + + + + + classes.dex + true + + 1 diff --git a/Demo/D10_4/SVGIconImageDemoFMX.res b/Demo/D10_4/SVGIconImageDemoFMX.res index eecf6d5..36f26e2 100644 Binary files a/Demo/D10_4/SVGIconImageDemoFMX.res and b/Demo/D10_4/SVGIconImageDemoFMX.res differ diff --git a/Demo/D11/CategoryButtonTest.dproj b/Demo/D11/CategoryButtonTest.dproj index dccf03b..4c21382 100644 --- a/Demo/D11/CategoryButtonTest.dproj +++ b/Demo/D11/CategoryButtonTest.dproj @@ -1,7 +1,7 @@ - + {713DC0B3-0BD5-42EE-8542-4CD75D94A280} - 19.3 + 19.5 VCL True Debug @@ -108,10 +108,6 @@
MainForm
dfm - - Cfg_2 - Base - Base @@ -119,6 +115,10 @@ Cfg_1 Base + + Cfg_2 + Base + Delphi.Personality.12 @@ -128,16 +128,10 @@ CategoryButtonTest.dpr - - + - - - - CategoryButtonTest.exe - true - - + + 1 @@ -150,14 +144,14 @@ 0 - + classes - 1 + 64 classes - 1 + 64 @@ -451,6 +445,11 @@ 1 .framework
+ + Contents\MacOS + 1 + .framework + 0 @@ -464,7 +463,7 @@ 1 .dylib - + 1 .dylib @@ -478,6 +477,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .dll;.bpl @@ -492,7 +496,7 @@ 1 .dylib - + 1 .dylib @@ -506,6 +510,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .bpl @@ -524,7 +533,7 @@ 0 - + 0 @@ -535,6 +544,10 @@ Contents\Resources\StartUp\ 0 + + Contents\Resources\StartUp\ + 0 + 0 @@ -544,13 +557,17 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 +
..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -560,7 +577,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -570,7 +587,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -580,7 +597,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -590,7 +607,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -600,7 +617,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -610,7 +627,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -620,7 +637,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -630,7 +647,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -640,7 +657,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -650,7 +667,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -660,7 +677,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -670,7 +687,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -680,7 +697,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -690,7 +707,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -700,7 +717,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -710,7 +727,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -720,7 +737,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -730,7 +747,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -752,6 +769,10 @@ ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + @@ -762,6 +783,10 @@ ..\ 1 + + ..\ + 1 + @@ -770,7 +795,7 @@ 1 - + 1 @@ -779,7 +804,7 @@ ..\$(PROJECTNAME).launchscreen 64 - + ..\$(PROJECTNAME).launchscreen 64 @@ -791,7 +816,7 @@ 1 - + 1 @@ -800,6 +825,10 @@ ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + @@ -810,6 +839,10 @@ ..\ 1 + + ..\ + 1 + @@ -820,6 +853,10 @@ Contents 1 + + Contents + 1 + @@ -830,6 +867,10 @@ Contents\Resources 1 + + Contents\Resources + 1 + @@ -846,7 +887,7 @@ 1 - + 1 @@ -860,6 +901,10 @@ Contents\MacOS 1 + + Contents\MacOS + 1 + 0 @@ -898,16 +943,18 @@ 1 - - + + + + + - - - - + + +
True diff --git a/Demo/D11/CategoryButtonTest.res b/Demo/D11/CategoryButtonTest.res index 14c6615..70760b5 100644 Binary files a/Demo/D11/CategoryButtonTest.res and b/Demo/D11/CategoryButtonTest.res differ diff --git a/Demo/D11/SVGIconImageCollectionIntoControlList.dproj b/Demo/D11/SVGIconImageCollectionIntoControlList.dproj index 49a59c5..449cb85 100644 --- a/Demo/D11/SVGIconImageCollectionIntoControlList.dproj +++ b/Demo/D11/SVGIconImageCollectionIntoControlList.dproj @@ -1,7 +1,7 @@ - + {424FFC3D-39D3-4BF9-8092-2889082C0FFA} - 19.4 + 19.5 VCL True Debug @@ -130,16 +130,10 @@ SVGIconImageCollectionIntoControlList.dpr - - + - - - - SVGIconImageCollectionIntoControlList.exe - true - - + + 1 @@ -152,14 +146,14 @@ 0 - + classes - 1 + 64 classes - 1 + 64 @@ -453,6 +447,11 @@ 1 .framework + + Contents\MacOS + 1 + .framework + 0 @@ -466,7 +465,7 @@ 1 .dylib - + 1 .dylib @@ -480,6 +479,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .dll;.bpl @@ -494,7 +498,7 @@ 1 .dylib - + 1 .dylib @@ -508,6 +512,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .bpl @@ -526,7 +535,7 @@ 0 - + 0 @@ -537,6 +546,10 @@ Contents\Resources\StartUp\ 0 + + Contents\Resources\StartUp\ + 0 + 0 @@ -546,13 +559,17 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -562,7 +579,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -572,7 +589,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -582,7 +599,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -592,7 +609,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -602,7 +619,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -612,7 +629,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -622,7 +639,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -632,7 +649,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -642,7 +659,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -652,7 +669,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -662,7 +679,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -672,7 +689,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -682,7 +699,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -692,7 +709,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -702,7 +719,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -712,7 +729,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -722,7 +739,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -732,7 +749,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -754,6 +771,10 @@ ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + @@ -764,6 +785,10 @@ ..\ 1 + + ..\ + 1 + @@ -772,7 +797,7 @@ 1 - + 1 @@ -781,7 +806,7 @@ ..\$(PROJECTNAME).launchscreen 64 - + ..\$(PROJECTNAME).launchscreen 64 @@ -793,7 +818,7 @@ 1 - + 1 @@ -802,6 +827,10 @@ ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + @@ -812,6 +841,10 @@ ..\ 1 + + ..\ + 1 + @@ -822,6 +855,10 @@ Contents 1 + + Contents + 1 + @@ -832,6 +869,10 @@ Contents\Resources 1 + + Contents\Resources + 1 + @@ -848,7 +889,7 @@ 1 - + 1 @@ -862,6 +903,10 @@ Contents\MacOS 1 + + Contents\MacOS + 1 + 0 @@ -900,16 +945,18 @@ 1 - - + + + + + - - - - + + + True diff --git a/Demo/D11/SVGIconImageDemoFMX.dproj b/Demo/D11/SVGIconImageDemoFMX.dproj index 12af30d..7daf470 100644 --- a/Demo/D11/SVGIconImageDemoFMX.dproj +++ b/Demo/D11/SVGIconImageDemoFMX.dproj @@ -196,7 +196,6 @@ Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) Debug true - CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 1033 $(BDS)\bin\default_app.manifest ..\Images\svgiconimagelistcomponenticon.ico @@ -208,7 +207,6 @@ Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) Debug true - CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 1033 $(BDS)\bin\default_app.manifest ..\Images\svgiconimagelistcomponenticon.ico diff --git a/Demo/D11/SVGIconImageDemoFMX.res b/Demo/D11/SVGIconImageDemoFMX.res index 0e5b76f..7d3b8d6 100644 Binary files a/Demo/D11/SVGIconImageDemoFMX.res and b/Demo/D11/SVGIconImageDemoFMX.res differ diff --git a/Demo/D11/SVGIconImageListDemo.dproj b/Demo/D11/SVGIconImageListDemo.dproj index 29ab9c6..85f2674 100644 --- a/Demo/D11/SVGIconImageListDemo.dproj +++ b/Demo/D11/SVGIconImageListDemo.dproj @@ -52,7 +52,7 @@ $(BDS)\bin\default_app.manifest ..\Dcu\D11\$(Platform)\$(Config) ..\Bin - ..\..\source;..\..\svg;..\..\Image32\Source;..\..\Skia4delphi\Source;..\..\Skia4delphi\Source\VCL;$(DCC_UnitSearchPath) + ..\..\source;..\..\svg;..\..\Image32\Source;$(DCC_UnitSearchPath) ..\Bin\IconFontsImageListDemo.exe 00400000 x86 @@ -168,7 +168,16 @@ 1.0.0.0 - + + Ethea SVGIconImageList FMX components + Ethea SVGIconImageList VCL components + Ethea InstantSolutions 7 Rtl Library + Ethea InstantSolutions 7 Vcl Library + Ethea InstantSolutions 7 LibreOffice/OpenOffice Components + Ethea InstantSolutions 7 Framework Library + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + True diff --git a/Demo/D11/SVGIconImageListDemoFMX.dproj b/Demo/D11/SVGIconImageListDemoFMX.dproj index 09476bf..3aee46a 100644 --- a/Demo/D11/SVGIconImageListDemoFMX.dproj +++ b/Demo/D11/SVGIconImageListDemoFMX.dproj @@ -6,8 +6,8 @@ SVGIconImageListDemoFMX.dpr True Debug - Win32 - 1 + Win64 + 32771 Application @@ -38,8 +38,8 @@ Base true - - true + + true Cfg_1 true true @@ -61,6 +61,12 @@ Base true + + true + Cfg_2 + true + true + true Cfg_2 @@ -140,78 +146,18 @@ $(BDS)\bin\Artwork\Android\FM_NotificationIcon_72x72.png $(BDS)\bin\Artwork\Android\FM_NotificationIcon_96x96.png android-support-v4.dex.jar;cloud-messaging.dex.jar;com-google-android-gms.play-services-ads-base.17.2.0.dex.jar;com-google-android-gms.play-services-ads-identifier.16.0.0.dex.jar;com-google-android-gms.play-services-ads-lite.17.2.0.dex.jar;com-google-android-gms.play-services-ads.17.2.0.dex.jar;com-google-android-gms.play-services-analytics-impl.16.0.8.dex.jar;com-google-android-gms.play-services-analytics.16.0.8.dex.jar;com-google-android-gms.play-services-base.16.0.1.dex.jar;com-google-android-gms.play-services-basement.16.2.0.dex.jar;com-google-android-gms.play-services-gass.17.2.0.dex.jar;com-google-android-gms.play-services-identity.16.0.0.dex.jar;com-google-android-gms.play-services-maps.16.1.0.dex.jar;com-google-android-gms.play-services-measurement-base.16.4.0.dex.jar;com-google-android-gms.play-services-measurement-sdk-api.16.4.0.dex.jar;com-google-android-gms.play-services-stats.16.0.1.dex.jar;com-google-android-gms.play-services-tagmanager-v4-impl.16.0.8.dex.jar;com-google-android-gms.play-services-tasks.16.0.1.dex.jar;com-google-android-gms.play-services-wallet.16.0.1.dex.jar;com-google-firebase.firebase-analytics.16.4.0.dex.jar;com-google-firebase.firebase-common.16.1.0.dex.jar;com-google-firebase.firebase-iid-interop.16.0.1.dex.jar;com-google-firebase.firebase-iid.17.1.1.dex.jar;com-google-firebase.firebase-measurement-connector.17.0.1.dex.jar;com-google-firebase.firebase-messaging.17.5.0.dex.jar;fmx.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar - - - CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing bluetooth;NSBluetoothPeripheralUsageDescription=The reason for accessing bluetooth peripherals;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSMotionUsageDescription=The reason for accessing the accelerometer;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple's speech recognition servers - iPhoneAndiPad - true - Debug - $(MSBuildProjectName) - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_1024x1024.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_120x120.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_180x180.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImage_2x.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImageDark_2x.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImage_3x.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImageDark_3x.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_120x120.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SettingIcon_58x58.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SettingIcon_87x87.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_NotificationIcon_40x40.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_NotificationIcon_60x60.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_152x152.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_167x167.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImage_2x.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageDark_2x.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SettingIcon_58x58.png - $(BDS)\bin\Artwork\iOS\iPad\FM_NotificationIcon_40x40.png - - - CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing bluetooth;NSBluetoothPeripheralUsageDescription=The reason for accessing bluetooth peripherals;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSMotionUsageDescription=The reason for accessing the accelerometer;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple's speech recognition servers - iPhoneAndiPad - true - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_1024x1024.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_120x120.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_180x180.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImage_2x.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImageDark_2x.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImage_3x.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImageDark_3x.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_120x120.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SettingIcon_58x58.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SettingIcon_87x87.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_NotificationIcon_40x40.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_NotificationIcon_60x60.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_152x152.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_167x167.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImage_2x.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageDark_2x.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SettingIcon_58x58.png - $(BDS)\bin\Artwork\iOS\iPad\FM_NotificationIcon_40x40.png - - - CFBundleName=$(MSBuildProjectName);CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);NSHighResolutionCapable=true;LSApplicationCategoryType=public.app-category.utilities;NSLocationUsageDescription=The reason for accessing the location information of the user;NSContactsUsageDescription=The reason for accessing the contacts;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSCameraUsageDescription=The reason for accessing the camera;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSMotionUsageDescription=The reason for accessing the accelerometer;NSDesktopFolderUsageDescription=The reason for accessing the Desktop folder;NSDocumentsFolderUsageDescription=The reason for accessing the Documents folder;NSDownloadsFolderUsageDescription=The reason for accessing the Downloads folder;NSNetworkVolumesUsageDescription=The reason for accessing files on a network volume;NSRemovableVolumesUsageDescription=The reason for accessing files on a removable volume;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple's speech recognition servers - Debug - true - - - CFBundleName=$(MSBuildProjectName);CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);NSHighResolutionCapable=true;LSApplicationCategoryType=public.app-category.utilities;NSLocationUsageDescription=The reason for accessing the location information of the user;NSContactsUsageDescription=The reason for accessing the contacts;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSCameraUsageDescription=The reason for accessing the camera;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSMotionUsageDescription=The reason for accessing the accelerometer;NSDesktopFolderUsageDescription=The reason for accessing the Desktop folder;NSDocumentsFolderUsageDescription=The reason for accessing the Documents folder;NSDownloadsFolderUsageDescription=The reason for accessing the Downloads folder;NSNetworkVolumesUsageDescription=The reason for accessing files on a network volume;NSRemovableVolumesUsageDescription=The reason for accessing files on a removable volume;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple's speech recognition servers - Debug - true + 1 + #000000 DBXSqliteDriver;RESTComponents;DataSnapServerMidas;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;emsclientfiredac;DataSnapFireDAC;svnui;tethering;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;FmxTeeUI;FireDACIBDriver;fmx;fmxdae;vclib;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;DataSnapCommon;emsclient;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;FireDACOracleDriver;CloudService;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonDriver;DataSnapClient;inet;bindcompdbx;IndyIPCommon;vcl;DBXSybaseASEDriver;IndyIPServer;IndySystem;FireDACDb2Driver;dsnapcon;FireDACMSAccDriver;fmxFireDAC;FireDACInfxDriver;vclimg;TeeDB;FireDAC;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;ibxpress;Tee;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;FireDACDSDriver;rtl;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;vclribbon;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;DataSnapProviderClient;dbrtl;inetdbxpress;FireDACMongoDBDriver;IndyProtocols;fmxase;$(DCC_UsePackage) 1033 Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) $(BDS)\bin\default_app.manifest - CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) true $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + none ..\Images\svgiconimagelistcomponenticon.ico @@ -224,6 +170,8 @@ $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png Debug + none + ..\Images\svgiconimagelistcomponenticon.ico DEBUG;$(DCC_Define) @@ -236,10 +184,8 @@ 1 package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= - #000000 - true false Debug PerMonitor @@ -248,9 +194,12 @@ ..\Images\svgiconimagelistcomponenticon.ico - true Debug PerMonitorV2 + true + 1033 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + ..\Images\svgiconimagelistcomponenticon.ico false @@ -258,15 +207,23 @@ 0 0 + + 1 + package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= + - true PerMonitor - ..\D10_3\IconFontsImageListComponentIcon.ico Debug + true + ..\Images\svgiconimagelistcomponenticon.ico + 1033 - true PerMonitorV2 + true + 1033 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + ..\Images\svgiconimagelistcomponenticon.ico @@ -299,6 +256,12 @@ SVGIconImageListDemoFMX.dpr + Ethea SVGIconImageList FMX components + Ethea SVGIconImageList VCL components + Ethea InstantSolutions 7 Rtl Library + Ethea InstantSolutions 7 Vcl Library + Ethea InstantSolutions 7 LibreOffice/OpenOffice Components + Ethea InstantSolutions 7 Framework Library Microsoft Office 2000 Sample Automation Server Wrapper Components Microsoft Office XP Sample Automation Server Wrapper Components diff --git a/Demo/D11/SVGIconImageListDemoFMX.res b/Demo/D11/SVGIconImageListDemoFMX.res index 4e9005b..130517a 100644 Binary files a/Demo/D11/SVGIconImageListDemoFMX.res and b/Demo/D11/SVGIconImageListDemoFMX.res differ diff --git a/Demo/Source/UMainNew.dfm b/Demo/Source/UMainNew.dfm index 2b1857b..83838c8 100644 --- a/Demo/Source/UMainNew.dfm +++ b/Demo/Source/UMainNew.dfm @@ -37,7 +37,6 @@ object MainForm: TMainForm Height = 509 Align = alLeft TabOrder = 0 - ExplicitHeight = 508 object SelectThemeRadioGroup: TRadioGroup Left = 1 Top = 1 @@ -47,7 +46,6 @@ object MainForm: TMainForm Caption = 'Select Theme/Color' TabOrder = 0 OnClick = SelectThemeRadioGroupClick - ExplicitHeight = 209 end object LoadGroupBox: TGroupBox Left = 1 @@ -57,7 +55,6 @@ object MainForm: TMainForm Align = alBottom Caption = 'Load SVG from disk' TabOrder = 1 - ExplicitTop = 210 object BuildFromFilesButton: TButton Left = 3 Top = 23 @@ -76,7 +73,6 @@ object MainForm: TMainForm Align = alBottom BevelOuter = bvNone TabOrder = 3 - ExplicitTop = 372 object IconSizeLabel: TLabel Left = 8 Top = 3 @@ -107,7 +103,6 @@ object MainForm: TMainForm Align = alBottom BevelOuter = bvNone TabOrder = 2 - ExplicitTop = 269 object ClearButton: TButton Left = 5 Top = 5 @@ -135,7 +130,6 @@ object MainForm: TMainForm Align = alBottom Caption = 'Fixed color' TabOrder = 4 - ExplicitTop = 434 object FixedColorComboBox: TColorBox Left = 10 Top = 19 @@ -175,7 +169,6 @@ object MainForm: TMainForm Align = alBottom BevelOuter = bvNone TabOrder = 5 - ExplicitTop = 310 object IconOpacityLabel: TLabel Left = 8 Top = 3 @@ -210,7 +203,6 @@ object MainForm: TMainForm Images = VirtualImageList TabOrder = 1 Transparent = False - ExplicitWidth = 705 object ToolButton1: TToolButton Left = 0 Top = 0 @@ -262,8 +254,6 @@ object MainForm: TMainForm Align = alRight TabOrder = 2 OnResize = paButtonsResize - ExplicitLeft = 625 - ExplicitHeight = 508 object SVGIconImage: TSVGIconImage Left = 1 Top = 428 @@ -277,6 +267,7 @@ object MainForm: TMainForm AutoSize = False ImageList = VirtualImageList ImageIndex = 100 + ImageName = 'Delphi_Product icon' Align = alBottom OnDblClick = SVGIconImageDblClick OnMouseDown = SVGIconImageMouseDown @@ -319,8 +310,6 @@ object MainForm: TMainForm Height = 509 Align = alClient TabOrder = 3 - ExplicitWidth = 420 - ExplicitHeight = 508 object ImageListLabel: TLabel Left = 1 Top = 209 @@ -350,7 +339,6 @@ object MainForm: TMainForm 0000000000FFFFFFFF0000000000000000000000000107740077006F00200074 0077006F00280000000300000003000000FFFFFFFFFFFFFFFF00000000000000 0000000000010574006800720065006500} - ExplicitWidth = 418 end object ImageView: TListView Left = 1 diff --git a/Demo/Source/UMainNew.pas b/Demo/Source/UMainNew.pas index d8e67f5..61ce94e 100644 --- a/Demo/Source/UMainNew.pas +++ b/Demo/Source/UMainNew.pas @@ -126,10 +126,10 @@ implementation {$R *.dfm} uses - PasSVGFactory - , Image32SVGFactory - , SkiaSVGFactory - , D2DSVGFactory + Image32SVGFactory +// , PasSVGFactory +// , SkiaSVGFactory +// , D2DSVGFactory , Themes {$IFDEF DXE3+} diff --git a/Image32/source/Img32.Draw.pas b/Image32/source/Img32.Draw.pas index ecff192..b4739a8 100644 --- a/Image32/source/Img32.Draw.pas +++ b/Image32/source/Img32.Draw.pas @@ -2,8 +2,8 @@ (******************************************************************************* * Author : Angus Johnson * -* Version : 4.3 * -* Date : 27 September 2022 * +* Version : 4.4 * +* Date : 21 December 2022 * * Website : http://www.angusj.com * * Copyright : Angus Johnson 2019-2021 * * * @@ -26,8 +26,8 @@ interface type TFillRule = Img32.Vector.TFillRule; - //TGradientColor: used internally by both - //TLinearGradientRenderer and TRadialGradientRenderer + // TGradientColor: used internally by both + // TLinearGradientRenderer and TRadialGradientRenderer TGradientColor = record offset: double; color: TColor32; @@ -36,13 +36,13 @@ TGradientColor = record TGradientFillStyle = (gfsClamp, gfsMirror, gfsRepeat); - //TBoundsProc: Function template for TCustomRenderer. + // TBoundsProc: Function template for TCustomRenderer. TBoundsProc = function(dist, colorsCnt: integer): integer; TBoundsProcD = function(dist: double; colorsCnt: integer): integer; TImage32ChangeProc = procedure of object; - //TCustomRenderer: can accommodate pixels of any size + // TCustomRenderer: can accommodate pixels of any size TCustomRenderer = class {$IFDEF ABSTRACT_CLASSES} abstract {$ENDIF} private fImgWidth : integer; @@ -58,8 +58,8 @@ TCustomRenderer = class {$IFDEF ABSTRACT_CLASSES} abstract {$ENDIF} imgWidth, imgHeight, pixelSize: integer): Boolean; overload; virtual; function Initialize(targetImage: TImage32): Boolean; overload; virtual; function GetDstPixel(x,y: integer): Pointer; - //RenderProc: x & y refer to pixel coords in the destination image and - //where x1 is the start (and left) and x2 is the end of the render + // RenderProc: x & y refer to pixel coords in the destination image and + // where x1 is the start (and left) and x2 is the end of the render procedure RenderProc(x1, x2, y: integer; alpha: PByte); virtual; abstract; property ImgWidth: integer read fImgWidth; property ImgHeight: integer read fImgHeight; @@ -120,7 +120,7 @@ TImageRenderer = class(TCustomRenderer) property Offset: TPoint read fOffset write fOffset; end; - //TCustomGradientRenderer is also an abstract class + // TCustomGradientRenderer is also an abstract class TCustomGradientRenderer = class(TCustomRenderer) private fBoundsProc : TBoundsProc; @@ -183,7 +183,7 @@ TSvgRadialGradientRenderer = class(TCustomGradientRenderer) gradientFillStyle: TGradientFillStyle = gfsClamp); reintroduce; end; - //Barycentric rendering colorizes inside triangles + // Barycentric rendering colorizes inside triangles TBarycentricRenderer = class(TCustomRenderer) private a: TPointD; @@ -197,9 +197,9 @@ TBarycentricRenderer = class(TCustomRenderer) procedure SetParameters(const a, b, c: TPointD; c1, c2, c3: TColor32); end; - /////////////////////////////////////////////////////////////////////////// + // ///////////////////////////////////////////////////////////////////////// // DRAWING FUNCTIONS - /////////////////////////////////////////////////////////////////////////// + // ///////////////////////////////////////////////////////////////////////// procedure DrawPoint(img: TImage32; const pt: TPointD; radius: double; color: TColor32); overload; @@ -280,17 +280,17 @@ TBarycentricRenderer = class(TCustomRenderer) procedure DrawPolygon_ClearType(img: TImage32; const polygons: TPathsD; fillRule: TFillRule; color: TColor32; backColor: TColor32 = clWhite32); - /////////////////////////////////////////////////////////////////////////// + // ///////////////////////////////////////////////////////////////////////// // MISCELLANEOUS FUNCTIONS - /////////////////////////////////////////////////////////////////////////// + // ///////////////////////////////////////////////////////////////////////// procedure ErasePolygon(img: TImage32; const polygon: TPathD; fillRule: TFillRule); overload; procedure ErasePolygon(img: TImage32; const polygons: TPathsD; fillRule: TFillRule); overload; - //Both DrawBoolMask and DrawAlphaMask require - //'mask' length to equal 'img' width * height + // Both DrawBoolMask and DrawAlphaMask require + // 'mask' length to equal 'img' width * height procedure DrawBoolMask(img: TImage32; const mask: TArrayOfByte; color: TColor32 = clBlack32); procedure DrawAlphaMask(img: TImage32; @@ -308,28 +308,25 @@ implementation type - //A horizontal scanline contains any number of line fragments. A fragment - //can be a number of pixels wide but it can't be more than one pixel high. - TFragment = record - botX, topX, dy, dydx: double; - end; - TFragmentArray = array[0 .. (Maxint div SizeOf(TFragment)) -1] of TFragment; - PFragments = ^TFragmentArray; - PFragment = ^TFragment; + // A horizontal scanline contains any number of line fragments. A fragment + // can be a number of pixels wide but it can't be more than one pixel high. + // TFragment = record + // botX, topX, dy, dydx: double; // ie x at bottom and top of scanline + // end; TScanLine = record Y: integer; minX, maxX: integer; fragCnt: integer; {$IFDEF MemCheck} total: integer; {$ENDIF} - fragments: PFragments; + fragOffset: integer; end; PScanline = ^TScanline; TArrayOfScanline = array of TScanline; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // ApplyClearType (see DrawPolygon_ClearType below) -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ type PArgbs = ^TArgbs; @@ -360,15 +357,15 @@ procedure ApplyClearType(img: TImage32; textColor: TColor32 = clBlack32; for h := 0 to img.Height -1 do begin - //each row of the image is copied into a temporary buffer ... - //noting that while 'dst' (img.Pixels) is initially the source - //it will later be destination (during image compression). + // each row of the image is copied into a temporary buffer ... + // noting that while 'dst' (img.Pixels) is initially the source + // it will later be destination (during image compression). dst := PARGB(@img.Pixels[h * img.Width]); src := PARGB(@rowBuffer[2]); Move(dst^, src^, img.Width * SizeOf(TColor32)); srcArr := PArgbs(rowBuffer); - //using this buffer compress the image ... + // using this buffer compress the image ... w := 2; while w < img.Width do begin @@ -389,11 +386,11 @@ procedure ApplyClearType(img: TImage32; textColor: TColor32 = clBlack32; end; end; - //Following compression the right 2/3 of the image is redundant + // Following compression the right 2/3 of the image is redundant img.Crop(Types.Rect(0,0, img.Width div 3, img.Height)); - //currently text is white and the background is black - //so blend in the text and background colors ... + // currently text is white and the background is black + // so blend in the text and background colors ... diff_R := fgColor.R - bgColor.R; diff_G := fgColor.G - bgColor.G; diff_B := fgColor.B - bgColor.B; @@ -407,7 +404,7 @@ procedure ApplyClearType(img: TImage32; textColor: TColor32 = clBlack32; dst.Color := bkColor else begin - //blend front (text) and background colors ... + // blend front (text) and background colors ... dst.R := (bg8_R + diff_R * dst.R) shr 8; dst.G := (bg8_G + diff_G * dst.G) shr 8; dst.B := (bg8_B + diff_B * dst.B) shr 8; @@ -416,26 +413,30 @@ procedure ApplyClearType(img: TImage32; textColor: TColor32 = clBlack32; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // Other miscellaneous functions -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ -////__Trunc: An efficient Trunc() algorithm (ie rounds toward zero) -//function __Trunc(val: double): integer; {$IFDEF INLINE} inline; {$ENDIF} -//var +// //__Trunc: An efficient Trunc() algorithm (ie rounds toward zero) +// function __Trunc(val: double): integer; {$IFDEF INLINE} inline; {$ENDIF} +// var // exp: integer; // i64: UInt64 absolute val; -//begin +// begin // //https://en.wikipedia.org/wiki/Double-precision_floating-point_format // Result := 0; // if i64 = 0 then Exit; // exp := Integer(Cardinal(i64 shr 52) and $7FF) - 1023; // //nb: when exp == 1024 then val == INF or NAN. -// if exp < 0 then Exit; -// Result := ((i64 and $1FFFFFFFFFFFFF) shr (52-exp)) or (1 shl exp); +// if exp < 0 then +// Exit +// else if exp > 52 then +// Result := ((i64 and $1FFFFFFFFFFFFF) shl (exp - 52)) or (UInt64(1) shl exp) +// else +// Result := ((i64 and $1FFFFFFFFFFFFF) shr (52 - exp)) or (UInt64(1) shl exp); // if val < 0 then Result := -Result; -//end; -//------------------------------------------------------------------------------ +// end; +// ------------------------------------------------------------------------------ function ClampByte(val: double): byte; {$IFDEF INLINE} inline; {$ENDIF} begin @@ -443,7 +444,7 @@ function ClampByte(val: double): byte; {$IFDEF INLINE} inline; {$ENDIF} else if val > 255 then result := 255 else result := Round(val); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function GetPixel(current: PARGB; delta: integer): PARGB; {$IFDEF INLINE} inline; {$ENDIF} @@ -451,7 +452,7 @@ function GetPixel(current: PARGB; delta: integer): PARGB; Result := current; inc(Result, delta); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function ReverseColors(const colors: TArrayOfGradientColor): TArrayOfGradientColor; var @@ -465,7 +466,7 @@ function ReverseColors(const colors: TArrayOfGradientColor): TArrayOfGradientCol result[i].offset := 1 - colors[highI -i].offset; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure SwapColors(var color1, color2: TColor32); var @@ -475,7 +476,7 @@ procedure SwapColors(var color1, color2: TColor32); color1 := color2; color2 := c; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure SwapPoints(var point1, point2: TPoint); overload; var @@ -485,7 +486,7 @@ procedure SwapPoints(var point1, point2: TPoint); overload; point1 := point2; point2 := pt; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure SwapPoints(var point1, point2: TPointD); overload; var @@ -495,7 +496,7 @@ procedure SwapPoints(var point1, point2: TPointD); overload; point1 := point2; point2 := pt; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function ClampQ(q, endQ: integer): integer; begin @@ -503,7 +504,7 @@ function ClampQ(q, endQ: integer): integer; else if q >= endQ then result := endQ -1 else result := q; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function ClampD(d: double; colorCnt: integer): integer; begin @@ -512,7 +513,7 @@ function ClampD(d: double; colorCnt: integer): integer; else if d >= 1 then result := colorCnt else result := Round(d * colorCnt); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function MirrorQ(q, endQ: integer): integer; begin @@ -521,7 +522,7 @@ function MirrorQ(q, endQ: integer): integer; if Odd(q div endQ) then result := (endQ -1) - result; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function MirrorD(d: double; colorCnt: integer): integer; begin @@ -530,7 +531,7 @@ function MirrorD(d: double; colorCnt: integer): integer; result := Round((1 - frac(d)) * colorCnt) else result := Round(frac(d) * colorCnt); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function RepeatQ(q, endQ: integer): integer; begin @@ -542,7 +543,7 @@ function RepeatQ(q, endQ: integer): integer; end else result := q; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function SoftRptQ(q, endQ: integer): integer; begin @@ -551,7 +552,7 @@ function SoftRptQ(q, endQ: integer): integer; result := (q mod endQ); if result = 0 then result := endQ div 2; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function RepeatD(d: double; colorCnt: integer): integer; begin @@ -560,7 +561,7 @@ function RepeatD(d: double; colorCnt: integer): integer; result := Round((1 + frac(d)) * colorCnt) else result := Round(frac(d) * colorCnt); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function BlendColorUsingMask(bgColor, fgColor: TColor32; mask: Byte): TColor32; var @@ -593,10 +594,10 @@ function BlendColorUsingMask(bgColor, fgColor: TColor32; mask: Byte): TColor32; res.B := R[fg.B] + InvR[bg.B]; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ -//MakeColorGradient: using the supplied array of TGradientColor, -//create an array of TColor32 of the specified length +// MakeColorGradient: using the supplied array of TGradientColor, +// create an array of TColor32 of the specified length function MakeColorGradient(const gradColors: TArrayOfGradientColor; len: integer): TArrayOfColor32; var @@ -634,18 +635,19 @@ function MakeColorGradient(const gradColors: TArrayOfGradientColor; if j < len then result[j] := result[j-1]; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // Rasterize() support functions -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure AllocateScanlines(const polygons: TPathsD; - var scanlines: TArrayOfScanline; clipBottom, clipRight: integer); + var scanlines: TArrayOfScanline; out fragments: PDouble; clipBottom, clipRight: integer); var i,j, highI, highJ: integer; y1, y2: integer; + fragOff: Cardinal; psl: PScanline; begin - //first count how often each edge intersects with each horizontal scanline + // first count how often each edge intersects with each horizontal scanline for i := 0 to high(polygons) do begin highJ := high(polygons[i]); @@ -656,10 +658,10 @@ procedure AllocateScanlines(const polygons: TPathsD; y2 := Round(polygons[i][j].Y); if y1 < y2 then begin - //descending (but ignore edges outside the clipping range) + // descending (but ignore edges outside the clipping range) if (y2 >= 0) and (y1 <= clipBottom) then begin - if (y1 > 0) and (y1 <= clipBottom) then + if (y1 > 0) then dec(scanlines[y1 -1].fragCnt); if y2 >= clipBottom then inc(scanlines[clipBottom].fragCnt) else @@ -667,7 +669,7 @@ procedure AllocateScanlines(const polygons: TPathsD; end; end else begin - //ascending (but ignore edges outside the clipping range) + // ascending (but ignore edges outside the clipping range) if (y1 >= 0) and (y2 <= clipBottom) then begin if (y2 > 0) then @@ -681,35 +683,42 @@ procedure AllocateScanlines(const polygons: TPathsD; end; end; - //convert 'count' accumulators into real counts and allocate storage + // convert 'count' accumulators into real counts and allocate storage j := 0; + fragOff := 0; highI := high(scanlines); psl := @scanlines[highI]; - //'fragments' is a pointer and not a dynamic array because - //dynamic arrays are zero initialized (hence slower than GetMem). + // 'fragments' is a pointer and not a dynamic array because + // dynamic arrays are zero initialized (hence slower than GetMem). for i := highI downto 0 do begin - inc(j, psl.fragCnt); //nb: psl.fragCnt may be < 0 here! + inc(j, psl.fragCnt); // nb: psl.fragCnt may be < 0 here! if j > 0 then - GetMem(psl.fragments, j * SizeOf(TFragment)); + begin + psl.fragOffset := fragOff; + inc(fragOff, j * 4); // 4 doubles are needed for each fragment + end else + psl.fragOffset := -1; {$IFDEF MemCheck} psl.total := j; {$ENDIF} - psl.fragCnt := 0; //reset for later + psl.fragCnt := 0; // reset for later psl.minX := clipRight; psl.maxX := 0; psl.Y := i; dec(psl); end; + // allocate fragments as a single block of memory + GetMem(fragments, fragOff * sizeOf(Double)); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure SplitEdgeIntoFragments(const pt1, pt2: TPointD; - const scanlines: TArrayOfScanline; const clipRec: TRect); + const scanlines: TArrayOfScanline; fragments: PDouble; const clipRec: TRect); var x,y, dx,dy, absDx, dydx, dxdy: double; i, scanlineY, maxY, maxX: integer; psl: PScanLine; - pFrag: PFragment; + pFrag: PDouble; bot, top: TPointD; begin dy := pt1.Y - pt2.Y; @@ -719,27 +728,27 @@ procedure SplitEdgeIntoFragments(const pt1, pt2: TPointD; if dy > 0 then begin - //ASCENDING EDGE (+VE WINDING DIR) + // ASCENDING EDGE (+VE WINDING DIR) if dy < 0.0001 then Exit; //ignore near horizontals bot := pt1; top := pt2; - //exclude edges that are completely outside the top or bottom clip region + // exclude edges that are completely outside the top or bottom clip region if (top.Y >= maxY) or (bot.Y <= 0) then Exit; end else begin - //DESCENDING EDGE (-VE WINDING DIR) + // DESCENDING EDGE (-VE WINDING DIR) if dy > -0.0001 then Exit; //ignore near horizontals bot := pt2; top := pt1; - //exclude edges that are completely outside the top or bottom clip region + // exclude edges that are completely outside the top or bottom clip region if (top.Y >= maxY) or (bot.Y <= 0) then Exit; end; if absDx < 0.000001 then begin - //VERTICAL EDGE + // VERTICAL EDGE top.X := bot.X; //this circumvents v. rare rounding issues. - //exclude vertical edges that are outside the right clip region - //but still update maxX for each scanline the edge passes + // exclude vertical edges that are outside the right clip region + // but still update maxX for each scanline the edge passes if bot.X > maxX then begin for i := Min(maxY, Round(bot.Y)) downto Max(0, Round(top.Y)) do @@ -755,7 +764,7 @@ procedure SplitEdgeIntoFragments(const pt1, pt2: TPointD; dydx := dy/absDx; end; - //TRIM EDGES THAT CROSS CLIPPING BOUNDARIES (EXCEPT THE LEFT BOUNDARY) + // TRIM EDGES THAT CROSS CLIPPING BOUNDARIES (EXCEPT THE LEFT BOUNDARY) if bot.X >= maxX then begin if top.X >= maxX then @@ -764,7 +773,7 @@ procedure SplitEdgeIntoFragments(const pt1, pt2: TPointD; scanlines[i].maxX := maxX; Exit; end; - //here the edge must be oriented bottom-right to top-left + // here the edge must be oriented bottom-right to top-left y := bot.Y - (bot.X - maxX) * Abs(dydx); for i := Min(maxY, Round(bot.Y)) downto Max(0, Round(y)) do scanlines[i].maxX := maxX; @@ -774,7 +783,7 @@ procedure SplitEdgeIntoFragments(const pt1, pt2: TPointD; end else if top.X > maxX then begin - //here the edge must be oriented bottom-left to top-right + // here the edge must be oriented bottom-left to top-right y := top.Y + (top.X - maxX) * Abs(dydx); for i := Min(maxY, Round(y)) downto Max(0, Round(top.Y)) do scanlines[i].maxX := maxX; @@ -795,67 +804,70 @@ procedure SplitEdgeIntoFragments(const pt1, pt2: TPointD; top.Y := 0; end; - //SPLIT THE EDGE INTO MULTIPLE SCANLINE FRAGMENTS + // SPLIT THE EDGE INTO MULTIPLE SCANLINE FRAGMENTS scanlineY := Round(bot.Y); if bot.Y = scanlineY then dec(scanlineY); - //at the lower-most extent of the edge 'split' the first fragment + // at the lower-most extent of the edge 'split' the first fragment if scanlineY < 0 then Exit; psl := @scanlines[scanlineY]; - if not assigned(psl.fragments) then Exit; //a very rare event + if psl.fragOffset < 0 then Exit; //a very rare event {$IFDEF MemCheck} if psl.fragCnt = psl.total then raise Exception.Create(sMemCheckError); {$ENDIF} - pFrag := @psl.fragments[psl.fragCnt]; + pFrag := fragments; + inc(pFrag, psl.fragOffset + psl.fragCnt * 4); inc(psl.fragCnt); - pFrag.botX := bot.X; + pFrag^ := bot.X; inc(pFrag); if scanlineY <= top.Y then begin - //the whole edge is within 1 scanline - pFrag.topX := top.X; - pFrag.dy := bot.Y - top.Y; - pFrag.dydx := dydx; + // the whole edge is within 1 scanline + pFrag^ := top.X; inc(pFrag); + pFrag^ := bot.Y - top.Y; inc(pFrag); + pFrag^ := dydx; Exit; end; x := bot.X + (bot.Y - scanlineY) * dxdy; - pFrag.topX := x; - pFrag.dy := bot.Y - scanlineY; - pFrag.dydx := dydx; - //'split' subsequent fragments until the top fragment + pFrag^ := x; inc(pFrag); + pFrag^ := bot.Y - scanlineY; inc(pFrag); + pFrag^ := dydx; + // 'split' subsequent fragments until the top fragment dec(psl); while psl.Y > top.Y do begin {$IFDEF MemCheck} if psl.fragCnt = psl.total then raise Exception.Create(sMemCheckError); {$ENDIF} - pFrag := @psl.fragments[psl.fragCnt]; + pFrag := fragments; + inc(pFrag, psl.fragOffset + psl.fragCnt * 4); inc(psl.fragCnt); - pFrag.botX := x; + pFrag^ := x; inc(pFrag); x := x + dxdy; - pFrag.topX := x; - pFrag.dy := 1; - pFrag.dydx := dydx; + pFrag^ := x; inc(pFrag); + pFrag^ := 1; inc(pFrag); + pFrag^ := dydx; dec(psl); end; - //and finally the top fragment + // and finally the top fragment {$IFDEF MemCheck} if psl.fragCnt = psl.total then raise Exception.Create(sMemCheckError); {$ENDIF} - pFrag := @psl.fragments[psl.fragCnt]; + pFrag := fragments; + inc(pFrag, psl.fragOffset + psl.fragCnt * 4); inc(psl.fragCnt); - pFrag.botX := x; - pFrag.topX := top.X; - pFrag.dy := psl.Y + 1 - top.Y; - pFrag.dydx := dydx; + pFrag^ := x; inc(pFrag); + pFrag^ := top.X; inc(pFrag); + pFrag^ := psl.Y + 1 - top.Y; inc(pFrag); + pFrag^ := dydx; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure InitializeScanlines(var polygons: TPathsD; - const scanlines: TArrayOfScanline; const clipRec: TRect); + const scanlines: TArrayOfScanline; fragments: PDouble; const clipRec: TRect); var i,j, highJ: integer; pt1, pt2: PPointD; @@ -868,54 +880,60 @@ procedure InitializeScanlines(var polygons: TPathsD; pt2 := @polygons[i][0]; for j := 0 to highJ do begin - SplitEdgeIntoFragments(pt1^, pt2^, scanlines, clipRec); + SplitEdgeIntoFragments(pt1^, pt2^, scanlines, fragments, clipRec); pt1 := pt2; inc(pt2); end; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure ProcessScanlineFragments(var scanline: TScanLine; - var buffer: TArrayOfDouble); + fragments: PDouble; var buffer: TArrayOfDouble); var i,j, leftXi,rightXi: integer; fracX, yy, q, windDir: double; - pd: PDouble; - frag: PFragment; + left, right, dy, dydx: double; + pd, frag: PDouble; begin - frag := @scanline.fragments[0]; + frag := fragments; + inc(frag, scanline.fragOffset); for i := 1 to scanline.fragCnt do begin - if frag.botX > frag.topX then + left := frag^; inc(frag); //botX + right := frag^; inc(frag); //topX + dy := frag^; inc(frag); + dydx := frag^; inc(frag); + + // converting botX & topX to left & right simplifies code + if {botX > topX} left > right then begin - //just swapping botX and topX simplifies code - q := frag.botX; - frag.botX := frag.topX; - frag.topX := q; + q := left; + left := right; + right := q; end; - leftXi := Max(0, Round(frag.botX)); - rightXi := Max(0, Round(frag.topX)); + leftXi := Max(0, Round(left)); + rightXi := Max(0, Round(right)); if (leftXi = rightXi) then begin - if frag.dydx < 0 then windDir := -1.0 else windDir := 1.0; - //the fragment is only one pixel wide + if dydx < 0 then windDir := -1.0 else windDir := 1.0; + // the fragment is only one pixel wide if leftXi < scanline.minX then scanline.minX := leftXi; if rightXi > scanline.maxX then scanline.maxX := rightXi; pd := @buffer[leftXi]; - if (frag.botX <= 0) then + if (left <= 0) then begin - pd^ := pd^ + frag.dy * windDir; + pd^ := pd^ + dy * windDir; end else begin - q := (frag.botX + frag.topX) * 0.5 - leftXi; - pd^ := pd^ + (1-q) * frag.dy * windDir; + q := (left + right) * 0.5 - leftXi; + pd^ := pd^ + (1-q) * dy * windDir; inc(pd); - pd^ := pd^ + q * frag.dy * windDir; + pd^ := pd^ + q * dy * windDir; end; end else begin @@ -924,32 +942,31 @@ procedure ProcessScanlineFragments(var scanline: TScanLine; if rightXi > scanline.maxX then scanline.maxX := rightXi; pd := @buffer[leftXi]; - //left pixel - fracX := leftXi + 1 - frag.botX; - yy := frag.dydx * fracX; + // left pixel + fracX := leftXi + 1 - left; + yy := dydx * fracX; q := fracX * yy * 0.5; pd^ := pd^ + q; q := yy - q; inc(pd); - //middle pixels + // middle pixels for j := leftXi +1 to rightXi -1 do begin - pd^ := pd^ + q + frag.dydx * 0.5; - q := frag.dydx * 0.5; + pd^ := pd^ + q + dydx * 0.5; + q := dydx * 0.5; inc(pd); end; - //right pixel - fracX := frag.topX - rightXi; - yy := fracX * frag.dydx; + // right pixel + fracX := right - rightXi; + yy := fracX * dydx; pd^ := pd^ + q + (1 - fracX * 0.5) * yy; inc(pd); - //overflow + // overflow pd^ := pd^ + fracX * 0.5 * yy; end; - inc(frag); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ {$IFNDEF TROUNDINGMODE} type @@ -966,48 +983,53 @@ procedure Rasterize(const paths: TPathsD; const clipRec: TRect; windingAccum: TArrayOfDouble; byteBuffer: TArrayOfByte; scanlines: TArrayOfScanline; + fragments: PDouble; scanline: PScanline; savedRoundMode: TRoundingMode; begin - //See also https://nothings.org/gamedev/rasterize/ + // See also https://nothings.org/gamedev/rasterize/ if not assigned(renderer) then Exit; Types.IntersectRect(clipRec2, clipRec, GetBounds(paths)); if IsEmptyRect(clipRec2) then Exit; paths2 := OffsetPath(paths, -clipRec2.Left, -clipRec2.Top); - //Delphi's Round() function is *much* faster than its Trunc function, and - //it's even a little faster than the __Trunc function above (except when - //the FastMM4 memory manager is enabled.) + // Delphi's Round() function is *much* faster than Trunc(), + // and even a little faster than __Trunc() above (except + // when the FastMM4 memory manager is enabled.) savedRoundMode := SetRoundMode(rmDown); + fragments := nil; RectWidthHeight(clipRec2, maxW, maxH); SetLength(scanlines, maxH +1); SetLength(windingAccum, maxW +2); - AllocateScanlines(paths2, scanlines, maxH, maxW-1); - InitializeScanlines(paths2, scanlines, clipRec2); + AllocateScanlines(paths2, scanlines, fragments, maxH, maxW-1); + InitializeScanlines(paths2, scanlines, fragments, clipRec2); SetLength(byteBuffer, maxW); - if byteBuffer = nil then Exit; + if byteBuffer = nil then + begin + FreeMem(fragments); + Exit; + end; scanline := @scanlines[0]; for i := 0 to high(scanlines) do begin if scanline.fragCnt = 0 then begin - FreeMem(scanline.fragments); inc(scanline); Continue; end; - //process each scanline to fill the winding count accumulation buffer - ProcessScanlineFragments(scanline^, windingAccum); - //it's faster to process only the modified sub-array of windingAccum + // process each scanline to fill the winding count accumulation buffer + ProcessScanlineFragments(scanline^, fragments, windingAccum); + // it's faster to process only the modified sub-array of windingAccum xli := scanline.minX; xri := Min(maxW -1, scanline.maxX +1); FillChar(byteBuffer[xli], xri - xli +1, 0); - //a 25% weighting has been added to the alpha channel to minimize any - //background bleed-through where polygons join with a common edge. + // a 25% weighting has been added to the alpha channel to minimize any + // background bleed-through where polygons join with a common edge. accum := 0; //winding count accumulator for j := xli to xri do @@ -1048,17 +1070,17 @@ procedure Rasterize(const paths: TPathsD; const clipRec: TRect; renderer.RenderProc(clipRec2.Left + xli, clipRec2.Left + xri, clipRec2.Top + i, @byteBuffer[xli]); - //cleanup and deallocate memory + // cleanup and deallocate memory FillChar(windingAccum[xli], (xri - xli +1) * sizeOf(Double), 0); - FreeMem(scanline.fragments); inc(scanline); end; + FreeMem(fragments); SetRoundMode(savedRoundMode); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TAbstractRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TCustomRenderer.Initialize(imgBase: Pointer; imgWidth, imgHeight, pixelSize: integer): Boolean; @@ -1072,13 +1094,13 @@ function TCustomRenderer.Initialize(imgBase: Pointer; fCurrY := 0; result := true; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TCustomRenderer.NotifyChange; begin if assigned(fChangeProc) then fChangeProc; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ type THackedImage32 = class(TImage32); //exposes protected Changed method. @@ -1088,7 +1110,7 @@ function TCustomRenderer.Initialize(targetImage: TImage32): Boolean; with targetImage do result := Initialize(PixelBase, Width, Height, SizeOf(TColor32)); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TCustomRenderer.GetDstPixel(x, y: integer): Pointer; begin @@ -1102,29 +1124,29 @@ function TCustomRenderer.GetDstPixel(x, y: integer): Pointer; inc(PByte(Result), x * fPixelSize); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TColorRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ constructor TColorRenderer.Create(color: TColor32 = clNone32); begin if color <> clNone32 then SetColor(color); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TColorRenderer.Initialize(targetImage: TImage32): Boolean; begin - //there's no point rendering if the color is fully transparent + // there's no point rendering if the color is fully transparent result := (fAlpha > 0) and inherited Initialize(targetImage); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TColorRenderer.SetColor(value: TColor32); begin fColor := value and $FFFFFF; fAlpha := GetAlpha(value); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TColorRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); var @@ -1134,32 +1156,32 @@ procedure TColorRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); dst := GetDstPixel(x1,y); for i := x1 to x2 do begin - //BlendToAlpha is marginally slower than BlendToOpaque but it's used - //here because it's universally applicable. - //Ord() is used here because very old compilers define PByte as a PChar + // BlendToAlpha is marginally slower than BlendToOpaque but it's used + // here because it's universally applicable. + // Ord() is used here because very old compilers define PByte as a PChar if Ord(alpha^) > 1 then dst^ := BlendToAlpha(dst^, ((Ord(alpha^) * fAlpha) shr 8) shl 24 or fColor); inc(dst); inc(alpha); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TAliasedColorRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ constructor TAliasedColorRenderer.Create(color: TColor32 = clNone32); begin fColor := color; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TAliasedColorRenderer.Initialize(targetImage: TImage32): Boolean; begin - //there's no point rendering if the color is fully transparent + // there's no point rendering if the color is fully transparent result := (GetAlpha(fColor) > 0) and inherited Initialize(targetImage); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TAliasedColorRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); var @@ -1174,9 +1196,9 @@ procedure TAliasedColorRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TBrushImageRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ constructor TImageRenderer.Create(tileFillStyle: TTileFillStyle; brushImage: TImage32); @@ -1184,14 +1206,14 @@ constructor TImageRenderer.Create(tileFillStyle: TTileFillStyle; fImage := TImage32.Create(brushImage); SetTileFillStyle(tileFillStyle); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ destructor TImageRenderer.Destroy; begin fImage.Free; inherited; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TImageRenderer.SetTileFillStyle(value: TTileFillStyle); begin @@ -1203,7 +1225,7 @@ procedure TImageRenderer.SetTileFillStyle(value: TTileFillStyle); end; fMirrorY := value in [tfsMirrorVert, tfsRotate180]; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TImageRenderer.Initialize(targetImage: TImage32): Boolean; begin @@ -1212,7 +1234,7 @@ function TImageRenderer.Initialize(targetImage: TImage32): Boolean; fLastYY := 0; fBrushPixel := PARGB(fImage.PixelBase); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TImageRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); var @@ -1233,7 +1255,7 @@ procedure TImageRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); pBrush := GetPixel(fBrushPixel, fBoundsProc(i, fImage.Width)); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TImageRenderer.GetFirstBrushPixel(x, y: integer): PARGB; begin @@ -1249,22 +1271,22 @@ function TImageRenderer.GetFirstBrushPixel(x, y: integer): PARGB; result := GetPixel(fBrushPixel, x); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TGradientRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ constructor TCustomGradientRenderer.Create; begin fBoundsProc := ClampQ; //default proc end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TCustomGradientRenderer.Clear; begin fGradientColors := nil; fColors := nil; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TCustomGradientRenderer.SetGradientFillStyle(value: TGradientFillStyle); begin @@ -1274,20 +1296,20 @@ procedure TCustomGradientRenderer.SetGradientFillStyle(value: TGradientFillStyle else fBoundsProc := RepeatQ; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TCustomGradientRenderer.SetParameters(startColor, endColor: TColor32; gradFillStyle: TGradientFillStyle = gfsClamp); begin SetGradientFillStyle(gradFillStyle); - //reset gradient colors if perviously set + // reset gradient colors if perviously set SetLength(fGradientColors, 2); fGradientColors[0].offset := 0; fGradientColors[0].color := startColor; fGradientColors[1].offset := 1; fGradientColors[1].color := endColor; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TCustomGradientRenderer.InsertColorStop(offsetFrac: double; color: TColor32); var @@ -1295,7 +1317,7 @@ procedure TCustomGradientRenderer.InsertColorStop(offsetFrac: double; color: TCo gradColor: TGradientColor; begin len := Length(fGradientColors); - //colorstops can only be inserted after calling SetParameters + // colorstops can only be inserted after calling SetParameters if len = 0 then Exit; if offsetFrac < 0 then offsetFrac := 0 @@ -1323,9 +1345,9 @@ procedure TCustomGradientRenderer.InsertColorStop(offsetFrac: double; color: TCo fGradientColors[i] := gradColor; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TLinearGradientRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TLinearGradientRenderer.SetParameters(const startPt, endPt: TPointD; startColor, endColor: TColor32; gradFillStyle: TGradientFillStyle); @@ -1334,7 +1356,7 @@ procedure TLinearGradientRenderer.SetParameters(const startPt, endPt: TPointD; fStartPt := startPt; fEndPt := endPt; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TLinearGradientRenderer.Initialize(targetImage: TImage32): Boolean; var @@ -1346,7 +1368,7 @@ function TLinearGradientRenderer.Initialize(targetImage: TImage32): Boolean; if abs(fEndPt.Y - fStartPt.Y) > abs(fEndPt.X - fStartPt.X) then begin - //gradient > 45 degrees + // gradient > 45 degrees if (fEndPt.Y < fStartPt.Y) then begin fGradientColors := ReverseColors(fGradientColors); @@ -1359,10 +1381,10 @@ function TLinearGradientRenderer.Initialize(targetImage: TImage32): Boolean; fColorsCnt := Ceil(dy + dxdy * (fEndPt.X - fStartPt.X)); fColors := MakeColorGradient(fGradientColors, fColorsCnt); - //get a list of perpendicular offsets for each + // get a list of perpendicular offsets for each SetLength(fPerpendicOffsets, ImgWidth); - //from an imaginary line that's through fStartPt and perpendicular to - //the gradient line, get a list of Y offsets for each X in image width + // from an imaginary line that's through fStartPt and perpendicular to + // the gradient line, get a list of Y offsets for each X in image width for i := 0 to ImgWidth -1 do fPerpendicOffsets[i] := Round(dxdy * (fStartPt.X - i) + fStartPt.Y); end @@ -1386,13 +1408,13 @@ function TLinearGradientRenderer.Initialize(targetImage: TImage32): Boolean; fColorsCnt := Ceil(dx + dydx * (fEndPt.Y - fStartPt.Y)); fColors := MakeColorGradient(fGradientColors, fColorsCnt); SetLength(fPerpendicOffsets, ImgHeight); - //from an imaginary line that's through fStartPt and perpendicular to - //the gradient line, get a list of X offsets for each Y in image height + // from an imaginary line that's through fStartPt and perpendicular to + // the gradient line, get a list of X offsets for each Y in image height for i := 0 to ImgHeight -1 do fPerpendicOffsets[i] := Round(dydx * (fStartPt.Y - i) + fStartPt.X); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TLinearGradientRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); var @@ -1405,12 +1427,12 @@ procedure TLinearGradientRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); begin if fIsVert then begin - //when fIsVert = true, fPerpendicOffsets is an array of Y for each X + // when fIsVert = true, fPerpendicOffsets is an array of Y for each X off := fPerpendicOffsets[i]; color.Color := fColors[fBoundsProc(y - off, fColorsCnt)]; end else begin - //when fIsVert = false, fPerpendicOffsets is an array of X for each Y + // when fIsVert = false, fPerpendicOffsets is an array of X for each Y off := fPerpendicOffsets[y]; color.Color := fColors[fBoundsProc(i - off, fColorsCnt)]; end; @@ -1420,9 +1442,9 @@ procedure TLinearGradientRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TRadialGradientRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TRadialGradientRenderer.Initialize(targetImage: TImage32): Boolean; begin @@ -1430,7 +1452,7 @@ function TRadialGradientRenderer.Initialize(targetImage: TImage32): Boolean; if result then fColors := MakeColorGradient(fGradientColors, fColorsCnt); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TRadialGradientRenderer.SetParameters(const focalRect: TRect; innerColor, outerColor: TColor32; @@ -1460,7 +1482,7 @@ procedure TRadialGradientRenderer.SetParameters(const focalRect: TRect; fColorsCnt := Ceil(radY) +1; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TRadialGradientRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); var @@ -1480,9 +1502,9 @@ procedure TRadialGradientRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TSvgRadialGradientRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TSvgRadialGradientRenderer.Initialize(targetImage: TImage32): Boolean; begin @@ -1490,7 +1512,7 @@ function TSvgRadialGradientRenderer.Initialize(targetImage: TImage32): Boolean; if result then fColors := MakeColorGradient(fGradientColors, fColorsCnt); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TSvgRadialGradientRenderer.SetParameters(const ellipseRect: TRect; const focus: TPoint; innerColor, outerColor: TColor32; @@ -1519,7 +1541,7 @@ procedure TSvgRadialGradientRenderer.SetParameters(const ellipseRect: TRect; fAA := fA * fA; fBB := fB * fB; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TSvgRadialGradientRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); var @@ -1530,16 +1552,16 @@ procedure TSvgRadialGradientRenderer.RenderProc(x1, x2, y: integer; alpha: PByte pDst: PColor32; pt, ellipsePt: TPointD; begin - //get the left-most pixel to render + // get the left-most pixel to render pDst := GetDstPixel(x1,y); pt.X := x1 - fCenterPt.X; pt.Y := y - fCenterPt.Y; for i := x1 to x2 do begin - //equation of ellipse = (x*x)/aa + (y*y)/bb = 1 - //equation of line = y = mx + c; + // equation of ellipse = (x*x)/aa + (y*y)/bb = 1 + // equation of line = y = mx + c; if (pt.X = fFocusPt.X) then //vertical line begin - //let x = pt.X, then y*y = b*b(1 - Sqr(pt.X)/aa) + // let x = pt.X, then y*y = b*b(1 - Sqr(pt.X)/aa) q := Sqrt(fBB*(1 - Sqr(pt.X)/fAA)); ellipsePt.X := pt.X; if pt.Y >= fFocusPt.Y then @@ -1552,16 +1574,16 @@ procedure TSvgRadialGradientRenderer.RenderProc(x1, x2, y: integer; alpha: PByte q := dist/ dist2; end else begin - //using simultaneous equations and substitution - //given y = mx + c + // using simultaneous equations and substitution + // given y = mx + c m := (pt.Y - fFocusPt.Y)/(pt.X - fFocusPt.X); c := pt.Y - m * pt.X; - //given (x*x)/aa + (y*y)/bb = 1 - //(x*x)/aa*bb + (y*y) = bb - //bb/aa *(x*x) + Sqr(m*x +c) = bb - //bb/aa *(x*x) + (m*m)*(x*x) + 2*m*x*c +c*c = b*b - //(bb/aa +(m*m)) *(x*x) + 2*m*c*(x) + (c*c) - bb = 0 - //solving quadratic equation + // given (x*x)/aa + (y*y)/bb = 1 + // (x*x)/aa*bb + (y*y) = bb + // bb/aa *(x*x) + Sqr(m*x +c) = bb + // bb/aa *(x*x) + (m*m)*(x*x) + 2*m*x*c +c*c = b*b + // (bb/aa +(m*m)) *(x*x) + 2*m*c*(x) + (c*c) - bb = 0 + // solving quadratic equation qa := (fBB/fAA +(m*m)); qb := 2*m*c; qc := (c*c) - fBB; @@ -1588,9 +1610,9 @@ procedure TSvgRadialGradientRenderer.RenderProc(x1, x2, y: integer; alpha: PByte end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TEraseRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TEraseRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); var @@ -1609,9 +1631,9 @@ procedure TEraseRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // TInverseRenderer -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TInverseRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); var @@ -1629,7 +1651,7 @@ procedure TInverseRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TBarycentricRenderer.SetParameters(const a, b, c: TPointD; c1, c2, c3: TColor32); @@ -1649,7 +1671,7 @@ procedure TBarycentricRenderer.SetParameters(const a, b, c: TPointD; d11 := (v1.X * v1.X + v1.Y * v1.Y); invDenom := 1/(d00 * d11 - d01 * d01); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ function TBarycentricRenderer.GetColor(const pt: TPointD): TColor32; var @@ -1672,7 +1694,7 @@ function TBarycentricRenderer.GetColor(const pt: TPointD): TColor32; Res.G := ClampByte(c1.G * u + c2.G * v + c3.G * w); Res.B := ClampByte(c1.B * u + c2.B * v + c3.B * w); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure TBarycentricRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); var @@ -1691,9 +1713,9 @@ procedure TBarycentricRenderer.RenderProc(x1, x2, y: integer; alpha: PByte); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // Draw functions -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawPoint(img: TImage32; const pt: TPointD; radius: double; color: TColor32); @@ -1705,7 +1727,7 @@ procedure DrawPoint(img: TImage32; path := Ellipse(RectD(pt.X-radius, pt.Y-radius, pt.X+radius, pt.Y+radius)); DrawPolygon(img, path, frEvenOdd, color); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawPoint(img: TImage32; const pt: TPointD; radius: double; renderer: TCustomRenderer); @@ -1715,7 +1737,7 @@ procedure DrawPoint(img: TImage32; const pt: TPointD; path := Ellipse(RectD(pt.X -radius, pt.Y -radius, pt.X +radius, pt.Y +radius)); DrawPolygon(img, path, frEvenOdd, renderer); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawPoint(img: TImage32; const points: TPathD; radius: double; color: TColor32); @@ -1725,7 +1747,7 @@ procedure DrawPoint(img: TImage32; const points: TPathD; for i := 0 to high(points) do DrawPoint(img, points[i], radius, color); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawPoint(img: TImage32; const paths: TPathsD; radius: double; color: TColor32); @@ -1735,7 +1757,7 @@ procedure DrawPoint(img: TImage32; const paths: TPathsD; for i := 0 to high(paths) do DrawPoint(img, paths[i], radius, color); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawLine(img: TImage32; const pt1, pt2: TPointD; lineWidth: double; color: TColor32); @@ -1748,7 +1770,7 @@ procedure DrawLine(img: TImage32; lines[0][1] := pt2; DrawLine(img, lines, lineWidth, color, esRound); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawLine(img: TImage32; const line: TPathD; lineWidth: double; color: TColor32; endStyle: TEndStyle; joinStyle: TJoinStyle; @@ -1760,7 +1782,7 @@ procedure DrawLine(img: TImage32; const line: TPathD; lineWidth: double; lines[0] := line; DrawLine(img, lines, lineWidth, color, endStyle, joinStyle, miterLimit); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawLine(img: TImage32; const line: TPathD; lineWidth: double; renderer: TCustomRenderer; endStyle: TEndStyle; joinStyle: TJoinStyle; @@ -1772,7 +1794,7 @@ procedure DrawLine(img: TImage32; const line: TPathD; lineWidth: double; lines[0] := line; DrawLine(img, lines, lineWidth, renderer, endStyle, joinStyle, miterLimit); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawInvertedLine(img: TImage32; const line: TPathD; lineWidth: double; endStyle: TEndStyle; joinStyle: TJoinStyle = jsAuto); @@ -1783,7 +1805,7 @@ procedure DrawInvertedLine(img: TImage32; const line: TPathD; lines[0] := line; DrawInvertedLine(img, lines, lineWidth, endStyle, joinStyle); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawLine(img: TImage32; const lines: TPathsD; lineWidth: double; color: TColor32; @@ -1809,7 +1831,7 @@ procedure DrawLine(img: TImage32; const lines: TPathsD; cr.free; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawLine(img: TImage32; const lines: TPathsD; lineWidth: double; renderer: TCustomRenderer; @@ -1827,7 +1849,7 @@ procedure DrawLine(img: TImage32; const lines: TPathsD; renderer.NotifyChange; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawInvertedLine(img: TImage32; const lines: TPathsD; lineWidth: double; @@ -1850,7 +1872,7 @@ procedure DrawInvertedLine(img: TImage32; ir.free; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawDashedLine(img: TImage32; const line: TPathD; dashPattern: TArrayOfInteger; patternOffset: PDouble; lineWidth: double; @@ -1888,7 +1910,7 @@ procedure DrawDashedLine(img: TImage32; const line: TPathD; cr.free; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawDashedLine(img: TImage32; const lines: TPathsD; dashPattern: TArrayOfInteger; patternOffset: PDouble; lineWidth: double; @@ -1901,7 +1923,7 @@ procedure DrawDashedLine(img: TImage32; const lines: TPathsD; DrawDashedLine(img, lines[i], dashPattern, patternOffset, lineWidth, color, endStyle, joinStyle); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawDashedLine(img: TImage32; const line: TPathD; dashPattern: TArrayOfInteger; patternOffset: PDouble; lineWidth: double; @@ -1925,7 +1947,7 @@ procedure DrawDashedLine(img: TImage32; const line: TPathD; renderer.NotifyChange; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawDashedLine(img: TImage32; const lines: TPathsD; dashPattern: TArrayOfInteger; patternOffset: PDouble; lineWidth: double; @@ -1938,7 +1960,7 @@ procedure DrawDashedLine(img: TImage32; const lines: TPathsD; DrawDashedLine(img, lines[i], dashPattern, patternOffset, lineWidth, renderer, endStyle, joinStyle); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawInvertedDashedLine(img: TImage32; const line: TPathD; dashPattern: TArrayOfInteger; @@ -1969,7 +1991,7 @@ procedure DrawInvertedDashedLine(img: TImage32; renderer.Free; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawInvertedDashedLine(img: TImage32; const lines: TPathsD; dashPattern: TArrayOfInteger; @@ -1983,7 +2005,7 @@ procedure DrawInvertedDashedLine(img: TImage32; DrawInvertedDashedLine(img, lines[i], dashPattern, patternOffset, lineWidth, endStyle, joinStyle); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawPolygon(img: TImage32; const polygon: TPathD; fillRule: TFillRule; color: TColor32); @@ -1995,7 +2017,7 @@ procedure DrawPolygon(img: TImage32; const polygon: TPathD; polygons[0] := polygon; DrawPolygon(img, polygons, fillRule, color); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawPolygon(img: TImage32; const polygon: TPathD; fillRule: TFillRule; renderer: TCustomRenderer); @@ -2011,7 +2033,7 @@ procedure DrawPolygon(img: TImage32; const polygon: TPathD; renderer.NotifyChange; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawPolygon(img: TImage32; const polygons: TPathsD; fillRule: TFillRule; color: TColor32); @@ -2032,7 +2054,7 @@ procedure DrawPolygon(img: TImage32; const polygons: TPathsD; cr.free; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawPolygon(img: TImage32; const polygons: TPathsD; fillRule: TFillRule; renderer: TCustomRenderer); @@ -2044,7 +2066,7 @@ procedure DrawPolygon(img: TImage32; const polygons: TPathsD; renderer.NotifyChange; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawPolygon_ClearType(img: TImage32; const polygons: TPathsD; fillRule: TFillRule; color: TColor32; backColor: TColor32); @@ -2076,7 +2098,7 @@ procedure DrawPolygon_ClearType(img: TImage32; const polygons: TPathsD; tmpImg.Free; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure ErasePolygon(img: TImage32; const polygon: TPathD; fillRule: TFillRule); @@ -2088,7 +2110,7 @@ procedure ErasePolygon(img: TImage32; const polygon: TPathD; polygons[0] := polygon; ErasePolygon(img, polygons, fillRule); end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure ErasePolygon(img: TImage32; const polygons: TPathsD; fillRule: TFillRule); @@ -2106,7 +2128,7 @@ procedure ErasePolygon(img: TImage32; const polygons: TPathsD; er.Free; end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawBoolMask(img: TImage32; const mask: TArrayOfByte; color: TColor32); var @@ -2130,7 +2152,7 @@ procedure DrawBoolMask(img: TImage32; const mask: TArrayOfByte; color: TColor32) inc(pc); inc(pb); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ procedure DrawAlphaMask(img: TImage32; const mask: TArrayOfByte; color: TColor32); var @@ -2157,6 +2179,6 @@ procedure DrawAlphaMask(img: TImage32; const mask: TArrayOfByte; color: TColor32 inc(pc); inc(pb); end; end; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ end. diff --git a/Image32/source/Img32.Extra.pas b/Image32/source/Img32.Extra.pas index 6768c33..2818fb1 100644 --- a/Image32/source/Img32.Extra.pas +++ b/Image32/source/Img32.Extra.pas @@ -1211,7 +1211,6 @@ TFloodFillRec = record next : PFloodFillRec; end; TFloodFillStack = class - private first : PFloodFillRec; maxY : integer; constructor Create(maxY: integer); @@ -1536,7 +1535,6 @@ procedure Emboss(img: TImage32; radius: Integer; type TPt2Container = class; TPt2 = class - private pt : TPointD; owner : TPt2Container; isStart : Boolean; @@ -1552,7 +1550,6 @@ TPt2 = class property IsAscending: Boolean read isStart; end; TPt2Container = class - private prevRight: integer; leftMostPt, rightMost: TPt2; solution: TPathsD; diff --git a/Image32/source/Img32.FMX.pas b/Image32/source/Img32.FMX.pas index 80c96b3..27388c7 100644 --- a/Image32/source/Img32.FMX.pas +++ b/Image32/source/Img32.FMX.pas @@ -2,10 +2,10 @@ (******************************************************************************* * Author : Angus Johnson * -* Version : 4.3 * -* Date : 27 September 2022 * +* Version : 4.4 * +* Date : 30 January 2023 * * Website : http://www.angusj.com * -* Copyright : Angus Johnson 2019-2022 * +* Copyright : Angus Johnson 2019-2023 * * Purpose : Image file format support for TImage32 and FMX * * License : http://www.boost.org/LICENSE_1_0.txt * *******************************************************************************) @@ -27,7 +27,8 @@ TImageFormat_FMX = class(TImageFormat) fPixelFormat: FMX.Types.TPixelFormat; public class function IsValidImageStream(stream: TStream): Boolean; override; - function LoadFromStream(stream: TStream; img32: TImage32): Boolean; override; + function LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; override; function SaveToFile(const filename: string; img32: TImage32): Boolean; override; procedure SaveToStream(stream: TStream; img32: TImage32); override; class function CopyToClipboard(img32: TImage32): Boolean; override; @@ -74,7 +75,8 @@ class function TImageFormat_FMX.IsValidImageStream(stream: TStream): Boolean; end; //------------------------------------------------------------------------------ -function TImageFormat_FMX.LoadFromStream(stream: TStream; img32: TImage32): Boolean; +function TImageFormat_FMX.LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; var cm: TBitmapCodecManager; surf: TBitmapSurface; diff --git a/Image32/source/Img32.Fmt.BMP.pas b/Image32/source/Img32.Fmt.BMP.pas index c35a66e..012ec65 100644 --- a/Image32/source/Img32.Fmt.BMP.pas +++ b/Image32/source/Img32.Fmt.BMP.pas @@ -2,10 +2,10 @@ (******************************************************************************* * Author : Angus Johnson * -* Version : 3.0 * -* Date : 20 July 2021 * +* Version : 4.4 * +* Date : 30 January 2023 * * Website : http://www.angusj.com * -* Copyright : Angus Johnson 2019-2021 * +* Copyright : Angus Johnson 2019-2023 * * Purpose : BMP file format extension for TImage32 * * License : http://www.boost.org/LICENSE_1_0.txt * *******************************************************************************) @@ -30,7 +30,8 @@ TImageFormat_BMP = class(TImageFormat) fIncludeFileHeaderInSaveStream: Boolean; public class function IsValidImageStream(stream: TStream): Boolean; override; - function LoadFromStream(stream: TStream; img32: TImage32): Boolean; override; + function LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; override; function SaveToFile(const filename: string; img32: TImage32): Boolean; override; procedure SaveToStream(stream: TStream; img32: TImage32); override; {$IFDEF MSWINDOWS} @@ -424,7 +425,7 @@ class function TImageFormat_BMP.IsValidImageStream(stream: TStream): Boolean; //------------------------------------------------------------------------------ function TImageFormat_BMP.LoadFromStream(stream: TStream; - img32: TImage32): Boolean; + img32: TImage32; imgIndex: integer): Boolean; var palEntrySize: integer; bihStart: cardinal; diff --git a/Image32/source/Img32.Fmt.GIF.pas b/Image32/source/Img32.Fmt.GIF.pas index c841b1f..24ccff4 100644 --- a/Image32/source/Img32.Fmt.GIF.pas +++ b/Image32/source/Img32.Fmt.GIF.pas @@ -1,36 +1,50 @@ unit Img32.Fmt.GIF; (******************************************************************************* * Author : Angus Johnson * -* Version : 4.3 * -* Date : 27 September 2022 * +* Version : 4.4 * +* Date : 30 January 2023 * * Website : http://www.angusj.com * -* Copyright : Angus Johnson 2019-2022 * +* Copyright : Angus Johnson 2019-2023 * * Purpose : GIF file format extension for TImage32 * * License : http://www.boost.org/LICENSE_1_0.txt * *******************************************************************************) + interface {$I Img32.inc} {$IF COMPILERVERSION = 15} implementation {$ELSE} + uses SysUtils, Classes, Windows, Math, Img32, {$IFDEF USES_NAMESPACES} Vcl.Graphics, {$ELSE}Graphics, {$ENDIF} {$IFDEF DELPHI_GIF} GifImg {$ELSE} GifImage {$ENDIF}; + type + TImageFormat_GIF = class(TImageFormat) public class function IsValidImageStream(stream: TStream): Boolean; override; - function LoadFromStream(stream: TStream; img32: TImage32): Boolean; override; + function LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; override; procedure SaveToStream(stream: TStream; img32: TImage32); override; + class function GetImageCount(stream: TStream): integer; override; class function CopyToClipboard(img32: TImage32): Boolean; override; class function CanPasteFromClipboard: Boolean; override; class function PasteFromClipboard(img32: TImage32): Boolean; override; + + class function GetDelays(stream: TStream): TArrayOfInteger; end; + implementation + +uses + Img32.Extra; + //------------------------------------------------------------------------------ // Loading (reading) GIF images from file ... //------------------------------------------------------------------------------ + class function TImageFormat_GIF.IsValidImageStream(stream: TStream): Boolean; var savedPos: integer; @@ -44,59 +58,100 @@ class function TImageFormat_GIF.IsValidImageStream(stream: TStream): Boolean; result := flag = $38464947; end; //------------------------------------------------------------------------------ -function TImageFormat_GIF.LoadFromStream(stream: TStream; img32: TImage32): Boolean; + +function TImageFormat_GIF.LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; var gif: TGIFImage; - i, w,h: integer; - bmp, bmpT: TBitmap; - pcT, pc: PARGB; + i: integer; + pb: PByte; + pc: PARGB; + palentries : array[0..255] of TPaletteEntry; + img: TImage32; + rec: TRect; begin result := false; - bmp := TBitmap.Create; - bmpT := TBitmap.Create; + img := TImage32.Create; gif := TGIFImage.Create; try gif.LoadFromStream(stream); if gif.Empty then Exit; - w := gif.Width; h := gif.Height; - bmp.SetSize(w, h); - bmp.PixelFormat := pf32bit; - //get color pixels - gif.Images[0].Draw(bmp.Canvas, bmp.Canvas.ClipRect, false, false); - if gif.Transparent then + if (imgIndex < 0) or (imgIndex >= gif.Images.Count) then + imgIndex := 0; + + if (imgIndex = 0) or (img32.Width <> gif.Width) or + (img32.Height <> gif.Height) then + img32.SetSize(gif.Width, gif.Height); + + with gif.Images[imgIndex] do begin - bmpT.SetSize(w, h); - bmpT.PixelFormat := pf32bit; - //get transparent pixels - gif.Images[0].Draw(bmpT.Canvas, bmpT.Canvas.ClipRect, true, false); - //set the alpha in bmp for each pixel in bmpT that's not transparent - pcT := bmpT.ScanLine[h-1]; - pc := bmp.ScanLine[h-1]; - for I := 0 to w * h -1 do + if DataSize < (Width * Height) then Exit; + GetPaletteEntries(Palette, 0, 256, palentries); + FixPalette(@palentries[0], 256); + + if Transparent and Assigned(GraphicControlExtension) then + with GraphicControlExtension do + Cardinal(palentries[TransparentColorIndex]) := 0; + + img.SetSize(Width, Height); + rec := Rect(Left, Top, Left+ Width, Top +Height); + pb := Data; + pc := PARGB(img.PixelBase); + for i := 1 to Width * Height do begin - if pcT.A = 0 then pc.A := 255; - inc(pcT); inc(pc); + pc.Color := TColor32(palentries[pb^]); + inc(pb); inc(pc); end; end; - img32.BeginUpdate; - try - //copy bmp to img32 - img32.SetSize(w, h); - for I := 0 to h -1 do - Move(bmp.ScanLine[i]^, img32.PixelRow[i]^, w * 4); - finally - img32.EndUpdate; - end; - result := true; + if imgIndex = 0 then + img32.Assign(img) else + img32.Copy(img, img.Bounds, rec); + finally + gif.Free; + img.Free; + end; +end; +//------------------------------------------------------------------------------ + +class function TImageFormat_GIF.GetImageCount(stream: TStream): integer; +var + gif: TGIFImage; +begin + gif := TGIFImage.Create; + try + gif.LoadFromStream(stream); + Result := gif.Images.Count; + finally + gif.Free; + end; +end; +//------------------------------------------------------------------------------ + +type + THackedGIFFrame = class(TGIFFrame); + +class function TImageFormat_GIF.GetDelays(stream: TStream): TArrayOfInteger; +var + i, cnt: Integer; + gif: TGIFImage; +begin + gif := TGIFImage.Create; + try + gif.LoadFromStream(stream); + cnt := gif.Images.Count; + SetLength(result, cnt); + for i := 0 to cnt -1 do + if Assigned(THackedGIFFrame(gif.Images[i])) then + result[i] := THackedGIFFrame(gif.Images[i]).GCE.Delay; finally gif.Free; - bmp.Free; - bmpT.Free; end; end; + //------------------------------------------------------------------------------ // Saving (writing) gif images to file ... //------------------------------------------------------------------------------ + procedure TImageFormat_GIF.SaveToStream(stream: TStream; img32: TImage32); var gif: TGIFImage; @@ -121,25 +176,29 @@ procedure TImageFormat_GIF.SaveToStream(stream: TStream; img32: TImage32); end; end; //------------------------------------------------------------------------------ + class function TImageFormat_GIF.CopyToClipboard(img32: TImage32): Boolean; begin result := false; //not implemented end; + //------------------------------------------------------------------------------ class function TImageFormat_GIF.CanPasteFromClipboard: Boolean; begin result := false; end; //------------------------------------------------------------------------------ + class function TImageFormat_GIF.PasteFromClipboard(img32: TImage32): Boolean; begin result := false; //not implemented end; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ + initialization TImage32.RegisterImageFormatClass('GIF', TImageFormat_GIF, cpLow); - + {$IFEND} end. diff --git a/Image32/source/Img32.Fmt.JPG.pas b/Image32/source/Img32.Fmt.JPG.pas index 4fcb8ab..bc9d253 100644 --- a/Image32/source/Img32.Fmt.JPG.pas +++ b/Image32/source/Img32.Fmt.JPG.pas @@ -2,10 +2,10 @@ (******************************************************************************* * Author : Angus Johnson * -* Version : 4.3 * -* Date : 27 September 2022 * +* Version : 4.4 * +* Date : 30 January 2023 * * Website : http://www.angusj.com * -* Copyright : Angus Johnson 2019-2021 * +* Copyright : Angus Johnson 2019-2023 * * Purpose : JPG/JPEG file format extension for TImage32 * * License : http://www.boost.org/LICENSE_1_0.txt * *******************************************************************************) @@ -22,7 +22,8 @@ interface TImageFormat_JPG = class(TImageFormat) public class function IsValidImageStream(stream: TStream): Boolean; override; - function LoadFromStream(stream: TStream; img32: TImage32): Boolean; override; + function LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; override; procedure SaveToStream(stream: TStream; img32: TImage32); override; class function CopyToClipboard(img32: TImage32): Boolean; override; class function CanPasteFromClipboard: Boolean; override; @@ -58,7 +59,8 @@ class function TImageFormat_JPG.IsValidImageStream(stream: TStream): Boolean; end; //------------------------------------------------------------------------------ -function TImageFormat_JPG.LoadFromStream(stream: TStream; img32: TImage32): Boolean; +function TImageFormat_JPG.LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; var jpeg: TJpegImage; begin diff --git a/Image32/source/Img32.Fmt.PNG.pas b/Image32/source/Img32.Fmt.PNG.pas index 39e4478..13fc5e7 100644 --- a/Image32/source/Img32.Fmt.PNG.pas +++ b/Image32/source/Img32.Fmt.PNG.pas @@ -2,10 +2,10 @@ (******************************************************************************* * Author : Angus Johnson * -* Version : 4.3 * -* Date : 27 September 2022 * +* Version : 4.4 * +* Date : 30 January 2023 * * Website : http://www.angusj.com * -* Copyright : Angus Johnson 2019-2022 * +* Copyright : Angus Johnson 2019-2023 * * Purpose : PNG file format extension for TImage32 * * License : http://www.boost.org/LICENSE_1_0.txt * *******************************************************************************) @@ -23,7 +23,8 @@ interface TImageFormat_PNG = class(TImageFormat) public class function IsValidImageStream(stream: TStream): Boolean; override; - function LoadFromStream(stream: TStream; img32: TImage32): Boolean; override; + function LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; override; procedure SaveToStream(stream: TStream; img32: TImage32); override; class function CanCopyToClipboard: Boolean; override; class function CopyToClipboard(img32: TImage32): Boolean; override; @@ -58,7 +59,8 @@ class function TImageFormat_PNG.IsValidImageStream(stream: TStream): Boolean; //------------------------------------------------------------------------------ {$IFDEF FPC} -function TImageFormat_PNG.LoadFromStream(stream: TStream; img32: TImage32): Boolean; +function TImageFormat_PNG.LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; var png: TPortableNetworkGraphic; begin @@ -102,35 +104,62 @@ procedure TImageFormat_PNG.SaveToStream(stream: TStream; img32: TImage32); //------------------------------------------------------------------------------ {$ELSE} -function TImageFormat_PNG.LoadFromStream(stream: TStream; img32: TImage32): Boolean; +function TImageFormat_PNG.LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer): Boolean; var i,j : integer; png : TPngImage; dst : PARGB; srcAlpha : PByte; srcColor : PByte; + bytesPerRow: integer; + palentries : array[0..255] of TPaletteEntry; + usingPal : Boolean; begin img32.BeginUpdate; png := TPngImage.Create; try png.LoadFromStream(stream); img32.SetSize(png.Width, png.Height); + + bytesPerRow := PByte(png.Scanline[1]) - + PByte(png.Scanline[0]); + usingPal := (Abs(bytesPerRow) = png.Width) and (png.Palette <> 0); + + if usingPal then + begin + GetPaletteEntries(png.Palette, 0, 256, palentries); + FixPalette(@palentries[0], 256); + end; + for i := 0 to img32.Height -1 do begin dst := PARGB(img32.PixelRow[i]); srcColor := png.Scanline[i]; - if png.Transparent then + + if usingPal then + begin + for j := 0 to img32.Width -1 do + begin + dst.Color := TColor32(palentries[srcColor^]); + inc(srcColor); + inc(dst); + end; + end + else if png.Transparent then begin srcAlpha := PByte(png.AlphaScanline[i]); for j := 0 to img32.Width -1 do begin dst.A := srcAlpha^; inc(srcAlpha); + dst.B := srcColor^; inc(srcColor); dst.G := srcColor^; inc(srcColor); dst.R := srcColor^; inc(srcColor); inc(dst); end end else + begin for j := 0 to img32.Width -1 do begin dst.A := 255; @@ -139,6 +168,8 @@ function TImageFormat_PNG.LoadFromStream(stream: TStream; img32: TImage32): Bool dst.R := srcColor^; inc(srcColor); inc(dst); end; + end; + end; finally png.Free; diff --git a/Image32/source/Img32.Fmt.QOI.pas b/Image32/source/Img32.Fmt.QOI.pas index 671c969..81c9b72 100644 --- a/Image32/source/Img32.Fmt.QOI.pas +++ b/Image32/source/Img32.Fmt.QOI.pas @@ -1,10 +1,10 @@ unit Img32.Fmt.QOI; (******************************************************************************* * Author : Angus Johnson * -* Version : 4.3 * -* Date : 27 September 2022 * +* Version : 4.4 * +* Date : 30 January 2023 * * Website : http://www.angusj.com * -* Copyright : Angus Johnson 2019-2022 * +* Copyright : Angus Johnson 2019-2023 * * Purpose : QOI file format extension for TImage32 * * License : http://www.boost.org/LICENSE_1_0.txt * *******************************************************************************) @@ -41,7 +41,8 @@ interface TImageFormat_QOI = class(TImageFormat) public class function IsValidImageStream(stream: TStream): Boolean; override; - function LoadFromStream(stream: TStream; img32: TImage32): Boolean; override; + function LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; override; procedure SaveToStream(stream: TStream; img32: TImage32); override; class function CanCopyToClipboard: Boolean; override; class function CopyToClipboard(img32: TImage32): Boolean; override; @@ -105,7 +106,8 @@ function ReadByte(var p: PByte): Byte; {$IFDEF INLINE} inline; {$ENDIF} //------------------------------------------------------------------------------ {*R-} -function TImageFormat_QOI.LoadFromStream(stream: TStream; img32: TImage32): Boolean; +function TImageFormat_QOI.LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; var i, size, run, vg: integer; desc: TQOI_DESC; diff --git a/Image32/source/Img32.Fmt.SVG.pas b/Image32/source/Img32.Fmt.SVG.pas index 6af5a52..8903d7b 100644 --- a/Image32/source/Img32.Fmt.SVG.pas +++ b/Image32/source/Img32.Fmt.SVG.pas @@ -2,10 +2,10 @@ (******************************************************************************* * Author : Angus Johnson * -* Version : 4.3.1 * -* Date : 5 October 2022 * +* Version : 4.4 * +* Date : 30 January 2023 * * Website : http://www.angusj.com * -* Copyright : Angus Johnson 2019-2022 * +* Copyright : Angus Johnson 2019-2023 * * Purpose : SVG file format extension for TImage32 * * License : http://www.boost.org/LICENSE_1_0.txt * *******************************************************************************) @@ -23,7 +23,8 @@ interface TImageFormat_SVG = class(TImageFormat) public class function IsValidImageStream(stream: TStream): Boolean; override; - function LoadFromStream(stream: TStream; img32: TImage32): Boolean; override; + function LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; override; procedure SaveToStream(stream: TStream; img32: TImage32); override; class function CanCopyToClipboard: Boolean; override; class function CopyToClipboard(img32: TImage32): Boolean; override; @@ -362,7 +363,8 @@ procedure TSvgImageList32.NotifyRecipients(notifyFlag: TImg32Notification); // Loading (reading) SVG images from file ... //------------------------------------------------------------------------------ -function TImageFormat_SVG.LoadFromStream(stream: TStream; img32: TImage32): Boolean; +function TImageFormat_SVG.LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; var r: TRectWH; w,h, sx,sy: double; diff --git a/Image32/source/Img32.SVG.HashConsts.inc b/Image32/source/Img32.SVG.HashConsts.inc index 9739de8..820b12d 100644 --- a/Image32/source/Img32.SVG.HashConsts.inc +++ b/Image32/source/Img32.SVG.HashConsts.inc @@ -1,191 +1,195 @@ -const - hAmplitude = $DA119D26; // Amplitude - hArial = $EC47D4A0; // Arial - harithmetic = $978C7D6F; // arithmetic - hAtop = $7655315D; // Atop - hauto_045_start_045_reverse = $EE4545A2; // auto-start-reverse - hBackgroundAlpha = $DA55EB83; // BackgroundAlpha - hBackgroundImage = $0313D8C9; // BackgroundImage - hBaseline = $C7461648; // Baseline - hbaseline_045_shift = $56FA5107; // baseline-shift - hBevel = $BF36E150; // Bevel - hBold = $2F420533; // Bold - hBolder = $9C928BF1; // Bolder - hButt = $B619E60B; // Butt - hCDATA = $FF50BB67; // CDATA - hCircle = $C6AE4953; // Circle - hClass = $E45C07DD; // Class - hClip_045_path = $B6C7D97A; // Clip-path - hClippath = $241B0E0D; // Clippath - hColor = $E953FD29; // Color - hCurrentColor = $5B8F31B0; // CurrentColor - hCx = $B5177A89; // Cx - hCy = $A6DCDE14; // Cy - hD = $2350C685; // D - hDarken = $3DD2B17F; // Darken - hDefs = $A819FE18; // Defs - hdiffuseConstant = $08AD9D7D; // diffuseConstant - hDiscrete = $ECBBCCA1; // Discrete - hDisplay = $17D82A47; // Display - hDx = $6798DE45; // Dx - hDy = $776B7DEA; // Dy - hEllipse = $30C7994A; // Ellipse - hEnd = $B0C485D7; // End - hEntity = $395039A9; // Entity - hExponent = $D8013FFD; // Exponent - hfeBlend = $751904B9; // feBlend - hfeColorMatrix = $C0C4CF02; // feColorMatrix - hfeComponentTransfer = $8B01CCC8; // feComponentTransfer - hfeComposite = $E652E33C; // feComposite - hfeDefuseLighting = $D9F6C722; // feDefuseLighting - hfeDropShadow = $16269B00; // feDropShadow - hfeFlood = $0B6C5F4E; // feFlood - hfeFuncA = $2EA47C9E; // feFuncA - hfeFuncB = $1C5DD811; // feFuncB - hfeFuncG = $E45FE81A; // feFuncG - hfeFuncR = $F8BB10C8; // feFuncR - hfeGaussianBlur = $B2225552; // feGaussianBlur - hfeMerge = $A2C358C0; // feMerge - hfeMergeNode = $F5F1E90F; // feMergeNode - hfeOffset = $04493A72; // feOffset - hfePointLight = $D3FFCCA4; // fePointLight - hfeSpecularLighting = $577C6E4B; // feSpecularLighting - hFill = $A3AAAB69; // Fill - hFill_045_Opacity = $18000C02; // Fill-Opacity - hFill_045_Rule = $5264679F; // Fill-Rule - hFilter = $49DC73B3; // Filter - hflood_045_color = $4E87F3B3; // flood-color - hflood_045_opacity = $691CCD42; // flood-opacity - hFlowRegion = $822E901A; // FlowRegion - hFlowRoot = $A802ADFD; // FlowRoot - hFont = $21461EC6; // Font - hFont_045_Family = $371C9BE4; // Font-Family - hFont_045_Size = $8BFECA77; // Font-Size - hFont_045_Style = $4CBDA7BE; // Font-Style - hFont_045_Weight = $EF7234B4; // Font-Weight - hFx = $D6733A04; // Fx - hFy = $A4AD5675; // Fy - hG = $3593EB0B; // G - hGradientTransform = $5B6A9CF7; // GradientTransform - hGradientUnits = $07DD34B6; // GradientUnits - hGramma = $302368DC; // Gramma - hHeight = $52FDF336; // Height - hHref = $8E926F4B; // Href - hId = $1B60404D; // Id - hIn = $4D5FA44B; // In - hIn2 = $FBFE02B1; // In2 - hIntercept = $7CBB607F; // Intercept - hItalic = $F07E7786; // Italic - hK1 = $33176D43; // K1 - hK2 = $DD11C139; // K2 - hK3 = $CF4B25AC; // K3 - hK4 = $77CCF6AD; // K4 - hkernelUnitLength = $3B25E980; // kernelUnitLength - hletter_045_spacing = $5130BCF5; // letter-spacing - hLighten = $85E826DE; // Lighten - hLighter = $CCEDB4E8; // Lighter - hlighting_045_color = $B4114C27; // lighting-color - hLine = $7A6D718F; // Line - hline_045_through = $1C703CCD; // line-through - hLinear = $39327DA3; // Linear - hLinearGradient = $C16E9BCD; // LinearGradient - hMarker = $72660BE9; // Marker - hMarker_045_End = $B06101FD; // Marker-End - hMarker_045_Mid = $FD95C733; // Marker-Mid - hMarker_045_Start = $CF854A0E; // Marker-Start - hMarkerHeight = $10360978; // MarkerHeight - hMarkerWidth = $EF8DF427; // MarkerWidth - hMask = $FAF8F32F; // Mask - hMatrix = $31E3AD46; // Matrix - hMiddle = $80732990; // Middle - hMiter = $33868A3B; // Miter - hMode = $68155C83; // Mode - hMonospace = $049AE941; // Monospace - hMultiply = $9110BAC4; // Multiply - hNone = $1D632BA1; // None - hNormal = $4F485502; // Normal - hObjectBoundingBox = $3D4B4519; // ObjectBoundingBox - hOffset = $A13C79EF; // Offset - hOpacity = $D9394F28; // Opacity - hOperator = $AA661628; // Operator - hOrient = $EFF6C65A; // Orient - hOut = $12067E90; // Out - hOver = $C9B82D21; // Over - hOverlay = $383BEA5E; // Overlay - hPad = $4A0CAD48; // Pad - hPath = $AD8A7AB5; // Path - hPattern = $FF0BFA79; // Pattern - hPatternContentUnits = $C6D9BCA5; // PatternContentUnits - hPatternTransform = $7051BE8C; // PatternTransform - hPatternUnits = $2FDF622C; // PatternUnits - hPoints = $87F41B44; // Points - hPolygon = $509667FD; // Polygon - hPolyline = $58B3D280; // Polyline - hR = $26014BE2; // R - hRadialGradient = $B0D7E1F9; // RadialGradient - hRect = $FA3BCBEA; // Rect - hReflect = $98BC393E; // Reflect - hRefX = $00C1DE46; // RefX - hRefY = $480CECDB; // RefY - hRepeat = $FF80069D; // Repeat - hResult = $47CD519F; // Result - hRound = $323B0E24; // Round - hRx = $3ABF70F3; // Rx - hRy = $0C7D9470; // Ry - hSans = $DE5518F6; // Sans - hSans_045_Serif = $95106804; // Sans-Serif - hScreen = $207A08BB; // Screen - hSerif = $B88D4332; // Serif - hSlope = $4774735C; // Slope - hSourceAlpha = $F891B958; // SourceAlpha - hSourceGraphic = $A4DB1DC2; // SourceGraphic - hspecularExponent = $93D520E8; // specularExponent - hSpreadMethod = $A08CEB57; // SpreadMethod - hSquare = $20E48144; // Square - hStart = $84DC271F; // Start - hstdDeviation = $00D13F6A; // stdDeviation - hStop = $930CA7F2; // Stop - hStop_045_Color = $9FD6E0BE; // Stop-Color - hStop_045_Opacity = $FC7751F2; // Stop-Opacity - hStroke = $E04ABDF3; // Stroke - hStroke_045_DashArray = $795F2D78; // Stroke-DashArray - hStroke_045_DashOffset = $A418B357; // Stroke-DashOffset - hstroke_045_linecap = $29D0178F; // stroke-linecap - hstroke_045_linejoin = $79642287; // stroke-linejoin - hstroke_045_miterlimit = $16C29890; // stroke-miterlimit - hStroke_045_Opacity = $D237C6B5; // Stroke-Opacity - hStroke_045_Width = $AFF671ED; // Stroke-Width - hStyle = $A9473AB4; // Style - hSub = $1B3C1FFA; // Sub - hSuper = $9C5EE034; // Super - hsurfaceScale = $EA29CC4F; // surfaceScale - hSvg = $ED67C37E; // Svg - hSwitch = $D60E64BB; // Switch - hSymbol = $07754611; // Symbol - hTable = $AB55E184; // Table - hTableValues = $2F999AD9; // TableValues - hText = $7F3B51AB; // Text - hText_045_Anchor = $D0D82FE8; // Text-Anchor - hText_045_Decoration = $3BC20862; // Text-Decoration - hTextLength = $DA75EDC0; // TextLength - hTextPath = $18F2748E; // TextPath - hTimes = $FF0E1FBE; // Times - hTransform = $A0930B32; // Transform - hTSpan = $33C1F865; // TSpan - hType = $3165B05D; // Type - hUnderline = $70D1B303; // Underline - hUrl = $BC113F8C; // Url - hUse = $65736EEA; // Use - hUserSpaceOnUse = $3D19F8A4; // UserSpaceOnUse - hValues = $33429E55; // Values - hViewbox = $AEF665C8; // Viewbox - hWidth = $96BEECA0; // Width - hX = $9303A5E5; // X - hX1 = $74A7DE27; // X1 - hX2 = $168E21F1; // X2 - hXlink_058_Href = $2BDA798B; // Xlink:Href - hXor = $4D86273A; // Xor - hY = $80950108; // Y - hY1 = $7F247680; // Y1 - hY2 = $6DE3D3FF; // Y2 - hZ = $B6606C9E; // Z +const + hAmplitude = $DA119D26; // Amplitude + hArial = $EC47D4A0; // Arial + harithmetic = $978C7D6F; // arithmetic + hAtop = $7655315D; // Atop + hauto_045_start_045_reverse = $EE4545A2; // auto-start-reverse + hBackgroundAlpha = $DA55EB83; // BackgroundAlpha + hBackgroundImage = $0313D8C9; // BackgroundImage + hBaseline = $C7461648; // Baseline + hbaseline_045_shift = $56FA5107; // baseline-shift + hBevel = $BF36E150; // Bevel + hBold = $2F420533; // Bold + hBolder = $9C928BF1; // Bolder + hButt = $B619E60B; // Butt + hCDATA = $FF50BB67; // CDATA + hCircle = $C6AE4953; // Circle + hClass = $E45C07DD; // Class + hClip_045_path = $B6C7D97A; // Clip-path + hClippath = $241B0E0D; // Clippath + hcollapse = $22A7B0EC; // collapse + hColor = $E953FD29; // Color + hCurrentColor = $5B8F31B0; // CurrentColor + hCx = $B5177A89; // Cx + hCy = $A6DCDE14; // Cy + hD = $2350C685; // D + hDarken = $3DD2B17F; // Darken + hDefs = $A819FE18; // Defs + hdiffuseConstant = $08AD9D7D; // diffuseConstant + hDiscrete = $ECBBCCA1; // Discrete + hDisplay = $17D82A47; // Display + hDx = $6798DE45; // Dx + hDy = $776B7DEA; // Dy + hEllipse = $30C7994A; // Ellipse + hEnd = $B0C485D7; // End + hEntity = $395039A9; // Entity + hExponent = $D8013FFD; // Exponent + hfeBlend = $751904B9; // feBlend + hfeColorMatrix = $C0C4CF02; // feColorMatrix + hfeComponentTransfer = $8B01CCC8; // feComponentTransfer + hfeComposite = $E652E33C; // feComposite + hfeDefuseLighting = $D9F6C722; // feDefuseLighting + hfeDropShadow = $16269B00; // feDropShadow + hfeFlood = $0B6C5F4E; // feFlood + hfeFuncA = $2EA47C9E; // feFuncA + hfeFuncB = $1C5DD811; // feFuncB + hfeFuncG = $E45FE81A; // feFuncG + hfeFuncR = $F8BB10C8; // feFuncR + hfeGaussianBlur = $B2225552; // feGaussianBlur + hfeMerge = $A2C358C0; // feMerge + hfeMergeNode = $F5F1E90F; // feMergeNode + hfeOffset = $04493A72; // feOffset + hfePointLight = $D3FFCCA4; // fePointLight + hfeSpecularLighting = $577C6E4B; // feSpecularLighting + hFill = $A3AAAB69; // Fill + hFill_045_Opacity = $18000C02; // Fill-Opacity + hFill_045_Rule = $5264679F; // Fill-Rule + hFilter = $49DC73B3; // Filter + hflood_045_color = $4E87F3B3; // flood-color + hflood_045_opacity = $691CCD42; // flood-opacity + hFlowRegion = $822E901A; // FlowRegion + hFlowRoot = $A802ADFD; // FlowRoot + hFont = $21461EC6; // Font + hFont_045_Family = $371C9BE4; // Font-Family + hFont_045_Size = $8BFECA77; // Font-Size + hFont_045_Style = $4CBDA7BE; // Font-Style + hFont_045_Weight = $EF7234B4; // Font-Weight + hFx = $D6733A04; // Fx + hFy = $A4AD5675; // Fy + hG = $3593EB0B; // G + hGradientTransform = $5B6A9CF7; // GradientTransform + hGradientUnits = $07DD34B6; // GradientUnits + hGramma = $302368DC; // Gramma + hHeight = $52FDF336; // Height + hhidden = $4C4D777D; // hidden + hHref = $8E926F4B; // Href + hId = $1B60404D; // Id + hIn = $4D5FA44B; // In + hIn2 = $FBFE02B1; // In2 + hIntercept = $7CBB607F; // Intercept + hItalic = $F07E7786; // Italic + hK1 = $33176D43; // K1 + hK2 = $DD11C139; // K2 + hK3 = $CF4B25AC; // K3 + hK4 = $77CCF6AD; // K4 + hkernelUnitLength = $3B25E980; // kernelUnitLength + hletter_045_spacing = $5130BCF5; // letter-spacing + hLighten = $85E826DE; // Lighten + hLighter = $CCEDB4E8; // Lighter + hlighting_045_color = $B4114C27; // lighting-color + hLine = $7A6D718F; // Line + hline_045_through = $1C703CCD; // line-through + hLinear = $39327DA3; // Linear + hLinearGradient = $C16E9BCD; // LinearGradient + hMarker = $72660BE9; // Marker + hMarker_045_End = $B06101FD; // Marker-End + hMarker_045_Mid = $FD95C733; // Marker-Mid + hMarker_045_Start = $CF854A0E; // Marker-Start + hMarkerHeight = $10360978; // MarkerHeight + hMarkerWidth = $EF8DF427; // MarkerWidth + hMask = $FAF8F32F; // Mask + hMatrix = $31E3AD46; // Matrix + hMiddle = $80732990; // Middle + hMiter = $33868A3B; // Miter + hMode = $68155C83; // Mode + hMonospace = $049AE941; // Monospace + hMultiply = $9110BAC4; // Multiply + hNone = $1D632BA1; // None + hNormal = $4F485502; // Normal + hObjectBoundingBox = $3D4B4519; // ObjectBoundingBox + hOffset = $A13C79EF; // Offset + hOpacity = $D9394F28; // Opacity + hOperator = $AA661628; // Operator + hOrient = $EFF6C65A; // Orient + hOut = $12067E90; // Out + hOver = $C9B82D21; // Over + hOverlay = $383BEA5E; // Overlay + hPad = $4A0CAD48; // Pad + hPath = $AD8A7AB5; // Path + hPattern = $FF0BFA79; // Pattern + hPatternContentUnits = $C6D9BCA5; // PatternContentUnits + hPatternTransform = $7051BE8C; // PatternTransform + hPatternUnits = $2FDF622C; // PatternUnits + hPoints = $87F41B44; // Points + hPolygon = $509667FD; // Polygon + hPolyline = $58B3D280; // Polyline + hR = $26014BE2; // R + hRadialGradient = $B0D7E1F9; // RadialGradient + hRect = $FA3BCBEA; // Rect + hReflect = $98BC393E; // Reflect + hRefX = $00C1DE46; // RefX + hRefY = $480CECDB; // RefY + hRepeat = $FF80069D; // Repeat + hResult = $47CD519F; // Result + hRound = $323B0E24; // Round + hRx = $3ABF70F3; // Rx + hRy = $0C7D9470; // Ry + hSans = $DE5518F6; // Sans + hSans_045_Serif = $95106804; // Sans-Serif + hScreen = $207A08BB; // Screen + hSerif = $B88D4332; // Serif + hSlope = $4774735C; // Slope + hSourceAlpha = $F891B958; // SourceAlpha + hSourceGraphic = $A4DB1DC2; // SourceGraphic + hspecularExponent = $93D520E8; // specularExponent + hSpreadMethod = $A08CEB57; // SpreadMethod + hSquare = $20E48144; // Square + hStart = $84DC271F; // Start + hstdDeviation = $00D13F6A; // stdDeviation + hStop = $930CA7F2; // Stop + hStop_045_Color = $9FD6E0BE; // Stop-Color + hStop_045_Opacity = $FC7751F2; // Stop-Opacity + hStroke = $E04ABDF3; // Stroke + hStroke_045_DashArray = $795F2D78; // Stroke-DashArray + hStroke_045_DashOffset = $A418B357; // Stroke-DashOffset + hstroke_045_linecap = $29D0178F; // stroke-linecap + hstroke_045_linejoin = $79642287; // stroke-linejoin + hstroke_045_miterlimit = $16C29890; // stroke-miterlimit + hStroke_045_Opacity = $D237C6B5; // Stroke-Opacity + hStroke_045_Width = $AFF671ED; // Stroke-Width + hStyle = $A9473AB4; // Style + hSub = $1B3C1FFA; // Sub + hSuper = $9C5EE034; // Super + hsurfaceScale = $EA29CC4F; // surfaceScale + hSvg = $ED67C37E; // Svg + hSwitch = $D60E64BB; // Switch + hSymbol = $07754611; // Symbol + hTable = $AB55E184; // Table + hTableValues = $2F999AD9; // TableValues + hText = $7F3B51AB; // Text + hText_045_Anchor = $D0D82FE8; // Text-Anchor + hText_045_Decoration = $3BC20862; // Text-Decoration + hTextLength = $DA75EDC0; // TextLength + hTextPath = $18F2748E; // TextPath + hTimes = $FF0E1FBE; // Times + hTransform = $A0930B32; // Transform + hTSpan = $33C1F865; // TSpan + hType = $3165B05D; // Type + hUnderline = $70D1B303; // Underline + hUrl = $BC113F8C; // Url + hUse = $65736EEA; // Use + hUserSpaceOnUse = $3D19F8A4; // UserSpaceOnUse + hValues = $33429E55; // Values + hViewbox = $AEF665C8; // Viewbox + hVisibility = $9F832B01; // Visibility + hvisible = $96C79D31; // visible + hWidth = $96BEECA0; // Width + hX = $9303A5E5; // X + hX1 = $74A7DE27; // X1 + hX2 = $168E21F1; // X2 + hXlink_058_Href = $2BDA798B; // Xlink:Href + hXor = $4D86273A; // Xor + hY = $80950108; // Y + hY1 = $7F247680; // Y1 + hY2 = $6DE3D3FF; // Y2 + hZ = $B6606C9E; // Z diff --git a/Image32/source/Img32.SVG.Reader.pas b/Image32/source/Img32.SVG.Reader.pas index d988dad..73d8728 100644 --- a/Image32/source/Img32.SVG.Reader.pas +++ b/Image32/source/Img32.SVG.Reader.pas @@ -3966,6 +3966,17 @@ procedure Viewbox_Attrib(aOwnerEl: TSvgElement; const value: UTF8String); end; //------------------------------------------------------------------------------ +procedure Visibility_Attrib(aOwnerEl: TSvgElement; const value: UTF8String); +begin + case GetHash(value) of + hCollapse: aOwnerEl.fDrawData.visible := false; + hHidden: aOwnerEl.fDrawData.visible := false; + hVisible: aOwnerEl.fDrawData.visible := true; + end; +end; +//------------------------------------------------------------------------------ + + procedure Height_Attrib(aOwnerEl: TSvgElement; const value: UTF8String); var mu: TUnitType; @@ -4316,90 +4327,91 @@ procedure Z_Attrib(aOwnerEl: TSvgElement; const value: UTF8String); procedure TSvgElement.LoadAttribute(attrib: PSvgAttrib); begin with attrib^ do - case hash of - hbaseline_045_shift: BaselineShift_Attrib(self, value); - hColor: Color_Attrib(self, value); - hClip_045_path: ClipPath_Attrib(self, value); - hCx: Cx_Attrib(self, value); - hCy: Cy_Attrib(self, value); - hD: D_Attrib(self, value); - hDisplay: Display_Attrib(self, value); - hDx: Dx_Attrib(self, value); - hDy: Dy_Attrib(self, value); - hStroke_045_DashArray: DashArray_Attrib(self, value); - hStroke_045_DashOffset: DashOffset_Attrib(self, value); - hFill: Fill_Attrib(self, value); - hFill_045_Opacity: FillOpacity_Attrib(self, value); - hFill_045_Rule: FillRule_Attrib(self, value); - hFilter: Filter_Attrib(self, value); - hflood_045_color: Fill_Attrib(self, value); - hflood_045_opacity: FillOpacity_Attrib(self, value); - hFont: Font_Attrib(self, value); - hFont_045_Family: FontFamily_Attrib(self, value); - hFont_045_Size: FontSize_Attrib(self, value); - hFont_045_Style: FontStyle_Attrib(self, value); - hFont_045_Weight: FontWeight_Attrib(self, value); - hFx: Fx_Attrib(self, value); - hFy: Fy_Attrib(self, value); - hGradientTransform: GradientTransform_Attrib(self, value); - hGradientUnits: GradientUnits_Attrib(self, value); - hHeight: Height_Attrib(self, value); - hHref: Href_Attrib(self, value); - hId: Id_Attrib(self, value); - hIn: In_Attrib(self, value); - hIn2: In2_Attrib(self, value); - hk1: K1_Attrib(self, value); - hk2: K2_Attrib(self, value); - hk3: K3_Attrib(self, value); - hk4: K4_Attrib(self, value); - hletter_045_spacing: LetterSpacing_Attrib(self, value); -// hlighting_045_color: LightingColor_Attrib(self, value); - hMarker_045_End: MarkerEnd_Attrib(self, value); - hMarkerHeight: Height_Attrib(self, value); - hMarker_045_Mid: MarkerMiddle_Attrib(self, value); - hMarker_045_Start: MarkerStart_Attrib(self, value); - hMarkerWidth: Width_Attrib(self, value); - hMask: Mask_Attrib(self, value); - hOffset: Offset_Attrib(self, value); - hOpacity: Opacity_Attrib(self, value); - hOperator: Operator_Attrib(self, value); - hOrient: Orient_Attrib(self, value); - hPatternUnits: GradientUnits_Attrib(self, value); - hPatternTransform: Transform_Attrib(self, value); - hPoints: Points_Attrib(self, value); - hR: Rx_Attrib(self, value); - hRefX: Rx_Attrib(self, value); - hRefY: Ry_Attrib(self, value); - hResult: Result_Attrib(self, value); - hRx: Rx_Attrib(self, value); - hRy: Ry_Attrib(self, value); - hspecularExponent: SpectacularExponent(self, value); - hSpreadMethod: SpreadMethod_Attrib(self, value); - hstdDeviation: StdDev_Attrib(self, value); - hStop_045_Color: StopColor_Attrib(self, value); - hStop_045_Opacity: StopOpacity_Attrib(self, value); - hStroke: Stroke_Attrib(self, value); - hstroke_045_linecap: StrokeLineCap_Attrib(self, value); - hstroke_045_linejoin: StrokeLineJoin_Attrib(self, value); - hstroke_045_miterlimit: StrokeMiterLimit_Attrib(self, value); - hStroke_045_Opacity: StrokeOpacity_Attrib(self, value); - hStroke_045_Width: StrokeWidth_Attrib(self, value); - hText_045_Anchor: TextAlign_Attrib(self, value); - hText_045_Decoration: TextDecoration_Attrib(self, value); - hTextLength: TextLength_Attrib(self, value); - hTransform: Transform_Attrib(self, value); - hValues: Values_Attrib(self, value); - hViewbox: Viewbox_Attrib(self, value); - hWidth: Width_Attrib(self, value); - hX: X1_Attrib(self, value); - hX1: X1_Attrib(self, value); - hX2: X2_Attrib(self, value); - hXlink_058_Href: Href_Attrib(self, value); - hY: Y1_Attrib(self, value); - hY1: Y1_Attrib(self, value); - hY2: Y2_Attrib(self, value); - hZ: Z_Attrib(self, value); - end; + case hash of + hbaseline_045_shift: BaselineShift_Attrib(self, value); + hColor: Color_Attrib(self, value); + hClip_045_path: ClipPath_Attrib(self, value); + hCx: Cx_Attrib(self, value); + hCy: Cy_Attrib(self, value); + hD: D_Attrib(self, value); + hDisplay: Display_Attrib(self, value); + hDx: Dx_Attrib(self, value); + hDy: Dy_Attrib(self, value); + hStroke_045_DashArray: DashArray_Attrib(self, value); + hStroke_045_DashOffset: DashOffset_Attrib(self, value); + hFill: Fill_Attrib(self, value); + hFill_045_Opacity: FillOpacity_Attrib(self, value); + hFill_045_Rule: FillRule_Attrib(self, value); + hFilter: Filter_Attrib(self, value); + hflood_045_color: Fill_Attrib(self, value); + hflood_045_opacity: FillOpacity_Attrib(self, value); + hFont: Font_Attrib(self, value); + hFont_045_Family: FontFamily_Attrib(self, value); + hFont_045_Size: FontSize_Attrib(self, value); + hFont_045_Style: FontStyle_Attrib(self, value); + hFont_045_Weight: FontWeight_Attrib(self, value); + hFx: Fx_Attrib(self, value); + hFy: Fy_Attrib(self, value); + hGradientTransform: GradientTransform_Attrib(self, value); + hGradientUnits: GradientUnits_Attrib(self, value); + hHeight: Height_Attrib(self, value); + hHref: Href_Attrib(self, value); + hId: Id_Attrib(self, value); + hIn: In_Attrib(self, value); + hIn2: In2_Attrib(self, value); + hk1: K1_Attrib(self, value); + hk2: K2_Attrib(self, value); + hk3: K3_Attrib(self, value); + hk4: K4_Attrib(self, value); + hletter_045_spacing: LetterSpacing_Attrib(self, value); + // hlighting_045_color: LightingColor_Attrib(self, value); + hMarker_045_End: MarkerEnd_Attrib(self, value); + hMarkerHeight: Height_Attrib(self, value); + hMarker_045_Mid: MarkerMiddle_Attrib(self, value); + hMarker_045_Start: MarkerStart_Attrib(self, value); + hMarkerWidth: Width_Attrib(self, value); + hMask: Mask_Attrib(self, value); + hOffset: Offset_Attrib(self, value); + hOpacity: Opacity_Attrib(self, value); + hOperator: Operator_Attrib(self, value); + hOrient: Orient_Attrib(self, value); + hPatternUnits: GradientUnits_Attrib(self, value); + hPatternTransform: Transform_Attrib(self, value); + hPoints: Points_Attrib(self, value); + hR: Rx_Attrib(self, value); + hRefX: Rx_Attrib(self, value); + hRefY: Ry_Attrib(self, value); + hResult: Result_Attrib(self, value); + hRx: Rx_Attrib(self, value); + hRy: Ry_Attrib(self, value); + hspecularExponent: SpectacularExponent(self, value); + hSpreadMethod: SpreadMethod_Attrib(self, value); + hstdDeviation: StdDev_Attrib(self, value); + hStop_045_Color: StopColor_Attrib(self, value); + hStop_045_Opacity: StopOpacity_Attrib(self, value); + hStroke: Stroke_Attrib(self, value); + hstroke_045_linecap: StrokeLineCap_Attrib(self, value); + hstroke_045_linejoin: StrokeLineJoin_Attrib(self, value); + hstroke_045_miterlimit: StrokeMiterLimit_Attrib(self, value); + hStroke_045_Opacity: StrokeOpacity_Attrib(self, value); + hStroke_045_Width: StrokeWidth_Attrib(self, value); + hText_045_Anchor: TextAlign_Attrib(self, value); + hText_045_Decoration: TextDecoration_Attrib(self, value); + hTextLength: TextLength_Attrib(self, value); + hTransform: Transform_Attrib(self, value); + hValues: Values_Attrib(self, value); + hViewbox: Viewbox_Attrib(self, value); + hVisibility: Visibility_Attrib(self, value); + hWidth: Width_Attrib(self, value); + hX: X1_Attrib(self, value); + hX1: X1_Attrib(self, value); + hX2: X2_Attrib(self, value); + hXlink_058_Href: Href_Attrib(self, value); + hY: Y1_Attrib(self, value); + hY1: Y1_Attrib(self, value); + hY2: Y2_Attrib(self, value); + hZ: Z_Attrib(self, value); + end; end; //------------------------------------------------------------------------------ diff --git a/Image32/source/Img32.Text.pas b/Image32/source/Img32.Text.pas index 8f9dae5..6f13246 100644 --- a/Image32/source/Img32.Text.pas +++ b/Image32/source/Img32.Text.pas @@ -284,7 +284,7 @@ TFontManager = class procedure Clear; function GetFont(const fontName: string): TFontReader; {$IFDEF MSWINDOWS} - function Load(const fontName: string): TFontReader; + function Load(const fontName: string; Weight: Integer = FW_NORMAL; Italic: Boolean = False): TFontReader; {$ENDIF} function LoadFromStream(stream: TStream): TFontReader; function LoadFromResource(const resName: string; resType: PChar): TFontReader; @@ -355,7 +355,7 @@ TFontReader = class(TInterfacedObj, INotifySender) constructor Create; overload; constructor CreateFromResource(const resName: string; resType: PChar); {$IFDEF MSWINDOWS} - constructor Create(const fontname: string); overload; + constructor Create(const fontname: string; Weight: Integer = FW_NORMAL; Italic: Boolean = False); overload; {$ENDIF} destructor Destroy; override; procedure Clear; @@ -366,7 +366,7 @@ TFontReader = class(TInterfacedObj, INotifySender) function LoadFromResource(const resName: string; resType: PChar): Boolean; function LoadFromFile(const filename: string): Boolean; {$IFDEF MSWINDOWS} - function Load(const fontname: string): Boolean; + function Load(const fontname: string; Weight: Integer = FW_NORMAL; Italic: Boolean = False): Boolean; function LoadUsingFontHdl(hdl: HFont): Boolean; {$ENDIF} function GetGlyphInfo(unicode: Word; out paths: TPathsD; @@ -394,7 +394,6 @@ TTextPageMetrics = record TWordInfoList = class; TWordInfo = class - private index : integer; aWord : UnicodeString; width : double; @@ -870,10 +869,10 @@ constructor TFontReader.CreateFromResource(const resName: string; resType: PChar //------------------------------------------------------------------------------ {$IFDEF MSWINDOWS} -constructor TFontReader.Create(const fontname: string); +constructor TFontReader.Create(const fontname: string; Weight: Integer; Italic: Boolean); begin Create; - Load(fontname); + Load(fontname, Weight, Italic); end; //------------------------------------------------------------------------------ {$ENDIF} @@ -1056,7 +1055,7 @@ function TFontReader.LoadUsingFontHdl(hdl: HFont): Boolean; end; //------------------------------------------------------------------------------ -function TFontReader.Load(const fontname: string): Boolean; +function TFontReader.Load(const fontname: string; Weight: Integer; Italic: Boolean): Boolean; var logfont: TLogFont; hdl: HFont; @@ -1064,6 +1063,8 @@ function TFontReader.Load(const fontname: string): Boolean; Result := false; FillChar(logfont, SizeOf(logfont), 0); StrPCopy(@logfont.lfFaceName[0], fontname); + logFont.lfWeight := Weight; + logFont.lfItalic := Byte(Italic); hdl := CreateFontIndirect(logfont); if hdl = 0 then Exit; try @@ -3468,7 +3469,7 @@ function TFontManager.GetFont(const fontName: string): TFontReader; //------------------------------------------------------------------------------ {$IFDEF MSWINDOWS} -function TFontManager.Load(const fontName: string): TFontReader; +function TFontManager.Load(const fontName: string; Weight: Integer; Italic: Boolean): TFontReader; begin if fFontList.Count >= fMaxFonts then raise Exception.Create(rsTooManyFonts); @@ -3478,7 +3479,7 @@ function TFontManager.Load(const fontName: string): TFontReader; Result := TFontReader.Create; try - if not Result.Load(fontName) or + if not Result.Load(fontName, Weight, Italic) or not ValidateAdd(Result) then FreeAndNil(Result); except diff --git a/Image32/source/Img32.Vector.pas b/Image32/source/Img32.Vector.pas index ef874d0..01ad804 100644 --- a/Image32/source/Img32.Vector.pas +++ b/Image32/source/Img32.Vector.pas @@ -2,10 +2,10 @@ (******************************************************************************* * Author : Angus Johnson * -* Version : 4.3 * -* Date : 27 September 2022 * +* Version : 4.4 * +* Date : 21 January 2023 * * Website : http://www.angusj.com * -* Copyright : Angus Johnson 2019-2022 * +* Copyright : Angus Johnson 2019-2023 * * * * Purpose : Vector drawing for TImage32 * * * @@ -431,6 +431,7 @@ interface NullRectD : TRectD = (left: 0; top: 0; right: 0; Bottom: 0); InvalidRect : TRect = (left: MaxInt; top: MaxInt; right: 0; Bottom: 0); BezierTolerance: double = 0.25; + DoubleTolerance: double = 1.0e-12; var //AutoWidthThreshold: When JoinStyle = jsAuto, this is the threshold at //which line joins will be rounded instead of squared. With wider strokes, @@ -736,13 +737,13 @@ function GetRotatedRectBounds(const rec: TRectD; angle: double): TRectD; end; //------------------------------------------------------------------------------ - function Rect(const recD: TRectD): TRect; begin - Result.Left := Floor(recD.Left); - Result.Top := Floor(recD.Top); - Result.Right := Ceil(recD.Right); - Result.Bottom := Ceil(recD.Bottom); + // see https://github.com/AngusJohnson/Image32/issues/15 + Result.Left := Floor(recD.Left + DoubleTolerance); + Result.Top := Floor(recD.Top + DoubleTolerance); + Result.Right := Ceil(recD.Right - DoubleTolerance); + Result.Bottom := Ceil(recD.Bottom - DoubleTolerance); end; //------------------------------------------------------------------------------ @@ -2258,7 +2259,7 @@ function IntersectPoint(const ln1a, ln1b, ln2a, ln2b: TPointD): TPointD; m1,b1,m2,b2: double; begin result := InvalidPointD; - //see http://astronomy.swin.edu.au/~pbourke/geometry/lineline2d/ + //see http://paulbourke.net/geometry/pointlineplane/ if (ln1B.X = ln1A.X) then begin if (ln2B.X = ln2A.X) then exit; //parallel lines @@ -3191,8 +3192,8 @@ function GetBoundsD(const paths: TPathsD): TRectD; l,t,r,b: double; p: PPointD; begin - l := MaxInt; t := MaxInt; - r := -MaxInt; b := -MaxInt; + l := MaxDouble; t := MaxDouble; + r := -MaxDouble; b := -MaxDouble; for i := 0 to high(paths) do begin p := PPointD(paths[i]); diff --git a/Image32/source/Img32.inc b/Image32/source/Img32.inc index 47326ce..0647f0c 100644 --- a/Image32/source/Img32.inc +++ b/Image32/source/Img32.inc @@ -6,7 +6,9 @@ //USING_VCL_LCL - using either Delphi or Lazarus Component Libraries //Adds a few extra library features (eg copying to and from TBitmap objects) //Enabled is recommended unless you're compiling console applications. -{$DEFINE USING_VCL_LCL} +{$IFDEF MSWINDOWS} + {$DEFINE USING_VCL_LCL} +{$ENDIF} {$IFDEF FPC} {$MODE DELPHI} diff --git a/Image32/source/Img32.pas b/Image32/source/Img32.pas index e33f5e2..525b952 100644 --- a/Image32/source/Img32.pas +++ b/Image32/source/Img32.pas @@ -2,10 +2,10 @@ (******************************************************************************* * Author : Angus Johnson * -* Version : 4.3 * -* Date : 27 September 2022 * +* Version : 4.4 * +* Date : 30 January 2023 * * Website : http://www.angusj.com * -* Copyright : Angus Johnson 2019-2022 * +* Copyright : Angus Johnson 2019-2023 * * * * Purpose : The core module of the Image32 library * * * @@ -39,6 +39,15 @@ TPointD = record X, Y: double; end; + PARGB = ^TARGB; + TARGB = packed record + case boolean of + false: (B: Byte; G: Byte; R: Byte; A: Byte); + true : (Color: TColor32); + end; + TArrayOfARGB = array of TARGB; + PArgbArray = ^TArrayOfARGB; + const clNone32 = TColor32($00000000); clAqua32 = TColor32($FF00FFFF); @@ -140,11 +149,14 @@ TImageFormatClass = class of TImageFormat; //file storage formats (eg BMP, PNG, GIF & JPG).
//Derived classes register with TImage32 using TImage32.RegisterImageFormatClass. TImageFormat = class + public class function IsValidImageStream(stream: TStream): Boolean; virtual; abstract; procedure SaveToStream(stream: TStream; img32: TImage32); virtual; abstract; function SaveToFile(const filename: string; img32: TImage32): Boolean; virtual; - function LoadFromStream(stream: TStream; img32: TImage32): Boolean; virtual; abstract; + function LoadFromStream(stream: TStream; + img32: TImage32; imgIndex: integer = 0): Boolean; virtual; abstract; function LoadFromFile(const filename: string; img32: TImage32): Boolean; virtual; + class function GetImageCount(stream: TStream): integer; virtual; class function CanCopyToClipboard: Boolean; virtual; class function CopyToClipboard(img32: TImage32): Boolean; virtual; abstract; class function CanPasteFromClipboard: Boolean; virtual; abstract; @@ -305,7 +317,7 @@ TImage32 = class(TObject) function SaveToFile(filename: string): Boolean; function SaveToStream(stream: TStream; const FmtExt: string): Boolean; function LoadFromFile(const filename: string): Boolean; - function LoadFromStream(stream: TStream): Boolean; + function LoadFromStream(stream: TStream; imgIdx: integer = 0): Boolean; function LoadFromResource(const resName: string; resType: PChar): Boolean; //properties ... @@ -357,15 +369,6 @@ TImageList32 = class property Last: TImage32 read GetLast; end; - PARGB = ^TARGB; - TARGB = packed record - case boolean of - false: (B: Byte; G: Byte; R: Byte; A: Byte); - true : (Color: TColor32); - end; - TArrayOfARGB = array of TARGB; - PArgbArray = ^TArrayOfARGB; - THsl = packed record hue : byte; sat : byte; @@ -448,6 +451,8 @@ TImageList32 = class {$IFDEF MSWINDOWS} //Color32: Converts a Graphics.TColor value into a TColor32 value. function Color32(rgbColor: Integer): TColor32; overload; + + procedure FixPalette(p: PARGB; count: integer); {$ENDIF} function Color32(a, r, g, b: Byte): TColor32; overload; @@ -597,7 +602,6 @@ TImgFmtRec = record PImgFmtRec = ^TImgFmtRec; TResamplerObj = class - private id: integer; name: string; func: TResamplerFunction; @@ -1045,6 +1049,19 @@ function Color32(rgbColor: Integer): TColor32; end; //------------------------------------------------------------------------------ +procedure FixPalette(p: PARGB; count: integer); +var + i: integer; +begin + for i := 1 to count do + begin + p.Color := SwapRedBlue(p.Color); + p.A := 255; + inc(p); + end; +end; +//------------------------------------------------------------------------------ + function Get32bitBitmapInfoHeader(width, height: Integer): TBitmapInfoHeader; begin FillChar(Result, sizeof(Result), #0); @@ -2273,7 +2290,7 @@ function TImage32.LoadFromFile(const filename: string): Boolean; end; //------------------------------------------------------------------------------ -function TImage32.LoadFromStream(stream: TStream): Boolean; +function TImage32.LoadFromStream(stream: TStream; imgIdx: integer): Boolean; var ifc: TImageFormatClass; begin @@ -2283,7 +2300,7 @@ function TImage32.LoadFromStream(stream: TStream): Boolean; with ifc.Create do try - result := LoadFromStream(stream, self); + result := LoadFromStream(stream, self, imgIdx); finally free; end; @@ -2489,6 +2506,7 @@ function TImage32.LoadFromResource(const resName: string; resType: PChar): Boole //------------------------------------------------------------------------------ {$IFDEF MSWINDOWS} + procedure TImage32.CopyFromDC(srcDc: HDC; const srcRect: TRect); var bi: TBitmapInfoHeader; @@ -3359,6 +3377,12 @@ class function TImageFormat.CanCopyToClipboard: Boolean; begin Result := false; end; +//------------------------------------------------------------------------------ + +class function TImageFormat.GetImageCount(stream: TStream): integer; +begin + Result := 1; +end; //------------------------------------------------------------------------------ // TInterfacedObj diff --git a/README.md b/README.md index 858e3ec..c6d80f4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Four engines to render SVG (Delphi Image32, Delphi TSVG, SKIA4Delphi, Direct2D wrapper) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...) -### Actual official version 3.9.5 (VCL+FMX) +### Actual official version 3.9.6 (VCL+FMX) | Component | Description | | - | - | @@ -83,6 +83,10 @@ Follow the [guide in Wiki section](https://github.com/EtheaDev/SVGIconImageList/ ### RELEASE NOTES +28 Feb 2023: version 3.9.6 (VCL+FMX) +- Updated to Image32 ver. 4.4 (30 Jan 2023) +- Updated to Skia4Delphi ver. 4.1.1 (26 Feb 2023) + 13 Jan 2023: version 3.9.5 (VCL+FMX) - Updated Copyright 2023 - Updated to Image32 ver. 4.3 (27 Sep 2022) diff --git a/Source/FMX.SVGIconImageList.pas b/Source/FMX.SVGIconImageList.pas index ebc45e0..7989ead 100644 --- a/Source/FMX.SVGIconImageList.pas +++ b/Source/FMX.SVGIconImageList.pas @@ -47,7 +47,7 @@ interface ; const - SVGIconImageListVersion = '3.9.5'; + SVGIconImageListVersion = '3.9.6'; DEFAULT_SIZE = 32; ZOOM_DEFAULT = 100; SVG_INHERIT_COLOR = TAlphaColors.Null; diff --git a/Source/SVGIconImageListBase.pas b/Source/SVGIconImageListBase.pas index 0ff380b..1a5036f 100644 --- a/Source/SVGIconImageListBase.pas +++ b/Source/SVGIconImageListBase.pas @@ -48,7 +48,7 @@ interface SvgInterfaces; const - SVGIconImageListVersion = '3.9.5'; + SVGIconImageListVersion = '3.9.6'; DEFAULT_SIZE = 16; type diff --git a/skia4delphi/Binary/Shared/OSX64/libsk4d.dylib b/skia4delphi/Binary/Shared/OSX64/libsk4d.dylib deleted file mode 100644 index 902ee19..0000000 Binary files a/skia4delphi/Binary/Shared/OSX64/libsk4d.dylib and /dev/null differ diff --git a/skia4delphi/Binary/Shared/OSXARM64/libsk4d.dylib b/skia4delphi/Binary/Shared/OSXARM64/libsk4d.dylib deleted file mode 100644 index 6fe61ac..0000000 Binary files a/skia4delphi/Binary/Shared/OSXARM64/libsk4d.dylib and /dev/null differ diff --git a/skia4delphi/Binary/Shared/iOSSimARM64/libsk4d.dylib b/skia4delphi/Binary/Shared/iOSSimARM64/libsk4d.dylib deleted file mode 100644 index f7d3f87..0000000 Binary files a/skia4delphi/Binary/Shared/iOSSimARM64/libsk4d.dylib and /dev/null differ diff --git a/skia4delphi/LICENSE b/skia4delphi/LICENSE deleted file mode 100644 index edda496..0000000 --- a/skia4delphi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021-2022 Skia4Delphi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/skia4delphi/README.md b/skia4delphi/README.md deleted file mode 100644 index 117648f..0000000 --- a/skia4delphi/README.md +++ /dev/null @@ -1,684 +0,0 @@ -

Logo

- -

- Delphi XE7+ support - Cross-platform support - Console, FMX, VCL support - Telegram group -

- -# - -**[Skia4Delphi](https://skia4delphi.org)** is a cross-platform 2D graphics API for Delphi based on [Google's Skia](https://skia.org/) graphics library. - -https://user-images.githubusercontent.com/1863024/175955980-f6c57253-aaa3-4617-90dc-b0d9bf25e21b.mp4 - -## About - -Skia is a great open source library for drawing 2D Text, Geometries, Images, focused on accurate, high quality and high performance rendering, which provides common APIs that work across a variety of hardware and software platforms. - -Google's Skia Graphics Library serves as the graphics engine for Google Chrome and Chrome OS, Android, Flutter, Xamarin, Mozilla Firefox and Firefox OS, and many other products. - -## Features - -- Canvas 2D and Text Layout; -- CPU software rasterization; -- GPU-accelerated rendering; -- Right-to-Left rendering; -- SVG rendering and creation; -- PDF output; -- Runtime effects; -- Shading language; -- Shaders, mask and color filters; -- Image and path effects; -- Animated image player; (Lottie, GIF, WebP) -- Image codecs; (bmp, gif, ico, jpg, png, wbmp, webp and raw images) -- Particles; (provides a way to quickly generate large numbers of drawing primitives with dynamic, animated behavior) - **and much more...** - -## FMX graphics engine replacement - -Using the **Skia4Delphi** library it is possible to override Firemonkey's rendering engine so that it can use Skia as its default Canvas. With that, your Firemonkey application will automatically: - -- Draw with antialiasing on any platform (the drawing quality is based on the Form.Quality property); -- Increase the overall graphics performance of your application by up to 50% (even drawing with higher quality); -- Resize images with better quality (also based on Form.Quality); -- Support Right-To-Left text rendering; -- Fix dozens of inconsistencies in drawings (especially in corners and strokes, such as dashes, and in texts with special emojis); -- Increase the performance of the library in general ([controls](#controls-vclfmx), drawings, among others...). - -[Learn more...](#fmx-canvas) - -# Summary - -- [Using the library](#using-the-library) - - [Prerequisites](#prerequisites) - - [Install](#install) - - [Enable Skia](#enable-skia) - - [Examples](#examples) - - [Basic usage](#basic-usage) - - [Text Right-to-Left](#text-right-to-left) - - [Custom fonts](#custom-fonts) - - [PDF](#pdf) - - [Codecs](#codecs) -- [Integration with Delphi](#integration-with-delphi) - - [Bitmap](#bitmap) - - [Image formats](#image-formats) - - [FMX Canvas](#fmx-canvas) - - [Enable Canvas](#enable-canvas) - - [Benchmark](#benchmark) - - [Surface](#surface) - - [Controls](#controls) - - [Right-to-Left](#right-to-left) -- [Controls VCL/FMX](#controls-vclfmx) - - [TSkAnimatedImage](#tskanimatedimage) - - [TSkLabel](#tsklabel) - - [TSkPaintBox](#tskpaintbox) - - [TSkSvg](#tsksvg) - - [Limitations](Documents/SVG.md#limitations) -- [Compatibility](#compatibility) -- [Documentation](#documentation) -- [Version](#version) - -# Using the library - -## Prerequisites - -### Install - -You can install **Skia4Delphi** in 3 ways: - -- Setup (recommended) - - Download the setup of [latest release](../../releases/latest) and install it. - - ![Skia4Delphi Installation](Assets/Documents/installation.png) - -- Embarcadero's GetIt _(RAD Studio > Tools > GetIt Package Manager...)_ - -

GetIt

-

GetIt

- -- Chocolatey package manager - - ```batch - choco install skia4delphi - ``` - -#### Remarks - -1. Manual installation is possible, although it is not recommended; [Learn more...](Documents/INSTALLATION.md) -2. The pre-built Skia binaries were included in the source, but you can easily recompile them; [Learn more...](Documents/BUILD.md) - -### Enable Skia - -After install the **Skia4Delphi**, just right click in your application project and click **Enable Skia**. - -![Menu](https://user-images.githubusercontent.com/16469061/153612703-81a9d1f8-8ae4-4977-b58f-6520a8318756.png#gh-light-mode-only) -![Menu](https://user-images.githubusercontent.com/16469061/153612789-38488c75-930a-48ac-8a6b-ea303f403e9e.png#gh-dark-mode-only) - -#### Tip - -To improve the quality and performance of FMX drawings, replace the FMX graphics engine with the **Skia4Delphi** graphic engine. [Learn more...](#fmx-canvas) - -## Examples - -In this section you will find some examples of using **Skia4Delphi**, it works in **Console**, **FMX**, and **VCL** applications. -The code below is common code among all the examples in this section: - -```pascal -uses - Skia; - -type - TSkDrawExampleProc = reference to procedure(const ACanvas: ISkCanvas; const ADest: TRectF); - -procedure DrawExample(const AWidth, AHeight: Integer; const ADrawProc: TSkDrawExampleProc); -var - LSurface: ISkSurface; -begin - LSurface := TSkSurface.MakeRaster(AWidth, AHeight); - LSurface.Canvas.Clear(TAlphaColors.Null); - ADrawProc(LSurface.Canvas, RectF(0, 0, AWidth, AHeight)); - LSurface.MakeImageSnapshot.EncodeToFile('output.png'); -end; -``` - -### Basic usage - -The code below demonstrate how to draw shapes: - -```pascal -DrawExample(256, 256, - procedure (const ACanvas: ISkCanvas; const ADest: TRectF) - var - LOval: ISkRoundRect; - LPaint: ISkPaint; - LRect: TRectF; - begin - LPaint := TSkPaint.Create; - LPaint.AntiAlias := True; - - LPaint.Color := $FF4285F4; - LRect := TRectF.Create(PointF(10, 10), 100, 160); - ACanvas.DrawRect(LRect, LPaint); - - LOval := TSkRoundRect.Create; - LOval.SetOval(LRect); - LOval.Offset(40, 80); - LPaint.Color := $FFDB4437; - ACanvas.DrawRoundRect(LOval, LPaint); - - LPaint.Color := $FF0F9D58; - ACanvas.DrawCircle(180, 50, 25, LPaint); - - LRect.Offset(80, 50); - LPaint.Color := $FFF4B400; - LPaint.Style := TSkPaintStyle.Stroke; - LPaint.StrokeWidth := 4; - ACanvas.DrawRoundRect(LRect, 10, 10, LPaint); - end); -``` - -This code results in the output below: - -

Example 1

- -[Learn more...](Documents/USAGE.md#basic-usage) - -### Text Right-to-Left - -There are a couple of languages that the direction of the text is from right to left such as Persian, Arabic, Hebrew, and more. With **Skia4Delphi** it is possible to render Right-to-Left. The example below demonstrates how to render a Persian sentence using a text-shaping engine: - -```pascal -DrawExample(256, 256, - procedure (const ACanvas: ISkCanvas; const ADest: TRectF) - var - LBlob: ISkTextBlob; - LFont: ISkFont; - LPaint: ISkPaint; - LShaper: ISkShaper; - begin - LFont := TSkFont.Create(TSkTypeface.MakeDefault, 55, 1); - LShaper := TSkShaper.Create; - LBlob := LShaper.Shape('سلام دنیا!', LFont, False, High(Integer)); - - LPaint := TSkPaint.Create; - LPaint.AntiAlias := True; - LPaint.Color := TAlphaColors.Tomato; - - ACanvas.DrawTextBlob(LBlob, 0, 0, LPaint); - end); -``` - -This code results in the output below: - -

Text RTL

- -### Custom fonts - -With **Skia4Delphi** it is possible to use custom fonts easily, from the file, without the need to install it on the operating system, regardless of the platform. The example below will draw using two custom fonts: - -```pascal -DrawExample(256, 256, - procedure (const ACanvas: ISkCanvas; const ADest: TRectF) - var - LFont: ISkFont; - LPaint: ISkPaint; - begin - LFont := TSkFont.Create(TSkTypeface.MakeFromFile('Samples\Demo\Assets\nunito-extrabold.ttf'), 23); - LPaint := TSkPaint.Create; - LPaint.Shader := TSkShader.MakeGradientLinear(PointF(0, 0), PointF(256, 145), $FFFF5F5F, $FF5B8DFE, TSkTileMode.Clamp); - - ACanvas.DrawSimpleText('"Each dream that you', 2, 25, LFont, LPaint); - ACanvas.DrawSimpleText('leave behind is a part', 2, 55, LFont, LPaint); - ACanvas.DrawSimpleText('of your future that will', 2, 85, LFont, LPaint); - ACanvas.DrawSimpleText('no longer exist."', 2, 115, LFont, LPaint); - - LFont := TSkFont.Create(TSkTypeface.MakeFromFile('Samples\Demo\Assets\bonheur-royale-regular.ttf'), 28); - LPaint.Shader := nil; - LPaint.Color := $FF5B8DFE; - ACanvas.DrawSimpleText('(Steve Jobs)', 2, 150, LFont, LPaint); - end); -``` - -This code results in the output below: - -

Text Custom Font

- -### PDF - -With **Skia4Delphi** it is possible to create PDF documents and draw anything on them, from text to images. The example below demonstrates how to create an PDF document and draw an SVG inside it: - -```pascal -var - LCanvas: ISkCanvas; - LDocument: ISkDocument; - LDocumentStream: TStream; - LSVGDOM: ISkSVGDOM; - LSize: TSizeF; -begin - LSVGDOM := TSkSVGDOM.MakeFromFile('Samples\Demo\Assets\lion.svg'); - LSize := TSizeF.Create(600, 600); - LSVGDOM.SetContainerSize(LSize); - - LDocumentStream := TFileStream.Create('output.pdf', fmCreate); - try - LDocument := TSkDocument.MakePDF(LDocumentStream); - try - LCanvas := LDocument.BeginPage(LSize.Width, LSize.Height); - try - LSVGDOM.Render(LCanvas); - finally - LDocument.EndPage; - end; - finally - LDocument.Close; - end; - finally - LDocumentStream.Free; - end; -end; -``` - -This code results in the output below: - -

Lion

- -### Codecs - -The **Skia4Delphi** library supports many image formats. See below the list: - -- Supported formats for decoding - - | Image Format | Extensions | - | ------------------------------ | ----------- | - | Bitmap | .bmp | - | GIF | .gif | - | Icon | .ico | - | JPEG | .jpg, .jpeg | - | PNG | .png | - | Raw Adobe DNG Digital Negative | .dng | - | Raw Canon | .cr2 | - | Raw Fujifilm RAF | .raf | - | Raw Nikon | .nef, .nrw | - | Raw Olympus ORF | .orf | - | Raw Panasonic | .rw2 | - | Raw Pentax PEF | .pef | - | Raw Samsung SRW | .srw | - | Raw Sony | .arw | - | WBMP | .wbmp | - | WebP | .webp | - - _Note: Raw images are limited to non-windows platforms_ - -- Supported formats for encoding - - | Image Format | Extensions | - | ------------ | ----------- | - | JPEG | .jpg, .jpeg | - | PNG | .png | - | WebP | .webp | - -#### About WebP - -WebP is a modern image format that provides superior lossless and lossy compression for images. WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller than comparable JPEG images at equivalent quality. - -The example below demonstrates how to encoder to WebP format: - -```pascal -var - LImage: ISkImage; -begin - LImage := TSkImage.MakeFromEncodedFile('Samples\Demo\Assets\kung-fu-panda.png'); - LImage.EncodeToFile('output.webp', TSkEncodedImageFormat.WEBP, 80); - LImage.EncodeToFile('output.jpg', TSkEncodedImageFormat.JPEG, 80); -end; -``` - -This code results in the output below: - -

King Fu Panda

- -| Format | Size | -| ------------------ | ------ | -| Png (100% quality) | 512 KB | -| Jpeg (80% quality) | 65 KB | -| WebP (80% quality) | 51 KB | - -# Integration with Delphi - -## Bitmap - -It is possible to edit TBitmap (**VCL** or **FMX**) with Skia's Canvas using the code below: - -```pascal -var - LBitmap: TBitmap; -begin - LBitmap := TBitmap.Create(100, 100); - try - LBitmap.SkiaDraw( - procedure (const ACanvas: ISkCanvas) - begin - // Draw with Skia canvas... - end); -``` - -## Image formats - -The library registers the following codecs: - -- **VCL**: .svg, .webp, .wbmp and raw images (.arw, .cr2, .dng, .nef, .nrw, .orf, .raf, .rw2, .pef and .srw). - -- **FMX**: .bmp, .gif, .ico, .webp, .wbmp and raw images (.arw, .cr2, .dng, .nef, .nrw, .orf, .raf, .rw2, .pef and .srw). - -As a result, any Delphi control, such as a TImage, can normally load these new formats. - -## FMX Canvas - -It is possible to replace the default Canvas from FMX to Skia based Canvas. Once this feature is enabled, all FMX controls will be painted using Skia4Delphi automatically. With that it is possible to improve the quality and performance of the drawings for the FMX as well as for the whole library. - -### Enable Canvas - -Open the source of your Delphi Application Project _(.dpr)_, include the `Skia.FMX` unit **after** the `FMX.Forms` unit, and set the `GlobalUseSkia` to **True**, as in the example below: - -```pascal -uses - System.StartUpCopy, - FMX.Forms, - Skia.FMX, - Unit1 in 'Unit1.pas' {Form1}; - -{$R *.res} - -begin - GlobalUseSkia := True; - Application.Initialize; - ... -``` - -#### Remarks - -1. `Skia.FMX` unit must be included after the `FMX.Forms`; -2. The **Metal** implementation is experimental, but can be used by including the `FMX.Types` unit **after** the `FMX.Forms` unit, and setting `GlobalUseMetal` to **True** together with `GlobalUseSkia`; -3. `GlobalUseSkia` has no effect on Linux. (although not supported, all [controls](#controls-vclfmx) work perfectly) -4. This declaration of `GlobalUseSkia := True;`, as well as other variables of FMX itself, such as `GlobalUseMetal`, can also be made in the initialization of some unit instead of .dpr. Sometimes this is really necessary because if in the initialization or in the class constructor of some unit, bitmaps are used, the GlobalUseXXX declarations of the .dpr will have no effect. In this case, just create a unit in the project like "Project.Startup.pas", place the GlobalUseXXX declarations in the initialization of this new unit, and declare this new unit before any other unit of yours in the .dpr, that is, right after FMX.Forms. - -### Benchmark - -The performance test is a simulation of a real application, with hundreds of controls, to measure the FPS rate when sliding a vertical scroll. - -| Device | Platform | FMX | Skia | -| ------------------------------------- | ----------- | -----: | --------: | -| Motorola Moto 3rd Generation | Android | 25 fps | 38 fps | -| LG K40s | Android | 30 fps | 47 fps | -| Samsung Galaxy A01 Core | Android | 20 fps | 26 fps | -| Samsung Galaxy S7 Edge | Android64 | 53 fps | 56 fps | -| Samsung Galaxy S8 Plus | Android64 | 50 fps | 55 fps | -| Apple iPhone 11 | iOSDevice64 | 59 fps | 60 fps | -| Apple iPhone 12 | iOSDevice64 | 59 fps | 59 fps | -| Apple MacBook Air Model A2337 | OSXARM64 | 58 fps | 30 fps \* | -| Intel Core i7-8565U / Radeon 520 | Win32 | 82 fps | 92 fps | -| Intel Core i7-8565U / Radeon 520 | Win64 | 83 fps | 91 fps | -| Intel Core i7-4500U / GeForce GT 720M | Win32 | 85 fps | 92 fps | -| Intel Core i7-4500U / GeForce GT 720M | Win64 | 86 fps | 93 fps | - -#### Metal - -| Device | Platform | FMX | Skia | -| ----------------------------- | ----------- | -----: | -----: | -| Apple iPhone 11 | iOSDevice64 | 59 fps | 60 fps | -| Apple iPhone 12 | iOSDevice64 | 59 fps | 59 fps | -| Apple MacBook Air Model A2337 | OSXARM64 | 60 fps | 60 fps | - -#### Remarks - -1. Delphi's `TGPUCanvas` (default Canvas used on cell phones, as well as Apple computers when Metal is enabled) does not use anti-aliasing (anti-aliasing is a technique that improves the quality of diagonal lines) while Skia uses it. That is, Skia has better performance and quality in the drawings than default FMX Canvas. - - | FMX circle | Skia circle | - | ---------------------------------------------- | ------------------------------------------------ | - | ![FMX Circle](Assets/Documents/fmx-circle.png) | ![Skia Circle](Assets/Documents/skia-circle.png) | - -2. Firemonkey uses Quartz on macOS, and for **Skia4Delphi** use OpenGL it would be necessary to edit the Delphi runtime library, so we choose to keep the rasterization method and not implement OpenGL on macOS. In the future it is likely that we will set Metal as default, as OpenGL is deprecated in Apple's operating systems. For those who want to use the Skia Canvas on macOS we recommend enabling Metal. - -3. Tests made from virtual machines are inconsistent with reality. - -### Surface - -Using Skia's Canvas, during the Scene of a Bitmap or Control (between the `BeginScene` and `EndScene` calls), it is possible to access the `Surface` property as follows: - -```pascal -uses - Skia, - Skia.FMX.Graphics; - -var - LBitmap: TBitmap; - LCanvas: ISkCanvas; -begin - LBitmap := TBitmap.Create(300, 300); - try - if LBitmap.Canvas.BeginScene then - begin - try - LCanvas := TSkCanvasCustom(LBitmap.Canvas).Surface.Canvas; - // Draw with LCanvas... - finally - LBitmap.Canvas.EndScene; - end; - end; - finally - LBitmap.Free; - end; -end; -``` - -#### Remarks - -1. `Surface` property will only be available during Scene (between the `BeginScene` and `EndScene` calls); -2. Canvas for UI (created from a window _eg rectangles, circles, objects inherited from TControl_) must draw exclusively from the **main thread**, while Canvas created from `TBitmap` are **thread safe**. - -#### Tip - -If your app has background threads that do a lot of bitmap drawings, be aware that it is safe to remove the global lock from the `TCanvas` base class when Skia based Canvas is enabled, to allow your app to do truly parallel drawings, gaining a lot of performance. For that, it is necessary to make a patch in the units `FMX.Graphics.pas` and `FMX.TextLayout.pas`. [Learn more](https://quality.embarcadero.com/browse/RSP-37232) - -### Controls - -Using Skia's Canvas, it is possible to access the Surface property from the `Paint` procedure of a control, to draw directly using Skia, as shown below: - -```pascal -unit Unit1; - -interface - -uses - FMX.Controls, - FMX.Graphics, - Skia, - Skia.FMX.Graphics; - - -type - TControl1 = class(TControl) - protected - procedure Paint; override; - end; - -implementation - -{ TControl1 } - -procedure TControl1.Paint; -var - LCanvas: ISkCanvas; -begin - LCanvas := TSkCanvasCustom(Canvas).Surface.Canvas; - // Draw with LCanvas... -end; -``` - -### Right-to-Left - -Using Skia's Canvas, your application will now support Right-To-Left text rendering. But for that you will need to make 3 changes to your project: - -1. Open the source of your Delphi Application Project _(.dpr)_, include the line `Application.BiDiMode := TBiDiMode.bdRightToLeft;`, like below: - -```pascal -program Project1; - -uses - System.StartUpCopy, - FMX.Forms, - System.Classes, - Skia.FMX, - Unit1 in 'Unit1.pas' {Form1}; - -{$R *.res} - -begin - Application.BiDiMode := TBiDiMode.bdRightToLeft; - GlobalUseSkia := True; - Application.Initialize; - Application.CreateForm(TForm1, Form1); - Application.Run; -end. -``` - -2. Set the property `BiDiMode` of your forms to `bdRightToLeft`; -3. Keyboard input controls like TEdit and TMemo, need to be fixed by Embarcadero, meanwhile, as a workaround, set the `ControlType` property of these controls to `Platform`. - -# Controls VCL/FMX - -## TSkAnimatedImage - -**TSkAnimatedImage** is the control that can load and render animated images, including vector animations, in a very simple way. The supported formats are: - -| Format | Extensions | -| ---------------- | -------------- | -| Lottie file | .json, .lottie | -| Telegram Sticker | .tgs | -| Animated GIF | .gif | -| Animated WebP | .webp | - -The example below demonstrates how to play lottie files using **TSkAnimatedImage**: - -```pascal -var - LAnimatedImage: TSkAnimatedImage; -begin - LAnimatedimage := TSkAnimatedImage.Create(Self); - LAnimatedimage.LoadFromFile('Samples\Demo\Assets\rocket.json'); - LAnimatedimage.Parent := Self; -end; -``` - -The example above results in the output below: - -![Rocket](Assets/Documents/rocket.webp) - -[Learn more...](Documents/ANIMATED-IMAGES.md#TSkAnimatedImage) - -## TSkLabel - -**TSkLabel** is the control that implements the SkParagraph internally, having several more features than the TLabel, such as: - -- Font families; (font fallback list like in css) -- Font weight; -- Font slant; -- Support for multiple styles in text; -- Support for BiDi; (Right-to-Left) -- Support justify horizontal alignment; -- Support custom font; (without install the font) -- Supports background color on parts of the text; -- Limit the maximum number of lines; -- Auto size option; (width and height) -- Advanced decorations; (like underline wavy, overline, dashed line, among others...) - **and much more...** - -![Label](https://user-images.githubusercontent.com/16469061/153615162-e2f51dd6-b22e-4f34-9493-244122faa5ae.png#gh-light-mode-only) -![Label](https://user-images.githubusercontent.com/16469061/153615217-53e851a3-c20d-4cb9-92fb-b9b18319c342.png#gh-dark-mode-only) - -[Learn more...](Documents/LABEL.md#tsklabel) - -## TSkPaintBox - -**TSkPaintBox** is the ideal control for painting with skia api directly on the canvas with the event `OnDraw`: - -```pascal -procedure TForm1.SkPaintBox1Draw(ASender: TObject; const ACanvas: ISkCanvas; - const ADest: TRectF; const AOpacity: Single); -var - LPaint: ISkPaint; -begin - LPaint := TSkPaint.Create; - LPaint.Shader := TSkShader.MakeGradientSweep(ADest.CenterPoint, - [$FFFCE68D, $FFF7CAA5, $FF2EBBC1, $FFFCE68D]); - ACanvas.DrawPaint(LPaint); -end; -``` - -The example above results in the output below: - -![Paint Box](Assets/Documents/paintbox.png) - -_Note: The TSkPaintBox has a drawing caching system. To force a drawing refresh, call TSkPaintBox.Redraw. However, this cache system does not exist in FMX apps that have enabled [Skia4Delphi graphic engine](#fmx-canvas) for optimization reasons._ - -## TSkSvg - -**TSkSvg** is the control to load and display SVG easily: - -```pascal -var - LSvg: TSkSvg; -begin - LSvg := TSkSvg.Create(Self); - LSvg.Svg.Source := TFile.ReadAllText('Samples\Demo\Assets\gorilla.svg'); - LSvg.Parent := Self; -end; -``` - -The example above results in the output below: - -

Gorilla

- -[Learn more...](Documents/SVG.md) - -# Compatibility - -| RAD Studio | Platforms | -| ---------------------------- | ---------------- | -| RAD Studio 11 Alexandria | All Platforms | -| RAD Studio 10.3 Rio or newer | Windows, Android | -| RAD Studio XE7 or newer | Windows | - -For the platforms supported by **Skia4Delphi** (listed above), the OS versions supported by the library are the same [OS versions that RAD Studio supports.](https://docwiki.embarcadero.com/PlatformStatus/en/Main_Page) - -# Documentation - -The APIs are very similar to Skia's, few methods and functions have been renamed for readability, so the [Skia documentation](https://skia.org/docs) can be used. - -# Version - -**[Skia4Delphi 4.0.2](/../../releases/latest)** - -Skia Version used: [chrome/m107](https://github.com/google/skia/tree/chrome/m107) - -# Sponsors & Partners - -

- - A-dato logo - - DelphiStyles logo -

- -# Contributors - - - - - -# - -Help us responding a small questionnaire about our users in [this link](https://form.typeform.com/to/Qc6o3ELs) diff --git a/skia4delphi/Source/FMX/Skia.FMX.Canvas.GL.pas b/skia4delphi/Source/FMX/Skia.FMX.Canvas.GL.pas deleted file mode 100644 index 2368109..0000000 --- a/skia4delphi/Source/FMX/Skia.FMX.Canvas.GL.pas +++ /dev/null @@ -1,814 +0,0 @@ -{************************************************************************} -{ } -{ Skia4Delphi } -{ } -{ Copyright (c) 2011-2022 Google LLC. } -{ Copyright (c) 2021-2022 Skia4Delphi Project. } -{ } -{ Use of this source code is governed by a BSD-style license that can be } -{ found in the LICENSE file. } -{ } -{************************************************************************} -unit Skia.FMX.Canvas.GL; - -interface - -{$SCOPEDENUMS ON} - -{$IF DEFINED(MSWINDOWS) or DEFINED(ANDROID) or DEFINED(IOS)} - -uses - { Delphi } - FMX.Graphics, - FMX.Types, - System.Types, - {$IF DEFINED(MSWINDOWS)} - Winapi.Windows, - {$ELSEIF DEFINED(ANDROID)} - Androidapi.Egl, - Androidapi.NativeWindow, - {$ELSEIF DEFINED(IOS)} - iOSapi.OpenGLES, - {$ENDIF} - - { Skia } - Skia, - Skia.FMX.Graphics; - -type -{$IF DEFINED(MSWINDOWS)} - - { TGlBackendContext } - - TGlBackendContext = record - DC: HDC; - GLRC: HGLRC; - end; - - { TGlSharedResources } - - TGlSharedResources = class(TGrCanvasSharedResources) - strict private - FContext: TGlBackendContext; - FGrGlInterface: IGrGlInterface; - FOldContext: TGlBackendContext; - FWindow: HWND; - strict protected - procedure AfterBeginContext; override; - procedure BeforeEndContext; override; - procedure FinalizeSharedResources; override; - procedure InitializeContext(out ASharedGrDirectContext: IGrDirectContext); override; - procedure InitializeSharedResources; override; - public - property Context: TGlBackendContext read FContext; - property GrGlInterface: IGrGlInterface read FGrGlInterface; - end; - - { TGlContext } - - TGlContext = record - strict private - FContext: TGlBackendContext; - FOldContext: TGlBackendContext; - public - procedure Finalize(const ASharedSharedResources: IGrCanvasSharedResources; const AWindow: TWindowHandle); - function Initialize(const ASharedSharedResources: IGrCanvasSharedResources; const AWindow: TWindowHandle): Boolean; - function MakeContextCurrent(const ASharedSharedResources: IGrCanvasSharedResources): Boolean; - procedure RestoreContext(const ASharedSharedResources: IGrCanvasSharedResources); - procedure SaveContext(const ASharedSharedResources: IGrCanvasSharedResources); - procedure SwapBuffers(const ASharedSharedResources: IGrCanvasSharedResources); - property Context: TGlBackendContext read FContext; - end; - -{$ELSEIF DEFINED(ANDROID)} - - { TGlBackendContext } - - TGlBackendContext = record - Draw: EGLSurface; - Read: EGLSurface; - Context: EGLContext; - end; - - { TGlSharedResources } - - TGlSharedResources = class(TGrCanvasSharedResources) - strict private - FContext: TGlBackendContext; - FDisplay: EGLDisplay; - FGrGlInterface: IGrGlInterface; - FOldContext: TGlBackendContext; - strict protected - procedure AfterBeginContext; override; - procedure BeforeEndContext; override; - procedure FinalizeSharedResources; override; - procedure InitializeContext(out ASharedGrDirectContext: IGrDirectContext); override; - procedure InitializeSharedResources; override; - public - property Context: TGlBackendContext read FContext; - property Display: EGLDisplay read FDisplay; - property GrGlInterface: IGrGlInterface read FGrGlInterface; - end; - - { TGlContext } - - TGlContext = record - strict private - FANativeWindow: PANativeWindow; - FContext: TGlBackendContext; - FOldContext: TGlBackendContext; - public - procedure Finalize(const ASharedSharedResources: IGrCanvasSharedResources; const AWindow: TWindowHandle); - function Initialize(const ASharedSharedResources: IGrCanvasSharedResources; const AWindow: TWindowHandle): Boolean; - function MakeContextCurrent(const ASharedSharedResources: IGrCanvasSharedResources): Boolean; - procedure RestoreContext(const ASharedSharedResources: IGrCanvasSharedResources); - procedure SaveContext(const ASharedSharedResources: IGrCanvasSharedResources); - procedure SwapBuffers(const ASharedSharedResources: IGrCanvasSharedResources); - property Context: TGlBackendContext read FContext; - end; - -{$ELSEIF DEFINED(IOS)} - - TGlBackendContext = EAGLContext; - - { TGlSharedResources } - - TGlSharedResources = class(TGrCanvasSharedResources) - strict private - FContext: TGlBackendContext; - FGrGlInterface: IGrGlInterface; - FLibModule: HMODULE; - FOldContext: TGlBackendContext; - strict protected - procedure AfterBeginContext; override; - procedure BeforeEndContext; override; - procedure FinalizeSharedResources; override; - procedure InitializeContext(out ASharedGrDirectContext: IGrDirectContext); override; - procedure InitializeSharedResources; override; - public - property Context: TGlBackendContext read FContext; - property GrGlInterface: IGrGlInterface read FGrGlInterface; - end; - - { TGlContext } - - TGlContext = record - strict private - FContext: TGlBackendContext; - FOldContext: TGlBackendContext; - public - procedure Finalize(const ASharedSharedResources: IGrCanvasSharedResources; const AWindow: TWindowHandle); - function Initialize(const ASharedSharedResources: IGrCanvasSharedResources; const AWindow: TWindowHandle): Boolean; - function MakeContextCurrent(const ASharedSharedResources: IGrCanvasSharedResources): Boolean; - procedure RestoreContext(const ASharedSharedResources: IGrCanvasSharedResources); - procedure SaveContext(const ASharedSharedResources: IGrCanvasSharedResources); - procedure SwapBuffers(const ASharedSharedResources: IGrCanvasSharedResources); - property Context: TGlBackendContext read FContext; - end; - -{$ENDIF} - - { TGlCanvas } - - TGlCanvas = class(TGrCanvas) - strict private - FContext: TGlContext; - FSampleCount: Integer; - strict protected - procedure BeforeRestore; override; - function CreateSurfaceFromWindow(var AGrDirectContext: IGrDirectContext): ISkSurface; override; - procedure DestroyContext; override; - procedure DoDrawBitmap(const ABitmap: FMX.Graphics.TBitmap; const ASrcRect, ADestRect: TRectF; const AOpacity: Single; const AHighSpeed: Boolean); override; - procedure DoEndScene; override; - class procedure InitializeSharedResources(out ASharedResources: IGrCanvasSharedResources); override; - public - destructor Destroy; override; - end; - -{$ENDIF} - -implementation - -{$IF DEFINED(MSWINDOWS) or DEFINED(ANDROID) or DEFINED(IOS)} - -uses - { Delphi } - System.SysUtils, - {$IF DEFINED(MSWINDOWS)} - FMX.Platform.Win, - Winapi.OpenGL, - Winapi.OpenGLext; - {$ELSEIF DEFINED(ANDROID)} - Androidapi.Gles2, - Androidapi.JNI.GraphicsContentViewText, - Androidapi.JNIBridge, - Androidapi.NativeWindowJni, - FMX.Platform.UI.Android, - FMX.Presentation.Android.Style; - {$ELSEIF DEFINED(IOS)} - FMX.Platform.iOS, - iOSapi.GLKit, - Macapi.ObjectiveC; - {$ENDIF} - -{$IF DEFINED(MSWINDOWS)} - -const - WGL_CONTEXT_CORE_PROFILE_BIT_ARB = $00000001; - WGL_CONTEXT_MAJOR_VERSION_ARB = $2091; - WGL_CONTEXT_MINOR_VERSION_ARB = $2092; - WGL_CONTEXT_PROFILE_MASK_ARB = $9126; - - PixelFormatDescriptor: TPixelFormatDescriptor = ( - nSize : SizeOf(TPixelFormatDescriptor); - nVersion : 1; - dwFlags : PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER; - iPixelType : PFD_TYPE_RGBA; - cColorBits : 24; - cRedBits : 0; - cRedShift : 0; - cGreenBits : 0; - cGreenShift : 0; - cBlueBits : 0; - cBlueShift : 0; - cAlphaBits : 8; - cAlphaShift : 0; - cAccumBits : 0; - cAccumRedBits : 0; - cAccumGreenBits : 0; - cAccumBlueBits : 0; - cAccumAlphaBits : 0; - cDepthBits : 24; - cStencilBits : 8; - cAuxBuffers : 0; - iLayerType : PFD_MAIN_PLANE; - bReserved : 0; - dwLayerMask : 0; - dwVisibleMask : 0; - dwDamageMask : 0); - -var - PixelFormat: Integer; - - ContextAttributes: array[0..6] of GLInt = ( - WGL_CONTEXT_MAJOR_VERSION_ARB , -1 , - WGL_CONTEXT_MINOR_VERSION_ARB , -1 , - WGL_CONTEXT_PROFILE_MASK_ARB , WGL_CONTEXT_CORE_PROFILE_BIT_ARB , - GL_NONE); - - wglCreateContextAttribsARB: function (hDC: HDC; hShareContext: HGLRC; const attribList: PInteger): HGLRC; stdcall; - -{ TGlSharedResources } - -procedure TGlSharedResources.AfterBeginContext; -begin - FOldContext.DC := wglGetCurrentDC; - FOldContext.GLRC := wglGetCurrentContext; - if not wglMakeCurrent(FContext.DC, FContext.GLRC) then - raise EGrCanvas.Create('Could not make the shared context as current.'); -end; - -procedure TGlSharedResources.BeforeEndContext; -begin - wglMakeCurrent(FOldContext.DC, FOldContext.GLRC); -end; - -procedure TGlSharedResources.FinalizeSharedResources; -begin - wglDeleteContext(FContext.GLRC); - ReleaseDC(FWindow, FContext.DC); - DestroyWindow(FWindow); - Winapi.Windows.UnregisterClass('SkClass', HInstance); -end; - -procedure TGlSharedResources.InitializeContext( - out ASharedGrDirectContext: IGrDirectContext); -begin - FGrGlInterface := TGrGlInterface.MakeNative; - ASharedGrDirectContext := TGrDirectContext.MakeGl(FGrGlInterface); -end; - -procedure TGlSharedResources.InitializeSharedResources; -const - CoreVersions: array[0..11] of GLInt = ( - 4, 3, - 4, 2, - 4, 1, - 4, 0, - 3, 3, - 3, 2); -var - I: Integer; - LClass: TWndClass; - LGLRC: HGLRC; - LOldContext: TGlBackendContext; -begin - FillChar(LClass, SizeOf(TWndClass), 0); - LClass.lpfnWndProc := @DefWindowProc; - LClass.hInstance := HInstance; - LClass.lpszClassName := 'SkClass'; - if Winapi.Windows.RegisterClass(LClass) = 0 then - raise EGrCanvas.Create('Could not register the dummy class.'); - FWindow := CreateWindowEx(WS_EX_TOOLWINDOW, 'SkClass', nil, WS_POPUP, 0, 0, 0, 0, 0, 0, HInstance, nil); - if FWindow = 0 then - raise EGrCanvas.Create('Could not create the dummy window.'); - try - FContext.DC := GetDC(FWindow); - if FContext.DC = 0 then - raise EGrCanvas.Create('Could not get a DC from the dummy window.'); - try - PixelFormat := ChoosePixelFormat(FContext.DC, @PixelFormatDescriptor); - if (PixelFormat = 0) or (not SetPixelFormat(FContext.DC, PixelFormat, @PixelFormatDescriptor)) then - raise EGrCanvas.Create('Could not choose/set pixel format for the dummy window DC.'); - LGLRC := wglCreateContext(FContext.DC); - if LGLRC = 0 then - raise EGrCanvas.Create('Could not create the dummy context.'); - try - LOldContext.DC := wglGetCurrentDC; - LOldContext.GLRC := wglGetCurrentContext; - if not wglMakeCurrent(FContext.DC, LGLRC) then - raise EGrCanvas.Create('Could not make the dummy context as current.'); - try - wglCreateContextAttribsARB := wglGetProcAddress('wglCreateContextAttribsARB'); - finally - wglMakeCurrent(LOldContext.DC, LOldContext.GLRC); - end; - if Assigned(wglCreateContextAttribsARB) then - begin - for I := 0 to Length(CoreVersions) div 2 - 1 do - begin - ContextAttributes[1] := CoreVersions[I * 2]; - ContextAttributes[3] := CoreVersions[I * 2 + 1]; - FContext.GLRC := wglCreateContextAttribsARB(FContext.DC, 0, @ContextAttributes[0]); - if FContext.GLRC <> 0 then - begin - wglDeleteContext(LGLRC); - Exit; - end; - end; - wglCreateContextAttribsARB := nil; - end; - FContext.GLRC := LGLRC; - except - wglDeleteContext(LGLRC); - raise; - end; - except - ReleaseDC(FWindow, FContext.DC); - raise; - end; - except - DestroyWindow(FWindow); - raise; - end; -end; - -{ TGlContext } - -procedure TGlContext.Finalize( - const ASharedSharedResources: IGrCanvasSharedResources; - const AWindow: TWindowHandle); -begin - if FContext.GLRC <> 0 then - begin - wglDeleteContext(FContext.GLRC); - ReleaseDC(WindowHandleToPlatform(AWindow).Wnd, FContext.DC); - end; -end; - -function TGlContext.Initialize( - const ASharedSharedResources: IGrCanvasSharedResources; - const AWindow: TWindowHandle): Boolean; -begin - if FContext.GLRC = 0 then - begin - if WindowHandleToPlatform(AWindow).Wnd = 0 then - Exit(False); - FContext.DC := GetDC(WindowHandleToPlatform(AWindow).Wnd); - if FContext.DC = 0 then - Exit(False); - SetPixelFormat(FContext.DC, PixelFormat, @PixelFormatDescriptor); - if Assigned(wglCreateContextAttribsARB) then - begin - FContext.GLRC := wglCreateContextAttribsARB(FContext.DC, TGlSharedResources(ASharedSharedResources).Context.GLRC, @ContextAttributes[0]); - if FContext.GLRC = 0 then - begin - ReleaseDC(WindowHandleToPlatform(AWindow).Wnd, FContext.DC); - Exit(False); - end; - end - else - begin - FContext.GLRC := wglCreateContext(FContext.DC); - if FContext.GLRC = 0 then - begin - ReleaseDC(WindowHandleToPlatform(AWindow).Wnd, FContext.DC); - Exit(False); - end; - wglShareLists(TGlSharedResources(ASharedSharedResources).Context.GLRC, FContext.GLRC); - end; - end; - Result := True; -end; - -function TGlContext.MakeContextCurrent( - const ASharedSharedResources: IGrCanvasSharedResources): Boolean; -begin - Result := wglMakeCurrent(FContext.DC, FContext.GLRC); -end; - -procedure TGlContext.RestoreContext( - const ASharedSharedResources: IGrCanvasSharedResources); -begin - wglMakeCurrent(FOldContext.DC, FOldContext.GLRC); -end; - -procedure TGlContext.SaveContext( - const ASharedSharedResources: IGrCanvasSharedResources); -begin - FOldContext.DC := wglGetCurrentDC; - FOldContext.GLRC := wglGetCurrentContext; -end; - -procedure TGlContext.SwapBuffers( - const ASharedSharedResources: IGrCanvasSharedResources); -begin - if not Winapi.Windows.SwapBuffers(FContext.DC) then - raise EGrCanvas.Create('Could not swap buffers.'); -end; - -{$ELSEIF DEFINED(ANDROID)} - -const - ContextAttributes: array[0..2] of EGLint = (EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE); - -var - Config: EGLConfig; - -{ TGlSharedResources } - -procedure TGlSharedResources.AfterBeginContext; -begin - if eglGetCurrentDisplay = FDisplay then - begin - FOldContext.Draw := eglGetCurrentSurface(EGL_DRAW); - FOldContext.Read := eglGetCurrentSurface(EGL_READ); - FOldContext.Context := eglGetCurrentContext; - end - else - begin - FOldContext.Draw := EGL_NO_SURFACE; - FOldContext.Read := EGL_NO_SURFACE; - FOldContext.Context := EGL_NO_CONTEXT; - end; - if eglMakeCurrent(FDisplay, FContext.Draw, FContext.Read, FContext.Context) = EGL_FALSE then - raise EGrCanvas.Create('Could not make the shared context as current.'); -end; - -procedure TGlSharedResources.BeforeEndContext; -begin - eglMakeCurrent(FDisplay, FOldContext.Draw, FOldContext.Read, FOldContext.Context); -end; - -procedure TGlSharedResources.FinalizeSharedResources; -begin - eglDestroyContext(FDisplay, FContext.Context); - eglDestroySurface(FDisplay, FContext.Draw); - eglTerminate(FDisplay); -end; - -procedure TGlSharedResources.InitializeContext( - out ASharedGrDirectContext: IGrDirectContext); -begin - FGrGlInterface := TGrGlInterface.MakeNative; - ASharedGrDirectContext := TGrDirectContext.MakeGl(FGrGlInterface); -end; - -procedure TGlSharedResources.InitializeSharedResources; -const - ConfigAttributes: array[0..16] of EGLint = ( - EGL_RENDERABLE_TYPE , EGL_OPENGL_ES2_BIT , - EGL_SURFACE_TYPE , EGL_WINDOW_BIT or EGL_PBUFFER_BIT , - EGL_RED_SIZE , 8 , - EGL_GREEN_SIZE , 8 , - EGL_BLUE_SIZE , 8 , - EGL_ALPHA_SIZE , 8 , - EGL_DEPTH_SIZE , 24 , - EGL_STENCIL_SIZE , 8 , - EGL_NONE); - - SurfaceAttributes: array[0..4] of EGLint = (EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE); -var - LNumConfig: EGLint; -begin - FDisplay := eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (FDisplay = EGL_NO_DISPLAY) or (eglInitialize(FDisplay, nil, nil) = EGL_FALSE) then - raise EGrCanvas.Create('Could not initialize the default display.'); - try - if eglChooseConfig(FDisplay, @ConfigAttributes[0], @Config, 1, @LNumConfig) = EGL_FALSE then - raise EGrCanvas.Create('Could not get frame buffer configurations list.'); - FContext.Draw := eglCreatePbufferSurface(FDisplay, Config, @SurfaceAttributes[0]); - if FContext.Draw = EGL_NO_SURFACE then - raise EGrCanvas.Create('Could not create a new pixel buffer surface.'); - try - FContext.Read := FContext.Draw; - FContext.Context := eglCreateContext(FDisplay, Config, EGL_NO_CONTEXT, @ContextAttributes[0]); - if FContext.Context = EGL_NO_CONTEXT then - raise EGrCanvas.Create('Could not create the shared context.'); - except - eglDestroySurface(FDisplay, FContext.Draw); - raise; - end; - except - eglTerminate(FDisplay); - raise; - end; -end; - -{ TGlContext } - -procedure TGlContext.Finalize( - const ASharedSharedResources: IGrCanvasSharedResources; - const AWindow: TWindowHandle); -begin - if FContext.Draw <> EGL_NO_SURFACE then - begin - eglDestroyContext(TGlSharedResources(ASharedSharedResources).Display, FContext.Context); - eglDestroySurface(TGlSharedResources(ASharedSharedResources).Display, FContext.Draw); - ANativeWindow_release(FANativeWindow); - end; -end; - -function TGlContext.Initialize( - const ASharedSharedResources: IGrCanvasSharedResources; - const AWindow: TWindowHandle): Boolean; -var - LANativeWindowSurface: JSurface; - LANativeWindowSurfaceID: Pointer; -begin - if FContext.Draw = EGL_NO_SURFACE then - begin - if AWindow is TAndroidWindowHandle then - begin - if TAndroidWindowHandle(AWindow).Holder = nil then - Exit(False); - LANativeWindowSurfaceID := (TAndroidWindowHandle(AWindow).Holder.getSurface as ILocalObject).GetObjectID; - end - else if AWindow is TAndroidHandle then - begin - if TAndroidHandle(AWindow).Surface = nil then - Exit(False); - LANativeWindowSurface := TJSurface.JavaClass.init(TAndroidHandle(AWindow).Surface); - LANativeWindowSurfaceID := TJNIResolver.JavaInstanceToID(LANativeWindowSurface); - end - else - Exit(False); - FANativeWindow := ANativeWindow_fromSurface(TJNIResolver.GetJNIEnv, LANativeWindowSurfaceID); - if FANativeWindow = nil then - Exit(False); - if ANativeWindow_setBuffersGeometry(FANativeWindow, 0, 0, WINDOW_FORMAT_RGBA_8888) <> 0 then - begin - ANativeWindow_release(FANativeWindow); - Exit(False); - end; - FContext.Draw := eglCreateWindowSurface(TGlSharedResources(ASharedSharedResources).Display, Config, FANativeWindow, nil); - if FContext.Draw = EGL_NO_SURFACE then - begin - ANativeWindow_release(FANativeWindow); - Exit(False); - end; - FContext.Context := eglCreateContext(TGlSharedResources(ASharedSharedResources).Display, Config, TGlSharedResources(ASharedSharedResources).Context.Context, @ContextAttributes[0]); - if FContext.Context = EGL_NO_CONTEXT then - begin - eglDestroySurface(TGlSharedResources(ASharedSharedResources).Display, FContext.Draw); - FContext.Draw := EGL_NO_SURFACE; - ANativeWindow_release(FANativeWindow); - Exit(False); - end; - FContext.Read := FContext.Draw; - end; - Result := True; -end; - -function TGlContext.MakeContextCurrent( - const ASharedSharedResources: IGrCanvasSharedResources): Boolean; -begin - Result := eglMakeCurrent(TGlSharedResources(ASharedSharedResources).Display, FContext.Draw, FContext.Read, FContext.Context) <> EGL_FALSE; -end; - -procedure TGlContext.RestoreContext( - const ASharedSharedResources: IGrCanvasSharedResources); -begin - eglMakeCurrent(TGlSharedResources(ASharedSharedResources).Display, FOldContext.Draw, FOldContext.Read, FOldContext.Context); -end; - -procedure TGlContext.SaveContext( - const ASharedSharedResources: IGrCanvasSharedResources); -begin - if eglGetCurrentDisplay = TGlSharedResources(ASharedSharedResources).Display then - begin - FOldContext.Draw := eglGetCurrentSurface(EGL_DRAW); - FOldContext.Read := eglGetCurrentSurface(EGL_READ); - FOldContext.Context := eglGetCurrentContext; - end - else - begin - FOldContext.Draw := EGL_NO_SURFACE; - FOldContext.Read := EGL_NO_SURFACE; - FOldContext.Context := EGL_NO_CONTEXT; - end; -end; - -procedure TGlContext.SwapBuffers( - const ASharedSharedResources: IGrCanvasSharedResources); -begin - if eglSwapBuffers(TGlSharedResources(ASharedSharedResources).Display, FContext.Draw) = EGL_FALSE then - raise EGrCanvas.Create('Could not swap buffers.'); -end; - -{$ELSEIF DEFINED(IOS)} - -{ TGlSharedResources } - -procedure TGlSharedResources.AfterBeginContext; -begin - FOldContext := TEAGLContext.Wrap(TEAGLContext.OCClass.currentContext); - if not TEAGLContext.OCClass.setCurrentContext(FContext) then - raise EGrCanvas.Create('Could not make the shared context as current.'); -end; - -procedure TGlSharedResources.BeforeEndContext; -begin - TEAGLContext.OCClass.setCurrentContext(FOldContext); -end; - -procedure TGlSharedResources.FinalizeSharedResources; -begin - FContext.release; - FreeLibrary(FLibModule); -end; - -procedure TGlSharedResources.InitializeContext( - out ASharedGrDirectContext: IGrDirectContext); -begin - FGrGlInterface := TGrGlInterface.MakeNative; - ASharedGrDirectContext := TGrDirectContext.MakeGl(FGrGlInterface); -end; - -procedure TGlSharedResources.InitializeSharedResources; -begin - FLibModule := SafeLoadLibrary(libGLKit); - if FLibModule = 0 then - raise EGrCanvas.Create('Could not load "GLKit" framework.'); - try - FContext := TEAGLContext.Wrap(TEAGLContext.Alloc.initWithAPI(kEAGLRenderingAPIOpenGLES2)); - if FContext = nil then - raise EGrCanvas.Create('Could not create the shared context.'); - except - FreeLibrary(FLibModule); - raise; - end; -end; - -{ TGlContext } - -procedure TGlContext.Finalize( - const ASharedSharedResources: IGrCanvasSharedResources; - const AWindow: TWindowHandle); -begin - if FContext <> nil then - FContext.release; -end; - -function TGlContext.Initialize( - const ASharedSharedResources: IGrCanvasSharedResources; - const AWindow: TWindowHandle): Boolean; -begin - if FContext = nil then - begin - if WindowHandleToPlatform(AWindow).View = nil then - Exit(False); - FContext := TEAGLContext.Wrap(TEAGLContext.Alloc.initWithAPI(kEAGLRenderingAPIOpenGLES2, TGlSharedResources(ASharedSharedResources).Context.sharegroup)); - if FContext = nil then - Exit(False); - GLKView(WindowHandleToPlatform(AWindow).View).setContext(FContext); - GLKView(WindowHandleToPlatform(AWindow).View).bindDrawable; - end; - Result := True; -end; - -function TGlContext.MakeContextCurrent( - const ASharedSharedResources: IGrCanvasSharedResources): Boolean; -begin - Result := TEAGLContext.OCClass.setCurrentContext(FContext); -end; - -procedure TGlContext.RestoreContext( - const ASharedSharedResources: IGrCanvasSharedResources); -begin - TEAGLContext.OCClass.setCurrentContext(FOldContext); -end; - -procedure TGlContext.SaveContext( - const ASharedSharedResources: IGrCanvasSharedResources); -begin - FOldContext := TEAGLContext.Wrap(TEAGLContext.OCClass.currentContext); -end; - -procedure TGlContext.SwapBuffers( - const ASharedSharedResources: IGrCanvasSharedResources); -begin -end; - -{$ENDIF} - -{ TGlCanvas } - -procedure TGlCanvas.BeforeRestore; -begin - if Parent <> nil then - FContext.MakeContextCurrent(SharedResources); -end; - -function TGlCanvas.CreateSurfaceFromWindow( - var AGrDirectContext: IGrDirectContext): ISkSurface; -var - LGrGlFramebufferInfo: TGrGlFramebufferInfo; - LGrRenderTarget: IGrBackendRenderTarget; -begin - if not FContext.Initialize(SharedResources, Parent) then - Exit(nil); - FContext.SaveContext(SharedResources); - if not FContext.MakeContextCurrent(SharedResources) then - Exit(nil); - if not Assigned(AGrDirectContext) then - begin - AGrDirectContext := TGrDirectContext.MakeGl(TGlSharedResources(SharedResources).GrGlInterface); - if Quality = TCanvasQuality.HighQuality then - FSampleCount := GrDirectContext.GetMaxSurfaceSampleCountForColorType(TSkColorType.RGBA8888) - else - FSampleCount := 1; - end; - glGetIntegerv(GL_FRAMEBUFFER_BINDING, @GLuint(LGrGlFramebufferInfo.FBOID)); - LGrGlFramebufferInfo.Format := GrGlSizedFormat[TSkColorType.RGBA8888]; - LGrRenderTarget := TGrBackendRenderTarget.CreateGl(Round(Width * Scale), Round(Height * Scale), FSampleCount, 8, LGrGlFramebufferInfo); - Result := TSkSurface.MakeFromRenderTarget(GrDirectContext, LGrRenderTarget, TGrSurfaceOrigin.BottomLeft, TSkColorType.RGBA8888); -end; - -destructor TGlCanvas.Destroy; -begin - if Parent <> nil then - FContext.Finalize(SharedResources, Parent); - inherited; -end; - -procedure TGlCanvas.DestroyContext; -begin - FContext.SaveContext(SharedResources); - try - FContext.MakeContextCurrent(SharedResources); - inherited; - finally - FContext.RestoreContext(SharedResources); - end; -end; - -procedure TGlCanvas.DoDrawBitmap(const ABitmap: FMX.Graphics.TBitmap; - const ASrcRect, ADestRect: TRectF; const AOpacity: Single; - const AHighSpeed: Boolean); -begin - FContext.MakeContextCurrent(SharedResources); - inherited; -end; - -procedure TGlCanvas.DoEndScene; -begin - if Parent <> nil then - begin - FContext.MakeContextCurrent(SharedResources); - inherited; - FContext.SwapBuffers(SharedResources); - FContext.RestoreContext(SharedResources); - end - else - inherited; -end; - -class procedure TGlCanvas.InitializeSharedResources( - out ASharedResources: IGrCanvasSharedResources); -begin - ASharedResources := TGlSharedResources.Create; -end; - -{$ENDIF} - -{$HPPEMIT NOUSINGNAMESPACE} -{$IF DEFINED(MSWINDOWS) or DEFINED(ANDROID) or DEFINED(IOS)} - (*$HPPEMIT 'namespace Skia {'*) - (*$HPPEMIT ' namespace Fmx {'*) - (*$HPPEMIT ' namespace Types { using namespace ::Fmx::Types; }'*) - (*$HPPEMIT ' }'*) - (*$HPPEMIT '}'*) -{$ENDIF} -end. - diff --git a/skia4delphi/Source/FMX/Skia.FMX.Canvas.Metal.pas b/skia4delphi/Source/FMX/Skia.FMX.Canvas.Metal.pas deleted file mode 100644 index 7328678..0000000 --- a/skia4delphi/Source/FMX/Skia.FMX.Canvas.Metal.pas +++ /dev/null @@ -1,194 +0,0 @@ -{************************************************************************} -{ } -{ Skia4Delphi } -{ } -{ Copyright (c) 2011-2022 Google LLC. } -{ Copyright (c) 2021-2022 Skia4Delphi Project. } -{ } -{ Use of this source code is governed by a BSD-style license that can be } -{ found in the LICENSE file. } -{ } -{************************************************************************} -unit Skia.FMX.Canvas.Metal; - -interface - -{$SCOPEDENUMS ON} - -{$IFDEF MACOS} - -uses - { Delphi } - {$IFDEF IOS} - iOSapi.CoreGraphics, - FMX.Platform.iOS, - {$ELSE} - Macapi.CocoaTypes, - FMX.Platform.Mac, - {$ENDIF} - Macapi.Metal, - Macapi.MetalKit, - Macapi.ObjectiveC, - System.SysUtils, - - { Skia } - Skia, - Skia.FMX.Graphics; - -type - { TMtlSharedResources } - - TMtlSharedResources = class(TGrCanvasSharedResources) - strict protected - procedure InitializeContext(out ASharedGrDirectContext: IGrDirectContext); override; - end; - - { TMtlCanvas } - - TMtlCanvas = class(TGrCanvas) - strict private - FCommandQueue: MTLCommandQueue; - FSampleCount: Integer; - strict protected - function CreateSurfaceFromWindow(var AGrDirectContext: IGrDirectContext): ISkSurface; override; - procedure DoEndScene; override; - class procedure InitializeSharedResources(out ASharedResources: IGrCanvasSharedResources); override; - end; - -{$ENDIF} - -implementation - -{$IFDEF MACOS} - -uses - { Delphi } - FMX.Graphics; - -{ TMtlSharedResources } - -procedure TMtlSharedResources.InitializeContext( - out ASharedGrDirectContext: IGrDirectContext); -var - LCommandQueue: MTLCommandQueue; - LDevice: MTLDevice; - LGrMtlBackendContext: TGrMtlBackendContext; -begin - LDevice := TMTLDevice.Wrap(MTLCreateSystemDefaultDevice); - if LDevice = nil then - raise EGrCanvas.Create('Could not get the default device instance Metal.'); - try - LCommandQueue := LDevice.newCommandQueue; - if LCommandQueue = nil then - raise EGrCanvas.Create('Could not create the shared command queue.'); - try - LGrMtlBackendContext.Device := (LDevice as ILocalObject).GetObjectID; - LGrMtlBackendContext.Queue := (LCommandQueue as ILocalObject).GetObjectID; - LGrMtlBackendContext.BinaryArchive := nil; - // The direct context will take ownership of the device and the queue. - ASharedGrDirectContext := TGrDirectContext.MakeMetal(LGrMtlBackendContext); - except - LCommandQueue.release; - raise; - end; - except - LDevice.release; - raise; - end; -end; - -{ TMtlCanvas } - -function TMtlCanvas.CreateSurfaceFromWindow( - var AGrDirectContext: IGrDirectContext): ISkSurface; -var - LDevice: MTLDevice; - LGrMtlBackendContext: TGrMtlBackendContext; -begin - if not Assigned(AGrDirectContext) then - begin - if WindowHandleToPlatform(Parent).View = nil then - Exit(nil); - LDevice := TMTLDevice.Wrap(MTLCreateSystemDefaultDevice); - try - MTKView(WindowHandleToPlatform(Parent).View).setDevice(LDevice); - {$REGION ' - Workaround RSP-37935'} - // - --------------------------------------------------------------------- - // - WORKAROUND - // - --------------------------------------------------------------------- - // - - // - Description: - // - This code is a workaround to a problem when Zoomed setting is - // - enabled on the OS then the form does not fit the screen. - // - - // - Bug report: - // - https://quality.embarcadero.com/browse/RSP-37935 - // - - // - --------------------------------------------------------------------- - {$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion112))} - var LSize: CGSize; - LSize.width := Width * Scale; - LSize.height := Height * Scale; - MTKView(WindowHandleToPlatform(Parent).View).setDrawableSize(LSize); - {$ENDIF} - // - --------------------------------------------------------------------- - {$ENDREGION} - FCommandQueue := LDevice.newCommandQueue; - if FCommandQueue = nil then - raise EGrCanvas.Create('Could not create a command queue.'); - try - LGrMtlBackendContext.Device := (LDevice as ILocalObject).GetObjectID; - LGrMtlBackendContext.Queue := (FCommandQueue as ILocalObject).GetObjectID; - LGrMtlBackendContext.BinaryArchive := nil; - // The direct context will take ownership of the device and the queue. - AGrDirectContext := TGrDirectContext.MakeMetal(LGrMtlBackendContext); - except - FCommandQueue.release; - raise; - end; - except - LDevice.release; - raise; - end; - if Quality = TCanvasQuality.HighQuality then - FSampleCount := GrDirectContext.GetMaxSurfaceSampleCountForColorType(TSkColorType.BGRA8888) - else - FSampleCount := 1; - end; - Result := TSkSurface.MakeFromMTKView(AGrDirectContext, (MTKView(WindowHandleToPlatform(Parent).View) as ILocalObject).GetObjectID, TGrSurfaceOrigin.TopLeft, FSampleCount, TSkColorType.BGRA8888); -end; - -procedure TMtlCanvas.DoEndScene; -var - LCommandBuffer: MTLCommandBuffer; -begin - inherited; - if Parent <> nil then - begin - LCommandBuffer := FCommandQueue.commandBuffer; - LCommandBuffer.presentDrawable(MTKView(WindowHandleToPlatform(Parent).View).currentDrawable); - LCommandBuffer.commit; - end; -end; - -class procedure TMtlCanvas.InitializeSharedResources( - out ASharedResources: IGrCanvasSharedResources); -begin - ASharedResources := TMtlSharedResources.Create; -end; - -{$ENDIF} - -{$HPPEMIT NOUSINGNAMESPACE} -(*$HPPEMIT 'namespace Skia {'*) -(*$HPPEMIT ' namespace Fmx {'*) -(*$HPPEMIT ' namespace Platform {'*) -{$IFDEF IOS} - (*$HPPEMIT ' namespace Ios { using namespace ::Fmx::Platform::Ios; }'*) -{$ELSE} - (*$HPPEMIT ' namespace Mac { using namespace ::Fmx::Platform::Mac; }'*) -{$ENDIF} -(*$HPPEMIT ' }'*) -(*$HPPEMIT ' }'*) -(*$HPPEMIT '}'*) -end. diff --git a/skia4delphi/Source/FMX/Skia.FMX.Graphics.pas b/skia4delphi/Source/FMX/Skia.FMX.Graphics.pas deleted file mode 100644 index 274386f..0000000 --- a/skia4delphi/Source/FMX/Skia.FMX.Graphics.pas +++ /dev/null @@ -1,3470 +0,0 @@ -{************************************************************************} -{ } -{ Skia4Delphi } -{ } -{ Copyright (c) 2011-2022 Google LLC. } -{ Copyright (c) 2021-2022 Skia4Delphi Project. } -{ } -{ Use of this source code is governed by a BSD-style license that can be } -{ found in the LICENSE file. } -{ } -{************************************************************************} -unit Skia.FMX.Graphics; - -interface - -{$SCOPEDENUMS ON} - -{$IF (CompilerVersion < 35) or not DECLARED(RTLVersion111)} - {$DEFINE MODULATE_CANVAS} -{$ENDIF} - -uses - { Delphi } - FMX.Graphics, - FMX.TextLayout, - FMX.Types, - System.Classes, - System.Generics.Defaults, - System.Math.Vectors, - System.Messaging, - System.SysUtils, - System.Types, - System.UITypes, - - { Skia } - Skia; - -type - ESkCanvas = class(Exception); - - EGrCanvas = class(ESkCanvas); - - { TSkCanvasCustom } - - TSkCanvasCustom = class abstract(TCanvas{$IFDEF MODULATE_CANVAS}, IModulateCanvas{$ENDIF}) - strict private type - TSaveState = class(TCanvasSaveState) - strict protected - procedure AssignTo(ADest: TPersistent); override; - public - procedure Assign(ASource: TPersistent); override; - end; - private - // Ideally, this function should be virtual and each Canvas should be able - // to choose its pixel format to avoid conversions, however, due to the - // current FMX code, they should be fixed per operating system. - class function PixelFormat: TPixelFormat; inline; - {$IFDEF MODULATE_CANVAS} - strict private - FModulateColor: TAlphaColor; - function GetModulateColor: TAlphaColor; - procedure SetModulateColor(const AColor: TAlphaColor); - {$ENDIF} - strict private - FBrushBitmapData: TBitmapData; - FBrushBitmapMapped: Boolean; - function GetSamplingOptions(const AHighSpeed: Boolean = False): TSkSamplingOptions; inline; - procedure BeginSkPaint(const ABrush: TBrush; const ARect: TRectF; const AOpacity: Single; const APaint: ISkPaint); - strict protected - // Since FMX effects use TContext3D, on systems using OpenGLES it makes the - // current context the context it created, and does not revert to the old - // one after it has finished its task. - procedure BeforeRestore; virtual; - function BeginSkPaintFromBrush(const ABrush: TBrush; const ARect: TRectF; const AOpacity: Single): ISkPaint; inline; - function BeginSkPaintFromStrokeBrush(const ABrush: TStrokeBrush; const ARect: TRectF; const AOpacity: Single): ISkPaint; - function CreateSaveState: TCanvasSaveState; override; - procedure DoDrawBitmap(const ABitmap: TBitmap; const ASrcRect, ADestRect: TRectF; const AOpacity: Single; const AHighSpeed: Boolean); override; - procedure DoDrawEllipse(const ARect: TRectF; const AOpacity: Single; const ABrush: TStrokeBrush); override; - procedure DoDrawLine(const APoint1, APoint2: TPointF; const AOpacity: Single; const ABrush: TStrokeBrush); override; - procedure DoDrawPath(const APath: TPathData; const AOpacity: Single; const ABrush: TStrokeBrush); override; - procedure DoDrawRect(const ARect: TRectF; const AOpacity: Single; const ABrush: TStrokeBrush); override; - procedure DoFillEllipse(const ARect: TRectF; const AOpacity: Single; const ABrush: TBrush); override; - procedure DoFillPath(const APath: TPathData; const AOpacity: Single; const ABrush: TBrush); override; - procedure DoFillRect(const ARect: TRectF; const AOpacity: Single; const ABrush: TBrush); override; - {$IF CompilerVersion >= 30} - procedure DoSetMatrix(const AMatrix: TMatrix); override; - {$ENDIF} - procedure EndSkPaint(const ABrush: TBrush); - function GetCache(const ABitmapHandle: THandle): ISkImage; virtual; - function GetCanvas: ISkCanvas; virtual; abstract; - procedure Resized; virtual; - public - procedure Clear(const AColor: TAlphaColor); override; - procedure ClearRect(const ARect: TRectF; const AColor: TAlphaColor = 0); override; - procedure ExcludeClipRect(const ARect: TRectF); override; - procedure IntersectClipRect(const ARect: TRectF); override; - function LoadFontFromStream(const AStream: TStream): Boolean; override; - function PtInPath(const APoint: TPointF; const APath: TPathData): Boolean; override; - {$IF CompilerVersion < 30} - procedure SetMatrix(const AMatrix: TMatrix); override; - {$ENDIF} - property Canvas: ISkCanvas read GetCanvas; - procedure SetSize(const AWidth, AHeight: Integer); override; final; - class function GetCanvasStyle: TCanvasStyles; override; - end; - - { TSkBitmapHandle } - - TSkBitmapHandle = class - strict private - FHeight: Integer; - FPixelFormat: TPixelFormat; - FPixels: Pointer; - FWidth: Integer; - public - constructor Create(const AWidth, AHeight: Integer; const APixelFormat: TPixelFormat); - destructor Destroy; override; - procedure AllocatePixels; inline; - property Height: Integer read FHeight; - property PixelFormat: TPixelFormat read FPixelFormat; - property Pixels: Pointer read FPixels; - property Width: Integer read FWidth; - end; - - { TSkCanvasBase } - - TSkCanvasBase = class abstract(TSkCanvasCustom) - strict private - FSurface: ISkSurface; - protected - class procedure Finalize; virtual; - class procedure Initialize; virtual; - strict protected - {$IFDEF MSWINDOWS} - constructor CreateFromWindow(const AParent: TWindowHandle; const AWidth, AHeight: Integer; const AQuality: TCanvasQuality = TCanvasQuality.SystemDefault); override; - {$ENDIF} - function DoBeginScene({$IF CompilerVersion < 35}const {$ENDIF}AClipRects: PClipRects = nil; AContextHandle: THandle = 0): Boolean; override; - function CreateSurfaceFromBitmap: ISkSurface; virtual; - function CreateSurfaceFromWindow(const AContextHandle: THandle): ISkSurface; virtual; abstract; - procedure DoEndScene; override; - function GetCanvas: ISkCanvas; override; - {$IFDEF MSWINDOWS} - procedure Resized; override; - {$ENDIF} - class procedure DoFinalizeBitmap(var ABitmapHandle: THandle); override; - class function DoInitializeBitmap(const AWidth, AHeight: Integer; const AScale: Single; var APixelFormat: TPixelFormat): THandle; override; - class function DoMapBitmap(const ABitmapHandle: THandle; const AAccess: TMapAccess; var ABitmapData: TBitmapData): Boolean; override; - class procedure DoUnmapBitmap(const ABitmapHandle: THandle; var ABitmapData: TBitmapData); override; - public - property Surface: ISkSurface read FSurface; - end; - - { IGrCanvasSharedResources } - - IGrCanvasSharedResources = interface - ['{3681405A-B7C1-4244-98B6-E6D2B8E45BC2}'] - procedure BeginContext; - procedure EndContext; - function GetGrDirectContext: IGrDirectContext; - /// Direct access to the ganesh backend. This property can only be used between the BeginContext and EndContext call. - property GrDirectContext: IGrDirectContext read GetGrDirectContext; - end; - - { TGrCanvasSharedResources } - - TGrCanvasSharedResources = class abstract(TInterfacedObject, IGrCanvasSharedResources) - strict private - FGrDirectContext: IGrDirectContext; - procedure BeginContext; - procedure EndContext; - function GetGrDirectContext: IGrDirectContext; - strict protected - procedure AfterBeginContext; virtual; - procedure BeforeEndContext; virtual; - procedure FinalizeSharedResources; virtual; - procedure InitializeContext(out ASharedGrDirectContext: IGrDirectContext); virtual; abstract; - procedure InitializeSharedResources; virtual; - public - constructor Create; - destructor Destroy; override; - end; - - { TGrBitmapHandle } - - TGrBitmapHandle = class(TSkBitmapHandle) - private - FSharedResources: IGrCanvasSharedResources; - FTexture: ISkImage; - public - destructor Destroy; override; - procedure ClearCache; inline; - property Texture: ISkImage read FTexture; - end; - - { TGrCanvas } - - TGrCanvas = class abstract(TSkCanvasBase) - strict private class var - FSharedResources: IGrCanvasSharedResources; - strict private - FGrDirectContext: IGrDirectContext; - strict protected - function CreateSurfaceFromBitmap: ISkSurface; override; - function CreateSurfaceFromWindow(const AContextHandle: THandle): ISkSurface; overload; override; final; - function CreateSurfaceFromWindow(var AGrDirectContext: IGrDirectContext): ISkSurface; reintroduce; overload; virtual; abstract; - procedure DestroyContext; virtual; - procedure DoEndScene; override; - function GetCache(const ABitmapHandle: THandle): ISkImage; override; - class function DoInitializeBitmap(const AWidth, AHeight: Integer; const AScale: Single; var APixelFormat: TPixelFormat): THandle; override; - class function DoMapBitmap(const ABitmapHandle: THandle; const AAccess: TMapAccess; var ABitmapData: TBitmapData): Boolean; override; - class procedure Initialize; override; - class procedure InitializeSharedResources(out ASharedResources: IGrCanvasSharedResources); virtual; abstract; - public - procedure BeforeDestruction; override; - /// Direct access to the ganesh backend. This property can only be used between the BeginScene and EndScene call. - property GrDirectContext: IGrDirectContext read FGrDirectContext; - class property SharedResources: IGrCanvasSharedResources read FSharedResources; - end; - - TGrBeforeSharedContextDestructionMessage = class(TMessage); - - { TSkTextLayout } - - TSkTextLayout = class(TTextLayout) - strict private type - TParagraph = record - Bounds: TRectF; - Offset: TPointF; - Paragraph: ISkParagraph; - Range: TTextRange; - end; - - TGraphemesMap = record - strict private - FCharIndexInGrapheme: TBytes; - FText: string; - function CreateGraphemesMapping(const AText: string): TBytes; - procedure SetText(const AText: string); inline; - public - procedure FindNextGraphemeBoundary(var AIndex: Integer); inline; - procedure FindPreviousGraphemeBoundary(var AIndex: Integer); inline; - property Text: string read FText write SetText; - end; - - strict private class var - FAttributesRangeComparer: IComparer; - FParagraphTextRangeComparer: IComparer; - strict private - FColor: TAlphaColor; - FGraphemesMap: TGraphemesMap; - {$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion113))} - FIgnoreUpdates: Boolean; - {$ENDIF} - FMaxLines: Integer; - FOpacity: Single; - FParagraphs: TArray; - FTextRect: TRectF; - function GetParagraphsInRange(const APos, ALength: Integer): TArray; - function NeedHorizontalAlignment: Boolean; - procedure SetMaxLines(AValue: Integer); - procedure UpdateParagraph; - class constructor Create; - protected - class procedure Initialize; - strict protected - procedure DoDrawLayout(const ACanvas: TCanvas); overload; override; - procedure DoDrawLayout(const ACanvas: ISkCanvas); reintroduce; overload; - function DoPositionAtPoint(const APoint: TPointF): Integer; override; - function DoRegionForRange(const ARange: TTextRange): TRegion; override; - procedure DoRenderLayout; override; - function GetTextHeight: Single; override; - function GetTextRect: TRectF; override; - function GetTextWidth: Single; override; - public - constructor Create(const ACanvas: TCanvas = nil); override; - procedure ConvertToPath(const APath: TPathData); override; - procedure RenderLayout(const ACanvas: ISkCanvas); overload; - /// Max lines allowed in text. When zero (default) it is unlimited. - property MaxLines: Integer read FMaxLines write SetMaxLines; - end; - -const - SVWEBPImages = 'WebP Images'; - SWBMPImages = 'WBMP Images'; - SRawCanon = 'Raw Canon'; - SRawDNG = 'Raw Adobe DNG Digital Negative'; - SRawNikon = 'Raw Nikon'; - SRawORF = 'Raw Olympus ORF'; - SRawPanasonic = 'Raw Panasonic'; - SRawPEF = 'Raw Pentax PEF'; - SRawRAF = 'Raw Fujifilm RAF'; - SRawSony = 'Raw Sony'; - SRawSRW = 'Raw Samsung SRW'; - -implementation - -uses - { Delphi } - FMX.Consts, - FMX.Platform, - FMX.Surfaces, - System.IOUtils, - System.Math, - System.UIConsts, - System.Generics.Collections, - {$IF DEFINED(MSWINDOWS)} - FMX.Platform.Win, - Winapi.Windows, - {$ELSEIF DEFINED(MACOS) and NOT DEFINED(IOS)} - Macapi.CocoaTypes, - Macapi.CoreGraphics, - {$ENDIF} - - // These units are used for workarounds - FMX.Forms, - {$IF DEFINED(MACOS)} - System.Rtti, - FMX.Context.Metal, - FMX.Types3D, - FMX.Utils, - Macapi.Metal, - Macapi.MetalKit, - Posix.SysMman, - Posix.Unistd, - {$IFDEF IOS} - FMX.Context.GLES, - FMX.Controls, - FMX.Helpers.iOS, - FMX.MediaLibrary, - FMX.MediaLibrary.IOS, - iOSapi.AssetsLibrary, - iOSapi.CocoaTypes, - iOSapi.CoreGraphics, - iOSapi.Foundation, - iOSapi.OpenGLES, - iOSapi.UIKit, - Macapi.Helpers, - Macapi.ObjectiveC, - {$ENDIF} - {$ELSEIF DEFINED(ANDROID)} - System.Rtti, - Androidapi.Gles2, - FMX.Context.GLES, - FMX.Types3D, - FMX.Utils, - Posix.SysMman, - Posix.Unistd, - {$ENDIF} - - { Skia } - Skia.API, - Skia.FMX, - Skia.FMX.Canvas.GL, - Skia.FMX.Canvas.Metal; - -type - { TSkBitmapHandleCodec } - - TSkBitmapHandleCodec = class(TCustomBitmapCodec) - strict private - function FitSize(const AWidth, AHeight: Integer; const AFitWidth, AFitHeight: Single): TSize; inline; - class constructor Create; - class procedure RegisterIfNotExists(const AFileExtension, ADescription: string; const ACanSave: Boolean); inline; - public - function LoadFromFile(const AFileName: string; const ABitmapSurface: TBitmapSurface; const AMaxSizeLimit: Cardinal = 0): Boolean; override; - function LoadFromStream(const AStream: TStream; const ABitmapSurface: TBitmapSurface; const AMaxSizeLimit: Cardinal = 0): Boolean; override; - function LoadThumbnailFromFile(const AFileName: string; const AFitWidth, AFitHeight: Single; const AUseEmbedded: Boolean; const ABitmapSurface: TBitmapSurface): Boolean; override; - function SaveToFile(const AFileName: string; const ABitmapSurface: TBitmapSurface; const ASaveParams: PBitmapCodecSaveParams = nil): Boolean; override; - function SaveToStream(const AStream: TStream; const ABitmapSurface: TBitmapSurface; const AExtension: string; const ASaveParams: PBitmapCodecSaveParams = nil): Boolean; override; - class function GetImageSize(const AFileName: string): TPointF; override; - class function IsValid(const AStream: TStream): Boolean; override; - end; - -{$IF DEFINED(MSWINDOWS)} - - { TSkRasterWindowsCanvas } - - TSkRasterWindowsCanvas = class(TSkCanvasBase) - strict private - FBitmap: HBITMAP; - FBits: Pointer; - FDC: HDC; - strict protected - function CreateSurfaceFromWindow(const AContextHandle: THandle): ISkSurface; override; - procedure DoEndScene; override; - procedure Resized; override; - public - destructor Destroy; override; - end; - -{$ELSEIF DEFINED(MACOS) and NOT DEFINED(IOS)} - - { TSkRasterMacOSCanvas } - - TSkRasterMacOSCanvas = class(TSkCanvasBase) - strict private class var - FColorSpace: CGColorSpaceRef; - strict private - FBitmapContext: CGContextRef; - FContext: CGContextRef; - strict protected - function CreateSurfaceFromWindow(const AContextHandle: THandle): ISkSurface; override; - procedure DoEndScene; override; - procedure Resized; override; - class procedure Finalize; override; - class procedure Initialize; override; - public - destructor Destroy; override; - end; - -{$ENDIF} - -{ TSkCanvasCustom } - -procedure TSkCanvasCustom.BeforeRestore; -begin -end; - -procedure TSkCanvasCustom.BeginSkPaint(const ABrush: TBrush; - const ARect: TRectF; const AOpacity: Single; const APaint: ISkPaint); -const - WrapMode: array[TWrapMode.Tile..TWrapMode.TileOriginal] of TSkTileMode = (TSkTileMode.Repeat, TSkTileMode.Clamp); -var - I: Integer; - LCenter: TPointF; - LColors: TArray; - LImage: ISkImage; - LMatrix: TMatrix; - LPositions: TArray; - LRadius: Single; - LRadiusX: Single; - LRadiusY: Single; -begin - if ABrush.Kind = TBrushKind.Resource then - begin - if ABrush.Resource.Brush = nil then - Exit; - ABrush.Assign(ABrush.Resource.Brush); - end; - APaint.AntiAlias := Quality <> TCanvasQuality.HighPerformance; - case ABrush.Kind of - TBrushKind.Solid: APaint.Color := MakeColor(ABrush.Color, AOpacity); - TBrushKind.Gradient: - begin - SetLength(LColors, ABrush.Gradient.Points.Count); - SetLength(LPositions, ABrush.Gradient.Points.Count); - case ABrush.Gradient.Style of - TGradientStyle.Linear: - begin - for I := 0 to ABrush.Gradient.Points.Count - 1 do - begin - LColors[I] := MakeColor(ABrush.Gradient.Points[I].Color, AOpacity); - LPositions[I] := ABrush.Gradient.Points[I].Offset; - end; - APaint.Shader := TSkShader.MakeGradientLinear(TPointF.Create(ARect.Left + ABrush.Gradient.StartPosition.X * ARect.Width, ARect.Top + ABrush.Gradient.StartPosition.Y * ARect.Height), TPointF.Create(ARect.Left + ABrush.Gradient.StopPosition.X * ARect.Width, ARect.Top + ABrush.Gradient.StopPosition.Y * ARect.Height), LColors, LPositions); - end; - TGradientStyle.Radial: - begin - for I := 0 to ABrush.Gradient.Points.Count - 1 do - begin - LColors[ABrush.Gradient.Points.Count - 1 - I] := MakeColor(ABrush.Gradient.Points[I].Color, AOpacity); - LPositions[ABrush.Gradient.Points.Count - 1 - I] := 1 - ABrush.Gradient.Points[I].Offset; - end; - LCenter := TPointF.Create(ARect.Width * ABrush.Gradient.RadialTransform.RotationCenter.X, ARect.Height * ABrush.Gradient.RadialTransform.RotationCenter.Y) + ARect.TopLeft; - LRadiusX := ABrush.Gradient.RadialTransform.Scale.X * (ARect.Width / 2); - LRadiusY := ABrush.Gradient.RadialTransform.Scale.Y * (ARect.Height / 2); - if not SameValue(LRadiusX, LRadiusY, Epsilon) then - begin - if LRadiusX < LRadiusY then - begin - LRadius := LRadiusY; - LMatrix := TMatrix.CreateScaling(LRadiusX / LRadiusY, 1) * TMatrix.CreateTranslation(LCenter.X - (LCenter.X * (LRadiusX / LRadiusY)), 0); - end - else - begin - LRadius := LRadiusX; - LMatrix := TMatrix.CreateScaling(1, LRadiusY / LRadiusX) * TMatrix.CreateTranslation(0, LCenter.Y - (LCenter.Y * (LRadiusY / LRadiusX))); - end; - APaint.Shader := TSkShader.MakeGradientRadial(LCenter, LRadius, LColors, LMatrix, LPositions); - end - else - APaint.Shader := TSkShader.MakeGradientRadial(LCenter, LRadiusX, LColors, LPositions); - end; - end; - end; - TBrushKind.Bitmap: - begin - if ABrush.Bitmap.Bitmap.HandleAllocated then - begin - LImage := GetCache(ABrush.Bitmap.Bitmap.Image.Handle); - if not Assigned(LImage) then - begin - FBrushBitmapMapped := ABrush.Bitmap.Bitmap.Map(TMapAccess.Read, FBrushBitmapData); - if FBrushBitmapMapped then - LImage := TSkImage.MakeFromRaster(TSkImageInfo.Create(FBrushBitmapData.Width, FBrushBitmapData.Height, SkFmxColorType[FBrushBitmapData.PixelFormat]), FBrushBitmapData.Data, FBrushBitmapData.Pitch); - end; - if Assigned(LImage) then - begin - if ABrush.Bitmap.WrapMode = TWrapMode.TileStretch then - APaint.Shader := LImage.MakeShader(TMatrix.CreateScaling(ARect.Width / LImage.Width, ARect.Height / LImage.Height) * TMatrix.CreateTranslation(ARect.Left, ARect.Top), GetSamplingOptions) - else - APaint.Shader := LImage.MakeShader(GetSamplingOptions, WrapMode[ABrush.Bitmap.WrapMode], WrapMode[ABrush.Bitmap.WrapMode]); - APaint.AlphaF := AOpacity; - Exit; - end; - end; - APaint.Alpha := 0; - end; - end; -end; - -function TSkCanvasCustom.BeginSkPaintFromBrush(const ABrush: TBrush; - const ARect: TRectF; const AOpacity: Single): ISkPaint; -begin - Result := TSkPaint.Create(TSkPaintStyle.Fill); - BeginSkPaint(ABrush, ARect, AOpacity, Result); -end; - -function TSkCanvasCustom.BeginSkPaintFromStrokeBrush(const ABrush: TStrokeBrush; - const ARect: TRectF; const AOpacity: Single): ISkPaint; -const - StrokeCap : array[TStrokeCap] of TSkStrokeCap = (TSkStrokeCap.Square, TSkStrokeCap.Round); - StrokeJoin: array[TStrokeJoin] of TSkStrokeJoin = (TSkStrokeJoin.Miter, TSkStrokeJoin.Round, TSkStrokeJoin.Bevel); -var - I: Integer; - LCap: Single; - LDash: TDashArray; -begin - Result := TSkPaint.Create(TSkPaintStyle.Stroke); - BeginSkPaint(ABrush, ARect, AOpacity, Result); - Result.StrokeCap := StrokeCap[ABrush.Cap]; - Result.StrokeJoin := StrokeJoin[ABrush.Join]; - Result.StrokeWidth := ABrush.Thickness; - LDash := ABrush.DashArray; - if Length(LDash) > 0 then - begin - if ABrush.Dash = TStrokeDash.Custom then - LCap := ABrush.Thickness - else - LCap := 0; - for I := 0 to Length(LDash) - 1 do - begin - if Odd(I) then - LDash[I] := (LDash[I] + 1) * ABrush.Thickness - LCap - else - LDash[I] := (LDash[I] - 1) * ABrush.Thickness + LCap; - end; - Result.PathEffect := TSkPathEffect.MakeDash(TArray(LDash), ABrush.DashOffset * ABrush.Thickness); - end; -end; - -procedure TSkCanvasCustom.Clear(const AColor: TAlphaColor); -begin - {$IF CompilerVersion >= 35} - RaiseIfBeginSceneCountZero; - {$ELSE} - if BeginSceneCount > 0 then - {$ENDIF} - Canvas.Clear(AColor); -end; - -procedure TSkCanvasCustom.ClearRect(const ARect: TRectF; - const AColor: TAlphaColor); -begin - Canvas.Save; - try - Canvas.ClipRect(ARect); - Canvas.Clear(AColor); - finally - Canvas.Restore; - end; -end; - -function TSkCanvasCustom.CreateSaveState: TCanvasSaveState; -begin - Result := TSaveState.Create; -end; - -procedure TSkCanvasCustom.DoDrawBitmap(const ABitmap: FMX.Graphics.TBitmap; - const ASrcRect, ADestRect: TRectF; const AOpacity: Single; - const AHighSpeed: Boolean); -var - LBitmapData: TBitmapData; - LImage: ISkImage; - LPaint: ISkPaint; -begin - if ABitmap.HandleAllocated then - begin - LPaint := TSkPaint.Create; - LPaint.AlphaF := AOpacity; - {$IFDEF MODULATE_CANVAS} - if FModulateColor <> TAlphaColors.Null then - LPaint.ColorFilter := TSkColorFilter.MakeBlend(FModulateColor, TSkBlendMode.SrcIn); - {$ENDIF} - LImage := GetCache(ABitmap.Image.Handle); - if Assigned(LImage) then - Canvas.DrawImageRect(LImage, ASrcRect, ADestRect, GetSamplingOptions(AHighSpeed), LPaint) - else - begin - if ABitmap.Map(TMapAccess.Read, LBitmapData) then - begin - try - LImage := TSkImage.MakeFromRaster(TSkImageInfo.Create(LBitmapData.Width, LBitmapData.Height, SkFmxColorType[LBitmapData.PixelFormat]), LBitmapData.Data, LBitmapData.Pitch); - if Assigned(LImage) then - Canvas.DrawImageRect(LImage, ASrcRect, ADestRect, GetSamplingOptions(AHighSpeed), LPaint); - finally - ABitmap.Unmap(LBitmapData); - end; - end; - end; - end; -end; - -procedure TSkCanvasCustom.DoDrawEllipse(const ARect: TRectF; - const AOpacity: Single; const ABrush: TStrokeBrush); -var - LPaint: ISkPaint; - LPathBuilder: ISkPathBuilder; -begin - if SameValue(ABrush.Thickness, 0, TEpsilon.Position) then - Exit; - LPathBuilder := TSkPathBuilder.Create; - LPathBuilder.AddOval(ARect, TSkPathDirection.CW, 3); - LPaint := BeginSkPaintFromStrokeBrush(ABrush, ARect, AOpacity); - try - Canvas.DrawPath(LPathBuilder.Detach, LPaint); - finally - EndSkPaint(ABrush); - end; -end; - -procedure TSkCanvasCustom.DoDrawLine(const APoint1, APoint2: TPointF; - const AOpacity: Single; const ABrush: TStrokeBrush); -var - LPaint: ISkPaint; -begin - if SameValue(ABrush.Thickness, 0, TEpsilon.Position) then - Exit; - LPaint := BeginSkPaintFromStrokeBrush(ABrush, TRectF.Create(APoint1, APoint2), AOpacity); - try - Canvas.DrawLine(APoint1, APoint2, LPaint); - finally - EndSkPaint(ABrush); - end; -end; - -procedure TSkCanvasCustom.DoDrawPath(const APath: TPathData; - const AOpacity: Single; const ABrush: TStrokeBrush); -var - LPaint: ISkPaint; -begin - if SameValue(ABrush.Thickness, 0, TEpsilon.Position) then - Exit; - LPaint := BeginSkPaintFromStrokeBrush(ABrush, APath.GetBounds, AOpacity); - try - Canvas.DrawPath(APath.ToSkPath, LPaint); - finally - EndSkPaint(ABrush); - end; -end; - -procedure TSkCanvasCustom.DoDrawRect(const ARect: TRectF; - const AOpacity: Single; const ABrush: TStrokeBrush); -var - LPaint: ISkPaint; -begin - if SameValue(ABrush.Thickness, 0, TEpsilon.Position) then - Exit; - LPaint := BeginSkPaintFromStrokeBrush(ABrush, ARect, AOpacity); - try - Canvas.DrawRect(ARect, LPaint); - finally - EndSkPaint(ABrush); - end; -end; - -procedure TSkCanvasCustom.DoFillEllipse(const ARect: TRectF; - const AOpacity: Single; const ABrush: TBrush); -var - LPaint: ISkPaint; - LPathBuilder: ISkPathBuilder; -begin - LPathBuilder := TSkPathBuilder.Create; - LPathBuilder.AddOval(ARect, TSkPathDirection.CW, 3); - LPaint := BeginSkPaintFromBrush(ABrush, ARect, AOpacity); - try - Canvas.DrawPath(LPathBuilder.Detach, LPaint); - finally - EndSkPaint(ABrush); - end; -end; - -procedure TSkCanvasCustom.DoFillPath(const APath: TPathData; - const AOpacity: Single; const ABrush: TBrush); -var - LPaint: ISkPaint; -begin - LPaint := BeginSkPaintFromBrush(ABrush, APath.GetBounds, AOpacity); - try - Canvas.DrawPath(APath.ToSkPath, LPaint); - finally - EndSkPaint(ABrush); - end; -end; - -procedure TSkCanvasCustom.DoFillRect(const ARect: TRectF; - const AOpacity: Single; const ABrush: TBrush); -var - LPaint: ISkPaint; -begin - LPaint := BeginSkPaintFromBrush(ABrush, ARect, AOpacity); - try - Canvas.DrawRect(ARect, LPaint); - finally - EndSkPaint(ABrush); - end; -end; - -{$IF CompilerVersion >= 30} - -procedure TSkCanvasCustom.DoSetMatrix(const AMatrix: TMatrix); -begin - if BeginSceneCount > 0 then - Canvas.SetMatrix(AMatrix * TMatrix.CreateScaling(Scale, Scale)); -end; - -{$ENDIF} - -procedure TSkCanvasCustom.EndSkPaint(const ABrush: TBrush); -begin - if (ABrush.Kind = TBrushKind.Bitmap) and (FBrushBitmapMapped) then - ABrush.Bitmap.Bitmap.Unmap(FBrushBitmapData); -end; - -procedure TSkCanvasCustom.ExcludeClipRect(const ARect: TRectF); -begin - Inc(FClippingChangeCount); - Canvas.ClipRect(ARect, TSkClipOp.Difference); -end; - -function TSkCanvasCustom.GetCache(const ABitmapHandle: THandle): ISkImage; -begin - Result := nil; -end; - -class function TSkCanvasCustom.GetCanvasStyle: TCanvasStyles; -begin - Result := []; -end; - -{$IFDEF MODULATE_CANVAS} - -function TSkCanvasCustom.GetModulateColor: TAlphaColor; -begin - Result := FModulateColor; -end; - -{$ENDIF} - -function TSkCanvasCustom.GetSamplingOptions( - const AHighSpeed: Boolean): TSkSamplingOptions; -begin - if AHighSpeed then - Result := TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None) - else - begin - case Quality of - TCanvasQuality.SystemDefault, - TCanvasQuality.HighQuality: Result := TSkSamplingOptions.High; - else - Result := TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.Nearest); - end; - end; -end; - -procedure TSkCanvasCustom.IntersectClipRect(const ARect: TRectF); -begin - Inc(FClippingChangeCount); - Canvas.ClipRect(ARect); -end; - -function TSkCanvasCustom.LoadFontFromStream(const AStream: TStream): Boolean; -begin - TSkDefaultProviders.RegisterTypeface(AStream); - Result := True; -end; - -class function TSkCanvasCustom.PixelFormat: TPixelFormat; -begin - {$IF DEFINED(MSWINDOWS)} - Result := TPixelFormat.BGRA; - {$ELSEIF DEFINED(IOS)} - if GlobalUseMetal then - Result := TPixelFormat.BGRA - else - Result := TPixelFormat.RGBA; - {$ELSEIF DEFINED(MACOS)} - Result := TPixelFormat.BGRA; - {$ELSEIF (CompilerVersion < 34) and DEFINED(ANDROID)} - // This is an old problem already fixed in recent versions, where the pixel - // format is not converted in the Surface to Bitmap assignment. - Result := TPixelFormat.BGRA; - {$ELSE} - Result := TPixelFormat.RGBA; - {$ENDIF} -end; - -function TSkCanvasCustom.PtInPath(const APoint: TPointF; - const APath: TPathData): Boolean; -var - LPaint: ISkPaint; - LPath: ISkPath; -begin - LPaint := TSkPaint.Create; - LPath := LPaint.GetFillPath(APath.ToSkPath); - Result := Assigned(LPath) and (LPath.Contains(APoint.X, APoint.Y)); -end; - -procedure TSkCanvasCustom.Resized; -begin -end; - -{$IF CompilerVersion < 30} - -procedure TSkCanvasCustom.SetMatrix(const AMatrix: TMatrix); -begin - inherited; - if BeginSceneCount > 0 then - Canvas.SetMatrix(AMatrix * TMatrix.CreateScaling(Scale, Scale)); -end; - -{$ENDIF} - -{$IFDEF MODULATE_CANVAS} - -procedure TSkCanvasCustom.SetModulateColor(const AColor: TAlphaColor); -begin - FModulateColor := AColor; -end; - -{$ENDIF} - -procedure TSkCanvasCustom.SetSize(const AWidth, AHeight: Integer); -begin - if (Width <> AWidth) or (Height <> AHeight) then - begin - inherited; - Resized; - end; -end; - -{ TSkCanvasCustom.TSaveState } - -procedure TSkCanvasCustom.TSaveState.Assign(ASource: TPersistent); -begin - inherited; - if ASource is TSkCanvasCustom then - TSkCanvasCustom(ASource).Canvas.Save; -end; - -procedure TSkCanvasCustom.TSaveState.AssignTo(ADest: TPersistent); -begin - inherited; - if ADest is TSkCanvasCustom then - begin - TSkCanvasCustom(ADest).BeforeRestore; - TSkCanvasCustom(ADest).Canvas.Restore; - end; -end; - -{ TSkBitmapHandle } - -procedure TSkBitmapHandle.AllocatePixels; -begin - if FPixels = nil then - FPixels := AllocMem(FWidth * FHeight * PixelFormatBytes[FPixelFormat]); -end; - - -constructor TSkBitmapHandle.Create(const AWidth, AHeight: Integer; - const APixelFormat: TPixelFormat); -begin - inherited Create; - FWidth := AWidth; - FHeight := AHeight; - FPixelFormat := APixelFormat; -end; - -destructor TSkBitmapHandle.Destroy; -begin - FreeMem(FPixels); - inherited; -end; - -{ TSkCanvasBase } - -{$IFDEF MSWINDOWS} - -constructor TSkCanvasBase.CreateFromWindow(const AParent: TWindowHandle; - const AWidth, AHeight: Integer; const AQuality: TCanvasQuality); -begin - inherited; - if WindowHandleToPlatform(Parent){$IF CompilerVersion < 30}.Form{$ENDIF}.Transparency then - WindowHandleToPlatform(Parent).CreateBuffer({$IF CompilerVersion < 31}Width, Height{$ELSE}WindowHandleToPlatform(Parent).WndClientSize.Width, WindowHandleToPlatform(Parent).WndClientSize.Height{$ENDIF}); -end; - -{$ENDIF} - -function TSkCanvasBase.CreateSurfaceFromBitmap: ISkSurface; -begin - TSkBitmapHandle(Bitmap.Handle).AllocatePixels; - Result := TSkSurface.MakeRasterDirect(TSkImageInfo.Create(TSkBitmapHandle(Bitmap.Handle).Width, TSkBitmapHandle(Bitmap.Handle).Height, SkFmxColorType[TSkBitmapHandle(Bitmap.Handle).PixelFormat]), TSkBitmapHandle(Bitmap.Handle).Pixels, TSkBitmapHandle(Bitmap.Handle).Width * PixelFormatBytes[TSkBitmapHandle(Bitmap.Handle).PixelFormat]); -end; - -function TSkCanvasBase.DoBeginScene({$IF CompilerVersion < 35}const {$ENDIF}AClipRects: PClipRects; - AContextHandle: THandle): Boolean; -begin - Result := inherited; - if Result then - begin - if Bitmap <> nil then - FSurface := CreateSurfaceFromBitmap - else if Parent <> nil then - FSurface := CreateSurfaceFromWindow(AContextHandle) - else - Exit(False); - Result := Assigned(FSurface); - if Result then - FSurface.Canvas.SetMatrix(TMatrix.CreateScaling(Scale, Scale)); - end; -end; - -procedure TSkCanvasBase.DoEndScene; -begin - {$IFDEF MSWINDOWS} - if Parent <> nil then - begin - if WindowHandleToPlatform(Parent){$IF CompilerVersion < 30}.Form{$ENDIF}.Transparency then - FSurface.ReadPixels(TSkImageInfo.Create({$IF CompilerVersion < 31}Width, Height{$ELSE}WindowHandleToPlatform(Parent).WndClientSize.Width, WindowHandleToPlatform(Parent).WndClientSize.Height{$ENDIF}, TSkColorType.BGRA8888), WindowHandleToPlatform(Parent).BufferBits, {$IF CompilerVersion < 31}Width{$ELSE}WindowHandleToPlatform(Parent).WndClientSize.Width{$ENDIF} * SkBytesPerPixel[TSkColorType.BGRA8888]); - end; - {$ENDIF} - FSurface := nil; - inherited; -end; - -class procedure TSkCanvasBase.DoFinalizeBitmap(var ABitmapHandle: THandle); -begin - TSkBitmapHandle(ABitmapHandle).Free; -end; - -class function TSkCanvasBase.DoInitializeBitmap(const AWidth, AHeight: Integer; - const AScale: Single; var APixelFormat: TPixelFormat): THandle; -begin - if APixelFormat = TPixelFormat.None then - APixelFormat := PixelFormat; - Result := THandle(TSkBitmapHandle.Create(AWidth, AHeight, APixelFormat)); - APixelFormat := PixelFormat; -end; - -class function TSkCanvasBase.DoMapBitmap(const ABitmapHandle: THandle; - const AAccess: TMapAccess; var ABitmapData: TBitmapData): Boolean; -begin - TSkBitmapHandle(ABitmapHandle).AllocatePixels; - ABitmapData.Data := TSkBitmapHandle(ABitmapHandle).Pixels; - ABitmapData.Pitch := TSkBitmapHandle(ABitmapHandle).Width * PixelFormatBytes[TSkBitmapHandle(ABitmapHandle).PixelFormat]; - Result := True; -end; - -class procedure TSkCanvasBase.DoUnmapBitmap(const ABitmapHandle: THandle; - var ABitmapData: TBitmapData); -begin -end; - -class procedure TSkCanvasBase.Finalize; -begin - SkFinalize; -end; - -function TSkCanvasBase.GetCanvas: ISkCanvas; -begin - Result := FSurface.Canvas; -end; - -class procedure TSkCanvasBase.Initialize; -begin - SkInitialize; -end; - -{$IFDEF MSWINDOWS} - -procedure TSkCanvasBase.Resized; -begin - inherited; - -end; - -{$ENDIF} - -{ TGrBitmapHandle } - -procedure TGrBitmapHandle.ClearCache; -begin - if Assigned(FTexture) then - begin - FSharedResources.BeginContext; - try - FTexture := nil; - finally - FSharedResources.EndContext; - end; - end; -end; - -destructor TGrBitmapHandle.Destroy; -begin - ClearCache; - inherited; -end; - -{ TGrCanvasSharedResources } - -procedure TGrCanvasSharedResources.AfterBeginContext; -begin -end; - -procedure TGrCanvasSharedResources.BeforeEndContext; -begin -end; - -procedure TGrCanvasSharedResources.BeginContext; -begin - TMonitor.Enter(Self); - AfterBeginContext; -end; - -constructor TGrCanvasSharedResources.Create; -begin - inherited; - InitializeSharedResources; - try - AfterBeginContext; - try - InitializeContext(FGrDirectContext); - finally - BeforeEndContext; - end; - except - FinalizeSharedResources; - raise; - end; -end; - -destructor TGrCanvasSharedResources.Destroy; -begin - AfterBeginContext; - try - TMessageManager.DefaultManager.SendMessage(TObject(FGrDirectContext), TGrBeforeSharedContextDestructionMessage.Create); - FGrDirectContext := nil; - finally - BeforeEndContext; - end; - FinalizeSharedResources; - inherited; -end; - -procedure TGrCanvasSharedResources.EndContext; -begin - FGrDirectContext.FlushAndSubmit(True); - BeforeEndContext; - TMonitor.Exit(Self); -end; - -procedure TGrCanvasSharedResources.FinalizeSharedResources; -begin -end; - -function TGrCanvasSharedResources.GetGrDirectContext: IGrDirectContext; -begin - Result := FGrDirectContext; -end; - -procedure TGrCanvasSharedResources.InitializeSharedResources; -begin -end; - -{ TGrCanvas } - -procedure TGrCanvas.BeforeDestruction; -begin - inherited; - if Assigned(FGrDirectContext) then - DestroyContext; -end; - -function TGrCanvas.CreateSurfaceFromBitmap: ISkSurface; -begin - TGrBitmapHandle(Bitmap.Handle).ClearCache; - Result := inherited; -end; - -function TGrCanvas.CreateSurfaceFromWindow( - const AContextHandle: THandle): ISkSurface; -begin - Result := CreateSurfaceFromWindow(FGrDirectContext); -end; - -procedure TGrCanvas.DestroyContext; -begin - FGrDirectContext := nil; -end; - -procedure TGrCanvas.DoEndScene; -begin - if Parent <> nil then - begin - Surface.Flush; - GrDirectContext.FlushAndSubmit; - end; - inherited; -end; - -class function TGrCanvas.DoInitializeBitmap(const AWidth, AHeight: Integer; - const AScale: Single; var APixelFormat: TPixelFormat): THandle; -begin - if APixelFormat = TPixelFormat.None then - APixelFormat := PixelFormat; - Result := THandle(TGrBitmapHandle.Create(AWidth, AHeight, APixelFormat)); -end; - -class function TGrCanvas.DoMapBitmap(const ABitmapHandle: THandle; - const AAccess: TMapAccess; var ABitmapData: TBitmapData): Boolean; -begin - if AAccess <> TMapAccess.Read then - TGrBitmapHandle(ABitmapHandle).ClearCache; - Result := inherited; -end; - -function TGrCanvas.GetCache(const ABitmapHandle: THandle): ISkImage; -begin - if Parent <> nil then - begin - if not Assigned(TGrBitmapHandle(ABitmapHandle).FTexture) then - begin - TGrBitmapHandle(ABitmapHandle).FSharedResources := FSharedResources; - FSharedResources.BeginContext; - try - TGrBitmapHandle(ABitmapHandle).FTexture := TSkImage.MakeCrossContext(FSharedResources.GrDirectContext, TSkImageInfo.Create(TGrBitmapHandle(ABitmapHandle).Width, TGrBitmapHandle(ABitmapHandle).Height, SkFmxColorType[TGrBitmapHandle(ABitmapHandle).PixelFormat]), TGrBitmapHandle(ABitmapHandle).Pixels, TGrBitmapHandle(ABitmapHandle).Width * PixelFormatBytes[TGrBitmapHandle(ABitmapHandle).PixelFormat], False, True); - finally - FSharedResources.EndContext; - end; - end; - Result := TGrBitmapHandle(ABitmapHandle).FTexture; - end; -end; - -class procedure TGrCanvas.Initialize; -begin - inherited; - try - InitializeSharedResources(FSharedResources); - except - inherited Finalize; - raise; - end; -end; - -{ TSkTextLayout.TGraphemesMap } - -function TSkTextLayout.TGraphemesMap.CreateGraphemesMapping( - const AText: string): TBytes; -var - I: Integer; - LCharIndex: Integer; - LGrapheme: TSkUnicodeBreakIteratorElem; - LGraphemesIterator: ISkUnicodeBreakIterator; - LUnicode: ISkUnicode; -begin - // For each char of the text in the same position of this array will have the - // index that it represents in the current grapheme, that is, index zero means - // a beginning of the grapheme. - SetLength(Result, Length(AText) + 1); - if AText <> '' then - begin - LUnicode := TSkUnicode.Create; - LGraphemesIterator := LUnicode.GetBreakIterator(TSkBreakType.Graphemes, AText); - LGraphemesIterator.MoveNext; - I := 0; - for LGrapheme in LGraphemesIterator do - begin - LCharIndex := 0; - repeat - Result[I] := LCharIndex; - Inc(LCharIndex); - Inc(I); - until I = LGrapheme.Position; - end; - end; - Result[High(Result)] := 0; -end; - -procedure TSkTextLayout.TGraphemesMap.FindNextGraphemeBoundary( - var AIndex: Integer); -begin - if AIndex < Length(FCharIndexInGrapheme) then - begin - while (FCharIndexInGrapheme[AIndex] <> 0) do - Inc(AIndex); - end; -end; - -procedure TSkTextLayout.TGraphemesMap.FindPreviousGraphemeBoundary( - var AIndex: Integer); -begin - Dec(AIndex, FCharIndexInGrapheme[AIndex]); -end; - -procedure TSkTextLayout.TGraphemesMap.SetText(const AText: string); -begin - if (FText <> AText) or (FCharIndexInGrapheme = nil) then - begin - FText := AText; - FCharIndexInGrapheme := CreateGraphemesMapping(AText); - end; -end; - -{ TSkTextLayout } - -procedure TSkTextLayout.ConvertToPath(const APath: TPathData); -var - I: Integer; - LPath: TPathData; -begin - if (not Assigned(FParagraphs)) or (not Assigned(APath)) then - Exit; - for I := 0 to Length(FParagraphs) - 1 do - begin - if Assigned(FParagraphs[I].Paragraph) then - begin - LPath := TPathData.Create; - try - LPath.AddSkPath(FParagraphs[I].Paragraph.ToPath); - LPath.Translate(FParagraphs[I].Offset + TopLeft); - APath.AddPath(LPath); - finally - LPath.Free; - end; - end; - end; -end; - -class constructor TSkTextLayout.Create; -begin - FAttributesRangeComparer := TComparer.Construct( - function(const ALeft, ARight: TTextAttributedRange): Integer - begin - if (ALeft.Range.Pos + ALeft.Range.Length) <= ARight.Range.Pos then - Result := -1 - else if ALeft.Range.Pos >= (ARight.Range.Pos + ARight.Range.Length) then - Result := 1 - else - Result := 0; - end); - FParagraphTextRangeComparer := TComparer.Construct( - function(const ALeft, ARight: TParagraph): Integer - begin - if (ALeft.Range.Length = 0) or (ARight.Range.Length = 0) then - begin - if InRange(ALeft.Range.Pos, ARight.Range.Pos, ARight.Range.Pos + ARight.Range.Length) or - InRange(ARight.Range.Pos, ALeft.Range.Pos, ALeft.Range.Pos + ALeft.Range.Length) then - begin - Result := 0; - end - else - Result := CompareValue(ALeft.Range.Pos, ARight.Range.Pos); - end - else if (ALeft.Range.Pos + ALeft.Range.Length) <= ARight.Range.Pos then - Result := -1 - else if ALeft.Range.Pos >= (ARight.Range.Pos + ARight.Range.Length) then - Result := 1 - else - Result := 0; - end); -end; - -constructor TSkTextLayout.Create(const ACanvas: TCanvas); -begin - inherited; - {$REGION ' - Workaround RSP-36975'} - // - ------------------------------------------------------------------------- - // - WORKAROUND - // - ------------------------------------------------------------------------- - // - - // - Description: - // - This code is a workaround intended to fix issues with controls that - // - create the TTextLayout but doesn't set the TTextLayout.RightToLeft, - // - like the TText control. - // - - // - Bug report: - // - https://quality.embarcadero.com/browse/RSP-36975 - // - - // - ------------------------------------------------------------------------- - {$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion113))} - FIgnoreUpdates := True; - try - RightToLeft := Application.BiDiMode = TBiDiMode.bdRightToLeft; - finally - FIgnoreUpdates := False; - end; - {$ENDIF} - // - ------------------------------------------------------------------------- - {$ENDREGION} -end; - -procedure TSkTextLayout.DoDrawLayout(const ACanvas: ISkCanvas); -var - I: Integer; -begin - if Assigned(FParagraphs) and Assigned(ACanvas) then - begin - if (FColor <> Color) or (FOpacity <> Opacity) then - UpdateParagraph; - ACanvas.Save; - try - ACanvas.ClipRect(TRectF.Create(TopLeft, MaxSize.X, MaxSize.Y)); - for I := 0 to Length(FParagraphs) - 1 do - if Assigned(FParagraphs[I].Paragraph) then - FParagraphs[I].Paragraph.Paint(ACanvas, FParagraphs[I].Offset.X + TopLeft.X, FParagraphs[I].Offset.Y + TopLeft.Y); - finally - ACanvas.Restore; - end; - end; -end; - -procedure TSkTextLayout.DoDrawLayout(const ACanvas: TCanvas); -var - I: Integer; - LTextLayout: TTextLayout; - LTextLayoutClass: TTextLayoutClass; -begin - if not Assigned(ACanvas) then - Exit; - if ACanvas is TSkCanvasCustom then - begin - if ACanvas.BeginSceneCount > 0 then - DoDrawLayout(TSkCanvasCustom(ACanvas).Canvas); - end - else - begin - LTextLayoutClass := TTextLayoutManager.TextLayoutByCanvas(ACanvas.ClassType); - if LTextLayoutClass <> nil then - begin - LTextLayout := LTextLayoutClass.Create; - try - LTextLayout.BeginUpdate; - try - LTextLayout.Text := Text; - LTextLayout.Padding := Padding; - LTextLayout.WordWrap := WordWrap; - LTextLayout.HorizontalAlign := HorizontalAlign; - LTextLayout.VerticalAlign := VerticalAlign; - LTextLayout.Color := Color; - LTextLayout.Font := Font; - LTextLayout.Opacity := Opacity; - LTextLayout.Trimming := Trimming; - LTextLayout.RightToLeft := RightToLeft; - LTextLayout.MaxSize := MaxSize; - LTextLayout.TopLeft := TopLeft; - LTextLayout.ClearAttributes; - for I := 0 to AttributesCount - 1 do - LTextLayout.AddAttribute(Attributes[I]); - finally - LTextLayout.EndUpdate; - end; - LTextLayout.RenderLayout(ACanvas); - finally - LTextLayout.Free; - end; - end; - end; -end; - - -function TSkTextLayout.DoPositionAtPoint(const APoint: TPointF): Integer; - - function TryGetNearestParagraph(const APoint: TPointF; - out AParagraph: TParagraph): Boolean; - var - I: Integer; - LDistance: Single; - LMinDistance: Single; - LPoint: TPointF; - begin - Result := False; - LPoint := APoint - TopLeft; - LMinDistance := MaxSingle; - for I := 0 to Length(FParagraphs) - 1 do - begin - if Assigned(FParagraphs[I].Paragraph) then - begin - if FParagraphs[I].Bounds.Contains(APoint) then - LDistance := -1 - else - begin - LDistance := FParagraphs[I].Bounds.TopLeft.Distance(LPoint); - LDistance := Min(LDistance, FParagraphs[I].Bounds.BottomRight.Distance(LPoint)); - LDistance := Min(LDistance, PointF(FParagraphs[I].Bounds.Left, FParagraphs[I].Bounds.Bottom).Distance(LPoint)); - LDistance := Min(LDistance, PointF(FParagraphs[I].Bounds.Right, FParagraphs[I].Bounds.Top).Distance(LPoint)); - end; - if LDistance < 0 then - begin - AParagraph := FParagraphs[I]; - Exit(True); - end; - if LDistance < LMinDistance then - begin - LMinDistance := LDistance; - AParagraph := FParagraphs[I]; - Result := True; - end; - end; - end; - end; - -var - LParagraph: TParagraph; -begin - if (not Assigned(FParagraphs)) or (not TryGetNearestParagraph(APoint, LParagraph)) then - Exit(-1); - Result := LParagraph.Paragraph.GetGlyphPositionAtCoordinate(APoint.X - TopLeft.X - LParagraph.Offset.X, APoint.Y - TopLeft.Y - LParagraph.Offset.Y).Position; -end; - -function TSkTextLayout.DoRegionForRange(const ARange: TTextRange): TRegion; - - // SkParagraph returns one rectangle for each grapheme, while other TextLayout - // implementations consider a single rectangle containing graphemes side by - // side on the same line. Simulating this behavior avoids issues in text - // editing controls. - function SummarizeRegion(const ARegion: TRegion): TRegion; - var - I: Integer; - LLastRect: PRectF; - LResultCount: Integer; - begin - Assert(Length(ARegion) > 1); - LResultCount := 1; - SetLength(Result, Length(ARegion)); - Result[0] := ARegion[0]; - LLastRect := @Result[0]; - for I := 1 to Length(ARegion) - 1 do - begin - if (SameValue(LLastRect.Right, ARegion[I].Left, 1)) and (InRange(ARegion[I].CenterPoint.Y, LLastRect.Top, LLastRect.Bottom) or InRange(LLastRect.CenterPoint.Y, ARegion[I].Top, ARegion[I].Bottom)) then - begin - LLastRect.Right := ARegion[I].Right; - LLastRect.Top := Min(LLastRect.Top, ARegion[I].Top); - LLastRect.Bottom := Max(LLastRect.Bottom, ARegion[I].Bottom); - end - else - begin - Result[LResultCount] := ARegion[I]; - Inc(LResultCount); - Inc(LLastRect); - end; - end; - SetLength(Result, LResultCount); - end; - - function GetRegionForRange(const AStartIndex, AEndIndex: Integer): TRegion; - var - I: Integer; - LLength: Integer; - LParagraph: TParagraph; - LTextBoxes: TArray; - begin - Result := nil; - for LParagraph in GetParagraphsInRange(AStartIndex, AEndIndex - AStartIndex) do - begin - if Assigned(LParagraph.Paragraph) then - begin - LTextBoxes := LParagraph.Paragraph.GetRectsForRange(AStartIndex - LParagraph.Range.Pos, AEndIndex - LParagraph.Range.Pos, TSkRectHeightStyle.Max, TSkRectWidthStyle.Tight); - LLength := Length(Result); - SetLength(Result, LLength + Length(LTextBoxes)); - for I := LLength to Length(LTextBoxes) - 1 do - begin - Result[I] := LTextBoxes[I].Rect; - Result[I].Offset(LParagraph.Offset + TopLeft); - end; - end; - end; - if Length(Result) > 1 then - Result := SummarizeRegion(Result); - end; - -var - LEndIndex: Integer; - LStartIndex: Integer; -begin - if not Assigned(FParagraphs) then - Exit(nil); - FGraphemesMap.Text := Text; - LStartIndex := Max(ARange.Pos, 0); - LEndIndex := Min(LStartIndex + ARange.Length, Text.Length); - FGraphemesMap.FindPreviousGraphemeBoundary(LStartIndex); - FGraphemesMap.FindPreviousGraphemeBoundary(LEndIndex); - - if LStartIndex = LEndIndex then - begin - if LStartIndex = 0 then - begin - // Right grapheme - LEndIndex := 1; - FGraphemesMap.FindNextGraphemeBoundary(LEndIndex); - Result := GetRegionForRange(LStartIndex, LEndIndex); - if Length(Result) > 0 then - Result := [RectF(Result[0].Left, Result[0].Top, Result[0].Left, Result[0].Bottom)]; - end - else - begin - // Left grapheme - Dec(LStartIndex); - FGraphemesMap.FindPreviousGraphemeBoundary(LStartIndex); - Result := GetRegionForRange(LStartIndex, LEndIndex); - if Length(Result) > 0 then - Result := [RectF(Result[0].Right, Result[0].Top, Result[0].Right, Result[0].Bottom)]; - end; - end - else - Result := GetRegionForRange(LStartIndex, LEndIndex); -end; - -procedure TSkTextLayout.DoRenderLayout; -type - THorizontalAlign = (Left, Center, Right); -const - HorizontalTextAlign: array[TTextAlign, Boolean] of THorizontalAlign = ((THorizontalAlign.Center, THorizontalAlign.Center), (THorizontalAlign.Left, THorizontalAlign.Right), (THorizontalAlign.Right, THorizontalAlign.Left)); - - function GetTextRect: TRectF; - var - I: Integer; - LOffset: TPointF; - LTextBox: TSkTextBox; - LTextBoxes: TArray; - begin - Result := TRectF.Empty; - LOffset := PointF(0, 0); - for I := 0 to Length(FParagraphs) - 1 do - begin - if Assigned(FParagraphs[I].Paragraph) then - begin - FParagraphs[I].Bounds := TRectF.Empty; - LTextBoxes := FParagraphs[I].Paragraph.GetRectsForRange(0, FParagraphs[I].Range.Length, TSkRectHeightStyle.Max, TSkRectWidthStyle.Tight); - for LTextBox in LTextBoxes do - begin - if FParagraphs[I].Bounds.IsEmpty then - FParagraphs[I].Bounds := LTextBox.Rect - else - FParagraphs[I].Bounds := FParagraphs[I].Bounds + LTextBox.Rect; - end; - if FParagraphs[I].Bounds.IsEmpty then - FParagraphs[I].Bounds.Height := FParagraphs[I].Paragraph.Height; - FParagraphs[I].Bounds.Offset(LOffset); - if Result.IsEmpty then - Result := FParagraphs[I].Bounds - else - Result := Result + FParagraphs[I].Bounds; - LOffset.Y := FParagraphs[I].Bounds.Bottom; - end; - end; - end; - - function GetParagraphOffset(ATextRect: TRectF): TPointF; - var - LBounds: TRectF; - begin - ATextRect := RectF(0, 0, ATextRect.Width, ATextRect.Height); - if not NeedHorizontalAlignment then - begin - case HorizontalTextAlign[HorizontalAlign, RightToLeft] of - THorizontalAlign.Center: ATextRect.Offset((MaxSize.X - Padding.Left - Padding.Right - ATextRect.Width) / 2, 0); - THorizontalAlign.Right : ATextRect.Offset(MaxSize.X - Padding.Left - Padding.Right - ATextRect.Right, 0); - end; - end; - - LBounds := RectF(0, 0, ATextRect.Width, ATextRect.Height); - case HorizontalTextAlign[HorizontalAlign, RightToLeft] of - THorizontalAlign.Center: LBounds.Offset((MaxSize.X - Padding.Left - Padding.Right - LBounds.Width) / 2, 0); - THorizontalAlign.Right : LBounds.Offset(MaxSize.X - Padding.Left - Padding.Right - LBounds.Right, 0); - end; - case VerticalAlign of - TTextAlign.Center : LBounds.Offset(0, (MaxSize.Y - Padding.Top - Padding.Bottom - LBounds.Height) / 2); - TTextAlign.Trailing: LBounds.Offset(0, MaxSize.Y - Padding.Top - Padding.Bottom - LBounds.Bottom); - end; - LBounds.Offset(Padding.Rect.TopLeft); - Result := LBounds.TopLeft - ATextRect.TopLeft; - end; - -var - I: Integer; - LOffset: TPointF; -begin - {$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion113))} - if FIgnoreUpdates then - Exit; - {$ENDIF} - UpdateParagraph; - FTextRect := GetTextRect; - LOffset := GetParagraphOffset(FTextRect); - FTextRect.Offset(LOffset); - for I := 0 to Length(FParagraphs) - 1 do - begin - if Assigned(FParagraphs[I].Paragraph) then - FParagraphs[I].Bounds.Offset(LOffset); - end; - for I := 0 to Length(FParagraphs) - 1 do - begin - if Assigned(FParagraphs[I].Paragraph) then - begin - FParagraphs[I].Offset := LOffset; - LOffset := LOffset + PointF(0, FParagraphs[I].Bounds.Height); - end; - end; - case VerticalAlign of - TTextAlign.Leading : FTextRect.Bottom := Min(MaxSize.Y - Padding.Top - Padding.Bottom, FTextRect.Bottom); - TTextAlign.Center : FTextRect.Inflate(0, Min(((MaxSize.Y - Padding.Top - Padding.Bottom) - FTextRect.Height) / 2, 0)); - TTextAlign.Trailing: FTextRect.Top := Max(FTextRect.Bottom - (MaxSize.Y - Padding.Top - Padding.Bottom), FTextRect.Top); - end; - case HorizontalTextAlign[HorizontalAlign, RightToLeft] of - THorizontalAlign.Left : FTextRect.Right := Min(MaxSize.X - Padding.Left - Padding.Right, FTextRect.Right); - THorizontalAlign.Center: FTextRect.Inflate(Min(((MaxSize.X - Padding.Left - Padding.Right) - FTextRect.Width) / 2, 0), 0); - THorizontalAlign.Right : FTextRect.Left := Max(FTextRect.Right - (MaxSize.X - Padding.Left - Padding.Right), FTextRect.Left); - end; -end; - -function TSkTextLayout.GetParagraphsInRange(const APos, - ALength: Integer): TArray; -var - LFoundIndex: Integer; - LParagraph: TParagraph; -begin - Result := nil; - LParagraph.Range := TTextRange.Create(APos, ALength); - if TArray.BinarySearch(FParagraphs, LParagraph, LFoundIndex, FParagraphTextRangeComparer) then - begin - repeat - Result := Result + [FParagraphs[LFoundIndex]]; - Inc(LFoundIndex); - until (LFoundIndex >= Length(FParagraphs)) or (FParagraphTextRangeComparer.Compare(FParagraphs[LFoundIndex], LParagraph) <> 0); - end; -end; - -function TSkTextLayout.GetTextHeight: Single; -begin - Result := FTextRect.Height; -end; - -function TSkTextLayout.GetTextRect: TRectF; -begin - Result := FTextRect; - Result.Offset(TopLeft); -end; - -function TSkTextLayout.GetTextWidth: Single; -begin - Result := FTextRect.Width; -end; - -class procedure TSkTextLayout.Initialize; -{$IFDEF ANDROID} -const - FontFilesFilter = '*.ttf'; // Do not localize -var - LFileName: string; -{$ENDIF} -begin - {$IFDEF ANDROID} - for LFileName in TDirectory.GetFiles(TPath.GetDocumentsPath, FontFilesFilter) do - TSkDefaultProviders.RegisterTypeface(LFileName); - {$ENDIF} -end; - -// The SkParagraph normally doesn't cut a word in half, it cuts the whole word. -// In some scenarios it can cause some errors, for example in edits where it is -// mandatory to cut in the middle of the word. To fix this we will readjust the -// MaxWidth, align horizontally manually and cut with ClipRect. -function TSkTextLayout.NeedHorizontalAlignment: Boolean; -begin - Result := (not WordWrap) and (Trimming = TTextTrimming.None); -end; - -procedure TSkTextLayout.RenderLayout(const ACanvas: ISkCanvas); -begin - RenderLayout(nil); - DoDrawLayout(ACanvas); -end; - -procedure TSkTextLayout.SetMaxLines(AValue: Integer); -begin - AValue := Max(AValue, 0); - if FMaxLines <> AValue then - begin - FMaxLines := AValue; - BeginUpdate; - try - {$IF CompilerVersion >= 29} - SetNeedUpdate; - {$ELSE} - RightToLeft := not RightToLeft; - RightToLeft := not RightToLeft; - {$ENDIF} - finally - EndUpdate; - end; - end; -end; - -procedure TSkTextLayout.UpdateParagraph; -const -{$IF CompilerVersion >= 31} - SkFontSlant : array[TFontSlant] of TSkFontSlant = (TSkFontSlant.Upright, TSkFontSlant.Italic, TSkFontSlant.Oblique); - SkFontWeight: array[TFontWeight] of Integer = (100, 200, 300, 350, 400, 500, 600, 700, 800, 900, 950); - SkFontWidth : array[TFontStretch] of Integer = (1, 2, 3, 4, 5, 6, 7, 8, 9); -{$ENDIF} - ZeroWidthChar = #8203; - - function GetFontFamilies(const AValue: string): TArray; inline; - begin - Result := AValue.Split([', ', ','], TStringSplitOptions.ExcludeEmpty){$IFDEF MACOS} + ['Helvetica Neue']{$ELSEIF DEFINED(LINUX)} + ['Ubuntu']{$ENDIF}; - end; - - function GetNormalizedAttributes(const ASubText: string; - const ASubTextPosition: Integer): TArray; - var - I: Integer; - LAttribute: TTextAttributedRange; - LAttributes: TList; - LIndex: Integer; - LNeighborAttribute: TTextAttributedRange; - begin - if AttributesCount = 0 then - Exit(nil); - LAttributes := TList.Create; - try - for I := 0 to AttributesCount - 1 do - begin - LAttribute := TTextAttributedRange.Create(TTextRange.Create(Attributes[I].Range.Pos - ASubTextPosition, Attributes[I].Range.Length), Attributes[I].Attribute); - if LAttribute.Range.Pos < 0 then - LAttribute.Range := TTextRange.Create(0, LAttribute.Range.Pos + LAttribute.Range.Length); - if (LAttribute.Range.Pos + LAttribute.Range.Length) > ASubText.Length then - LAttribute.Range := TTextRange.Create(LAttribute.Range.Pos, LAttribute.Range.Length - ((LAttribute.Range.Pos + LAttribute.Range.Length) - ASubText.Length)); - if LAttribute.Range.Length <= 0 then - begin - LAttribute.Free; - Continue; - end; - if LAttributes.BinarySearch(LAttribute, LIndex, FAttributesRangeComparer) then - begin - if (LAttributes[LIndex].Range.Pos < LAttribute.Range.Pos) and ((LAttributes[LIndex].Range.Pos + LAttributes[LIndex].Range.Length) > (LAttribute.Range.Pos + LAttribute.Range.Length)) then - begin - LNeighborAttribute := TTextAttributedRange.Create(TTextRange.Create(LAttribute.Range.Pos + LAttribute.Range.Length, LAttributes[LIndex].Range.Pos + LAttributes[LIndex].Range.Length - (LAttribute.Range.Pos + LAttribute.Range.Length)), LAttributes[LIndex].Attribute); - LAttributes.Insert(LIndex + 1, LNeighborAttribute); - LAttributes.Insert(LIndex + 1, LAttribute); - LNeighborAttribute := LAttributes[LIndex]; - LNeighborAttribute.Range.Length := LAttribute.Range.Pos - LNeighborAttribute.Range.Pos; - Continue; - end; - end; - LAttributes.Insert(LIndex, LAttribute); - if LIndex > 0 then - begin - LNeighborAttribute := LAttributes[LIndex - 1]; - if (LNeighborAttribute.Range.Pos + LNeighborAttribute.Range.Length) > LAttribute.Range.Pos then - begin - LNeighborAttribute.Range := TTextRange.Create(LNeighborAttribute.Range.Pos, LNeighborAttribute.Range.Length - ((LNeighborAttribute.Range.Pos + LNeighborAttribute.Range.Length) - LAttribute.Range.Pos)); - if LNeighborAttribute.Range.Length <= 0 then - begin - LNeighborAttribute.Free; - LAttributes.Delete(LIndex - 1); - Dec(LIndex); - end; - end; - end; - if LIndex < LAttributes.Count - 1 then - begin - LNeighborAttribute := LAttributes[LIndex + 1]; - if LNeighborAttribute.Range.Pos < (LAttribute.Range.Pos + LAttribute.Range.Length) then - begin - LNeighborAttribute.Range := TTextRange.Create(LAttribute.Range.Pos + LAttribute.Range.Length, LNeighborAttribute.Range.Length - ((LAttribute.Range.Pos + LAttribute.Range.Length) - LNeighborAttribute.Range.Pos)); - if LNeighborAttribute.Range.Length <= 0 then - begin - LNeighborAttribute.Free; - LAttributes.Delete(LIndex + 1); - end; - end; - end; - end; - Result := LAttributes.ToArray; - finally - LAttributes.Free; - end; - end; - - procedure InitializeTextStyle(const ATextStyle: ISkTextStyle; const AFont: TFont; const AColor: TAlphaColor); - begin - ATextStyle.Color := MakeColor(AColor, FOpacity); - ATextStyle.FontFamilies := GetFontFamilies(AFont.Family); - ATextStyle.FontSize := AFont.Size; - {$IF CompilerVersion < 31} - if (TFontStyle.fsBold in AFont.Style) and (TFontStyle.fsItalic in AFont.Style) then - ATextStyle.FontStyle := TSkFontStyle.BoldItalic - else if TFontStyle.fsBold in AFont.Style then - ATextStyle.FontStyle := TSkFontStyle.Bold - else if TFontStyle.fsItalic in AFont.Style then - ATextStyle.FontStyle := TSkFontStyle.Italic - else - ATextStyle.FontStyle := TSkFontStyle.Normal; - {$ELSE} - ATextStyle.FontStyle := TSkFontStyle.Create(SkFontWeight[AFont.StyleExt.Weight], SkFontWidth[AFont.StyleExt.Stretch], SkFontSlant[AFont.StyleExt.Slant]); - {$ENDIF} - if (TFontStyle.fsUnderline in AFont.Style) or (TFontStyle.fsStrikeOut in AFont.Style) then - begin - ATextStyle.DecorationColor := MakeColor(Color, FOpacity); - if TFontStyle.fsUnderline in AFont.Style then - ATextStyle.Decorations := ATextStyle.Decorations + [TSkTextDecoration.Underline]; - if TFontStyle.fsStrikeOut in AFont.Style then - ATextStyle.Decorations := ATextStyle.Decorations + [TSkTextDecoration.LineThrough]; - end; - end; - - function CreateTextStyle(const AAttribute: TTextAttribute): ISkTextStyle; - begin - Result := TSkTextStyle.Create; - if AAttribute.Font <> nil then - InitializeTextStyle(Result, AAttribute.Font, AAttribute.Color) - else - InitializeTextStyle(Result, Font, AAttribute.Color); - end; - - function CreateDefaultTextStyle: ISkTextStyle; - begin - Result := TSkTextStyle.Create; - InitializeTextStyle(Result, Font, Color); - end; - - function CreateParagraphStyle(const AAttributes: TArray; - AMaxLines: Integer): ISkParagraphStyle; - const - SkTextAlign: array[TTextAlign] of TSkTextAlign = (TSkTextAlign.Center, TSkTextAlign.Start, TSkTextAlign.Terminate); - var - LAttribute: TTextAttributedRange; - LMinFontSize: Single; - begin - Result := TSkParagraphStyle.Create; - if RightToLeft then - Result.TextDirection := TSkTextDirection.RightToLeft; - if Trimming in [TTextTrimming.Character, TTextTrimming.Word] then - Result.Ellipsis := '...'; - if WordWrap then - begin - if AMaxLines <= 0 then - Result.MaxLines := High(Integer) - else - Result.MaxLines := AMaxLines; - end - else - Result.MaxLines := 1; - if NeedHorizontalAlignment then - begin - if RightToLeft then - Result.TextAlign := TSkTextAlign.Terminate - else - Result.TextAlign := TSkTextAlign.Start; - end - else - Result.TextAlign := SkTextAlign[HorizontalAlign]; - Result.TextStyle := CreateDefaultTextStyle; - if Result.MaxLines = NativeUInt(High(Integer)) then - begin - LMinFontSize := Result.TextStyle.FontSize; - for LAttribute in AAttributes do - LMinFontSize := Min(LMinFontSize, LAttribute.Attribute.Font.Size); - if LMinFontSize > 0.1 then - begin - AMaxLines := Ceil(MaxSize.Y / LMinFontSize); - if AMaxLines > 0 then - Result.MaxLines := AMaxLines; - end; - end; - end; - - // Temporary solution to fix an issue with Skia - // https://bugs.chromium.org/p/skia/issues/detail?id=13117 - // - // SkParagraph has several issues with the #13 line break, so the best thing - // to do is replace it with #10 or a zero-widh character (#8203) - function NormalizeParagraphText(const AText: string): string; inline; - begin - Result := AText.Replace(#13#10, ZeroWidthChar + #10).Replace(#13, #10); - end; - - function CreateParagraph(const AMaxLines: Integer; const ASubText: string; - const ASubTextPosition: Integer): ISkParagraph; - var - LAttribute: TTextAttributedRange; - LAttributes: TArray; - LBuilder: ISkParagraphBuilder; - LLastAttributeEndIndex: Integer; - LText: string; - begin - FColor := Color; - FOpacity := Opacity; - LAttributes := GetNormalizedAttributes(ASubText, ASubTextPosition); - try - LBuilder := TSkParagraphBuilder.Create(CreateParagraphStyle(LAttributes, AMaxLines), TSkDefaultProviders.TypefaceFont); - LLastAttributeEndIndex := 0; - for LAttribute in LAttributes do - begin - if LLastAttributeEndIndex < LAttribute.Range.Pos then - LBuilder.AddText(ASubText.Substring(LLastAttributeEndIndex, LAttribute.Range.Pos - LLastAttributeEndIndex)); - LText := NormalizeParagraphText(ASubText.Substring(LAttribute.Range.Pos, LAttribute.Range.Length)); - if not LText.IsEmpty then - begin - LBuilder.PushStyle(CreateTextStyle(LAttribute.Attribute)); - LBuilder.AddText(LText); - LBuilder.Pop; - end; - LLastAttributeEndIndex := LAttribute.Range.Pos + LAttribute.Range.Length; - end; - if LLastAttributeEndIndex < ASubText.Length then - LBuilder.AddText(ASubText.Substring(LLastAttributeEndIndex, ASubText.Length - LLastAttributeEndIndex)); - finally - for LAttribute in LAttributes do - LAttribute.DisposeOf; - end; - Result := LBuilder.Build; - end; - - procedure DoUpdateParagraph(var AParagraph: TParagraph; - const ASubText: string; const AMaxLines: Integer); - {$IF CompilerVersion < 29} - const - MaxLayoutSize: TPointF = (X: $FFFF; Y: $FFFF); - {$ENDIF} - var - LMetrics: TSkMetrics; - begin - AParagraph.Paragraph := CreateParagraph(AMaxLines, ASubText, AParagraph.Range.Pos); - if NeedHorizontalAlignment then - AParagraph.Paragraph.Layout(MaxLayoutSize.X) - else - AParagraph.Paragraph.Layout(MaxSize.X - Padding.Left - Padding.Right); - if WordWrap and (AParagraph.Paragraph.Height > MaxSize.Y - Padding.Top - Padding.Bottom) then - begin - for LMetrics in AParagraph.Paragraph.LineMetrics do - begin - if (LMetrics.LineNumber <> 0) and (LMetrics.Baseline + LMetrics.Descent > MaxSize.Y - Padding.Top - Padding.Bottom) then - begin - AParagraph.Paragraph := CreateParagraph(LMetrics.LineNumber, ASubText, AParagraph.Range.Pos); - AParagraph.Paragraph.Layout(MaxSize.X - Padding.Left - Padding.Right); - Break; - end; - end; - end; - end; - -var - I: Integer; - LLimitedLines: Boolean; - LLines: TArray; - LMaxLines: Integer; - LPos: Integer; - LText: string; -begin - LText := Text; - - {$REGION ' - Workaround RSP-38480'} - // - ------------------------------------------------------------------------- - // - WORKAROUND - // - ------------------------------------------------------------------------- - // - - // - Description: - // - This code is a workaround intended to fix issues with controls that - // - create the TTextLayout but doesn't set the TTextLayout.RightToLeft, - // - like the TText control. - // - This code is a workaround intended to fix issues with function - // - FMX.Types.DelAmp with results in texts with #0 char at end of string - // - when the original text contains a '&' char - // - - // - Bug report: - // - https://quality.embarcadero.com/browse/RSP-38480 - // - - // - ------------------------------------------------------------------------- - {$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion112))} - if LText.EndsWith(#0) then - LText := LText.Substring(0, LText.Length - 1) + ZeroWidthChar; - {$ENDIF} - // - ------------------------------------------------------------------------- - {$ENDREGION} - - if WordWrap or LText.IsEmpty then - LLines := [LText] - else - LLines := LText.Replace(#13#10, ZeroWidthChar + #10).Replace(#13, #10).Replace(#10, ZeroWidthChar + #10).Split([#10]); - LPos := 0; - LMaxLines := FMaxLines; - LLimitedLines := FMaxLines <> 0; - SetLength(FParagraphs, Length(LLines)); - for I := 0 to Length(LLines) - 1 do - begin - FParagraphs[I].Range := TTextRange.Create(LPos, LLines[I].Length); - if LMaxLines = -1 then - begin - FParagraphs[I].Bounds := TRectF.Empty; - FParagraphs[I].Paragraph := nil; - FParagraphs[I].Offset := PointF(0, 0); - end - else - begin - DoUpdateParagraph(FParagraphs[I], LLines[I], LMaxLines); - if LLimitedLines then - begin - Dec(LMaxLines, Length(FParagraphs[I].Paragraph.LineMetrics)); - if LMaxLines <= 0 then - LMaxLines := -1; - end; - end; - Inc(LPos, LLines[I].Length); - end; -end; - -{ TSkBitmapHandleCodec } - -class constructor TSkBitmapHandleCodec.Create; -begin - RegisterIfNotExists('.bmp', SVBitmaps, False); - RegisterIfNotExists('.gif', SVGIFImages, False); - RegisterIfNotExists('.ico', SVIcons, False); - RegisterIfNotExists('.wbmp', SWBMPImages, False); - RegisterIfNotExists('.webp', SVWEBPImages, True); - {$IFNDEF MSWINDOWS} - RegisterIfNotExists('.arw', SRawSony, False); - RegisterIfNotExists('.cr2', SRawCanon, False); - RegisterIfNotExists('.dng', SRawDNG, False); - RegisterIfNotExists('.nef', SRawNikon, False); - RegisterIfNotExists('.nrw', SRawNikon, False); - RegisterIfNotExists('.orf', SRawORF, False); - RegisterIfNotExists('.raf', SRawRAF, False); - RegisterIfNotExists('.rw2', SRawPanasonic, False); - RegisterIfNotExists('.pef', SRawPEF, False); - RegisterIfNotExists('.srw', SRawSRW, False); - {$ENDIF} -end; - -function TSkBitmapHandleCodec.FitSize(const AWidth, AHeight: Integer; - const AFitWidth, AFitHeight: Single): TSize; -var - LRatio: Single; -begin - if (AWidth / AFitWidth) > (AHeight / AFitHeight) then - LRatio := AWidth / AFitWidth - else - LRatio := AHeight / AFitHeight; - if LRatio < 1 then - Result := TSize.Create(AWidth, AHeight) - else - Result := TSize.Create(Trunc((AWidth + Epsilon) / LRatio), Trunc((AHeight + Epsilon) / LRatio)); -end; - -class function TSkBitmapHandleCodec.GetImageSize( - const AFileName: string): TPointF; -var - LCodec: ISkCodec; -begin - LCodec := TSkCodec.MakeFromFile(AFileName); - if not Assigned(LCodec) then - Exit(TPointF.Create(0, 0)); - Result := TPointF.Create(LCodec.Width, LCodec.Height); -end; - -class function TSkBitmapHandleCodec.IsValid(const AStream: TStream): Boolean; - - function IsValid(const AMemoryStream: TCustomMemoryStream): Boolean; inline; - begin - Result := Assigned(TSkCodec.MakeWithoutCopy(AMemoryStream.Memory, AMemoryStream.Size)); - end; - -var - LMemoryStream: TMemoryStream; -begin - if AStream is TCustomMemoryStream then - Result := IsValid(TCustomMemoryStream(AStream)) - else - begin - LMemoryStream := TMemoryStream.Create; - try - LMemoryStream.CopyFrom(AStream, 0); - Result := IsValid(LMemoryStream); - finally - LMemoryStream.Free; - end; - end; -end; - -function TSkBitmapHandleCodec.LoadFromFile(const AFileName: string; - const ABitmapSurface: TBitmapSurface; const AMaxSizeLimit: Cardinal): Boolean; -var - LCodec: ISkCodec; - LImage: ISkImage; - LSize: TSize; -begin - LCodec := TSkCodec.MakeFromFile(AFileName); - if not Assigned(LCodec) then - Exit(False); - if AMaxSizeLimit > 0 then - begin - LSize := FitSize(LCodec.Width, LCodec.Height, AMaxSizeLimit, AMaxSizeLimit); - ABitmapSurface.SetSize(LSize.Width, LSize.Height, SkFmxPixelFormat[SkNative32ColorType]); - LImage := LCodec.GetImage(SkNative32ColorType); - Result := (Assigned(LImage)) and (LImage.ScalePixels(TSkImageInfo.Create(ABitmapSurface.Width, ABitmapSurface.Height), ABitmapSurface.Bits, ABitmapSurface.Pitch, TSkImageCachingHint.Disallow)); - end - else - begin - ABitmapSurface.SetSize(LCodec.Width, LCodec.Height, SkFmxPixelFormat[SkNative32ColorType]); - Result := LCodec.GetPixels(ABitmapSurface.Bits, ABitmapSurface.Pitch, SkNative32ColorType); - end; -end; - -function TSkBitmapHandleCodec.LoadFromStream(const AStream: TStream; - const ABitmapSurface: TBitmapSurface; const AMaxSizeLimit: Cardinal): Boolean; - - function LoadFromStream(const AMemoryStream: TCustomMemoryStream): Boolean; - var - LCodec: ISkCodec; - LImage: ISkImage; - LSize: TSize; - begin - LCodec := TSkCodec.MakeWithoutCopy(AMemoryStream.Memory, AMemoryStream.Size); - if not Assigned(LCodec) then - Exit(False); - if AMaxSizeLimit > 0 then - begin - LSize := FitSize(LCodec.Width, LCodec.Height, AMaxSizeLimit, AMaxSizeLimit); - ABitmapSurface.SetSize(LSize.Width, LSize.Height, SkFmxPixelFormat[SkNative32ColorType]); - LImage := LCodec.GetImage(SkNative32ColorType); - Result := (Assigned(LImage)) and (LImage.ScalePixels(TSkImageInfo.Create(ABitmapSurface.Width, ABitmapSurface.Height), ABitmapSurface.Bits, ABitmapSurface.Pitch, TSkImageCachingHint.Disallow)); - end - else - begin - ABitmapSurface.SetSize(LCodec.Width, LCodec.Height, SkFmxPixelFormat[SkNative32ColorType]); - Result := LCodec.GetPixels(ABitmapSurface.Bits, ABitmapSurface.Pitch, SkNative32ColorType); - end; - end; - -var - LMemoryStream: TMemoryStream; -begin - if AStream is TCustomMemoryStream then - Result := LoadFromStream(TCustomMemoryStream(AStream)) - else - begin - LMemoryStream := TMemoryStream.Create; - try - LMemoryStream.CopyFrom(AStream, 0); - Result := LoadFromStream(LMemoryStream); - finally - LMemoryStream.Free; - end; - end; -end; - -function TSkBitmapHandleCodec.LoadThumbnailFromFile(const AFileName: string; - const AFitWidth, AFitHeight: Single; const AUseEmbedded: Boolean; - const ABitmapSurface: TBitmapSurface): Boolean; -var - LCodec: ISkCodec; - LImage: ISkImage; - LSize: TSize; -begin - LCodec := TSkCodec.MakeFromFile(AFileName); - if not Assigned(LCodec) then - Exit(False); - LSize := FitSize(LCodec.Width, LCodec.Height, AFitWidth, AFitHeight); - ABitmapSurface.SetSize(LSize.Width, LSize.Height, SkFmxPixelFormat[SkNative32ColorType]); - LImage := LCodec.GetImage(SkNative32ColorType); - Result := (Assigned(LImage)) and (LImage.ScalePixels(TSkImageInfo.Create(ABitmapSurface.Width, ABitmapSurface.Height), ABitmapSurface.Bits, ABitmapSurface.Pitch, TSkImageCachingHint.Disallow)); -end; - -class procedure TSkBitmapHandleCodec.RegisterIfNotExists(const AFileExtension, - ADescription: string; const ACanSave: Boolean); -begin - if not TBitmapCodecManager.CodecExists(AFileExtension) then - TBitmapCodecManager.RegisterBitmapCodecClass(AFileExtension, ADescription, ACanSave, TSkBitmapHandleCodec); -end; - -function TSkBitmapHandleCodec.SaveToFile(const AFileName: string; - const ABitmapSurface: TBitmapSurface; - const ASaveParams: PBitmapCodecSaveParams): Boolean; -var - LQuality: Integer; -begin - if ASaveParams <> nil then - LQuality := ASaveParams.Quality - else - LQuality := 100; - TSkImageEncoder.EncodeToFile(AFileName, TSkImageInfo.Create(ABitmapSurface.Width, ABitmapSurface.Height, SkFmxColorType[ABitmapSurface.PixelFormat]), ABitmapSurface.Bits, ABitmapSurface.Pitch, LQuality); - Result := True; -end; - -function TSkBitmapHandleCodec.SaveToStream(const AStream: TStream; - const ABitmapSurface: TBitmapSurface; const AExtension: string; - const ASaveParams: PBitmapCodecSaveParams): Boolean; -var - LQuality: Integer; -begin - if ASaveParams <> nil then - LQuality := ASaveParams.Quality - else - LQuality := 100; - TSkImageEncoder.EncodeToStream(AStream, TSkImageInfo.Create(ABitmapSurface.Width, ABitmapSurface.Height, SkFmxColorType[ABitmapSurface.PixelFormat]), ABitmapSurface.Bits, ABitmapSurface.Pitch, ExtensionToEncodedImageFormat(AExtension), LQuality); - Result := True; -end; - -{$IF DEFINED(MSWINDOWS)} - -{ TSkRasterWindowsCanvas } - -function TSkRasterWindowsCanvas.CreateSurfaceFromWindow( - const AContextHandle: THandle): ISkSurface; -var - LBitmapInfo: TBitmapInfo; - LHeight: Integer; - LWidth: Integer; -begin - LWidth := Round(Width * Scale); - LHeight := Round(Height * Scale); - if FBitmap = 0 then - begin - FillChar(LBitmapInfo, SizeOf(TBitmapInfo), 0); - FillChar(LBitmapInfo, 0, SizeOf(TBitmapInfo)); - LBitmapInfo.bmiHeader.biSize := SizeOf(TBitmapInfoHeader); - LBitmapInfo.bmiHeader.biWidth := LWidth; - LBitmapInfo.bmiHeader.biHeight := -LHeight; - LBitmapInfo.bmiHeader.biPlanes := 1; - LBitmapInfo.bmiHeader.biBitCount := 32; - LBitmapInfo.bmiHeader.biCompression := BI_RGB; - LBitmapInfo.bmiHeader.biSizeImage := LWidth * LHeight * SkBytesPerPixel[TSkColorType.BGRA8888]; - FBitmap := CreateDIBSection(0, LBitmapInfo, DIB_RGB_COLORS, FBits, 0, 0); - if FBitmap = 0 then - raise ESkCanvas.Create('Could not create a DIB.'); - end; - FDC := HDC(AContextHandle); - Result := TSkSurface.MakeRasterDirect(TSkImageInfo.Create(LWidth, LHeight, TSkColorType.BGRA8888), FBits, LWidth * SkBytesPerPixel[TSkColorType.BGRA8888]); -end; - -destructor TSkRasterWindowsCanvas.Destroy; -begin - if FBitmap <> 0 then - DeleteObject(FBitmap); - inherited; -end; - -procedure TSkRasterWindowsCanvas.DoEndScene; -var - LBitmapDC: HDC; -begin - inherited; - if Parent <> nil then - begin - if FDC <> 0 then - begin - LBitmapDC := CreateCompatibleDC(0); - if LBitmapDC = 0 then - raise ESkCanvas.Create('Could not create a DC.'); - try - if SelectObject(LBitmapDC, FBitmap) = 0 then - raise ESkCanvas.Create('Could not select the bitmap in to the DC.'); - if not BitBlt(FDC, 0, 0, Round(Width * Scale), Round(Height * Scale), LBitmapDC, 0, 0, SRCCOPY) then - raise ESkCanvas.Create('Unable to move pixels to window context.'); - finally - DeleteDC(LBitmapDC); - end; - end; - end; -end; - -procedure TSkRasterWindowsCanvas.Resized; -begin - if FBitmap <> 0 then - begin - DeleteObject(FBitmap); - FBitmap := 0; - end; -end; - -{$ELSEIF DEFINED(MACOS) and NOT DEFINED(IOS)} - -{ TSkRasterMacOSCanvas } - -function TSkRasterMacOSCanvas.CreateSurfaceFromWindow( - const AContextHandle: THandle): ISkSurface; -var - LHeight: Integer; - LWidth: Integer; -begin - LWidth := Round(Width * Scale); - LHeight := Round(Height * Scale); - if FBitmapContext = nil then - begin - FBitmapContext := CGBitmapContextCreate(nil, LWidth, LHeight, 8, LWidth * SkBytesPerPixel[TSkColorType.RGBA8888], FColorSpace, kCGImageAlphaPremultipliedLast); - if FBitmapContext = nil then - raise ESkCanvas.Create('Could not create a bitmap graphics context.'); - end; - FContext := CGContextRef(AContextHandle); - Result := TSkSurface.MakeRasterDirect(TSkImageInfo.Create(LWidth, LHeight, TSkColorType.RGBA8888), CGBitmapContextGetData(FBitmapContext), LWidth * SkBytesPerPixel[TSkColorType.RGBA8888]); -end; - -destructor TSkRasterMacOSCanvas.Destroy; -begin - if FBitmapContext <> nil then - CGContextRelease(FBitmapContext); - inherited; -end; - -procedure TSkRasterMacOSCanvas.DoEndScene; -var - LImage: CGImageRef; -begin - inherited; - if Parent <> nil then - begin - LImage := CGBitmapContextCreateImage(FBitmapContext); - if LImage = nil then - raise ESkCanvas.Create('Could not create a image from the pixel data in a bitmap graphics context.'); - try - CGContextDrawImage(FContext, CGRectMake(0, 0, Width, Height), LImage); - finally - CGImageRelease(LImage); - end; - end; -end; - -class procedure TSkRasterMacOSCanvas.Finalize; -begin - CGColorSpaceRelease(FColorSpace); - inherited; -end; - -class procedure TSkRasterMacOSCanvas.Initialize; -begin - inherited; - try - FColorSpace := CGColorSpaceCreateDeviceRGB; - if FColorSpace = nil then - raise ESkCanvas.Create('Could not create a device-dependent RGB color space.'); - except - inherited Finalize; - raise; - end; -end; - -procedure TSkRasterMacOSCanvas.Resized; -begin - if FBitmapContext <> nil then - begin - CGContextRelease(FBitmapContext); - FBitmapContext := nil; - end; -end; - -{$ENDIF} - -(*$HPPEMIT 'namespace Skia {'*) -(*$HPPEMIT ' namespace Fmx {'*) -(*$HPPEMIT ' namespace Types { using namespace ::Fmx::Types; }'*) -(*$HPPEMIT ' namespace Graphics { using namespace ::Fmx::Graphics; }'*) -(*$HPPEMIT ' namespace Textlayout { using namespace ::Fmx::Textlayout; }'*) -(*$HPPEMIT ' }'*) -(*$HPPEMIT '}'*) - -{$HPPEMIT NOUSINGNAMESPACE} -{$HPPEMIT END '#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_SKIA)'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::_di_IGrCanvasSharedResources;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::EGrCanvas;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::ESkCanvas;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::IGrCanvasSharedResources;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::TGrBeforeSharedContextDestructionMessage;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::TGrBitmapHandle;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::TGrCanvas;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::TGrCanvasSharedResources;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::TSkBitmapHandle;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::TSkCanvasBase;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::TSkCanvasCustom;'} -{$HPPEMIT END ' using ::Skia::Fmx::Graphics::TSkTextLayout;'} -{$HPPEMIT END '#endif'} - -{$REGION ' - Workaround RSP-36957'} -// - --------------------------------------------------------------------------- -// - WORKAROUND -// - --------------------------------------------------------------------------- -// - -// - Description: -// - This code is a workaround intended to fix a bug involving the -// - TCustomContextOpenGL.DoCopyToBits. -// - -// - Bug report: -// - https://quality.embarcadero.com/browse/RSP-36957 -// - -// - --------------------------------------------------------------------------- -{$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion112))} -{$IF DEFINED(ANDROID) or DEFINED(IOS)} - -type - { TRSP36957Workaround } - - TRSP36957Workaround = record - strict private type - {$RTTI EXPLICIT METHODS([vcProtected])} - TContextOpenGLPatch = class(TCustomContextOpenGL) - protected - procedure DoCopyToBits(const Bits: Pointer; const Pitch: Integer; const ARect: TRect); override; - end; - {$RTTI METHODS([vcPublic, vcPublished])} - public - class procedure Apply; static; - end; - -{ TRSP36957Workaround } - -class procedure TRSP36957Workaround.Apply; - - function HookVMT(const AVMTEntry, ATargetAddress: Pointer): Boolean; - var - LOriginEnd: Pointer; - LOriginStart: Pointer; - LPageSize: Integer; - LTargetEnd: Pointer; - LTargetStart: Pointer; - begin - LPageSize := sysconf(_SC_PAGESIZE); - LOriginStart := Pointer(NativeUInt(AVMTEntry) and not (LPageSize - 1)); - LOriginEnd := Pointer((NativeUInt(AVMTEntry) + SizeOf(Pointer) + Cardinal(LPageSize) - 1) and not (LPageSize - 1)); - LTargetStart := Pointer(NativeUInt(ATargetAddress) and not (LPageSize - 1)); - LTargetEnd := Pointer((NativeUInt(ATargetAddress) + SizeOf(Pointer) + Cardinal(LPageSize) - 1) and not (LPageSize - 1)); - Result := (mprotect(LOriginStart, PByte(LOriginEnd) - PByte(LOriginStart), PROT_READ or PROT_WRITE) = 0) and (mprotect(LTargetStart, PByte(LTargetEnd) - PByte(LTargetStart), PROT_READ or PROT_WRITE) = 0); - if Result then - PPointer(AVMTEntry)^ := PPointer(ATargetAddress)^; - end; - - function TryGetVMT(const AClass: TClass; const AMethodName: string; out AVMT: Integer): Boolean; - var - LRttiContext: TRttiContext; - LRttiMethod: TRttiMethod; - begin - LRttiContext := TRttiContext.Create; - try - LRttiMethod := LRttiContext.GetType(AClass).AsInstance.GetMethod(AMethodName); - Result := Assigned(LRttiMethod); - if Result then - AVMT := LRttiMethod.VirtualIndex * SizeOf(Pointer); - finally - LRttiContext.Free; - end; - end; - -var - LVMT: Integer; -begin - if TContextManager.DefaultContextClass.InheritsFrom(TCustomContextOpenGL) and TryGetVMT(TContextOpenGLPatch, 'DoCopyToBits', LVMT) then - HookVMT(PByte(TContextManager.DefaultContextClass) + LVMT, PByte(TContextOpenGLPatch) + LVMT); -end; - -{ TRSP36957Workaround.TContextOpenGLPatch } - -procedure TRSP36957Workaround.TContextOpenGLPatch.DoCopyToBits( - const Bits: Pointer; const Pitch: Integer; const ARect: TRect); -var - I: Integer; - OldFBO: GLuint; - BitmapBuffer: PAlphaColorArray; - BitmapBufferLen: Integer; - Rect: TRect; -begin - if Valid then - begin - BitmapBufferLen := Width * Height * 4; - GetMem(BitmapBuffer, BitmapBufferLen); - try - if FFrameBuf <> 0 then - begin - glGetIntegerv(GL_FRAMEBUFFER_BINDING, @OldFBO); - glBindFramebuffer(GL_FRAMEBUFFER, FFrameBuf); - end; - glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, BitmapBuffer); - Rect := TRect.Intersect(ARect, TRect.Create(0, 0, Width, Height)); - for I := Rect.Top to Rect.Bottom - 1 do - Move(BitmapBuffer[(Height - 1 - I) * Width + Rect.Left], PAlphaColorArray(Bits)[I * (Pitch div 4) + Rect.Left], - Rect.Width * 4); - if FFrameBuf <> 0 then - glBindFramebuffer(GL_FRAMEBUFFER, OldFBO); - finally - FreeMem(BitmapBuffer); - end; - {$IF CompilerVersion < 34} - if GLHasAnyErrors then - RaiseContextExceptionFmt(@SErrorInContextMethod, ['DoCopyBits']); - {$ELSE} - TGlesDiagnostic.RaiseIfHasError(@SErrorInContextMethod, ['DoCopyBits']); - {$ENDIF} - end; -end; - -{$ENDIF} -{$ENDIF} -// - --------------------------------------------------------------------------- -{$ENDREGION} - -{$REGION ' - Workaround RSP-37147'} -// - --------------------------------------------------------------------------- -// - WORKAROUND -// - --------------------------------------------------------------------------- -// - -// - Description: -// - This code is a workaround intended to fix a bug involving the -// - TContextMetal.DoCopyToBits. -// - -// - Bug report: -// - https://quality.embarcadero.com/browse/RSP-37147 -// - -// - --------------------------------------------------------------------------- -{$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion112))} -{$IFDEF MACOS} - -type - { TRSP37147Workaround } - - TRSP37147Workaround = record - strict private type - {$RTTI EXPLICIT METHODS([vcProtected])} - TContextMetalPatch = class(TCustomContextMetal) - protected - FPipelineStateConfiguration: TPipelineStateConfiguration; - FDepthStencilStateConfiguration: TDepthStencilStateConfiguration; - FCommandQueue: MTLCommandQueue; - FCommandBuffer: MTLCommandBuffer; - FRenderPassDescriptor: MTLRenderPassDescriptor; - FRenderCommandEncoder: MTLRenderCommandEncoder; - FCurrentDrawable: CAMetalDrawable; - FOnScreenTexture: MTLTexture; - FStencilReferenceValue: LongWord; - FSampleCount: NSUInteger; - procedure DoCopyToBits(const Bits: Pointer; const Pitch: Integer; const ARect: TRect); override; - end; - {$RTTI METHODS([vcPublic, vcPublished])} - public - class procedure Apply; static; - end; - -{ TRSP37147Workaround } - -class procedure TRSP37147Workaround.Apply; - - function HookVMT(const AVMTEntry, ATargetAddress: Pointer): Boolean; - var - LOriginEnd: Pointer; - LOriginStart: Pointer; - LPageSize: Integer; - LTargetEnd: Pointer; - LTargetStart: Pointer; - begin - LPageSize := sysconf(_SC_PAGESIZE); - LOriginStart := Pointer(NativeUInt(AVMTEntry) and not (LPageSize - 1)); - LOriginEnd := Pointer((NativeUInt(AVMTEntry) + SizeOf(Pointer) + Cardinal(LPageSize) - 1) and not (LPageSize - 1)); - LTargetStart := Pointer(NativeUInt(ATargetAddress) and not (LPageSize - 1)); - LTargetEnd := Pointer((NativeUInt(ATargetAddress) + SizeOf(Pointer) + Cardinal(LPageSize) - 1) and not (LPageSize - 1)); - Result := (mprotect(LOriginStart, PByte(LOriginEnd) - PByte(LOriginStart), PROT_READ or PROT_WRITE) = 0) and (mprotect(LTargetStart, PByte(LTargetEnd) - PByte(LTargetStart), PROT_READ or PROT_WRITE) = 0); - if Result then - PPointer(AVMTEntry)^ := PPointer(ATargetAddress)^; - end; - - function TryGetVMT(const AClass: TClass; const AMethodName: string; out AVMT: Integer): Boolean; - var - LRttiContext: TRttiContext; - LRttiMethod: TRttiMethod; - begin - LRttiContext := TRttiContext.Create; - try - LRttiMethod := LRttiContext.GetType(AClass).AsInstance.GetMethod(AMethodName); - Result := Assigned(LRttiMethod); - if Result then - AVMT := LRttiMethod.VirtualIndex * SizeOf(Pointer); - finally - LRttiContext.Free; - end; - end; - -var - LVMT: Integer; -begin - if TContextManager.DefaultContextClass.InheritsFrom(TCustomContextMetal) and TryGetVMT(TContextMetalPatch, 'DoCopyToBits', LVMT) then - HookVMT(PByte(TContextManager.DefaultContextClass) + LVMT, PByte(TContextMetalPatch) + LVMT); -end; - -{ TRSP37147Workaround.TContextMetalPatch } - -procedure TRSP37147Workaround.TContextMetalPatch.DoCopyToBits( - const Bits: Pointer; const Pitch: Integer; const ARect: TRect); - - function CreateRegion(const ARect: TRect; const AScale: Single): MTLRegion; - begin - if SameValue(AScale, 1, TEpsilon.Scale) then - begin - Result.origin.x := ARect.left; - Result.origin.y := ARect.top; - Result.size.width := ARect.Width; - Result.size.height := ARect.Height; - end - else - begin - Result.origin.x := Round(ARect.Left * Scale); - Result.origin.y := Round(ARect.Top * Scale); - Result.size.width := Round(ARect.Width * Scale); - Result.size.height := Round(ARect.Height * Scale); - end; - Result.origin.z := 0; - Result.size.depth := 1; - end; - - procedure SynchronizeResources(const ATexture: MTLTexture); - var - CommandBuffer: MTLCommandBuffer; - LBlitCommandEncoder: MTLBlitCommandEncoder; - begin - CommandBuffer := FCommandQueue.CommandBuffer; - - if CommandBuffer = nil then - Exit; - - LBlitCommandEncoder := CommandBuffer.blitCommandEncoder; - LBlitCommandEncoder.synchronizeResource(ATexture); - LBlitCommandEncoder.endEncoding; - CommandBuffer.commit; - CommandBuffer.waitUntilCompleted; - end; - -var - LCopyRect: TRect; - LTexture: MTLTexture; - LRegion: MTLRegion; -begin - LTexture := nil; - - if FCommandBuffer <> nil then - FCommandBuffer.waitUntilCompleted; - - LCopyRect := TRect.Intersect(ARect, TRect.Create(0, 0, Width, Height)); - if Texture <> nil then - begin - LTexture := TMTLTexture.Wrap(Pointer(Texture.Handle)); - LRegion := CreateRegion(LCopyRect, 1); - end - else if FOnScreenTexture <> nil then - begin - LTexture := FOnScreenTexture; - LRegion := CreateRegion(LCopyRect, Scale); - end; - - if LTexture <> nil then - begin - // Synchronizing a Managed Resource between GPU and CPU - if LTexture.storageMode = MTLStorageModeManaged then - SynchronizeResources(LTexture); - // Get texture data - LTexture.getBytesBytesPerRowFromRegionMipmapLevel( - Bits, // pixelBytes: Pointer; - Pitch, // bytesPerRow: NSUInteger; - LRegion, // fromRegion: MTLRegion; - 0); // mipmapLevel: NSUInteger - end; -end; - -{$ENDIF} -{$ENDIF} -// - --------------------------------------------------------------------------- -{$ENDREGION} - -{$REGION ' - Workaround RSP-37829'} -// - --------------------------------------------------------------------------- -// - WORKAROUND -// - --------------------------------------------------------------------------- -// - -// - Description: -// - This code is a workaround intended to fix a bug involving the -// - wrong render of effects/filters using Metal. -// - -// - Bug report: -// - https://quality.embarcadero.com/browse/RSP-37829 -// - -// - --------------------------------------------------------------------------- -{$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion112))} -{$IFDEF MACOS} - -type - { TRSP37829Workaround } - - TRSP37829Workaround = record - strict private class var - FOriginalDoEndScene: Pointer; - strict private type - TDoEndSceneProc = procedure of object; - - {$RTTI EXPLICIT METHODS([vcProtected])} - TContextMetalPatch = class(TCustomContextMetal) - protected - FPipelineStateConfiguration: TPipelineStateConfiguration; - FDepthStencilStateConfiguration: TDepthStencilStateConfiguration; - FCommandQueue: MTLCommandQueue; - FCommandBuffer: MTLCommandBuffer; - FRenderPassDescriptor: MTLRenderPassDescriptor; - FRenderCommandEncoder: MTLRenderCommandEncoder; - FCurrentDrawable: CAMetalDrawable; - FOnScreenTexture: MTLTexture; - FStencilReferenceValue: LongWord; - FSampleCount: NSUInteger; - procedure DoEndScene; override; - end; - {$RTTI METHODS([vcPublic, vcPublished])} - public - class procedure Apply; static; - end; - -{ TRSP37829Workaround } - -class procedure TRSP37829Workaround.Apply; - - function HookVMT(const AVMTEntry, ATargetAddress: Pointer): Boolean; - var - LOriginEnd: Pointer; - LOriginStart: Pointer; - LPageSize: Integer; - LTargetEnd: Pointer; - LTargetStart: Pointer; - begin - LPageSize := sysconf(_SC_PAGESIZE); - LOriginStart := Pointer(NativeUInt(AVMTEntry) and not (LPageSize - 1)); - LOriginEnd := Pointer((NativeUInt(AVMTEntry) + SizeOf(Pointer) + Cardinal(LPageSize) - 1) and not (LPageSize - 1)); - LTargetStart := Pointer(NativeUInt(ATargetAddress) and not (LPageSize - 1)); - LTargetEnd := Pointer((NativeUInt(ATargetAddress) + SizeOf(Pointer) + Cardinal(LPageSize) - 1) and not (LPageSize - 1)); - Result := (mprotect(LOriginStart, PByte(LOriginEnd) - PByte(LOriginStart), PROT_READ or PROT_WRITE) = 0) and (mprotect(LTargetStart, PByte(LTargetEnd) - PByte(LTargetStart), PROT_READ or PROT_WRITE) = 0); - if Result then - PPointer(AVMTEntry)^ := PPointer(ATargetAddress)^; - end; - - function TryGetVMT(const AClass: TClass; const AMethodName: string; out AVMT: Integer): Boolean; - var - LRttiContext: TRttiContext; - LRttiMethod: TRttiMethod; - begin - LRttiContext := TRttiContext.Create; - try - LRttiMethod := LRttiContext.GetType(AClass).AsInstance.GetMethod(AMethodName); - Result := Assigned(LRttiMethod); - if Result then - AVMT := LRttiMethod.VirtualIndex * SizeOf(Pointer); - finally - LRttiContext.Free; - end; - end; - -var - LVMT: Integer; -begin - if TContextManager.DefaultContextClass.InheritsFrom(TCustomContextMetal) and TryGetVMT(TContextMetalPatch, 'DoEndScene', LVMT) then - begin - FOriginalDoEndScene := PPointer(PByte(TContextManager.DefaultContextClass) + LVMT)^; - HookVMT(PByte(TContextManager.DefaultContextClass) + LVMT, PByte(TContextMetalPatch) + LVMT); - end; -end; - -{ TRSP37829Workaround.TContextMetalPatch } - -procedure TRSP37829Workaround.TContextMetalPatch.DoEndScene; -var - LOriginalMethod: TMethod; -begin - LOriginalMethod.Data := Self; - LOriginalMethod.Code := FOriginalDoEndScene; - TDoEndSceneProc(LOriginalMethod)(); - if Assigned(FCommandBuffer) then - FCommandBuffer.waitUntilCompleted; -end; - -{$ENDIF} -{$ENDIF} -// - --------------------------------------------------------------------------- -{$ENDREGION} - -{$REGION ' - Workaround RSP-37660'} -// - --------------------------------------------------------------------------- -// - WORKAROUND -// - --------------------------------------------------------------------------- -// - -// - Description: -// - The functions BitmapToUIImage and UIImageToBitmap of unit FMX.Helpers.iOS -// - are ignoring the PixelFormat of bitmaps. This issue generates wrong -// - colors in several parts of the code, and this workaround will fix some -// - important services that use these functions: IFMXTakenImageService, -// - IFMXCameraService, IFMXPhotoLibrary and IFMXShareSheetActionsService. -// - -// - Bug report: -// - https://quality.embarcadero.com/browse/RSP-37651 -// - https://quality.embarcadero.com/browse/RSP-37660 -// - -// - --------------------------------------------------------------------------- -{$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion112))} -{$IFDEF IOS} - -type - { TRSP37660Workaround } - - TRSP37660Workaround = record - strict private type - TImageDelegate = class; - TImageManagerCocoa = class; - - TSaveImageRequest = class - private - [Weak] FImageManager: TImageManagerCocoa; - FImage: UIImage; - FOnCompletion: TWriteImageCompletionEvent; - procedure PerformResultOfSavingPhoto(assetURL: NSURL; error: NSError); - public - constructor Create(const AImageManager: TImageManagerCocoa; const AImage: UIImage; const AHandler: TWriteImageCompletionEvent); - procedure Save; - end; - - TImageManagerCocoa = class(TInterfacedObject, IFMXTakenImageService, IFMXCameraService, IFMXPhotoLibrary) - private - FImageDelegate: TImageDelegate; - FImagePicker: UIImagePickerController; - FSaveImageRequests: TList; - protected - procedure TakeImage(const AControl: TControl; const ASourceType: UIImagePickerControllerSourceType); - procedure SaveImageToSavedPhotosAlbum(const AImage: UIImage; const AOnResult: TWriteImageCompletionEvent = nil); - public - constructor Create; - destructor Destroy; override; - class function IsAvailableSourceType(const ASourceType: UIImagePickerControllerSourceType): Boolean; - { IFMXTakenImage } - procedure TakeImageFromLibrary(const AControl: TControl; const ARequiredResolution: TSize; const AEditable: Boolean; - const AOnDidFinishTaking: TOnDidFinishTaking; const AOnDidCancelTaking: TOnDidCancelTaking); overload; - procedure TakeImageFromLibrary(const AControl: TControl; const AParams: TParamsPhotoQuery); overload; - { IFMXPhotoLibrary } - procedure AddImageToSavedPhotosAlbum(const ABitmap: TBitmap; const AWriteImageCompletionEvent: TWriteImageCompletionEvent = nil); - { IFMXCameraService } - procedure TakePhoto(const AControl: TControl; const ARequiredResolution: TSize; const AEditable: Boolean; - const AOnDidFinishTaking: TOnDidFinishTaking; const AOnDidCancelTaking: TOnDidCancelTaking); overload; - procedure TakePhoto(const AControl: TControl; const AParams: TParamsPhotoQuery); overload; - end; - - TImageDelegate = class(TOCLocal, UIImagePickerControllerDelegate) - private - [Weak] FImageManager: TImageManagerCocoa; - FParams: TParamsPhotoQuery; - protected - procedure DoDidFinishTaking(const AImage: TBitmap); - procedure DoDidCancelTaking; - procedure HidePicker(const APicker: UIImagePickerController); - function GetAngleOfImageOrientation(const AImage: UIImage): Single; - public - constructor Create(const AImageManager: TImageManagerCocoa); - property Params: TParamsPhotoQuery read FParams write FParams; - { UIImagePickerControllerDelegate } - procedure imagePickerController(picker: UIImagePickerController; didFinishPickingImage: UIImage; editingInfo: NSDictionary); overload; cdecl; - procedure imagePickerController(picker: UIImagePickerController; didFinishPickingMediaWithInfo: NSDictionary); overload; cdecl; - procedure imagePickerControllerDidCancel(picker: UIImagePickerController); cdecl; - end; - - TShareService = class(TInterfacedObject, IFMXShareSheetActionsService) - strict private - FActivityViewController: UIActivityViewController; - FActivityItems: NSMutableArray; - FPopoverController: UIPopoverController; - public - constructor Create; - destructor Destroy; override; - procedure ReleaseOldSharingController; - { IFMXShareSheetActionsService } - procedure Share(const AControl: TControl; const AText: string; const ABitmap: TBitmap); - end; - - strict private - class procedure SetPixelFormatRGBA(const ABitmap: TBitmap); static; - public - class procedure Apply; static; - end; - -{ TRSP37660Workaround } - -class procedure TRSP37660Workaround.Apply; -var - LImageManager: TImageManagerCocoa; -begin - TPlatformServices.Current.RemovePlatformService(IFMXShareSheetActionsService); - TPlatformServices.Current.RemovePlatformService(IFMXPhotoLibrary); - TPlatformServices.Current.RemovePlatformService(IFMXTakenImageService); - TPlatformServices.Current.RemovePlatformService(IFMXCameraService); - LImageManager := TImageManagerCocoa.Create; - if TImageManagerCocoa.IsAvailableSourceType(UIImagePickerControllerSourceTypeCamera) then - TPlatformServices.Current.AddPlatformService(IFMXCameraService, LImageManager); - if TImageManagerCocoa.IsAvailableSourceType(UIImagePickerControllerSourceTypeSavedPhotosAlbum) then - TPlatformServices.Current.AddPlatformService(IFMXTakenImageService, LImageManager); - TPlatformServices.Current.AddPlatformService(IFMXPhotoLibrary, LImageManager); - if TOSVersion.Check(6, 0) then - TPlatformServices.Current.AddPlatformService(IFMXShareSheetActionsService, IInterface(TShareService.Create)); -end; - -class procedure TRSP37660Workaround.SetPixelFormatRGBA(const ABitmap: TBitmap); -var - LBitmapData: TBitmapData; -begin - if Assigned(ABitmap) and (not ABitmap.IsEmpty) and ABitmap.Map(TMapAccess.ReadWrite, LBitmapData) then - begin - try - ChangePixelFormat(LBitmapData.Data, LBitmapData.Data, (LBitmapData.Pitch * LBitmapData.Height) div LBitmapData.BytesPerPixel, - LBitmapData.PixelFormat, TPixelFormat.RGBA); - finally - ABitmap.Unmap(LBitmapData); - end; - end; -end; - -{ TRSP37660Workaround.TSaveImageRequest } - -constructor TRSP37660Workaround.TSaveImageRequest.Create( - const AImageManager: TImageManagerCocoa; const AImage: UIImage; - const AHandler: TWriteImageCompletionEvent); -begin - if AImageManager = nil then - raise EArgumentNilException.CreateFmt(SWrongParameter, ['AImageManager']); - if AImage = nil then - raise EArgumentNilException.CreateFmt(SWrongParameter, ['AImage']); - FImageManager := AImageManager; - FImage := AImage; - FOnCompletion := AHandler; -end; - -procedure TRSP37660Workaround.TSaveImageRequest.PerformResultOfSavingPhoto( - assetURL: NSURL; error: NSError); -begin - try - if Assigned(FOnCompletion) then - if error <> nil then - FOnCompletion(False, NSStrToStr(error.localizedDescription)) - else - FOnCompletion(True, SImageSaved); - finally - // ARC will remove instance of this object, when we remove the single link from FSaveQueue - FImageManager.FSaveImageRequests.Remove(Self); - end; -end; - -procedure TRSP37660Workaround.TSaveImageRequest.Save; -var - AssetsLibrary: ALAssetsLibrary; -begin - AssetsLibrary := TALAssetsLibrary.Create; - try - AssetsLibrary.writeImageToSavedPhotosAlbum(FImage.CGImage, FImage.imageOrientation, PerformResultOfSavingPhoto); - finally - AssetsLibrary.release; - end; -end; - -{ TRSP37660Workaround.TImageManagerCocoa } - -procedure TRSP37660Workaround.TImageManagerCocoa.AddImageToSavedPhotosAlbum( - const ABitmap: TBitmap; - const AWriteImageCompletionEvent: TWriteImageCompletionEvent); -var - OCImage: UIImage; - LBitmap: TBitmap; -begin - LBitmap := TBitmap.Create; - try - LBitmap.Assign(ABitmap); - SetPixelFormatRGBA(LBitmap); - OCImage := BitmapToUIImage(LBitmap); - try - SaveImageToSavedPhotosAlbum(OCImage, AWriteImageCompletionEvent); - finally - OCImage.release; - end; - finally - LBitmap.Free; - end; -end; - -constructor TRSP37660Workaround.TImageManagerCocoa.Create; -begin - inherited Create; - FImageDelegate := TImageDelegate.Create(Self); - FSaveImageRequests := TList.Create; -end; - -destructor TRSP37660Workaround.TImageManagerCocoa.Destroy; -begin - FSaveImageRequests.Free; - if FImagePicker <> nil then - begin - FImagePicker.release; - FImagePicker.setDelegate(nil); - end; - FImageDelegate.DisposeOf; - inherited Destroy; -end; - -class function TRSP37660Workaround.TImageManagerCocoa.IsAvailableSourceType( - const ASourceType: UIImagePickerControllerSourceType): Boolean; -begin - Result := TUIImagePickerController.OCClass.isSourceTypeAvailable(ASourceType); -end; - -procedure TRSP37660Workaround.TImageManagerCocoa.SaveImageToSavedPhotosAlbum( - const AImage: UIImage; const AOnResult: TWriteImageCompletionEvent); -var - SaveImageRequest: TSaveImageRequest; -begin - SaveImageRequest := TSaveImageRequest.Create(Self, AImage, AOnResult); - FSaveImageRequests.Add(SaveImageRequest); - SaveImageRequest.Save; -end; - -procedure TRSP37660Workaround.TImageManagerCocoa.TakeImage( - const AControl: TControl; - const ASourceType: UIImagePickerControllerSourceType); -var - Window: UIWindow; -begin - if IsAvailableSourceType(ASourceType) then - begin - if FImagePicker <> nil then - begin - FImagePicker.setDelegate(nil); - FImagePicker.release; - end; - FImagePicker := TUIImagePickerController.Create; - FImagePicker.retain; - FImagePicker.setDelegate(FImageDelegate.GetObjectID); - FImagePicker.setSourceType(ASourceType); - FImagePicker.setAllowsEditing(FImageDelegate.Params.Editable); - if IsPad and (ASourceType <> UIImagePickerControllerSourceTypeCamera) then - FImagePicker.setModalPresentationStyle(UIModalPresentationFormSheet); - Window := SharedApplication.keyWindow; - if (Window <> nil) and (Window.rootViewController <> nil) then - Window.rootViewController.presentModalViewController(FImagePicker, True); - end; -end; - -procedure TRSP37660Workaround.TImageManagerCocoa.TakeImageFromLibrary( - const AControl: TControl; const AParams: TParamsPhotoQuery); -var - ParamsTmp: TParamsPhotoQuery; -begin - ParamsTmp := AParams; - ParamsTmp.NeedSaveToAlbum := False; - FImageDelegate.Params := ParamsTmp; - TakeImage(AControl, UIImagePickerControllerSourceTypePhotoLibrary) -end; - -procedure TRSP37660Workaround.TImageManagerCocoa.TakeImageFromLibrary( - const AControl: TControl; const ARequiredResolution: TSize; - const AEditable: Boolean; const AOnDidFinishTaking: TOnDidFinishTaking; - const AOnDidCancelTaking: TOnDidCancelTaking); -var - ParamTmp: TParamsPhotoQuery; -begin - ParamTmp.Editable := AEditable; - ParamTmp.RequiredResolution := ARequiredResolution; - ParamTmp.NeedSaveToAlbum := False; - ParamTmp.OnDidFinishTaking := AOnDidFinishTaking; - ParamTmp.OnDidCancelTaking := AOnDidCancelTaking; - TakeImageFromLibrary(AControl, ParamTmp); -end; - -procedure TRSP37660Workaround.TImageManagerCocoa.TakePhoto( - const AControl: TControl; const ARequiredResolution: TSize; - const AEditable: Boolean; const AOnDidFinishTaking: TOnDidFinishTaking; - const AOnDidCancelTaking: TOnDidCancelTaking); -var - ParamTmp: TParamsPhotoQuery; -begin - ParamTmp.Editable := AEditable; - ParamTmp.RequiredResolution := ARequiredResolution; - ParamTmp.NeedSaveToAlbum := False; - ParamTmp.OnDidFinishTaking := AOnDidFinishTaking; - ParamTmp.OnDidCancelTaking := AOnDidCancelTaking; - TakePhoto(AControl, ParamTmp); -end; - -procedure TRSP37660Workaround.TImageManagerCocoa.TakePhoto( - const AControl: TControl; const AParams: TParamsPhotoQuery); -begin - FImageDelegate.Params := AParams; - TakeImage(AControl, UIImagePickerControllerSourceTypeCamera); -end; - -{ TRSP37660Workaround.TImageDelegate } - -constructor TRSP37660Workaround.TImageDelegate.Create( - const AImageManager: TImageManagerCocoa); -begin - inherited Create; - FImageManager := AImageManager; -end; - -procedure TRSP37660Workaround.TImageDelegate.DoDidCancelTaking; -begin - if Assigned(Params.OnDidCancelTaking) then - Params.OnDidCancelTaking; -end; - -procedure TRSP37660Workaround.TImageDelegate.DoDidFinishTaking( - const AImage: TBitmap); -var - LBitmap: TBitmap; -begin - LBitmap := TBitmap.Create; - try - LBitmap.Assign(AImage); - SetPixelFormatRGBA(LBitmap); - if Assigned(Params.OnDidFinishTaking) then - Params.OnDidFinishTaking(LBitmap); - finally - LBitmap.Free; - end; -end; - -function TRSP37660Workaround.TImageDelegate.GetAngleOfImageOrientation( - const AImage: UIImage): Single; -begin - case AImage.imageOrientation of - UIImageOrientationDown, - UIImageOrientationDownMirrored: - Result := 180; - UIImageOrientationLeft, - UIImageOrientationLeftMirrored: - Result := -90; - UIImageOrientationRight, - UIImageOrientationRightMirrored: - Result := 90; - UIImageOrientationUp, - UIImageOrientationUpMirrored: - Result := 0; - else - Result := 0; - end; -end; - -procedure TRSP37660Workaround.TImageDelegate.HidePicker( - const APicker: UIImagePickerController); -begin - APicker.dismissModalViewControllerAnimated(True); -end; - -procedure TRSP37660Workaround.TImageDelegate.imagePickerController( - picker: UIImagePickerController; didFinishPickingImage: UIImage; - editingInfo: NSDictionary); -var - Bitmap: TBitmap; - RotationAngle: Single; -begin - HidePicker(picker); - RotationAngle := GetAngleOfImageOrientation(didFinishPickingImage); - Bitmap := UIImageToBitmap(didFinishPickingImage, RotationAngle, Params.RequiredResolution); - try - DoDidFinishTaking(Bitmap); - if Params.NeedSaveToAlbum then - FImageManager.SaveImageToSavedPhotosAlbum(didFinishPickingImage); - finally - Bitmap.DisposeOf; - end; -end; - -procedure TRSP37660Workaround.TImageDelegate.imagePickerController( - picker: UIImagePickerController; didFinishPickingMediaWithInfo: NSDictionary); -var - Bitmap: TBitmap; - ImageTmp: UIImage; - RotationAngle: Single; -begin - HidePicker(picker); - if Params.Editable then - ImageTmp := TUIImage.Wrap(didFinishPickingMediaWithInfo.objectForKey((UIImagePickerControllerEditedImage as ILocalObject).GetObjectID)) - else - ImageTmp := TUIImage.Wrap(didFinishPickingMediaWithInfo.objectForKey((UIImagePickerControllerOriginalImage as ILocalObject).GetObjectID)); - RotationAngle := GetAngleOfImageOrientation(ImageTmp); - Bitmap := UIImageToBitmap(ImageTmp, RotationAngle, Params.RequiredResolution); - try - DoDidFinishTaking(Bitmap); - if Params.NeedSaveToAlbum then - FImageManager.SaveImageToSavedPhotosAlbum(ImageTmp); - finally - Bitmap.DisposeOf; - end; -end; - -procedure TRSP37660Workaround.TImageDelegate.imagePickerControllerDidCancel( - picker: UIImagePickerController); -begin - DoDidCancelTaking; - HidePicker(picker); -end; - -{ TRSP37660Workaround.TShareService } - -constructor TRSP37660Workaround.TShareService.Create; -begin - inherited; - FActivityItems := TNSMutableArray.Create; -end; - -destructor TRSP37660Workaround.TShareService.Destroy; -begin - ReleaseOldSharingController; - FActivityItems.release; - inherited; -end; - -procedure TRSP37660Workaround.TShareService.ReleaseOldSharingController; -var - Pop: UIPopoverController; -begin - if FPopoverController <> nil then - FPopoverController.release; - Pop := FPopoverController; - - if FActivityViewController <> nil then - begin - FActivityViewController.release; - FActivityViewController := nil; - end; -end; - -procedure TRSP37660Workaround.TShareService.Share(const AControl: TControl; - const AText: string; const ABitmap: TBitmap); - - procedure ShowForPhone; - var - Window: UIWindow; - begin - Window := SharedApplication.keyWindow; - if (Window <> nil) and (Window.rootViewController <> nil) then - Window.rootViewController.presentModalViewController(FActivityViewController, True); - end; - - procedure ShowForPad; - var - Window: UIWindow; - PopoverRect: CGRect; - AbsolutePos: TPointF; - begin - Window := SharedApplication.keyWindow; - if AControl <> nil then - begin - AbsolutePos := AControl.LocalToAbsolute(PointF(0, 0)); - if AControl.Scene <> nil then - AbsolutePos := AControl.Scene.LocalToScreen(AbsolutePos); - PopoverRect := CGRectMake(AbsolutePos.X, AbsolutePos.Y, AControl.Width, AControl.Height); - end - else - PopoverRect := CGRectMake(0, 0, 0, 0); - FPopoverController := TUIPopoverController.Alloc; - FPopoverController.initWithContentViewController(FActivityViewController); - FPopoverController.presentPopoverFromRect(PopoverRect, Window.rootViewController.View, UIPopoverArrowDirectionAny, True); - end; - - procedure ShowActionsSheet; - begin - if IsPad then - ShowForPad - else - ShowForPhone; - end; - -var - OCImage: UIImage; - LBitmap: TBitmap; -begin - Assert((ABitmap <> nil) or not AText.IsEmpty); - FActivityItems.removeAllObjects; - - if not AText.IsEmpty then - FActivityItems.addObject((StrToNSStr(AText) as ILocalObject).GetObjectID); - - if (ABitmap <> nil) and not ABitmap.IsEmpty then - begin - LBitmap := TBitmap.Create; - try - LBitmap.Assign(ABitmap); - SetPixelFormatRGBA(LBitmap); - OCImage := BitmapToUIImage(LBitmap); - finally - LBitmap.Free; - end; - FActivityItems.addObject((OCImage as ILocalObject).GetObjectID); - end; - - try - if FActivityItems.count > 0 then - begin - ReleaseOldSharingController; - FActivityViewController := TUIActivityViewController.alloc; - FActivityViewController.initWithActivityItems(FActivityItems , nil); - ShowActionsSheet; - end; - finally - if OCImage <> nil then - OCImage.release; - end; -end; - -{$ENDIF} -{$ENDIF} -// - --------------------------------------------------------------------------- -{$ENDREGION} - -{$REGION '- Canvas Registration'} -type - TSkCanvasClass = class of TSkCanvasBase; - - { TSkCanvasService } - - TSkCanvasService = class(TInterfacedObject, IFMXCanvasService) - strict private - FCanvasClass: TSkCanvasClass; - FCurrent: IFMXCanvasService; - {$IFDEF DEBUG} - FGlobalUseSkiaInRegistration: Boolean; - FMainFormChangedMessageId: Integer; - procedure MainFormChangedChangeHandler(const ASender: TObject; const AMessage: System.Messaging.TMessage); - {$ENDIF} - procedure RegisterCanvasClasses; - procedure UnregisterCanvasClasses; - public - constructor Create(const ACurrent: IFMXCanvasService); - {$IFDEF DEBUG} - destructor Destroy; override; - {$ENDIF} - end; - -{ TSkCanvasService } - -constructor TSkCanvasService.Create(const ACurrent: IFMXCanvasService); -begin - inherited Create; - FCurrent := ACurrent; - {$IFDEF DEBUG} - FMainFormChangedMessageId := TMessageManager.DefaultManager.SubscribeToMessage(TMainFormChangedMessage, MainFormChangedChangeHandler); - {$ENDIF} -end; - -{$IFDEF DEBUG} - -destructor TSkCanvasService.Destroy; -begin - if FMainFormChangedMessageId > 0 then - TMessageManager.DefaultManager.Unsubscribe(TMainFormChangedMessage, FMainFormChangedMessageId); - inherited; -end; - -procedure TSkCanvasService.MainFormChangedChangeHandler(const ASender: TObject; - const AMessage: System.Messaging.TMessage); -const - MessageText = 'Your declaration of GlobalUseSkia has no effect because the ' + - 'canvas service has already been started. In this case, just ' + - 'create a unit in the project like "Project.Startup.pas", ' + - 'place the GlobalUseSkia declaration in the initialization of' + - ' this new unit, and declare this new unit before any other ' + - 'unit of yours in the .dpr, that is, right after FMX.Forms.'; -begin - TMessageManager.DefaultManager.Unsubscribe(TMainFormChangedMessage, FMainFormChangedMessageId); - FMainFormChangedMessageId := 0; - if FGlobalUseSkiaInRegistration <> GlobalUseSkia then - raise ESkCanvas.Create(MessageText); -end; - -{$ENDIF} - -procedure TSkCanvasService.RegisterCanvasClasses; -begin - TSkTextLayout.Initialize; - if Assigned(FCurrent) then - begin - if GlobalUseSkia then - begin - {$IF DEFINED(MSWINDOWS)} - if GlobalUseSkiaRasterWhenAvailable then - FCanvasClass := TSkRasterWindowsCanvas - else - FCanvasClass := TGlCanvas; - {$ELSEIF DEFINED(MACOS)} - if GlobalUseMetal then - FCanvasClass := TMtlCanvas - else - {$IFDEF IOS} - FCanvasClass := TGlCanvas; - {$ELSE} - FCanvasClass := TSkRasterMacOSCanvas; - {$ENDIF} - {$ELSEIF DEFINED(ANDROID)} - FCanvasClass := TGlCanvas; - {$ELSE} - FCanvasClass := nil; - {$ENDIF} - if Assigned(FCanvasClass) then - begin - FCanvasClass.Initialize; - // Ensuring that our canvas will be chosen as the default - TCanvasManager.EnableSoftwareCanvas(True); - TCanvasManager.RegisterCanvas(FCanvasClass, True, False); - TTextLayoutManager.RegisterTextLayout(TSkTextLayout, FCanvasClass); - if not GlobalDisableSkiaCodecsReplacement then - begin - TBitmapCodecManager.UnregisterBitmapCodecClass('.jpg'); - TBitmapCodecManager.RegisterBitmapCodecClass('.jpg', SVJPGImages, True, TSkBitmapHandleCodec); - TBitmapCodecManager.UnregisterBitmapCodecClass('.jpeg'); - TBitmapCodecManager.RegisterBitmapCodecClass('.jpeg', SVJPGImages, True, TSkBitmapHandleCodec); - TBitmapCodecManager.UnregisterBitmapCodecClass('.png'); - TBitmapCodecManager.RegisterBitmapCodecClass('.png', SVPNGImages, True, TSkBitmapHandleCodec); - end; - // Apply workarounds - {$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion112))} - {$IF DEFINED(ANDROID) or DEFINED(IOS)} - TRSP36957Workaround.Apply; - {$ENDIF} - {$IFDEF MACOS} - TRSP37147Workaround.Apply; - {$ENDIF} - {$IFDEF MACOS} - TRSP37829Workaround.Apply; - {$ENDIF} - {$IFDEF IOS} - TRSP37660Workaround.Apply; - {$ENDIF} - {$ENDIF} - end; - end; - FCurrent.RegisterCanvasClasses; - end; - {$IFDEF DEBUG} - FGlobalUseSkiaInRegistration := GlobalUseSkia; - {$ENDIF} -end; - -procedure TSkCanvasService.UnregisterCanvasClasses; -begin - if Assigned(FCurrent) then - begin - if Assigned(FCanvasClass) then - FCanvasClass.Finalize; - FCurrent.UnregisterCanvasClasses; - end; -end; - -var - CanvasService: TSkCanvasService; -initialization - CanvasService := TSkCanvasService.Create(IFMXCanvasService(TPlatformServices.Current.GetPlatformService(IFMXCanvasService))); - TPlatformServices.Current.RemovePlatformService(IFMXCanvasService); - TPlatformServices.Current.AddPlatformService(IFMXCanvasService, CanvasService); -{$ENDREGION} -end. diff --git a/skia4delphi/Source/FMX/Skia.FMX.pas b/skia4delphi/Source/FMX/Skia.FMX.pas deleted file mode 100644 index 77296fd..0000000 --- a/skia4delphi/Source/FMX/Skia.FMX.pas +++ /dev/null @@ -1,6166 +0,0 @@ -{************************************************************************} -{ } -{ Skia4Delphi } -{ } -{ Copyright (c) 2011-2022 Google LLC. } -{ Copyright (c) 2021-2022 Skia4Delphi Project. } -{ } -{ Use of this source code is governed by a BSD-style license that can be } -{ found in the LICENSE file. } -{ } -{************************************************************************} -unit Skia.FMX; - -interface - -{$SCOPEDENUMS ON} - -uses - { Delphi } - System.SysUtils, - System.Types, - System.UITypes, - System.Classes, - System.Math, - System.Messaging, - System.Generics.Collections, - FMX.Types, - FMX.Graphics, - FMX.Controls, - FMX.ActnList, - - { Skia } - Skia; - -const - {$IF CompilerVersion < 33} - SkSupportedPlatformsMask = pidWin32 or pidWin64; - {$ELSEIF CompilerVersion < 35} - SkSupportedPlatformsMask = pidWin32 or pidWin64 or pidAndroid32Arm or pidAndroid64Arm; - {$ELSE} - SkSupportedPlatformsMask = pidAllPlatforms; - {$ENDIF} - -type - ESkFMX = class(Exception); - ESkBitmapHelper = class(ESkFMX); - ESkPersistentData = class(ESkFMX); - ESkTextSettingsInfo = class(ESkFMX); - ESkLabel = class(ESkFMX); - - TSkDrawProc = reference to procedure(const ACanvas: ISkCanvas); - - { TSkBitmapHelper } - - TSkBitmapHelper = class helper for TBitmap - public - constructor CreateFromSkImage(const AImage: ISkImage); - procedure SkiaDraw(const AProc: TSkDrawProc; const AStartClean: Boolean = True); - function ToSkImage: ISkImage; - end; - - { TSkPathDataHelper } - - TSkPathDataHelper = class helper for TPathData - public - constructor CreateFromSkPath(const AValue: ISkPath); - procedure AddSkPath(const AValue: ISkPath); - procedure FromSkPath(const AValue: ISkPath); deprecated 'Use TPathData.CreateFromSkPath instead'; - function ToSkPath: ISkPath; - end; - - { TSkPersistent } - - TSkPersistent = class(TPersistent) - strict private - FChanged: Boolean; - FCreated: Boolean; - FIgnoringAllChanges: Boolean; - FOnChange: TNotifyEvent; - FUpdatingCount: Integer; - function GetUpdating: Boolean; - protected - procedure DoAssign(ASource: TPersistent); virtual; - procedure DoChanged; virtual; - function GetHasChanged: Boolean; virtual; - function SetValue(var AField: Byte; const AValue: Byte): Boolean; overload; - function SetValue(var AField: Word; const AValue: Word): Boolean; overload; - function SetValue(var AField: Cardinal; const AValue: Cardinal): Boolean; overload; - function SetValue(var AField: Boolean; const AValue: Boolean): Boolean; overload; - function SetValue(var AField: Integer; const AValue: Integer): Boolean; overload; - function SetValue(var AField: Int64; const AValue: Int64): Boolean; overload; - function SetValue(var AField: Single; const AValue: Single; const AEpsilon: Single = 0.0): Boolean; overload; - function SetValue(var AField: Double; const AValue: Double; const AEpsilon: Double = 0.0): Boolean; overload; - function SetValue(var AField: TBytes; const AValue: TBytes): Boolean; overload; - function SetValue(var AField: string; const AValue: string): Boolean; overload; - function SetValue(var AField: T; const AValue: T): Boolean; overload; - property Created: Boolean read FCreated; - property UpdatingCount: Integer read FUpdatingCount; - property OnChange: TNotifyEvent read FOnChange write FOnChange; - public - procedure AfterConstruction; override; - procedure Assign(ASource: TPersistent); override; final; - procedure BeginUpdate; overload; - procedure BeginUpdate(const AIgnoreAllChanges: Boolean); overload; virtual; - procedure Change; virtual; - procedure EndUpdate; overload; - procedure EndUpdate(const AIgnoreAllChanges: Boolean); overload; virtual; - property HasChanged: Boolean read GetHasChanged; - property Updating: Boolean read GetUpdating; - end; - - TSkDrawEvent = procedure(ASender: TObject; const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single) of object; - TSkDrawCacheKind = (Never, Raster, Always); - - { TSkCustomControl } - - TSkCustomControl = class abstract(TControl) - strict private - FBuffer: TBitmap; - FDrawCached: Boolean; - FDrawCacheKind: TSkDrawCacheKind; - FOnDraw: TSkDrawEvent; - procedure SetDrawCacheKind(const AValue: TSkDrawCacheKind); - procedure SetOnDraw(const AValue: TSkDrawEvent); - strict protected - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); virtual; - procedure DrawDesignBorder(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); - function NeedsRedraw: Boolean; virtual; - procedure Paint; override; final; - property DrawCacheKind: TSkDrawCacheKind read FDrawCacheKind write SetDrawCacheKind default TSkDrawCacheKind.Raster; - property OnDraw: TSkDrawEvent read FOnDraw write SetOnDraw; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure Redraw; - published - property Align; - property Anchors; - property ClipChildren default False; - property ClipParent default False; - property Cursor default crDefault; - property DragMode default TDragMode.dmManual; - property Enabled default True; - property EnableDragHighlight default True; - property Height; - property Hint; - property HitTest default False; - property Locked default False; - property Margins; - property Opacity; - property Padding; - {$IF CompilerVersion >= 30} - property ParentShowHint; - {$ENDIF} - property PopupMenu; - property Position; - property RotationAngle; - property RotationCenter; - property Scale; - property ShowHint; - property Size; - property Visible default True; - property Width; - property OnClick; - property OnDblClick; - property OnDragDrop; - property OnDragEnd; - property OnDragEnter; - property OnDragLeave; - property OnDragOver; - property OnMouseDown; - property OnMouseEnter; - property OnMouseLeave; - property OnMouseMove; - property OnMouseUp; - property OnMouseWheel; - property OnPainting; - property OnResize; - {$IF CompilerVersion >= 32} - property OnResized; - {$ENDIF} - end; - - { TSkStyledControl } - - TSkStyledControl = class abstract(TStyledControl) - strict private - FBuffer: TBitmap; - FDrawCached: Boolean; - FDrawCacheKind: TSkDrawCacheKind; - FOnDraw: TSkDrawEvent; - procedure SetDrawCacheKind(const AValue: TSkDrawCacheKind); - procedure SetOnDraw(const AValue: TSkDrawEvent); - strict protected - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); virtual; - procedure DrawDesignBorder(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); - function NeedsRedraw: Boolean; virtual; - procedure Paint; override; final; - property DrawCacheKind: TSkDrawCacheKind read FDrawCacheKind write SetDrawCacheKind default TSkDrawCacheKind.Raster; - property OnDraw: TSkDrawEvent read FOnDraw write SetOnDraw; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure Redraw; - end; - - { TSkPaintBox } - - [ComponentPlatforms(SkSupportedPlatformsMask)] - TSkPaintBox = class(TSkCustomControl) - published - property OnDraw; - end; - - TSkSvgSource = type string; - TSkSvgWrapMode = (Default, Fit, FitCrop, Original, OriginalCenter, Place, Stretch, Tile); - - { TSkSvgBrush } - - TSkSvgBrush = class(TPersistent) - strict private const - DefaultGrayScale = False; - DefaultWrapMode = TSkSvgWrapMode.Fit; - strict private - FDOM: ISkSVGDOM; - FGrayScale: Boolean; - FOnChanged: TNotifyEvent; - FOriginalSize: TSizeF; - FOverrideColor: TAlphaColor; - FSource: TSkSvgSource; - FWrapMode: TSkSvgWrapMode; - function GetDOM: ISkSVGDOM; - function GetOriginalSize: TSizeF; - function IsGrayScaleStored: Boolean; - function IsOverrideColorStored: Boolean; - function IsWrapModeStored: Boolean; - procedure SetGrayScale(const AValue: Boolean); - procedure SetOverrideColor(const AValue: TAlphaColor); - procedure SetSource(const AValue: TSkSvgSource); - procedure SetWrapMode(const AValue: TSkSvgWrapMode); - strict protected - procedure DoAssign(ASource: TSkSvgBrush); virtual; - procedure DoChanged; virtual; - function HasContent: Boolean; virtual; - function MakeDOM: ISkSVGDOM; virtual; - procedure RecreateDOM; - public - constructor Create; - procedure Assign(ASource: TPersistent); override; - function Equals(AObject: TObject): Boolean; override; - procedure Render(const ACanvas: ISkCanvas; const ADestRect: TRectF; const AOpacity: Single); - property DOM: ISkSVGDOM read GetDOM; - property OriginalSize: TSizeF read GetOriginalSize; - property OnChanged: TNotifyEvent read FOnChanged write FOnChanged; - published - property GrayScale: Boolean read FGrayScale write SetGrayScale stored IsGrayScaleStored; - property OverrideColor: TAlphaColor read FOverrideColor write SetOverrideColor stored IsOverrideColorStored; - property Source: TSkSvgSource read FSource write SetSource; - property WrapMode: TSkSvgWrapMode read FWrapMode write SetWrapMode stored IsWrapModeStored; - end; - - { TSkSvg } - - [ComponentPlatforms(SkSupportedPlatformsMask)] - TSkSvg = class(TSkCustomControl) - strict private - FSvg: TSkSvgBrush; - procedure SetSvg(const AValue: TSkSvgBrush); - procedure SvgChanged(ASender: TObject); - strict protected - function CreateSvgBrush: TSkSvgBrush; virtual; - 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; - property OnDraw; - end; - - { TSkCustomAnimation } - - TSkCustomAnimation = class(TSkPersistent) - protected const - DefaultAutoReverse = False; - DefaultDelay = 0; - DefaultEnabled = True; - DefaultInverse = False; - DefaultLoop = True; - DefaultPause = False; - DefaultSpeed = 1; - DefaultStartFromCurrent = False; - DefaultStartProgress = 0; - DefaultStopProgress = 1; - ProgressEpsilon = 0; - SpeedEpsilon = 1E-3; - SpeedRoundTo = -3; - TimeEpsilon = 1E-3; - TimeRoundTo = -3; - strict private type - TProcess = class - strict private - // Unsafe referece for TSkAnimation in list - FAniList: TList; - FAniProcessingList: TList; - [unsafe] FAniRoot: TSkCustomAnimation; - FAnimation: TFmxObject; - FMainFormChangedMessageId: Integer; - FTime: Double; - FTimerService: IFMXTimerService; - procedure DoAdd(const AAnimation: TSkCustomAnimation); - procedure DoRemove(const AAnimation: TSkCustomAnimation); - procedure DoRootChanged(const AAnimation: TSkCustomAnimation); - procedure MainFormChangeHandler(const ASender: TObject; const AMessage: TMessage); - procedure OnProcess(ASender: TObject); - procedure TryFindRoot; - strict private - class var FProcess: TProcess; - class destructor Destroy; - public - constructor Create; - destructor Destroy; override; - class procedure Add(const AAnimation: TSkCustomAnimation); static; - class procedure Remove(const AAnimation: TSkCustomAnimation); static; - class procedure RootChanged(const AAnimation: TSkCustomAnimation); static; - end; - strict private - FAllowAnimation: Boolean; - FAutoReverse: Boolean; - FCurrentTime: Double; - FCurrentTimeChanged: Boolean; - FDelay: Double; - FDelayTime: Double; - FDuration: Double; - FEnabled: Boolean; - FEnabledChanged: Boolean; - FInverse: Boolean; - FLoop: Boolean; - FNeedStart: Boolean; - FNeedStartRepaint: Boolean; - [unsafe] FOwner: TComponent; - FPause: Boolean; - FProcessDuration: Double; - FProcessing: Boolean; - FProcessTime: Double; - FProgress: Double; - FRunning: Boolean; - FSavedInverse: Boolean; - FSavedProgress: Double; - FSpeed: Double; - FStartFromCurrent: Boolean; - FStartProgress: Double; - FStopProgress: Double; - FTickCount: Integer; - function CanProcessing: Boolean; - function DoSetCurrentTime(const AValue: Double): Boolean; - function GetRoot: IRoot; - procedure InternalStart(const ACanProcess: Boolean); - function IsDelayStored: Boolean; - function IsProgressStored: Boolean; - function IsSpeedStored: Boolean; - function IsStartProgressStored: Boolean; - function IsStopProgressStored: Boolean; - procedure ProcessTick(ADeltaTime: Double); - procedure SetAllowAnimation(const AValue: Boolean); - procedure SetCurrentTime(const AValue: Double); - procedure SetDelay(const AValue: Double); - procedure SetEnabled(const AValue: Boolean); - procedure SetLoop(const AValue: Boolean); - procedure SetPause(const AValue: Boolean); - procedure SetProcessing(const AValue: Boolean); - procedure SetProgress(const AValue: Double); - procedure SetRunning(const AValue: Boolean); - procedure SetSpeed(const AValue: Double); - procedure SetStartProgress(const AValue: Double); - procedure SetStartValues(const ADelayTime: Double; const AStartAtEnd: Boolean); - procedure SetStopProgress(const AValue: Double); - procedure UpdateCurrentTime(const AIsRunning, ARecalcProcessDuration: Boolean); inline; - private - property Root: IRoot read GetRoot; - property SavedProgress: Double read FSavedProgress write FSavedProgress; - protected - procedure BeforePaint; - procedure DoAssign(ASource: TPersistent); override; - procedure DoChanged; override; - procedure DoFinish; virtual; abstract; - procedure DoProcess; virtual; abstract; - procedure DoStart; virtual; abstract; - function GetDuration: Double; - procedure RootChanged; - procedure SetDuration(const AValue: Double); - property AllowAnimation: Boolean read FAllowAnimation write SetAllowAnimation; - property Owner: TComponent read FOwner; - property Processing: Boolean read FProcessing; - public - constructor Create(const AOwner: TComponent); - destructor Destroy; override; - function Equals(AObject: TObject): Boolean; override; - procedure Start; virtual; - procedure Stop; virtual; - procedure StopAtCurrent; virtual; - property AutoReverse: Boolean read FAutoReverse write FAutoReverse default DefaultAutoReverse; - /// Current time of the animation in seconds - property CurrentTime: Double read FCurrentTime write SetCurrentTime stored False nodefault; - /// Delay in seconds to start the animation - property Delay: Double read FDelay write SetDelay stored IsDelayStored; - /// Duration in seconds - property Duration: Double read GetDuration; - /// Enables the animation to run automatically (in the next control's paint). - property Enabled: Boolean read FEnabled write SetEnabled default DefaultEnabled; - property Inverse: Boolean read FInverse write FInverse default DefaultInverse; - property Loop: Boolean read FLoop write SetLoop default DefaultLoop; - property Pause: Boolean read FPause write SetPause default DefaultPause; - /// Normalized CurrentTime (value between 0..1) - property Progress: Double read FProgress write SetProgress stored IsProgressStored; - property Running: Boolean read FRunning; - property Speed: Double read FSpeed write SetSpeed stored IsSpeedStored; - property StartFromCurrent: Boolean read FStartFromCurrent write FStartFromCurrent default DefaultStartFromCurrent; - property StartProgress: Double read FStartProgress write SetStartProgress stored IsStartProgressStored; - property StopProgress: Double read FStopProgress write SetStopProgress stored IsStopProgressStored; - end; - - TSkAnimationDrawEvent = procedure(ASender: TObject; const ACanvas: ISkCanvas; const ADest: TRectF; const AProgress: Double; const AOpacity: Single) of object; - TSkAnimationDrawProc = reference to procedure(const ACanvas: ISkCanvas; const ADest: TRectF; const AProgress: Double; const AOpacity: Single); - - { TSkCustomAnimatedControl } - - TSkCustomAnimatedControl = class abstract(TSkCustomControl) - protected type - TAnimationBase = class(TSkCustomAnimation) - strict private - FInsideDoProcess: Boolean; - protected - procedure DoChanged; override; - procedure DoFinish; override; - procedure DoProcess; override; - procedure DoStart; override; - end; - strict private - FAbsoluteVisible: Boolean; - FAbsoluteVisibleCached: Boolean; - FOnAnimationDraw: TSkAnimationDrawEvent; - FOnAnimationFinish: TNotifyEvent; - FOnAnimationProcess: TNotifyEvent; - FOnAnimationStart: TNotifyEvent; - FSuccessRedraw: Boolean; - procedure CheckDuration; - function GetAbsoluteVisible: Boolean; - procedure SetOnAnimationDraw(const AValue: TSkAnimationDrawEvent); - strict protected - FAnimation: TAnimationBase; - procedure AncestorVisibleChanged(const AVisible: Boolean); override; - function CanRunAnimation: Boolean; virtual; - procedure CheckAnimation; - function CreateAnimation: TAnimationBase; virtual; abstract; - procedure DoAnimationChanged; virtual; - procedure DoAnimationFinish; virtual; - procedure DoAnimationProcess; virtual; - procedure DoAnimationStart; virtual; - procedure DoRootChanged; override; - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - procedure ReadState(AReader: TReader); override; - procedure RenderFrame(const ACanvas: ISkCanvas; const ADest: TRectF; const AProgress: Double; const AOpacity: Single); virtual; - property AbsoluteVisible: Boolean read GetAbsoluteVisible; - property OnAnimationDraw: TSkAnimationDrawEvent read FOnAnimationDraw write SetOnAnimationDraw; - property OnAnimationFinish: TNotifyEvent read FOnAnimationFinish write FOnAnimationFinish; - property OnAnimationProcess: TNotifyEvent read FOnAnimationProcess write FOnAnimationProcess; - property OnAnimationStart: TNotifyEvent read FOnAnimationStart write FOnAnimationStart; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure SetNewScene(AScene: IScene); override; - end; - - { TSkAnimatedPaintBox } - - [ComponentPlatforms(SkSupportedPlatformsMask)] - TSkAnimatedPaintBox = class(TSkCustomAnimatedControl) - public type - { TAnimation } - - TAnimation = class(TAnimationBase) - protected const - DefaultDuration = 1; - strict private - function IsDurationStored: Boolean; - strict protected - procedure DoAssign(ASource: TPersistent); override; - public - constructor Create(const AOwner: TFmxObject); - function Equals(AObject: TObject): Boolean; override; - published - property AutoReverse; - property Delay; - property Duration: Double read GetDuration write SetDuration stored IsDurationStored; - property Enabled; - property Inverse; - property Loop; - property Progress; - property Speed; - property StartFromCurrent; - property StartProgress; - property StopProgress; - end; - strict private - function GetAnimation: TAnimation; - procedure ReadAnimate(AReader: TReader); - procedure ReadDuration(AReader: TReader); - procedure ReadLoop(AReader: TReader); - procedure SetAnimation(const AValue: TAnimation); - strict protected - function CreateAnimation: TSkCustomAnimatedControl.TAnimationBase; override; - procedure DefineProperties(AFiler: TFiler); override; - published - property Animation: TAnimation read GetAnimation write SetAnimation; - property OnAnimationDraw; - property OnAnimationFinish; - property OnAnimationProcess; - property OnAnimationStart; - end; - - { TSkAnimatedPaintBoxHelper } - - TSkAnimatedPaintBoxHelper = class helper for TSkAnimatedPaintBox - strict protected - function RunningAnimation: Boolean; deprecated 'Use Animation.Running instead'; - public - function Animate: Boolean; deprecated 'Use Animation.Enabled instead'; - function Duration: Double; deprecated 'Use Animation.Duration instead'; - function FixedProgress: Boolean; deprecated 'Use Animation.Enabled instead'; - function Loop: Boolean; deprecated 'Use Animation.Loop instead'; - function Progress: Double; deprecated 'Use Animation.Progress instead'; - end; - - TSkAnimatedImageWrapMode = (Fit, FitCrop, Original, OriginalCenter, Place, Stretch); - - { TSkAnimatedImage } - - [ComponentPlatforms(SkSupportedPlatformsMask)] - TSkAnimatedImage = class(TSkCustomAnimatedControl) - public type - { TAnimation } - - TAnimation = class(TAnimationBase) - published - property AutoReverse; - property Delay; - property Duration; - property Enabled; - property Inverse; - property Loop; - property Progress; - property Speed; - property StartFromCurrent; - property StartProgress; - property StopProgress; - end; - - { TSource } - - TSource = class(TPersistent) - public type - TChangeProc = procedure of object; - strict private - FData: TBytes; - FOnChange: TChangeProc; - procedure SetData(const AValue: TBytes); - public - constructor Create(const AOnChange: TChangeProc); - procedure Assign(ASource: TPersistent); override; - function Equals(AObject: TObject): Boolean; override; - property Data: TBytes read FData write SetData; - end; - - { TFormatInfo } - - TFormatInfo = record - Description: string; - Extensions: TArray; - Name: string; - constructor Create(const AName, ADescription: string; const AExtensions: TArray); - end; - - { TAnimationCodec } - - TAnimationCodec = class - strict private - FQuality: TCanvasQuality; - strict protected - function GetDuration: Double; virtual; abstract; - function GetFPS: Double; virtual; abstract; - function GetIsStatic: Boolean; virtual; abstract; - function GetSize: TSizeF; virtual; abstract; - public - procedure Render(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); virtual; abstract; - procedure SeekFrameTime(const ATime: Double); virtual; abstract; - class function SupportedFormats: TArray; virtual; abstract; - class function TryDetectFormat(const ABytes: TBytes; out AFormat: TFormatInfo): Boolean; virtual; abstract; - class function TryMakeFromStream(const AStream: TStream; out ACodec: TAnimationCodec): Boolean; virtual; abstract; - property Duration: Double read GetDuration; - property FPS: Double read GetFPS; - property IsStatic: Boolean read GetIsStatic; - property Quality: TCanvasQuality read FQuality write FQuality; - property Size: TSizeF read GetSize; - end; - - TAnimationCodecClass = class of TAnimationCodec; - strict private class var - FRegisteredCodecs: TArray; - strict private - FCodec: TAnimationCodec; - FSource: TSource; - FWrapMode: TSkAnimatedImageWrapMode; - function GetAnimation: TAnimation; - function GetOriginalSize: TSizeF; - procedure ReadData(AStream: TStream); - procedure ReadLoop(AReader: TReader); - procedure ReadOnAnimationFinished(AReader: TReader); - procedure ReadOnAnimationProgress(AReader: TReader); - procedure SetAnimation(const AValue: TAnimation); - procedure SetSource(const AValue: TSource); - procedure SetWrapMode(const AValue: TSkAnimatedImageWrapMode); - procedure WriteData(AStream: TStream); - strict protected - function CreateAnimation: TSkCustomAnimatedControl.TAnimationBase; override; - procedure DefineProperties(AFiler: TFiler); override; - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - procedure RenderFrame(const ACanvas: ISkCanvas; const ADest: TRectF; const AProgress: Double; const AOpacity: Single); override; - procedure SourceChange; virtual; - property Codec: TAnimationCodec read FCodec; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure LoadFromFile(const AFileName: string); - procedure LoadFromStream(const AStream: TStream); - class procedure RegisterCodec(const ACodecClass: TAnimationCodecClass); static; - class property RegisteredCodecs: TArray read FRegisteredCodecs; - property OriginalSize: TSizeF read GetOriginalSize; - published - property Animation: TAnimation read GetAnimation write SetAnimation; - property Source: TSource read FSource write SetSource; - property WrapMode: TSkAnimatedImageWrapMode read FWrapMode write SetWrapMode default TSkAnimatedImageWrapMode.Fit; - property OnAnimationDraw; - property OnAnimationFinish; - property OnAnimationProcess; - property OnAnimationStart; - end; - - { TSkAnimatedImageHelper } - - TSkAnimatedImageHelper = class helper for TSkAnimatedImage - strict protected - function Duration: Double; deprecated 'Use Animation.Duration instead'; - public - function FixedProgress: Boolean; deprecated 'Use Animation.Enabled instead'; - function Loop: Boolean; deprecated 'Use Animation.Loop instead'; - function Progress: Double; deprecated 'Use Animation.Progress instead'; - function RunningAnimation: Boolean; deprecated 'Use Animation.Running instead'; - end; - - {$IF CompilerVersion < 31} - TFontWeight = (Thin, UltraLight, Light, SemiLight, Regular, Medium, Semibold, Bold, UltraBold, Black, UltraBlack); - TFontSlant = (Regular, Italic, Oblique); - TFontStretch = (UltraCondensed, ExtraCondensed, Condensed, SemiCondensed, Regular, SemiExpanded, Expanded, ExtraExpanded, UltraExpanded); - {$ENDIF} - - { TSkFontComponent } - - TSkFontComponent = class(TSkPersistent) - strict protected const - DefaultSize = 14; - DefaultSlant = TFontSlant.Regular; - DefaultStretch = TFontStretch.Regular; - DefaultWeight = TFontWeight.Regular; - strict private - FFamilies: string; - FSize: Single; - FSlant: TFontSlant; - FStretch: TFontStretch; - FWeight: TFontWeight; - procedure SetFamilies(const AValue: string); - procedure SetSize(const AValue: Single); - procedure SetSlant(const AValue: TFontSlant); - procedure SetStretch(const AValue: TFontStretch); - procedure SetWeight(const AValue: TFontWeight); - strict protected - procedure AssignTo(ADest: TPersistent); override; - function DefaultFamilies: string; virtual; - procedure DoAssign(ASource: TPersistent); override; - function IsFamiliesStored: Boolean; virtual; - function IsSizeStored: Boolean; virtual; - public - constructor Create; - function Equals(AObject: TObject): Boolean; override; - property OnChange; - published - property Families: string read FFamilies write SetFamilies stored IsFamiliesStored; - property Size: Single read FSize write SetSize stored IsSizeStored; - property Slant: TFontSlant read FSlant write SetSlant default DefaultSlant; - property Stretch: TFontStretch read FStretch write SetStretch default DefaultStretch; - property Weight: TFontWeight read FWeight write SetWeight default DefaultWeight; - end; - - TSkTextHorzAlign = (Center, Leading, Trailing, Justify); - - { TSkTextSettings } - - TSkTextSettings = class(TSkPersistent) - public type - { TDecorations } - - TDecorations = class(TSkPersistent) - strict protected - const - DefaultColor = TAlphaColors.Null; - DefaultDecorations = []; - DefaultStrokeColor = TAlphaColors.Null; - DefaultStyle = TSkTextDecorationStyle.Solid; - DefaultThickness = 1; - strict private - FColor: TAlphaColor; - FDecorations: TSkTextDecorations; - FStrokeColor: TAlphaColor; - FStyle: TSkTextDecorationStyle; - FThickness: Single; - procedure SetColor(const AValue: TAlphaColor); - procedure SetDecorations(const AValue: TSkTextDecorations); - procedure SetStrokeColor(const AValue: TAlphaColor); - procedure SetStyle(const AValue: TSkTextDecorationStyle); - procedure SetThickness(const AValue: Single); - strict protected - procedure DoAssign(ASource: TPersistent); override; - function IsThicknessStored: Boolean; virtual; - public - constructor Create; - function Equals(AObject: TObject): Boolean; override; - published - property Color: TAlphaColor read FColor write SetColor default DefaultColor; - property Decorations: TSkTextDecorations read FDecorations write SetDecorations default DefaultDecorations; - property StrokeColor: TAlphaColor read FStrokeColor write SetStrokeColor default DefaultStrokeColor; - property Style: TSkTextDecorationStyle read FStyle write SetStyle default DefaultStyle; - property Thickness: Single read FThickness write SetThickness stored IsThicknessStored; - end; - strict protected const - DefaultFontColor = TAlphaColors.Black; - DefaultHeightMultiplier = 0; - DefaultHorzAlign = TSkTextHorzAlign.Leading; - DefaultLetterSpacing = 0; - DefaultMaxLines = 1; - DefaultTrimming = TTextTrimming.Word; - DefaultVertAlign = TTextAlign.Center; - strict private - FDecorations: TDecorations; - FFont: TSkFontComponent; - FFontColor: TAlphaColor; - FHeightMultiplier: Single; - FHorzAlign: TSkTextHorzAlign; - FLetterSpacing: Single; - FMaxLines: NativeUInt; - [unsafe] FOwner: TPersistent; - FTrimming: TTextTrimming; - FVertAlign: TTextAlign; - procedure DecorationsChange(ASender: TObject); - procedure FontChanged(ASender: TObject); - function IsHeightMultiplierStored: Boolean; - function IsLetterSpacingStored: Boolean; - procedure SetDecorations(const AValue: TDecorations); - procedure SetFont(const AValue: TSkFontComponent); - procedure SetFontColor(const AValue: TAlphaColor); - procedure SetHeightMultiplier(const AValue: Single); - procedure SetHorzAlign(const AValue: TSkTextHorzAlign); - procedure SetLetterSpacing(const AValue: Single); - procedure SetMaxLines(const AValue: NativeUInt); - procedure SetTrimming(const AValue: TTextTrimming); - procedure SetVertAlign(const AValue: TTextAlign); - strict protected - function CreateFont: TSkFontComponent; virtual; - procedure DoAssign(ASource: TPersistent); override; - procedure DoAssignNotStyled(const ATextSettings: TSkTextSettings; const AStyledSettings: TStyledSettings); virtual; - public - constructor Create(const AOwner: TPersistent); virtual; - destructor Destroy; override; - procedure AssignNotStyled(const ATextSettings: TSkTextSettings; const AStyledSettings: TStyledSettings); - function Equals(AObject: TObject): Boolean; override; - procedure UpdateStyledSettings(const AOldTextSettings, ADefaultTextSettings: TSkTextSettings; - var AStyledSettings: TStyledSettings); virtual; - property Owner: TPersistent read FOwner; - property OnChange; - published - property Decorations: TDecorations read FDecorations write SetDecorations; - property Font: TSkFontComponent read FFont write SetFont; - property FontColor: TAlphaColor read FFontColor write SetFontColor default DefaultFontColor; - property HeightMultiplier: Single read FHeightMultiplier write SetHeightMultiplier stored IsHeightMultiplierStored; - property HorzAlign: TSkTextHorzAlign read FHorzAlign write SetHorzAlign default DefaultHorzAlign; - property LetterSpacing: Single read FLetterSpacing write SetLetterSpacing stored IsLetterSpacingStored; - property MaxLines: NativeUInt read FMaxLines write SetMaxLines default DefaultMaxLines; - property Trimming: TTextTrimming read FTrimming write SetTrimming default DefaultTrimming; - property VertAlign: TTextAlign read FVertAlign write SetVertAlign default DefaultVertAlign; - end; - - TSkTextSettingsClass = class of TSkTextSettings; - - { ISkTextSettings } - - ISkTextSettings = interface - ['{CE7E837B-F927-4C78-B1D2-C62EF4A93014}'] - function GetDefaultTextSettings: TSkTextSettings; - function GetResultingTextSettings: TSkTextSettings; - function GetStyledSettings: TStyledSettings; - function GetTextSettings: TSkTextSettings; - procedure SetStyledSettings(const AValue: TStyledSettings); - procedure SetTextSettings(const AValue: TSkTextSettings); - property DefaultTextSettings: TSkTextSettings read GetDefaultTextSettings; - property ResultingTextSettings: TSkTextSettings read GetResultingTextSettings; - property StyledSettings: TStyledSettings read GetStyledSettings write SetStyledSettings; - property TextSettings: TSkTextSettings read GetTextSettings write SetTextSettings; - end; - - { TSkTextSettingsInfo } - - TSkTextSettingsInfo = class(TPersistent) - public type - TBaseTextSettings = class(TSkTextSettings) - strict private - [unsafe] FControl: TControl; - [unsafe] FInfo: TSkTextSettingsInfo; - public - constructor Create(const AOwner: TPersistent); override; - property Control: TControl read FControl; - property Info: TSkTextSettingsInfo read FInfo; - end; - - TCustomTextSettings = class(TBaseTextSettings) - public - constructor Create(const AOwner: TPersistent); override; - published - property MaxLines default 0; - end; - - TCustomTextSettingsClass = class of TCustomTextSettings; - strict private - FDefaultTextSettings: TSkTextSettings; - FDesign: Boolean; - FOldTextSettings: TSkTextSettings; - FOnChange: TNotifyEvent; - [unsafe] FOwner: TPersistent; - FResultingTextSettings: TSkTextSettings; - FStyledSettings: TStyledSettings; - FTextSettings: TSkTextSettings; - procedure OnCalculatedTextSettings(ASender: TObject); - procedure OnDefaultChanged(ASender: TObject); - procedure OnTextChanged(ASender: TObject); - procedure SetDefaultTextSettings(const AValue: TSkTextSettings); - procedure SetStyledSettings(const AValue: TStyledSettings); - procedure SetTextSettings(const AValue: TSkTextSettings); - strict protected - procedure DoCalculatedTextSettings; virtual; - procedure DoDefaultChanged; virtual; - procedure DoStyledSettingsChanged; virtual; - procedure DoTextChanged; virtual; - procedure RecalculateTextSettings; virtual; - public - constructor Create(AOwner: TPersistent; ATextSettingsClass: TSkTextSettingsInfo.TCustomTextSettingsClass); virtual; - destructor Destroy; override; - property DefaultTextSettings: TSkTextSettings read FDefaultTextSettings write SetDefaultTextSettings; - property Design: Boolean read FDesign write FDesign; - property Owner: TPersistent read FOwner; - property ResultingTextSettings: TSkTextSettings read FResultingTextSettings; - property StyledSettings: TStyledSettings read FStyledSettings write SetStyledSettings; - property TextSettings: TSkTextSettings read FTextSettings write SetTextSettings; - property OnChange: TNotifyEvent read FOnChange write FOnChange; - end; - - { ISkStyleTextObject } - - ISkStyleTextObject = interface(IFreeNotificationBehavior) - ['{B5584DD4-D568-4A84-BCD5-C8CB7C068E4D}'] - function GetTextSettings: TSkTextSettings; - procedure SetTextSettings(const AValue: TSkTextSettings); - property TextSettings: TSkTextSettings read GetTextSettings write SetTextSettings; - end; - - { TSkCustomStyleTextObject } - - TSkCustomStyleTextObject = class(TFmxObject, ISkStyleTextObject, IObjectState) - strict private - FOnChange: TNotifyEvent; - FTextSettings: TSkTextSettings; - FSavedTextSettings: TSkTextSettings; - function GetTextSettings: TSkTextSettings; - function RestoreState: Boolean; - function SaveState: Boolean; - procedure SetTextSettings(const AValue: TSkTextSettings); - procedure TextSettingsChange(ASender: TObject); - strict protected - function CreateTextSettings: TSkTextSettings; virtual; - procedure SetName(const ANewName: TComponentName); override; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - property OnChange: TNotifyEvent read FOnChange write FOnChange; - property TextSettings: TSkTextSettings read FTextSettings write SetTextSettings; - end; - - { TSkStyleTextObject } - - [ComponentPlatforms(SkSupportedPlatformsMask)] - TSkStyleTextObject = class(TSkCustomStyleTextObject) - published - property TextSettings; - end; - - { TSkLabel } - - [ComponentPlatforms(SkSupportedPlatformsMask)] - TSkLabel = class(TSkStyledControl, ISkTextSettings{$IF CompilerVersion >= 29}, ICaption{$ENDIF}) - public type - TWordsCollection = class; - TCustomWordsItemClass = class of TCustomWordsItem; - - TCustomWordsItem = class(TCollectionItem) - strict protected - const - DefaultBackgroundColor = TAlphaColors.Null; - DefaultCursor = crDefault; - DefaultFontColor = TAlphaColors.Black; - DefaultHeightMultiplier = 0; - DefaultLetterSpacing = 0; - DefaultName = 'Item 0'; - DefaultText = ''; - strict private - FBackgroundColor: TAlphaColor; - FChanged: Boolean; - FCursor: TCursor; - FIgnoringAllChanges: Boolean; - FName: string; - FOnClick: TNotifyEvent; - FTag: NativeInt; - FTagFloat: Single; - [Weak] FTagObject: TObject; - FTagString: string; - FText: string; - FTextSettingsInfo: TSkTextSettingsInfo; - FUpdatingCount: Integer; - [unsafe] FWords: TWordsCollection; - procedure CheckName(const AName: string; AWordsCollection: TWordsCollection); - function GetDecorations: TSkTextSettings.TDecorations; - function GetFont: TSkFontComponent; - function GetFontColor: TAlphaColor; - function GetHeightMultiplier: Single; - function GetLetterSpacing: Single; - function GetStyledSettings: TStyledSettings; - function IsFontColorStored: Boolean; - function IsHeightMultiplierStored: Boolean; - function IsLetterSpacingStored: Boolean; - function IsNameStored: Boolean; - function IsStyledSettingsStored: Boolean; - function IsTextStored: Boolean; - procedure TextSettingsChange(ASender: TObject); - procedure SetBackgroundColor(const AValue: TAlphaColor); - procedure SetCursor(const AValue: TCursor); - procedure SetDecorations(const AValue: TSkTextSettings.TDecorations); - procedure SetFont(const AValue: TSkFontComponent); - procedure SetFontColor(const AValue: TAlphaColor); - procedure SetHeightMultiplier(const AValue: Single); - procedure SetLetterSpacing(const AValue: Single); - procedure SetName(const AValue: string); - procedure SetStyledSettings(const AValue: TStyledSettings); - procedure SetText(const AValue: string); - function UniqueName(const AName: string; const ACollection: TCollection): string; - strict protected - procedure DoAssign(ASource: TPersistent); virtual; - procedure DoChanged; virtual; - function GetDisplayName: string; override; - procedure SetCollection(AValue: TCollection); override; - public - constructor Create(ACollection: TCollection); override; - destructor Destroy; override; - procedure Assign(ASource: TPersistent); override; final; - procedure BeginUpdate; overload; - procedure Change; virtual; - procedure EndUpdate; overload; - procedure EndUpdate(const AIgnoreAllChanges: Boolean); overload; virtual; - property BackgroundColor: TAlphaColor read FBackgroundColor write SetBackgroundColor default DefaultBackgroundColor; - property Cursor: TCursor read FCursor write SetCursor default crDefault; - property Decorations: TSkTextSettings.TDecorations read GetDecorations write SetDecorations; - property Font: TSkFontComponent read GetFont write SetFont; - property FontColor: TAlphaColor read GetFontColor write SetFontColor stored IsFontColorStored; - property HeightMultiplier: Single read GetHeightMultiplier write SetHeightMultiplier stored IsHeightMultiplierStored; - property LetterSpacing: Single read GetLetterSpacing write SetLetterSpacing stored IsLetterSpacingStored; - /// The case-insensitive name of the item in the collection. This field cannot be empty and must be unique for his collection - property Name: string read FName write SetName stored IsNameStored; - property StyledSettings: TStyledSettings read GetStyledSettings write SetStyledSettings stored IsStyledSettingsStored; - property Tag: NativeInt read FTag write FTag default 0; - property TagFloat: Single read FTagFloat write FTagFloat; - property TagObject: TObject read FTagObject write FTagObject; - property TagString: string read FTagString write FTagString; - property Text: string read FText write SetText stored IsTextStored; - property Words: TWordsCollection read FWords; - property OnClick: TNotifyEvent read FOnClick write FOnClick; - end; - - { TWordsCollection } - - TWordsCollection = class(TOwnedCollection) - strict protected - const - DefaultColor = TAlphaColors.Black; - DefaultFontSize = 14; - DefaultFontSlant = TFontSlant.Regular; - DefaultFontWeight = TFontWeight.Regular; - strict private - [unsafe] FLabel: TSkLabel; - FOnChange: TNotifyEvent; - function GetItem(AIndex: Integer): TCustomWordsItem; - function GetItemByName(const AName: string): TCustomWordsItem; - procedure SetItem(AIndex: Integer; const AValue: TCustomWordsItem); - strict protected - procedure Update(AItem: TCollectionItem); override; - public - constructor Create(AOwner: TPersistent; AItemClass: TCustomWordsItemClass); - function Add: TCustomWordsItem; overload; - function Add(const AText: string; const AColor: TAlphaColor = DefaultColor; - const AFontSize: Single = DefaultFontSize; - const AFontWeight: TFontWeight = DefaultFontWeight; - const AFontSlant: TFontSlant = DefaultFontSlant): TCustomWordsItem; overload; - function AddOrSet(const AName, AText: string; const AFontColor: TAlphaColor = DefaultColor; - const AFont: TSkFontComponent = nil; const AOnClick: TNotifyEvent = nil; - const ACursor: TCursor = crDefault): TCustomWordsItem; - function Insert(AIndex: Integer): TCustomWordsItem; - /// Case-insensitive search of item by name - function IndexOf(const AName: string): Integer; - /// Case-insensitive search of item by name - property ItemByName[const AName: string]: TCustomWordsItem read GetItemByName; - property Items[AIndex: Integer]: TCustomWordsItem read GetItem write SetItem; default; - property &Label: TSkLabel read FLabel; - property OnChange: TNotifyEvent read FOnChange write FOnChange; - end; - - { TWordsItem } - - TWordsItem = class(TCustomWordsItem) - published - property BackgroundColor; - property Cursor; - property Decorations; - property Font; - property FontColor; - property HeightMultiplier; - property LetterSpacing; - property Name; - property StyledSettings; - property TagString; - property Text; - property OnClick; - end; - - { TItemClickedMessage } - - TItemClickedMessage = class(TMessage); - strict private - FAutoSize: Boolean; - FBackgroundPicture: ISkPicture; - FClickedPosition: TPointF; - FHasCustomBackground: Boolean; - FHasCustomCursor: Boolean; - FLastFillTextFlags: TFillTextFlags; - FObjectState: IObjectState; - FParagraph: ISkParagraph; - FParagraphBounds: TRectF; - FParagraphLayoutWidth: Single; - FParagraphStroked: ISkParagraph; - {$IF CompilerVersion < 30} - FPressedPosition: TPointF; - {$ENDIF} - FStyleText: ISkStyleTextObject; - FTextSettingsInfo: TSkTextSettingsInfo; - FWords: TWordsCollection; - FWordsMouseOver: TCustomWordsItem; - procedure DeleteParagraph; - procedure GetFitSize(var AWidth, AHeight: Single); - function GetLinesCount: Integer; - function GetParagraph: ISkParagraph; - function GetParagraphBounds: TRectF; - function GetText: string; - function HasFitSizeChanged: Boolean; - procedure ParagraphLayout(const AWidth: Single); - procedure SetAutoSize(const AValue: Boolean); - procedure SetText(const AValue: string); - procedure SetWords(const AValue: TWordsCollection); - procedure SetWordsMouseOver(const AValue: TCustomWordsItem); - procedure TextSettingsChanged(AValue: TObject); - {$IF CompilerVersion >= 29} - { ICaption } - function TextStored: Boolean; - {$ENDIF} - procedure WordsChange(ASender: TObject); - strict private - { ISkTextSettings } - function GetDefaultTextSettings: TSkTextSettings; - function GetResultingTextSettings: TSkTextSettings; - function GetStyledSettings: TStyledSettings; - function GetTextSettings: TSkTextSettings; - procedure SetStyledSettings(const AValue: TStyledSettings); - procedure SetTextSettings(const AValue: TSkTextSettings); - strict protected - procedure ApplyStyle; override; - procedure Click; override; - procedure DoEndUpdate; override; - procedure DoMouseLeave; override; - function DoSetSize(const ASize: TControlSize; const ANewPlatformDefault: Boolean; ANewWidth, ANewHeight: Single; - var ALastWidth, ALastHeight: Single): Boolean; override; - procedure DoStyleChanged; override; - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - procedure FreeStyle; override; - function GetDefaultSize: TSizeF; override; - function GetTextSettingsClass: TSkTextSettingsInfo.TCustomTextSettingsClass; virtual; - function GetWordsItemAtPosition(const AX, AY: Single): TCustomWordsItem; - function IsStyledSettingsStored: Boolean; virtual; - procedure Loaded; override; - procedure MouseClick(AButton: TMouseButton; AShift: TShiftState; AX, AY: Single); override; - {$IF CompilerVersion < 30} - procedure MouseDown(AButton: TMouseButton; AShift: TShiftState; AX, AY: Single); override; - {$ENDIF} - procedure MouseMove(AShift: TShiftState; AX, AY: Single); override; - function NeedsRedraw: Boolean; override; - procedure SetAlign(const AValue: TAlignLayout); override; - procedure SetName(const AValue: TComponentName); override; - property Paragraph: ISkParagraph read GetParagraph; - property ParagraphBounds: TRectF read GetParagraphBounds; - property StyleText: ISkStyleTextObject read FStyleText; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - function DidExceedMaxLines: Boolean; - property DefaultTextSettings: TSkTextSettings read GetDefaultTextSettings; - property LinesCount: Integer read GetLinesCount; - {$IF CompilerVersion < 30} - property PressedPosition: TPointF read FPressedPosition write FPressedPosition; - {$ENDIF} - property ResultingTextSettings: TSkTextSettings read GetResultingTextSettings; - published - property Align; - property Anchors; - property ClipChildren default False; - property ClipParent default False; - property DragMode default TDragMode.dmManual; - property Enabled default True; - property EnableDragHighlight default True; - property Height; - property Hint; - property HitTest default False; - property Locked default False; - property Margins; - property Opacity; - property Padding; - {$IF CompilerVersion >= 30} - property ParentShowHint; - {$ENDIF} - property PopupMenu; - property Position; - property RotationAngle; - property RotationCenter; - property Scale; - property ShowHint; - property Size; - property Visible default True; - property Width; - property OnClick; - property OnDblClick; - property OnDragDrop; - property OnDragEnd; - property OnDragEnter; - property OnDragLeave; - property OnDragOver; - property OnMouseDown; - property OnMouseEnter; - property OnMouseLeave; - property OnMouseMove; - property OnMouseUp; - property OnMouseWheel; - property OnPainting; - property OnResize; - {$IF CompilerVersion >= 32} - property OnResized; - {$ENDIF} - published - property AutoSize: Boolean read FAutoSize write SetAutoSize default True; - property AutoTranslate default True; - property StyledSettings: TStyledSettings read GetStyledSettings write SetStyledSettings stored IsStyledSettingsStored; - property StyleLookup; - property Text: string read GetText write SetText stored False; - property TextSettings: TSkTextSettings read GetTextSettings write SetTextSettings; - property TouchTargetExpansion; - property Words: TWordsCollection read FWords write SetWords; - property OnApplyStyleLookup; - property OnDraw; - end; - - { TSkDefaultProviders } - - TSkDefaultProviders = class sealed - strict private class var - FResource: ISkResourceProvider; - FTypefaceFont: ISkTypefaceFontProvider; - class constructor Create; - public - class procedure RegisterTypeface(const AFileName: string); overload; static; - class procedure RegisterTypeface(const AStream: TStream); overload; static; - class property Resource: ISkResourceProvider read FResource write FResource; - class property TypefaceFont: ISkTypefaceFontProvider read FTypefaceFont; - end; - - { TSkTypefaceManager } - - TSkTypefaceManager = class sealed - public - class function Provider: ISkTypefaceFontProvider; static; deprecated 'Use TSkDefaultProviders.TypefaceFont instead'; - class procedure RegisterTypeface(const AFileName: string); overload; static; deprecated 'Use TSkDefaultProviders.RegisterTypeface instead'; - class procedure RegisterTypeface(const AStream: TStream); overload; static; deprecated 'Use TSkDefaultProviders.RegisterTypeface instead'; - end; - -procedure AddSkPathToPathData(const APathData: TPathData; const ASkPath: ISkPath); -function BitmapToSkImage(const ABitmap: TBitmap): ISkImage; -function PathDataToSkPath(const APathData: TPathData): ISkPath; -procedure SkiaDraw(const ABitmap: TBitmap; const AProc: TSkDrawProc; const AStartClean: Boolean = True); -function SkImageToBitmap(const AImage: ISkImage): TBitmap; -function SkPathToPathData(const ASkPath: ISkPath): TPathData; - -const - SkFmxColorType: array[TPixelFormat] of TSkColorType = ( - { None } TSkColorType.Unknown, - { RGB } TSkColorType.Unknown, - { RGBA } TSkColorType.RGBA8888, - { BGR } TSkColorType.Unknown, - { BGRA } TSkColorType.BGRA8888, - { RGBA16 } TSkColorType.RGBA16161616, - { BGR_565 } TSkColorType.RGB565, - { BGRA4 } TSkColorType.ARGB4444, - { BGR4 } TSkColorType.Unknown, - { BGR5_A1 } TSkColorType.Unknown, - { BGR5 } TSkColorType.Unknown, - { BGR10_A2 } TSkColorType.BGRA1010102, - { RGB10_A2 } TSkColorType.RGBA1010102, - { L } TSkColorType.Gray8, - { LA } TSkColorType.Unknown, - { LA4 } TSkColorType.Unknown, - { L16 } TSkColorType.Unknown, - { A } TSkColorType.Alpha8, - { R16F } TSkColorType.AlphaF16, - { RG16F } TSkColorType.RGF16, - { RGBA16F } TSkColorType.RGBAF16, - { R32F } TSkColorType.Unknown, - { RG32F } TSkColorType.Unknown, - { RGBA32F } TSkColorType.RGBAF32 - ); - - - SkFmxPixelFormat: array[TSkColorType] of TPixelFormat = ( - { Unknown } TPixelFormat.None, - { Alpha8 } TPixelFormat.A, - { RGB565 } TPixelFormat.BGR_565, - { ARGB4444 } TPixelFormat.BGRA4, - { RGBA8888 } TPixelFormat.RGBA, - { RGB888X } TPixelFormat.None, - { BGRA8888 } TPixelFormat.BGRA, - { RGBA1010102 } TPixelFormat.RGB10_A2, - { BGRA1010102 } TPixelFormat.BGR10_A2, - { RGB101010X } TPixelFormat.None, - { BGR101010X } TPixelFormat.None, - { Gray8 } TPixelFormat.L, - { RGBAF16 } TPixelFormat.RGBA16F, - { RGBAF16Clamped } TPixelFormat.RGBA16F, - { RGBAF32 } TPixelFormat.RGBA32F, - { RG88 } TPixelFormat.None, - { AlphaF16 } TPixelFormat.R16F, - { RGF16 } TPixelFormat.RG16F, - { Alpha16 } TPixelFormat.None, - { RG1616 } TPixelFormat.None, - { RGBA16161616 } TPixelFormat.RGBA16, - { SRGBA8888 } TPixelFormat.None, - { R8 } TPixelFormat.None - ); - -var - /// Allows use of Skia Canvas for UI rendering, replacing FMX's default Canvas - GlobalUseSkia: Boolean; - /// Allows the UI rendering in Skia Canvas to use the CPU instead of the GPU (only takes effect on Windows currently) - GlobalUseSkiaRasterWhenAvailable: Boolean = True; - /// Disables registration of Skia image codecs - GlobalDisableSkiaCodecsReplacement: Boolean; - -procedure Register; - -implementation - -uses - { Delphi } - System.Math.Vectors, - System.ZLib, - System.IOUtils, - System.TypInfo, - System.Character, - System.Generics.Defaults, - System.RTLConsts, - {$IF CompilerVersion >= 29} - FMX.Utils, - {$ENDIF} - FMX.Platform, - FMX.BehaviorManager, - FMX.Forms, - FMX.Ani, - - { Skia } - Skia.FMX.Graphics; - -type - { TSkDefaultAnimationCodec } - - TSkDefaultAnimationCodec = class(TSkAnimatedImage.TAnimationCodec) - strict private type - TImageFormat = (GIF, WebP); - strict private - FAnimationCodec: ISkAnimationCodecPlayer; - FStream: TStream; - strict protected - function GetDuration: Double; override; - function GetFPS: Double; override; - function GetIsStatic: Boolean; override; - function GetSize: TSizeF; override; - public - constructor Create(const AAnimationCodec: ISkAnimationCodecPlayer; const AStream: TStream); - destructor Destroy; override; - procedure Render(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - procedure SeekFrameTime(const ATime: Double); override; - class function SupportedFormats: TArray; override; - class function TryDetectFormat(const ABytes: TBytes; out AFormat: TSkAnimatedImage.TFormatInfo): Boolean; override; - class function TryMakeFromStream(const AStream: TStream; out ACodec: TSkAnimatedImage.TAnimationCodec): Boolean; override; - end; - - { TSkLottieAnimationCodec } - - TSkLottieAnimationCodec = class(TSkAnimatedImage.TAnimationCodec) - strict private type - TAnimationFormat = (Lottie, TGS); - strict private - FSkottie: ISkottieAnimation; - strict protected - function GetDuration: Double; override; - function GetFPS: Double; override; - function GetIsStatic: Boolean; override; - function GetSize: TSizeF; override; - public - constructor Create(const ASkottie: ISkottieAnimation); - procedure Render(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - procedure SeekFrameTime(const ATime: Double); override; - class function SupportedFormats: TArray; override; - class function TryDetectFormat(const ABytes: TBytes; out AFormat: TSkAnimatedImage.TFormatInfo): Boolean; override; - class function TryMakeFromStream(const AStream: TStream; out ACodec: TSkAnimatedImage.TAnimationCodec): Boolean; override; - end; - - {$IF CompilerVersion < 31} - { TSkCanvasHelper } - - TSkCanvasHelper = class helper for TCanvas - public - function AlignToPixel(const ARect: TRectF): TRectF; - end; - {$ENDIF} - - {$IF CompilerVersion < 33} - { TSkEpsilonHelper } - - TSkEpsilonHelper = record helper for TEpsilon - const - Scale = 1E-4; - FontSize = 1E-2; - Position = 1E-3; - end; - {$ENDIF} - - {$IF CompilerVersion < 32} - { TSkRectFHelper } - - TSkRectFHelper = record helper for TRectF - public - function FitInto(const ADesignatedArea: TRectF): TRectF; overload; - function FitInto(const ADesignatedArea: TRectF; out ARatio: Single): TRectF; overload; - end; - - function RectCenter(var R: TRectF; const Bounds: TRectF): TRectF; forward; - {$ENDIF} - -const - ControlExceededBitmapLimitWarning = 'Skia.FMX: A control has exceeded the size allowed for a bitmap (class %s, name "%s"). We will reduce the drawing quality to avoid this exception. Consider using "GlobalUseSkia := True" to avoid this kind of problem.'; - SkFontSlant: array[TFontSlant] of TSkFontSlant = (TSkFontSlant.Upright, TSkFontSlant.Italic, TSkFontSlant.Oblique); - SkFontWeightValue: array[TFontWeight] of Integer = (100, 200, 300, 350, 400, 500, 600, 700, 800, 900, 950); - SkFontWidthValue: array[TFontStretch] of Integer = (1, 2, 3, 4, 5, 6, 7, 8, 9); - -procedure AddSkPathToPathData(const APathData: TPathData; const ASkPath: ISkPath); -begin - APathData.AddSkPath(ASkPath); -end; - -function BitmapToSkImage(const ABitmap: TBitmap): ISkImage; -begin - Result := ABitmap.ToSkImage; -end; - -function IsSameBytes(const ALeft, ARight: TBytes): Boolean; -begin - Result := (ALeft = ARight) or - ((Length(ALeft) = Length(ARight)) and - ((Length(ALeft) = 0) or CompareMem(PByte(@ALeft[0]), PByte(@ARight[0]), Length(ALeft)))); -end; - -function PathDataToSkPath(const APathData: TPathData): ISkPath; -begin - Result := APathData.ToSkPath; -end; - -function PlaceIntoTopLeft(const ASourceRect, ADesignatedArea: TRectF): TRectF; -begin - Result := ASourceRect; - if (ASourceRect.Width > ADesignatedArea.Width) or (ASourceRect.Height > ADesignatedArea.Height) then - Result := Result.FitInto(ADesignatedArea); - Result.SetLocation(ADesignatedArea.TopLeft); -end; - -procedure SkiaDraw(const ABitmap: TBitmap; const AProc: TSkDrawProc; const AStartClean: Boolean); -begin - ABitmap.SkiaDraw(AProc, AStartClean); -end; - -function SkImageToBitmap(const AImage: ISkImage): TBitmap; -begin - Result := TBitmap.CreateFromSkImage(AImage); -end; - -function SkPathToPathData(const ASkPath: ISkPath): TPathData; -begin - Result := TPathData.CreateFromSkPath(ASkPath); -end; - -{$IF CompilerVersion < 31} -{ TSkCanvasHelper } - -function TSkCanvasHelper.AlignToPixel(const ARect: TRectF): TRectF; -begin - Result.Left := AlignToPixelHorizontally(ARect.Left); - Result.Top := AlignToPixelVertically(ARect.Top); - Result.Right := Result.Left + Round(ARect.Width * Scale) / Scale; // keep ratio horizontally - Result.Bottom := Result.Top + Round(ARect.Height * Scale) / Scale; // keep ratio vertically -end; -{$ENDIF} - -{$IF CompilerVersion < 32} -{ TSkRectFHelper } - -function TSkRectFHelper.FitInto(const ADesignatedArea: TRectF): TRectF; -var - LRatio: Single; -begin - Result := FitInto(ADesignatedArea, LRatio); -end; - -function TSkRectFHelper.FitInto(const ADesignatedArea: TRectF; out ARatio: Single): TRectF; -begin - if (ADesignatedArea.Width <= 0) or (ADesignatedArea.Height <= 0) then - begin - ARatio := 1; - Exit(Self); - end; - - if (Self.Width / ADesignatedArea.Width) > (Self.Height / ADesignatedArea.Height) then - ARatio := Self.Width / ADesignatedArea.Width - else - ARatio := Self.Height / ADesignatedArea.Height; - - if ARatio = 0 then - Exit(Self) - else - begin - Result := TRectF.Create(0, 0, Self.Width / ARatio, Self.Height / ARatio); - RectCenter(Result, ADesignatedArea); - end; -end; - -function RectCenter(var R: TRectF; const Bounds: TRectF): TRectF; -begin - OffsetRect(R, -R.Left, -R.Top); - OffsetRect(R, (RectWidth(Bounds)/2 - RectWidth(R)/2), (RectHeight(Bounds)/2 - RectHeight(R)/2)); - OffsetRect(R, Bounds.Left, Bounds.Top); - Result := R; -end; -{$ENDIF} - -{ TSkBitmapHelper } - -constructor TSkBitmapHelper.CreateFromSkImage(const AImage: ISkImage); -var - LData: TBitmapData; -begin - Assert(Assigned(AImage)); - Create(AImage.Width, AImage.Height); - if (not IsEmpty) and Map(TMapAccess.Write, LData) then - begin - try - AImage.ReadPixels(TSkImageInfo.Create(Width, Height, SkFmxColorType[LData.PixelFormat]), LData.Data, LData.Pitch); - finally - Unmap(LData); - end; - end; -end; - -procedure TSkBitmapHelper.SkiaDraw(const AProc: TSkDrawProc; const AStartClean: Boolean); - - procedure Draw(const ACanvas: ISkCanvas); - begin - if AStartClean then - ACanvas.Clear(TAlphaColors.Null); - AProc(ACanvas); - end; - -var - LAccess: TMapAccess; - LBeginSceneCount: Integer; - LColorType: TSkColorType; - LData: TBitmapData; - LSurface: ISkSurface; -begin - Assert(Assigned(AProc)); - if IsEmpty then - raise ESkBitmapHelper.Create('Invalid bitmap'); - if CanvasClass.InheritsFrom(TSkCanvasCustom) then - begin - {$REGION ' - Workaround RSP-38418'} - // - ----------------------------------------------------------------------- - // - WORKAROUND - // - ----------------------------------------------------------------------- - // - - // - Description: - // - This code is a workaround intended to fix issue when changes the - // - bitmap that has been assign to another. - // - - // - Bug report: - // - https://quality.embarcadero.com/browse/RSP-38418 - // - - // - ----------------------------------------------------------------------- - {$IF (CompilerVersion < 35) or ((CompilerVersion = 35) and not DECLARED(RTLVersion113))} - if Image.RefCount > 1 then - begin - LBeginSceneCount := Canvas.BeginSceneCount; - CopyToNewReference; - while LBeginSceneCount > 0 do - begin - Canvas.BeginScene; - Dec(LBeginSceneCount); - end; - end; - {$ENDIF} - // - ----------------------------------------------------------------------- - {$ENDREGION} - if Canvas.BeginSceneCount = 0 then - begin - if Canvas.BeginScene then - begin - try - Draw(TSkCanvasCustom(Canvas).Canvas); - finally - Canvas.EndScene; - end; - end; - end - else - Draw(TSkCanvasCustom(Canvas).Canvas); - end - else - begin - case PixelFormat of - TPixelFormat.RGBA: LColorType := TSkColorType.RGBA8888; - TPixelFormat.BGRA: LColorType := TSkColorType.BGRA8888; - else - raise ESkBitmapHelper.Create('Invalid pixelformat'); - end; - if AStartClean then - LAccess := TMapAccess.Write - else - LAccess := TMapAccess.ReadWrite; - if Map(LAccess, LData) then - try - LSurface := TSkSurface.MakeRasterDirect(TSkImageInfo.Create(LData.Width, LData.Height, LColorType), LData.Data, LData.Pitch); - Draw(LSurface.Canvas); - finally - Unmap(LData); - end; - end; -end; - -function TSkBitmapHelper.ToSkImage: ISkImage; -var - LColorType: TSkColorType; - LData: TBitmapData; -begin - if IsEmpty then - raise ESkBitmapHelper.Create('Invalid bitmap'); - case PixelFormat of - TPixelFormat.RGBA: LColorType := TSkColorType.RGBA8888; - TPixelFormat.BGRA: LColorType := TSkColorType.BGRA8888; - else - raise ESkBitmapHelper.Create('Invalid pixelformat'); - end; - if not Map(TMapAccess.Read, LData) then - raise ESkBitmapHelper.Create('Could not map the bitmap'); - try - Result := TSkImage.MakeRasterCopy(TSkImageInfo.Create(Width, Height, LColorType), LData.Data, LData.Pitch); - finally - Unmap(LData); - end; -end; - -{ TSkPathDataHelper } - -procedure TSkPathDataHelper.AddSkPath(const AValue: ISkPath); -var - LElem: TSkPathIteratorElem; - LPoints: TArray; -begin - for LElem in AValue.GetIterator(False) do - begin - case LElem.Verb of - TSkPathVerb.Move : MoveTo(LElem.Points[0]); - TSkPathVerb.Line : LineTo(LElem.Points[1]); - TSkPathVerb.Quad : QuadCurveTo(LElem.Points[1], LElem.Points[2]); - TSkPathVerb.Conic : - begin - LPoints := TSkPath.ConvertConicToQuads(LElem.Points[0], LElem.Points[1], LElem.Points[2], LElem.ConicWeight, 1); - QuadCurveTo(LPoints[1], LPoints[2]); - QuadCurveTo(LPoints[3], LPoints[4]); - end; - TSkPathVerb.Cubic : CurveTo(LElem.Points[1], LElem.Points[2], LElem.Points[3]); - TSkPathVerb.Close : ClosePath; - end; - end; -end; - -constructor TSkPathDataHelper.CreateFromSkPath(const AValue: ISkPath); -begin - Create; - AddSkPath(AValue); -end; - -procedure TSkPathDataHelper.FromSkPath(const AValue: ISkPath); -begin - Clear; - AddSkPath(AValue); -end; - -function TSkPathDataHelper.ToSkPath: ISkPath; -var - I: Integer; - LPathBuilder: ISkPathBuilder; -begin - LPathBuilder := TSkPathBuilder.Create(TSkPathFillType.EvenOdd); - I := 0; - while I < Count do - begin - case Points[I].Kind of - TPathPointKind.MoveTo : LPathBuilder.MoveTo(Points[I].Point); - TPathPointKind.LineTo : LPathBuilder.LineTo(Points[I].Point); - TPathPointKind.Close : LPathBuilder.Close; - TPathPointKind.CurveTo : - begin - LPathBuilder.CubicTo(Points[I].Point, Points[I + 1].Point, Points[I + 2].Point); - Inc(I, 2); - end; - end; - Inc(I); - end; - Result := LPathBuilder.Detach; -end; - -{ TSkPersistent } - -procedure TSkPersistent.AfterConstruction; -begin - inherited; - FCreated := True; -end; - -procedure TSkPersistent.Assign(ASource: TPersistent); -begin - if ASource <> Self then - begin - BeginUpdate; - try - DoAssign(ASource); - finally - EndUpdate; - end; - end; -end; - -procedure TSkPersistent.BeginUpdate; -begin - BeginUpdate(False); -end; - -procedure TSkPersistent.BeginUpdate(const AIgnoreAllChanges: Boolean); -begin - Inc(FUpdatingCount); - FIgnoringAllChanges := FIgnoringAllChanges or AIgnoreAllChanges; -end; - -procedure TSkPersistent.Change; -begin - if FUpdatingCount > 0 then - FChanged := True - else - begin - FChanged := False; - DoChanged; - end; -end; - -procedure TSkPersistent.DoAssign(ASource: TPersistent); -begin - inherited Assign(ASource); -end; - -procedure TSkPersistent.DoChanged; -begin - if FCreated and Assigned(FOnChange) then - FOnChange(Self); -end; - -procedure TSkPersistent.EndUpdate; -begin - EndUpdate(False); -end; - -procedure TSkPersistent.EndUpdate(const AIgnoreAllChanges: Boolean); -var - LCallChange: Boolean; - LIgnoreChanges: Boolean; -begin - LIgnoreChanges := AIgnoreAllChanges or FIgnoringAllChanges; - LCallChange := False; - if FUpdatingCount <= 0 then - raise ESkPersistentData.Create('The object is not in update state'); - Dec(FUpdatingCount); - if (not LIgnoreChanges) and HasChanged then - LCallChange := True - else - FChanged := False; - if FUpdatingCount <= 0 then - FIgnoringAllChanges := False; - if LCallChange and (FUpdatingCount = 0) then - begin - FChanged := False; - DoChanged; - end; -end; - -function TSkPersistent.GetHasChanged: Boolean; -begin - Result := FChanged; -end; - -function TSkPersistent.GetUpdating: Boolean; -begin - Result := FUpdatingCount > 0; -end; - -function TSkPersistent.SetValue(var AField: Byte; const AValue: Byte): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Word; const AValue: Word): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Double; const AValue, - AEpsilon: Double): Boolean; -begin - Result := not SameValue(AField, AValue, AEpsilon); - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: TBytes; const AValue: TBytes): Boolean; -begin - Result := not IsSameBytes(AField, AValue); - if Result then - begin - AField := Copy(AValue); - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: string; const AValue: string): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Single; const AValue, - AEpsilon: Single): Boolean; -begin - Result := not SameValue(AField, AValue, AEpsilon); - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Boolean; - const AValue: Boolean): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Cardinal; - const AValue: Cardinal): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Integer; - const AValue: Integer): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Int64; const AValue: Int64): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: T; const AValue: T): Boolean; -begin - if Assigned(TypeInfo(T)) and (PTypeInfo(TypeInfo(T)).Kind in [TTypeKind.tkSet, TTypeKind.tkEnumeration, TTypeKind.tkRecord{$IF CompilerVersion >= 33}, TTypeKind.tkMRecord{$ENDIF}]) then - Result := not CompareMem(@AField, @AValue, SizeOf(T)) - else - Result := TComparer.Default.Compare(AField, AValue) <> 0; - if Result then - begin - AField := AValue; - Change; - end; -end; - -{ TSkCustomControl } - -constructor TSkCustomControl.Create(AOwner: TComponent); -begin - inherited; - FDrawCacheKind := TSkDrawCacheKind.Raster; - HitTest := False; -end; - -destructor TSkCustomControl.Destroy; -begin - FBuffer.Free; - inherited; -end; - -procedure TSkCustomControl.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; - const AOpacity: Single); -begin - if csDesigning in ComponentState then - DrawDesignBorder(ACanvas, ADest, AOpacity); -end; - -procedure TSkCustomControl.DrawDesignBorder(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); -const - DesignBorderColor = $A0909090; -var - R: TRectF; - LPaint: ISkPaint; -begin - R := ADest; - InflateRect(R, -0.5, -0.5); - ACanvas.Save; - try - LPaint := TSkPaint.Create(TSkPaintStyle.Stroke); - LPaint.AlphaF := AOpacity; - LPaint.Color := DesignBorderColor; - LPaint.StrokeWidth := 1; - LPaint.PathEffect := TSKPathEffect.MakeDash([3, 1], 0); - ACanvas.DrawRect(R, LPaint); - finally - ACanvas.Restore; - end; -end; - -function TSkCustomControl.NeedsRedraw: Boolean; -begin - Result := (not FDrawCached) or (FDrawCacheKind = TSkDrawCacheKind.Never) or (FBuffer = nil); -end; - -procedure TSkCustomControl.Paint; -var - LAbsoluteBimapSize: TSize; - LAbsoluteScale: TPointF; - LAbsoluteSize: TSize; - LDestRect: TRectF; - LExceededRatio: Single; - LMaxBitmapSize: Integer; - LSceneScale: Single; -begin - if (FDrawCacheKind <> TSkDrawCacheKind.Always) and (Canvas is TSkCanvasCustom) then - begin - LDestRect := Canvas.AlignToPixel(LocalRect); - Draw(TSkCanvasCustom(Canvas).Canvas, LDestRect, AbsoluteOpacity); - if Assigned(FOnDraw) then - FOnDraw(Self, TSkCanvasCustom(Canvas).Canvas, LDestRect, AbsoluteOpacity); - FreeAndNil(FBuffer); - end - else - begin - if Assigned(Scene) then - LSceneScale := Scene.GetSceneScale - else - LSceneScale := 1; - LAbsoluteScale := AbsoluteScale; - LAbsoluteSize := TSize.Create(Round(Width * LAbsoluteScale.X * LSceneScale), Round(Height * LAbsoluteScale.Y * LSceneScale)); - - LMaxBitmapSize := Canvas.GetAttribute(TCanvasAttribute.MaxBitmapSize); - if (LAbsoluteSize.Width > LMaxBitmapSize) or (LAbsoluteSize.Height > LMaxBitmapSize) then - begin - LAbsoluteBimapSize := RectF(0, 0, LAbsoluteSize.Width, LAbsoluteSize.Height) - .FitInto(RectF(0, 0, LMaxBitmapSize, LMaxBitmapSize), LExceededRatio).Size.Round; - if NeedsRedraw or (TSize.Create(FBuffer.Width, FBuffer.Height) <> LAbsoluteBimapSize) then - Log.d(Format(ControlExceededBitmapLimitWarning, [ClassName, Name])); - end - else - begin - LAbsoluteBimapSize := LAbsoluteSize; - LExceededRatio := 1; - end; - - if NeedsRedraw or (TSize.Create(FBuffer.Width, FBuffer.Height) <> LAbsoluteBimapSize) then - begin - if FBuffer = nil then - FBuffer := TBitmap.Create(LAbsoluteBimapSize.Width, LAbsoluteBimapSize.Height) - else if TSize.Create(FBuffer.Width, FBuffer.Height) <> LAbsoluteBimapSize then - FBuffer.SetSize(LAbsoluteBimapSize.Width, LAbsoluteBimapSize.Height); - FBuffer.SkiaDraw( - procedure(const ACanvas: ISkCanvas) - var - LAbsoluteScale: TPointF; - LDestRect: TRectF; - begin - ACanvas.Clear(TAlphaColors.Null); - LAbsoluteScale := AbsoluteScale * LSceneScale / LExceededRatio; - ACanvas.Concat(TMatrix.CreateScaling(LAbsoluteScale.X, LAbsoluteScale.Y)); - LDestRect := RectF(0, 0, LAbsoluteBimapSize.Width / LAbsoluteScale.X, LAbsoluteBimapSize.Height / LAbsoluteScale.Y); - Draw(ACanvas, LDestRect, 1); - if Assigned(FOnDraw) then - FOnDraw(Self, ACanvas, LDestRect, 1); - end, False); - FDrawCached := True; - end; - Canvas.DrawBitmap(FBuffer, RectF(0, 0, FBuffer.Width, FBuffer.Height), Canvas.AlignToPixel(LocalRect), AbsoluteOpacity); - end; -end; - -procedure TSkCustomControl.Redraw; -begin - FDrawCached := False; - Repaint; -end; - -procedure TSkCustomControl.SetDrawCacheKind(const AValue: TSkDrawCacheKind); -begin - if FDrawCacheKind <> AValue then - begin - FDrawCacheKind := AValue; - if FDrawCacheKind <> TSkDrawCacheKind.Always then - Repaint; - end; -end; - -procedure TSkCustomControl.SetOnDraw(const AValue: TSkDrawEvent); -begin - if TMethod(FOnDraw) <> TMethod(AValue) then - begin - FOnDraw := AValue; - Redraw; - end; -end; - -{ TSkStyledControl } - -constructor TSkStyledControl.Create(AOwner: TComponent); -begin - inherited; - FDrawCacheKind := TSkDrawCacheKind.Raster; - HitTest := False; -end; - -destructor TSkStyledControl.Destroy; -begin - FBuffer.Free; - inherited; -end; - -procedure TSkStyledControl.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; - const AOpacity: Single); -begin - if csDesigning in ComponentState then - DrawDesignBorder(ACanvas, ADest, AOpacity); -end; - -procedure TSkStyledControl.DrawDesignBorder(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); -const - DesignBorderColor = $A0909090; -var - R: TRectF; - LPaint: ISkPaint; -begin - R := ADest; - InflateRect(R, -0.5, -0.5); - ACanvas.Save; - try - LPaint := TSkPaint.Create(TSkPaintStyle.Stroke); - LPaint.AlphaF := AOpacity; - LPaint.Color := DesignBorderColor; - LPaint.StrokeWidth := 1; - LPaint.PathEffect := TSkPathEffect.MakeDash([3, 1], 0); - ACanvas.DrawRect(R, LPaint); - finally - ACanvas.Restore; - end; -end; - -function TSkStyledControl.NeedsRedraw: Boolean; -begin - Result := (not FDrawCached) or (FDrawCacheKind = TSkDrawCacheKind.Never) or (FBuffer = nil); -end; - -procedure TSkStyledControl.Paint; -var - LAbsoluteBimapSize: TSize; - LAbsoluteScale: TPointF; - LAbsoluteSize: TSize; - LDestRect: TRectF; - LExceededRatio: Single; - LMaxBitmapSize: Integer; - LSceneScale: Single; -begin - if (FDrawCacheKind <> TSkDrawCacheKind.Always) and (Canvas is TSkCanvasCustom) then - begin - LDestRect := Canvas.AlignToPixel(LocalRect); - Draw(TSkCanvasCustom(Canvas).Canvas, LDestRect, AbsoluteOpacity); - if Assigned(FOnDraw) then - FOnDraw(Self, TSkCanvasCustom(Canvas).Canvas, LDestRect, AbsoluteOpacity); - FreeAndNil(FBuffer); - end - else - begin - if Assigned(Scene) then - LSceneScale := Scene.GetSceneScale - else - LSceneScale := 1; - LAbsoluteScale := AbsoluteScale; - LAbsoluteSize := TSize.Create(Ceil(Width * LAbsoluteScale.X * LSceneScale), Ceil(Height * LAbsoluteScale.Y * LSceneScale)); - - LMaxBitmapSize := Canvas.GetAttribute(TCanvasAttribute.MaxBitmapSize); - if (LAbsoluteSize.Width > LMaxBitmapSize) or (LAbsoluteSize.Height > LMaxBitmapSize) then - begin - LAbsoluteBimapSize := RectF(0, 0, LAbsoluteSize.Width, LAbsoluteSize.Height) - .FitInto(RectF(0, 0, LMaxBitmapSize, LMaxBitmapSize), LExceededRatio).Size.Round; - if NeedsRedraw or (TSize.Create(FBuffer.Width, FBuffer.Height) <> LAbsoluteBimapSize) then - Log.d(Format(ControlExceededBitmapLimitWarning, [ClassName, Name])); - end - else - begin - LAbsoluteBimapSize := LAbsoluteSize; - LExceededRatio := 1; - end; - - if NeedsRedraw or (TSize.Create(FBuffer.Width, FBuffer.Height) <> LAbsoluteBimapSize) then - begin - if FBuffer = nil then - FBuffer := TBitmap.Create(LAbsoluteBimapSize.Width, LAbsoluteBimapSize.Height) - else if TSize.Create(FBuffer.Width, FBuffer.Height) <> LAbsoluteBimapSize then - FBuffer.SetSize(LAbsoluteBimapSize.Width, LAbsoluteBimapSize.Height); - FBuffer.SkiaDraw( - procedure(const ACanvas: ISkCanvas) - var - LAbsoluteScale: TPointF; - LDestRect: TRectF; - begin - ACanvas.Clear(TAlphaColors.Null); - LAbsoluteScale := AbsoluteScale * LSceneScale / LExceededRatio; - ACanvas.Concat(TMatrix.CreateScaling(LAbsoluteScale.X, LAbsoluteScale.Y)); - LDestRect := RectF(0, 0, LAbsoluteBimapSize.Width / LAbsoluteScale.X, LAbsoluteBimapSize.Height / LAbsoluteScale.Y); - Draw(ACanvas, LDestRect, 1); - if Assigned(FOnDraw) then - FOnDraw(Self, ACanvas, LDestRect, 1); - end, False); - FDrawCached := True; - end; - Canvas.DrawBitmap(FBuffer, RectF(0, 0, FBuffer.Width, FBuffer.Height), Canvas.AlignToPixel(LocalRect), AbsoluteOpacity); - end; -end; - -procedure TSkStyledControl.Redraw; -begin - FDrawCached := False; - Repaint; -end; - -procedure TSkStyledControl.SetDrawCacheKind(const AValue: TSkDrawCacheKind); -begin - if FDrawCacheKind <> AValue then - begin - FDrawCacheKind := AValue; - if AValue <> TSkDrawCacheKind.Always then - Repaint; - end; -end; - -procedure TSkStyledControl.SetOnDraw(const AValue: TSkDrawEvent); -begin - if TMethod(FOnDraw) <> TMethod(AValue) then - begin - FOnDraw := AValue; - Redraw; - end; -end; - -{ TSkSvgBrush } - -procedure TSkSvgBrush.Assign(ASource: TPersistent); -var - LSourceSvgBrush: TSkSvgBrush absolute ASource; -begin - if ASource is TSkSvgBrush then - begin - if not Equals(LSourceSvgBrush) then - begin - DoAssign(LSourceSvgBrush); - DoChanged; - end; - end - else - inherited; -end; - -constructor TSkSvgBrush.Create; -begin - inherited Create; - FGrayScale := DefaultGrayScale; - FWrapMode := DefaultWrapMode; -end; - -procedure TSkSvgBrush.DoAssign(ASource: TSkSvgBrush); -begin - FDOM := ASource.FDOM; - FGrayScale := ASource.FGrayScale; - FOriginalSize := ASource.FOriginalSize; - FOverrideColor := ASource.FOverrideColor; - FSource := ASource.FSource; - FWrapMode := ASource.FWrapMode; -end; - -procedure TSkSvgBrush.DoChanged; -begin - if Assigned(FOnChanged) then - FOnChanged(Self); -end; - -function TSkSvgBrush.Equals(AObject: TObject): Boolean; -var - LObjectSvgBrush: TSkSvgBrush absolute AObject; -begin - Result := (AObject is TSkSvgBrush) and - (FGrayScale = LObjectSvgBrush.FGrayScale) and - (FOverrideColor = LObjectSvgBrush.FOverrideColor) and - (FWrapMode = LObjectSvgBrush.FWrapMode) and - (FSource = LObjectSvgBrush.FSource); -end; - -function TSkSvgBrush.GetDOM: ISkSVGDOM; -var - LSvgRect: TRectF; -begin - if (FDOM = nil) and HasContent then - begin - FDOM := MakeDOM; - if Assigned(FDOM) then - begin - LSvgRect.TopLeft := PointF(0, 0); - LSvgRect.Size := FDOM.Root.GetIntrinsicSize(TSizeF.Create(0, 0)); - if (not LSvgRect.IsEmpty) or (FDOM.Root.TryGetViewBox(LSvgRect) and not LSvgRect.IsEmpty) then - FOriginalSize := LSvgRect.Size; - end; - end; - Result := FDOM; -end; - -function TSkSvgBrush.GetOriginalSize: TSizeF; -begin - if (FDOM = nil) and HasContent then - GetDOM; - Result := FOriginalSize; -end; - -function TSkSvgBrush.HasContent: Boolean; -begin - Result := FSource <> ''; -end; - -function TSkSvgBrush.IsGrayScaleStored: Boolean; -begin - Result := FGrayScale <> DefaultGrayScale; -end; - -function TSkSvgBrush.IsOverrideColorStored: Boolean; -begin - Result := FOverrideColor <> Default(TAlphaColor); -end; - -function TSkSvgBrush.IsWrapModeStored: Boolean; -begin - Result := FWrapMode <> DefaultWrapMode; -end; - -function TSkSvgBrush.MakeDOM: ISkSVGDOM; -begin - Result := TSkSVGDOM.Make(FSource, TSkDefaultProviders.Resource); -end; - -procedure TSkSvgBrush.RecreateDOM; -begin - FDOM := nil; - FOriginalSize := TSizeF.Create(0, 0); -end; - -procedure TSkSvgBrush.Render(const ACanvas: ISkCanvas; const ADestRect: TRectF; - const AOpacity: Single); - - function GetWrappedDest(const ADOM: ISkSVGDOM; const ASvgRect, ADestRect: TRectF; const AIntrinsicSize: TSizeF): TRectF; - var - LRatio: Single; - begin - case FWrapMode of - TSkSvgWrapMode.Default: - begin - if AIntrinsicSize.IsZero then - Result := ADestRect - else - begin - Result := ASvgRect; - Result.Offset(ADestRect.TopLeft); - end; - ADOM.SetContainerSize(ADestRect.Size); - end; - TSkSvgWrapMode.Fit: Result := ASvgRect.FitInto(ADestRect); - TSkSvgWrapMode.FitCrop: - begin - if (ASvgRect.Width / ADestRect.Width) < (ASvgRect.Height / ADestRect.Height) then - LRatio := ASvgRect.Width / ADestRect.Width - else - LRatio := ASvgRect.Height / ADestRect.Height; - if SameValue(LRatio, 0, TEpsilon.Vector) then - Result := ADestRect - else - begin - Result := RectF(0, 0, Round(ASvgRect.Width / LRatio), Round(ASvgRect.Height / LRatio)); - RectCenter(Result, ADestRect); - end; - end; - TSkSvgWrapMode.Original, - TSkSvgWrapMode.Tile: Result := ASvgRect; - TSkSvgWrapMode.OriginalCenter: - begin - Result := ASvgRect; - RectCenter(Result, ADestRect); - end; - TSkSvgWrapMode.Place: Result := PlaceIntoTopLeft(ASvgRect, ADestRect); - TSkSvgWrapMode.Stretch: Result := ADestRect; - else - Result := ADestRect; - end; - end; - - procedure DrawTileOrCustomColor(const ACanvas: ISkCanvas; const ADOM: ISkSVGDOM; - const ASvgRect, ADestRect, AWrappedDest: TRectF; const AIntrinsicSize: TSizeF; - const AWrapMode: TSkSvgWrapMode); - var - LPicture: ISkPicture; - LPictureRecorder: ISkPictureRecorder; - LCanvas: ISkCanvas; - LPaint: ISkPaint; - begin - LPictureRecorder := TSkPictureRecorder.Create; - LCanvas := LPictureRecorder.BeginRecording(AWrappedDest.Width, AWrappedDest.Height); - if AIntrinsicSize.IsZero then - begin - if AWrapMode <> TSkSvgWrapMode.Default then - begin - ADOM.Root.Width := TSkSVGLength.Create(AWrappedDest.Width, TSkSVGLengthUnit.Pixel); - ADOM.Root.Height := TSkSVGLength.Create(AWrappedDest.Height, TSkSVGLengthUnit.Pixel); - end; - end - else - LCanvas.Scale(AWrappedDest.Width / ASvgRect.Width, AWrappedDest.Height / ASvgRect.Height); - ADOM.Render(LCanvas); - LPicture := LPictureRecorder.FinishRecording; - LPaint := TSkPaint.Create; - if FGrayScale then - LPaint.ColorFilter := TSkColorFilter.MakeMatrix(TSkColorMatrix.CreateSaturation(0)) - else if FOverrideColor <> TAlphaColors.Null then - LPaint.ColorFilter := TSkColorFilter.MakeBlend(FOverrideColor, TSkBlendMode.SrcIn); - if FWrapMode = TSkSvgWrapMode.Tile then - begin - LPaint.Shader := LPicture.MakeShader(TSkTileMode.Repeat, TSkTileMode.Repeat); - ACanvas.DrawRect(ADestRect, LPaint); - end - else - begin - ACanvas.Translate(AWrappedDest.Left, AWrappedDest.Top); - ACanvas.DrawPicture(LPicture, LPaint); - end; - end; - -var - LDOM: ISkSVGDOM; - LSvgRect: TRectF; - LWrappedDest: TRectF; - LIntrinsicSize: TSizeF; -begin - if not ADestRect.IsEmpty then - begin - LDOM := DOM; - if Assigned(LDOM) then - begin - LSvgRect.TopLeft := PointF(0, 0); - LIntrinsicSize := LDOM.Root.GetIntrinsicSize(TSizeF.Create(0, 0)); - LSvgRect.Size := LIntrinsicSize; - if LSvgRect.IsEmpty and ((not LDOM.Root.TryGetViewBox(LSvgRect)) or LSvgRect.IsEmpty) then - Exit; - - if SameValue(AOpacity, 1, TEpsilon.Position) then - ACanvas.Save - else - ACanvas.SaveLayerAlpha(Round(AOpacity * 255)); - try - LWrappedDest := GetWrappedDest(LDOM, LSvgRect, ADestRect, LIntrinsicSize); - if (FOverrideColor <> TAlphaColors.Null) or (FWrapMode = TSkSvgWrapMode.Tile) or FGrayScale then - DrawTileOrCustomColor(ACanvas, LDOM, LSvgRect, ADestRect, LWrappedDest, LIntrinsicSize, FWrapMode) - else - begin - ACanvas.Translate(LWrappedDest.Left, LWrappedDest.Top); - if LIntrinsicSize.IsZero then - begin - if FWrapMode <> TSkSvgWrapMode.Default then - begin - LDOM.Root.Width := TSkSVGLength.Create(LWrappedDest.Width, TSkSVGLengthUnit.Pixel); - LDOM.Root.Height := TSkSVGLength.Create(LWrappedDest.Height, TSkSVGLengthUnit.Pixel); - end; - end - else - ACanvas.Scale(LWrappedDest.Width / LSvgRect.Width, LWrappedDest.Height / LSvgRect.Height); - LDOM.Render(ACanvas); - end; - finally - ACanvas.Restore; - end; - end; - end; -end; - -procedure TSkSvgBrush.SetGrayScale(const AValue: Boolean); -begin - if FGrayScale <> AValue then - begin - FGrayScale := AValue; - if HasContent then - DoChanged; - end; -end; - -procedure TSkSvgBrush.SetOverrideColor(const AValue: TAlphaColor); -begin - if FOverrideColor <> AValue then - begin - FOverrideColor := AValue; - if HasContent then - DoChanged; - end; -end; - -procedure TSkSvgBrush.SetSource(const AValue: TSkSvgSource); -begin - if FSource <> AValue then - begin - FSource := AValue; - RecreateDOM; - DoChanged; - end; -end; - -procedure TSkSvgBrush.SetWrapMode(const AValue: TSkSvgWrapMode); -begin - if FWrapMode <> AValue then - begin - FWrapMode := AValue; - RecreateDOM; - if HasContent then - DoChanged; - end; -end; - -{ TSkSvg } - -constructor TSkSvg.Create(AOwner: TComponent); -begin - inherited; - FSvg := CreateSvgBrush; - FSvg.OnChanged := SvgChanged; - DrawCacheKind := TSkDrawCacheKind.Always; -end; - -function TSkSvg.CreateSvgBrush: TSkSvgBrush; -begin - Result := TSkSvgBrush.Create; -end; - -destructor TSkSvg.Destroy; -begin - FSvg.Free; - inherited; -end; - -procedure TSkSvg.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); -begin - inherited; - FSvg.Render(ACanvas, ADest, AOpacity); -end; - -procedure TSkSvg.SetSvg(const AValue: TSkSvgBrush); -begin - FSvg.Assign(AValue); -end; - -procedure TSkSvg.SvgChanged(ASender: TObject); -begin - Redraw; -end; - -{ TBasicAnimation } - -type - TBasicAnimation = class(TAnimation) - protected - procedure ProcessAnimation; override; - end; - -procedure TBasicAnimation.ProcessAnimation; -begin -end; - -{ TSkCustomAnimation.TProcess } - -class procedure TSkCustomAnimation.TProcess.Add(const AAnimation: TSkCustomAnimation); -begin - if FProcess = nil then - FProcess := TProcess.Create; - FProcess.DoAdd(AAnimation); -end; - -constructor TSkCustomAnimation.TProcess.Create; -begin - inherited Create; - if not TPlatformServices.Current.SupportsPlatformService(IFMXTimerService, FTimerService) then - raise EUnsupportedPlatformService.Create('IFMXTimerService'); - FAniList := TList.Create; - FAniProcessingList := TList.Create; - FAnimation := TBasicAnimation.Create(nil); - TBasicAnimation(FAnimation).Loop := True; - TBasicAnimation(FAnimation).Duration := 30; - TBasicAnimation(FAnimation).OnProcess := OnProcess; - FMainFormChangedMessageId := TMessageManager.DefaultManager.SubscribeToMessage(TMainFormChangedMessage, MainFormChangeHandler); -end; - -destructor TSkCustomAnimation.TProcess.Destroy; -begin - TMessageManager.DefaultManager.Unsubscribe(TMainFormChangedMessage, FMainFormChangedMessageId); - FreeAndNil(FAniList); - FAniProcessingList.Free; - FAnimation.Free; - inherited; -end; - -class destructor TSkCustomAnimation.TProcess.Destroy; -begin - FProcess.Free; - inherited; -end; - -procedure TSkCustomAnimation.TProcess.DoAdd(const AAnimation: TSkCustomAnimation); -begin - if FAniList.IndexOf(AAnimation) < 0 then - FAniList.Add(AAnimation); - if not TBasicAnimation(FAnimation).Enabled and (FAniList.Count > 0) then - begin - FTime := FTimerService.GetTick; - if Assigned(Application.MainForm) then - begin - FAnimation.SetRoot(Application.MainForm); - FAniRoot := nil; - end - else if Assigned(AAnimation.Root) then - begin - FAnimation.SetRoot(AAnimation.Root); - FAniRoot := AAnimation; - end; - end; - TBasicAnimation(FAnimation).Enabled := Assigned(FAnimation.Root) and (FAniList.Count > 0); -end; - -procedure TSkCustomAnimation.TProcess.DoRemove(const AAnimation: TSkCustomAnimation); -begin - if FAniList <> nil then - begin - FAniList.Remove(AAnimation); - FAniProcessingList.Remove(AAnimation); - if FAniRoot = AAnimation then - begin - FAnimation.SetRoot(nil); - FAniRoot := nil; - TryFindRoot; - end; - TBasicAnimation(FAnimation).Enabled := Assigned(FAnimation.Root) and (FAniList.Count > 0); - end; -end; - -procedure TSkCustomAnimation.TProcess.DoRootChanged(const AAnimation: TSkCustomAnimation); -begin - if FAniRoot = AAnimation then - begin - FAnimation.SetRoot(nil); - FAniRoot := nil; - TryFindRoot; - end - else if not Assigned(FAnimation.Root) and Assigned(AAnimation.Root) then - begin - FAnimation.SetRoot(AAnimation.Root); - FAniRoot := AAnimation; - end; - TBasicAnimation(FAnimation).Enabled := Assigned(FAnimation.Root) and (FAniList.Count > 0); -end; - -procedure TSkCustomAnimation.TProcess.MainFormChangeHandler( - const ASender: TObject; const AMessage: TMessage); -begin - FAnimation.SetRoot(nil); - TryFindRoot; -end; - -procedure TSkCustomAnimation.TProcess.OnProcess(ASender: TObject); -var - I: Integer; - LNewTime: Double; - LDeltaTime: Double; - [unsafe] LAnimation: TSkCustomAnimation; -begin - LNewTime := FTimerService.GetTick; - LDeltaTime := LNewTime - FTime; - if LDeltaTime < TimeEpsilon then - Exit; - FTime := LNewTime; - if FAniList.Count > 0 then - begin - FAniProcessingList.AddRange(FAniList); - I := FAniProcessingList.Count - 1; - while I >= 0 do - begin - if I < FAniProcessingList.Count then - begin - LAnimation := FAniProcessingList[I]; - FAniProcessingList.Delete(I); - if LAnimation.Running then - LAnimation.ProcessTick(LDeltaTime); - Dec(I); - end - else - I := FAniProcessingList.Count - 1; - end; - end; -end; - -class procedure TSkCustomAnimation.TProcess.Remove( - const AAnimation: TSkCustomAnimation); -begin - if FProcess <> nil then - FProcess.DoRemove(AAnimation); -end; - -class procedure TSkCustomAnimation.TProcess.RootChanged( - const AAnimation: TSkCustomAnimation); -begin - if FProcess <> nil then - FProcess.DoRootChanged(AAnimation); -end; - -procedure TSkCustomAnimation.TProcess.TryFindRoot; -var - I: Integer; -begin - if Assigned(Application.MainForm) then - begin - FAnimation.SetRoot(Application.MainForm); - FAniRoot := nil; - end - else - begin - for I := 0 to FAniList.Count - 1 do - begin - if Assigned(TSkCustomAnimation(FAniList[I]).Root) then - begin - FAniRoot := TSkCustomAnimation(FAniList[I]); - FAnimation.SetRoot(FAniRoot.Root); - Break; - end; - end; - end; -end; - -{ TSkCustomAnimation } - -procedure TSkCustomAnimation.BeforePaint; -begin - if FNeedStart then - begin - if FAllowAnimation then - InternalStart(False) - else - FNeedStartRepaint := True; - end; -end; - -function TSkCustomAnimation.CanProcessing: Boolean; -begin - Result := FRunning and (not FPause) and (FSpeed >= SpeedEpsilon) and (FProcessDuration >= TimeEpsilon) and (FAllowAnimation or not FLoop); -end; - -constructor TSkCustomAnimation.Create(const AOwner: TComponent); -begin - inherited Create; - FOwner := AOwner; - Assign(nil); -end; - -destructor TSkCustomAnimation.Destroy; -begin - SetProcessing(False); - inherited; -end; - -procedure TSkCustomAnimation.DoAssign(ASource: TPersistent); -var - LSourceAnimation: TSkCustomAnimation absolute ASource; -begin - if ASource = nil then - begin - AutoReverse := DefaultAutoReverse; - Delay := DefaultDelay; - Enabled := DefaultEnabled; - Inverse := DefaultInverse; - Loop := DefaultLoop; - Pause := DefaultPause; - Speed := DefaultSpeed; - StartFromCurrent := DefaultStartFromCurrent; - StartProgress := DefaultStartProgress; - StopProgress := DefaultStopProgress; - DoSetCurrentTime(0); - SetRunning(False); - end - else if ASource is TSkCustomAnimation then - begin - AutoReverse := LSourceAnimation.AutoReverse; - Delay := LSourceAnimation.Delay; - Enabled := LSourceAnimation.Enabled; - Inverse := LSourceAnimation.Inverse; - Loop := LSourceAnimation.Loop; - Pause := LSourceAnimation.Pause; - Speed := LSourceAnimation.Speed; - StartFromCurrent := LSourceAnimation.StartFromCurrent; - StartProgress := LSourceAnimation.StartProgress; - StopProgress := LSourceAnimation.StopProgress; - DoSetCurrentTime(LSourceAnimation.CurrentTime); - SetRunning(LSourceAnimation.Running); - end - else - inherited; -end; - -procedure TSkCustomAnimation.DoChanged; -var - LCanProcess: Boolean; -begin - UpdateCurrentTime(FRunning, True); - LCanProcess := FAllowAnimation; - - if FEnabledChanged then - begin - FEnabledChanged := False; - if not FEnabled then - Stop - else if (not Assigned(FOwner)) or (not (csDesigning in FOwner.ComponentState)) then - begin - FNeedStart := True; - FNeedStartRepaint := False; - end; - end; - if FNeedStart and FNeedStartRepaint and FAllowAnimation then - begin - Start; - LCanProcess := False; - end; - SetProcessing(CanProcessing); - inherited; - if LCanProcess then - DoProcess; -end; - -function TSkCustomAnimation.DoSetCurrentTime(const AValue: Double): Boolean; -begin - Result := SetValue(FDelayTime, 0, TimeEpsilon); - Result := SetValue(FCurrentTime, EnsureRange(AValue, 0, FDuration), TimeEpsilon) or Result; -end; - -function TSkCustomAnimation.Equals(AObject: TObject): Boolean; -var - LSourceAnimation: TSkCustomAnimation absolute AObject; -begin - Result := (AObject is TSkCustomAnimation) and - (FAutoReverse = LSourceAnimation.AutoReverse) and - (FEnabled = LSourceAnimation.Enabled) and - (FInverse = LSourceAnimation.Inverse) and - (FLoop = LSourceAnimation.Loop) and - (FPause = LSourceAnimation.Pause) and - (FStartFromCurrent = LSourceAnimation.StartFromCurrent) and - (FRunning = LSourceAnimation.Running) and - SameValue(FCurrentTime, LSourceAnimation.CurrentTime, TimeEpsilon) and - SameValue(FDelay, LSourceAnimation.Delay, TimeEpsilon) and - SameValue(FSpeed, LSourceAnimation.Speed, SpeedEpsilon) and - SameValue(FStartProgress, LSourceAnimation.StartProgress, ProgressEpsilon) and - SameValue(FStopProgress, LSourceAnimation.StopProgress, ProgressEpsilon); -end; - -function TSkCustomAnimation.GetDuration: Double; -begin - Result := FDuration; -end; - -function TSkCustomAnimation.GetRoot: IRoot; -begin - if FOwner is TFmxObject then - Result := TFmxObject(FOwner).Root - else - Result := nil; -end; - -procedure TSkCustomAnimation.InternalStart(const ACanProcess: Boolean); -begin - FNeedStart := False; - if not FLoop then - FTickCount := 0; - if FAutoReverse then - begin - if FRunning then - FInverse := FSavedInverse - else - FSavedInverse := FInverse; - end; - if FProcessDuration < TimeEpsilon then - begin - SetStartValues(0, True); - FRunning := True; - DoStart; - if ACanProcess and FAllowAnimation then - DoProcess; - FRunning := False; - FProcessTime := 0; - DoFinish; - end - else - begin - SetStartValues(FDelay, False); - FRunning := True; - FEnabled := True; - SetProcessing(CanProcessing); - - if FDelay < TimeEpsilon then - begin - DoStart; - if ACanProcess and FAllowAnimation then - DoProcess; - end - else - DoStart; - end; -end; - -function TSkCustomAnimation.IsDelayStored: Boolean; -begin - Result := not SameValue(FDelay, DefaultDelay, TimeEpsilon); -end; - -function TSkCustomAnimation.IsProgressStored: Boolean; -begin - Result := not SameValue(FProgress, DefaultStartProgress, ProgressEpsilon); -end; - -function TSkCustomAnimation.IsSpeedStored: Boolean; -begin - Result := not SameValue(FSpeed, DefaultSpeed, SpeedEpsilon); -end; - -function TSkCustomAnimation.IsStartProgressStored: Boolean; -begin - Result := not SameValue(FStartProgress, DefaultStartProgress, ProgressEpsilon); -end; - -function TSkCustomAnimation.IsStopProgressStored: Boolean; -begin - Result := not SameValue(FStopProgress, DefaultStopProgress, ProgressEpsilon); -end; - -procedure TSkCustomAnimation.ProcessTick(ADeltaTime: Double); -begin - if Assigned(FOwner) and (csDestroying in FOwner.ComponentState) then - Exit; - SetProcessing(CanProcessing); - if (not FRunning) or FPause or (FSpeed < SpeedEpsilon) or (not FProcessing) then - Exit; - - if FDelayTime >= TimeEpsilon then - begin - FDelayTime := FDelayTime - ADeltaTime; - if FDelayTime < TimeEpsilon then - begin - ADeltaTime := Max(-FDelayTime, 0); - SetStartValues(0, False); - if ADeltaTime < TimeEpsilon then - Exit; - end - else - Exit; - end; - - if FInverse then - FProcessTime := FProcessTime - ADeltaTime * FSpeed - else - FProcessTime := FProcessTime + ADeltaTime * FSpeed; - if FProcessTime >= FProcessDuration then - begin - FProcessTime := FProcessDuration; - if FLoop then - begin - if FAutoReverse then - begin - FInverse := True; - FProcessTime := FProcessDuration; - end - else - FProcessTime := 0; - end - else - if FAutoReverse and (FTickCount = 0) then - begin - Inc(FTickCount); - FInverse := True; - FProcessTime := FProcessDuration; - end - else - FRunning := False; - end - else if FProcessTime <= 0 then - begin - FProcessTime := 0; - if FLoop then - begin - if FAutoReverse then - begin - FInverse := False; - FProcessTime := 0; - end - else - FProcessTime := FProcessDuration; - end - else - if FAutoReverse and (FTickCount = 0) then - begin - Inc(FTickCount); - FInverse := False; - FProcessTime := 0; - end - else - FRunning := False; - end; - UpdateCurrentTime(True, Updating); - - if not FRunning then - begin - if FAutoReverse then - FInverse := FSavedInverse; - FEnabled := False; - SetProcessing(False); - end; - - if FAllowAnimation then - DoProcess; - if not FRunning then - DoFinish; -end; - -procedure TSkCustomAnimation.RootChanged; -begin - if FProcessing then - TProcess.RootChanged(Self); -end; - -procedure TSkCustomAnimation.SetAllowAnimation(const AValue: Boolean); -begin - SetValue(FAllowAnimation, AValue); -end; - -procedure TSkCustomAnimation.SetCurrentTime(const AValue: Double); -begin - BeginUpdate; - try - FCurrentTimeChanged := DoSetCurrentTime(RoundTo(AValue, TimeRoundTo)) or FCurrentTimeChanged; - finally - EndUpdate; - end; -end; - -procedure TSkCustomAnimation.SetDelay(const AValue: Double); -begin - FDelay := Max(0, RoundTo(AValue, TimeRoundTo)); - FDelayTime := Min(FDelayTime, FDelay); -end; - -procedure TSkCustomAnimation.SetDuration(const AValue: Double); -begin - SetValue(FDuration, Max(RoundTo(AValue, TimeRoundTo), 0), TimeEpsilon); -end; - -procedure TSkCustomAnimation.SetEnabled(const AValue: Boolean); -begin - BeginUpdate; - try - FEnabledChanged := SetValue(FEnabled, AValue) or FEnabledChanged; - finally - EndUpdate; - end; -end; - -procedure TSkCustomAnimation.SetLoop(const AValue: Boolean); -begin - SetValue(FLoop, AValue); -end; - -procedure TSkCustomAnimation.SetPause(const AValue: Boolean); -begin - SetValue(FPause, AValue); -end; - -procedure TSkCustomAnimation.SetProcessing(const AValue: Boolean); -begin - if FProcessing <> AValue then - begin - FProcessing := AValue; - if FProcessing then - TProcess.Add(Self) - else - TProcess.Remove(Self); - end; -end; - -procedure TSkCustomAnimation.SetProgress(const AValue: Double); -begin - FSavedProgress := AValue; - CurrentTime := FDuration * EnsureRange(AValue, 0, 1); -end; - -procedure TSkCustomAnimation.SetRunning(const AValue: Boolean); -begin - SetValue(FRunning, AValue); -end; - -procedure TSkCustomAnimation.SetSpeed(const AValue: Double); -begin - SetValue(FSpeed, Max(RoundTo(AValue, SpeedRoundTo), 0), SpeedEpsilon); -end; - -procedure TSkCustomAnimation.SetStartProgress(const AValue: Double); -begin - SetValue(FStartProgress, EnsureRange(AValue, 0, 1), ProgressEpsilon); -end; - -procedure TSkCustomAnimation.SetStartValues(const ADelayTime: Double; const AStartAtEnd: Boolean); -begin - FDelayTime := ADelayTime; - if FStartFromCurrent and not AStartAtEnd then - FProcessTime := EnsureRange(FCurrentTime - Min(FStartProgress, FStopProgress) * FDuration, 0, FProcessDuration) - else - FProcessTime := IfThen(FInverse = AStartAtEnd, 0, FProcessDuration); - UpdateCurrentTime(True, Updating); -end; - -procedure TSkCustomAnimation.SetStopProgress(const AValue: Double); -begin - SetValue(FStopProgress, EnsureRange(AValue, 0, 1), ProgressEpsilon); -end; - -procedure TSkCustomAnimation.Start; -begin - InternalStart(True); -end; - -procedure TSkCustomAnimation.Stop; -begin - FNeedStart := False; - if not FRunning then - Exit; - if FAutoReverse then - FInverse := FSavedInverse; - if FInverse then - begin - FCurrentTime := 0; - FProgress := 0; - end - else - begin - FCurrentTime := FProcessDuration; - FProgress := 1; - end; - if FAllowAnimation then - DoProcess; - FRunning := False; - FEnabled := False; - SetProcessing(False); - DoFinish; -end; - -procedure TSkCustomAnimation.StopAtCurrent; -begin - FNeedStart := False; - if not FRunning then - Exit; - if FAutoReverse then - FInverse := FSavedInverse; - FRunning := False; - FEnabled := False; - SetProcessing(False); - DoFinish; -end; - -procedure TSkCustomAnimation.UpdateCurrentTime(const AIsRunning, ARecalcProcessDuration: Boolean); -begin - if ARecalcProcessDuration then - begin - FProcessDuration := Abs(FStopProgress - FStartProgress) * FDuration; - if FProcessDuration < TimeEpsilon then - FProcessDuration := 0; - end; - if FCurrentTimeChanged and AIsRunning then - FProcessTime := EnsureRange(FCurrentTime - Min(FStartProgress, FStopProgress) * FDuration, 0, FProcessDuration); - if AIsRunning then - FCurrentTime := Min(FStartProgress, FStopProgress) * FDuration + FProcessTime - else - FCurrentTime := EnsureRange(FCurrentTime, 0, FDuration); - FCurrentTimeChanged := False; - if FDuration < TimeEpsilon then - begin - if FInverse then - FProgress := FStopProgress - else - FProgress := FStartProgress; - end - else - FProgress := FCurrentTime / FDuration; -end; - -{ TSkCustomAnimatedControl.TAnimationBase } - -procedure TSkCustomAnimatedControl.TAnimationBase.DoChanged; -begin - inherited; - if Created then - TSkCustomAnimatedControl(Owner).DoAnimationChanged; -end; - -procedure TSkCustomAnimatedControl.TAnimationBase.DoFinish; -begin - TSkCustomAnimatedControl(Owner).DoAnimationFinish; -end; - -procedure TSkCustomAnimatedControl.TAnimationBase.DoProcess; -begin - if FInsideDoProcess then - Exit; - FInsideDoProcess := True; - try - TSkCustomAnimatedControl(Owner).DoAnimationProcess; - finally - FInsideDoProcess := False; - end; -end; - -procedure TSkCustomAnimatedControl.TAnimationBase.DoStart; -begin - TSkCustomAnimatedControl(Owner).DoAnimationStart; -end; - -{ TSkCustomAnimatedControl } - -procedure TSkCustomAnimatedControl.AncestorVisibleChanged(const AVisible: Boolean); -var - LLastAbsoluteVisible: Boolean; -begin - LLastAbsoluteVisible := FAbsoluteVisible; - if not AVisible then - begin - FAbsoluteVisible := False; - FAbsoluteVisibleCached := True; - end - else - FAbsoluteVisibleCached := False; - if Assigned(FAnimation) and FAnimation.Loop and FAnimation.Running and (not LLastAbsoluteVisible) and AbsoluteVisible then - FAnimation.Start; - CheckAnimation; - inherited; -end; - -function TSkCustomAnimatedControl.CanRunAnimation: Boolean; -begin - Result := Assigned(Scene) and ([csDestroying, csLoading] * ComponentState = []) and - AbsoluteVisible and - (not SameValue(AbsoluteWidth, 0, TEpsilon.Position)) and - (not SameValue(AbsoluteHeight, 0, TEpsilon.Position)) and - (Scene.GetObject is TCommonCustomForm) and TCommonCustomForm(Scene.GetObject).Visible; -end; - -procedure TSkCustomAnimatedControl.CheckAnimation; -begin - if Assigned(FAnimation) then - FAnimation.AllowAnimation := CanRunAnimation; -end; - -procedure TSkCustomAnimatedControl.CheckDuration; -begin - if Assigned(FAnimation) then - begin - if SameValue(FAnimation.Duration, 0, TAnimationBase.TimeEpsilon) then - DrawCacheKind := TSkDrawCacheKind.Raster - else - DrawCacheKind := TSkDrawCacheKind.Never; - end; -end; - -constructor TSkCustomAnimatedControl.Create(AOwner: TComponent); -begin - inherited; - FAnimation := CreateAnimation; - FAbsoluteVisible := Visible; - FAbsoluteVisibleCached := True; - CheckDuration; -end; - -destructor TSkCustomAnimatedControl.Destroy; -begin - FreeAndNil(FAnimation); - inherited; -end; - -procedure TSkCustomAnimatedControl.DoAnimationChanged; -begin - CheckDuration; - if csDesigning in ComponentState then - Repaint; -end; - -procedure TSkCustomAnimatedControl.DoAnimationFinish; -begin - Redraw; - if Assigned(FOnAnimationFinish) then - FOnAnimationFinish(Self); -end; - -procedure TSkCustomAnimatedControl.DoAnimationProcess; -begin - if not FSuccessRedraw then - CheckAnimation; - FSuccessRedraw := False; - Redraw; - if Assigned(FOnAnimationProcess) then - FOnAnimationProcess(Self); -end; - -procedure TSkCustomAnimatedControl.DoAnimationStart; -begin - if Assigned(FOnAnimationStart) then - FOnAnimationStart(Self); -end; - -procedure TSkCustomAnimatedControl.DoRootChanged; -begin - inherited; - if Assigned(FAnimation) then - FAnimation.RootChanged; -end; - -procedure TSkCustomAnimatedControl.Draw(const ACanvas: ISkCanvas; - const ADest: TRectF; const AOpacity: Single); -begin - inherited; - if not FAnimation.AllowAnimation then - CheckAnimation; - FAnimation.BeforePaint; - RenderFrame(ACanvas, ADest, FAnimation.Progress, AOpacity); - FSuccessRedraw := True; -end; - -function TSkCustomAnimatedControl.GetAbsoluteVisible: Boolean; -begin - if not FAbsoluteVisibleCached then - begin - FAbsoluteVisible := GetParentedVisible; - FAbsoluteVisibleCached := True; - end; - Result := FAbsoluteVisible; -end; - -procedure TSkCustomAnimatedControl.ReadState(AReader: TReader); -begin - FAnimation.BeginUpdate; - try - FAnimation.SavedProgress := FAnimation.Progress; - inherited; - FAnimation.Progress := FAnimation.SavedProgress; - finally - FAnimation.EndUpdate; - end; -end; - -procedure TSkCustomAnimatedControl.RenderFrame(const ACanvas: ISkCanvas; - const ADest: TRectF; const AProgress: Double; const AOpacity: Single); -begin - if Assigned(FOnAnimationDraw) then - FOnAnimationDraw(Self, ACanvas, ADest, AProgress, AOpacity); -end; - -procedure TSkCustomAnimatedControl.SetNewScene(AScene: IScene); -var - LCanCheck: Boolean; -begin - LCanCheck := Scene = nil; - inherited; - if LCanCheck then - CheckAnimation; -end; - -procedure TSkCustomAnimatedControl.SetOnAnimationDraw( - const AValue: TSkAnimationDrawEvent); -begin - if TMethod(FOnAnimationDraw) <> TMethod(AValue) then - begin - FOnAnimationDraw := AValue; - Redraw; - end; -end; - -{ TSkAnimatedPaintBox.TAnimation } - -constructor TSkAnimatedPaintBox.TAnimation.Create(const AOwner: TFmxObject); -begin - inherited Create(AOwner); - Duration := DefaultDuration; -end; - -procedure TSkAnimatedPaintBox.TAnimation.DoAssign(ASource: TPersistent); -var - LSourceAnimation: TSkCustomAnimation absolute ASource; -begin - if ASource = nil then - Duration := DefaultDuration - else if ASource is TSkCustomAnimation then - Duration := LSourceAnimation.Duration; - inherited; -end; - -function TSkAnimatedPaintBox.TAnimation.Equals(AObject: TObject): Boolean; -var - LSourceAnimation: TSkCustomAnimation absolute AObject; -begin - Result := inherited and SameValue(Duration, LSourceAnimation.Duration, TimeEpsilon); -end; - -function TSkAnimatedPaintBox.TAnimation.IsDurationStored: Boolean; -begin - Result := not SameValue(Duration, DefaultDuration, TimeEpsilon); -end; - -{ TSkAnimatedPaintBox } - -function TSkAnimatedPaintBox.CreateAnimation: TSkCustomAnimatedControl.TAnimationBase; -begin - Result := TAnimation.Create(Self); -end; - -procedure TSkAnimatedPaintBox.DefineProperties(AFiler: TFiler); -begin - inherited; - // Backward compatibility with version 3 - AFiler.DefineProperty('Animate', ReadAnimate, nil, False); - AFiler.DefineProperty('Duration', ReadDuration, nil, False); - AFiler.DefineProperty('Loop', ReadLoop, nil, False); -end; - -function TSkAnimatedPaintBox.GetAnimation: TSkAnimatedPaintBox.TAnimation; -begin - Result := TSkAnimatedPaintBox.TAnimation(FAnimation); -end; - -procedure TSkAnimatedPaintBox.ReadAnimate(AReader: TReader); -begin - Animation.Enabled := AReader.ReadBoolean; -end; - -procedure TSkAnimatedPaintBox.ReadDuration(AReader: TReader); -begin - Animation.Duration := AReader.ReadFloat; -end; - -procedure TSkAnimatedPaintBox.ReadLoop(AReader: TReader); -begin - Animation.Loop := AReader.ReadBoolean; -end; - -procedure TSkAnimatedPaintBox.SetAnimation(const AValue: TSkAnimatedPaintBox.TAnimation); -begin - FAnimation.Assign(AValue); -end; - -{ TSkAnimatedPaintBoxHelper } - -function TSkAnimatedPaintBoxHelper.Animate: Boolean; -begin - Result := Animation.Enabled; -end; - -function TSkAnimatedPaintBoxHelper.Duration: Double; -begin - Result := Animation.Duration; -end; - -function TSkAnimatedPaintBoxHelper.FixedProgress: Boolean; -begin - Result := not Animation.Enabled; -end; - -function TSkAnimatedPaintBoxHelper.Loop: Boolean; -begin - Result := Animation.Loop; -end; - -function TSkAnimatedPaintBoxHelper.Progress: Double; -begin - Result := Animation.Progress; -end; - -function TSkAnimatedPaintBoxHelper.RunningAnimation: Boolean; -begin - Result := Animation.Running; -end; - -{ TSkAnimatedImage.TSource } - -procedure TSkAnimatedImage.TSource.Assign(ASource: TPersistent); -begin - if ASource is TSource then - Data := TSource(ASource).Data - else if ASource = nil then - Data := nil - else - inherited; -end; - -constructor TSkAnimatedImage.TSource.Create(const AOnChange: TChangeProc); -begin - inherited Create; - FOnChange := AOnChange; -end; - -function TSkAnimatedImage.TSource.Equals(AObject: TObject): Boolean; -begin - Result := (AObject is TSource) and IsSameBytes(FData, TSource(AObject).Data); -end; - -procedure TSkAnimatedImage.TSource.SetData(const AValue: TBytes); -begin - if not IsSameBytes(FData, AValue) then - begin - FData := Copy(AValue); - if Assigned(FOnChange) then - FOnChange(); - end; -end; - -{ TSkAnimatedImage.TFormatInfo } - -constructor TSkAnimatedImage.TFormatInfo.Create(const AName, - ADescription: string; const AExtensions: TArray); -begin - Name := AName; - Description := ADescription; - Extensions := AExtensions; -end; - -{ TSkAnimatedImage } - -constructor TSkAnimatedImage.Create(AOwner: TComponent); -begin - inherited; - FSource := TSource.Create(SourceChange); -end; - -function TSkAnimatedImage.CreateAnimation: TSkCustomAnimatedControl.TAnimationBase; -begin - Result := TAnimation.Create(Self); -end; - -procedure TSkAnimatedImage.DefineProperties(AFiler: TFiler); - - function DoWrite: Boolean; - begin - if AFiler.Ancestor <> nil then - Result := (not (AFiler.Ancestor is TSkAnimatedImage)) or not TSkAnimatedImage(AFiler.Ancestor).Source.Equals(FSource) - else - Result := FSource.Data <> nil; - end; - -begin - inherited; - AFiler.DefineBinaryProperty('Data', ReadData, WriteData, DoWrite); - // Backward compatibility with version 3 - AFiler.DefineProperty('Loop', ReadLoop, nil, False); - AFiler.DefineProperty('OnAnimationFinished', ReadOnAnimationFinished, nil, False); - AFiler.DefineProperty('OnAnimationProgress', ReadOnAnimationProgress, nil, False); -end; - -destructor TSkAnimatedImage.Destroy; -begin - FCodec.Free; - FSource.Free; - inherited; -end; - -procedure TSkAnimatedImage.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; - const AOpacity: Single); -begin - if Assigned(FCodec) then - inherited - else if csDesigning in ComponentState then - DrawDesignBorder(ACanvas, ADest, AOpacity); -end; - -function TSkAnimatedImage.GetAnimation: TSkAnimatedImage.TAnimation; -begin - Result := TSkAnimatedImage.TAnimation(FAnimation); -end; - -function TSkAnimatedImage.GetOriginalSize: TSizeF; -begin - if Assigned(FCodec) then - Result := FCodec.Size - else - Result := TSizeF.Create(0, 0); -end; - -procedure TSkAnimatedImage.LoadFromFile(const AFileName: string); -begin - FSource.Data := TFile.ReadAllBytes(AFileName); -end; - -procedure TSkAnimatedImage.LoadFromStream(const AStream: TStream); -var - LBytes: TBytes; -begin - SetLength(LBytes, AStream.Size - AStream.Position); - if Length(LBytes) > 0 then - AStream.ReadBuffer(LBytes, 0, Length(LBytes)); - FSource.Data := LBytes; -end; - -procedure TSkAnimatedImage.ReadData(AStream: TStream); -begin - if AStream.Size = 0 then - FSource.Data := nil - else - LoadFromStream(AStream); -end; - -procedure TSkAnimatedImage.ReadLoop(AReader: TReader); -begin - Animation.Loop := AReader.ReadBoolean; -end; - -type - TReaderAccess = class(TReader) end; - -procedure TSkAnimatedImage.ReadOnAnimationFinished(AReader: TReader); -var - LMethod: TMethod; -begin - LMethod := TReaderAccess(AReader).FindMethodInstance(AReader.Root, AReader.ReadIdent); - if LMethod.Code <> nil then - OnAnimationFinish := TNotifyEvent(LMethod); -end; - -procedure TSkAnimatedImage.ReadOnAnimationProgress(AReader: TReader); -var - LMethod: TMethod; -begin - LMethod := TReaderAccess(AReader).FindMethodInstance(AReader.Root, AReader.ReadIdent); - if LMethod.Code <> nil then - OnAnimationProcess := TNotifyEvent(LMethod); -end; - -class procedure TSkAnimatedImage.RegisterCodec( - const ACodecClass: TAnimationCodecClass); -begin - FRegisteredCodecs := FRegisteredCodecs + [ACodecClass]; -end; - -procedure TSkAnimatedImage.RenderFrame(const ACanvas: ISkCanvas; - const ADest: TRectF; const AProgress: Double; const AOpacity: Single); - - function GetWrappedRect(const ADest: TRectF): TRectF; - var - LImageRect: TRectF; - LRatio: Single; - begin - LImageRect := TRectF.Create(PointF(0, 0), FCodec.Size); - case FWrapMode of - TSkAnimatedImageWrapMode.Fit: Result := LImageRect.FitInto(ADest); - TSkAnimatedImageWrapMode.FitCrop: - begin - if (LImageRect.Width / ADest.Width) < (LImageRect.Height / ADest.Height) then - LRatio := LImageRect.Width / ADest.Width - else - LRatio := LImageRect.Height / ADest.Height; - if SameValue(LRatio, 0, TEpsilon.Vector) then - Result := ADest - else - begin - Result := RectF(0, 0, Round(LImageRect.Width / LRatio), Round(LImageRect.Height / LRatio)); - RectCenter(Result, ADest); - end; - end; - TSkAnimatedImageWrapMode.Original: - begin - Result := LImageRect; - Result.Offset(ADest.TopLeft); - end; - TSkAnimatedImageWrapMode.OriginalCenter: - begin - Result := LImageRect; - RectCenter(Result, ADest); - end; - TSkAnimatedImageWrapMode.Place: Result := PlaceIntoTopLeft(LImageRect, ADest); - TSkAnimatedImageWrapMode.Stretch: Result := ADest; - end; - end; - -begin - if Assigned(FCodec) then - begin - FCodec.Quality := Canvas.Quality; - if (csDesigning in ComponentState) and (not Animation.Running) and (AProgress = 0) then - FCodec.SeekFrameTime(Animation.Duration / 8) - else - FCodec.SeekFrameTime(Animation.CurrentTime); - ACanvas.Save; - try - ACanvas.ClipRect(ADest); - FCodec.Render(ACanvas, GetWrappedRect(ADest), AOpacity); - finally - ACanvas.Restore; - end; - end; - inherited; -end; - -procedure TSkAnimatedImage.SetAnimation(const AValue: TSkAnimatedImage.TAnimation); -begin - FAnimation.Assign(AValue); -end; - -procedure TSkAnimatedImage.SetSource(const AValue: TSource); -begin - FSource.Assign(AValue); -end; - -procedure TSkAnimatedImage.SetWrapMode(const AValue: TSkAnimatedImageWrapMode); -begin - if FWrapMode <> AValue then - begin - FWrapMode := AValue; - Redraw; - end; -end; - -procedure TSkAnimatedImage.SourceChange; -var - LCodecClass: TAnimationCodecClass; - LStream: TStream; -begin - FreeAndNil(FCodec); - LStream := TBytesStream.Create(FSource.Data); - try - for LCodecClass in FRegisteredCodecs do - begin - LStream.Position := 0; - if LCodecClass.TryMakeFromStream(LStream, FCodec) then - Break; - end; - finally - LStream.Free; - end; - if Assigned(FCodec) then - begin - Animation.SetDuration(FCodec.Duration); - if Animation.Running then - Animation.Start; - end - else - Animation.SetDuration(0); - Redraw; -end; - -procedure TSkAnimatedImage.WriteData(AStream: TStream); -begin - if FSource.Data <> nil then - AStream.WriteBuffer(FSource.Data, Length(FSource.Data)); -end; - -{ TSkAnimatedImageHelper } - -function TSkAnimatedImageHelper.Duration: Double; -begin - Result := Animation.Duration; -end; - -function TSkAnimatedImageHelper.FixedProgress: Boolean; -begin - Result := not Animation.Enabled; -end; - -function TSkAnimatedImageHelper.Loop: Boolean; -begin - Result := Animation.Loop; -end; - -function TSkAnimatedImageHelper.Progress: Double; -begin - Result := Animation.Progress; -end; - -function TSkAnimatedImageHelper.RunningAnimation: Boolean; -begin - Result := Animation.Running; -end; - -{ TSkDefaultAnimationCodec } - -constructor TSkDefaultAnimationCodec.Create( - const AAnimationCodec: ISkAnimationCodecPlayer; const AStream: TStream); -begin - inherited Create; - FAnimationCodec := AAnimationCodec; - FStream := AStream; -end; - -destructor TSkDefaultAnimationCodec.Destroy; -begin - FStream.Free; - inherited; -end; - -function TSkDefaultAnimationCodec.GetDuration: Double; -begin - Result := FAnimationCodec.Duration / 1000; -end; - -function TSkDefaultAnimationCodec.GetFPS: Double; -begin - Result := TAnimation.DefaultAniFrameRate; -end; - -function TSkDefaultAnimationCodec.GetIsStatic: Boolean; -begin - Result := FAnimationCodec.Duration = 0; -end; - -function TSkDefaultAnimationCodec.GetSize: TSizeF; -begin - Result := FAnimationCodec.Dimensions; -end; - -procedure TSkDefaultAnimationCodec.Render(const ACanvas: ISkCanvas; - const ADest: TRectF; const AOpacity: Single); -var - LPaint: ISkPaint; -begin - if SameValue(AOpacity, 1, TEpsilon.Position) then - LPaint := nil - else - begin - LPaint := TSkPaint.Create; - LPaint.AlphaF := AOpacity; - end; - case Quality of - TCanvasQuality.SystemDefault: ACanvas.DrawImageRect(FAnimationCodec.Frame, ADest, TSkSamplingOptions.Medium, LPaint); - TCanvasQuality.HighPerformance: ACanvas.DrawImageRect(FAnimationCodec.Frame, ADest, TSkSamplingOptions.Low, LPaint); - TCanvasQuality.HighQuality: ACanvas.DrawImageRect(FAnimationCodec.Frame, ADest, TSkSamplingOptions.Medium, LPaint); - end; -end; - -procedure TSkDefaultAnimationCodec.SeekFrameTime(const ATime: Double); -begin - FAnimationCodec.Seek(Round(ATime * 1000)); -end; - -class function TSkDefaultAnimationCodec.SupportedFormats: TArray; -begin - SetLength(Result, Ord(High(TImageFormat)) + 1); - Result[Ord(TImageFormat.GIF)] := TSkAnimatedImage.TFormatInfo.Create('GIF', 'GIF image', ['.gif']); - Result[Ord(TImageFormat.WebP)] := TSkAnimatedImage.TFormatInfo.Create('WebP', 'WebP image', ['.webp']); -end; - -class function TSkDefaultAnimationCodec.TryDetectFormat(const ABytes: TBytes; - out AFormat: TSkAnimatedImage.TFormatInfo): Boolean; - - function IsWebP: Boolean; - const - HeaderRiff: array[0..3] of Byte = ($52, $49, $46, $46); - HeaderWebP: array[0..3] of Byte = ($57, $45, $42, $50); - begin - Result := (Length(ABytes) > 12) and - CompareMem(@HeaderRiff[0], ABytes, Length(HeaderRiff)) and - CompareMem(@HeaderWebP[0], @ABytes[8], Length(HeaderWebP)); - end; - -const - GIFSignature: array[0..2] of Byte = (71, 73, 70); -begin - Result := True; - if (Length(ABytes) >= Length(GIFSignature)) and CompareMem(@GIFSignature[0], ABytes, Length(GIFSignature)) then - AFormat := SupportedFormats[Ord(TImageFormat.GIF)] - else if IsWebP then - AFormat := SupportedFormats[Ord(TImageFormat.WebP)] - else - Result := False; -end; - -class function TSkDefaultAnimationCodec.TryMakeFromStream( - const AStream: TStream; out ACodec: TSkAnimatedImage.TAnimationCodec): Boolean; -var - LAnimationCodec: ISkAnimationCodecPlayer; - LStream: TMemoryStream; -begin - Result := False; - LStream := TMemoryStream.Create; - try - LStream.CopyFrom(AStream, 0); - LStream.Position := 0; - LAnimationCodec := TSkAnimationCodecPlayer.MakeFromStream(LStream); - if Assigned(LAnimationCodec) then - begin - ACodec := TSkDefaultAnimationCodec.Create(LAnimationCodec, LStream); - Result := True; - end - else - ACodec := nil; - finally - if not Result then - LStream.Free; - end; -end; - -{ TSkLottieAnimationCodec } - -constructor TSkLottieAnimationCodec.Create(const ASkottie: ISkottieAnimation); -begin - inherited Create; - FSkottie := ASkottie; -end; - -function TSkLottieAnimationCodec.GetDuration: Double; -begin - Result := FSkottie.Duration; -end; - -function TSkLottieAnimationCodec.GetFPS: Double; -begin - Result := FSkottie.FPS; -end; - -function TSkLottieAnimationCodec.GetIsStatic: Boolean; -begin - Result := False; -end; - -function TSkLottieAnimationCodec.GetSize: TSizeF; -begin - Result := FSkottie.Size; -end; - -procedure TSkLottieAnimationCodec.Render(const ACanvas: ISkCanvas; - const ADest: TRectF; const AOpacity: Single); -var - LLottieRect: TRectF; - LNeedSaveLayer: Boolean; -begin - if ADest.IsEmpty then - Exit; - LLottieRect := TRectF.Create(PointF(0, 0), FSkottie.Size).FitInto(ADest); - if LLottieRect.IsEmpty then - Exit; - LNeedSaveLayer := not SameValue(AOpacity, 1, TEpsilon.Position); - if LNeedSaveLayer then - ACanvas.SaveLayerAlpha(Round(AOpacity * 255)); - try - if SameValue(ADest.Width / LLottieRect.Width, ADest.Height / LLottieRect.Height, TEpsilon.Matrix) then - FSkottie.Render(ACanvas, ADest) - else - begin - if not LNeedSaveLayer then - ACanvas.Save; - try - ACanvas.Scale(ADest.Width / LLottieRect.Width, ADest.Height / LLottieRect.Height); - ACanvas.Translate((LLottieRect.Width - ADest.Width) / 2, (LLottieRect.Height - ADest.Height) / 2); - FSkottie.Render(ACanvas, ADest); - finally - if not LNeedSaveLayer then - ACanvas.Restore; - end; - end; - finally - if LNeedSaveLayer then - ACanvas.Restore; - end; -end; - -procedure TSkLottieAnimationCodec.SeekFrameTime(const ATime: Double); -begin - FSkottie.SeekFrameTime(ATime); -end; - -class function TSkLottieAnimationCodec.SupportedFormats: TArray; -begin - SetLength(Result, Ord(High(TAnimationFormat)) + 1); - Result[Ord(TAnimationFormat.Lottie)] := TSkAnimatedImage.TFormatInfo.Create('Lottie', 'Lottie file', ['.json', '.lottie']); - Result[Ord(TAnimationFormat.TGS)] := TSkAnimatedImage.TFormatInfo.Create('TGS', 'Telegram sticker', ['.tgs']); -end; - -class function TSkLottieAnimationCodec.TryDetectFormat(const ABytes: TBytes; - out AFormat: TSkAnimatedImage.TFormatInfo): Boolean; -const - GZipSignature: Word = $8B1F; -begin - Result := False; - if Length(ABytes) > 4 then - begin - if PWord(ABytes)^ = GZipSignature then - begin - AFormat := SupportedFormats[Ord(TAnimationFormat.TGS)]; - Result := True; - end - else if ((ABytes[0] = $7B) and (ABytes[Length(ABytes) - 1] = $7D)) or - ((PWord(ABytes)^ = $7B00) and (PWord(@ABytes[Length(ABytes) - 2])^ = $7D00)) then - begin - AFormat := SupportedFormats[Ord(TAnimationFormat.Lottie)]; - Result := True; - end; - end; -end; - -class function TSkLottieAnimationCodec.TryMakeFromStream(const AStream: TStream; out ACodec: TSkAnimatedImage.TAnimationCodec): Boolean; - - function IsTgs: Boolean; - const - GZipSignature: Word = $8B1F; - var - LSignature: Word; - LSavePosition: Int64; - begin - if AStream.Size < 2 then - Exit(False); - LSavePosition := AStream.Position; - try - Result := (AStream.ReadData(LSignature) = SizeOf(Word)) and (LSignature = GZipSignature); - finally - AStream.Position := LSavePosition; - end; - end; - - function MakeFromTgsStream(const AStream: TStream): ISkottieAnimation; - var - LDecompressionStream: TDecompressionStream; - begin - LDecompressionStream := TDecompressionStream.Create(AStream, 31); - try - Result := TSkottieAnimation.MakeFromStream(LDecompressionStream, TSkDefaultProviders.Resource); - finally - LDecompressionStream.Free; - end; - end; - -var - LSkottie: ISkottieAnimation; -begin - if IsTgs then - LSkottie := MakeFromTgsStream(AStream) - else - LSkottie := TSkottieAnimation.MakeFromStream(AStream, TSkDefaultProviders.Resource); - - Result := Assigned(LSkottie); - if Result then - ACodec := TSkLottieAnimationCodec.Create(LSkottie) - else - ACodec := nil; -end; - -{ TSkFontComponent } - -procedure TSkFontComponent.AssignTo(ADest: TPersistent); -var - LDestFont: TFont absolute ADest; - {$IF CompilerVersion < 31} - LStyle: TFontStyles; - {$ENDIF} -begin - if ADest is TFont then - begin - LDestFont.Family := Families; - LDestFont.Size := Size; - {$IF CompilerVersion >= 31} - LDestFont.StyleExt := TFontStyleExt.Create(Weight, Slant, Stretch); - {$ELSE} - LStyle := []; - if SkFontWeightValue[Weight] >= 600 then - LStyle := LStyle + [TFontStyle.fsBold]; - if Slant <> TFontSlant.Regular then - LStyle := LStyle + [TFontStyle.fsItalic]; - LDestFont.Style := LStyle; - {$ENDIF} - end - else - inherited; -end; - -constructor TSkFontComponent.Create; -begin - inherited Create; - Assign(nil); -end; - -function TSkFontComponent.DefaultFamilies: string; -begin - Result := ''; -end; - -procedure TSkFontComponent.DoAssign(ASource: TPersistent); -var - LSourceFont: TSkFontComponent absolute ASource; -begin - if ASource = nil then - begin - Families := DefaultFamilies; - Size := DefaultSize; - Slant := DefaultSlant; - Stretch := DefaultStretch; - Weight := DefaultWeight; - end - else if ASource is TSkFontComponent then - begin - Families := LSourceFont.Families; - Size := LSourceFont.Size; - Slant := LSourceFont.Slant; - Stretch := LSourceFont.Stretch; - Weight := LSourceFont.Weight; - end - else if ASource is TFont then - begin - Families := TFont(ASource).Family; - Size := TFont(ASource).Size; - {$IF CompilerVersion >= 31} - Slant := TFont(ASource).StyleExt.Slant; - Stretch := TFont(ASource).StyleExt.Stretch; - Weight := TFont(ASource).StyleExt.Weight; - {$ELSE} - if TFontStyle.fsItalic in TFont(ASource).Style then - Slant := TFontSlant.Italic - else - Slant := TFontSlant.Regular; - Stretch := TFontStretch.Regular; - if TFontStyle.fsBold in TFont(ASource).Style then - Weight := TFontWeight.Bold - else - Weight := TFontWeight.Regular; - {$ENDIF} - end - else - inherited; -end; - -function TSkFontComponent.Equals(AObject: TObject): Boolean; -var - LFont: TSkFontComponent absolute AObject; -begin - Result := (AObject is TSkFontComponent) and - (FFamilies = LFont.Families) and - (FSlant = LFont.Slant) and - (FStretch = LFont.Stretch) and - (FWeight = LFont.Weight) and - SameValue(FSize, LFont.Size, TEpsilon.FontSize); -end; - -function TSkFontComponent.IsFamiliesStored: Boolean; -begin - Result := FFamilies <> DefaultFamilies; -end; - -function TSkFontComponent.IsSizeStored: Boolean; -begin - Result := not SameValue(FSize, DefaultSize, TEpsilon.FontSize); -end; - -procedure TSkFontComponent.SetFamilies(const AValue: string); - - function NormalizeFamilies(const AValue: string): string; - var - LSplitted: TArray; - LFamilies: TArray; - I: Integer; - begin - LSplitted := AValue.Split([',', #13, #10], TStringSplitOptions.ExcludeEmpty); - LFamilies := []; - for I := 0 to Length(LSplitted) - 1 do - begin - LSplitted[I] := LSplitted[I].Trim; - if LSplitted[I] <> '' then - LFamilies := LFamilies + [LSplitted[I]]; - end; - if LFamilies = nil then - Exit(''); - Result := string.Join(', ', LFamilies); - end; - -begin - SetValue(FFamilies, NormalizeFamilies(AValue)); -end; - -procedure TSkFontComponent.SetSize(const AValue: Single); -begin - SetValue(FSize, AValue, TEpsilon.FontSize); -end; - -procedure TSkFontComponent.SetSlant(const AValue: TFontSlant); -begin - SetValue(FSlant, AValue); -end; - -procedure TSkFontComponent.SetStretch(const AValue: TFontStretch); -begin - SetValue(FStretch, AValue); -end; - -procedure TSkFontComponent.SetWeight(const AValue: TFontWeight); -begin - SetValue(FWeight, AValue); -end; - -{ TSkTextSettings.TDecorations } - -constructor TSkTextSettings.TDecorations.Create; -begin - inherited Create; - Assign(nil); -end; - -procedure TSkTextSettings.TDecorations.DoAssign(ASource: TPersistent); -var - LSourceDecorations: TDecorations absolute ASource; -begin - if ASource = nil then - begin - Color := DefaultColor; - Decorations := DefaultDecorations; - StrokeColor := DefaultStrokeColor; - Style := DefaultStyle; - Thickness := DefaultThickness; - end - else if ASource is TDecorations then - begin - Color := LSourceDecorations.Color; - Decorations := LSourceDecorations.Decorations; - StrokeColor := LSourceDecorations.StrokeColor; - Style := LSourceDecorations.Style; - Thickness := LSourceDecorations.Thickness; - end - else - inherited; -end; - -function TSkTextSettings.TDecorations.Equals(AObject: TObject): Boolean; -var - LDecorations: TDecorations absolute AObject; -begin - Result := (AObject is TDecorations) and - (Color = LDecorations.Color) and - (Decorations = LDecorations.Decorations) and - (StrokeColor = LDecorations.StrokeColor) and - (Style = LDecorations.Style) and - (Thickness = LDecorations.Thickness); -end; - -function TSkTextSettings.TDecorations.IsThicknessStored: Boolean; -begin - Result := not SameValue(FThickness, DefaultThickness, TEpsilon.Scale); -end; - -procedure TSkTextSettings.TDecorations.SetColor(const AValue: TAlphaColor); -begin - SetValue(FColor, AValue); -end; - -procedure TSkTextSettings.TDecorations.SetDecorations( - const AValue: TSkTextDecorations); -begin - SetValue(FDecorations, AValue); -end; - -procedure TSkTextSettings.TDecorations.SetStrokeColor( - const AValue: TAlphaColor); -begin - SetValue(FStrokeColor, AValue); -end; - -procedure TSkTextSettings.TDecorations.SetStyle( - const AValue: TSkTextDecorationStyle); -begin - SetValue(FStyle, AValue); -end; - -procedure TSkTextSettings.TDecorations.SetThickness( - const AValue: Single); -begin - SetValue(FThickness, AValue); -end; - -{ TSkTextSettings } - -procedure TSkTextSettings.AssignNotStyled(const ATextSettings: TSkTextSettings; - const AStyledSettings: TStyledSettings); -var - LTextSettings: TSkTextSettings; -begin - if AStyledSettings <> AllStyledSettings then - begin - if AStyledSettings = [] then - Assign(ATextSettings) - else - begin - if ATextSettings = nil then - LTextSettings := TSkTextSettingsClass(ClassType).Create(Owner) - else - LTextSettings := ATextSettings; - try - BeginUpdate; - try - DoAssignNotStyled(LTextSettings, AStyledSettings); - finally - EndUpdate; - end; - finally - if ATextSettings = nil then - LTextSettings.Free; - end; - end; - end; -end; - -constructor TSkTextSettings.Create(const AOwner: TPersistent); -begin - inherited Create; - FOwner := AOwner; - FFont := CreateFont; - FFont.OnChange := FontChanged; - FDecorations := TDecorations.Create; - FDecorations.OnChange := DecorationsChange; - Assign(nil); -end; - -function TSkTextSettings.CreateFont: TSkFontComponent; -begin - Result := TSkFontComponent.Create; -end; - -procedure TSkTextSettings.DecorationsChange(ASender: TObject); -begin - Change; -end; - -destructor TSkTextSettings.Destroy; -begin - FDecorations.Free; - FFont.Free; - inherited; -end; - -procedure TSkTextSettings.DoAssign(ASource: TPersistent); -var - LSourceTextSettings: TSkTextSettings absolute ASource; -begin - if ASource = nil then - begin - Decorations := nil; - Font := nil; - FontColor := DefaultFontColor; - HeightMultiplier := DefaultHeightMultiplier; - HorzAlign := DefaultHorzAlign; - LetterSpacing := DefaultLetterSpacing; - MaxLines := DefaultMaxLines; - Trimming := DefaultTrimming; - VertAlign := DefaultVertAlign; - end - else if ASource is TSkTextSettings then - begin - Decorations := LSourceTextSettings.Decorations; - Font := LSourceTextSettings.Font; - FontColor := LSourceTextSettings.FontColor; - HeightMultiplier := LSourceTextSettings.HeightMultiplier; - HorzAlign := LSourceTextSettings.HorzAlign; - LetterSpacing := LSourceTextSettings.LetterSpacing; - MaxLines := LSourceTextSettings.MaxLines; - Trimming := LSourceTextSettings.Trimming; - VertAlign := LSourceTextSettings.VertAlign; - end - else - inherited; -end; - -procedure TSkTextSettings.DoAssignNotStyled( - const ATextSettings: TSkTextSettings; const AStyledSettings: TStyledSettings); -begin - Font.BeginUpdate; - try - if not (TStyledSetting.Family in AStyledSettings) then - Font.Families := ATextSettings.Font.Families; - if not (TStyledSetting.Size in AStyledSettings) then - Font.Size := ATextSettings.Font.Size; - if not (TStyledSetting.Style in AStyledSettings) then - begin - Font.Slant := ATextSettings.Font.Slant; - Font.Stretch := ATextSettings.Font.Stretch; - Font.Weight := ATextSettings.Font.Weight; - end; - finally - Font.EndUpdate; - end; - if not (TStyledSetting.FontColor in AStyledSettings) then - FontColor := ATextSettings.FontColor; - if not (TStyledSetting.Other in AStyledSettings) then - begin - Decorations := ATextSettings.Decorations; - HeightMultiplier := ATextSettings.HeightMultiplier; - HorzAlign := ATextSettings.HorzAlign; - LetterSpacing := ATextSettings.LetterSpacing; - VertAlign := ATextSettings.VertAlign; - MaxLines := ATextSettings.MaxLines; - Trimming := ATextSettings.Trimming; - end; -end; - -function TSkTextSettings.Equals(AObject: TObject): Boolean; -var - LTextSettings: TSkTextSettings absolute AObject; -begin - Result := (AObject is TSkTextSettings) and - FDecorations.Equals(LTextSettings.Decorations) and - FFont.Equals(LTextSettings.Font) and - (FFontColor = LTextSettings.FontColor) and - (FHeightMultiplier = LTextSettings.HeightMultiplier) and - (FHorzAlign = LTextSettings.HorzAlign) and - (FLetterSpacing = LTextSettings.LetterSpacing) and - (FMaxLines = LTextSettings.MaxLines) and - (FTrimming = LTextSettings.Trimming) and - (FVertAlign = LTextSettings.VertAlign); -end; - -procedure TSkTextSettings.FontChanged(ASender: TObject); -begin - Change; -end; - -function TSkTextSettings.IsHeightMultiplierStored: Boolean; -begin - Result := not SameValue(FHeightMultiplier, DefaultHeightMultiplier, TEpsilon.Position); -end; - -function TSkTextSettings.IsLetterSpacingStored: Boolean; -begin - Result := not SameValue(FLetterSpacing, DefaultLetterSpacing, TEpsilon.Position); -end; - -procedure TSkTextSettings.SetDecorations(const AValue: TDecorations); -begin - FDecorations.Assign(AValue); -end; - -procedure TSkTextSettings.SetFont(const AValue: TSkFontComponent); -begin - FFont.Assign(AValue); -end; - -procedure TSkTextSettings.SetFontColor(const AValue: TAlphaColor); -begin - SetValue(FFontColor, AValue); -end; - -procedure TSkTextSettings.SetHeightMultiplier(const AValue: Single); -begin - SetValue(FHeightMultiplier, AValue, TEpsilon.Position); -end; - -procedure TSkTextSettings.SetHorzAlign(const AValue: TSkTextHorzAlign); -begin - SetValue(FHorzAlign, AValue); -end; - -procedure TSkTextSettings.SetLetterSpacing(const AValue: Single); -begin - SetValue(FLetterSpacing, AValue, TEpsilon.Position); -end; - -procedure TSkTextSettings.SetMaxLines(const AValue: NativeUInt); -begin - SetValue(FMaxLines, AValue); -end; - -procedure TSkTextSettings.SetTrimming(const AValue: TTextTrimming); -begin - SetValue(FTrimming, AValue); -end; - -procedure TSkTextSettings.SetVertAlign(const AValue: TTextAlign); -begin - SetValue(FVertAlign, AValue); -end; - -procedure TSkTextSettings.UpdateStyledSettings(const AOldTextSettings, - ADefaultTextSettings: TSkTextSettings; var AStyledSettings: TStyledSettings); -begin - // If the user changed the value of the property, and it differs from the default, - // then delete the corresponding value from AStyledSettings - if (not SameText(AOldTextSettings.Font.Families, Font.Families)) and - (not SameText(ADefaultTextSettings.Font.Families, Font.Families)) then - begin - Exclude(AStyledSettings, TStyledSetting.Family); - end; - - if (not SameValue(AOldTextSettings.Font.Size, Font.Size, TEpsilon.FontSize)) and - (not SameValue(ADefaultTextSettings.Font.Size, Font.Size, TEpsilon.FontSize)) then - begin - Exclude(AStyledSettings, TStyledSetting.Size); - end; - - if ((AOldTextSettings.Font.Slant <> Font.Slant) or (AOldTextSettings.Font.Stretch <> Font.Stretch) or - (AOldTextSettings.Font.Weight <> Font.Weight)) and - ((ADefaultTextSettings.Font.Slant <> Font.Slant) or (ADefaultTextSettings.Font.Stretch <> Font.Stretch) or - (ADefaultTextSettings.Font.Weight <> Font.Weight)) then - begin - Exclude(AStyledSettings, TStyledSetting.Style); - end; - - if ((AOldTextSettings.FontColor <> FontColor) and (ADefaultTextSettings.FontColor <> FontColor)) then - Exclude(AStyledSettings, TStyledSetting.FontColor); - - if ((not AOldTextSettings.Decorations.Equals(Decorations)) or - (AOldTextSettings.HeightMultiplier <> HeightMultiplier) or - (AOldTextSettings.HorzAlign <> HorzAlign) or (AOldTextSettings.VertAlign <> VertAlign) or - (AOldTextSettings.LetterSpacing <> LetterSpacing) or - (AOldTextSettings.Trimming <> Trimming) or (AOldTextSettings.MaxLines <> MaxLines)) and - ((not ADefaultTextSettings.Decorations.Equals(Decorations)) or - (ADefaultTextSettings.HeightMultiplier <> HeightMultiplier) or - (ADefaultTextSettings.HorzAlign <> HorzAlign) or (ADefaultTextSettings.VertAlign <> VertAlign) or - (ADefaultTextSettings.LetterSpacing <> LetterSpacing) or - (ADefaultTextSettings.Trimming <> Trimming) or (ADefaultTextSettings.MaxLines <> MaxLines)) then - begin - Exclude(AStyledSettings, TStyledSetting.Other); - end; -end; - -{ TSkTextSettingsInfo.TBaseTextSettings } - -constructor TSkTextSettingsInfo.TBaseTextSettings.Create( - const AOwner: TPersistent); -begin - inherited; - if AOwner is TSkTextSettingsInfo then - begin - FInfo := TSkTextSettingsInfo(AOwner); - if FInfo.Owner is TControl then - FControl := TControl(FInfo.Owner); - end; -end; - -{ TSkTextSettingsInfo.TCustomTextSettings } - -constructor TSkTextSettingsInfo.TCustomTextSettings.Create( - const AOwner: TPersistent); -begin - inherited; - MaxLines := 0; -end; - -{ TSkTextSettingsInfo } - -constructor TSkTextSettingsInfo.Create(AOwner: TPersistent; - ATextSettingsClass: TSkTextSettingsInfo.TCustomTextSettingsClass); -var - LClass: TSkTextSettingsInfo.TCustomTextSettingsClass; -begin - if AOwner = nil then - raise ESkTextSettingsInfo.Create(SArgumentNil); - inherited Create; - FOwner := AOwner; - FStyledSettings := DefaultStyledSettings; - if ATextSettingsClass = nil then - LClass := TCustomTextSettings - else - LClass := ATextSettingsClass; - - FDefaultTextSettings := LClass.Create(Self); - FDefaultTextSettings.OnChange := OnDefaultChanged; - FTextSettings := LClass.Create(Self); - FTextSettings.OnChange := OnTextChanged; - FResultingTextSettings := LClass.Create(Self); - FResultingTextSettings.OnChange := OnCalculatedTextSettings; - FOldTextSettings := LClass.Create(Self); - FOldTextSettings.Assign(FTextSettings); -end; - -destructor TSkTextSettingsInfo.Destroy; -begin - FDefaultTextSettings.Free; - FTextSettings.Free; - FResultingTextSettings.Free; - FOldTextSettings.Free; - inherited; -end; - -procedure TSkTextSettingsInfo.DoCalculatedTextSettings; -begin -end; - -procedure TSkTextSettingsInfo.DoDefaultChanged; -begin - RecalculateTextSettings; -end; - -procedure TSkTextSettingsInfo.DoStyledSettingsChanged; -begin - RecalculateTextSettings; - if Assigned(FOnChange) then - FOnChange(Self); -end; - -procedure TSkTextSettingsInfo.DoTextChanged; -var - LDesign: Boolean; -begin - try - LDesign := Design and (not (Owner is TComponent) or - (TComponent(Owner).ComponentState * [csLoading, csDestroying, csReading] = [])); - if LDesign then - TextSettings.UpdateStyledSettings(FOldTextSettings, DefaultTextSettings, FStyledSettings); - RecalculateTextSettings; - finally - if FOldTextSettings <> nil then - FOldTextSettings.Assign(FTextSettings); - end; - if Assigned(FOnChange) then - FOnChange(Self); -end; - -procedure TSkTextSettingsInfo.OnCalculatedTextSettings(ASender: TObject); -begin - DoCalculatedTextSettings; -end; - -procedure TSkTextSettingsInfo.OnDefaultChanged(ASender: TObject); -begin - DoDefaultChanged; -end; - -procedure TSkTextSettingsInfo.OnTextChanged(ASender: TObject); -begin - DoTextChanged; -end; - -procedure TSkTextSettingsInfo.RecalculateTextSettings; -var - TmpResultingTextSettings: TSkTextSettings; -begin - if ResultingTextSettings <> nil then - begin - TmpResultingTextSettings := TSkTextSettingsClass(TextSettings.ClassType).Create(Self); - try - TmpResultingTextSettings.Assign(DefaultTextSettings); - TmpResultingTextSettings.AssignNotStyled(TextSettings, StyledSettings); - ResultingTextSettings.Assign(TmpResultingTextSettings); - finally - TmpResultingTextSettings.Free; - end; - end; -end; - -procedure TSkTextSettingsInfo.SetDefaultTextSettings( - const AValue: TSkTextSettings); -begin - FDefaultTextSettings.Assign(AValue); -end; - -procedure TSkTextSettingsInfo.SetStyledSettings(const AValue: TStyledSettings); -begin - if FStyledSettings <> AValue then - begin - FStyledSettings := AValue; - DoStyledSettingsChanged; - end; -end; - -procedure TSkTextSettingsInfo.SetTextSettings(const AValue: TSkTextSettings); -begin - FTextSettings.Assign(AValue); -end; - -{ TSkCustomStyleTextObject } - -constructor TSkCustomStyleTextObject.Create(AOwner: TComponent); -begin - inherited; - FTextSettings := CreateTextSettings; - FTextSettings.OnChange := TextSettingsChange; -end; - -function TSkCustomStyleTextObject.CreateTextSettings: TSkTextSettings; -begin - Result := TSkTextSettings.Create(Self); -end; - -destructor TSkCustomStyleTextObject.Destroy; -begin - FTextSettings.Free; - FSavedTextSettings.Free; - inherited; -end; - -function TSkCustomStyleTextObject.GetTextSettings: TSkTextSettings; -begin - Result := FTextSettings; -end; - -function TSkCustomStyleTextObject.RestoreState: Boolean; -begin - Result := False; - if (FSavedTextSettings <> nil) and (FTextSettings <> nil) then - begin - TextSettings := FSavedTextSettings; - FreeAndNil(FSavedTextSettings); - Result := True; - end; -end; - -function TSkCustomStyleTextObject.SaveState: Boolean; -begin - Result := False; - if FTextSettings <> nil then - begin - if FSavedTextSettings = nil then - FSavedTextSettings := TSkTextSettingsClass(FTextSettings.ClassType).Create(nil); - FSavedTextSettings.Assign(FTextSettings); - Result := True; - end; -end; - -procedure TSkCustomStyleTextObject.SetName(const ANewName: TComponentName); -begin - inherited; - if FStyleName = '' then - FStyleName := Name; -end; - -procedure TSkCustomStyleTextObject.SetTextSettings(const AValue: TSkTextSettings); -begin - FTextSettings.Assign(AValue); -end; - -procedure TSkCustomStyleTextObject.TextSettingsChange(ASender: TObject); -begin - if Assigned(FOnChange) then - FOnChange(Self); -end; - -{$IF CompilerVersion < 29} -procedure ValidateInheritance(const AValue: TPersistent; const AClass: TClass; const CanBeNil: Boolean = True); -const - SEUseHeirs = 'You can use only the inheritors of class "%s"'; -begin - if (AClass <> nil) and (CanBeNil or (AValue <> nil)) then - begin - if (AValue <> nil) and not AValue.InheritsFrom(AClass) then - raise EArgumentException.CreateFMT(SEUseHeirs, [AClass.ClassName])at ReturnAddress; - end - else - raise EArgumentNilException.Create(SArgumentNil)at ReturnAddress; -end; -{$ENDIF} - -{ TSkLabel.TCustomWordsItem } - -procedure TSkLabel.TCustomWordsItem.Assign(ASource: TPersistent); -begin - if ASource <> Self then - begin - BeginUpdate; - try - DoAssign(ASource); - finally - EndUpdate; - end; - end; -end; - -procedure TSkLabel.TCustomWordsItem.BeginUpdate; -begin - Inc(FUpdatingCount); -end; - -procedure TSkLabel.TCustomWordsItem.Change; -begin - if FUpdatingCount > 0 then - FChanged := True - else - begin - FChanged := False; - DoChanged; - end; -end; - -procedure TSkLabel.TCustomWordsItem.CheckName(const AName: string; - AWordsCollection: TWordsCollection); -var - I: Integer; -begin - if AName.Trim.IsEmpty then - raise ESkLabel.CreateFmt(SInvalidName, [AName]); - if AWordsCollection <> nil then - for I := 0 to AWordsCollection.Count - 1 do - if (AWordsCollection.Items[I] <> Self) and (string.Compare(AName, AWordsCollection.Items[I].Name, [TCompareOption.coIgnoreCase]) = 0) then - raise ESkLabel.CreateFmt(SDuplicateName, [AWordsCollection.Items[I].Name]); -end; - -constructor TSkLabel.TCustomWordsItem.Create(ACollection: TCollection); -var - LTextSettingsInfoOwner: TPersistent; -begin - inherited; - if (ACollection is TWordsCollection) and Assigned(TWordsCollection(ACollection).&Label) then - LTextSettingsInfoOwner := TWordsCollection(ACollection).&Label - else - LTextSettingsInfoOwner := Self; - FTextSettingsInfo := TSkTextSettingsInfo.Create(LTextSettingsInfoOwner, nil); - if LTextSettingsInfoOwner is TSkLabel then - FTextSettingsInfo.Design := True; - Assign(nil); - FTextSettingsInfo.OnChange := TextSettingsChange; -end; - -destructor TSkLabel.TCustomWordsItem.Destroy; -begin - FTextSettingsInfo.Free; - inherited; -end; - -procedure TSkLabel.TCustomWordsItem.DoAssign(ASource: TPersistent); -var - LSourceItem: TCustomWordsItem absolute ASource; -begin - if ASource = nil then - begin - BackgroundColor := DefaultBackgroundColor; - Cursor := DefaultCursor; - Font := nil; - FontColor := DefaultFontColor; - HeightMultiplier := DefaultHeightMultiplier; - LetterSpacing := DefaultLetterSpacing; - Name := UniqueName(DefaultName, Collection); - StyledSettings := DefaultStyledSettings; - Text := DefaultText; - OnClick := nil; - end - else if ASource is TCustomWordsItem then - begin - BackgroundColor := LSourceItem.BackgroundColor; - Cursor := LSourceItem.Cursor; - Font := LSourceItem.Font; - FontColor := LSourceItem.FontColor; - HeightMultiplier := LSourceItem.HeightMultiplier; - LetterSpacing := LSourceItem.LetterSpacing; - Name := UniqueName(LSourceItem.Name, Collection); - StyledSettings := LSourceItem.StyledSettings; - Text := LSourceItem.Text; - OnClick := LSourceItem.OnClick; - end - else - inherited Assign(ASource); -end; - -procedure TSkLabel.TCustomWordsItem.DoChanged; -begin - Changed(False); -end; - -procedure TSkLabel.TCustomWordsItem.EndUpdate; -begin - EndUpdate(False); -end; - -procedure TSkLabel.TCustomWordsItem.EndUpdate(const AIgnoreAllChanges: Boolean); -var - LCallChange: Boolean; - LIgnoreChanges: Boolean; -begin - LIgnoreChanges := AIgnoreAllChanges or FIgnoringAllChanges; - LCallChange := False; - if FUpdatingCount <= 0 then - raise ESkLabel.Create('The object is not in update state'); - Dec(FUpdatingCount); - if (not LIgnoreChanges) and FChanged then - LCallChange := True - else - FChanged := False; - if FUpdatingCount <= 0 then - FIgnoringAllChanges := False; - if LCallChange and (FUpdatingCount = 0) then - begin - FChanged := False; - DoChanged; - end; -end; - -function TSkLabel.TCustomWordsItem.GetDecorations: TSkTextSettings.TDecorations; -begin - Result := FTextSettingsInfo.TextSettings.Decorations; -end; - -function TSkLabel.TCustomWordsItem.GetDisplayName: string; -begin - Result := Name; -end; - -function TSkLabel.TCustomWordsItem.GetFont: TSkFontComponent; -begin - Result := FTextSettingsInfo.TextSettings.Font; -end; - -function TSkLabel.TCustomWordsItem.GetFontColor: TAlphaColor; -begin - Result := FTextSettingsInfo.TextSettings.FontColor; -end; - -function TSkLabel.TCustomWordsItem.GetHeightMultiplier: Single; -begin - Result := FTextSettingsInfo.TextSettings.HeightMultiplier; -end; - -function TSkLabel.TCustomWordsItem.GetLetterSpacing: Single; -begin - Result := FTextSettingsInfo.TextSettings.LetterSpacing; -end; - -function TSkLabel.TCustomWordsItem.GetStyledSettings: TStyledSettings; -begin - Result := FTextSettingsInfo.StyledSettings; -end; - -function TSkLabel.TCustomWordsItem.IsFontColorStored: Boolean; -begin - Result := (FontColor <> DefaultFontColor) or not (TStyledSetting.FontColor in StyledSettings); -end; - -function TSkLabel.TCustomWordsItem.IsHeightMultiplierStored: Boolean; -begin - Result := (not SameValue(HeightMultiplier, DefaultHeightMultiplier, TEpsilon.Position)) or not (TStyledSetting.Other in StyledSettings); -end; - -function TSkLabel.TCustomWordsItem.IsLetterSpacingStored: Boolean; -begin - Result := (not SameValue(LetterSpacing, DefaultLetterSpacing, TEpsilon.Position)) or not (TStyledSetting.Other in StyledSettings); -end; - -function TSkLabel.TCustomWordsItem.IsNameStored: Boolean; -begin - Result := (Assigned(Collection) and (Collection.Count <> 1)) or (Name <> 'Item 0'); -end; - -function TSkLabel.TCustomWordsItem.IsStyledSettingsStored: Boolean; -begin - Result := StyledSettings <> DefaultStyledSettings; -end; - -function TSkLabel.TCustomWordsItem.IsTextStored: Boolean; -begin - Result := Text <> DefaultText; -end; - -procedure TSkLabel.TCustomWordsItem.SetBackgroundColor( - const AValue: TAlphaColor); -begin - if FBackgroundColor <> AValue then - begin - FBackgroundColor := AValue; - Change; - end; -end; - -procedure TSkLabel.TCustomWordsItem.SetCollection(AValue: TCollection); -var - S: string; -begin - ValidateInheritance(AValue, TWordsCollection); - S := UniqueName(FName, AValue); - if string.Compare(S, FName, [TCompareOption.coIgnoreCase]) <> 0 then - CheckName(S, TWordsCollection(AValue)); - FName := S; - inherited; - FWords := TWordsCollection(Collection); -end; - -procedure TSkLabel.TCustomWordsItem.SetCursor(const AValue: TCursor); -begin - if FCursor <> AValue then - begin - FCursor := AValue; - Change; - end; -end; - -procedure TSkLabel.TCustomWordsItem.SetDecorations( - const AValue: TSkTextSettings.TDecorations); -begin - FTextSettingsInfo.TextSettings.Decorations.Assign(AValue); -end; - -procedure TSkLabel.TCustomWordsItem.SetFont(const AValue: TSkFontComponent); -begin - FTextSettingsInfo.TextSettings.Font.Assign(AValue); -end; - -procedure TSkLabel.TCustomWordsItem.SetFontColor(const AValue: TAlphaColor); -begin - FTextSettingsInfo.TextSettings.FontColor := AValue; -end; - -procedure TSkLabel.TCustomWordsItem.SetHeightMultiplier(const AValue: Single); -begin - FTextSettingsInfo.TextSettings.HeightMultiplier := AValue; -end; - -procedure TSkLabel.TCustomWordsItem.SetLetterSpacing(const AValue: Single); -begin - FTextSettingsInfo.TextSettings.LetterSpacing := AValue; -end; - -procedure TSkLabel.TCustomWordsItem.SetName(const AValue: string); -var - LValue: string; -begin - LValue := AValue.Trim; - if FName <> LValue then - begin - if string.Compare(LValue, FName, [TCompareOption.coIgnoreCase]) <> 0 then - CheckName(LValue, Words); - FName := LValue; - Change; - end; -end; - -procedure TSkLabel.TCustomWordsItem.SetStyledSettings( - const AValue: TStyledSettings); -begin - FTextSettingsInfo.StyledSettings := AValue; -end; - -procedure TSkLabel.TCustomWordsItem.SetText(const AValue: string); -begin - if FText <> AValue then - begin - FText := AValue; - Change; - end; -end; - -procedure TSkLabel.TCustomWordsItem.TextSettingsChange(ASender: TObject); -begin - Change; -end; - -function TSkLabel.TCustomWordsItem.UniqueName(const AName: string; - const ACollection: TCollection): string; -var - S: string; - I, J, LIndex, LMaxIndex: Integer; - LFound: Boolean; - LOriginalName: string; - - procedure SeparateNameIndex(var S: string; var AIndex: Integer); - var - I, N: integer; - begin - AIndex := -1; - I := S.Length - 1; - N := 0; - while (N <= 9) and (I >= 0) and S.Chars[I].IsDigit do - begin - Dec(I); - Inc(N); - end; - if (I >= 0) and InRange(N, 1, 5) then - begin - AIndex := S.Substring(I + 1).ToInteger; - S := S.Substring(0, I + 1); - end; - end; - -begin - LOriginalName := AName.Trim; - Result := LOriginalName; - if ACollection <> nil then - begin - SeparateNameIndex(Result, LIndex); - LMaxIndex := -1; - LFound := False; - for I := 0 to ACollection.Count - 1 do - if (ACollection.Items[I] <> Self) and (ACollection.Items[I] is TCustomWordsItem) then - begin - S := TCustomWordsItem(ACollection.Items[I]).Name; - SeparateNameIndex(S, J); - if string.Compare(S, Result, [TCompareOption.coIgnoreCase]) = 0 then - begin - LMaxIndex := Max(LMaxIndex, J); - if (LIndex = J) then - LFound := True; - end; - end; - if LFound then - begin - LMaxIndex := Max(LMaxIndex + 1, 1); - Result := Result + LMaxIndex.ToString; - end - else - Result := LOriginalName; - end; -end; - -{ TSkLabel.TWordsCollection } - -function TSkLabel.TWordsCollection.Add: TCustomWordsItem; -begin - Result := TCustomWordsItem(inherited Add); -end; - -function TSkLabel.TWordsCollection.Add(const AText: string; - const AColor: TAlphaColor; const AFontSize: Single; - const AFontWeight: TFontWeight; - const AFontSlant: TFontSlant): TCustomWordsItem; -begin - Result := Add; - Result.BeginUpdate; - try - Result.Text := AText; - Result.Font.BeginUpdate; - try - Result.Font.Size := AFontSize; - Result.Font.Weight := AFontWeight; - Result.Font.Slant := AFontSlant; - finally - Result.Font.EndUpdate; - end; - Result.FontColor := AColor; - finally - Result.EndUpdate; - end; -end; - -function TSkLabel.TWordsCollection.AddOrSet(const AName, AText: string; - const AFontColor: TAlphaColor; const AFont: TSkFontComponent; - const AOnClick: TNotifyEvent; const ACursor: TCursor): TCustomWordsItem; -begin - Result := ItemByName[AName]; - if not Assigned(Result) then - Result := Add; - Result.BeginUpdate; - try - if not AName.IsEmpty then - Result.Name := AName; - Result.Font := AFont; - Result.FontColor := AFontColor; - Result.Text := AText; - Result.OnClick := AOnClick; - Result.Cursor := ACursor; - finally - Result.EndUpdate; - end; -end; - -constructor TSkLabel.TWordsCollection.Create(AOwner: TPersistent; - AItemClass: TCustomWordsItemClass); -begin - ValidateInheritance(AOwner, TSkLabel, False); - inherited Create(AOwner, AItemClass); - FLabel := TSkLabel(AOwner); -end; - -function TSkLabel.TWordsCollection.GetItem(AIndex: Integer): TCustomWordsItem; -begin - Result := TCustomWordsItem(inherited GetItem(AIndex)); -end; - -function TSkLabel.TWordsCollection.GetItemByName( - const AName: string): TCustomWordsItem; -var - LIndex: Integer; -begin - LIndex := IndexOf(AName); - if LIndex = -1 then - Result := nil - else - Result := Items[LIndex]; -end; - -function TSkLabel.TWordsCollection.IndexOf(const AName: string): Integer; -var - I: Integer; -begin - Result := -1; - for I := 0 to Count - 1 do - if string.Compare(AName, Items[I].Name, [TCompareOption.coIgnoreCase]) = 0 then - begin - Result := I; - Break; - end; -end; - -function TSkLabel.TWordsCollection.Insert(AIndex: Integer): TCustomWordsItem; -begin - Result := TCustomWordsItem(inherited Insert(AIndex)); -end; - -procedure TSkLabel.TWordsCollection.SetItem(AIndex: Integer; - const AValue: TCustomWordsItem); -begin - inherited SetItem(AIndex, AValue); -end; - -procedure TSkLabel.TWordsCollection.Update(AItem: TCollectionItem); -begin - inherited; - if (FLabel <> nil) and not (csDestroying in FLabel.ComponentState) then - begin - if Assigned(FOnChange) then - FOnChange(Self); - end; -end; - -{ TSkLabel } - -procedure TSkLabel.ApplyStyle; -var - LFontBehavior: IFontBehavior; - - procedure SetupDefaultTextSetting(const AObject: TFmxObject; - const ADefaultTextSettings: TSkTextSettings); - var - LNewFamily: string; - LNewSize: Single; - begin - if (AObject <> nil) and AObject.GetInterface(IObjectState, FObjectState) then - FObjectState.SaveState - else - FObjectState := nil; - - FStyleText := nil; - if ADefaultTextSettings <> nil then - begin - if (AObject <> nil) and Supports(AObject, ISkStyleTextObject, FStyleText) then - ADefaultTextSettings.Assign(FStyleText.TextSettings) - else - ADefaultTextSettings.Assign(nil); - - if LFontBehavior <> nil then - begin - LNewFamily := ''; - LFontBehavior.GetDefaultFontFamily(Scene.GetObject, LNewFamily); - if not LNewFamily.IsEmpty then - ADefaultTextSettings.Font.Families := LNewFamily; - - LNewSize := 0; - LFontBehavior.GetDefaultFontSize(Scene.GetObject, LNewSize); - if not SameValue(LNewSize, 0, TEpsilon.FontSize) then - ADefaultTextSettings.Font.Size := LNewSize; - end; - end; - end; - -var - LInterface: IInterface; - LNewText: string; - I: Integer; -begin - LFontBehavior := nil; - BeginUpdate; - try - ResultingTextSettings.BeginUpdate; - try - FTextSettingsInfo.Design := False; - { behavior } - if (Scene <> nil) and TBehaviorServices.Current.SupportsBehaviorService(IFontBehavior, LInterface, Scene.GetObject) then - Supports(LInterface, IFontBehavior, LFontBehavior); - { from text } - SetupDefaultTextSetting(FindStyleResource('text'), FTextSettingsInfo.DefaultTextSettings); - inherited; - ResultingTextSettings.Change; - finally - ResultingTextSettings.EndUpdate; - FTextSettingsInfo.Design := True;//csDesigning in ComponentState; - end; - if AutoTranslate and not Text.IsEmpty then - begin - for I := 0 to FWords.Count - 1 do - begin - LNewText := Translate(FWords[I].Text); // need for collection texts - if not (csDesigning in ComponentState) then - FWords[I].Text := LNewText; - end; - end; - DeleteParagraph; - if (not IsUpdating) and FAutoSize and HasFitSizeChanged then - SetSize(Width, Height); - Redraw; - finally - EndUpdate; - end; -end; - -procedure TSkLabel.Click; -var - LClickedItem: TCustomWordsItem; -begin - LClickedItem := GetWordsItemAtPosition(FClickedPosition.X, FClickedPosition.Y); - if Assigned(LClickedItem) and (LClickedItem = GetWordsItemAtPosition(PressedPosition.X, PressedPosition.Y)) then - begin - TMessageManager.DefaultManager.SendMessage(Self, TItemClickedMessage.Create(LClickedItem)); - if Assigned(LClickedItem.OnClick) then - LClickedItem.OnClick(FWordsMouseOver) - else - inherited; - end - else - inherited; -end; - -constructor TSkLabel.Create(AOwner: TComponent); -begin - inherited; - SetAcceptsControls(False); - FAutoSize := True; - AutoTranslate := True; - FTextSettingsInfo := TSkTextSettingsInfo.Create(Self, nil); - FTextSettingsInfo.Design := True;//csDesigning in ComponentState; - FTextSettingsInfo.OnChange := TextSettingsChanged; - FWords := TWordsCollection.Create(Self, TWordsItem); - FWords.OnChange := WordsChange; -end; - -procedure TSkLabel.DeleteParagraph; -begin - FParagraph := nil; - FParagraphStroked := nil; - FParagraphBounds := TRectF.Empty; - FParagraphLayoutWidth := 0; -end; - -destructor TSkLabel.Destroy; -begin - FTextSettingsInfo.Free; - FWords.Free; - inherited; -end; - -function TSkLabel.DidExceedMaxLines: Boolean; -var - LParagraph: ISkParagraph; -begin - LParagraph := Paragraph; - Result := Assigned(LParagraph) and (LParagraph.DidExceedMaxLines); -end; - -procedure TSkLabel.DoEndUpdate; -begin - if (not (csLoading in ComponentState)) and FAutoSize and HasFitSizeChanged then - SetSize(Width, Height) - else - inherited; -end; - -procedure TSkLabel.DoMouseLeave; -begin - inherited; - SetWordsMouseOver(nil); -end; - -function TSkLabel.DoSetSize(const ASize: TControlSize; - const ANewPlatformDefault: Boolean; ANewWidth, ANewHeight: Single; - var ALastWidth, ALastHeight: Single): Boolean; -begin - if FAutoSize and not (csLoading in ComponentState) then - GetFitSize(ANewWidth, ANewHeight); - Result := inherited; -end; - -procedure TSkLabel.DoStyleChanged; -var - LNewText: string; - I: Integer; -begin - inherited; - if AutoTranslate and not Text.IsEmpty then - begin - for I := 0 to FWords.Count - 1 do - begin - LNewText := Translate(FWords[I].Text); // need for collection texts - if not (csDesigning in ComponentState) then - FWords[I].Text := LNewText; - end; - end; -end; - -procedure TSkLabel.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; - const AOpacity: Single); - - function CreateBackgroundPicture(const AParagraph: ISkParagraph): ISkPicture; - var - LPictureRecorder: ISkPictureRecorder; - LCanvas: ISkCanvas; - LPaint: ISkPaint; - I: Integer; - LTextEndIndex: Integer; - LTextBox: TSkTextBox; - LRects: TArray; - LRectsColor: TArray; - LLastRect: TRectF; - LLastColor: TAlphaColor; - begin - LPictureRecorder := TSkPictureRecorder.Create; - LCanvas := LPictureRecorder.BeginRecording(ADest); - LPaint := TSkPaint.Create; - LPaint.AntiAlias := True; - LTextEndIndex := 0; - LRects := nil; - for I := 0 to FWords.Count - 1 do - begin - Inc(LTextEndIndex, FWords[I].Text.Length); - if TAlphaColorRec(FWords[I].BackgroundColor).A = 0 then - Continue; - for LTextBox in AParagraph.GetRectsForRange(LTextEndIndex - FWords[I].Text.Length, LTextEndIndex, TSkRectHeightStyle.Tight, TSkRectWidthStyle.Tight) do - begin - if LRects = nil then - begin - LRects := [LTextBox.Rect]; - LRectsColor := [FWords[I].BackgroundColor]; - Continue; - end; - LLastRect := LRects[High(LRects)]; - LLastColor := LRectsColor[High(LRectsColor)]; - if (LLastColor = FWords[I].BackgroundColor) and SameValue(LLastRect.Right, LTextBox.Rect.Left, 1) and - (InRange(LTextBox.Rect.CenterPoint.Y, LLastRect.Top, LLastRect.Bottom) or - InRange(LLastRect.CenterPoint.Y, LTextBox.Rect.Top, LTextBox.Rect.Bottom)) then - begin - LLastRect.Right := LTextBox.Rect.Right; - LLastRect.Top := Min(LLastRect.Top, LTextBox.Rect.Top); - LLastRect.Bottom := Max(LLastRect.Bottom, LTextBox.Rect.Bottom); - LRects[High(LRects)] := LLastRect; - end - else - begin - LRects := LRects + [LTextBox.Rect]; - LRectsColor := LRectsColor + [FWords[I].BackgroundColor]; - end; - end; - end; - for I := 0 to Length(LRects) - 1 do - begin - LPaint.Color := LRectsColor[I]; - LCanvas.DrawRoundRect(Canvas.AlignToPixel(LRects[I]), 2, 2, LPaint); - end; - Result := LPictureRecorder.FinishRecording; - end; - -var - LParagraph: ISkParagraph; - LPositionY: Single; - LCurrentFillTextFlags: TFillTextFlags; -begin - LCurrentFillTextFlags := FillTextFlags; - if FLastFillTextFlags <> LCurrentFillTextFlags then - begin - DeleteParagraph; - FLastFillTextFlags := LCurrentFillTextFlags; - end; - LParagraph := Paragraph; - if Assigned(LParagraph) then - begin - ParagraphLayout(ADest.Width); - LPositionY := ADest.Top; - case ResultingTextSettings.VertAlign of - TTextAlign.Center: LPositionY := LPositionY + ((ADest.Height - ParagraphBounds.Height) / 2); - TTextAlign.Leading: ; - TTextAlign.Trailing: LPositionY := LPositionY + (ADest.Height - ParagraphBounds.Height); - end; - - if SameValue(AOpacity, 1, TEpsilon.Position) then - ACanvas.Save - else - ACanvas.SaveLayerAlpha(Round(AOpacity * 255)); - try - ACanvas.ClipRect(ADest); - ACanvas.Translate(ADest.Left, LPositionY); - if FHasCustomBackground then - begin - if FBackgroundPicture = nil then - FBackgroundPicture := CreateBackgroundPicture(LParagraph); - ACanvas.DrawPicture(FBackgroundPicture); - end; - LParagraph.Paint(ACanvas, 0, 0); - if Assigned(FParagraphStroked) then - FParagraphStroked.Paint(ACanvas, 0, 0); - finally - ACanvas.Restore; - end; - end; -end; - -procedure TSkLabel.FreeStyle; -begin - if FObjectState <> nil then - begin - FObjectState.RestoreState; - FObjectState := nil; - end; - FStyleText := nil; - inherited; -end; - -function TSkLabel.GetDefaultSize: TSizeF; -{$IF CompilerVersion >= 30} -var - LDeviceInfo: IDeviceBehavior; -{$ENDIF} -begin - {$IF CompilerVersion >= 30} - if TBehaviorServices.Current.SupportsBehaviorService(IDeviceBehavior, LDeviceInfo, Self) then - case LDeviceInfo.GetOSPlatform(Self) of - TOSPlatform.Windows: Result := TSizeF.Create(120, 19); - TOSPlatform.OSX: Result := TSizeF.Create(120, 19); - TOSPlatform.iOS: Result := TSize.Create(82, 21); - TOSPlatform.Android: Result := TSize.Create(82, 23); - {$IF CompilerVersion >= 34} - TOSPlatform.Linux: Result := TSizeF.Create(120, 19); - {$ENDIF} - end - else - {$ENDIF} - Result := TSizeF.Create(120, 19); -end; - -function TSkLabel.GetDefaultTextSettings: TSkTextSettings; -begin - Result := FTextSettingsInfo.DefaultTextSettings; -end; - -procedure TSkLabel.GetFitSize(var AWidth, AHeight: Single); -var - LFinalScale: TPointF; - - function GetFitHeight: Single; - begin - case Align of - TAlignLayout.Client, - TAlignLayout.Contents, - TAlignLayout.Left, - TAlignLayout.MostLeft, - TAlignLayout.Right, - TAlignLayout.MostRight, - TAlignLayout.FitLeft, - TAlignLayout.FitRight, - TAlignLayout.HorzCenter, - TAlignLayout.Vertical: Result := AHeight; - else - Result := Ceil(ParagraphBounds.Height * LFinalScale.Y) / LFinalScale.Y; - end; - end; - - function GetFitWidth: Single; - begin - case Align of - TAlignLayout.Client, - TAlignLayout.Contents, - TAlignLayout.Top, - TAlignLayout.MostTop, - TAlignLayout.Bottom, - TAlignLayout.MostBottom, - TAlignLayout.VertCenter, - TAlignLayout.Horizontal: Result := AWidth; - else - Result := Ceil(ParagraphBounds.Width * LFinalScale.X) / LFinalScale.X; - end; - end; - - function GetFinalScale: TPointF; - begin - if Assigned(Scene) then - Result := AbsoluteScale * Scene.GetSceneScale - else - Result := AbsoluteScale; - end; - -var - LParagraph: ISkParagraph; -begin - LParagraph := Paragraph; - LFinalScale := GetFinalScale; - if Assigned(LParagraph) then - begin - if Align in [TAlignLayout.Top, TAlignLayout.MostTop, TAlignLayout.Bottom, - TAlignLayout.MostBottom, TAlignLayout.VertCenter, TAlignLayout.Horizontal] then - begin - ParagraphLayout(AWidth); - end - else - ParagraphLayout(High(Integer)); - end; - try - AWidth := GetFitWidth; - AHeight := GetFitHeight; - finally - if Assigned(LParagraph) then - ParagraphLayout(AWidth); - end; -end; - -function TSkLabel.GetLinesCount: Integer; -var - LParagraph: ISkParagraph; -begin - LParagraph := Paragraph; - if Assigned(LParagraph) then - Result := Length(LParagraph.LineMetrics) - else - Result := 0; -end; - -function TSkLabel.GetParagraph: ISkParagraph; -type - TDrawKind = (Fill, Stroke); -var - LFontBehavior: IFontBehavior; - LHasTextStroked: Boolean; - - function GetFontFamilies(const AValue: string): TArray; - var - LInterface: IInterface; - begin - Result := AValue.Split([', ', ','], TStringSplitOptions.ExcludeEmpty); - if Result = nil then - begin - if (LFontBehavior = nil) and (Scene <> nil) and TBehaviorServices.Current.SupportsBehaviorService(IFontBehavior, LInterface, Scene.GetObject) then - Supports(LInterface, IFontBehavior, LFontBehavior); - if Assigned(LFontBehavior) then - begin - SetLength(Result, 1); - Result[0] := ''; - LFontBehavior.GetDefaultFontFamily(Scene.GetObject, Result[0]); - if Result[0].IsEmpty then - Result := []; - end; - end; - {$IFDEF MACOS} - Result := Result + ['Helvetica Neue']; - {$ELSEIF DEFINED(LINUX)} - Result := Result + ['Ubuntu']; - {$ENDIF} - end; - - function GetFontSize(const AValue: Single): Single; - var - LInterface: IInterface; - begin - Result := AValue; - if SameValue(AValue, 0, TEpsilon.FontSize) then - begin - if (LFontBehavior = nil) and (Scene <> nil) and TBehaviorServices.Current.SupportsBehaviorService(IFontBehavior, LInterface, Scene.GetObject) then - Supports(LInterface, IFontBehavior, LFontBehavior); - if Assigned(LFontBehavior) then - LFontBehavior.GetDefaultFontSize(Scene.GetObject, Result); - end; - end; - - procedure SetTextStyleDecorations(var ATextStyle: ISkTextStyle; - const ADecorations: TSkTextSettings.TDecorations; - const ADrawKind: TDrawKind); - var - LPaint: ISkPaint; - begin - if ADecorations.Decorations <> [] then - begin - if ADecorations.Color = TAlphaColors.Null then - ATextStyle.DecorationColor := ATextStyle.Color - else - ATextStyle.DecorationColor := ADecorations.Color; - ATextStyle.Decorations := ADecorations.Decorations; - ATextStyle.DecorationStyle := ADecorations.Style; - ATextStyle.DecorationThickness := ADecorations.Thickness; - end; - if ADrawKind = TDrawKind.Stroke then - begin - if (ADecorations.StrokeColor <> TAlphaColors.Null) and not SameValue(ADecorations.Thickness, 0, TEpsilon.Position) then - begin - LPaint := TSkPaint.Create(TSkPaintStyle.Stroke); - LPaint.Color := ADecorations.StrokeColor; - LPaint.StrokeWidth := (ADecorations.Thickness / 2) * (ATextStyle.FontSize / 14); - ATextStyle.SetForegroundColor(LPaint); - end - else - ATextStyle.Color := TAlphaColors.Null; - end - else - LHasTextStroked := LHasTextStroked or - ((ADecorations.StrokeColor <> TAlphaColors.Null) and not SameValue(ADecorations.Thickness, 0, TEpsilon.Position)); - end; - - function CreateTextStyle(const AWordsItem: TCustomWordsItem; - const ADefaultTextStyle: ISkTextStyle; - const ADrawKind: TDrawKind): ISkTextStyle; - begin - Result := TSkTextStyle.Create; - if TStyledSetting.FontColor in AWordsItem.StyledSettings then - Result.Color := ResultingTextSettings.FontColor - else - Result.Color := AWordsItem.FontColor; - if TStyledSetting.Family in AWordsItem.StyledSettings then - Result.FontFamilies := ADefaultTextStyle.FontFamilies - else - Result.FontFamilies := GetFontFamilies(AWordsItem.Font.Families); - if TStyledSetting.Size in AWordsItem.StyledSettings then - Result.FontSize := ADefaultTextStyle.FontSize - else - Result.FontSize := GetFontSize(AWordsItem.Font.Size); - if TStyledSetting.Style in AWordsItem.StyledSettings then - Result.FontStyle := ADefaultTextStyle.FontStyle - else - Result.FontStyle := TSkFontStyle.Create(SkFontWeightValue[AWordsItem.Font.Weight], SkFontWidthValue[AWordsItem.Font.Stretch], SkFontSlant[AWordsItem.Font.Slant]); - if TStyledSetting.Other in AWordsItem.StyledSettings then - begin - Result.HeightMultiplier := ADefaultTextStyle.HeightMultiplier; - SetTextStyleDecorations(Result, ResultingTextSettings.Decorations, ADrawKind); - Result.LetterSpacing := ADefaultTextStyle.LetterSpacing; - end - else - begin - Result.HeightMultiplier := AWordsItem.HeightMultiplier; - SetTextStyleDecorations(Result, AWordsItem.Decorations, ADrawKind); - Result.LetterSpacing := AWordsItem.LetterSpacing; - end; - end; - - function CreateDefaultTextStyle(const ADrawKind: TDrawKind): ISkTextStyle; - begin - Result := TSkTextStyle.Create; - Result.Color := ResultingTextSettings.FontColor; - Result.FontFamilies := GetFontFamilies(ResultingTextSettings.Font.Families); - Result.FontSize := GetFontSize(ResultingTextSettings.Font.Size); - Result.FontStyle := TSkFontStyle.Create(SkFontWeightValue[ResultingTextSettings.Font.Weight], SkFontWidthValue[ResultingTextSettings.Font.Stretch], SkFontSlant[ResultingTextSettings.Font.Slant]); - Result.HeightMultiplier := ResultingTextSettings.HeightMultiplier; - Result.LetterSpacing := ResultingTextSettings.LetterSpacing; - SetTextStyleDecorations(Result, ResultingTextSettings.Decorations, ADrawKind); - end; - - function CreateParagraphStyle(const ADefaultTextStyle: ISkTextStyle): ISkParagraphStyle; - const - SkTextAlign: array[TSkTextHorzAlign] of TSkTextAlign = (TSkTextAlign.Center, TSkTextAlign.Start, TSkTextAlign.Terminate, TSkTextAlign.Justify); - begin - Result := TSkParagraphStyle.Create; - if ((Root = nil) and (Application.BiDiMode = TBiDiMode.bdRightToLeft)) or (TFillTextFlag.RightToLeft in FillTextFlags) then - Result.TextDirection := TSkTextDirection.RightToLeft; - if ResultingTextSettings.Trimming in [TTextTrimming.Character, TTextTrimming.Word] then - Result.Ellipsis := '...'; - if ResultingTextSettings.MaxLines = 0 then - Result.MaxLines := High(Integer) - else - Result.MaxLines := ResultingTextSettings.MaxLines; - Result.TextAlign := SkTextAlign[ResultingTextSettings.HorzAlign]; - Result.TextStyle := ADefaultTextStyle; - end; - - // Temporary solution to fix an issue with Skia: https://bugs.chromium.org/p/skia/issues/detail?id=13117 - // SkParagraph has several issues with the #13 line break, so the best thing to do is replace it with #10 or a zero-widh character (#8203) - function NormalizeParagraphText(const AText: string): string; - begin - Result := AText.Replace(#13#10, #8203#10).Replace(#13, #10); - end; - - function CreateParagraph(const ADrawKind: TDrawKind): ISkParagraph; - var - LBuilder: ISkParagraphBuilder; - LDefaultTextStyle: ISkTextStyle; - LText: string; - I: Integer; - begin - LFontBehavior := nil; - LDefaultTextStyle := CreateDefaultTextStyle(ADrawKind); - LBuilder := TSkParagraphBuilder.Create(CreateParagraphStyle(LDefaultTextStyle), TSkDefaultProviders.TypefaceFont); - for I := 0 to FWords.Count- 1 do - begin - if FWords[I].Text = '' then - Continue; - if FWords[I].StyledSettings = AllStyledSettings then - LBuilder.AddText(FWords[I].Text) - else - begin - LText := NormalizeParagraphText(FWords[I].Text); - if not LText.IsEmpty then - begin - LBuilder.PushStyle(CreateTextStyle(FWords[I], LDefaultTextStyle, ADrawKind)); - LBuilder.AddText(LText); - LBuilder.Pop; - end; - end; - FHasCustomBackground := FHasCustomBackground or (FWords[I].BackgroundColor <> TAlphaColors.Null); - end; - Result := LBuilder.Build; - end; - -begin - if (FParagraph = nil) and (Text <> '') then - begin - FBackgroundPicture := nil; - FHasCustomBackground := False; - LHasTextStroked := False; - FParagraph := CreateParagraph(TDrawKind.Fill); - if LHasTextStroked then - FParagraphStroked := CreateParagraph(TDrawKind.Stroke); - ParagraphLayout(Width); - end; - Result := FParagraph; -end; - -function TSkLabel.GetParagraphBounds: TRectF; - - function CalculateParagraphBounds: TRectF; - var - LParagraph: ISkParagraph; - begin - LParagraph := Paragraph; - if Assigned(LParagraph) then - Result := RectF(0, 0, Ceil(LParagraph.MaxIntrinsicWidth), Ceil(LParagraph.Height)) - else - Result := TRectF.Empty; - end; - -begin - if FParagraphBounds.IsEmpty then - FParagraphBounds := CalculateParagraphBounds; - Result := FParagraphBounds; -end; - -function TSkLabel.GetResultingTextSettings: TSkTextSettings; -begin - Result := FTextSettingsInfo.ResultingTextSettings; -end; - -function TSkLabel.GetStyledSettings: TStyledSettings; -begin - Result := FTextSettingsInfo.StyledSettings; -end; - -function TSkLabel.GetText: string; -var - I: Integer; -begin - Result := ''; - if Assigned(FWords) and (FWords.Count > 0) then - for I := 0 to FWords.Count - 1 do - Result := Result + FWords[I].Text; -end; - -function TSkLabel.GetTextSettings: TSkTextSettings; -begin - Result := FTextSettingsInfo.TextSettings; -end; - -function TSkLabel.GetTextSettingsClass: TSkTextSettingsInfo.TCustomTextSettingsClass; -begin - Result := TSkTextSettingsInfo.TCustomTextSettings; -end; - -function TSkLabel.GetWordsItemAtPosition(const AX, - AY: Single): TCustomWordsItem; - - // Remove inconsistencies such as area after a line break - function IsInsideValidArea(const AParagraph: ISkParagraph; const ATextArea: TRectF; const APoint: TPointF): Boolean; - var - LGlyphTextBoxes: TArray; - LGlyphPosition: TSkPositionAffinity; - begin - LGlyphPosition := AParagraph.GetGlyphPositionAtCoordinate(APoint.X, APoint.Y); - if LGlyphPosition.Affinity = TSkAffinity.Downstream then - Result := True - else if LGlyphPosition.Position >= 0 then - begin - LGlyphTextBoxes := AParagraph.GetRectsForRange(LGlyphPosition.Position, LGlyphPosition.Position + 1, TSkRectHeightStyle.Max, TSkRectWidthStyle.Tight); - Result := (LGlyphTextBoxes <> nil) and - ((LGlyphTextBoxes[0].Rect.CenterPoint.Distance(APoint) < (LGlyphTextBoxes[0].Rect.Width + LGlyphTextBoxes[0].Rect.Height) / 2) or - ATextArea.Contains(LGlyphTextBoxes[0].Rect.CenterPoint)); - end - else - Result := False; - end; - -var - I, J: Integer; - LTextIndex: Integer; - LTextBoxes: TArray; - LParagraph: ISkParagraph; - LParagraphPoint: TPointF; -begin - Result := nil; - LParagraph := Paragraph; - if Assigned(LParagraph) then - begin - case ResultingTextSettings.VertAlign of - TTextAlign.Center: LParagraphPoint := PointF(AX, AY - (Height - ParagraphBounds.Height) / 2); - TTextAlign.Trailing: LParagraphPoint := PointF(AX, AY - Height - ParagraphBounds.Height); - else - LParagraphPoint := PointF(AX, AY); - end; - LTextIndex := 0; - for I := 0 to FWords.Count - 1 do - begin - if FWords[I].Text.Length = 0 then - Continue; - LTextBoxes := LParagraph.GetRectsForRange(LTextIndex, LTextIndex + FWords[I].Text.Length, TSkRectHeightStyle.Max, TSkRectWidthStyle.Tight); - for J := 0 to Length(LTextBoxes) - 1 do - begin - if LTextBoxes[J].Rect.Contains(LParagraphPoint) then - begin - if IsInsideValidArea(LParagraph, LTextBoxes[J].Rect, LParagraphPoint) then - Result := FWords[I]; - Break; - end; - end; - if Assigned(Result) then - Break; - Inc(LTextIndex, FWords[I].Text.Length); - end; - end; -end; - -function TSkLabel.HasFitSizeChanged: Boolean; -var - LNewWidth: Single; - LNewHeight: Single; -begin - LNewWidth := Width; - LNewHeight := Height; - GetFitSize(LNewWidth, LNewHeight); - Result := (not SameValue(LNewWidth, Width, TEpsilon.Position)) or (not SameValue(LNewHeight, Height, TEpsilon.Position)); -end; - -function TSkLabel.IsStyledSettingsStored: Boolean; -begin - Result := StyledSettings <> DefaultStyledSettings; -end; - -procedure TSkLabel.Loaded; -begin - inherited; - if (not IsUpdating) and FAutoSize and HasFitSizeChanged then - SetSize(Width, Height); -end; - -procedure TSkLabel.MouseClick(AButton: TMouseButton; AShift: TShiftState; AX, - AY: Single); -begin - FClickedPosition := PointF(AX, AY); - inherited; -end; - -{$IF CompilerVersion < 30} -procedure TSkLabel.MouseDown(AButton: TMouseButton; AShift: TShiftState; AX, AY: Single); -begin - inherited; - if AButton = TMouseButton.mbLeft then - FPressedPosition := TPointF.Create(AX, AY); -end; -{$ENDIF} - -procedure TSkLabel.MouseMove(AShift: TShiftState; AX, AY: Single); -begin - if FHasCustomCursor then - SetWordsMouseOver(GetWordsItemAtPosition(AX, AY)); - inherited; -end; - -function TSkLabel.NeedsRedraw: Boolean; -begin - Result := inherited or (FLastFillTextFlags <> FillTextFlags); -end; - -procedure TSkLabel.ParagraphLayout(const AWidth: Single); -var - LParagraph: ISkParagraph; -begin - if not SameValue(FParagraphLayoutWidth, AWidth, TEpsilon.Position) then - begin - LParagraph := Paragraph; - if Assigned(LParagraph) then - begin - LParagraph.Layout(AWidth); - if Assigned(FParagraphStroked) then - FParagraphStroked.Layout(AWidth); - FParagraphLayoutWidth := AWidth; - FParagraphBounds := TRectF.Empty; - FBackgroundPicture := nil; - end; - end; -end; - -procedure TSkLabel.SetAlign(const AValue: TAlignLayout); -begin - if (Align <> AValue) and AutoSize then - begin - inherited; - SetSize(Width, Height); - end - else - inherited; -end; - -procedure TSkLabel.SetAutoSize(const AValue: Boolean); -begin - if FAutoSize <> AValue then - begin - FAutoSize := AValue; - SetSize(Width, Height); - end; -end; - -procedure TSkLabel.SetName(const AValue: TComponentName); -var - LChangeText: Boolean; -begin - LChangeText := not (csLoading in ComponentState) and (Name = Text) and - ((Owner = nil) or not (csLoading in TComponent(Owner).ComponentState)); - inherited SetName(AValue); - if LChangeText then - Text := AValue; -end; - -procedure TSkLabel.SetStyledSettings(const AValue: TStyledSettings); -begin - FTextSettingsInfo.StyledSettings := AValue; -end; - -procedure TSkLabel.SetText(const AValue: string); -begin - if Assigned(FWords) then - begin - FWords.BeginUpdate; - try - if FWords.Count = 1 then - FWords[0].Text := AValue - else - begin - FWords.Clear; - FWords.Add.Text := AValue; - end; - finally - FWords.EndUpdate; - end; - end; -end; - -procedure TSkLabel.SetTextSettings(const AValue: TSkTextSettings); -begin - FTextSettingsInfo.TextSettings := AValue; -end; - -procedure TSkLabel.SetWords(const AValue: TWordsCollection); -begin - FWords.Assign(AValue); -end; - -procedure TSkLabel.SetWordsMouseOver(const AValue: TCustomWordsItem); -begin - if FWordsMouseOver <> AValue then - begin - FWordsMouseOver := AValue; - if not (csDesigning in ComponentState) and IsMouseOver then - begin - if Assigned(FWordsMouseOver) and (FWordsMouseOver.Cursor <> crDefault) then - Cursor := FWordsMouseOver.Cursor - else - Cursor := crDefault; - end; - end - else if Assigned(FWordsMouseOver) and (FWordsMouseOver.Cursor <> crDefault) then - Cursor := FWordsMouseOver.Cursor - else - Cursor := crDefault; -end; - -procedure TSkLabel.TextSettingsChanged(AValue: TObject); -begin - DeleteParagraph; - if not (csLoading in ComponentState) then - begin - if (not IsUpdating) and FAutoSize and HasFitSizeChanged then - SetSize(Width, Height) - else - Redraw; - end; -end; - -{$IF CompilerVersion >= 29} -function TSkLabel.TextStored: Boolean; -begin - Result := Text <> ''; -end; -{$ENDIF} - -procedure TSkLabel.WordsChange(ASender: TObject); -var - I: Integer; -begin - FHasCustomCursor := False; - for I := 0 to FWords.Count - 1 do - begin - if FWords[I].Cursor <> crDefault then - begin - FHasCustomCursor := True; - Break; - end; - end; - if FWords.Count = 0 then - FWords.Add - else - TextSettingsChanged(nil); -end; - -{ TSkDefaultProviders } - -class constructor TSkDefaultProviders.Create; -begin - FTypefaceFont := TSkTypefaceFontProvider.Create; -end; - -class procedure TSkDefaultProviders.RegisterTypeface(const AFileName: string); -begin - FTypefaceFont.RegisterTypeface(TSkTypeFace.MakeFromFile(AFileName)); -end; - -class procedure TSkDefaultProviders.RegisterTypeface(const AStream: TStream); -begin - FTypefaceFont.RegisterTypeface(TSkTypeFace.MakeFromStream(AStream)); -end; - -{ TSkTypefaceManager } - -class function TSkTypefaceManager.Provider: ISkTypefaceFontProvider; -begin - Result := TSkDefaultProviders.TypefaceFont; -end; - -class procedure TSkTypefaceManager.RegisterTypeface(const AFileName: string); -begin - TSkDefaultProviders.RegisterTypeface(AFileName); -end; - -class procedure TSkTypefaceManager.RegisterTypeface(const AStream: TStream); -begin - TSkDefaultProviders.RegisterTypeface(AStream); -end; - -{ Register } - -procedure Register; -begin - RegisterComponents('Skia', [TSkAnimatedImage, TSkAnimatedPaintBox, TSkLabel, TSkPaintBox, TSkStyleTextObject, TSkSvg]); -end; - -{$IFDEF MSWINDOWS} - {$HPPEMIT '#ifdef USEPACKAGES'} - {$HPPEMIT ' #pragma link "Skia.Package.FMX.bpi"'} - {$HPPEMIT '#elif defined(__WIN32__)'} - {$HPPEMIT ' #pragma link "Skia.Package.FMX.lib"'} - {$HPPEMIT '#elif defined(_WIN64)'} - {$HPPEMIT ' #pragma link "Skia.Package.FMX.a"'} - {$HPPEMIT '#endif'} -{$ENDIF} - -(*$HPPEMIT 'namespace Skia {'*) -(*$HPPEMIT ' namespace Fmx {'*) -(*$HPPEMIT ' namespace Types { using namespace ::Fmx::Types; }'*) -(*$HPPEMIT ' namespace Graphics { using namespace ::Fmx::Graphics; }'*) -(*$HPPEMIT ' namespace Controls { using namespace ::Fmx::Controls; }'*) -(*$HPPEMIT ' namespace Ani { using namespace ::Fmx::Ani; }'*) -(*$HPPEMIT ' namespace Actnlist { using namespace ::Fmx::Actnlist; }'*) -(*$HPPEMIT ' }'*) -(*$HPPEMIT '}'*) - -{$HPPEMIT NOUSINGNAMESPACE} -{$HPPEMIT END '#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_SKIA)'} -{$HPPEMIT END ' using ::Skia::Fmx::_di_ISkStyleTextObject;'} -{$HPPEMIT END ' using ::Skia::Fmx::_di_ISkTextSettings;'} -{$HPPEMIT END ' using ::Skia::Fmx::_di_TSkAnimationDrawProc;'} -{$HPPEMIT END ' using ::Skia::Fmx::_di_TSkDrawProc;'} -{$HPPEMIT END ' using ::Skia::Fmx::ESkBitmapHelper;'} -{$HPPEMIT END ' using ::Skia::Fmx::ESkFMX;'} -{$HPPEMIT END ' using ::Skia::Fmx::ESkLabel;'} -{$HPPEMIT END ' using ::Skia::Fmx::ESkPersistentData;'} -{$HPPEMIT END ' using ::Skia::Fmx::ESkTextSettingsInfo;'} -{$HPPEMIT END ' using ::Skia::Fmx::ISkStyleTextObject;'} -{$HPPEMIT END ' using ::Skia::Fmx::ISkTextSettings;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkAnimatedImage;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkAnimatedImageWrapMode;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkAnimatedPaintBox;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkAnimationDrawEvent;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkAnimationDrawProc;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkCustomAnimatedControl;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkCustomAnimation;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkCustomControl;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkCustomStyleTextObject;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkDefaultProviders;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkDrawCacheKind;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkDrawEvent;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkDrawProc;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkFontComponent;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkLabel;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkPaintBox;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkPersistent;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkStyledControl;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkStyleTextObject;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkSvg;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkSvgBrush;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkSvgSource;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkSvgWrapMode;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkTextHorzAlign;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkTextSettings;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkTextSettingsClass;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkTextSettingsInfo;'} -{$HPPEMIT END ' using ::Skia::Fmx::TSkTypefaceManager;'} -{$HPPEMIT END ' typedef void (__fastcall *TAddSkPathToPathDataProc)(::Fmx::Graphics::TPathData* const APathData, const ::Skia::_di_ISkPath ASkPath);'} -{$HPPEMIT END ' typedef ::Skia::_di_ISkImage (__fastcall *TBitmapToSkImageFunc)(::Fmx::Graphics::TBitmap* const ABitmap);'} -{$HPPEMIT END ' typedef ::Skia::_di_ISkPath (__fastcall *TPathDataToSkPathFunc)(::Fmx::Graphics::TPathData* const APathData);'} -{$HPPEMIT END ' typedef void (__fastcall *TSkiaDrawProc)(::Fmx::Graphics::TBitmap* const ABitmap, const ::Skia::Fmx::_di_TSkDrawProc AProc, const bool AStartClean);'} -{$HPPEMIT END ' typedef ::Fmx::Graphics::TBitmap* (__fastcall *TSkImageToBitmapFunc)(const ::Skia::_di_ISkImage AImage);'} -{$HPPEMIT END ' typedef ::Fmx::Graphics::TPathData* (__fastcall *TSkPathToPathDataFunc)(const ::Skia::_di_ISkPath ASkPath);'} -{$HPPEMIT END ' static const int SkSupportedPlatformsMask = ::Skia::Fmx::SkSupportedPlatformsMask;'} -{$HPPEMIT END ' static bool& GlobalDisableSkiaCodecsReplacement = ::Skia::Fmx::GlobalDisableSkiaCodecsReplacement;'} -{$HPPEMIT END ' static bool& GlobalUseSkia = ::Skia::Fmx::GlobalUseSkia;'} -{$HPPEMIT END ' static bool& GlobalUseSkiaRasterWhenAvailable = ::Skia::Fmx::GlobalUseSkiaRasterWhenAvailable;'} -{$HPPEMIT END ' static ::System::StaticArray<::Skia::TSkColorType, 24>& SkFmxColorType = ::Skia::Fmx::SkFmxColorType;'} -{$HPPEMIT END ' static ::System::StaticArray<::Fmx::Types::TPixelFormat, 23>& SkFmxPixelFormat = ::Skia::Fmx::SkFmxPixelFormat;'} -{$HPPEMIT END ' static const TAddSkPathToPathDataProc AddSkPathToPathData = ::Skia::Fmx::AddSkPathToPathData;'} -{$HPPEMIT END ' static const TBitmapToSkImageFunc BitmapToSkImage = ::Skia::Fmx::BitmapToSkImage;'} -{$HPPEMIT END ' static const TPathDataToSkPathFunc PathDataToSkPath = ::Skia::Fmx::PathDataToSkPath;'} -{$HPPEMIT END ' static const TSkiaDrawProc SkiaDraw = ::Skia::Fmx::SkiaDraw;'} -{$HPPEMIT END ' static const TSkImageToBitmapFunc SkImageToBitmap = ::Skia::Fmx::SkImageToBitmap;'} -{$HPPEMIT END ' static const TSkPathToPathDataFunc SkPathToPathData = ::Skia::Fmx::SkPathToPathData;'} -{$HPPEMIT END '#endif'} - -initialization - RegisterFMXClasses([TSkAnimatedImage, TSkAnimatedPaintBox, TSkCustomControl, TSkLabel, TSkPaintBox, - TSkStyledControl, TSkCustomStyleTextObject, TSkStyleTextObject, TSkSvgBrush, TSkSvg]); - RegisterFMXClasses([TSkAnimatedImage.TAnimation, TSkAnimatedPaintBox.TAnimation, TSkCustomAnimation, - TSkFontComponent, TSkTextSettings, TSkTextSettingsInfo, TSkTextSettings.TDecorations, - TSkLabel.TCustomWordsItem, TSkLabel.TWordsCollection]); - TSkAnimatedImage.RegisterCodec(TSkLottieAnimationCodec); - TSkAnimatedImage.RegisterCodec(TSkDefaultAnimationCodec); -end. diff --git a/skia4delphi/Source/Skia.Api.pas b/skia4delphi/Source/Skia.Api.pas deleted file mode 100644 index c3c145a..0000000 --- a/skia4delphi/Source/Skia.Api.pas +++ /dev/null @@ -1,4269 +0,0 @@ -{************************************************************************} -{ } -{ Skia4Delphi } -{ } -{ Copyright (c) 2011-2022 Google LLC. } -{ Copyright (c) 2021-2022 Skia4Delphi Project. } -{ } -{ Use of this source code is governed by a BSD-style license that can be } -{ found in the LICENSE file. } -{ } -{************************************************************************} -unit Skia.API; - -interface - -{$HPPEMIT NOUSINGNAMESPACE} -{$IFDEF MSWINDOWS} - {$HPPEMIT '#ifdef USEPACKAGES'} - {$HPPEMIT ' #pragma link "Skia.Package.RTL.bpi"'} - {$HPPEMIT '#elif defined(__WIN32__)'} - {$HPPEMIT ' #pragma link "Skia.Package.RTL.lib"'} - {$HPPEMIT '#elif defined(_WIN64)'} - {$HPPEMIT ' #pragma link "Skia.Package.RTL.a"'} - {$HPPEMIT '#endif'} -{$ENDIF} - -{.$DEFINE SK_DEBUG} - -{$ALIGN ON} -{$MINENUMSIZE 4} - -{$IF DEFINED(IOS) and NOT DEFINED(IOSSIMULATOR)} - {$DEFINE SK_STATIC_LIBRARY} -{$ENDIF} - -type - _bool = Boolean; - {$IF CompilerVersion < 31} - _char = AnsiChar; - {$ELSE} - _char = UTF8Char; - {$ENDIF} - char16_t = Char; - _double = Double; - float = Single; - int16_t = SmallInt; - int32_t = Integer; - int64_t = Int64; - int8_t = ShortInt; - intptr_t = NativeInt; - long = LongInt; - size_t = NativeUInt; - uint16_t = Word; - uint32_t = Cardinal; - uint64_t = UInt64; - uint8_t = Byte; - uintptr_t = NativeUInt; - - _pbool = ^_bool; - _pchar = ^_char; - pchar16_t = ^char16_t; - _pdouble = ^_double; - pfloat = ^float; - pint16_t = ^int16_t; - pint32_t = ^int32_t; - pint64_t = ^int64_t; - pint8_t = ^int8_t; - pintptr_t = ^intptr_t; - plong = ^long; - psize_t = ^size_t; - puint16_t = ^uint16_t; - puint32_t = ^uint32_t; - puint64_t = ^uint64_t; - puint8_t = ^uint8_t; - puintptr_t = ^uintptr_t; - - - { include/c/sk4d_types.h } - - sk_animcodecplayer_t = THandle; - sk_blender_t = THandle; - sk_canvas_t = THandle; - sk_codec_t = THandle; - sk_colorfilter_t = THandle; - sk_colorspace_t = THandle; - sk_colorspaceiccprofile_t = THandle; - sk_data_t = THandle; - sk_document_t = THandle; - sk_font_t = THandle; - sk_image_t = THandle; - sk_imagefilter_t = THandle; - sk_maskfilter_t = THandle; - sk_opbuilder_t = THandle; - sk_paint_t = THandle; - sk_path_t = THandle; - sk_pathbuilder_t = THandle; - sk_patheffect_t = THandle; - sk_pathiterator_t = THandle; - sk_pathmeasure_t = THandle; - sk_pathrawiter_t = THandle; - sk_picture_t = THandle; - sk_picturerecorder_t = THandle; - sk_pixmap_t = THandle; - sk_refcnt_t = THandle; - sk_region_t = THandle; - sk_regioncliperator_t = THandle; - sk_regioniterator_t = THandle; - sk_regionspanerator_t = THandle; - sk_rrect_t = THandle; - sk_runtimeeffect_t = THandle; - sk_shader_t = THandle; - sk_stream_t = THandle; - sk_streamadapter_t = THandle; - sk_string_t = THandle; - sk_surface_t = THandle; - sk_textblob_t = THandle; - sk_tracememorydump_t = THandle; - sk_tracememorydumpbaseclass_t = THandle; - sk_typeface_t = THandle; - sk_vertices_t = THandle; - sk_wstream_t = THandle; - sk_wstreamadapter_t = THandle; - - psk_animcodecplayer_t = ^sk_animcodecplayer_t; - psk_blender_t = ^sk_blender_t; - psk_canvas_t = ^sk_canvas_t; - psk_codec_t = ^sk_codec_t; - psk_colorfilter_t = ^sk_colorfilter_t; - psk_colorspace_t = ^sk_colorspace_t; - psk_colorspaceiccprofile_t = ^sk_colorspaceiccprofile_t; - psk_data_t = ^sk_data_t; - psk_document_t = ^sk_document_t; - psk_font_t = ^sk_font_t; - psk_image_t = ^sk_image_t; - psk_imagefilter_t = ^sk_imagefilter_t; - psk_maskfilter_t = ^sk_maskfilter_t; - psk_opbuilder_t = ^sk_opbuilder_t; - psk_paint_t = ^sk_paint_t; - psk_path_t = ^sk_path_t; - psk_pathbuilder_t = ^sk_pathbuilder_t; - psk_patheffect_t = ^sk_patheffect_t; - psk_pathiterator_t = ^sk_pathiterator_t; - psk_pathmeasure_t = ^sk_pathmeasure_t; - psk_pathrawiter_t = ^sk_pathrawiter_t; - psk_picture_t = ^sk_picture_t; - psk_picturerecorder_t = ^sk_picturerecorder_t; - psk_pixmap_t = ^sk_pixmap_t; - psk_refcnt_t = ^sk_refcnt_t; - psk_region_t = ^sk_region_t; - psk_regioncliperator_t = ^sk_regioncliperator_t; - psk_regioniterator_t = ^sk_regioniterator_t; - psk_regionspanerator_t = ^sk_regionspanerator_t; - psk_rrect_t = ^sk_rrect_t; - psk_runtimeeffect_t = ^sk_runtimeeffect_t; - psk_shader_t = ^sk_shader_t; - psk_stream_t = ^sk_stream_t; - psk_streamadapter_t = ^sk_streamadapter_t; - psk_string_t = ^sk_string_t; - psk_surface_t = ^sk_surface_t; - psk_textblob_t = ^sk_textblob_t; - psk_tracememorydump_t = ^sk_tracememorydump_t; - psk_tracememorydumpbaseclass_t = ^sk_tracememorydumpbaseclass_t; - psk_typeface_t = ^sk_typeface_t; - psk_vertices_t = ^sk_vertices_t; - psk_wstream_t = ^sk_wstream_t; - psk_wstreamadapter_t = ^sk_wstreamadapter_t; - - sk_alphatype_t = ( - UNKNOWN_SK_ALPHATYPE, - OPAQUE_SK_ALPHATYPE, - PREMUL_SK_ALPHATYPE, - UNPREMUL_SK_ALPHATYPE - ); - psk_alphatype_t = ^sk_alphatype_t; - - sk_blendmode_t = ( - CLEAR_SK_BLENDMODE, - SRC_SK_BLENDMODE, - DEST_SK_BLENDMODE, - SRC_OVER_SK_BLENDMODE, - DEST_OVER_SK_BLENDMODE, - SRC_IN_SK_BLENDMODE, - DEST_IN_SK_BLENDMODE, - SRC_OUT_SK_BLENDMODE, - DEST_OUT_SK_BLENDMODE, - SRC_A_TOP_SK_BLENDMODE, - DEST_A_TOP_SK_BLENDMODE, - XOR_SK_BLENDMODE, - PLUS_SK_BLENDMODE, - MODULATE_SK_BLENDMODE, - SCREEN_SK_BLENDMODE, - OVERLAY_SK_BLENDMODE, - DARKEN_SK_BLENDMODE, - LIGHTEN_SK_BLENDMODE, - COLOR_DODGE_SK_BLENDMODE, - COLOR_BURN_SK_BLENDMODE, - HARD_LIGHT_SK_BLENDMODE, - SOFT_LIGHT_SK_BLENDMODE, - DIFFERENCE_SK_BLENDMODE, - EXCLUSION_SK_BLENDMODE, - MULTIPLY_SK_BLENDMODE, - HUE_SK_BLENDMODE, - SATURATION_SK_BLENDMODE, - COLOR_SK_BLENDMODE, - LUMINOSITY_SK_BLENDMODE - ); - psk_blendmode_t = ^sk_blendmode_t; - - sk_blurstyle_t = ( - NORMAL_SK_BLURSTYLE, - SOLID_SK_BLURSTYLE, - OUTER_SK_BLURSTYLE, - INNER_SK_BLURSTYLE - ); - psk_blurstyle_t = ^sk_blurstyle_t; - - sk_clipop_t = ( - DIFFERENCE_SK_CLIPOP, - INTERSECT_SK_CLIPOP - ); - psk_clipop_t = ^sk_clipop_t; - - sk_colorchannel_t = ( - R_SK_COLORCHANNEL, - G_SK_COLORCHANNEL, - B_SK_COLORCHANNEL, - A_SK_COLORCHANNEL - ); - psk_colorchannel_t = ^sk_colorchannel_t; - - sk_colortype_t = ( - UNKNOWN_SK_COLORTYPE, - ALPHA8_SK_COLORTYPE, - RGB565_SK_COLORTYPE, - ARGB4444_SK_COLORTYPE, - RGBA8888_SK_COLORTYPE, - RGB888X_SK_COLORTYPE, - BGRA8888_SK_COLORTYPE, - RGBA1010102_SK_COLORTYPE, - BGRA1010102_SK_COLORTYPE, - RGB101010X_SK_COLORTYPE, - BGR101010X_SK_COLORTYPE, - GRAY8_SK_COLORTYPE, - RGBAF16_SK_COLORTYPE, - RGBAF16CLAMPED_SK_COLORTYPE, - RGBAF32_SK_COLORTYPE, - RG88_SK_COLORTYPE, - ALPHAF16_SK_COLORTYPE, - RGF16_SK_COLORTYPE, - ALPHA16_SK_COLORTYPE, - RG1616_SK_COLORTYPE, - RGBA16161616_SK_COLORTYPE, - SRGBA8888_SK_COLORTYPE, - R8_SK_COLORTYPE - ); - psk_colortype_t = ^sk_colortype_t; - - sk_drawpointsmode_t = ( - POINTS_SK_DRAWPOINTSMODE, - LINES_SK_DRAWPOINTSMODE, - POLYGON_DRAWPOINTSMODE - ); - psk_drawpointsmode_t = ^sk_drawpointsmode_t; - - sk_encodedimageformat_t = ( - BMP_SK_ENCODEDIMAGEFORMAT, - GIF_SK_ENCODEDIMAGEFORMAT, - ICO_SK_ENCODEDIMAGEFORMAT, - JPEG_SK_ENCODEDIMAGEFORMAT, - PNG_SK_ENCODEDIMAGEFORMAT, - WBMP_SK_ENCODEDIMAGEFORMAT, - WEBP_SK_ENCODEDIMAGEFORMAT, - PKM_SK_ENCODEDIMAGEFORMAT, - KTX_SK_ENCODEDIMAGEFORMAT, - ASTC_SK_ENCODEDIMAGEFORMAT, - DNG_SK_ENCODEDIMAGEFORMAT, - HEIF_SK_ENCODEDIMAGEFORMAT, - AVIF_SK_ENCODEDIMAGEFORMAT - ); - psk_encodedimageformat_t = ^sk_encodedimageformat_t; - - sk_filtermode_t = ( - NEAREST_SK_FILTERMODE, - LINEAR_SK_FILTERMODE - ); - psk_filtermode_t = ^sk_filtermode_t; - - sk_fontedging_t = ( - ALIAS_SK_FONTEDGING, - ANTI_ALIAS_SK_FONTEDGING, - SUBPIXEL_ANTI_ALIAS_SK_FONTEDGING - ); - psk_fontedging_t = ^sk_fontedging_t; - - sk_fonthinting_t = ( - NONE_SK_FONTHINTING, - SLIGHT_SK_FONTHINTING, - NORMAL_SK_FONTHINTING, - FULL_SK_FONTHINTING - ); - psk_fonthinting_t = ^sk_fonthinting_t; - - sk_fontslant_t = ( - UPRIGHT_SK_FONTSLANT, - ITALIC_SK_FONTSLANT, - OBLIQUE_SK_FONTSLANT - ); - psk_fontslant_t = ^sk_fontslant_t; - - sk_contrastinvertstyle_t = ( - NO_INVERT_SK_CONTRASTINVERTSTYLE, - INVERT_BRIGHTNESS_SK_CONTRASTINVERTSTYLE, - INVERT_LIGHTNESS_SK_CONTRASTINVERTSTYLE - ); - psk_contrastinvertstyle_t = ^sk_contrastinvertstyle_t; - - sk_imagecachinghint_t = ( - ALLOW_SK_IMAGECACHINGHINT, - DISALLOW_SK_IMAGECACHINGHINT - ); - psk_imagecachinghint_t = ^sk_imagecachinghint_t; - - sk_latticerecttype_t = ( - DEFAULT_SK_LATTICERECTTYPE, - TRANSPARENT_SK_LATTICERECTTYPE, - FIXED_COLOR_SK_LATTICERECTTYPE - ); - psk_latticerecttype_t = ^sk_latticerecttype_t; - - sk_mipmapmode_t = ( - NONE_SK_MIPMAPMODE, - NEAREST_SK_MIPMAPMODE, - LINEAR_SK_MIPMAPMODE - ); - psk_mipmapmode_t = ^sk_mipmapmode_t; - - sk_paintstyle_t = ( - FILL_SK_PAINTSTYLE, - STROKE_SK_PAINTSTYLE, - STROKE_AND_FILL_SK_PAINTSTYLE - ); - psk_paintstyle_t = ^sk_paintstyle_t; - - sk_patharcsize_t = ( - SMALL_SK_ARCSIZE, - LARGE_SK_ARCSIZE - ); - psk_patharcsize_t = ^sk_patharcsize_t; - - sk_pathdirection_t = ( - CW_SK_PATHDIRECTION, - CCW_SK_PATHDIRECTION - ); - psk_pathdirection_t = ^sk_pathdirection_t; - - sk_patheffect1dstyle_t = ( - TRANSLATE_SK_PATHEFFECT1DSTYLE, - ROTATE_SK_PATHEFFECT1DSTYLE, - MORPH_SK_PATHEFFECT1DSTYLE - ); - psk_patheffect1dstyle_t = ^sk_patheffect1dstyle_t; - - sk_patheffecttrimmode_t = ( - NORMAL_SK_PATHEFFECTTRIMMODE, - INVERTED_SK_PATHEFFECTTRIMMODE - ); - psk_patheffecttrimmode_t = ^sk_patheffecttrimmode_t; - - sk_pathfilltype_t = ( - WINDING_SK_PATHFILLTYPE, - EVEN_ODD_SK_PATHFILLTYPE, - INVERSE_WINDING_SK_PATHFILLTYPE, - INVERSE_EVEN_ODD_SK_PATHFILLTYPE - ); - psk_pathfilltype_t = ^sk_pathfilltype_t; - - sk_pathop_t = ( - DIFFERENCE_SK_PATHOP, - INTERSECT_SK_PATHOP, - UNION_SK_PATHOP, - XOR_SK_PATHOP, - REVERSE_DIFFERENCE_SK_PATHOP - ); - psk_pathop_t = ^sk_pathop_t; - - sk_pathverb_t = ( - MOVE_SK_PATHVERB, - LINE_SK_PATHVERB, - QUAD_SK_PATHVERB, - CONIC_SK_PATHVERB, - CUBIC_SK_PATHVERB, - CLOSE_SK_PATHVERB - ); - psk_pathverb_t = ^sk_pathverb_t; - - sk_pixelgeometry_t = ( - UNKNOWN_SK_PIXELGEOMETRY, - RGB_HORIZONTAL_SK_PIXELGEOMETRY, - BGR_HORIZONTAL_SK_PIXELGEOMETRY, - RGB_VERTICAL_SK_PIXELGEOMETRY, - BGR_VERTICAL_SK_PIXELGEOMETRY - ); - psk_pixelgeometry_t = ^sk_pixelgeometry_t; - - sk_regionop_t = ( - DIFFERENCE_SK_REGIONOP, - INTERSECT_SK_REGIONOP, - UNION_SK_REGIONOP, - XOR_SK_REGIONOP, - REVERSE_DIFFERENCE_SK_REGIONOP, - REPLACE_SK_REGIONOP - ); - psk_regionop_t = ^sk_regionop_t; - - sk_rrectcorner_t = ( - UPPER_LEFT_SK_RRECTCORNER, - UPPER_RIGHT_SK_RRECTCORNER, - LOWER_RIGHT_SK_RRECTCORNER, - LOWER_LEFT_SK_RRECTCORNER - ); - psk_rrectcorner_t = ^sk_rrectcorner_t; - - sk_runtimeeffectchildtype_t = ( - SHADER_SK_RUNTIMEEFFECTCHILDTYPE, - COLOR_FILTER_SK_RUNTIMEEFFECTCHILDTYPE, - BLENDER_FILTER_SK_RUNTIMEEFFECTCHILDTYPE - ); - psk_runtimeeffectchildtype_t = ^sk_runtimeeffectchildtype_t; - - sk_runtimeeffectuniformtype_t = ( - FLOAT_SK_RUNTIMEEFFECTUNIFORMTYPE, - FLOAT2_SK_RUNTIMEEFFECTUNIFORMTYPE, - FLOAT3_SK_RUNTIMEEFFECTUNIFORMTYPE, - FLOAT4_SK_RUNTIMEEFFECTUNIFORMTYPE, - FLOAT2X2_SK_RUNTIMEEFFECTUNIFORMTYPE, - FLOAT3X3_SK_RUNTIMEEFFECTUNIFORMTYPE, - FLOAT4X4_SK_RUNTIMEEFFECTUNIFORMTYPE, - INT_SK_RUNTIMEEFFECTUNIFORMTYPE, - INT2_SK_RUNTIMEEFFECTUNIFORMTYPE, - INT3_SK_RUNTIMEEFFECTUNIFORMTYPE, - INT4_SK_RUNTIMEEFFECTUNIFORMTYPE - ); - psk_runtimeeffectuniformtype_t = ^sk_runtimeeffectuniformtype_t; - - sk_srcrectconstraint_t = ( - CLOSE_SK_SRCRECTCONSTRAINT, - FAST_SK_SRCRECTCONSTRAINT - ); - psk_srcrectconstraint_t = ^sk_srcrectconstraint_t; - - sk_strokecap_t = ( - BUTT_SK_STROKECAP, - ROUND_SK_STROKECAP, - SQUARE_SK_STROKECAP - ); - psk_strokecap_t = ^sk_strokecap_t; - - sk_strokejoin_t = ( - MITER_SK_STROKEJOIN, - ROUND_SK_STROKEJOIN, - BEVEL_SK_STROKEJOIN - ); - psk_strokejoin_t = ^sk_strokejoin_t; - - sk_textencoding_t = ( - UTF8_SK_TEXTENCODING, - UTF16_SK_TEXTENCODING, - UTF32_SK_TEXTENCODING, - GLYPH_ID_SK_TEXTENCODING - ); - psk_textencoding_t = ^sk_textencoding_t; - - sk_tilemode_t = ( - CLAMP_SK_TILEMODE, - REPEAT_SK_TILEMODE, - MIRROR_SK_TILEMODE, - DECAL_SK_TILEMODE - ); - psk_tilemode_t = ^sk_tilemode_t; - - sk_vertexmode_t = ( - TRIANGLES_SK_VERTEXMODE, - TRIANGLE_STRIP_SK_VERTEXMODE, - TRIANGLE_FAN_SK_VERTEXMODE - ); - psk_vertexmode_t = ^sk_vertexmode_t; - - sk_color_t = uint32_t; - sk_glyphid_t = uint16_t; - sk_unichar_t = int32_t; - - psk_color_t = ^sk_color_t; - psk_glyphid_t = ^sk_glyphid_t; - psk_unichar_t = ^sk_unichar_t; - - sk_color4f_t = record - r: float; - g: float; - b: float; - a: float; - end; - psk_color4f_t = ^sk_color4f_t; - - sk_colormatrix_t = record - m_11: float; - m_12: float; - m_13: float; - m_14: float; - m_15: float; - m_21: float; - m_22: float; - m_23: float; - m_24: float; - m_25: float; - m_31: float; - m_32: float; - m_33: float; - m_34: float; - m_35: float; - m_41: float; - m_42: float; - m_43: float; - m_44: float; - m_45: float; - end; - psk_colormatrix_t = ^sk_colormatrix_t; - - sk_colorspaceprimaries_t = record - rx: float; - ry: float; - gx: float; - gy: float; - bx: float; - by: float; - wx: float; - wy: float; - end; - psk_colorspaceprimaries_t = ^sk_colorspaceprimaries_t; - - sk_colorspacetransferfn_t = record - g: float; - a: float; - b: float; - c: float; - d: float; - e: float; - f: float; - end; - psk_colorspacetransferfn_t = ^sk_colorspacetransferfn_t; - - sk_colorspacexyz_t = record - m_11: float; - m_12: float; - m_13: float; - m_21: float; - m_22: float; - m_23: float; - m_31: float; - m_32: float; - m_33: float; - end; - psk_colorspacexyz_t = ^sk_colorspacexyz_t; - - sk_cubicresampler_t = record - b: float; - c: float; - end; - psk_cubicresampler_t = ^sk_cubicresampler_t; - - sk_datetime_t = record - time_zone_minutes : int16_t; - year : uint16_t; - month : uint8_t; - day_of_week : uint8_t; - day : uint8_t; - hour : uint8_t; - minute : uint8_t; - second : uint8_t; - end; - psk_datetime_t = ^sk_datetime_t; - - sk_fontmetrics_t = record - flags : uint32_t; - top : float; - ascent : float; - descent : float; - bottom : float; - leading : float; - avg_char_width : float; - max_char_width : float; - x_min : float; - x_max : float; - x_height : float; - cap_height : float; - underline_thickness : float; - underline_position : float; - strikeout_thickness : float; - strikeout_position : float; - end; - psk_fontmetrics_t = ^sk_fontmetrics_t; - - sk_fontstyle_t = record - weight : int32_t; - width : int32_t; - slant : sk_fontslant_t; - end; - psk_fontstyle_t = ^sk_fontstyle_t; - - sk_highcontrastconfig_t = record - grayscale : _bool; - invert_style : sk_contrastinvertstyle_t; - contrast : float; - end; - psk_highcontrastconfig_t = ^sk_highcontrastconfig_t; - - sk_imageinfo_t = record - width : int32_t; - height : int32_t; - color_type : sk_colortype_t; - alpha_type : sk_alphatype_t; - color_space : sk_colorspace_t; - end; - psk_imageinfo_t = ^sk_imageinfo_t; - - sk_ipoint_t = record - x: int32_t; - y: int32_t; - end; - psk_ipoint_t = ^sk_ipoint_t; - - sk_irect_t = record - left : int32_t; - top : int32_t; - right : int32_t; - bottom : int32_t; - end; - psk_irect_t = ^sk_irect_t; - - sk_isize_t = record - width : int32_t; - height : int32_t; - end; - psk_isize_t = ^sk_isize_t; - - sk_lattice_t = record - x_divs : pint32_t; - y_divs : pint32_t; - rect_types : psk_latticerecttype_t; - x_count : int32_t; - y_count : int32_t; - bounds : psk_irect_t; - colors : psk_color_t; - end; - psk_lattice_t = ^sk_lattice_t; - - sk_matrix_t = record - m_11: float; - m_12: float; - m_13: float; - m_21: float; - m_22: float; - m_23: float; - m_31: float; - m_32: float; - m_33: float; - end; - psk_matrix_t = ^sk_matrix_t; - - sk_matrix44_t = record - m_11: float; - m_12: float; - m_13: float; - m_14: float; - m_21: float; - m_22: float; - m_23: float; - m_24: float; - m_31: float; - m_32: float; - m_33: float; - m_34: float; - m_41: float; - m_42: float; - m_43: float; - m_44: float; - end; - psk_matrix44_t = ^sk_matrix44_t; - - sk_point_t = record - x: float; - y: float; - end; - psk_point_t = ^sk_point_t; - - sk_pathiteratorelem_t = record - verb : sk_pathverb_t; - points : array[0..3] of sk_point_t; - conic_weight : float; - end; - psk_pathiteratorelem_t = ^sk_pathiteratorelem_t; - - sk_pdfmetadata_t = record - title : MarshaledAString; - author : MarshaledAString; - subject : MarshaledAString; - keywords : MarshaledAString; - creator : MarshaledAString; - producer : MarshaledAString; - creation : sk_datetime_t; - modified : sk_datetime_t; - raster_dpi : float; - pdfa : _bool; - encoding_quality : int32_t; - end; - psk_pdfmetadata_t = ^sk_pdfmetadata_t; - - sk_point3_t = record - x: float; - y: float; - z: float; - end; - psk_point3_t = ^sk_point3_t; - - sk_rect_t = record - left : float; - top : float; - right : float; - bottom : float; - end; - psk_rect_t = ^sk_rect_t; - - sk_rotationscalematrix_t = record - s_cos : float; - s_sin : float; - t_x : float; - t_y : float; - end; - psk_rotationscalematrix_t = ^sk_rotationscalematrix_t; - - sk_samplingoptions_t = record - max_anisotropic : int32_t; - use_cubic : _bool; - cubic : sk_cubicresampler_t; - filter : sk_filtermode_t; - mipmap : sk_mipmapmode_t; - end; - psk_samplingoptions_t = ^sk_samplingoptions_t; - - sk_size_t = record - width : float; - height : float; - end; - psk_size_t = ^sk_size_t; - - sk_surfaceprops_t = record - flags : uint32_t; - pixel_geometry : sk_pixelgeometry_t; - end; - psk_surfaceprops_t = ^sk_surfaceprops_t; - - sk_vector_t = sk_point_t; - psk_vector_t = ^sk_vector_t; - - sk_font_path_proc = procedure (const path: sk_path_t; const matrix: psk_matrix_t; context: Pointer); cdecl; - sk_image_raster_release_proc = procedure (const pixels: Pointer; context: Pointer); cdecl; - sk_image_texture_release_proc = procedure (context: Pointer); cdecl; - sk_surface_raster_release_proc = procedure (pixels, context: Pointer); cdecl; - - sk_streamadapter_procs_t = record - get_length : function (context: Pointer): size_t; cdecl; - get_position : function (context: Pointer): size_t; cdecl; - read : function (context: Pointer; buffer: Pointer; size: size_t): size_t; cdecl; - seek : function (context: Pointer; position: size_t): _bool; cdecl; - end; - psk_streamadapter_procs_t = ^sk_streamadapter_procs_t; - - sk_wstreamadapter_procs_t = record - write: function (context: Pointer; const buffer: Pointer; size: size_t): _bool; cdecl; - end; - psk_wstreamadapter_procs_t = ^sk_wstreamadapter_procs_t; - - sk_tracememorydumpbaseclass_procs_t = record - dump_numeric_value : procedure (context: Pointer; const dump_name, value_name, units: MarshaledAString; value: uint64_t); cdecl; - dump_string_value : procedure (context: Pointer; const dump_name, value_name, value: MarshaledAString); cdecl; - end; - psk_tracememorydumpbaseclass_procs_t = ^sk_tracememorydumpbaseclass_procs_t; - - // Ganesh - - gr_backendrendertarget_t = THandle; - gr_backendtexture_t = THandle; - gr_directcontext_t = THandle; - gr_persistentcache_t = THandle; - gr_persistentcachebaseclass_t = THandle; - gr_shadererrorhandler_t = THandle; - gr_shadererrorhandlerbaseclass_t = THandle; - - pgr_backendrendertarget_t = ^gr_backendrendertarget_t; - pgr_backendtexture_t = ^gr_backendtexture_t; - pgr_directcontext_t = ^gr_directcontext_t; - pgr_persistentcache_t = ^gr_persistentcache_t; - pgr_persistentcachebaseclass_t = ^gr_persistentcachebaseclass_t; - pgr_shadererrorhandler_t = ^gr_shadererrorhandler_t; - pgr_shadererrorhandlerbaseclass_t = ^gr_shadererrorhandlerbaseclass_t; - - gr_backendapi_t = ( - OPEN_GL_GR_BACKENDAPI, - VULKAN_GR_BACKENDAPI, - METAL_GR_BACKENDAPI - ); - pgr_backendapi_t = ^gr_backendapi_t; - - gr_shadercachestrategy_t = ( - SKSL_GR_SHADERCACHESTRATEGY, - BACKEND_SOURCE_GR_SHADERCACHESTRATEGY, - BACKEND_BINARY_GR_SHADERCACHESTRATEGY - ); - pgr_shadercachestrategy_t = ^gr_shadercachestrategy_t; - - gr_surfaceorigin_t = ( - TOP_LEFT_GR_SURFACEORIGIN, - BOTTOM_LEFT_GR_SURFACEORIGIN - ); - pgr_surfaceorigin_t = ^gr_surfaceorigin_t; - - gr_contextoptions_t = record - buffer_map_threshold : int32_t; - do_manual_mipmapping : _bool; - allow_path_mask_caching : _bool; - glyph_cache_texture_maximum_bytes : size_t; - avoid_stencil_buffers : _bool; - runtime_program_cache_size : int32_t; - persistent_cache : gr_persistentcache_t; - shader_cache_strategy : gr_shadercachestrategy_t; - shader_error_handler : gr_shadererrorhandler_t; - end; - pgr_contextoptions_t = ^gr_contextoptions_t; - - gr_persistentcachebaseclass_procs_t = record - load : function (context: Pointer; const key_data: Pointer; key_size: size_t): sk_data_t; cdecl; - store : procedure (context: Pointer; const key_data: Pointer; key_size: size_t; const data: Pointer; size: size_t); cdecl; - end; - pgr_persistentcachebaseclass_procs_t = ^gr_persistentcachebaseclass_procs_t; - - gr_shadererrorhandlerbaseclass_procs_t = record - compile_error : procedure (context: Pointer; const shader, errors: MarshaledAString); cdecl; - end; - pgr_shadererrorhandlerbaseclass_procs_t = ^gr_shadererrorhandlerbaseclass_procs_t; - - // Ganesh - OpenGL - - gr_gl_interface_t = THandle; - - pgr_gl_interface_t = ^gr_gl_interface_t; - - gl_enum_t = uint32_t; - gl_uint_t = uint32_t; - - pgl_enum_t = ^gl_enum_t; - pgl_uint_t = ^gl_uint_t; - - gr_gl_framebufferinfo_t = record - fboid : gl_uint_t; - format : gl_enum_t; - end; - pgr_gl_framebufferinfo_t = ^gr_gl_framebufferinfo_t; - - gr_gl_textureinfo_t = record - target : gl_enum_t; - id : gl_uint_t; - format : gl_enum_t; - end; - pgr_gl_textureinfo_t = ^gr_gl_textureinfo_t; - - gr_gl_get_proc = function (context: Pointer; const name: MarshaledAString): Pointer; cdecl; - - // Ganesh - Metal - - gr_mtl_handle_t = Pointer; - - gr_mtl_textureinfo_t = record - texture: gr_mtl_handle_t; - end; - pgr_mtl_textureinfo_t = ^gr_mtl_textureinfo_t; - - gr_mtl_backendcontext_t = record - device : gr_mtl_handle_t; - queue : gr_mtl_handle_t; - binary_archive : gr_mtl_handle_t; - end; - pgr_mtl_backendcontext_t = ^gr_mtl_backendcontext_t; - - // Ganesh - Vulkan - - gr_vk_extensions_t = THandle; - gr_vk_physicaldevicefeatures_t = THandle; - gr_vk_physicaldevicefeatures2_t = THandle; - - pgr_vk_extensions_t = ^gr_vk_extensions_t; - pgr_vk_physicaldevicefeatures_t = ^gr_vk_physicaldevicefeatures_t; - pgr_vk_physicaldevicefeatures2_t = ^gr_vk_physicaldevicefeatures2_t; - - gr_vk_bool32_t = uint32_t; - gr_vk_chromalocation_t = int32_t; - gr_vk_device_t = Pointer; - gr_vk_devicememory_t = uint64_t; - gr_vk_devicesize_t = uint64_t; - gr_vk_filter_t = int32_t; - gr_vk_format_t = int32_t; - gr_vk_formatfeatureflags_t = uint32_t; - gr_vk_image_t = uint64_t; - gr_vk_imagelayout_t = int32_t; - gr_vk_imagetiling_t = int32_t; - gr_vk_imageusageflags_t = uint32_t; - gr_vk_instance_t = Pointer; - gr_vk_physicaldevice_t = Pointer; - gr_vk_queue_t = Pointer; - gr_vk_samplerycbcrmodelconversion_t = int32_t; - gr_vk_samplerycbcrrange_t = int32_t; - gr_vk_sharingmode_t = int32_t; - - pgr_vk_bool32_t = ^gr_vk_bool32_t; - pgr_vk_chromalocation_t = ^gr_vk_chromalocation_t; - pgr_vk_device_t = ^gr_vk_device_t; - pgr_vk_devicememory_t = ^gr_vk_devicememory_t; - pgr_vk_devicesize_t = ^gr_vk_devicesize_t; - pgr_vk_filter_t = ^gr_vk_filter_t; - pgr_vk_format_t = ^gr_vk_format_t; - pgr_vk_formatfeatureflags_t = ^gr_vk_formatfeatureflags_t; - pgr_vk_image_t = ^gr_vk_image_t; - pgr_vk_imagelayout_t = ^gr_vk_imagelayout_t; - pgr_vk_imagetiling_t = ^gr_vk_imagetiling_t; - pgr_vk_imageusageflags_t = ^gr_vk_imageusageflags_t; - pgr_vk_instance_t = ^gr_vk_instance_t; - pgr_vk_physicaldevice_t = ^gr_vk_physicaldevice_t; - pgr_vk_queue_t = ^gr_vk_queue_t; - pgr_vk_samplerycbcrmodelconversion_t = ^gr_vk_samplerycbcrmodelconversion_t; - pgr_vk_samplerycbcrrange_t = ^gr_vk_samplerycbcrrange_t; - pgr_vk_sharingmode_t = ^gr_vk_sharingmode_t; - - gr_vk_get_proc = function (context: Pointer; const name: MarshaledAString; instance: gr_vk_instance_t; device: gr_vk_device_t): Pointer; cdecl; - - gr_vk_alloc_t = record - device_memory : gr_vk_devicememory_t; - offset : gr_vk_devicesize_t; - size : gr_vk_devicesize_t; - flags : uint32_t; - memory : intptr_t; - end; - pgr_vk_alloc_t = ^gr_vk_alloc_t; - - - gr_vk_backendcontext_t = record - instance : gr_vk_instance_t; - physical_device : gr_vk_physicaldevice_t; - device : gr_vk_device_t; - queue : gr_vk_queue_t; - graphics_queue_index : uint32_t; - max_version : uint32_t; - extensions : gr_vk_extensions_t; - physical_device_features : gr_vk_physicaldevicefeatures_t; - physical_device_features2 : gr_vk_physicaldevicefeatures2_t; - get_context : Pointer; - get_proc : gr_vk_get_proc; - protected_context : _bool; - end; - pgr_vk_backendcontext_t = ^gr_vk_backendcontext_t; - - gr_vk_ycbcrconversioninfo_t = record - format : gr_vk_format_t; - external_format : uint64_t; - ycbcr_model : gr_vk_samplerycbcrmodelconversion_t; - ycbcr_range : gr_vk_samplerycbcrrange_t; - x_chroma_offset : gr_vk_chromalocation_t; - y_chroma_offset : gr_vk_chromalocation_t; - chroma_filter : gr_vk_filter_t; - force_explicit_reconstruction : gr_vk_bool32_t; - format_features : gr_vk_formatfeatureflags_t; - end; - pgr_vk_ycbcrconversioninfo_t = ^gr_vk_ycbcrconversioninfo_t; - - gr_vk_imageinfo_t = record - image : gr_vk_image_t; - alloc : gr_vk_alloc_t; - image_tiling : gr_vk_imagetiling_t; - image_layout : gr_vk_imagetiling_t; - format : gr_vk_format_t; - image_usage_flags : gr_vk_imageusageflags_t; - sample_count : uint32_t; - level_count : uint32_t; - current_queue_family : uint32_t; - protected_image : _bool; - ycbcr_conversion_info : gr_vk_ycbcrconversioninfo_t; - sharing_mode : gr_vk_sharingmode_t; - end; - pgr_vk_imageinfo_t = ^gr_vk_imageinfo_t; - - { modules/particles/include/sk4d_particles_types.h } - - sk_particleeffect_t = THandle; - - psk_particleeffect_t = ^sk_particleeffect_t; - - sk_particleuniform_t = record - columns : int32_t; - rows : int32_t; - slot : int32_t; - end; - psk_particleuniform_t = ^sk_particleuniform_t; - - - { modules/skottie/include/sk4d_skottie_types.h } - - sk_skottieanimation_t = THandle; - - psk_skottieanimation_t = ^sk_skottieanimation_t; - - - { modules/skparagraph/include/sk4d_paragraph_types.h } - - sk_paragraph_t = THandle; - sk_paragraphbuilder_t = THandle; - sk_paragraphstyle_t = THandle; - sk_strutstyle_t = THandle; - sk_textstyle_t = THandle; - sk_typefacefontprovider_t = THandle; - - psk_paragraph_t = ^sk_paragraph_t; - psk_paragraphbuilder_t = ^sk_paragraphbuilder_t; - psk_paragraphstyle_t = ^sk_paragraphstyle_t; - psk_strutstyle_t = ^sk_strutstyle_t; - psk_textstyle_t = ^sk_textstyle_t; - psk_typefacefontprovider_t = ^sk_typefacefontprovider_t; - - sk_affinity_t = ( - UPSTREAM_SK_AFFINITY, - DOWNSTREAM_SK_AFFINITY - ); - psk_affinity_t = ^sk_affinity_t; - - sk_placeholderalignment_t = ( - BASELINE_SK_PLACEHOLDERALIGNMENT, - ABOVE_BASELINE_SK_PLACEHOLDERALIGNMENT, - BELOW_BASELINE_SK_PLACEHOLDERALIGNMENT, - TOP_SK_PLACEHOLDERALIGNMENT, - BOTTOM_SK_PLACEHOLDERALIGNMENT, - MIDDLE_SK_PLACEHOLDERALIGNMENT - ); - psk_placeholderalignment_t = ^sk_placeholderalignment_t; - - sk_rectheightstyle_t = ( - TIGHT_SK_RECTHEIGHTSTYLE, - MAX_SK_RECTHEIGHTSTYLE, - INCLUDE_LINE_SPACING_MIDDLE_SK_RECTHEIGHTSTYLE, - INCLUDE_LINE_SPACING_TOP_SK_RECTHEIGHTSTYLE, - INCLUDE_LINE_SPACING_BOTTOM_SK_RECTHEIGHTSTYLE, - STRUT_SK_RECTHEIGHTSTYLE - ); - psk_rectheightstyle_t = ^sk_rectheightstyle_t; - - sk_rectwidthstyle_t = ( - TIGHT_SK_RECTWIDTHSTYLE, - MAX_SK_RECTWIDTHSTYLE - ); - psk_rectwidthstyle_t = ^sk_rectwidthstyle_t; - - sk_textalign_t = ( - LEFT_SK_TEXTALIGN, - RIGHT_SK_TEXTALIGN, - CENTER_SK_TEXTALIGN, - JUSTIFY_SK_TEXTALIGN, - START_SK_TEXTALIGN, - TERMINATE_SK_TEXTALIGN - ); - psk_textalign_t = ^sk_textalign_t; - - sk_textbaseline_t = ( - ALPHABETIC_SK_TEXTBASELINE, - IDEOGRAPHIC_SK_TEXTBASELINE - ); - psk_textbaseline_t = ^sk_textbaseline_t; - - sk_textdecorationstyle_t = ( - SOLID_SK_TEXTDECORATIONSTYLE, - DOUBLE_SK_TEXTDECORATIONSTYLE, - DOTTED_SK_TEXTDECORATIONSTYLE, - DASHED_SK_TEXTDECORATIONSTYLE, - WAVY_SK_TEXTDECORATIONSTYLE - ); - psk_textdecorationstyle_t = ^sk_textdecorationstyle_t; - - sk_textdirection_t = ( - RIGHT_TO_LEFT_SK_TEXTDIRECTION, - LEFT_TO_RIGHT_SK_TEXTDIRECTION - ); - psk_textdirection_t = ^sk_textdirection_t; - - sk_metrics_t = record - start_index : size_t; - end_index : size_t; - end_excluding_whitespaces : size_t; - end_including_newline : size_t; - is_hard_break : _bool; - ascent : _double; - descent : _double; - height : _double; - width : _double; - left : _double; - baseline : _double; - line_number : size_t; - end; - psk_metrics_t = ^sk_metrics_t; - - sk_paragraphvisitorinfo_t = record - font : sk_font_t; - origin : sk_point_t; - advance_x : float; - count : int32_t; - glyphs : puint16_t; - positions : psk_point_t; - utf8_starts : puint32_t; - flags : uint32_t; - end; - psk_paragraphvisitorinfo_t = ^sk_paragraphvisitorinfo_t; - - sk_placeholderstyle_t = record - width : float; - height : float; - alignment : sk_placeholderalignment_t; - baseline : sk_textbaseline_t; - baseline_offset : float; - end; - psk_placeholderstyle_t = ^sk_placeholderstyle_t; - - sk_positionaffinity_t = record - position: int32_t; - affinity: sk_affinity_t; - end; - psk_positionaffinity_t = ^sk_positionaffinity_t; - - sk_textbox_t = record - rect : sk_rect_t; - direction : sk_textdirection_t; - end; - psk_textbox_t = ^sk_textbox_t; - - sk_textshadow_t = record - color : sk_color_t; - offset : sk_point_t; - blur_radius : _double; - end; - psk_textshadow_t = ^sk_textshadow_t; - - sk_paragraph_visit_proc = procedure (line_number: int32_t; const info: psk_paragraphvisitorinfo_t; context: Pointer); cdecl; - - - { modules/skresources/include/sk4d_resources_types.h } - - sk_resourceprovider_t = THandle; - sk_resourceproviderbaseclass_t = THandle; - - psk_resourceprovider_t = ^sk_resourceprovider_t; - psk_resourceproviderbaseclass_t = ^sk_resourceproviderbaseclass_t; - - sk_resourceproviderbaseclass_procs_t = record - load: function (context: Pointer; const path, name: MarshaledAString): sk_data_t; cdecl; - end; - psk_resourceproviderbaseclass_procs_t = ^sk_resourceproviderbaseclass_procs_t; - - - { modules/skshaper/include/sk4d_shaper_types.h } - - sk_shaper_t = THandle; - - psk_shaper_t = ^sk_shaper_t; - - - { modules/skunicode/include/sk4d_unicode_types.h } - - sk_unicode_t = THandle; - sk_unicodebreakiterator_t = THandle; - - psk_unicode_t = ^sk_unicode_t; - psk_unicodebreakiterator_t = ^sk_unicodebreakiterator_t; - - sk_breaktype_t = ( - WORDS_SK_BREAKTYPE, - GRAPHEMES_SK_BREAKTYPE, - LINES_SK_BREAKTYPE - ); - psk_breaktype_t = ^sk_breaktype_t; - - sk_direction_t = ( - LEFT_TO_RIGHT_SK_DIRECTION, - RIGHT_TO_LEFT_SK_DIRECTION - ); - psk_direction_t = ^sk_direction_t; - - sk_unicodebreakiteratorelem_t = record - position: int32_t; - status: int32_t; - end; - psk_unicodebreakiteratorelem_t = ^sk_unicodebreakiteratorelem_t; - - sk_unicode_bidi_region_proc = procedure (start, &end: int32_t; level: uint8_t; context: Pointer); cdecl; - sk_unicode_break_proc = procedure (position, status: int32_t; context: Pointer); cdecl; - sk_unicode_codepoint_proc = procedure (uni_char: sk_unichar_t; start, &end: int32_t; context: Pointer); cdecl; - - - { modules/svg/include/sk4d_svg_types.h } - - sk_svgdom_t = THandle; - sk_svgsvg_t = THandle; - sk_svgnode_t = THandle; - - psk_svgdom_t = ^sk_svgdom_t; - psk_svgsvg_t = ^sk_svgsvg_t; - psk_svgnode_t = ^sk_svgnode_t; - - sk_svglengthunit_t = ( - UNKNOWN_SK_SVGLENGTHUNIT, - NUMBER_SK_SVGLENGTHUNIT, - PERCENTAGE_SK_SVGLENGTHUNIT, - EMS_SK_SVGLENGTHUNIT, - EXS_SK_SVGLENGTHUNIT, - PX_SK_SVGLENGTHUNIT, - CM_SK_SVGLENGTHUNIT, - MM_SK_SVGLENGTHUNIT, - IN_SK_SVGLENGTHUNIT, - PT_SK_SVGLENGTHUNIT, - PC_SK_SVGLENGTHUNIT - ); - psk_svglengthunit_t = ^sk_svglengthunit_t; - - sk_svgaspectalign_t = ( - X_MIN_Y_MIN_SK_SVGASPECTALIGN, - X_MID_Y_MIN_SK_SVGASPECTALIGN, - X_MAX_Y_MIN_SK_SVGASPECTALIGN, - X_MIN_Y_MID_SK_SVGASPECTALIGN = 4, - X_MID_Y_MID_SK_SVGASPECTALIGN, - X_MAX_Y_MID_SK_SVGASPECTALIGN, - X_MIN_Y_MAX_SK_SVGASPECTALIGN = 8, - X_MID_Y_MAX_SK_SVGASPECTALIGN, - X_MAX_Y_MAX_SK_SVGASPECTALIGN, - NONE_SK_SVGASPECTALIGN = 16 - ); - psk_svgaspectalign_t = ^sk_svgaspectalign_t; - - sk_svgaspectscale_t = ( - MEET_SK_SVGASPECTSCALE, - SLICE_SK_SVGASPECTSCALE - ); - psk_svgaspectscale_t = ^sk_svgaspectscale_t; - - sk_svglength_t = record - value: float; - &unit: sk_svglengthunit_t; - end; - psk_svglength_t = ^sk_svglength_t; - - sk_svgpreserveaspectratio_t = record - align: sk_svgaspectalign_t; - scale: sk_svgaspectscale_t; - end; - psk_svgpreserveaspectratio_t = ^sk_svgpreserveaspectratio_t; - - - -{$IFNDEF SK_STATIC_LIBRARY} -var -{$ENDIF} - - { include/c/gr4d_backendsurface.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendrendertarget_create_gl {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(width, height, sample_count, stencil_bits: int32_t; const framebuffer_info: pgr_gl_framebufferinfo_t): gr_backendrendertarget_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendrendertarget_create_mtl {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(width, height: int32_t; const texture_info: pgr_mtl_textureinfo_t): gr_backendrendertarget_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendrendertarget_create_vk {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(width, height: int32_t; const image_info: pgr_vk_imageinfo_t): gr_backendrendertarget_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_backendrendertarget_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_backendrendertarget_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendrendertarget_get_backend_api {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendrendertarget_t): gr_backendapi_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendrendertarget_get_height {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendrendertarget_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendrendertarget_get_sample_count {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendrendertarget_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendrendertarget_get_stencil_bits {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendrendertarget_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendrendertarget_get_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendrendertarget_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendrendertarget_is_valid {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendrendertarget_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendtexture_create_gl {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(width, height: int32_t; is_mipmapped: _bool; const texture_info: pgr_gl_textureinfo_t): gr_backendtexture_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendtexture_create_mtl {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(width, height: int32_t; is_mipmapped: _bool; const texture_info: pgr_mtl_textureinfo_t): gr_backendtexture_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendtexture_create_vk {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(width, height: int32_t; const image_info: pgr_vk_imageinfo_t): gr_backendtexture_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_backendtexture_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_backendtexture_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendtexture_get_backend_api {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendtexture_t): gr_backendapi_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendtexture_get_gl_framebuffer_info{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendtexture_t; out texture_info: gr_gl_textureinfo_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendtexture_get_height {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendtexture_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendtexture_get_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendtexture_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendtexture_has_mipmaps {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendtexture_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_backendtexture_is_valid {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_backendtexture_t): _bool; cdecl; - - - { include/c/gr4d_contextoptions.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_persistentcachebaseclass_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: Pointer): gr_persistentcachebaseclass_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_persistentcachebaseclass_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_persistentcachebaseclass_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_persistentcachebaseclass_set_procs{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const procs: pgr_persistentcachebaseclass_procs_t); cdecl; - - - { include/c/gr4d_directcontext.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_abandon_context {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_dump_memory_statistics {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: gr_directcontext_t; trace_memory_dump: sk_tracememorydump_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_flush {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_flush_and_submit {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t; sync_cpu: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_free_gpu_resources {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_directcontext_get_backend_api {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_directcontext_t): gr_backendapi_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_directcontext_get_max_surface_sample_count_for_color_type{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_directcontext_t; color_type: sk_colortype_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_directcontext_get_resource_cache_limit {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_directcontext_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_get_resource_cache_usage {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: gr_directcontext_t; out resources: int32_t; out resources_bytes: size_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_directcontext_is_abandoned {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: gr_directcontext_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_directcontext_make_gl {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const gl_interface: gr_gl_interface_t; const options: pgr_contextoptions_t): gr_directcontext_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_directcontext_make_metal {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const backend_context: pgr_mtl_backendcontext_t; const options: pgr_contextoptions_t): gr_directcontext_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_directcontext_make_vulkan {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const backend_context: pgr_vk_backendcontext_t; const options: pgr_contextoptions_t): gr_directcontext_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_perform_deferred_cleanup {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t; milliseconds: int64_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_purge_unlocked_resources {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t; scratch_resources_only: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_purge_unlocked_resources2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t; bytes_to_purge: size_t; prefer_scratch_resources: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_release_resources_and_abandon_context {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_reset_context {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_directcontext_set_resource_cache_limit {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_directcontext_t; value: size_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_directcontext_submit {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: gr_directcontext_t; sync_cpu: _bool): _bool; cdecl; - - - { include/c/gr4d_gl_interface.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_gl_interface_has_extension {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_gl_interface_t; const name: MarshaledAString): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_gl_interface_make_assembled {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: Pointer; proc: gr_gl_get_proc): gr_gl_interface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_gl_interface_make_assembled_gl {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: Pointer; proc: gr_gl_get_proc): gr_gl_interface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_gl_interface_make_assembled_gles {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: Pointer; proc: gr_gl_get_proc): gr_gl_interface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_gl_interface_make_assembled_webgl{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: Pointer; proc: gr_gl_get_proc): gr_gl_interface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_gl_interface_make_native {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): gr_gl_interface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_gl_interface_validate {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_gl_interface_t): _bool; cdecl; - - - { include/c/gr4d_shadererrorhandler.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_shadererrorhandlerbaseclass_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: Pointer): gr_shadererrorhandlerbaseclass_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_shadererrorhandlerbaseclass_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_shadererrorhandlerbaseclass_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_shadererrorhandlerbaseclass_set_procs{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const procs: pgr_shadererrorhandlerbaseclass_procs_t); cdecl; - - - { include/c/gr4d_vk_extensions.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_vk_extensions_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): gr_vk_extensions_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_vk_extensions_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_vk_extensions_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}gr4d_vk_extensions_has_extension{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: gr_vk_extensions_t; const name: MarshaledAString; min_version: uint32_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}gr4d_vk_extensions_init {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: gr_vk_extensions_t; context: Pointer; proc: gr_vk_get_proc; instance: gr_vk_instance_t; physical_device: gr_vk_physicaldevice_t; const instance_extensions: PMarshaledAString; instance_extension_count: int32_t; const device_extensions: PMarshaledAString; device_extension_count: int32_t); cdecl; - - - { include/c/sk4d_blender.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_blender_make_arithmetic{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(k1, k2, k3, k4: float; enforce_premultiplied_color: _bool): sk_blender_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_blender_make_mode {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(mode: sk_blendmode_t): sk_blender_t; cdecl; - - - { include/c/sk4d_canvas.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_clear {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; color: sk_color_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_clear2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const color: psk_color4f_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_discard {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_clip_path {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const path: sk_path_t; op: sk_clipop_t; anti_alias: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_clip_rect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const rect: psk_rect_t; op: sk_clipop_t; anti_alias: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_clip_region {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const region: sk_region_t; op: sk_clipop_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_clip_rrect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const rrect: sk_rrect_t; op: sk_clipop_t; anti_alias: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_clip_shader {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; shader: sk_shader_t; op: sk_clipop_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_concat {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const matrix: psk_matrix44_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_concat2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const matrix: psk_matrix_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_annotation {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const rect: psk_rect_t; const key: MarshaledAString; const value: Pointer; size: size_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_arc {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const oval: psk_rect_t; start_angle, sweep_angle: float; use_center: _bool; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_atlas {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const atlas: sk_image_t; const transforms: psk_rotationscalematrix_t; const sprites: psk_rect_t; const colors: psk_color_t; count: int32_t; blend_mode: sk_blendmode_t; const sampling: psk_samplingoptions_t; const cull_rect: psk_rect_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_circle {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const center: psk_point_t; radius: float; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_color {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; color: sk_color_t; blend_mode: sk_blendmode_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_color2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const color: psk_color4f_t; blend_mode: sk_blendmode_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_glyphs {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; count: int32_t; const glyphs: psk_glyphid_t; const positions: psk_point_t; const origin: psk_point_t; const font: sk_font_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_glyphs2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; count: int32_t; const glyphs: psk_glyphid_t; const matrices: psk_rotationscalematrix_t; const origin: psk_point_t; const font: sk_font_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_image {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const image: sk_image_t; x, y: float; const sampling: psk_samplingoptions_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_image_lattice {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const image: sk_image_t; const lattice: psk_lattice_t; const dest: psk_rect_t; filter_mode: sk_filtermode_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_image_nine {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const image: sk_image_t; const center: psk_irect_t; const dest: psk_rect_t; filter_mode: sk_filtermode_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_image_rect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const image: sk_image_t; const src, dest: psk_rect_t; const sampling: psk_samplingoptions_t; const paint: sk_paint_t; constraint: sk_srcrectconstraint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_line {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const point1, point2: psk_point_t; paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_oval {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const oval: psk_rect_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_paint {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_patch {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const cubics: psk_point_t; const colors: psk_color_t; const tex_coords: psk_point_t; blend_mode: sk_blendmode_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_path {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const path: sk_path_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_picture {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const picture: sk_picture_t; const matrix: psk_matrix_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_point {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const point: psk_point_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_points {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; mode: sk_drawpointsmode_t; count: size_t; const points: psk_point_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_rect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const rect: psk_rect_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_region {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const region: sk_region_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_rrect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const rrect: sk_rrect_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_rrect2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const rect: psk_rect_t; radius_x, radius_y: float; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_rrect_difference {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const outer, inner: sk_rrect_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_simple_text {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const text: Pointer; size: size_t; encoding: sk_textencoding_t; x, y: float; const font: sk_font_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_text_blob {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const text_blob: sk_textblob_t; x, y: float; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_draw_vertices {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const vertices: sk_vertices_t; blend_mode: sk_blendmode_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_get_base_props {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_canvas_t; out result: sk_surfaceprops_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_get_device_clip_bounds {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_canvas_t; out result: sk_irect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_get_local_clip_bounds {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_canvas_t; out result: sk_rect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_get_local_to_device {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_canvas_t; out result: sk_matrix44_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_get_local_to_device_as_3x3{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_canvas_t; out result: sk_matrix_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_get_top_props {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_canvas_t; out result: sk_surfaceprops_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_canvas_get_save_count {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_canvas_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_canvas_make_surface {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_canvas_t; const image_info: psk_imageinfo_t; const props: psk_surfaceprops_t): sk_surface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_canvas_quick_reject {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_canvas_t; const rect: psk_rect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_canvas_quick_reject2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_canvas_t; const path: sk_path_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_reset_matrix {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_restore {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_restore_to_count {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; save_count: int32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_rotate {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; degrees: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_rotate2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; degrees, px, py: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_canvas_save {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_canvas_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_canvas_save_layer {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_canvas_t; const rect: psk_rect_t; const paint: sk_paint_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_canvas_save_layer_alpha {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_canvas_t; const rect: psk_rect_t; alpha: uint8_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_scale {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; sx, sy: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_set_matrix {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const matrix: psk_matrix44_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_set_matrix2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; const matrix: psk_matrix_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_skew {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; kx, ky: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_canvas_translate {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_canvas_t; dx, dy: float); cdecl; - - - { include/c/sk4d_codec.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_codec_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(codec: sk_codec_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_codec_get_dimensions {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_codec_t; out result: sk_isize_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_codec_get_encoded_image_format {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_codec_t): sk_encodedimageformat_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_codec_get_image {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_codec_t; color_type: sk_colortype_t; alpha_type: sk_alphatype_t; color_space: sk_colorspace_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_codec_get_pixels {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_codec_t; pixels: Pointer; row_bytes: size_t; color_type: sk_colortype_t; alpha_type: sk_alphatype_t; color_space: sk_colorspace_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_codec_make_from_file {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const file_name: MarshaledAString): sk_codec_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_codec_make_from_stream {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(stream: sk_stream_t): sk_codec_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_codec_make_with_copy {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const data: Pointer; size: size_t): sk_codec_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_codec_make_without_copy {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const data: Pointer; size: size_t): sk_codec_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_animcodecplayer_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_animcodecplayer_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_animcodecplayer_get_dimensions {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_animcodecplayer_t; out result: sk_isize_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_animcodecplayer_get_duration {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_animcodecplayer_t): uint32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_animcodecplayer_get_frame {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_animcodecplayer_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_animcodecplayer_make_from_file {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const file_name: MarshaledAString): sk_animcodecplayer_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_animcodecplayer_make_from_stream{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(stream: sk_stream_t): sk_animcodecplayer_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_animcodecplayer_seek {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_animcodecplayer_t; milliseconds: uint32_t): _bool; cdecl; - - - { include/c/sk4d_colorfilter.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_blend {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(color: sk_color_t; mode: sk_blendmode_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_blend2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const color: psk_color4f_t; color_space: sk_colorspace_t; mode: sk_blendmode_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_compose {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(outer, inner: sk_colorfilter_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_high_contrast {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const config: psk_highcontrastconfig_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_hsla_matrix {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const matrix: psk_colormatrix_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_lighting {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(multiply, add: sk_color_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_linear_to_srgb_gamma{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_luma_color {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_matrix {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const matrix: psk_colormatrix_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_overdraw {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const colors: psk_color_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorfilter_make_table {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const tablea_a, tablea_r, tablea_g, tablea_b: puint8_t): sk_colorfilter_t; cdecl; - - - { include/c/sk4d_colorspace.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_gamma_close_to_srgb {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspace_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_gamma_is_linear {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspace_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_is_equal {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, color_space: sk_colorspace_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_is_numerical_transfer_fn {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspace_t; out transfer_function: sk_colorspacetransferfn_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_is_srgb {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspace_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_make {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const profile: sk_colorspaceiccprofile_t): sk_colorspace_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_make_linear_gamma {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspace_t): sk_colorspace_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_make_rgb {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const transfer_function: psk_colorspacetransferfn_t; const xyz: psk_colorspacexyz_t): sk_colorspace_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_make_srgb {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_colorspace_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_make_srgb_gamma {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspace_t): sk_colorspace_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_make_srgb_linear {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_colorspace_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_colorspace_ref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_colorspace_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_to_profile {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspace_t): sk_colorspaceiccprofile_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspace_to_xyz {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspace_t; out xyz: sk_colorspacexyz_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_colorspace_unref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_colorspace_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_colorspaceiccprofile_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_colorspaceiccprofile_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspaceiccprofile_get_buffer {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspaceiccprofile_t; size: puint32_t): puint8_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspaceiccprofile_make_with_parse{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const buffer: Pointer; size: size_t): sk_colorspaceiccprofile_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspaceiccprofile_to_xyz {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_colorspaceiccprofile_t; out dest: sk_colorspacexyz_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspaceprimaries_to_xyz {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: psk_colorspaceprimaries_t; out xyz: sk_colorspacexyz_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspacetransferfn_invert {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: psk_colorspacetransferfn_t; out transfer_function: sk_colorspacetransferfn_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_colorspacetransferfn_transform {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: psk_colorspacetransferfn_t; x: float): float; cdecl; - - - { include/c/sk4d_data.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_data_make_empty {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_data_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_data_make_with_copy{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const data: Pointer; size: size_t): sk_data_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_data_ref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_data_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_data_unref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_data_t); cdecl; - - - { include/c/sk4d_document.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_document_begin_page{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_document_t; width, height: float; const content: psk_rect_t): sk_canvas_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_document_close {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_document_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_document_end_page {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_document_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_document_make_pdf {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(w_stream: sk_wstream_t): sk_document_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_document_make_pdf2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(w_stream: sk_wstream_t; const metadata: psk_pdfmetadata_t): sk_document_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_document_make_xps {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(w_stream: sk_wstream_t; dpi: float): sk_document_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_document_terminate {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_document_t); cdecl; - - - { include/c/sk4d_font.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(typeface: sk_typeface_t; size, sx, kx: float): sk_font_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_create2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const font: sk_font_t): sk_font_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_baseline_snap {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_edging {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): sk_fontedging_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_embedded_bitmaps {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_embolden {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_force_auto_hinting {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_glyphs {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t; const text: Pointer; size: size_t; encoding: sk_textencoding_t; result: psk_glyphid_t; max_count: int32_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_glyphs_count {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t; const text: Pointer; size: size_t; encoding: sk_textencoding_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_hinting {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): sk_fonthinting_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_get_horizontal_positions{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_font_t; const glyphs: psk_glyphid_t; count: int32_t; result: pfloat; origin: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_intercepts {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t; const glyphs: psk_glyphid_t; count: int32_t; const positions: psk_point_t; const bounds: pfloat; result: pfloat; const paint: sk_paint_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_linear_metrics {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_metrics {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t; metrics: psk_fontmetrics_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_path {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t; glyph: sk_glyphid_t): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_get_paths {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_font_t; const glyphs: psk_glyphid_t; count: int32_t; proc: sk_font_path_proc; proc_context: Pointer); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_get_positions {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_font_t; const glyphs: psk_glyphid_t; count: int32_t; result: psk_point_t; const origin: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_scale_x {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_size {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_skew_x {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_subpixel {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_typeface {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): sk_typeface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_get_typeface_or_default {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t): sk_typeface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_get_widths_bounds {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_font_t; const glyphs: psk_glyphid_t; count: int32_t; widths: pfloat; bounds: psk_rect_t; const paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_is_equal {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, font: sk_font_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_measure_text {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t; const text: Pointer; size: size_t; encoding: sk_textencoding_t; bounds: psk_rect_t; const paint: sk_paint_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_baseline_snap {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_edging {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: sk_fontedging_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_embedded_bitmaps {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_embolden {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_force_auto_hinting {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_hinting {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: sk_fonthinting_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_linear_metrics {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_scale_x {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_size {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_skew_x {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_subpixel {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_set_typeface {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_font_t; typeface: sk_typeface_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_font_unichar_to_glyph {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_font_t; uni_char: sk_unichar_t): sk_glyphid_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_font_unichars_to_glyphs {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_font_t; const uni_chars: psk_unichar_t; count: int32_t; result: psk_glyphid_t); cdecl; - - - { include/c/sk4d_graphics.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_graphics_allow_jit {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_graphics_dump_memory_statistics {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(trace_memory_dump: sk_tracememorydump_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_get_font_cache_count_limit {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_get_font_cache_count_used {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_get_font_cache_limit {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_get_font_cache_used {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_get_resource_cache_single_allocation_byte_limit{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_get_resource_cache_total_byte_limit {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_get_resource_cache_total_bytes_used {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_graphics_init {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_graphics_purge_all_caches {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_graphics_purge_font_cache {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_graphics_purge_resource_cache {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_set_font_cache_count_limit {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(value: int32_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_set_font_cache_limit {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(value: size_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_set_resource_cache_single_allocation_byte_limit{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(value: size_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_graphics_set_resource_cache_total_byte_limit {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(value: size_t): size_t; cdecl; - - - { include/c/sk4d_image.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_encode_to_file {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; const file_name: MarshaledAString; format: sk_encodedimageformat_t; quality: int32_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_encode_to_stream {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; w_stream: sk_wstream_t; format: sk_encodedimageformat_t; quality: int32_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_get_alpha_type {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): sk_alphatype_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_get_color_space {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): sk_colorspace_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_get_color_type {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): sk_colortype_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_get_height {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_image_get_image_info {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_image_t; out result: sk_imageinfo_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_get_unique_id {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): uint32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_get_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_is_lazy_generated {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_is_texture_backed {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_is_valid {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; context: gr_directcontext_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_cross_context {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: gr_directcontext_t; const pixmap: sk_pixmap_t; build_mips, limit_to_max_texture_size: _bool): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_from_adopted_texture{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: gr_directcontext_t; const texture: gr_backendtexture_t; origin: gr_surfaceorigin_t; color_type: sk_colortype_t; alpha_type: sk_alphatype_t; color_space: sk_colorspace_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_from_encoded_file {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const file_name: MarshaledAString): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_from_encoded_stream {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(stream: sk_stream_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_from_picture {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(picture: sk_picture_t; const dimensions: psk_isize_t; const matrix: psk_matrix_t; const paint: sk_paint_t; color_space: sk_colorspace_t; const props: psk_surfaceprops_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_from_raster {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const pixmap: sk_pixmap_t; proc: sk_image_raster_release_proc; proc_context: Pointer): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_from_texture {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: gr_directcontext_t; const texture: gr_backendtexture_t; origin: gr_surfaceorigin_t; color_type: sk_colortype_t; alpha_type: sk_alphatype_t; color_space: sk_colorspace_t; proc: sk_image_texture_release_proc; proc_context: Pointer): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_non_texture_image {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_raster_copy {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const pixmap: sk_pixmap_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_raster_image {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_raw_shader {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; tile_mode_x, tile_mode_y: sk_tilemode_t; const sampling: psk_samplingoptions_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_shader {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; tile_mode_x, tile_mode_y: sk_tilemode_t; const sampling: psk_samplingoptions_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_subset {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; const subset: psk_irect_t; context: gr_directcontext_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_texture_image {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; context: gr_directcontext_t; is_mipmapped: _bool): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_make_with_filter {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; context: gr_directcontext_t; const filter: sk_imagefilter_t; const subset, clip_bounds: psk_irect_t; out out_subset: sk_irect_t; out offset: sk_ipoint_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_peek_pixels {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t): sk_pixmap_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_read_pixels {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; context: gr_directcontext_t; const dest: sk_pixmap_t; src_x, src_y: int32_t; caching_hint: sk_imagecachinghint_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_image_scale_pixels {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_image_t; const dest: sk_pixmap_t; const sampling: psk_samplingoptions_t; caching_hint: sk_imagecachinghint_t): _bool; cdecl; - - - { include/c/sk4d_imageencoder.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imageencoder_encode_to_file {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const file_name: MarshaledAString; const src: sk_pixmap_t; format: sk_encodedimageformat_t; quality: int32_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imageencoder_encode_to_stream{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(w_stream: sk_wstream_t; const src: sk_pixmap_t; format: sk_encodedimageformat_t; quality: int32_t): _bool; cdecl; - - - { include/c/sk4d_imagefilter.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_alpha_threshold {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const region: sk_region_t; inner_min, outer_max: float; input: sk_imagefilter_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_arithmetic {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(k1, k2, k3, k4: float; enforce_premultiplied_color: _bool; background, foreground: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_blend {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(mode: sk_blendmode_t; background, foreground: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_blur {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(sigma_x, sigma_y: float; tile_mode: sk_tilemode_t; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_colorfilter {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(color_filter: sk_colorfilter_t; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_compose {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(inner, outer: sk_imagefilter_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_dilate {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(radius_x, radius_y: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_displacement_map {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(x_channel_selector, y_channel_selector: sk_colorchannel_t; scale: float; displacement, input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_distant_lit_diffuse {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const direction: psk_point3_t; light_color: sk_color_t; surface_scale, kd: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_distant_lit_specular{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const direction: psk_point3_t; light_color: sk_color_t; surface_scale, ks, shininess: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_drop_shadow {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(dx, dy, sigma_x, sigma_y: float; color: sk_color_t; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_drop_shadow_only {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(dx, dy, sigma_x, sigma_y: float; color: sk_color_t; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_erode {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(radius_x, radius_y: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_image {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(image: sk_image_t; const src, dest: psk_rect_t; const sampling: psk_samplingoptions_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_magnifier {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const src: psk_rect_t; inset: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_matrix_convolution {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const kernel_size: psk_isize_t; const kernel: pfloat; gain, bias: float; const kernel_offset: psk_ipoint_t; tile_mode: sk_tilemode_t; convolve_alpha: _bool; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_matrix_transform {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const matrix: psk_matrix_t; const sampling: psk_samplingoptions_t; input: sk_imagefilter_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_merge {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const filters: psk_imagefilter_t; count: int32_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_offset {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(dx, dy: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_picture {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(picture: sk_picture_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_point_lit_diffuse {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const location: psk_point3_t; light_color: sk_color_t; surface_scale, kd: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_point_lit_specular {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const location: psk_point3_t; light_color: sk_color_t; surface_scale, ks, shininess: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_shader {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(shader: sk_shader_t; dither: _bool; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_spot_lit_diffuse {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const location, target: psk_point3_t; falloff_exponent, cutoff_angle: float; light_color: sk_color_t; surface_scale, kd: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_spot_lit_specular {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const location, target: psk_point3_t; falloff_exponent, cutoff_angle: float; light_color: sk_color_t; surface_scale, ks, shininess: float; input: sk_imagefilter_t; const crop_rect: psk_rect_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_tile {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const src, dest: psk_rect_t; input: sk_imagefilter_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_imagefilter_make_with_local_matrix {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_imagefilter_t; const local_matrix: psk_matrix_t): sk_imagefilter_t; cdecl; - - - - { include/c/sk4d_maskfilter.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_maskfilter_make_blur {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(style: sk_blurstyle_t; sigma: float; respect_ctm: _bool): sk_maskfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_maskfilter_make_shader {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(shader: sk_shader_t): sk_maskfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_maskfilter_make_table {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const table: puint8_t): sk_maskfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_maskfilter_make_table_clip {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(min, max: uint8_t): sk_maskfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_maskfilter_make_table_gamma{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(gamma: float): sk_maskfilter_t; cdecl; - - - { include/c/sk4d_paint.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_paint_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_create2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const paint: sk_paint_t): sk_paint_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_alpha {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): uint8_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_alphaf {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_anti_alias {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_blender {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_blender_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_color {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_color_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_get_colorf {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_paint_t; out result: sk_color4f_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_color_filter {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_dither {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_fill_path {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t; const path: sk_path_t; const cull_rect: psk_rect_t; res_scale: float): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_image_filter {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_imagefilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_mask_filter {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_maskfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_path_effect {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_shader {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_stroke_cap {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_strokecap_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_stroke_join {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_strokejoin_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_stroke_miter {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_stroke_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paint_get_style {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paint_t): sk_paintstyle_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_reset {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_alpha {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: uint8_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_alphaf {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_antialias {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_argb {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; a, r, g, b: uint8_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_blender {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_blender_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_color {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_color_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_colorf {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; const value: psk_color4f_t; color_space: sk_colorspace_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_color_filter {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_colorfilter_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_dither {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_image_filter {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_imagefilter_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_mask_filter {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_maskfilter_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_path_effect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_patheffect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_shader {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_shader_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_stroke_cap {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_strokecap_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_stroke_join {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_strokejoin_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_stroke_miter {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_stroke_width {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paint_set_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paint_t; value: sk_paintstyle_t); cdecl; - - - { include/c/sk4d_path.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_opbuilder_add {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_opbuilder_t; const path: sk_path_t; op: sk_pathop_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_opbuilder_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_opbuilder_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_opbuilder_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_opbuilder_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_opbuilder_detach {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_opbuilder_t): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_contains {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t; x, y: float): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_convert_conic_to_quads{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const point1, point2, point3: psk_point_t; weight: float; points: psk_point_t; power2: int32_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const svg: MarshaledAString): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_create2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(stream: sk_stream_t): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_path_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_path_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_path_get_bounds {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_path_t; out result: sk_rect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_get_fill_type {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t): sk_pathfilltype_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_get_last_point {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t; out result: sk_point_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_get_segment_masks {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t): uint32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_path_get_tight_bounds {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_path_t; out result: sk_rect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_interpolate {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, ending: sk_path_t; weight: float): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_is_convex {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_is_empty {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_is_finite {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_is_interpolatable {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, path: sk_path_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_is_last_contour_closed{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_is_line {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t; lines: psk_point_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_is_oval {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t; oval: psk_rect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_is_rect {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t; rect: psk_rect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_is_rrect {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t; rrect: sk_rrect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_op {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, path: sk_path_t; op: sk_pathop_t): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_path_serialize_to_stream {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_path_t; w_stream: sk_wstream_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_to_svg {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t): sk_string_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_path_transform {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_path_t; const matrix: psk_matrix_t): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathiterator_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const path: sk_path_t; force_close: _bool): sk_pathiterator_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathiterator_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathiterator_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathiterator_next {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_pathiterator_t; out elem: sk_pathiteratorelem_t): _bool; cdecl; - - - { include/c/sk4d_pathbuilder.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_add_arc {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const oval: psk_rect_t; start_angle, sweep_angle: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_add_circle {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; center_x, center_y, radius: float; direction: sk_pathdirection_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_add_oval {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const oval: psk_rect_t; direction: sk_pathdirection_t; start_index: uint32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_add_path {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const path: sk_path_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_add_polygon {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; polygon: psk_point_t; count: int32_t; is_closed: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_add_rect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const rect: psk_rect_t; direction: sk_pathdirection_t; start_index: uint32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_add_rrect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const rrect: sk_rrect_t; direction: sk_pathdirection_t; start_index: uint32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_arc_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const radius: psk_point_t; x_axis_rotate: float; large_arc: sk_patharcsize_t; sweep: sk_pathdirection_t; const xy: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_arc_to2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const oval: psk_rect_t; start_angle, sweep_angle: float; force_move_to: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_arc_to3 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const point1, point2: psk_point_t; radius: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_close {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_conic_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const point1, point2: psk_point_t; weight: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathbuilder_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_pathbuilder_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathbuilder_create2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const path_builder: sk_pathbuilder_t): sk_pathbuilder_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_cubic_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const point1, point2, point3: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathbuilder_detach {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_pathbuilder_t): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_get_bounds {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_pathbuilder_t; out result: sk_rect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathbuilder_get_fill_type {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pathbuilder_t): sk_pathfilltype_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_inc_reserve {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; extra_point_count, extra_verb_count: int32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_line_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const cpoint: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_move_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const cpoint: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_offset {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; dx, dy: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_polyline_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const points: psk_point_t; count: int32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_quad_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const point1, point2: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_r_conic_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const point1, point2: psk_point_t; weight: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_r_cubic_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const point1, point2, point3: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_r_line_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const point: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_r_quad_to {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; const point1, point2: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_reset {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_set_filltype {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t; value: sk_pathfilltype_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathbuilder_snapshot {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pathbuilder_t): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathbuilder_toggle_inverse_filltype{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathbuilder_t); cdecl; - - - { include/c/sk4d_patheffect.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_1dpath {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const path: sk_path_t; advance, phase: float; style: sk_patheffect1dstyle_t): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_2dline {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(width: float; const matrix: psk_matrix_t): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_2dpath {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const matrix: psk_matrix_t; const path: sk_path_t): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_compose {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(outer, inner: sk_patheffect_t): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_corner {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(radius: float): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_dash {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const intervals: pfloat; count: int32_t; phase: float): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_discrete {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(seg_length, deviation: float; seed_assist: uint32_t): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_matrix {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const matrix: psk_matrix_t): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_merge {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(effect1, effect2: sk_patheffect_t; op: sk_pathop_t): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_stroke {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(width: float; join: sk_strokejoin_t; cap: sk_strokecap_t; miter: float): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_stroke_and_fill{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_sum {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(effect1, effect2: sk_patheffect_t): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_translate {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(dx, dy: float): sk_patheffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_patheffect_make_trim {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(start, stop: float; mode: sk_patheffecttrimmode_t): sk_patheffect_t; cdecl; - - - { include/c/sk4d_pathmeasure.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathmeasure_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const path: sk_path_t; force_closed: _bool; res_scale: float): sk_pathmeasure_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pathmeasure_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pathmeasure_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathmeasure_get_length {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_pathmeasure_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathmeasure_get_matrix {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_pathmeasure_t; distance: float; out matrix: sk_matrix_t; matrix_flags: uint32_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathmeasure_get_position_and_tangent{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_pathmeasure_t; distance: float; out position: sk_point_t; out tangent: sk_vector_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathmeasure_get_segment {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_pathmeasure_t; start, stop: float; start_with_move_to: _bool): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathmeasure_is_closed {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_pathmeasure_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pathmeasure_next_contour {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_pathmeasure_t): _bool; cdecl; - - - { include/c/sk4d_picture.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_picture_get_cull_rect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_picture_t; out result: sk_rect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_picture_make_from_stream {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(stream: sk_stream_t): sk_picture_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_picture_make_shader {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_picture_t; tile_mode_x, tile_mode_y: sk_tilemode_t; filter_mode: sk_filtermode_t; const local_matrix: psk_matrix_t; const tile_rect: psk_rect_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_picture_playback {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_picture_t; canvas: sk_canvas_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_picture_serialize_to_stream{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_picture_t; w_stream: sk_wstream_t); cdecl; - - - { include/c/sk4d_picturerecorder.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_picturerecorder_begin_recording {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_picturerecorder_t; const bounds: psk_rect_t): sk_canvas_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_picturerecorder_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_picturerecorder_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_picturerecorder_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_picturerecorder_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_picturerecorder_finish_recording {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_picturerecorder_t): sk_picture_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_picturerecorder_finish_recording2{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_picturerecorder_t; const cull_rect: psk_rect_t): sk_picture_t; cdecl; - - - { include/c/sk4d_pixmap.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const image_info: psk_imageinfo_t; const pixels: Pointer; row_bytes: size_t): sk_pixmap_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pixmap_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pixmap_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_erase {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t; color: sk_color_t; const area: psk_irect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_erase2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t; const color: psk_color4f_t; color_space: sk_colorspace_t; const area: psk_irect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_extract_subset {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t; dest: sk_pixmap_t; const area: psk_irect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_alpha {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t; x, y: int32_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_alpha_type {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t): sk_alphatype_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_color {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t; x, y: int32_t): sk_color_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_color_space{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t): sk_colorspace_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_color_type {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t): sk_colortype_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pixmap_get_colorf {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_pixmap_t; x, y: int32_t; out result: sk_color4f_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_height {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pixmap_get_image_info {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_pixmap_t; out result: sk_imageinfo_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_pixel_addr {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t; x, y: int32_t): Pointer; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_pixels {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t): Pointer; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_row_bytes {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_get_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_pixmap_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_read_pixels {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, dest: sk_pixmap_t; src_x, src_y: int32_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_pixmap_scale_pixels {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, dest: sk_pixmap_t; const sampling: psk_samplingoptions_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_pixmap_set_colorspace {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_pixmap_t; value: sk_colorspace_t); cdecl; - - - { include/c/sk4d_refcnt.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_refcnt_ref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_refcnt_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_refcnt_unref{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_refcnt_t); cdecl; - - - { include/c/sk4d_region.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_contains {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, region: sk_region_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_contains2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_region_t; const rect: psk_irect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_contains3 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_region_t; x, y: int32_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_region_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_create2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const region: sk_region_t): sk_region_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_region_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_region_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_get_boundary_path {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_region_t): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_region_get_bounds {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_region_t; out result: sk_irect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_intersects {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, region: sk_region_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_intersects2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_region_t; const rect: psk_irect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_is_complex {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_region_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_is_empty {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_region_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_is_equal {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, region: sk_region_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_is_rect {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_region_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_op {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_region_t; const region: sk_region_t; op: sk_regionop_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_op2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_region_t; const rect: psk_irect_t; op: sk_regionop_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_quick_contains {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_region_t; const rect: psk_irect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_quick_reject {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, region: sk_region_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_quick_reject2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_region_t; const rect: psk_irect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_region_set_empty {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_region_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_set_path {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_region_t; const path: sk_path_t; const clip: sk_region_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_set_rect {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_region_t; const rect: psk_irect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_region_set_rects {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_region_t; const rects: psk_irect_t; count: int32_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_region_translate {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_region_t; x, y: int32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_regioncliperator_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const region: sk_region_t; const clip: psk_irect_t): sk_regioncliperator_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_regioncliperator_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_regioncliperator_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_regioncliperator_get_current{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_regioncliperator_t; out result: sk_irect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_regioncliperator_move_next {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_regioncliperator_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_regioniterator_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const region: sk_region_t): sk_regioniterator_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_regioniterator_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_regioniterator_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_regioniterator_get_current {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_regioniterator_t; out result: sk_irect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_regioniterator_move_next {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_regioniterator_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_regionspanerator_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const region: sk_region_t; y, left, right: int32_t): sk_regionspanerator_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_regionspanerator_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_regionspanerator_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_regionspanerator_next {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_regionspanerator_t; out elem: sk_ipoint_t): _bool; cdecl; - - - { include/c/sk4d_rrect.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_contains {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t; const rect: psk_rect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_rrect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_create2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const rrect: sk_rrect_t): sk_rrect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_deflate {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t; dx, dy: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_get_height {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_get_radii {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_rrect_t; corner: sk_rrectcorner_t; out result: sk_vector_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_get_rect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_rrect_t; out result: sk_rect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_get_simple_radii{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_rrect_t; out result: sk_vector_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_get_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_inflate {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t; dx, dy: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_is_complex {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_is_empty {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_is_equal {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, rrect: sk_rrect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_is_nine_patch {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_is_oval {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_is_rect {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_is_simple {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_is_valid {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_offset {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t; dx, dy: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_set_empty {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_set_nine_patch {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t; const rect: psk_rect_t; radius_left, radius_top, radius_right, radius_bottom: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_set_oval {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t; const rect: psk_rect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_set_rect {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t; const rect: psk_rect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_set_rect2 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t; const rect: psk_rect_t; const radii: psk_vector_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_rrect_set_rect3 {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_rrect_t; const rect: psk_rect_t; radius_x, radius_y: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_rrect_transform {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_rrect_t; const matrix: psk_matrix_t): sk_rrect_t; cdecl; - - - { include/c/sk4d_runtimeeffect.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_get_child_count {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_get_child_name {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; index: int32_t): MarshaledAString; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_get_child_type {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; index: int32_t): sk_runtimeeffectchildtype_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_get_uniform_count {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_get_uniform_data_size {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_get_uniform_name {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; index: int32_t): MarshaledAString; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_get_uniform_offset {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; index: int32_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_get_uniform_type {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; index: int32_t): sk_runtimeeffectuniformtype_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_get_uniform_type_count{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; index: int32_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_index_of_child {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; const name: MarshaledAString): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_index_of_uniform {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; const name: MarshaledAString): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_make_blender {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; const uniforms: Pointer; children: psk_blender_t): sk_blender_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_make_color_filter {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; const uniforms: Pointer; children: psk_colorfilter_t): sk_colorfilter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_make_for_blender {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const sksl: MarshaledAString; error_text: sk_string_t): sk_runtimeeffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_make_for_color_filter {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const sksl: MarshaledAString; error_text: sk_string_t): sk_runtimeeffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_make_for_shader {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const sksl: MarshaledAString; error_text: sk_string_t): sk_runtimeeffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_make_image {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; context: gr_directcontext_t; const uniforms: Pointer; children: psk_shader_t; const local_matrix: psk_matrix_t; const image_info: psk_imageinfo_t; mipmapped: _bool): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_runtimeeffect_make_shader {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_runtimeeffect_t; const uniforms: Pointer; children: psk_shader_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - - - { include/c/sk4d_shader.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_blend {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(mode: sk_blendmode_t; dest, src: sk_shader_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_color {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(color: sk_color_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_color2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const color: psk_color4f_t; color_space: sk_colorspace_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_gradient_linear {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const points: psk_point_t; const colors: psk_color_t; const positions: pfloat; count: int32_t; tile_mode: sk_tilemode_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_gradient_linear2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const points: psk_point_t; const colors: psk_color4f_t; color_space: sk_colorspace_t; const positions: pfloat; count: int32_t; tile_mode: sk_tilemode_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_gradient_radial {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const center: psk_point_t; radius: float; const colors: psk_color_t; const positions: pfloat; count: int32_t; tile_mode: sk_tilemode_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_gradient_radial2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const center: psk_point_t; radius: float; const colors: psk_color4f_t; color_space: sk_colorspace_t; const positions: pfloat; count: int32_t; tile_mode: sk_tilemode_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_gradient_sweep {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(center_x, center_y: float; const colors: psk_color_t; const positions: pfloat; count: int32_t; tile_mode: sk_tilemode_t; start_angle, end_angle: float; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_gradient_sweep2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(center_x, center_y: float; const colors: psk_color4f_t; color_space: sk_colorspace_t; const positions: pfloat; count: int32_t; tile_mode: sk_tilemode_t; start_angle, end_angle: float; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_gradient_two_point_conical {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const start: psk_point_t; start_radius: float; const &end: psk_point_t; end_radius: float; const colors: psk_color_t; const positions: pfloat; count: int32_t; tile_mode: sk_tilemode_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_gradient_two_point_conical2{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const start: psk_point_t; start_radius: float; const &end: psk_point_t; end_radius: float; const colors: psk_color4f_t; color_space: sk_colorspace_t; const positions: pfloat; count: int32_t; tile_mode: sk_tilemode_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_perlin_noise_fractal_noise {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(base_frequency_x, base_frequency_y: float; num_octaves: int32_t; seed: float; const tile_size: psk_isize_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_perlin_noise_turbulence {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(base_frequency_x, base_frequency_y: float; num_octaves: int32_t; seed: float; const tile_size: psk_isize_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_with_color_filter {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_shader_t; color_filter: sk_colorfilter_t): sk_shader_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shader_make_with_local_matrix {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_shader_t; const local_matrix: psk_matrix_t): sk_shader_t; cdecl; - - - { include/c/sk4d_stream.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_streamadapter_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: Pointer): sk_streamadapter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_streamadapter_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_streamadapter_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_streamadapter_set_procs {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const procs: psk_streamadapter_procs_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_wstreamadapter_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: Pointer): sk_wstreamadapter_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_wstreamadapter_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_wstreamadapter_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_wstreamadapter_set_procs{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const procs: psk_wstreamadapter_procs_t); cdecl; - - - { include/c/sk4d_string.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_string_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_string_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_string_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_string_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_string_get_text{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_string_t): MarshaledAString; cdecl; - - - { include/c/sk4d_surface.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_surface_draw {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_surface_t; canvas: sk_canvas_t; x, y: float; paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_surface_flush {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_surface_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_surface_flush_and_submit {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_surface_t; sync_cpu: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_get_canvas {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_surface_t): sk_canvas_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_surface_get_props {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_surface_t; out result: sk_surfaceprops_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_make_from_mtk_view {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: gr_directcontext_t; layer: gr_mtl_handle_t; origin: gr_surfaceorigin_t; sample_count: int32_t; color_type: sk_colortype_t; color_space: sk_colorspace_t; const props: psk_surfaceprops_t): sk_surface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_make_from_render_target {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: gr_directcontext_t; const render_target: gr_backendrendertarget_t; origin: gr_surfaceorigin_t; color_type: sk_colortype_t; color_space: sk_colorspace_t; const props: psk_surfaceprops_t): sk_surface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_make_from_texture {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: gr_directcontext_t; const texture: gr_backendtexture_t; origin: gr_surfaceorigin_t; sample_count: int32_t; color_type: sk_colortype_t; color_space: sk_colorspace_t; const props: psk_surfaceprops_t): sk_surface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_make_image_snapshot {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_surface_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_make_image_snapshot2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_surface_t; const bounds: psk_irect_t): sk_image_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_make_raster {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const image_info: psk_imageinfo_t; row_bytes: size_t; const props: psk_surfaceprops_t): sk_surface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_make_raster_direct {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const pixmap: sk_pixmap_t; proc: sk_surface_raster_release_proc; proc_context: Pointer; const props: psk_surfaceprops_t): sk_surface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_make_render_target {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(context: gr_directcontext_t; is_budgeted: _bool; const image_info: psk_imageinfo_t; sample_count: int32_t; origin: gr_surfaceorigin_t; const props: psk_surfaceprops_t; should_create_with_mips: _bool): sk_surface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_peek_pixels {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_surface_t): sk_pixmap_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_surface_read_pixels {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_surface_t; const dest: sk_pixmap_t; src_x, src_y: int32_t): _bool; cdecl; - - - { include/c/sk4d_svgcanvas.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_svgcanvas_make{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const bounds: psk_rect_t; w_stream: sk_wstream_t; flags: uint32_t): sk_canvas_t; cdecl; - - - { include/c/sk4d_textblob.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textblob_get_intercepts {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textblob_t; const bounds: pfloat; result: pfloat; const paint: sk_paint_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textblob_make_from_text {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const text: Pointer; size: size_t; const font: sk_font_t; encoding: sk_textencoding_t): sk_textblob_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textblob_make_from_text_horizontally_positioned{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const text: Pointer; size: size_t; const x_positions: pfloat; y: float; const font: sk_font_t; encoding: sk_textencoding_t): sk_textblob_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textblob_make_from_text_positioned {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const text: Pointer; size: size_t; const positions: psk_point_t; const font: sk_font_t; encoding: sk_textencoding_t): sk_textblob_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textblob_make_from_text_transform {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const text: Pointer; size: size_t; const matrices: psk_rotationscalematrix_t; const font: sk_font_t; encoding: sk_textencoding_t): sk_textblob_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textblob_ref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_textblob_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textblob_unref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_textblob_t); cdecl; - - - { include/c/sk4d_tracememorydump.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_tracememorydumpbaseclass_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(detailed_dump, dump_wrapped_objects: _bool; context: Pointer): sk_tracememorydumpbaseclass_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_tracememorydumpbaseclass_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_tracememorydumpbaseclass_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_tracememorydumpbaseclass_set_procs{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const procs: psk_tracememorydumpbaseclass_procs_t); cdecl; - - - { include/c/sk4d_typeface.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_typeface_get_family_name {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_typeface_t): sk_string_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_typeface_get_slant {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_typeface_t): sk_fontslant_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_typeface_get_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_typeface_t; out result: sk_fontstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_typeface_get_weight {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_typeface_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_typeface_get_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_typeface_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_typeface_make_default {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_typeface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_typeface_make_from_file {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const file_name: MarshaledAString; ttc_index: int32_t): sk_typeface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_typeface_make_from_stream{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(stream: sk_stream_t; ttc_index: int32_t): sk_typeface_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_typeface_make_from_name {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const family_name: MarshaledAString; const style: psk_fontstyle_t): sk_typeface_t; cdecl; - - - { include/c/sk4d_vertices.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_vertices_make_copy{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(vertex_mode: sk_vertexmode_t; vertex_count: int32_t; const positions, textures: psk_point_t; const colors: psk_color_t; index_count: int32_t; const indices: puint16_t): sk_vertices_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_vertices_ref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_vertices_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_vertices_unref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_vertices_t); cdecl; - - - { modules/particles/include/sk4d_particleeffect.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_particleeffect_get_position {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_particleeffect_t; out result: sk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_particleeffect_get_rate {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_particleeffect_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_particleeffect_get_uniform {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_particleeffect_t; index: size_t; out result: sk_particleuniform_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_particleeffect_get_uniform_count {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_particleeffect_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_particleeffect_get_uniform_data {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_particleeffect_t): pfloat; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_particleeffect_get_uniform_data_count{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_particleeffect_t): int32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_particleeffect_get_uniform_name {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_particleeffect_t; index: size_t): sk_string_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_particleeffect_init {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_particleeffect_make_from_file {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const file_name: MarshaledAString): sk_particleeffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_particleeffect_make_from_stream {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(stream: sk_stream_t; resource_provider: sk_resourceprovider_t): sk_particleeffect_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_particleeffect_render {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_particleeffect_t; canvas: sk_canvas_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_particleeffect_set_position {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_particleeffect_t; const value: psk_point_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_particleeffect_set_rate {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_particleeffect_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_particleeffect_set_uniform {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_particleeffect_t; const name: MarshaledAString; const data: pfloat; count: int32_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_particleeffect_start {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_particleeffect_t; now: _double; looping: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_particleeffect_update {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_particleeffect_t; now: _double); cdecl; - - - { modules/skottie/include/sk4d_skottie.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_skottieanimation_get_duration {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_skottieanimation_t): _double; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_skottieanimation_get_fps {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_skottieanimation_t): _double; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_skottieanimation_get_in_point {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_skottieanimation_t): _double; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_skottieanimation_get_out_point {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_skottieanimation_t): _double; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_skottieanimation_get_size {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_skottieanimation_t; out result: sk_size_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_skottieanimation_get_version {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_skottieanimation_t): MarshaledAString; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_skottieanimation_make_from_file {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const file_name: MarshaledAString): sk_skottieanimation_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_skottieanimation_make_from_stream{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(stream: sk_stream_t; resource_provider: sk_resourceprovider_t): sk_skottieanimation_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_skottieanimation_ref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_skottieanimation_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_skottieanimation_render {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_skottieanimation_t; canvas: sk_canvas_t; const dest: psk_rect_t; render_flags: uint32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_skottieanimation_seek_frame {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_skottieanimation_t; tick: _double); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_skottieanimation_seek_frame_time {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_skottieanimation_t; tick: _double); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_skottieanimation_unref {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_skottieanimation_t); cdecl; - - - { modules/skparagraph/include/sk4d_paragraph.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraph_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraph_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_did_exceed_max_lines {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_alphabetic_baseline {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraph_get_glyph_position_at_coordinate{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraph_t; dx, dy: float; out result: sk_positionaffinity_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_height {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_ideographic_baseline {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_line_metrics {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t; result: psk_metrics_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_longest_line {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_max_intrinsic_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_max_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_min_intrinsic_width {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_rects_for_placeholders {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t; result: psk_textbox_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_get_rects_for_range {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t; start, &end: uint32_t; rect_height_style: sk_rectheightstyle_t; rect_width_style: sk_rectwidthstyle_t; result: psk_textbox_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraph_get_word_boundary {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraph_t; offset: uint32_t; out start, &end: uint32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraph_layout {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraph_t; width: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraph_paint {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraph_t; canvas: sk_canvas_t; x, y: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraph_to_path {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraph_t): sk_path_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraph_visit {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraph_t; proc: sk_paragraph_visit_proc; proc_context: Pointer); cdecl; - - - { modules/skparagraph/include/sk4d_paragraphbuilder.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphbuilder_add_placeholder{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphbuilder_t; const placeholder: psk_placeholderstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphbuilder_add_text {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphbuilder_t; const text: MarshaledAString); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphbuilder_build {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_paragraphbuilder_t): sk_paragraph_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphbuilder_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const paragraph_style: sk_paragraphstyle_t): sk_paragraphbuilder_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphbuilder_create2 {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const paragraph_style: sk_paragraphstyle_t; font_provider: sk_typefacefontprovider_t; enable_font_fallback: _bool): sk_paragraphbuilder_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphbuilder_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphbuilder_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphbuilder_pop {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphbuilder_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphbuilder_push_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphbuilder_t; const text_style: sk_textstyle_t); cdecl; - - - { modules/skparagraph/include/sk4d_paragraphstyle.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphstyle_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_paragraphstyle_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_disable_hinting {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphstyle_get_ellipsis {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paragraphstyle_t): sk_string_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphstyle_get_height {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paragraphstyle_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphstyle_get_max_lines {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paragraphstyle_t): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphstyle_get_strut_style {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paragraphstyle_t): sk_strutstyle_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphstyle_get_text_align {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paragraphstyle_t): sk_textalign_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphstyle_get_text_direction {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paragraphstyle_t): sk_textdirection_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphstyle_get_text_height_behaviors{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paragraphstyle_t): uint32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_paragraphstyle_get_text_style {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_paragraphstyle_t): sk_textstyle_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_set_ellipsis {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t; const value: MarshaledAString); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_set_height {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_set_max_lines {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t; value: size_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_set_strut_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t; const value: sk_strutstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_set_text_align {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t; value: sk_textalign_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_set_text_direction {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t; value: sk_textdirection_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_set_text_height_behaviors{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t; value: uint32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_paragraphstyle_set_text_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_paragraphstyle_t; value: sk_textstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_strutstyle_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_strutstyle_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_strutstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_strutstyle_get_enabled {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_strutstyle_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_strutstyle_get_font_families {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_strutstyle_t; const result: PMarshaledAString): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_strutstyle_get_font_size {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_strutstyle_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_get_font_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_strutstyle_t; out result: sk_fontstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_strutstyle_get_force_height {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_strutstyle_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_strutstyle_get_half_leading {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_strutstyle_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_strutstyle_get_height_multiplier {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_strutstyle_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_strutstyle_get_leading {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_strutstyle_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_strutstyle_is_equal {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_strutstyle_t; const strut_style: sk_strutstyle_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_set_enabled {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_strutstyle_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_set_font_families {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_strutstyle_t; const values: PMarshaledAString; count: size_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_set_font_size {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_strutstyle_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_set_font_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_strutstyle_t; value: psk_fontstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_set_force_height {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_strutstyle_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_set_half_leading {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_strutstyle_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_set_height_multiplier {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_strutstyle_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_strutstyle_set_leading {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_strutstyle_t; value: float); cdecl; - - - { modules/skparagraph/include/sk4d_textstyle.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_add_font_feature {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; const feature: MarshaledAString; value: int32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_add_shadow {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; const shadow: psk_textshadow_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_clear_background_color {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_clear_foreground_color {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_textstyle_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_background {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): sk_paint_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_color {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): sk_color_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_decoration_color {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): sk_color_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_decoration_style {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): sk_textdecorationstyle_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_decoration_thickness{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_decorations {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): uint32_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_font_families {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t; const result: PMarshaledAString): size_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_get_font_metrics {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_textstyle_t; out result: sk_fontmetrics_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_font_size {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_get_font_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_textstyle_t; out result: sk_fontstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_foreground {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): sk_paint_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_half_leading {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_height_multiplier {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_letter_spacing {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_locale {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): sk_string_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_get_word_spacing {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_textstyle_t): float; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_textstyle_is_equal {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self, text_style: sk_textstyle_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_reset_font_features {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_reset_shadows {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_background_color {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_color {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: sk_color_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_decoration_color {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: sk_color_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_decoration_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: sk_textdecorationstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_decoration_thickness{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_decorations {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: uint32_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_font_families {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; const values: PMarshaledAString; count: size_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_font_size {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_font_style {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; const value: psk_fontstyle_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_foreground_color {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; paint: sk_paint_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_half_leading {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: _bool); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_height_multiplier {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_letter_spacing {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: float); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_locale {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; const value: MarshaledAString); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_textstyle_set_word_spacing {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_textstyle_t; value: float); cdecl; - - - { modules/skparagraph/include/sk4d_typefacefontprovider.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_typefacefontprovider_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_typefacefontprovider_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_typefacefontprovider_register_typeface {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_typefacefontprovider_t; typeface: sk_typeface_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_typefacefontprovider_register_typeface2{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_typefacefontprovider_t; typeface: sk_typeface_t; const family_name: MarshaledAString); cdecl; - - - { modules/skresources/include/sk4d_resources.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_resourceproviderbaseclass_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(predecode: _bool; context: Pointer): sk_resourceproviderbaseclass_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_resourceproviderbaseclass_set_procs{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const procs: psk_resourceproviderbaseclass_procs_t); cdecl; - - - { modules/skshaper/include/sk4d_shaper.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shaper_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_shaper_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_shaper_destroy{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_shaper_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_shaper_shape {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_shaper_t; const text: MarshaledAString; const font: sk_font_t; left_to_right: _bool; width: float; const offset: psk_point_t; end_point: psk_point_t): sk_textblob_t; cdecl; - - - { modules/skunicode/include/sk4d_unicode.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_unicode_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(): sk_unicode_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_unicode_destroy {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_unicode_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_unicode_for_each_bidi_region{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_unicode_t; const utf16_text: puint16_t; utf16_units: int32_t; direction: sk_direction_t; proc: sk_unicode_bidi_region_proc; context: Pointer); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_unicode_for_each_break {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_unicode_t; const utf16_text: pchar16_t; utf16_units: int32_t; &type: sk_breaktype_t; proc: sk_unicode_break_proc; context: Pointer); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_unicode_for_each_codepoint {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_unicode_t; const utf16_text: pchar16_t; utf16_units: int32_t; proc: sk_unicode_codepoint_proc; context: Pointer); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_unicodebreakiterator_create {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(unicode: sk_unicode_t; &type: sk_breaktype_t; const text: _pchar; units: int32_t): sk_unicodebreakiterator_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_unicodebreakiterator_create2{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(unicode: sk_unicode_t; &type: sk_breaktype_t; const utf16_text: pchar16_t; utf16_units: int32_t): sk_unicodebreakiterator_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_unicodebreakiterator_destroy{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_unicodebreakiterator_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_unicodebreakiterator_next {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_unicodebreakiterator_t; out elem: sk_unicodebreakiteratorelem_t): _bool; cdecl; - - { modules/svg/include/sk4d_svgdom.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_svgdom_find_node_by_id {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_svgdom_t; const id: MarshaledAString): sk_svgnode_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_svgdom_get_root {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_svgdom_t): sk_svgsvg_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_svgdom_make_from_file {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const file_name: MarshaledAString): sk_svgdom_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_svgdom_make_from_stream {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(stream: sk_stream_t; resource_provider: sk_resourceprovider_t): sk_svgdom_t; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgdom_render {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_svgdom_t; canvas: sk_canvas_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgdom_set_container_size{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_svgdom_t; const size: psk_size_t); cdecl; - - - { modules/svg/include/sk4d_svgnode.h } - - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_svgnode_set_attribute{$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(self: sk_svgnode_t; const name, value: MarshaledAString): _bool; cdecl; - - - { modules/svg/include/sk4d_svgsvg.h } - - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_get_height {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_svgsvg_t; out result: sk_svglength_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_get_intrinsic_size {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_svgsvg_t; const view_port: psk_size_t; dpi: float; out result: sk_size_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_get_preserve_aspect_ratio{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_svgsvg_t; out result: sk_svgpreserveaspectratio_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}function {$ENDIF}sk4d_svgsvg_get_view_box {$IFNDEF SK_STATIC_LIBRARY}: function {$ENDIF}(const self: sk_svgsvg_t; out result: sk_rect_t): _bool; cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_get_width {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_svgsvg_t; out result: sk_svglength_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_get_x {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_svgsvg_t; out result: sk_svglength_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_get_y {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(const self: sk_svgsvg_t; out result: sk_svglength_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_set_height {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_svgsvg_t; value: psk_svglength_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_set_preserve_aspect_ratio{$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_svgsvg_t; value: psk_svgpreserveaspectratio_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_set_view_box {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_svgsvg_t; view_box: psk_rect_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_set_width {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_svgsvg_t; value: psk_svglength_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_set_x {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_svgsvg_t; value: psk_svglength_t); cdecl; - {$IFDEF SK_STATIC_LIBRARY}procedure {$ENDIF}sk4d_svgsvg_set_y {$IFNDEF SK_STATIC_LIBRARY}: procedure {$ENDIF}(self: sk_svgsvg_t; value: psk_svglength_t); cdecl; - -procedure SkInitialize; -procedure SkFinalize; - -implementation - -uses - { Delphi } -{$IF DEFINED(MSWINDOWS)} - System.Math, - Winapi.Windows, -{$ELSEIF DEFINED(ANDROID)} - System.IOUtils, -{$ENDIF} - System.SysUtils; - -const -{$IFDEF SK_STATIC_LIBRARY} - {$IF DEFINED(IOS) and NOT DEFINED(IOSSIMULATOR)} - LibraryName = 'libsk4d.a'; - {$ENDIF} -{$ELSE} - {$IF DEFINED(MSWINDOWS)} - LibraryName = 'sk4d.dll'; - {$ELSEIF DEFINED(MACOS)} - LibraryName = 'libsk4d.dylib'; - {$ELSE} - LibraryName = 'libsk4d.so'; - {$ENDIF} -{$ENDIF} - -{$IFNDEF SK_STATIC_LIBRARY} -var - InitCount: Integer; - LibraryHandle: HMODULE; -{$ENDIF} - -{$IF DEFINED(SK_DEBUG) and DEFINED(MSWINDOWS)} -function GetProcAddress(AModule: HMODULE; AProcName: PChar): Pointer; -begin - Result := Winapi.Windows.GetProcAddress(AModule, AProcName); - if Result = nil then - raise Exception.CreateFmt('Function "%s" not found in Skia library.', [AProcName]); -end; -{$ENDIF} - -{$IFNDEF SK_STATIC_LIBRARY} -procedure SkInitialize; -begin - if AtomicIncrement(InitCount) <> 1 then - Exit; - {$IF DEFINED(ANDROID)} - // Some Android devices, normally old, need the full path of the library, - // and other devices, normally new, do not accept the full path. - LibraryHandle := SafeLoadLibrary(LibraryName); - if LibraryHandle = 0 then - LibraryHandle := SafeLoadLibrary(TPath.Combine(TPath.GetLibraryPath, LibraryName)); - {$ELSE} - LibraryHandle := SafeLoadLibrary(LibraryName); - {$ENDIF} - if LibraryHandle = 0 then - Abort; - {$IFDEF MSWINDOWS} - SetExceptionMask(exAllArithmeticExceptions); - {$ENDIF} -{$ENDIF} - -{ include/c/gr4d_backendsurface.h } - -{$IFNDEF SK_STATIC_LIBRARY} - gr4d_backendrendertarget_create_gl := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_create_gl')); - gr4d_backendrendertarget_create_mtl := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_create_mtl')); - gr4d_backendrendertarget_create_vk := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_create_vk')); - gr4d_backendrendertarget_destroy := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_destroy')); - gr4d_backendrendertarget_get_backend_api := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_get_backend_api')); - gr4d_backendrendertarget_get_height := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_get_height')); - gr4d_backendrendertarget_get_sample_count := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_get_sample_count')); - gr4d_backendrendertarget_get_stencil_bits := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_get_stencil_bits')); - gr4d_backendrendertarget_get_width := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_get_width')); - gr4d_backendrendertarget_is_valid := GetProcAddress(LibraryHandle, PChar('gr4d_backendrendertarget_is_valid')); - gr4d_backendtexture_create_gl := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_create_gl')); - gr4d_backendtexture_create_mtl := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_create_mtl')); - gr4d_backendtexture_create_vk := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_create_vk')); - gr4d_backendtexture_destroy := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_destroy')); - gr4d_backendtexture_get_backend_api := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_get_backend_api')); - gr4d_backendtexture_get_gl_framebuffer_info := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_get_gl_framebuffer_info')); - gr4d_backendtexture_get_height := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_get_height')); - gr4d_backendtexture_get_width := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_get_width')); - gr4d_backendtexture_has_mipmaps := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_has_mipmaps')); - gr4d_backendtexture_is_valid := GetProcAddress(LibraryHandle, PChar('gr4d_backendtexture_is_valid')); -{$ELSE} -function gr4d_backendrendertarget_create_gl; external LibraryName name 'gr4d_backendrendertarget_create_gl'; -function gr4d_backendrendertarget_create_mtl; external LibraryName name 'gr4d_backendrendertarget_create_mtl'; -function gr4d_backendrendertarget_create_vk; external LibraryName name 'gr4d_backendrendertarget_create_vk'; -procedure gr4d_backendrendertarget_destroy; external LibraryName name 'gr4d_backendrendertarget_destroy'; -function gr4d_backendrendertarget_get_backend_api; external LibraryName name 'gr4d_backendrendertarget_get_backend_api'; -function gr4d_backendrendertarget_get_height; external LibraryName name 'gr4d_backendrendertarget_get_height'; -function gr4d_backendrendertarget_get_sample_count; external LibraryName name 'gr4d_backendrendertarget_get_sample_count'; -function gr4d_backendrendertarget_get_stencil_bits; external LibraryName name 'gr4d_backendrendertarget_get_stencil_bits'; -function gr4d_backendrendertarget_get_width; external LibraryName name 'gr4d_backendrendertarget_get_width'; -function gr4d_backendrendertarget_is_valid; external LibraryName name 'gr4d_backendrendertarget_is_valid'; -function gr4d_backendtexture_create_gl; external LibraryName name 'gr4d_backendtexture_create_gl'; -function gr4d_backendtexture_create_mtl; external LibraryName name 'gr4d_backendtexture_create_mtl'; -function gr4d_backendtexture_create_vk; external LibraryName name 'gr4d_backendtexture_create_vk'; -procedure gr4d_backendtexture_destroy; external LibraryName name 'gr4d_backendtexture_destroy'; -function gr4d_backendtexture_get_backend_api; external LibraryName name 'gr4d_backendtexture_get_backend_api'; -function gr4d_backendtexture_get_gl_framebuffer_info; external LibraryName name 'gr4d_backendtexture_get_gl_framebuffer_info'; -function gr4d_backendtexture_get_height; external LibraryName name 'gr4d_backendtexture_get_height'; -function gr4d_backendtexture_get_width; external LibraryName name 'gr4d_backendtexture_get_width'; -function gr4d_backendtexture_has_mipmaps; external LibraryName name 'gr4d_backendtexture_has_mipmaps'; -function gr4d_backendtexture_is_valid; external LibraryName name 'gr4d_backendtexture_is_valid'; -{$ENDIF} - - -{ include/c/gr4d_contextoptions.h } - -{$IFNDEF SK_STATIC_LIBRARY} -gr4d_persistentcachebaseclass_create := GetProcAddress(LibraryHandle, PChar('gr4d_persistentcachebaseclass_create')); -gr4d_persistentcachebaseclass_destroy := GetProcAddress(LibraryHandle, PChar('gr4d_persistentcachebaseclass_destroy')); -gr4d_persistentcachebaseclass_set_procs := GetProcAddress(LibraryHandle, PChar('gr4d_persistentcachebaseclass_set_procs')); -{$ELSE} -function gr4d_persistentcachebaseclass_create; external LibraryName name 'gr4d_persistentcachebaseclass_create'; -procedure gr4d_persistentcachebaseclass_destroy; external LibraryName name 'gr4d_persistentcachebaseclass_destroy'; -procedure gr4d_persistentcachebaseclass_set_procs; external LibraryName name 'gr4d_persistentcachebaseclass_set_procs'; -{$ENDIF} - - -{ include/c/gr4d_directcontext.h } - -{$IFNDEF SK_STATIC_LIBRARY} - gr4d_directcontext_abandon_context := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_abandon_context')); - gr4d_directcontext_dump_memory_statistics := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_dump_memory_statistics')); - gr4d_directcontext_flush := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_flush')); - gr4d_directcontext_flush_and_submit := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_flush_and_submit')); - gr4d_directcontext_free_gpu_resources := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_free_gpu_resources')); - gr4d_directcontext_get_backend_api := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_get_backend_api')); - gr4d_directcontext_get_max_surface_sample_count_for_color_type := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_get_max_surface_sample_count_for_color_type')); - gr4d_directcontext_get_resource_cache_limit := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_get_resource_cache_limit')); - gr4d_directcontext_get_resource_cache_usage := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_get_resource_cache_usage')); - gr4d_directcontext_is_abandoned := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_is_abandoned')); - gr4d_directcontext_make_gl := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_make_gl')); - gr4d_directcontext_make_metal := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_make_metal')); - gr4d_directcontext_make_vulkan := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_make_vulkan')); - gr4d_directcontext_perform_deferred_cleanup := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_perform_deferred_cleanup')); - gr4d_directcontext_purge_unlocked_resources := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_purge_unlocked_resources')); - gr4d_directcontext_purge_unlocked_resources2 := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_purge_unlocked_resources2')); - gr4d_directcontext_release_resources_and_abandon_context := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_release_resources_and_abandon_context')); - gr4d_directcontext_reset_context := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_reset_context')); - gr4d_directcontext_set_resource_cache_limit := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_set_resource_cache_limit')); - gr4d_directcontext_submit := GetProcAddress(LibraryHandle, PChar('gr4d_directcontext_submit')); -{$ELSE} -procedure gr4d_directcontext_abandon_context; external LibraryName name 'gr4d_directcontext_abandon_context'; -procedure gr4d_directcontext_dump_memory_statistics; external LibraryName name 'gr4d_directcontext_dump_memory_statistics'; -procedure gr4d_directcontext_flush; external LibraryName name 'gr4d_directcontext_flush'; -procedure gr4d_directcontext_flush_and_submit; external LibraryName name 'gr4d_directcontext_flush_and_submit'; -procedure gr4d_directcontext_free_gpu_resources; external LibraryName name 'gr4d_directcontext_free_gpu_resources'; -function gr4d_directcontext_get_backend_api; external LibraryName name 'gr4d_directcontext_get_backend_api'; -function gr4d_directcontext_get_max_surface_sample_count_for_color_type; external LibraryName name 'gr4d_directcontext_get_max_surface_sample_count_for_color_type'; -function gr4d_directcontext_get_resource_cache_limit; external LibraryName name 'gr4d_directcontext_get_resource_cache_limit'; -procedure gr4d_directcontext_get_resource_cache_usage; external LibraryName name 'gr4d_directcontext_get_resource_cache_usage'; -function gr4d_directcontext_is_abandoned; external LibraryName name 'gr4d_directcontext_is_abandoned'; -function gr4d_directcontext_make_gl; external LibraryName name 'gr4d_directcontext_make_gl'; -function gr4d_directcontext_make_metal; external LibraryName name 'gr4d_directcontext_make_metal'; -function gr4d_directcontext_make_vulkan; external LibraryName name 'gr4d_directcontext_make_vulkan'; -procedure gr4d_directcontext_perform_deferred_cleanup; external LibraryName name 'gr4d_directcontext_perform_deferred_cleanup'; -procedure gr4d_directcontext_purge_unlocked_resources; external LibraryName name 'gr4d_directcontext_purge_unlocked_resources'; -procedure gr4d_directcontext_purge_unlocked_resources2; external LibraryName name 'gr4d_directcontext_purge_unlocked_resources2'; -procedure gr4d_directcontext_release_resources_and_abandon_context; external LibraryName name 'gr4d_directcontext_release_resources_and_abandon_context'; -procedure gr4d_directcontext_reset_context; external LibraryName name 'gr4d_directcontext_reset_context'; -procedure gr4d_directcontext_set_resource_cache_limit; external LibraryName name 'gr4d_directcontext_set_resource_cache_limit'; -function gr4d_directcontext_submit; external LibraryName name 'gr4d_directcontext_submit'; -{$ENDIF} - - -{ include/c/gr4d_gl_interface.h } - -{$IFNDEF SK_STATIC_LIBRARY} - gr4d_gl_interface_has_extension := GetProcAddress(LibraryHandle, PChar('gr4d_gl_interface_has_extension')); - gr4d_gl_interface_make_assembled := GetProcAddress(LibraryHandle, PChar('gr4d_gl_interface_make_assembled')); - gr4d_gl_interface_make_assembled_gl := GetProcAddress(LibraryHandle, PChar('gr4d_gl_interface_make_assembled_gl')); - gr4d_gl_interface_make_assembled_gles := GetProcAddress(LibraryHandle, PChar('gr4d_gl_interface_make_assembled_gles')); - gr4d_gl_interface_make_assembled_webgl := GetProcAddress(LibraryHandle, PChar('gr4d_gl_interface_make_assembled_webgl')); - gr4d_gl_interface_make_native := GetProcAddress(LibraryHandle, PChar('gr4d_gl_interface_make_native')); - gr4d_gl_interface_validate := GetProcAddress(LibraryHandle, PChar('gr4d_gl_interface_validate')); -{$ELSE} -function gr4d_gl_interface_has_extension; external LibraryName name 'gr4d_gl_interface_has_extension'; -function gr4d_gl_interface_make_assembled; external LibraryName name 'gr4d_gl_interface_make_assembled'; -function gr4d_gl_interface_make_assembled_gl; external LibraryName name 'gr4d_gl_interface_make_assembled_gl'; -function gr4d_gl_interface_make_assembled_gles; external LibraryName name 'gr4d_gl_interface_make_assembled_gles'; -function gr4d_gl_interface_make_assembled_webgl; external LibraryName name 'gr4d_gl_interface_make_assembled_webgl'; -function gr4d_gl_interface_make_native; external LibraryName name 'gr4d_gl_interface_make_native'; -function gr4d_gl_interface_validate; external LibraryName name 'gr4d_gl_interface_validate'; -{$ENDIF} - - -{ include/c/gr4d_shadererrorhandler.h } - -{$IFNDEF SK_STATIC_LIBRARY} -gr4d_shadererrorhandlerbaseclass_create := GetProcAddress(LibraryHandle, PChar('gr4d_shadererrorhandlerbaseclass_create')); -gr4d_shadererrorhandlerbaseclass_destroy := GetProcAddress(LibraryHandle, PChar('gr4d_shadererrorhandlerbaseclass_destroy')); -gr4d_shadererrorhandlerbaseclass_set_procs := GetProcAddress(LibraryHandle, PChar('gr4d_shadererrorhandlerbaseclass_set_procs')); -{$ELSE} -function gr4d_shadererrorhandlerbaseclass_create; external LibraryName name 'gr4d_shadererrorhandlerbaseclass_create'; -procedure gr4d_shadererrorhandlerbaseclass_destroy; external LibraryName name 'gr4d_shadererrorhandlerbaseclass_destroy'; -procedure gr4d_shadererrorhandlerbaseclass_set_procs; external LibraryName name 'gr4d_shadererrorhandlerbaseclass_set_procs'; -{$ENDIF} - - -{ include/c/gr4d_vk_extensions.h } - -{$IFNDEF SK_STATIC_LIBRARY} -gr4d_vk_extensions_create := GetProcAddress(LibraryHandle, PChar('gr4d_vk_extensions_create')); -gr4d_vk_extensions_destroy := GetProcAddress(LibraryHandle, PChar('gr4d_vk_extensions_destroy')); -gr4d_vk_extensions_has_extension := GetProcAddress(LibraryHandle, PChar('gr4d_vk_extensions_has_extension')); -gr4d_vk_extensions_init := GetProcAddress(LibraryHandle, PChar('gr4d_vk_extensions_init')); -{$ELSE} -function gr4d_vk_extensions_create; external LibraryName name 'gr4d_vk_extensions_create'; -procedure gr4d_vk_extensions_destroy; external LibraryName name 'gr4d_vk_extensions_destroy'; -function gr4d_vk_extensions_has_extension; external LibraryName name 'gr4d_vk_extensions_has_extension'; -procedure gr4d_vk_extensions_init; external LibraryName name 'gr4d_vk_extensions_init'; -{$ENDIF} - - -{ include/c/sk4d_blender.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_blender_make_arithmetic := GetProcAddress(LibraryHandle, PChar('sk4d_blender_make_arithmetic')); - sk4d_blender_make_mode := GetProcAddress(LibraryHandle, PChar('sk4d_blender_make_mode')); -{$ELSE} -function sk4d_blender_make_arithmetic; external LibraryName name 'sk4d_blender_make_arithmetic'; -function sk4d_blender_make_mode; external LibraryName name 'sk4d_blender_make_mode'; -{$ENDIF} - - -{ include/c/sk4d_canvas.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_canvas_clear := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_clear')); - sk4d_canvas_clear2 := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_clear2')); - sk4d_canvas_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_destroy')); - sk4d_canvas_discard := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_discard')); - sk4d_canvas_clip_path := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_clip_path')); - sk4d_canvas_clip_rect := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_clip_rect')); - sk4d_canvas_clip_region := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_clip_region')); - sk4d_canvas_clip_rrect := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_clip_rrect')); - sk4d_canvas_clip_shader := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_clip_shader')); - sk4d_canvas_concat := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_concat')); - sk4d_canvas_concat2 := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_concat2')); - sk4d_canvas_draw_annotation := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_annotation')); - sk4d_canvas_draw_arc := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_arc')); - sk4d_canvas_draw_atlas := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_atlas')); - sk4d_canvas_draw_circle := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_circle')); - sk4d_canvas_draw_color := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_color')); - sk4d_canvas_draw_color2 := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_color2')); - sk4d_canvas_draw_glyphs := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_glyphs')); - sk4d_canvas_draw_glyphs2 := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_glyphs2')); - sk4d_canvas_draw_image := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_image')); - sk4d_canvas_draw_image_lattice := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_image_lattice')); - sk4d_canvas_draw_image_nine := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_image_nine')); - sk4d_canvas_draw_image_rect := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_image_rect')); - sk4d_canvas_draw_line := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_line')); - sk4d_canvas_draw_oval := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_oval')); - sk4d_canvas_draw_paint := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_paint')); - sk4d_canvas_draw_patch := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_patch')); - sk4d_canvas_draw_path := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_path')); - sk4d_canvas_draw_picture := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_picture')); - sk4d_canvas_draw_point := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_point')); - sk4d_canvas_draw_points := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_points')); - sk4d_canvas_draw_rect := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_rect')); - sk4d_canvas_draw_region := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_region')); - sk4d_canvas_draw_rrect := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_rrect')); - sk4d_canvas_draw_rrect2 := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_rrect2')); - sk4d_canvas_draw_rrect_difference := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_rrect_difference')); - sk4d_canvas_draw_simple_text := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_simple_text')); - sk4d_canvas_draw_text_blob := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_text_blob')); - sk4d_canvas_draw_vertices := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_draw_vertices')); - sk4d_canvas_get_base_props := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_get_base_props')); - sk4d_canvas_get_device_clip_bounds := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_get_device_clip_bounds')); - sk4d_canvas_get_local_clip_bounds := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_get_local_clip_bounds')); - sk4d_canvas_get_local_to_device := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_get_local_to_device')); - sk4d_canvas_get_local_to_device_as_3x3 := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_get_local_to_device_as_3x3')); - sk4d_canvas_get_top_props := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_get_top_props')); - sk4d_canvas_get_save_count := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_get_save_count')); - sk4d_canvas_make_surface := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_make_surface')); - sk4d_canvas_quick_reject := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_quick_reject')); - sk4d_canvas_quick_reject2 := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_quick_reject2')); - sk4d_canvas_reset_matrix := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_reset_matrix')); - sk4d_canvas_restore := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_restore')); - sk4d_canvas_restore_to_count := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_restore_to_count')); - sk4d_canvas_rotate := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_rotate')); - sk4d_canvas_rotate2 := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_rotate2')); - sk4d_canvas_save := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_save')); - sk4d_canvas_save_layer := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_save_layer')); - sk4d_canvas_save_layer_alpha := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_save_layer_alpha')); - sk4d_canvas_scale := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_scale')); - sk4d_canvas_set_matrix := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_set_matrix')); - sk4d_canvas_set_matrix2 := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_set_matrix2')); - sk4d_canvas_skew := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_skew')); - sk4d_canvas_translate := GetProcAddress(LibraryHandle, PChar('sk4d_canvas_translate')); -{$ELSE} -procedure sk4d_canvas_clear; external LibraryName name 'sk4d_canvas_clear'; -procedure sk4d_canvas_clear2; external LibraryName name 'sk4d_canvas_clear2'; -procedure sk4d_canvas_destroy; external LibraryName name 'sk4d_canvas_destroy'; -procedure sk4d_canvas_discard; external LibraryName name 'sk4d_canvas_discard'; -procedure sk4d_canvas_clip_path; external LibraryName name 'sk4d_canvas_clip_path'; -procedure sk4d_canvas_clip_rect; external LibraryName name 'sk4d_canvas_clip_rect'; -procedure sk4d_canvas_clip_region; external LibraryName name 'sk4d_canvas_clip_region'; -procedure sk4d_canvas_clip_rrect; external LibraryName name 'sk4d_canvas_clip_rrect'; -procedure sk4d_canvas_clip_shader; external LibraryName name 'sk4d_canvas_clip_shader'; -procedure sk4d_canvas_concat; external LibraryName name 'sk4d_canvas_concat'; -procedure sk4d_canvas_concat2; external LibraryName name 'sk4d_canvas_concat2'; -procedure sk4d_canvas_draw_annotation; external LibraryName name 'sk4d_canvas_draw_annotation'; -procedure sk4d_canvas_draw_arc; external LibraryName name 'sk4d_canvas_draw_arc'; -procedure sk4d_canvas_draw_atlas; external LibraryName name 'sk4d_canvas_draw_atlas'; -procedure sk4d_canvas_draw_circle; external LibraryName name 'sk4d_canvas_draw_circle'; -procedure sk4d_canvas_draw_color; external LibraryName name 'sk4d_canvas_draw_color'; -procedure sk4d_canvas_draw_color2; external LibraryName name 'sk4d_canvas_draw_color2'; -procedure sk4d_canvas_draw_glyphs; external LibraryName name 'sk4d_canvas_draw_glyphs'; -procedure sk4d_canvas_draw_glyphs2; external LibraryName name 'sk4d_canvas_draw_glyphs2'; -procedure sk4d_canvas_draw_image; external LibraryName name 'sk4d_canvas_draw_image'; -procedure sk4d_canvas_draw_image_lattice; external LibraryName name 'sk4d_canvas_draw_image_lattice'; -procedure sk4d_canvas_draw_image_nine; external LibraryName name 'sk4d_canvas_draw_image_nine'; -procedure sk4d_canvas_draw_image_rect; external LibraryName name 'sk4d_canvas_draw_image_rect'; -procedure sk4d_canvas_draw_line; external LibraryName name 'sk4d_canvas_draw_line'; -procedure sk4d_canvas_draw_oval; external LibraryName name 'sk4d_canvas_draw_oval'; -procedure sk4d_canvas_draw_paint; external LibraryName name 'sk4d_canvas_draw_paint'; -procedure sk4d_canvas_draw_patch; external LibraryName name 'sk4d_canvas_draw_patch'; -procedure sk4d_canvas_draw_path; external LibraryName name 'sk4d_canvas_draw_path'; -procedure sk4d_canvas_draw_picture; external LibraryName name 'sk4d_canvas_draw_picture'; -procedure sk4d_canvas_draw_point; external LibraryName name 'sk4d_canvas_draw_point'; -procedure sk4d_canvas_draw_points; external LibraryName name 'sk4d_canvas_draw_points'; -procedure sk4d_canvas_draw_rect; external LibraryName name 'sk4d_canvas_draw_rect'; -procedure sk4d_canvas_draw_region; external LibraryName name 'sk4d_canvas_draw_region'; -procedure sk4d_canvas_draw_rrect; external LibraryName name 'sk4d_canvas_draw_rrect'; -procedure sk4d_canvas_draw_rrect2; external LibraryName name 'sk4d_canvas_draw_rrect2'; -procedure sk4d_canvas_draw_rrect_difference; external LibraryName name 'sk4d_canvas_draw_rrect_difference'; -procedure sk4d_canvas_draw_simple_text; external LibraryName name 'sk4d_canvas_draw_simple_text'; -procedure sk4d_canvas_draw_text_blob; external LibraryName name 'sk4d_canvas_draw_text_blob'; -procedure sk4d_canvas_draw_vertices; external LibraryName name 'sk4d_canvas_draw_vertices'; -procedure sk4d_canvas_get_base_props; external LibraryName name 'sk4d_canvas_get_base_props'; -procedure sk4d_canvas_get_device_clip_bounds; external LibraryName name 'sk4d_canvas_get_device_clip_bounds'; -procedure sk4d_canvas_get_local_clip_bounds; external LibraryName name 'sk4d_canvas_get_local_clip_bounds'; -procedure sk4d_canvas_get_local_to_device; external LibraryName name 'sk4d_canvas_get_local_to_device'; -procedure sk4d_canvas_get_local_to_device_as_3x3; external LibraryName name 'sk4d_canvas_get_local_to_device_as_3x3'; -procedure sk4d_canvas_get_top_props; external LibraryName name 'sk4d_canvas_get_top_props'; -function sk4d_canvas_get_save_count; external LibraryName name 'sk4d_canvas_get_save_count'; -function sk4d_canvas_make_surface; external LibraryName name 'sk4d_canvas_make_surface'; -function sk4d_canvas_quick_reject; external LibraryName name 'sk4d_canvas_quick_reject'; -function sk4d_canvas_quick_reject2; external LibraryName name 'sk4d_canvas_quick_reject2'; -procedure sk4d_canvas_reset_matrix; external LibraryName name 'sk4d_canvas_reset_matrix'; -procedure sk4d_canvas_restore; external LibraryName name 'sk4d_canvas_restore'; -procedure sk4d_canvas_restore_to_count; external LibraryName name 'sk4d_canvas_restore_to_count'; -procedure sk4d_canvas_rotate; external LibraryName name 'sk4d_canvas_rotate'; -procedure sk4d_canvas_rotate2; external LibraryName name 'sk4d_canvas_rotate2'; -function sk4d_canvas_save; external LibraryName name 'sk4d_canvas_save'; -function sk4d_canvas_save_layer; external LibraryName name 'sk4d_canvas_save_layer'; -function sk4d_canvas_save_layer_alpha; external LibraryName name 'sk4d_canvas_save_layer_alpha'; -procedure sk4d_canvas_scale; external LibraryName name 'sk4d_canvas_scale'; -procedure sk4d_canvas_set_matrix; external LibraryName name 'sk4d_canvas_set_matrix'; -procedure sk4d_canvas_set_matrix2; external LibraryName name 'sk4d_canvas_set_matrix2'; -procedure sk4d_canvas_skew; external LibraryName name 'sk4d_canvas_skew'; -procedure sk4d_canvas_translate; external LibraryName name 'sk4d_canvas_translate'; -{$ENDIF} - - -{ include/c/sk4d_codec.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_codec_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_codec_destroy')); - sk4d_codec_get_dimensions := GetProcAddress(LibraryHandle, PChar('sk4d_codec_get_dimensions')); - sk4d_codec_get_encoded_image_format := GetProcAddress(LibraryHandle, PChar('sk4d_codec_get_encoded_image_format')); - sk4d_codec_get_image := GetProcAddress(LibraryHandle, PChar('sk4d_codec_get_image')); - sk4d_codec_get_pixels := GetProcAddress(LibraryHandle, PChar('sk4d_codec_get_pixels')); - sk4d_codec_make_from_file := GetProcAddress(LibraryHandle, PChar('sk4d_codec_make_from_file')); - sk4d_codec_make_from_stream := GetProcAddress(LibraryHandle, PChar('sk4d_codec_make_from_stream')); - sk4d_codec_make_with_copy := GetProcAddress(LibraryHandle, PChar('sk4d_codec_make_with_copy')); - sk4d_codec_make_without_copy := GetProcAddress(LibraryHandle, PChar('sk4d_codec_make_without_copy')); - sk4d_animcodecplayer_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_animcodecplayer_destroy')); - sk4d_animcodecplayer_get_dimensions := GetProcAddress(LibraryHandle, PChar('sk4d_animcodecplayer_get_dimensions')); - sk4d_animcodecplayer_get_duration := GetProcAddress(LibraryHandle, PChar('sk4d_animcodecplayer_get_duration')); - sk4d_animcodecplayer_get_frame := GetProcAddress(LibraryHandle, PChar('sk4d_animcodecplayer_get_frame')); - sk4d_animcodecplayer_make_from_file := GetProcAddress(LibraryHandle, PChar('sk4d_animcodecplayer_make_from_file')); - sk4d_animcodecplayer_make_from_stream := GetProcAddress(LibraryHandle, PChar('sk4d_animcodecplayer_make_from_stream')); - sk4d_animcodecplayer_seek := GetProcAddress(LibraryHandle, PChar('sk4d_animcodecplayer_seek')); -{$ELSE} -procedure sk4d_codec_destroy; external LibraryName name 'sk4d_codec_destroy'; -procedure sk4d_codec_get_dimensions; external LibraryName name 'sk4d_codec_get_dimensions'; -function sk4d_codec_get_encoded_image_format; external LibraryName name 'sk4d_codec_get_encoded_image_format'; -function sk4d_codec_get_image; external LibraryName name 'sk4d_codec_get_image'; -function sk4d_codec_get_pixels; external LibraryName name 'sk4d_codec_get_pixels'; -function sk4d_codec_make_from_file; external LibraryName name 'sk4d_codec_make_from_file'; -function sk4d_codec_make_from_stream; external LibraryName name 'sk4d_codec_make_from_stream'; -function sk4d_codec_make_with_copy; external LibraryName name 'sk4d_codec_make_with_copy'; -function sk4d_codec_make_without_copy; external LibraryName name 'sk4d_codec_make_without_copy'; -procedure sk4d_animcodecplayer_destroy; external LibraryName name 'sk4d_animcodecplayer_destroy'; -procedure sk4d_animcodecplayer_get_dimensions; external LibraryName name 'sk4d_animcodecplayer_get_dimensions'; -function sk4d_animcodecplayer_get_duration; external LibraryName name 'sk4d_animcodecplayer_get_duration'; -function sk4d_animcodecplayer_get_frame; external LibraryName name 'sk4d_animcodecplayer_get_frame'; -function sk4d_animcodecplayer_make_from_file; external LibraryName name 'sk4d_animcodecplayer_make_from_file'; -function sk4d_animcodecplayer_make_from_stream; external LibraryName name 'sk4d_animcodecplayer_make_from_stream'; -function sk4d_animcodecplayer_seek; external LibraryName name 'sk4d_animcodecplayer_seek'; -{$ENDIF} - - -{ include/c/sk4d_colorfilter.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_colorfilter_make_blend := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_blend')); - sk4d_colorfilter_make_blend2 := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_blend2')); - sk4d_colorfilter_make_compose := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_compose')); - sk4d_colorfilter_make_high_contrast := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_high_contrast')); - sk4d_colorfilter_make_hsla_matrix := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_hsla_matrix')); - sk4d_colorfilter_make_lighting := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_lighting')); - sk4d_colorfilter_make_linear_to_srgb_gamma := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_linear_to_srgb_gamma')); - sk4d_colorfilter_make_luma_color := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_luma_color')); - sk4d_colorfilter_make_matrix := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_matrix')); - sk4d_colorfilter_make_overdraw := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_overdraw')); - sk4d_colorfilter_make_table := GetProcAddress(LibraryHandle, PChar('sk4d_colorfilter_make_table')); -{$ELSE} -function sk4d_colorfilter_make_blend; external LibraryName name 'sk4d_colorfilter_make_blend'; -function sk4d_colorfilter_make_blend2; external LibraryName name 'sk4d_colorfilter_make_blend2'; -function sk4d_colorfilter_make_compose; external LibraryName name 'sk4d_colorfilter_make_compose'; -function sk4d_colorfilter_make_high_contrast; external LibraryName name 'sk4d_colorfilter_make_high_contrast'; -function sk4d_colorfilter_make_hsla_matrix; external LibraryName name 'sk4d_colorfilter_make_hsla_matrix'; -function sk4d_colorfilter_make_lighting; external LibraryName name 'sk4d_colorfilter_make_lighting'; -function sk4d_colorfilter_make_linear_to_srgb_gamma; external LibraryName name 'sk4d_colorfilter_make_linear_to_srgb_gamma'; -function sk4d_colorfilter_make_luma_color; external LibraryName name 'sk4d_colorfilter_make_luma_color'; -function sk4d_colorfilter_make_matrix; external LibraryName name 'sk4d_colorfilter_make_matrix'; -function sk4d_colorfilter_make_overdraw; external LibraryName name 'sk4d_colorfilter_make_overdraw'; -function sk4d_colorfilter_make_table; external LibraryName name 'sk4d_colorfilter_make_table'; -{$ENDIF} - - -{ include/c/sk4d_colorspace.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_colorspace_gamma_close_to_srgb := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_gamma_close_to_srgb')); - sk4d_colorspace_gamma_is_linear := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_gamma_is_linear')); - sk4d_colorspace_is_equal := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_is_equal')); - sk4d_colorspace_is_numerical_transfer_fn := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_is_numerical_transfer_fn')); - sk4d_colorspace_is_srgb := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_is_srgb')); - sk4d_colorspace_make := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_make')); - sk4d_colorspace_make_linear_gamma := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_make_linear_gamma')); - sk4d_colorspace_make_rgb := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_make_rgb')); - sk4d_colorspace_make_srgb := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_make_srgb')); - sk4d_colorspace_make_srgb_gamma := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_make_srgb_gamma')); - sk4d_colorspace_make_srgb_linear := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_make_srgb_linear')); - sk4d_colorspace_ref := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_ref')); - sk4d_colorspace_to_profile := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_to_profile')); - sk4d_colorspace_to_xyz := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_to_xyz')); - sk4d_colorspace_unref := GetProcAddress(LibraryHandle, PChar('sk4d_colorspace_unref')); - sk4d_colorspaceiccprofile_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_colorspaceiccprofile_destroy')); - sk4d_colorspaceiccprofile_get_buffer := GetProcAddress(LibraryHandle, PChar('sk4d_colorspaceiccprofile_get_buffer')); - sk4d_colorspaceiccprofile_make_with_parse := GetProcAddress(LibraryHandle, PChar('sk4d_colorspaceiccprofile_make_with_parse')); - sk4d_colorspaceiccprofile_to_xyz := GetProcAddress(LibraryHandle, PChar('sk4d_colorspaceiccprofile_to_xyz')); - sk4d_colorspaceprimaries_to_xyz := GetProcAddress(LibraryHandle, PChar('sk4d_colorspaceprimaries_to_xyz')); - sk4d_colorspacetransferfn_invert := GetProcAddress(LibraryHandle, PChar('sk4d_colorspacetransferfn_invert')); - sk4d_colorspacetransferfn_transform := GetProcAddress(LibraryHandle, PChar('sk4d_colorspacetransferfn_transform')); -{$ELSE} -function sk4d_colorspace_gamma_close_to_srgb; external LibraryName name 'sk4d_colorspace_gamma_close_to_srgb'; -function sk4d_colorspace_gamma_is_linear; external LibraryName name 'sk4d_colorspace_gamma_is_linear'; -function sk4d_colorspace_is_equal; external LibraryName name 'sk4d_colorspace_is_equal'; -function sk4d_colorspace_is_numerical_transfer_fn; external LibraryName name 'sk4d_colorspace_is_numerical_transfer_fn'; -function sk4d_colorspace_is_srgb; external LibraryName name 'sk4d_colorspace_is_srgb'; -function sk4d_colorspace_make; external LibraryName name 'sk4d_colorspace_make'; -function sk4d_colorspace_make_linear_gamma; external LibraryName name 'sk4d_colorspace_make_linear_gamma'; -function sk4d_colorspace_make_rgb; external LibraryName name 'sk4d_colorspace_make_rgb'; -function sk4d_colorspace_make_srgb; external LibraryName name 'sk4d_colorspace_make_srgb'; -function sk4d_colorspace_make_srgb_gamma; external LibraryName name 'sk4d_colorspace_make_srgb_gamma'; -function sk4d_colorspace_make_srgb_linear; external LibraryName name 'sk4d_colorspace_make_srgb_linear'; -procedure sk4d_colorspace_ref; external LibraryName name 'sk4d_colorspace_ref'; -function sk4d_colorspace_to_profile; external LibraryName name 'sk4d_colorspace_to_profile'; -function sk4d_colorspace_to_xyz; external LibraryName name 'sk4d_colorspace_to_xyz'; -procedure sk4d_colorspace_unref; external LibraryName name 'sk4d_colorspace_unref'; -procedure sk4d_colorspaceiccprofile_destroy; external LibraryName name 'sk4d_colorspaceiccprofile_destroy'; -function sk4d_colorspaceiccprofile_get_buffer; external LibraryName name 'sk4d_colorspaceiccprofile_get_buffer'; -function sk4d_colorspaceiccprofile_make_with_parse; external LibraryName name 'sk4d_colorspaceiccprofile_make_with_parse'; -function sk4d_colorspaceiccprofile_to_xyz; external LibraryName name 'sk4d_colorspaceiccprofile_to_xyz'; -function sk4d_colorspaceprimaries_to_xyz; external LibraryName name 'sk4d_colorspaceprimaries_to_xyz'; -function sk4d_colorspacetransferfn_invert; external LibraryName name 'sk4d_colorspacetransferfn_invert'; -function sk4d_colorspacetransferfn_transform; external LibraryName name 'sk4d_colorspacetransferfn_transform'; -{$ENDIF} - - -{ include/c/sk4d_data.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_data_make_empty := GetProcAddress(LibraryHandle, PChar('sk4d_data_make_empty')); - sk4d_data_make_with_copy := GetProcAddress(LibraryHandle, PChar('sk4d_data_make_with_copy')); - sk4d_data_ref := GetProcAddress(LibraryHandle, PChar('sk4d_data_ref')); - sk4d_data_unref := GetProcAddress(LibraryHandle, PChar('sk4d_data_unref')); -{$ELSE} -function sk4d_data_make_empty; external LibraryName name 'sk4d_data_make_empty'; -function sk4d_data_make_with_copy; external LibraryName name 'sk4d_data_make_with_copy'; -procedure sk4d_data_ref; external LibraryName name 'sk4d_data_ref'; -procedure sk4d_data_unref; external LibraryName name 'sk4d_data_unref'; -{$ENDIF} - - -{ include/c/sk4d_document.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_document_begin_page := GetProcAddress(LibraryHandle, PChar('sk4d_document_begin_page')); - sk4d_document_close := GetProcAddress(LibraryHandle, PChar('sk4d_document_close')); - sk4d_document_end_page := GetProcAddress(LibraryHandle, PChar('sk4d_document_end_page')); - sk4d_document_make_pdf := GetProcAddress(LibraryHandle, PChar('sk4d_document_make_pdf')); - sk4d_document_make_pdf2 := GetProcAddress(LibraryHandle, PChar('sk4d_document_make_pdf2')); - sk4d_document_make_xps := GetProcAddress(LibraryHandle, PChar('sk4d_document_make_xps')); - sk4d_document_terminate := GetProcAddress(LibraryHandle, PChar('sk4d_document_terminate')); -{$ELSE} -function sk4d_document_begin_page; external LibraryName name 'sk4d_document_begin_page'; -procedure sk4d_document_close; external LibraryName name 'sk4d_document_close'; -procedure sk4d_document_end_page; external LibraryName name 'sk4d_document_end_page'; -function sk4d_document_make_pdf; external LibraryName name 'sk4d_document_make_pdf'; -function sk4d_document_make_pdf2; external LibraryName name 'sk4d_document_make_pdf2'; -function sk4d_document_make_xps; external LibraryName name 'sk4d_document_make_xps'; -procedure sk4d_document_terminate; external LibraryName name 'sk4d_document_terminate'; -{$ENDIF} - - -{ include/c/sk4d_font.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_font_create := GetProcAddress(LibraryHandle, PChar('sk4d_font_create')); - sk4d_font_create2 := GetProcAddress(LibraryHandle, PChar('sk4d_font_create2')); - sk4d_font_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_font_destroy')); - sk4d_font_get_baseline_snap := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_baseline_snap')); - sk4d_font_get_edging := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_edging')); - sk4d_font_get_embedded_bitmaps := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_embedded_bitmaps')); - sk4d_font_get_embolden := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_embolden')); - sk4d_font_get_force_auto_hinting := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_force_auto_hinting')); - sk4d_font_get_glyphs := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_glyphs')); - sk4d_font_get_glyphs_count := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_glyphs_count')); - sk4d_font_get_hinting := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_hinting')); - sk4d_font_get_horizontal_positions := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_horizontal_positions')); - sk4d_font_get_intercepts := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_intercepts')); - sk4d_font_get_linear_metrics := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_linear_metrics')); - sk4d_font_get_metrics := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_metrics')); - sk4d_font_get_path := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_path')); - sk4d_font_get_paths := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_paths')); - sk4d_font_get_positions := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_positions')); - sk4d_font_get_scale_x := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_scale_x')); - sk4d_font_get_size := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_size')); - sk4d_font_get_skew_x := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_skew_x')); - sk4d_font_get_subpixel := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_subpixel')); - sk4d_font_get_typeface := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_typeface')); - sk4d_font_get_typeface_or_default := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_typeface_or_default')); - sk4d_font_get_widths_bounds := GetProcAddress(LibraryHandle, PChar('sk4d_font_get_widths_bounds')); - sk4d_font_is_equal := GetProcAddress(LibraryHandle, PChar('sk4d_font_is_equal')); - sk4d_font_measure_text := GetProcAddress(LibraryHandle, PChar('sk4d_font_measure_text')); - sk4d_font_set_baseline_snap := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_baseline_snap')); - sk4d_font_set_edging := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_edging')); - sk4d_font_set_embedded_bitmaps := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_embedded_bitmaps')); - sk4d_font_set_embolden := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_embolden')); - sk4d_font_set_force_auto_hinting := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_force_auto_hinting')); - sk4d_font_set_hinting := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_hinting')); - sk4d_font_set_linear_metrics := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_linear_metrics')); - sk4d_font_set_scale_x := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_scale_x')); - sk4d_font_set_size := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_size')); - sk4d_font_set_skew_x := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_skew_x')); - sk4d_font_set_subpixel := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_subpixel')); - sk4d_font_set_typeface := GetProcAddress(LibraryHandle, PChar('sk4d_font_set_typeface')); - sk4d_font_unichar_to_glyph := GetProcAddress(LibraryHandle, PChar('sk4d_font_unichar_to_glyph')); - sk4d_font_unichars_to_glyphs := GetProcAddress(LibraryHandle, PChar('sk4d_font_unichars_to_glyphs')); -{$ELSE} -function sk4d_font_create; external LibraryName name 'sk4d_font_create'; -function sk4d_font_create2; external LibraryName name 'sk4d_font_create2'; -procedure sk4d_font_destroy; external LibraryName name 'sk4d_font_destroy'; -function sk4d_font_get_baseline_snap; external LibraryName name 'sk4d_font_get_baseline_snap'; -function sk4d_font_get_edging; external LibraryName name 'sk4d_font_get_edging'; -function sk4d_font_get_embedded_bitmaps; external LibraryName name 'sk4d_font_get_embedded_bitmaps'; -function sk4d_font_get_embolden; external LibraryName name 'sk4d_font_get_embolden'; -function sk4d_font_get_force_auto_hinting; external LibraryName name 'sk4d_font_get_force_auto_hinting'; -function sk4d_font_get_glyphs; external LibraryName name 'sk4d_font_get_glyphs'; -function sk4d_font_get_glyphs_count; external LibraryName name 'sk4d_font_get_glyphs_count'; -function sk4d_font_get_hinting; external LibraryName name 'sk4d_font_get_hinting'; -procedure sk4d_font_get_horizontal_positions; external LibraryName name 'sk4d_font_get_horizontal_positions'; -function sk4d_font_get_intercepts; external LibraryName name 'sk4d_font_get_intercepts'; -function sk4d_font_get_linear_metrics; external LibraryName name 'sk4d_font_get_linear_metrics'; -function sk4d_font_get_metrics; external LibraryName name 'sk4d_font_get_metrics'; -function sk4d_font_get_path; external LibraryName name 'sk4d_font_get_path'; -procedure sk4d_font_get_paths; external LibraryName name 'sk4d_font_get_paths'; -procedure sk4d_font_get_positions; external LibraryName name 'sk4d_font_get_positions'; -function sk4d_font_get_scale_x; external LibraryName name 'sk4d_font_get_scale_x'; -function sk4d_font_get_size; external LibraryName name 'sk4d_font_get_size'; -function sk4d_font_get_skew_x; external LibraryName name 'sk4d_font_get_skew_x'; -function sk4d_font_get_subpixel; external LibraryName name 'sk4d_font_get_subpixel'; -function sk4d_font_get_typeface; external LibraryName name 'sk4d_font_get_typeface'; -function sk4d_font_get_typeface_or_default; external LibraryName name 'sk4d_font_get_typeface_or_default'; -procedure sk4d_font_get_widths_bounds; external LibraryName name 'sk4d_font_get_widths_bounds'; -function sk4d_font_is_equal; external LibraryName name 'sk4d_font_is_equal'; -function sk4d_font_measure_text; external LibraryName name 'sk4d_font_measure_text'; -procedure sk4d_font_set_baseline_snap; external LibraryName name 'sk4d_font_set_baseline_snap'; -procedure sk4d_font_set_edging; external LibraryName name 'sk4d_font_set_edging'; -procedure sk4d_font_set_embedded_bitmaps; external LibraryName name 'sk4d_font_set_embedded_bitmaps'; -procedure sk4d_font_set_embolden; external LibraryName name 'sk4d_font_set_embolden'; -procedure sk4d_font_set_force_auto_hinting; external LibraryName name 'sk4d_font_set_force_auto_hinting'; -procedure sk4d_font_set_hinting; external LibraryName name 'sk4d_font_set_hinting'; -procedure sk4d_font_set_linear_metrics; external LibraryName name 'sk4d_font_set_linear_metrics'; -procedure sk4d_font_set_scale_x; external LibraryName name 'sk4d_font_set_scale_x'; -procedure sk4d_font_set_size; external LibraryName name 'sk4d_font_set_size'; -procedure sk4d_font_set_skew_x; external LibraryName name 'sk4d_font_set_skew_x'; -procedure sk4d_font_set_subpixel; external LibraryName name 'sk4d_font_set_subpixel'; -procedure sk4d_font_set_typeface; external LibraryName name 'sk4d_font_set_typeface'; -function sk4d_font_unichar_to_glyph; external LibraryName name 'sk4d_font_unichar_to_glyph'; -procedure sk4d_font_unichars_to_glyphs; external LibraryName name 'sk4d_font_unichars_to_glyphs'; -{$ENDIF} - - -{ include/c/sk4d_graphics.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_graphics_allow_jit := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_allow_jit')); - sk4d_graphics_dump_memory_statistics := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_dump_memory_statistics')); - sk4d_graphics_get_font_cache_count_limit := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_get_font_cache_count_limit')); - sk4d_graphics_get_font_cache_count_used := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_get_font_cache_count_used')); - sk4d_graphics_get_font_cache_limit := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_get_font_cache_limit')); - sk4d_graphics_get_font_cache_used := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_get_font_cache_used')); - sk4d_graphics_get_resource_cache_single_allocation_byte_limit := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_get_resource_cache_single_allocation_byte_limit')); - sk4d_graphics_get_resource_cache_total_byte_limit := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_get_resource_cache_total_byte_limit')); - sk4d_graphics_get_resource_cache_total_bytes_used := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_get_resource_cache_total_bytes_used')); - sk4d_graphics_init := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_init')); - sk4d_graphics_purge_all_caches := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_purge_all_caches')); - sk4d_graphics_purge_font_cache := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_purge_font_cache')); - sk4d_graphics_purge_resource_cache := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_purge_resource_cache')); - sk4d_graphics_set_font_cache_count_limit := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_set_font_cache_count_limit')); - sk4d_graphics_set_font_cache_limit := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_set_font_cache_limit')); - sk4d_graphics_set_resource_cache_single_allocation_byte_limit := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_set_resource_cache_single_allocation_byte_limit')); - sk4d_graphics_set_resource_cache_total_byte_limit := GetProcAddress(LibraryHandle, PChar('sk4d_graphics_set_resource_cache_total_byte_limit')); -{$ELSE} -procedure sk4d_graphics_allow_jit; external LibraryName name 'sk4d_graphics_allow_jit'; -procedure sk4d_graphics_dump_memory_statistics; external LibraryName name 'sk4d_graphics_dump_memory_statistics'; -function sk4d_graphics_get_font_cache_count_limit; external LibraryName name 'sk4d_graphics_get_font_cache_count_limit'; -function sk4d_graphics_get_font_cache_count_used; external LibraryName name 'sk4d_graphics_get_font_cache_count_used'; -function sk4d_graphics_get_font_cache_limit; external LibraryName name 'sk4d_graphics_get_font_cache_limit'; -function sk4d_graphics_get_font_cache_used; external LibraryName name 'sk4d_graphics_get_font_cache_used'; -function sk4d_graphics_get_resource_cache_single_allocation_byte_limit; external LibraryName name 'sk4d_graphics_get_resource_cache_single_allocation_byte_limit'; -function sk4d_graphics_get_resource_cache_total_byte_limit; external LibraryName name 'sk4d_graphics_get_resource_cache_total_byte_limit'; -function sk4d_graphics_get_resource_cache_total_bytes_used; external LibraryName name 'sk4d_graphics_get_resource_cache_total_bytes_used'; -procedure sk4d_graphics_init; external LibraryName name 'sk4d_graphics_init'; -procedure sk4d_graphics_purge_all_caches; external LibraryName name 'sk4d_graphics_purge_all_caches'; -procedure sk4d_graphics_purge_font_cache; external LibraryName name 'sk4d_graphics_purge_font_cache'; -procedure sk4d_graphics_purge_resource_cache; external LibraryName name 'sk4d_graphics_purge_resource_cache'; -function sk4d_graphics_set_font_cache_count_limit; external LibraryName name 'sk4d_graphics_set_font_cache_count_limit'; -function sk4d_graphics_set_font_cache_limit; external LibraryName name 'sk4d_graphics_set_font_cache_limit'; -function sk4d_graphics_set_resource_cache_single_allocation_byte_limit; external LibraryName name 'sk4d_graphics_set_resource_cache_single_allocation_byte_limit'; -function sk4d_graphics_set_resource_cache_total_byte_limit; external LibraryName name 'sk4d_graphics_set_resource_cache_total_byte_limit'; -{$ENDIF} - - -{ include/c/sk4d_image.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_image_encode_to_file := GetProcAddress(LibraryHandle, PChar('sk4d_image_encode_to_file')); - sk4d_image_encode_to_stream := GetProcAddress(LibraryHandle, PChar('sk4d_image_encode_to_stream')); - sk4d_image_get_alpha_type := GetProcAddress(LibraryHandle, PChar('sk4d_image_get_alpha_type')); - sk4d_image_get_color_space := GetProcAddress(LibraryHandle, PChar('sk4d_image_get_color_space')); - sk4d_image_get_color_type := GetProcAddress(LibraryHandle, PChar('sk4d_image_get_color_type')); - sk4d_image_get_height := GetProcAddress(LibraryHandle, PChar('sk4d_image_get_height')); - sk4d_image_get_image_info := GetProcAddress(LibraryHandle, PChar('sk4d_image_get_image_info')); - sk4d_image_get_unique_id := GetProcAddress(LibraryHandle, PChar('sk4d_image_get_unique_id')); - sk4d_image_get_width := GetProcAddress(LibraryHandle, PChar('sk4d_image_get_width')); - sk4d_image_is_lazy_generated := GetProcAddress(LibraryHandle, PChar('sk4d_image_is_lazy_generated')); - sk4d_image_is_texture_backed := GetProcAddress(LibraryHandle, PChar('sk4d_image_is_texture_backed')); - sk4d_image_is_valid := GetProcAddress(LibraryHandle, PChar('sk4d_image_is_valid')); - sk4d_image_make_cross_context := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_cross_context')); - sk4d_image_make_from_adopted_texture := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_from_adopted_texture')); - sk4d_image_make_from_encoded_file := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_from_encoded_file')); - sk4d_image_make_from_encoded_stream := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_from_encoded_stream')); - sk4d_image_make_from_picture := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_from_picture')); - sk4d_image_make_from_raster := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_from_raster')); - sk4d_image_make_from_texture := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_from_texture')); - sk4d_image_make_non_texture_image := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_non_texture_image')); - sk4d_image_make_raster_copy := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_raster_copy')); - sk4d_image_make_raster_image := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_raster_image')); - sk4d_image_make_raw_shader := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_raw_shader')); - sk4d_image_make_shader := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_shader')); - sk4d_image_make_subset := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_subset')); - sk4d_image_make_texture_image := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_texture_image')); - sk4d_image_make_with_filter := GetProcAddress(LibraryHandle, PChar('sk4d_image_make_with_filter')); - sk4d_image_peek_pixels := GetProcAddress(LibraryHandle, PChar('sk4d_image_peek_pixels')); - sk4d_image_read_pixels := GetProcAddress(LibraryHandle, PChar('sk4d_image_read_pixels')); - sk4d_image_scale_pixels := GetProcAddress(LibraryHandle, PChar('sk4d_image_scale_pixels')); -{$ELSE} -function sk4d_image_encode_to_file; external LibraryName name 'sk4d_image_encode_to_file'; -function sk4d_image_encode_to_stream; external LibraryName name 'sk4d_image_encode_to_stream'; -function sk4d_image_get_alpha_type; external LibraryName name 'sk4d_image_get_alpha_type'; -function sk4d_image_get_color_space; external LibraryName name 'sk4d_image_get_color_space'; -function sk4d_image_get_color_type; external LibraryName name 'sk4d_image_get_color_type'; -function sk4d_image_get_height; external LibraryName name 'sk4d_image_get_height'; -procedure sk4d_image_get_image_info; external LibraryName name 'sk4d_image_get_image_info'; -function sk4d_image_get_unique_id; external LibraryName name 'sk4d_image_get_unique_id'; -function sk4d_image_get_width; external LibraryName name 'sk4d_image_get_width'; -function sk4d_image_is_lazy_generated; external LibraryName name 'sk4d_image_is_lazy_generated'; -function sk4d_image_is_texture_backed; external LibraryName name 'sk4d_image_is_texture_backed'; -function sk4d_image_is_valid; external LibraryName name 'sk4d_image_is_valid'; -function sk4d_image_make_cross_context; external LibraryName name 'sk4d_image_make_cross_context'; -function sk4d_image_make_from_adopted_texture; external LibraryName name 'sk4d_image_make_from_adopted_texture'; -function sk4d_image_make_from_encoded_file; external LibraryName name 'sk4d_image_make_from_encoded_file'; -function sk4d_image_make_from_encoded_stream; external LibraryName name 'sk4d_image_make_from_encoded_stream'; -function sk4d_image_make_from_picture; external LibraryName name 'sk4d_image_make_from_picture'; -function sk4d_image_make_from_raster; external LibraryName name 'sk4d_image_make_from_raster'; -function sk4d_image_make_from_texture; external LibraryName name 'sk4d_image_make_from_texture'; -function sk4d_image_make_non_texture_image; external LibraryName name 'sk4d_image_make_non_texture_image'; -function sk4d_image_make_raster_copy; external LibraryName name 'sk4d_image_make_raster_copy'; -function sk4d_image_make_raster_image; external LibraryName name 'sk4d_image_make_raster_image'; -function sk4d_image_make_raw_shader; external LibraryName name 'sk4d_image_make_raw_shader'; -function sk4d_image_make_shader; external LibraryName name 'sk4d_image_make_shader'; -function sk4d_image_make_subset; external LibraryName name 'sk4d_image_make_subset'; -function sk4d_image_make_texture_image; external LibraryName name 'sk4d_image_make_texture_image'; -function sk4d_image_make_with_filter; external LibraryName name 'sk4d_image_make_with_filter'; -function sk4d_image_peek_pixels; external LibraryName name 'sk4d_image_peek_pixels'; -function sk4d_image_read_pixels; external LibraryName name 'sk4d_image_read_pixels'; -function sk4d_image_scale_pixels; external LibraryName name 'sk4d_image_scale_pixels'; -{$ENDIF} - - -{ include/c/sk4d_imageencoder.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_imageencoder_encode_to_file := GetProcAddress(LibraryHandle, PChar('sk4d_imageencoder_encode_to_file')); - sk4d_imageencoder_encode_to_stream := GetProcAddress(LibraryHandle, PChar('sk4d_imageencoder_encode_to_stream')); -{$ELSE} -function sk4d_imageencoder_encode_to_file; external LibraryName name 'sk4d_imageencoder_encode_to_file'; -function sk4d_imageencoder_encode_to_stream; external LibraryName name 'sk4d_imageencoder_encode_to_stream'; -{$ENDIF} - - -{ include/c/sk4d_imagefilter.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_imagefilter_make_alpha_threshold := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_alpha_threshold')); - sk4d_imagefilter_make_arithmetic := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_arithmetic')); - sk4d_imagefilter_make_blend := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_blend')); - sk4d_imagefilter_make_blur := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_blur')); - sk4d_imagefilter_make_colorfilter := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_colorfilter')); - sk4d_imagefilter_make_compose := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_compose')); - sk4d_imagefilter_make_dilate := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_dilate')); - sk4d_imagefilter_make_displacement_map := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_displacement_map')); - sk4d_imagefilter_make_distant_lit_diffuse := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_distant_lit_diffuse')); - sk4d_imagefilter_make_distant_lit_specular := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_distant_lit_specular')); - sk4d_imagefilter_make_drop_shadow := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_drop_shadow')); - sk4d_imagefilter_make_drop_shadow_only := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_drop_shadow_only')); - sk4d_imagefilter_make_erode := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_erode')); - sk4d_imagefilter_make_image := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_image')); - sk4d_imagefilter_make_magnifier := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_magnifier')); - sk4d_imagefilter_make_matrix_convolution := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_matrix_convolution')); - sk4d_imagefilter_make_matrix_transform := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_matrix_transform')); - sk4d_imagefilter_make_merge := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_merge')); - sk4d_imagefilter_make_offset := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_offset')); - sk4d_imagefilter_make_picture := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_picture')); - sk4d_imagefilter_make_point_lit_diffuse := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_point_lit_diffuse')); - sk4d_imagefilter_make_point_lit_specular := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_point_lit_specular')); - sk4d_imagefilter_make_shader := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_shader')); - sk4d_imagefilter_make_spot_lit_diffuse := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_spot_lit_diffuse')); - sk4d_imagefilter_make_spot_lit_specular := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_spot_lit_specular')); - sk4d_imagefilter_make_tile := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_tile')); - sk4d_imagefilter_make_with_local_matrix := GetProcAddress(LibraryHandle, PChar('sk4d_imagefilter_make_with_local_matrix')); -{$ELSE} -function sk4d_imagefilter_make_alpha_threshold; external LibraryName name 'sk4d_imagefilter_make_alpha_threshold'; -function sk4d_imagefilter_make_arithmetic; external LibraryName name 'sk4d_imagefilter_make_arithmetic'; -function sk4d_imagefilter_make_blend; external LibraryName name 'sk4d_imagefilter_make_blend'; -function sk4d_imagefilter_make_blur; external LibraryName name 'sk4d_imagefilter_make_blur'; -function sk4d_imagefilter_make_colorfilter; external LibraryName name 'sk4d_imagefilter_make_colorfilter'; -function sk4d_imagefilter_make_compose; external LibraryName name 'sk4d_imagefilter_make_compose'; -function sk4d_imagefilter_make_dilate; external LibraryName name 'sk4d_imagefilter_make_dilate'; -function sk4d_imagefilter_make_displacement_map; external LibraryName name 'sk4d_imagefilter_make_displacement_map'; -function sk4d_imagefilter_make_distant_lit_diffuse; external LibraryName name 'sk4d_imagefilter_make_distant_lit_diffuse'; -function sk4d_imagefilter_make_distant_lit_specular; external LibraryName name 'sk4d_imagefilter_make_distant_lit_specular'; -function sk4d_imagefilter_make_drop_shadow; external LibraryName name 'sk4d_imagefilter_make_drop_shadow'; -function sk4d_imagefilter_make_drop_shadow_only; external LibraryName name 'sk4d_imagefilter_make_drop_shadow_only'; -function sk4d_imagefilter_make_erode; external LibraryName name 'sk4d_imagefilter_make_erode'; -function sk4d_imagefilter_make_image; external LibraryName name 'sk4d_imagefilter_make_image'; -function sk4d_imagefilter_make_magnifier; external LibraryName name 'sk4d_imagefilter_make_magnifier'; -function sk4d_imagefilter_make_matrix_convolution; external LibraryName name 'sk4d_imagefilter_make_matrix_convolution'; -function sk4d_imagefilter_make_matrix_transform; external LibraryName name 'sk4d_imagefilter_make_matrix_transform'; -function sk4d_imagefilter_make_merge; external LibraryName name 'sk4d_imagefilter_make_merge'; -function sk4d_imagefilter_make_offset; external LibraryName name 'sk4d_imagefilter_make_offset'; -function sk4d_imagefilter_make_picture; external LibraryName name 'sk4d_imagefilter_make_picture'; -function sk4d_imagefilter_make_point_lit_diffuse; external LibraryName name 'sk4d_imagefilter_make_point_lit_diffuse'; -function sk4d_imagefilter_make_point_lit_specular; external LibraryName name 'sk4d_imagefilter_make_point_lit_specular'; -function sk4d_imagefilter_make_shader; external LibraryName name 'sk4d_imagefilter_make_shader'; -function sk4d_imagefilter_make_spot_lit_diffuse; external LibraryName name 'sk4d_imagefilter_make_spot_lit_diffuse'; -function sk4d_imagefilter_make_spot_lit_specular; external LibraryName name 'sk4d_imagefilter_make_spot_lit_specular'; -function sk4d_imagefilter_make_tile; external LibraryName name 'sk4d_imagefilter_make_tile'; -function sk4d_imagefilter_make_with_local_matrix; external LibraryName name 'sk4d_imagefilter_make_with_local_matrix'; -{$ENDIF} - - -{ include/c/sk4d_maskfilter.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_maskfilter_make_blur := GetProcAddress(LibraryHandle, PChar('sk4d_maskfilter_make_blur')); - sk4d_maskfilter_make_shader := GetProcAddress(LibraryHandle, PChar('sk4d_maskfilter_make_shader')); - sk4d_maskfilter_make_table := GetProcAddress(LibraryHandle, PChar('sk4d_maskfilter_make_table')); - sk4d_maskfilter_make_table_clip := GetProcAddress(LibraryHandle, PChar('sk4d_maskfilter_make_table_clip')); - sk4d_maskfilter_make_table_gamma := GetProcAddress(LibraryHandle, PChar('sk4d_maskfilter_make_table_gamma')); -{$ELSE} -function sk4d_maskfilter_make_blur; external LibraryName name 'sk4d_maskfilter_make_blur'; -function sk4d_maskfilter_make_shader; external LibraryName name 'sk4d_maskfilter_make_shader'; -function sk4d_maskfilter_make_table; external LibraryName name 'sk4d_maskfilter_make_table'; -function sk4d_maskfilter_make_table_clip; external LibraryName name 'sk4d_maskfilter_make_table_clip'; -function sk4d_maskfilter_make_table_gamma; external LibraryName name 'sk4d_maskfilter_make_table_gamma'; -{$ENDIF} - - -{ include/c/sk4d_paint.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_paint_create := GetProcAddress(LibraryHandle, PChar('sk4d_paint_create')); - sk4d_paint_create2 := GetProcAddress(LibraryHandle, PChar('sk4d_paint_create2')); - sk4d_paint_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_paint_destroy')); - sk4d_paint_get_alpha := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_alpha')); - sk4d_paint_get_alphaf := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_alphaf')); - sk4d_paint_get_anti_alias := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_anti_alias')); - sk4d_paint_get_blender := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_blender')); - sk4d_paint_get_color := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_color')); - sk4d_paint_get_colorf := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_colorf')); - sk4d_paint_get_color_filter := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_color_filter')); - sk4d_paint_get_dither := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_dither')); - sk4d_paint_get_fill_path := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_fill_path')); - sk4d_paint_get_image_filter := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_image_filter')); - sk4d_paint_get_mask_filter := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_mask_filter')); - sk4d_paint_get_path_effect := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_path_effect')); - sk4d_paint_get_shader := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_shader')); - sk4d_paint_get_stroke_cap := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_stroke_cap')); - sk4d_paint_get_stroke_join := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_stroke_join')); - sk4d_paint_get_stroke_miter := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_stroke_miter')); - sk4d_paint_get_stroke_width := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_stroke_width')); - sk4d_paint_get_style := GetProcAddress(LibraryHandle, PChar('sk4d_paint_get_style')); - sk4d_paint_reset := GetProcAddress(LibraryHandle, PChar('sk4d_paint_reset')); - sk4d_paint_set_alpha := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_alpha')); - sk4d_paint_set_alphaf := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_alphaf')); - sk4d_paint_set_antialias := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_antialias')); - sk4d_paint_set_argb := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_argb')); - sk4d_paint_set_blender := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_blender')); - sk4d_paint_set_color := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_color')); - sk4d_paint_set_colorf := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_colorf')); - sk4d_paint_set_color_filter := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_color_filter')); - sk4d_paint_set_dither := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_dither')); - sk4d_paint_set_image_filter := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_image_filter')); - sk4d_paint_set_mask_filter := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_mask_filter')); - sk4d_paint_set_path_effect := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_path_effect')); - sk4d_paint_set_shader := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_shader')); - sk4d_paint_set_stroke_cap := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_stroke_cap')); - sk4d_paint_set_stroke_join := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_stroke_join')); - sk4d_paint_set_stroke_miter := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_stroke_miter')); - sk4d_paint_set_stroke_width := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_stroke_width')); - sk4d_paint_set_style := GetProcAddress(LibraryHandle, PChar('sk4d_paint_set_style')); -{$ELSE} -function sk4d_paint_create; external LibraryName name 'sk4d_paint_create'; -function sk4d_paint_create2; external LibraryName name 'sk4d_paint_create2'; -procedure sk4d_paint_destroy; external LibraryName name 'sk4d_paint_destroy'; -function sk4d_paint_get_alpha; external LibraryName name 'sk4d_paint_get_alpha'; -function sk4d_paint_get_alphaf; external LibraryName name 'sk4d_paint_get_alphaf'; -function sk4d_paint_get_anti_alias; external LibraryName name 'sk4d_paint_get_anti_alias'; -function sk4d_paint_get_blender; external LibraryName name 'sk4d_paint_get_blender'; -function sk4d_paint_get_color; external LibraryName name 'sk4d_paint_get_color'; -procedure sk4d_paint_get_colorf; external LibraryName name 'sk4d_paint_get_colorf'; -function sk4d_paint_get_color_filter; external LibraryName name 'sk4d_paint_get_color_filter'; -function sk4d_paint_get_dither; external LibraryName name 'sk4d_paint_get_dither'; -function sk4d_paint_get_fill_path; external LibraryName name 'sk4d_paint_get_fill_path'; -function sk4d_paint_get_image_filter; external LibraryName name 'sk4d_paint_get_image_filter'; -function sk4d_paint_get_mask_filter; external LibraryName name 'sk4d_paint_get_mask_filter'; -function sk4d_paint_get_path_effect; external LibraryName name 'sk4d_paint_get_path_effect'; -function sk4d_paint_get_shader; external LibraryName name 'sk4d_paint_get_shader'; -function sk4d_paint_get_stroke_cap; external LibraryName name 'sk4d_paint_get_stroke_cap'; -function sk4d_paint_get_stroke_join; external LibraryName name 'sk4d_paint_get_stroke_join'; -function sk4d_paint_get_stroke_miter; external LibraryName name 'sk4d_paint_get_stroke_miter'; -function sk4d_paint_get_stroke_width; external LibraryName name 'sk4d_paint_get_stroke_width'; -function sk4d_paint_get_style; external LibraryName name 'sk4d_paint_get_style'; -procedure sk4d_paint_reset; external LibraryName name 'sk4d_paint_reset'; -procedure sk4d_paint_set_alpha; external LibraryName name 'sk4d_paint_set_alpha'; -procedure sk4d_paint_set_alphaf; external LibraryName name 'sk4d_paint_set_alphaf'; -procedure sk4d_paint_set_antialias; external LibraryName name 'sk4d_paint_set_antialias'; -procedure sk4d_paint_set_argb; external LibraryName name 'sk4d_paint_set_argb'; -procedure sk4d_paint_set_blender; external LibraryName name 'sk4d_paint_set_blender'; -procedure sk4d_paint_set_color; external LibraryName name 'sk4d_paint_set_color'; -procedure sk4d_paint_set_colorf; external LibraryName name 'sk4d_paint_set_colorf'; -procedure sk4d_paint_set_color_filter; external LibraryName name 'sk4d_paint_set_color_filter'; -procedure sk4d_paint_set_dither; external LibraryName name 'sk4d_paint_set_dither'; -procedure sk4d_paint_set_image_filter; external LibraryName name 'sk4d_paint_set_image_filter'; -procedure sk4d_paint_set_mask_filter; external LibraryName name 'sk4d_paint_set_mask_filter'; -procedure sk4d_paint_set_path_effect; external LibraryName name 'sk4d_paint_set_path_effect'; -procedure sk4d_paint_set_shader; external LibraryName name 'sk4d_paint_set_shader'; -procedure sk4d_paint_set_stroke_cap; external LibraryName name 'sk4d_paint_set_stroke_cap'; -procedure sk4d_paint_set_stroke_join; external LibraryName name 'sk4d_paint_set_stroke_join'; -procedure sk4d_paint_set_stroke_miter; external LibraryName name 'sk4d_paint_set_stroke_miter'; -procedure sk4d_paint_set_stroke_width; external LibraryName name 'sk4d_paint_set_stroke_width'; -procedure sk4d_paint_set_style; external LibraryName name 'sk4d_paint_set_style'; -{$ENDIF} - - -{ include/c/sk4d_path.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_opbuilder_add := GetProcAddress(LibraryHandle, PChar('sk4d_opbuilder_add')); - sk4d_opbuilder_create := GetProcAddress(LibraryHandle, PChar('sk4d_opbuilder_create')); - sk4d_opbuilder_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_opbuilder_destroy')); - sk4d_opbuilder_detach := GetProcAddress(LibraryHandle, PChar('sk4d_opbuilder_detach')); - sk4d_path_contains := GetProcAddress(LibraryHandle, PChar('sk4d_path_contains')); - sk4d_path_convert_conic_to_quads := GetProcAddress(LibraryHandle, PChar('sk4d_path_convert_conic_to_quads')); - sk4d_path_create := GetProcAddress(LibraryHandle, PChar('sk4d_path_create')); - sk4d_path_create2 := GetProcAddress(LibraryHandle, PChar('sk4d_path_create2')); - sk4d_path_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_path_destroy')); - sk4d_path_get_bounds := GetProcAddress(LibraryHandle, PChar('sk4d_path_get_bounds')); - sk4d_path_get_fill_type := GetProcAddress(LibraryHandle, PChar('sk4d_path_get_fill_type')); - sk4d_path_get_last_point := GetProcAddress(LibraryHandle, PChar('sk4d_path_get_last_point')); - sk4d_path_get_segment_masks := GetProcAddress(LibraryHandle, PChar('sk4d_path_get_segment_masks')); - sk4d_path_get_tight_bounds := GetProcAddress(LibraryHandle, PChar('sk4d_path_get_tight_bounds')); - sk4d_path_interpolate := GetProcAddress(LibraryHandle, PChar('sk4d_path_interpolate')); - sk4d_path_is_convex := GetProcAddress(LibraryHandle, PChar('sk4d_path_is_convex')); - sk4d_path_is_empty := GetProcAddress(LibraryHandle, PChar('sk4d_path_is_empty')); - sk4d_path_is_finite := GetProcAddress(LibraryHandle, PChar('sk4d_path_is_finite')); - sk4d_path_is_interpolatable := GetProcAddress(LibraryHandle, PChar('sk4d_path_is_interpolatable')); - sk4d_path_is_last_contour_closed := GetProcAddress(LibraryHandle, PChar('sk4d_path_is_last_contour_closed')); - sk4d_path_is_line := GetProcAddress(LibraryHandle, PChar('sk4d_path_is_line')); - sk4d_path_is_oval := GetProcAddress(LibraryHandle, PChar('sk4d_path_is_oval')); - sk4d_path_is_rect := GetProcAddress(LibraryHandle, PChar('sk4d_path_is_rect')); - sk4d_path_is_rrect := GetProcAddress(LibraryHandle, PChar('sk4d_path_is_rrect')); - sk4d_path_op := GetProcAddress(LibraryHandle, PChar('sk4d_path_op')); - sk4d_path_serialize_to_stream := GetProcAddress(LibraryHandle, PChar('sk4d_path_serialize_to_stream')); - sk4d_path_to_svg := GetProcAddress(LibraryHandle, PChar('sk4d_path_to_svg')); - sk4d_path_transform := GetProcAddress(LibraryHandle, PChar('sk4d_path_transform')); - sk4d_pathiterator_create := GetProcAddress(LibraryHandle, PChar('sk4d_pathiterator_create')); - sk4d_pathiterator_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_pathiterator_destroy')); - sk4d_pathiterator_next := GetProcAddress(LibraryHandle, PChar('sk4d_pathiterator_next')); -{$ELSE} -procedure sk4d_opbuilder_add; external LibraryName name 'sk4d_opbuilder_add'; -function sk4d_opbuilder_create; external LibraryName name 'sk4d_opbuilder_create'; -procedure sk4d_opbuilder_destroy; external LibraryName name 'sk4d_opbuilder_destroy'; -function sk4d_opbuilder_detach; external LibraryName name 'sk4d_opbuilder_detach'; -function sk4d_path_contains; external LibraryName name 'sk4d_path_contains'; -function sk4d_path_convert_conic_to_quads; external LibraryName name 'sk4d_path_convert_conic_to_quads'; -function sk4d_path_create; external LibraryName name 'sk4d_path_create'; -function sk4d_path_create2; external LibraryName name 'sk4d_path_create2'; -procedure sk4d_path_destroy; external LibraryName name 'sk4d_path_destroy'; -procedure sk4d_path_get_bounds; external LibraryName name 'sk4d_path_get_bounds'; -function sk4d_path_get_fill_type; external LibraryName name 'sk4d_path_get_fill_type'; -function sk4d_path_get_last_point; external LibraryName name 'sk4d_path_get_last_point'; -function sk4d_path_get_segment_masks; external LibraryName name 'sk4d_path_get_segment_masks'; -procedure sk4d_path_get_tight_bounds; external LibraryName name 'sk4d_path_get_tight_bounds'; -function sk4d_path_interpolate; external LibraryName name 'sk4d_path_interpolate'; -function sk4d_path_is_convex; external LibraryName name 'sk4d_path_is_convex'; -function sk4d_path_is_empty; external LibraryName name 'sk4d_path_is_empty'; -function sk4d_path_is_finite; external LibraryName name 'sk4d_path_is_finite'; -function sk4d_path_is_interpolatable; external LibraryName name 'sk4d_path_is_interpolatable'; -function sk4d_path_is_last_contour_closed; external LibraryName name 'sk4d_path_is_last_contour_closed'; -function sk4d_path_is_line; external LibraryName name 'sk4d_path_is_line'; -function sk4d_path_is_oval; external LibraryName name 'sk4d_path_is_oval'; -function sk4d_path_is_rect; external LibraryName name 'sk4d_path_is_rect'; -function sk4d_path_is_rrect; external LibraryName name 'sk4d_path_is_rrect'; -function sk4d_path_op; external LibraryName name 'sk4d_path_op'; -procedure sk4d_path_serialize_to_stream; external LibraryName name 'sk4d_path_serialize_to_stream'; -function sk4d_path_to_svg; external LibraryName name 'sk4d_path_to_svg'; -function sk4d_path_transform; external LibraryName name 'sk4d_path_transform'; -function sk4d_pathiterator_create; external LibraryName name 'sk4d_pathiterator_create'; -procedure sk4d_pathiterator_destroy; external LibraryName name 'sk4d_pathiterator_destroy'; -function sk4d_pathiterator_next; external LibraryName name 'sk4d_pathiterator_next'; -{$ENDIF} - - -{ include/c/sk4d_pathbuilder.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_pathbuilder_add_arc := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_add_arc')); - sk4d_pathbuilder_add_circle := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_add_circle')); - sk4d_pathbuilder_add_oval := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_add_oval')); - sk4d_pathbuilder_add_path := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_add_path')); - sk4d_pathbuilder_add_polygon := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_add_polygon')); - sk4d_pathbuilder_add_rect := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_add_rect')); - sk4d_pathbuilder_add_rrect := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_add_rrect')); - sk4d_pathbuilder_arc_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_arc_to')); - sk4d_pathbuilder_arc_to2 := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_arc_to2')); - sk4d_pathbuilder_arc_to3 := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_arc_to3')); - sk4d_pathbuilder_close := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_close')); - sk4d_pathbuilder_conic_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_conic_to')); - sk4d_pathbuilder_create := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_create')); - sk4d_pathbuilder_create2 := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_create2')); - sk4d_pathbuilder_cubic_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_cubic_to')); - sk4d_pathbuilder_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_destroy')); - sk4d_pathbuilder_detach := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_detach')); - sk4d_pathbuilder_get_bounds := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_get_bounds')); - sk4d_pathbuilder_get_fill_type := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_get_fill_type')); - sk4d_pathbuilder_inc_reserve := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_inc_reserve')); - sk4d_pathbuilder_line_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_line_to')); - sk4d_pathbuilder_move_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_move_to')); - sk4d_pathbuilder_offset := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_offset')); - sk4d_pathbuilder_polyline_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_polyline_to')); - sk4d_pathbuilder_quad_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_quad_to')); - sk4d_pathbuilder_r_conic_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_r_conic_to')); - sk4d_pathbuilder_r_cubic_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_r_cubic_to')); - sk4d_pathbuilder_r_line_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_r_line_to')); - sk4d_pathbuilder_r_quad_to := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_r_quad_to')); - sk4d_pathbuilder_reset := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_reset')); - sk4d_pathbuilder_set_filltype := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_set_filltype')); - sk4d_pathbuilder_snapshot := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_snapshot')); - sk4d_pathbuilder_toggle_inverse_filltype := GetProcAddress(LibraryHandle, PChar('sk4d_pathbuilder_toggle_inverse_filltype')); -{$ELSE} -procedure sk4d_pathbuilder_add_arc; external LibraryName name 'sk4d_pathbuilder_add_arc'; -procedure sk4d_pathbuilder_add_circle; external LibraryName name 'sk4d_pathbuilder_add_circle'; -procedure sk4d_pathbuilder_add_oval; external LibraryName name 'sk4d_pathbuilder_add_oval'; -procedure sk4d_pathbuilder_add_path; external LibraryName name 'sk4d_pathbuilder_add_path'; -procedure sk4d_pathbuilder_add_polygon; external LibraryName name 'sk4d_pathbuilder_add_polygon'; -procedure sk4d_pathbuilder_add_rect; external LibraryName name 'sk4d_pathbuilder_add_rect'; -procedure sk4d_pathbuilder_add_rrect; external LibraryName name 'sk4d_pathbuilder_add_rrect'; -procedure sk4d_pathbuilder_arc_to; external LibraryName name 'sk4d_pathbuilder_arc_to'; -procedure sk4d_pathbuilder_arc_to2; external LibraryName name 'sk4d_pathbuilder_arc_to2'; -procedure sk4d_pathbuilder_arc_to3; external LibraryName name 'sk4d_pathbuilder_arc_to3'; -procedure sk4d_pathbuilder_close; external LibraryName name 'sk4d_pathbuilder_close'; -procedure sk4d_pathbuilder_conic_to; external LibraryName name 'sk4d_pathbuilder_conic_to'; -function sk4d_pathbuilder_create; external LibraryName name 'sk4d_pathbuilder_create'; -function sk4d_pathbuilder_create2; external LibraryName name 'sk4d_pathbuilder_create2'; -procedure sk4d_pathbuilder_cubic_to; external LibraryName name 'sk4d_pathbuilder_cubic_to'; -procedure sk4d_pathbuilder_destroy; external LibraryName name 'sk4d_pathbuilder_destroy'; -function sk4d_pathbuilder_detach; external LibraryName name 'sk4d_pathbuilder_detach'; -procedure sk4d_pathbuilder_get_bounds; external LibraryName name 'sk4d_pathbuilder_get_bounds'; -function sk4d_pathbuilder_get_fill_type; external LibraryName name 'sk4d_pathbuilder_get_fill_type'; -procedure sk4d_pathbuilder_inc_reserve; external LibraryName name 'sk4d_pathbuilder_inc_reserve'; -procedure sk4d_pathbuilder_line_to; external LibraryName name 'sk4d_pathbuilder_line_to'; -procedure sk4d_pathbuilder_move_to; external LibraryName name 'sk4d_pathbuilder_move_to'; -procedure sk4d_pathbuilder_offset; external LibraryName name 'sk4d_pathbuilder_offset'; -procedure sk4d_pathbuilder_polyline_to; external LibraryName name 'sk4d_pathbuilder_polyline_to'; -procedure sk4d_pathbuilder_quad_to; external LibraryName name 'sk4d_pathbuilder_quad_to'; -procedure sk4d_pathbuilder_r_conic_to; external LibraryName name 'sk4d_pathbuilder_r_conic_to'; -procedure sk4d_pathbuilder_r_cubic_to; external LibraryName name 'sk4d_pathbuilder_r_cubic_to'; -procedure sk4d_pathbuilder_r_line_to; external LibraryName name 'sk4d_pathbuilder_r_line_to'; -procedure sk4d_pathbuilder_r_quad_to; external LibraryName name 'sk4d_pathbuilder_r_quad_to'; -procedure sk4d_pathbuilder_reset; external LibraryName name 'sk4d_pathbuilder_reset'; -procedure sk4d_pathbuilder_set_filltype; external LibraryName name 'sk4d_pathbuilder_set_filltype'; -function sk4d_pathbuilder_snapshot; external LibraryName name 'sk4d_pathbuilder_snapshot'; -procedure sk4d_pathbuilder_toggle_inverse_filltype; external LibraryName name 'sk4d_pathbuilder_toggle_inverse_filltype'; -{$ENDIF} - - -{ include/c/sk4d_patheffect.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_patheffect_make_1dpath := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_1dpath')); - sk4d_patheffect_make_2dline := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_2dline')); - sk4d_patheffect_make_2dpath := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_2dpath')); - sk4d_patheffect_make_compose := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_compose')); - sk4d_patheffect_make_corner := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_corner')); - sk4d_patheffect_make_dash := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_dash')); - sk4d_patheffect_make_discrete := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_discrete')); - sk4d_patheffect_make_matrix := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_matrix')); - sk4d_patheffect_make_merge := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_merge')); - sk4d_patheffect_make_stroke := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_stroke')); - sk4d_patheffect_make_stroke_and_fill := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_stroke_and_fill')); - sk4d_patheffect_make_sum := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_sum')); - sk4d_patheffect_make_translate := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_translate')); - sk4d_patheffect_make_trim := GetProcAddress(LibraryHandle, PChar('sk4d_patheffect_make_trim')); -{$ELSE} -function sk4d_patheffect_make_1dpath; external LibraryName name 'sk4d_patheffect_make_1dpath'; -function sk4d_patheffect_make_2dline; external LibraryName name 'sk4d_patheffect_make_2dline'; -function sk4d_patheffect_make_2dpath; external LibraryName name 'sk4d_patheffect_make_2dpath'; -function sk4d_patheffect_make_compose; external LibraryName name 'sk4d_patheffect_make_compose'; -function sk4d_patheffect_make_corner; external LibraryName name 'sk4d_patheffect_make_corner'; -function sk4d_patheffect_make_dash; external LibraryName name 'sk4d_patheffect_make_dash'; -function sk4d_patheffect_make_discrete; external LibraryName name 'sk4d_patheffect_make_discrete'; -function sk4d_patheffect_make_matrix; external LibraryName name 'sk4d_patheffect_make_matrix'; -function sk4d_patheffect_make_merge; external LibraryName name 'sk4d_patheffect_make_merge'; -function sk4d_patheffect_make_stroke; external LibraryName name 'sk4d_patheffect_make_stroke'; -function sk4d_patheffect_make_stroke_and_fill; external LibraryName name 'sk4d_patheffect_make_stroke_and_fill'; -function sk4d_patheffect_make_sum; external LibraryName name 'sk4d_patheffect_make_sum'; -function sk4d_patheffect_make_translate; external LibraryName name 'sk4d_patheffect_make_translate'; -function sk4d_patheffect_make_trim; external LibraryName name 'sk4d_patheffect_make_trim'; -{$ENDIF} - - -{ include/c/sk4d_pathmeasure.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_pathmeasure_create := GetProcAddress(LibraryHandle, PChar('sk4d_pathmeasure_create')); - sk4d_pathmeasure_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_pathmeasure_destroy')); - sk4d_pathmeasure_get_length := GetProcAddress(LibraryHandle, PChar('sk4d_pathmeasure_get_length')); - sk4d_pathmeasure_get_matrix := GetProcAddress(LibraryHandle, PChar('sk4d_pathmeasure_get_matrix')); - sk4d_pathmeasure_get_position_and_tangent := GetProcAddress(LibraryHandle, PChar('sk4d_pathmeasure_get_position_and_tangent')); - sk4d_pathmeasure_get_segment := GetProcAddress(LibraryHandle, PChar('sk4d_pathmeasure_get_segment')); - sk4d_pathmeasure_is_closed := GetProcAddress(LibraryHandle, PChar('sk4d_pathmeasure_is_closed')); - sk4d_pathmeasure_next_contour := GetProcAddress(LibraryHandle, PChar('sk4d_pathmeasure_next_contour')); -{$ELSE} -function sk4d_pathmeasure_create; external LibraryName name 'sk4d_pathmeasure_create'; -procedure sk4d_pathmeasure_destroy; external LibraryName name 'sk4d_pathmeasure_destroy'; -function sk4d_pathmeasure_get_length; external LibraryName name 'sk4d_pathmeasure_get_length'; -function sk4d_pathmeasure_get_matrix; external LibraryName name 'sk4d_pathmeasure_get_matrix'; -function sk4d_pathmeasure_get_position_and_tangent; external LibraryName name 'sk4d_pathmeasure_get_position_and_tangent'; -function sk4d_pathmeasure_get_segment; external LibraryName name 'sk4d_pathmeasure_get_segment'; -function sk4d_pathmeasure_is_closed; external LibraryName name 'sk4d_pathmeasure_is_closed'; -function sk4d_pathmeasure_next_contour; external LibraryName name 'sk4d_pathmeasure_next_contour'; -{$ENDIF} - - -{ include/c/sk4d_picture.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_picture_get_cull_rect := GetProcAddress(LibraryHandle, PChar('sk4d_picture_get_cull_rect')); - sk4d_picture_make_from_stream := GetProcAddress(LibraryHandle, PChar('sk4d_picture_make_from_stream')); - sk4d_picture_make_shader := GetProcAddress(LibraryHandle, PChar('sk4d_picture_make_shader')); - sk4d_picture_playback := GetProcAddress(LibraryHandle, PChar('sk4d_picture_playback')); - sk4d_picture_serialize_to_stream := GetProcAddress(LibraryHandle, PChar('sk4d_picture_serialize_to_stream')); -{$ELSE} -procedure sk4d_picture_get_cull_rect; external LibraryName name 'sk4d_picture_get_cull_rect'; -function sk4d_picture_make_from_stream; external LibraryName name 'sk4d_picture_make_from_stream'; -function sk4d_picture_make_shader; external LibraryName name 'sk4d_picture_make_shader'; -procedure sk4d_picture_playback; external LibraryName name 'sk4d_picture_playback'; -procedure sk4d_picture_serialize_to_stream; external LibraryName name 'sk4d_picture_serialize_to_stream'; -{$ENDIF} - - -{ include/c/sk4d_picturerecorder.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_picturerecorder_begin_recording := GetProcAddress(LibraryHandle, PChar('sk4d_picturerecorder_begin_recording')); - sk4d_picturerecorder_create := GetProcAddress(LibraryHandle, PChar('sk4d_picturerecorder_create')); - sk4d_picturerecorder_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_picturerecorder_destroy')); - sk4d_picturerecorder_finish_recording := GetProcAddress(LibraryHandle, PChar('sk4d_picturerecorder_finish_recording')); - sk4d_picturerecorder_finish_recording2 := GetProcAddress(LibraryHandle, PChar('sk4d_picturerecorder_finish_recording2')); -{$ELSE} -function sk4d_picturerecorder_begin_recording; external LibraryName name 'sk4d_picturerecorder_begin_recording'; -function sk4d_picturerecorder_create; external LibraryName name 'sk4d_picturerecorder_create'; -procedure sk4d_picturerecorder_destroy; external LibraryName name 'sk4d_picturerecorder_destroy'; -function sk4d_picturerecorder_finish_recording; external LibraryName name 'sk4d_picturerecorder_finish_recording'; -function sk4d_picturerecorder_finish_recording2; external LibraryName name 'sk4d_picturerecorder_finish_recording2'; -{$ENDIF} - - -{ include/c/sk4d_pixmap.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_pixmap_create := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_create')); - sk4d_pixmap_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_destroy')); - sk4d_pixmap_erase := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_erase')); - sk4d_pixmap_erase2 := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_erase2')); - sk4d_pixmap_extract_subset := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_extract_subset')); - sk4d_pixmap_get_alpha := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_alpha')); - sk4d_pixmap_get_alpha_type := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_alpha_type')); - sk4d_pixmap_get_color := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_color')); - sk4d_pixmap_get_color_space := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_color_space')); - sk4d_pixmap_get_color_type := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_color_type')); - sk4d_pixmap_get_colorf := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_colorf')); - sk4d_pixmap_get_height := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_height')); - sk4d_pixmap_get_image_info := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_image_info')); - sk4d_pixmap_get_pixel_addr := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_pixel_addr')); - sk4d_pixmap_get_pixels := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_pixels')); - sk4d_pixmap_get_row_bytes := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_row_bytes')); - sk4d_pixmap_get_width := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_get_width')); - sk4d_pixmap_read_pixels := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_read_pixels')); - sk4d_pixmap_scale_pixels := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_scale_pixels')); - sk4d_pixmap_set_colorspace := GetProcAddress(LibraryHandle, PChar('sk4d_pixmap_set_colorspace')); -{$ELSE} -function sk4d_pixmap_create; external LibraryName name 'sk4d_pixmap_create'; -procedure sk4d_pixmap_destroy; external LibraryName name 'sk4d_pixmap_destroy'; -function sk4d_pixmap_erase; external LibraryName name 'sk4d_pixmap_erase'; -function sk4d_pixmap_erase2; external LibraryName name 'sk4d_pixmap_erase2'; -function sk4d_pixmap_extract_subset; external LibraryName name 'sk4d_pixmap_extract_subset'; -function sk4d_pixmap_get_alpha; external LibraryName name 'sk4d_pixmap_get_alpha'; -function sk4d_pixmap_get_alpha_type; external LibraryName name 'sk4d_pixmap_get_alpha_type'; -function sk4d_pixmap_get_color; external LibraryName name 'sk4d_pixmap_get_color'; -function sk4d_pixmap_get_color_space; external LibraryName name 'sk4d_pixmap_get_color_space'; -function sk4d_pixmap_get_color_type; external LibraryName name 'sk4d_pixmap_get_color_type'; -procedure sk4d_pixmap_get_colorf; external LibraryName name 'sk4d_pixmap_get_colorf'; -function sk4d_pixmap_get_height; external LibraryName name 'sk4d_pixmap_get_height'; -procedure sk4d_pixmap_get_image_info; external LibraryName name 'sk4d_pixmap_get_image_info'; -function sk4d_pixmap_get_pixel_addr; external LibraryName name 'sk4d_pixmap_get_pixel_addr'; -function sk4d_pixmap_get_pixels; external LibraryName name 'sk4d_pixmap_get_pixels'; -function sk4d_pixmap_get_row_bytes; external LibraryName name 'sk4d_pixmap_get_row_bytes'; -function sk4d_pixmap_get_width; external LibraryName name 'sk4d_pixmap_get_width'; -function sk4d_pixmap_read_pixels; external LibraryName name 'sk4d_pixmap_read_pixels'; -function sk4d_pixmap_scale_pixels; external LibraryName name 'sk4d_pixmap_scale_pixels'; -procedure sk4d_pixmap_set_colorspace; external LibraryName name 'sk4d_pixmap_set_colorspace'; -{$ENDIF} - - -{ include/c/sk4d_refcnt.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_refcnt_ref := GetProcAddress(LibraryHandle, PChar('sk4d_refcnt_ref')); - sk4d_refcnt_unref := GetProcAddress(LibraryHandle, PChar('sk4d_refcnt_unref')); -{$ELSE} -procedure sk4d_refcnt_ref; external LibraryName name 'sk4d_refcnt_ref'; -procedure sk4d_refcnt_unref; external LibraryName name 'sk4d_refcnt_unref'; -{$ENDIF} - - -{ include/c/sk4d_region.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_region_contains := GetProcAddress(LibraryHandle, PChar('sk4d_region_contains')); - sk4d_region_contains2 := GetProcAddress(LibraryHandle, PChar('sk4d_region_contains2')); - sk4d_region_contains3 := GetProcAddress(LibraryHandle, PChar('sk4d_region_contains3')); - sk4d_region_create := GetProcAddress(LibraryHandle, PChar('sk4d_region_create')); - sk4d_region_create2 := GetProcAddress(LibraryHandle, PChar('sk4d_region_create2')); - sk4d_region_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_region_destroy')); - sk4d_region_get_boundary_path := GetProcAddress(LibraryHandle, PChar('sk4d_region_get_boundary_path')); - sk4d_region_get_bounds := GetProcAddress(LibraryHandle, PChar('sk4d_region_get_bounds')); - sk4d_region_intersects := GetProcAddress(LibraryHandle, PChar('sk4d_region_intersects')); - sk4d_region_intersects2 := GetProcAddress(LibraryHandle, PChar('sk4d_region_intersects2')); - sk4d_region_is_complex := GetProcAddress(LibraryHandle, PChar('sk4d_region_is_complex')); - sk4d_region_is_empty := GetProcAddress(LibraryHandle, PChar('sk4d_region_is_empty')); - sk4d_region_is_equal := GetProcAddress(LibraryHandle, PChar('sk4d_region_is_equal')); - sk4d_region_is_rect := GetProcAddress(LibraryHandle, PChar('sk4d_region_is_rect')); - sk4d_region_op := GetProcAddress(LibraryHandle, PChar('sk4d_region_op')); - sk4d_region_op2 := GetProcAddress(LibraryHandle, PChar('sk4d_region_op2')); - sk4d_region_quick_contains := GetProcAddress(LibraryHandle, PChar('sk4d_region_quick_contains')); - sk4d_region_quick_reject := GetProcAddress(LibraryHandle, PChar('sk4d_region_quick_reject')); - sk4d_region_quick_reject2 := GetProcAddress(LibraryHandle, PChar('sk4d_region_quick_reject2')); - sk4d_region_set_empty := GetProcAddress(LibraryHandle, PChar('sk4d_region_set_empty')); - sk4d_region_set_path := GetProcAddress(LibraryHandle, PChar('sk4d_region_set_path')); - sk4d_region_set_rect := GetProcAddress(LibraryHandle, PChar('sk4d_region_set_rect')); - sk4d_region_set_rects := GetProcAddress(LibraryHandle, PChar('sk4d_region_set_rects')); - sk4d_region_translate := GetProcAddress(LibraryHandle, PChar('sk4d_region_translate')); - sk4d_regioncliperator_create := GetProcAddress(LibraryHandle, PChar('sk4d_regioncliperator_create')); - sk4d_regioncliperator_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_regioncliperator_destroy')); - sk4d_regioncliperator_get_current := GetProcAddress(LibraryHandle, PChar('sk4d_regioncliperator_get_current')); - sk4d_regioncliperator_move_next := GetProcAddress(LibraryHandle, PChar('sk4d_regioncliperator_move_next')); - sk4d_regioniterator_create := GetProcAddress(LibraryHandle, PChar('sk4d_regioniterator_create')); - sk4d_regioniterator_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_regioniterator_destroy')); - sk4d_regioniterator_get_current := GetProcAddress(LibraryHandle, PChar('sk4d_regioniterator_get_current')); - sk4d_regioniterator_move_next := GetProcAddress(LibraryHandle, PChar('sk4d_regioniterator_move_next')); - sk4d_regionspanerator_create := GetProcAddress(LibraryHandle, PChar('sk4d_regionspanerator_create')); - sk4d_regionspanerator_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_regionspanerator_destroy')); - sk4d_regionspanerator_next := GetProcAddress(LibraryHandle, PChar('sk4d_regionspanerator_next')); -{$ELSE} -function sk4d_region_contains; external LibraryName name 'sk4d_region_contains'; -function sk4d_region_contains2; external LibraryName name 'sk4d_region_contains2'; -function sk4d_region_contains3; external LibraryName name 'sk4d_region_contains3'; -function sk4d_region_create; external LibraryName name 'sk4d_region_create'; -function sk4d_region_create2; external LibraryName name 'sk4d_region_create2'; -procedure sk4d_region_destroy; external LibraryName name 'sk4d_region_destroy'; -function sk4d_region_get_boundary_path; external LibraryName name 'sk4d_region_get_boundary_path'; -procedure sk4d_region_get_bounds; external LibraryName name 'sk4d_region_get_bounds'; -function sk4d_region_intersects; external LibraryName name 'sk4d_region_intersects'; -function sk4d_region_intersects2; external LibraryName name 'sk4d_region_intersects2'; -function sk4d_region_is_complex; external LibraryName name 'sk4d_region_is_complex'; -function sk4d_region_is_empty; external LibraryName name 'sk4d_region_is_empty'; -function sk4d_region_is_equal; external LibraryName name 'sk4d_region_is_equal'; -function sk4d_region_is_rect; external LibraryName name 'sk4d_region_is_rect'; -function sk4d_region_op; external LibraryName name 'sk4d_region_op'; -function sk4d_region_op2; external LibraryName name 'sk4d_region_op2'; -function sk4d_region_quick_contains; external LibraryName name 'sk4d_region_quick_contains'; -function sk4d_region_quick_reject; external LibraryName name 'sk4d_region_quick_reject'; -function sk4d_region_quick_reject2; external LibraryName name 'sk4d_region_quick_reject2'; -procedure sk4d_region_set_empty; external LibraryName name 'sk4d_region_set_empty'; -function sk4d_region_set_path; external LibraryName name 'sk4d_region_set_path'; -function sk4d_region_set_rect; external LibraryName name 'sk4d_region_set_rect'; -function sk4d_region_set_rects; external LibraryName name 'sk4d_region_set_rects'; -procedure sk4d_region_translate; external LibraryName name 'sk4d_region_translate'; -function sk4d_regioncliperator_create; external LibraryName name 'sk4d_regioncliperator_create'; -procedure sk4d_regioncliperator_destroy; external LibraryName name 'sk4d_regioncliperator_destroy'; -procedure sk4d_regioncliperator_get_current; external LibraryName name 'sk4d_regioncliperator_get_current'; -function sk4d_regioncliperator_move_next; external LibraryName name 'sk4d_regioncliperator_move_next'; -function sk4d_regioniterator_create; external LibraryName name 'sk4d_regioniterator_create'; -procedure sk4d_regioniterator_destroy; external LibraryName name 'sk4d_regioniterator_destroy'; -procedure sk4d_regioniterator_get_current; external LibraryName name 'sk4d_regioniterator_get_current'; -function sk4d_regioniterator_move_next; external LibraryName name 'sk4d_regioniterator_move_next'; -function sk4d_regionspanerator_create; external LibraryName name 'sk4d_regionspanerator_create'; -procedure sk4d_regionspanerator_destroy; external LibraryName name 'sk4d_regionspanerator_destroy'; -function sk4d_regionspanerator_next; external LibraryName name 'sk4d_regionspanerator_next'; -{$ENDIF} - - -{ include/c/sk4d_rrect.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_rrect_contains := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_contains')); - sk4d_rrect_create := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_create')); - sk4d_rrect_create2 := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_create2')); - sk4d_rrect_deflate := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_deflate')); - sk4d_rrect_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_destroy')); - sk4d_rrect_get_height := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_get_height')); - sk4d_rrect_get_radii := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_get_radii')); - sk4d_rrect_get_rect := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_get_rect')); - sk4d_rrect_get_simple_radii := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_get_simple_radii')); - sk4d_rrect_get_width := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_get_width')); - sk4d_rrect_inflate := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_inflate')); - sk4d_rrect_is_complex := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_is_complex')); - sk4d_rrect_is_empty := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_is_empty')); - sk4d_rrect_is_equal := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_is_equal')); - sk4d_rrect_is_nine_patch := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_is_nine_patch')); - sk4d_rrect_is_oval := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_is_oval')); - sk4d_rrect_is_rect := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_is_rect')); - sk4d_rrect_is_simple := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_is_simple')); - sk4d_rrect_is_valid := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_is_valid')); - sk4d_rrect_offset := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_offset')); - sk4d_rrect_set_empty := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_set_empty')); - sk4d_rrect_set_nine_patch := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_set_nine_patch')); - sk4d_rrect_set_oval := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_set_oval')); - sk4d_rrect_set_rect := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_set_rect')); - sk4d_rrect_set_rect2 := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_set_rect2')); - sk4d_rrect_set_rect3 := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_set_rect3')); - sk4d_rrect_transform := GetProcAddress(LibraryHandle, PChar('sk4d_rrect_transform')); -{$ELSE} -function sk4d_rrect_contains; external LibraryName name 'sk4d_rrect_contains'; -function sk4d_rrect_create; external LibraryName name 'sk4d_rrect_create'; -function sk4d_rrect_create2; external LibraryName name 'sk4d_rrect_create2'; -procedure sk4d_rrect_deflate; external LibraryName name 'sk4d_rrect_deflate'; -procedure sk4d_rrect_destroy; external LibraryName name 'sk4d_rrect_destroy'; -function sk4d_rrect_get_height; external LibraryName name 'sk4d_rrect_get_height'; -procedure sk4d_rrect_get_radii; external LibraryName name 'sk4d_rrect_get_radii'; -procedure sk4d_rrect_get_rect; external LibraryName name 'sk4d_rrect_get_rect'; -procedure sk4d_rrect_get_simple_radii; external LibraryName name 'sk4d_rrect_get_simple_radii'; -function sk4d_rrect_get_width; external LibraryName name 'sk4d_rrect_get_width'; -procedure sk4d_rrect_inflate; external LibraryName name 'sk4d_rrect_inflate'; -function sk4d_rrect_is_complex; external LibraryName name 'sk4d_rrect_is_complex'; -function sk4d_rrect_is_empty; external LibraryName name 'sk4d_rrect_is_empty'; -function sk4d_rrect_is_equal; external LibraryName name 'sk4d_rrect_is_equal'; -function sk4d_rrect_is_nine_patch; external LibraryName name 'sk4d_rrect_is_nine_patch'; -function sk4d_rrect_is_oval; external LibraryName name 'sk4d_rrect_is_oval'; -function sk4d_rrect_is_rect; external LibraryName name 'sk4d_rrect_is_rect'; -function sk4d_rrect_is_simple; external LibraryName name 'sk4d_rrect_is_simple'; -function sk4d_rrect_is_valid; external LibraryName name 'sk4d_rrect_is_valid'; -procedure sk4d_rrect_offset; external LibraryName name 'sk4d_rrect_offset'; -procedure sk4d_rrect_set_empty; external LibraryName name 'sk4d_rrect_set_empty'; -procedure sk4d_rrect_set_nine_patch; external LibraryName name 'sk4d_rrect_set_nine_patch'; -procedure sk4d_rrect_set_oval; external LibraryName name 'sk4d_rrect_set_oval'; -procedure sk4d_rrect_set_rect; external LibraryName name 'sk4d_rrect_set_rect'; -procedure sk4d_rrect_set_rect2; external LibraryName name 'sk4d_rrect_set_rect2'; -procedure sk4d_rrect_set_rect3; external LibraryName name 'sk4d_rrect_set_rect3'; -function sk4d_rrect_transform; external LibraryName name 'sk4d_rrect_transform'; -{$ENDIF} - - -{ include/c/sk4d_runtimeeffect.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_runtimeeffect_get_child_count := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_get_child_count')); - sk4d_runtimeeffect_get_child_name := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_get_child_name')); - sk4d_runtimeeffect_get_child_type := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_get_child_type')); - sk4d_runtimeeffect_get_uniform_count := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_get_uniform_count')); - sk4d_runtimeeffect_get_uniform_data_size := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_get_uniform_data_size')); - sk4d_runtimeeffect_get_uniform_name := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_get_uniform_name')); - sk4d_runtimeeffect_get_uniform_offset := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_get_uniform_offset')); - sk4d_runtimeeffect_get_uniform_type := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_get_uniform_type')); - sk4d_runtimeeffect_get_uniform_type_count := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_get_uniform_type_count')); - sk4d_runtimeeffect_index_of_child := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_index_of_child')); - sk4d_runtimeeffect_index_of_uniform := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_index_of_uniform')); - sk4d_runtimeeffect_make_blender := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_make_blender')); - sk4d_runtimeeffect_make_color_filter := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_make_color_filter')); - sk4d_runtimeeffect_make_for_blender := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_make_for_blender')); - sk4d_runtimeeffect_make_for_color_filter := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_make_for_color_filter')); - sk4d_runtimeeffect_make_for_shader := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_make_for_shader')); - sk4d_runtimeeffect_make_image := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_make_image')); - sk4d_runtimeeffect_make_shader := GetProcAddress(LibraryHandle, PChar('sk4d_runtimeeffect_make_shader')); -{$ELSE} -function sk4d_runtimeeffect_get_child_count; external LibraryName name 'sk4d_runtimeeffect_get_child_count'; -function sk4d_runtimeeffect_get_child_name; external LibraryName name 'sk4d_runtimeeffect_get_child_name'; -function sk4d_runtimeeffect_get_child_type; external LibraryName name 'sk4d_runtimeeffect_get_child_type'; -function sk4d_runtimeeffect_get_uniform_count; external LibraryName name 'sk4d_runtimeeffect_get_uniform_count'; -function sk4d_runtimeeffect_get_uniform_data_size; external LibraryName name 'sk4d_runtimeeffect_get_uniform_data_size'; -function sk4d_runtimeeffect_get_uniform_name; external LibraryName name 'sk4d_runtimeeffect_get_uniform_name'; -function sk4d_runtimeeffect_get_uniform_offset; external LibraryName name 'sk4d_runtimeeffect_get_uniform_offset'; -function sk4d_runtimeeffect_get_uniform_type; external LibraryName name 'sk4d_runtimeeffect_get_uniform_type'; -function sk4d_runtimeeffect_get_uniform_type_count; external LibraryName name 'sk4d_runtimeeffect_get_uniform_type_count'; -function sk4d_runtimeeffect_index_of_child; external LibraryName name 'sk4d_runtimeeffect_index_of_child'; -function sk4d_runtimeeffect_index_of_uniform; external LibraryName name 'sk4d_runtimeeffect_index_of_uniform'; -function sk4d_runtimeeffect_make_blender; external LibraryName name 'sk4d_runtimeeffect_make_blender'; -function sk4d_runtimeeffect_make_color_filter; external LibraryName name 'sk4d_runtimeeffect_make_color_filter'; -function sk4d_runtimeeffect_make_for_blender; external LibraryName name 'sk4d_runtimeeffect_make_for_blender'; -function sk4d_runtimeeffect_make_for_color_filter; external LibraryName name 'sk4d_runtimeeffect_make_for_color_filter'; -function sk4d_runtimeeffect_make_for_shader; external LibraryName name 'sk4d_runtimeeffect_make_for_shader'; -function sk4d_runtimeeffect_make_image; external LibraryName name 'sk4d_runtimeeffect_make_image'; -function sk4d_runtimeeffect_make_shader; external LibraryName name 'sk4d_runtimeeffect_make_shader'; -{$ENDIF} - - -{ include/c/sk4d_shader.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_shader_make_blend := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_blend')); - sk4d_shader_make_color := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_color')); - sk4d_shader_make_color2 := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_color2')); - sk4d_shader_make_gradient_linear := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_gradient_linear')); - sk4d_shader_make_gradient_linear2 := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_gradient_linear2')); - sk4d_shader_make_gradient_radial := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_gradient_radial')); - sk4d_shader_make_gradient_radial2 := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_gradient_radial2')); - sk4d_shader_make_gradient_sweep := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_gradient_sweep')); - sk4d_shader_make_gradient_sweep2 := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_gradient_sweep2')); - sk4d_shader_make_gradient_two_point_conical := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_gradient_two_point_conical')); - sk4d_shader_make_gradient_two_point_conical2 := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_gradient_two_point_conical2')); - sk4d_shader_make_perlin_noise_fractal_noise := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_perlin_noise_fractal_noise')); - sk4d_shader_make_perlin_noise_turbulence := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_perlin_noise_turbulence')); - sk4d_shader_make_with_color_filter := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_with_color_filter')); - sk4d_shader_make_with_local_matrix := GetProcAddress(LibraryHandle, PChar('sk4d_shader_make_with_local_matrix')); -{$ELSE} -function sk4d_shader_make_blend; external LibraryName name 'sk4d_shader_make_blend'; -function sk4d_shader_make_color; external LibraryName name 'sk4d_shader_make_color'; -function sk4d_shader_make_color2; external LibraryName name 'sk4d_shader_make_color2'; -function sk4d_shader_make_gradient_linear; external LibraryName name 'sk4d_shader_make_gradient_linear'; -function sk4d_shader_make_gradient_linear2; external LibraryName name 'sk4d_shader_make_gradient_linear2'; -function sk4d_shader_make_gradient_radial; external LibraryName name 'sk4d_shader_make_gradient_radial'; -function sk4d_shader_make_gradient_radial2; external LibraryName name 'sk4d_shader_make_gradient_radial2'; -function sk4d_shader_make_gradient_sweep; external LibraryName name 'sk4d_shader_make_gradient_sweep'; -function sk4d_shader_make_gradient_sweep2; external LibraryName name 'sk4d_shader_make_gradient_sweep2'; -function sk4d_shader_make_gradient_two_point_conical; external LibraryName name 'sk4d_shader_make_gradient_two_point_conical'; -function sk4d_shader_make_gradient_two_point_conical2; external LibraryName name 'sk4d_shader_make_gradient_two_point_conical2'; -function sk4d_shader_make_perlin_noise_fractal_noise; external LibraryName name 'sk4d_shader_make_perlin_noise_fractal_noise'; -function sk4d_shader_make_perlin_noise_turbulence; external LibraryName name 'sk4d_shader_make_perlin_noise_turbulence'; -function sk4d_shader_make_with_color_filter; external LibraryName name 'sk4d_shader_make_with_color_filter'; -function sk4d_shader_make_with_local_matrix; external LibraryName name 'sk4d_shader_make_with_local_matrix'; -{$ENDIF} - - -{ include/c/sk4d_stream.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_streamadapter_create := GetProcAddress(LibraryHandle, PChar('sk4d_streamadapter_create')); - sk4d_streamadapter_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_streamadapter_destroy')); - sk4d_streamadapter_set_procs := GetProcAddress(LibraryHandle, PChar('sk4d_streamadapter_set_procs')); - sk4d_wstreamadapter_create := GetProcAddress(LibraryHandle, PChar('sk4d_wstreamadapter_create')); - sk4d_wstreamadapter_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_wstreamadapter_destroy')); - sk4d_wstreamadapter_set_procs := GetProcAddress(LibraryHandle, PChar('sk4d_wstreamadapter_set_procs')); -{$ELSE} -function sk4d_streamadapter_create; external LibraryName name 'sk4d_streamadapter_create'; -procedure sk4d_streamadapter_destroy; external LibraryName name 'sk4d_streamadapter_destroy'; -procedure sk4d_streamadapter_set_procs; external LibraryName name 'sk4d_streamadapter_set_procs'; -function sk4d_wstreamadapter_create; external LibraryName name 'sk4d_wstreamadapter_create'; -procedure sk4d_wstreamadapter_destroy; external LibraryName name 'sk4d_wstreamadapter_destroy'; -procedure sk4d_wstreamadapter_set_procs; external LibraryName name 'sk4d_wstreamadapter_set_procs'; -{$ENDIF} - - -{ include/c/sk4d_string.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_string_create := GetProcAddress(LibraryHandle, PChar('sk4d_string_create')); - sk4d_string_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_string_destroy')); - sk4d_string_get_text := GetProcAddress(LibraryHandle, PChar('sk4d_string_get_text')); -{$ELSE} -function sk4d_string_create; external LibraryName name 'sk4d_string_create'; -procedure sk4d_string_destroy; external LibraryName name 'sk4d_string_destroy'; -function sk4d_string_get_text; external LibraryName name 'sk4d_string_get_text'; -{$ENDIF} - - -{ include/c/sk4d_surface.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_surface_draw := GetProcAddress(LibraryHandle, PChar('sk4d_surface_draw')); - sk4d_surface_flush := GetProcAddress(LibraryHandle, PChar('sk4d_surface_flush')); - sk4d_surface_flush_and_submit := GetProcAddress(LibraryHandle, PChar('sk4d_surface_flush_and_submit')); - sk4d_surface_get_canvas := GetProcAddress(LibraryHandle, PChar('sk4d_surface_get_canvas')); - sk4d_surface_get_props := GetProcAddress(LibraryHandle, PChar('sk4d_surface_get_props')); - sk4d_surface_make_from_mtk_view := GetProcAddress(LibraryHandle, PChar('sk4d_surface_make_from_mtk_view')); - sk4d_surface_make_from_render_target := GetProcAddress(LibraryHandle, PChar('sk4d_surface_make_from_render_target')); - sk4d_surface_make_from_texture := GetProcAddress(LibraryHandle, PChar('sk4d_surface_make_from_texture')); - sk4d_surface_make_image_snapshot := GetProcAddress(LibraryHandle, PChar('sk4d_surface_make_image_snapshot')); - sk4d_surface_make_image_snapshot2 := GetProcAddress(LibraryHandle, PChar('sk4d_surface_make_image_snapshot2')); - sk4d_surface_make_raster := GetProcAddress(LibraryHandle, PChar('sk4d_surface_make_raster')); - sk4d_surface_make_raster_direct := GetProcAddress(LibraryHandle, PChar('sk4d_surface_make_raster_direct')); - sk4d_surface_make_render_target := GetProcAddress(LibraryHandle, PChar('sk4d_surface_make_render_target')); - sk4d_surface_peek_pixels := GetProcAddress(LibraryHandle, PChar('sk4d_surface_peek_pixels')); - sk4d_surface_read_pixels := GetProcAddress(LibraryHandle, PChar('sk4d_surface_read_pixels')); -{$ELSE} -procedure sk4d_surface_draw; external LibraryName name 'sk4d_surface_draw'; -procedure sk4d_surface_flush; external LibraryName name 'sk4d_surface_flush'; -procedure sk4d_surface_flush_and_submit; external LibraryName name 'sk4d_surface_flush_and_submit'; -function sk4d_surface_get_canvas; external LibraryName name 'sk4d_surface_get_canvas'; -procedure sk4d_surface_get_props; external LibraryName name 'sk4d_surface_get_props'; -function sk4d_surface_make_from_mtk_view; external LibraryName name 'sk4d_surface_make_from_mtk_view'; -function sk4d_surface_make_from_render_target; external LibraryName name 'sk4d_surface_make_from_render_target'; -function sk4d_surface_make_from_texture; external LibraryName name 'sk4d_surface_make_from_texture'; -function sk4d_surface_make_image_snapshot; external LibraryName name 'sk4d_surface_make_image_snapshot'; -function sk4d_surface_make_image_snapshot2; external LibraryName name 'sk4d_surface_make_image_snapshot2'; -function sk4d_surface_make_raster; external LibraryName name 'sk4d_surface_make_raster'; -function sk4d_surface_make_raster_direct; external LibraryName name 'sk4d_surface_make_raster_direct'; -function sk4d_surface_make_render_target; external LibraryName name 'sk4d_surface_make_render_target'; -function sk4d_surface_peek_pixels; external LibraryName name 'sk4d_surface_peek_pixels'; -function sk4d_surface_read_pixels; external LibraryName name 'sk4d_surface_read_pixels'; -{$ENDIF} - - -{ include/c/sk4d_svgcanvas.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_svgcanvas_make := GetProcAddress(LibraryHandle, PChar('sk4d_svgcanvas_make')); -{$ELSE} -function sk4d_svgcanvas_make; external LibraryName name 'sk4d_svgcanvas_make'; -{$ENDIF} - - -{ include/c/sk4d_textblob.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_textblob_get_intercepts := GetProcAddress(LibraryHandle, PChar('sk4d_textblob_get_intercepts')); - sk4d_textblob_make_from_text := GetProcAddress(LibraryHandle, PChar('sk4d_textblob_make_from_text')); - sk4d_textblob_make_from_text_horizontally_positioned := GetProcAddress(LibraryHandle, PChar('sk4d_textblob_make_from_text_horizontally_positioned')); - sk4d_textblob_make_from_text_positioned := GetProcAddress(LibraryHandle, PChar('sk4d_textblob_make_from_text_positioned')); - sk4d_textblob_make_from_text_transform := GetProcAddress(LibraryHandle, PChar('sk4d_textblob_make_from_text_transform')); - sk4d_textblob_ref := GetProcAddress(LibraryHandle, PChar('sk4d_textblob_ref')); - sk4d_textblob_unref := GetProcAddress(LibraryHandle, PChar('sk4d_textblob_unref')); -{$ELSE} -function sk4d_textblob_get_intercepts; external LibraryName name 'sk4d_textblob_get_intercepts'; -function sk4d_textblob_make_from_text; external LibraryName name 'sk4d_textblob_make_from_text'; -function sk4d_textblob_make_from_text_horizontally_positioned; external LibraryName name 'sk4d_textblob_make_from_text_horizontally_positioned'; -function sk4d_textblob_make_from_text_positioned; external LibraryName name 'sk4d_textblob_make_from_text_positioned'; -function sk4d_textblob_make_from_text_transform; external LibraryName name 'sk4d_textblob_make_from_text_transform'; -procedure sk4d_textblob_ref; external LibraryName name 'sk4d_textblob_ref'; -procedure sk4d_textblob_unref; external LibraryName name 'sk4d_textblob_unref'; - -{$ENDIF} - - -{ include/c/sk4d_tracememorydump.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_tracememorydumpbaseclass_create := GetProcAddress(LibraryHandle, PChar('sk4d_tracememorydumpbaseclass_create')); - sk4d_tracememorydumpbaseclass_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_tracememorydumpbaseclass_destroy')); - sk4d_tracememorydumpbaseclass_set_procs := GetProcAddress(LibraryHandle, PChar('sk4d_tracememorydumpbaseclass_set_procs')); -{$ELSE} -function sk4d_tracememorydumpbaseclass_create; external LibraryName name 'sk4d_tracememorydumpbaseclass_create'; -procedure sk4d_tracememorydumpbaseclass_destroy; external LibraryName name 'sk4d_tracememorydumpbaseclass_destroy'; -procedure sk4d_tracememorydumpbaseclass_set_procs; external LibraryName name 'sk4d_tracememorydumpbaseclass_set_procs'; -{$ENDIF} - - -{ include/c/sk4d_typeface.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_typeface_get_family_name := GetProcAddress(LibraryHandle, PChar('sk4d_typeface_get_family_name')); - sk4d_typeface_get_slant := GetProcAddress(LibraryHandle, PChar('sk4d_typeface_get_slant')); - sk4d_typeface_get_style := GetProcAddress(LibraryHandle, PChar('sk4d_typeface_get_style')); - sk4d_typeface_get_weight := GetProcAddress(LibraryHandle, PChar('sk4d_typeface_get_weight')); - sk4d_typeface_get_width := GetProcAddress(LibraryHandle, PChar('sk4d_typeface_get_width')); - sk4d_typeface_make_default := GetProcAddress(LibraryHandle, PChar('sk4d_typeface_make_default')); - sk4d_typeface_make_from_file := GetProcAddress(LibraryHandle, PChar('sk4d_typeface_make_from_file')); - sk4d_typeface_make_from_stream := GetProcAddress(LibraryHandle, PChar('sk4d_typeface_make_from_stream')); - sk4d_typeface_make_from_name := GetProcAddress(LibraryHandle, PChar('sk4d_typeface_make_from_name')); -{$ELSE} -function sk4d_typeface_get_family_name; external LibraryName name 'sk4d_typeface_get_family_name'; -function sk4d_typeface_get_slant; external LibraryName name 'sk4d_typeface_get_slant'; -procedure sk4d_typeface_get_style; external LibraryName name 'sk4d_typeface_get_style'; -function sk4d_typeface_get_weight; external LibraryName name 'sk4d_typeface_get_weight'; -function sk4d_typeface_get_width; external LibraryName name 'sk4d_typeface_get_width'; -function sk4d_typeface_make_default; external LibraryName name 'sk4d_typeface_make_default'; -function sk4d_typeface_make_from_file; external LibraryName name 'sk4d_typeface_make_from_file'; -function sk4d_typeface_make_from_stream; external LibraryName name 'sk4d_typeface_make_from_stream'; -function sk4d_typeface_make_from_name; external LibraryName name 'sk4d_typeface_make_from_name'; -{$ENDIF} - - -{ include/c/sk4d_vertices.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_vertices_make_copy := GetProcAddress(LibraryHandle, PChar('sk4d_vertices_make_copy')); - sk4d_vertices_ref := GetProcAddress(LibraryHandle, PChar('sk4d_vertices_ref')); - sk4d_vertices_unref := GetProcAddress(LibraryHandle, PChar('sk4d_vertices_unref')); -{$ELSE} -function sk4d_vertices_make_copy; external LibraryName name 'sk4d_vertices_make_copy'; -procedure sk4d_vertices_ref; external LibraryName name 'sk4d_vertices_ref'; -procedure sk4d_vertices_unref; external LibraryName name 'sk4d_vertices_unref'; -{$ENDIF} - - -{ modules/particles/include/sk4d_particleeffect.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_particleeffect_get_position := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_get_position')); - sk4d_particleeffect_get_rate := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_get_rate')); - sk4d_particleeffect_get_uniform := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_get_uniform')); - sk4d_particleeffect_get_uniform_count := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_get_uniform_count')); - sk4d_particleeffect_get_uniform_data := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_get_uniform_data')); - sk4d_particleeffect_get_uniform_data_count := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_get_uniform_data_count')); - sk4d_particleeffect_get_uniform_name := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_get_uniform_name')); - sk4d_particleeffect_init := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_init')); - sk4d_particleeffect_make_from_file := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_make_from_file')); - sk4d_particleeffect_make_from_stream := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_make_from_stream')); - sk4d_particleeffect_render := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_render')); - sk4d_particleeffect_set_position := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_set_position')); - sk4d_particleeffect_set_rate := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_set_rate')); - sk4d_particleeffect_set_uniform := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_set_uniform')); - sk4d_particleeffect_start := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_start')); - sk4d_particleeffect_update := GetProcAddress(LibraryHandle, PChar('sk4d_particleeffect_update')); -{$ELSE} -procedure sk4d_particleeffect_get_position; external LibraryName name 'sk4d_particleeffect_get_position'; -function sk4d_particleeffect_get_rate; external LibraryName name 'sk4d_particleeffect_get_rate'; -procedure sk4d_particleeffect_get_uniform; external LibraryName name 'sk4d_particleeffect_get_uniform'; -function sk4d_particleeffect_get_uniform_count; external LibraryName name 'sk4d_particleeffect_get_uniform_count'; -function sk4d_particleeffect_get_uniform_data; external LibraryName name 'sk4d_particleeffect_get_uniform_data'; -function sk4d_particleeffect_get_uniform_data_count; external LibraryName name 'sk4d_particleeffect_get_uniform_data_count'; -function sk4d_particleeffect_get_uniform_name; external LibraryName name 'sk4d_particleeffect_get_uniform_name'; -procedure sk4d_particleeffect_init; external LibraryName name 'sk4d_particleeffect_init'; -function sk4d_particleeffect_make_from_file; external LibraryName name 'sk4d_particleeffect_make_from_file'; -function sk4d_particleeffect_make_from_stream; external LibraryName name 'sk4d_particleeffect_make_from_stream'; -procedure sk4d_particleeffect_render; external LibraryName name 'sk4d_particleeffect_render'; -procedure sk4d_particleeffect_set_position; external LibraryName name 'sk4d_particleeffect_set_position'; -procedure sk4d_particleeffect_set_rate; external LibraryName name 'sk4d_particleeffect_set_rate'; -function sk4d_particleeffect_set_uniform; external LibraryName name 'sk4d_particleeffect_set_uniform'; -procedure sk4d_particleeffect_start; external LibraryName name 'sk4d_particleeffect_start'; -procedure sk4d_particleeffect_update; external LibraryName name 'sk4d_particleeffect_update'; -{$ENDIF} - - -{ modules/skottie/include/sk4d_skottie.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_skottieanimation_get_duration := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_get_duration')); - sk4d_skottieanimation_get_fps := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_get_fps')); - sk4d_skottieanimation_get_in_point := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_get_in_point')); - sk4d_skottieanimation_get_out_point := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_get_out_point')); - sk4d_skottieanimation_get_size := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_get_size')); - sk4d_skottieanimation_get_version := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_get_version')); - sk4d_skottieanimation_make_from_file := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_make_from_file')); - sk4d_skottieanimation_make_from_stream := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_make_from_stream')); - sk4d_skottieanimation_ref := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_ref')); - sk4d_skottieanimation_render := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_render')); - sk4d_skottieanimation_seek_frame := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_seek_frame')); - sk4d_skottieanimation_seek_frame_time := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_seek_frame_time')); - sk4d_skottieanimation_unref := GetProcAddress(LibraryHandle, PChar('sk4d_skottieanimation_unref')); -{$ELSE} -function sk4d_skottieanimation_get_duration; external LibraryName name 'sk4d_skottieanimation_get_duration'; -function sk4d_skottieanimation_get_fps; external LibraryName name 'sk4d_skottieanimation_get_fps'; -function sk4d_skottieanimation_get_in_point; external LibraryName name 'sk4d_skottieanimation_get_in_point'; -function sk4d_skottieanimation_get_out_point; external LibraryName name 'sk4d_skottieanimation_get_out_point'; -procedure sk4d_skottieanimation_get_size; external LibraryName name 'sk4d_skottieanimation_get_size'; -function sk4d_skottieanimation_get_version; external LibraryName name 'sk4d_skottieanimation_get_version'; -function sk4d_skottieanimation_make_from_file; external LibraryName name 'sk4d_skottieanimation_make_from_file'; -function sk4d_skottieanimation_make_from_stream; external LibraryName name 'sk4d_skottieanimation_make_from_stream'; -procedure sk4d_skottieanimation_ref; external LibraryName name 'sk4d_skottieanimation_ref'; -procedure sk4d_skottieanimation_render; external LibraryName name 'sk4d_skottieanimation_render'; -procedure sk4d_skottieanimation_seek_frame; external LibraryName name 'sk4d_skottieanimation_seek_frame'; -procedure sk4d_skottieanimation_seek_frame_time; external LibraryName name 'sk4d_skottieanimation_seek_frame_time'; -procedure sk4d_skottieanimation_unref; external LibraryName name 'sk4d_skottieanimation_unref'; -{$ENDIF} - - -{ modules/skparagraph/include/sk4d_paragraph.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_paragraph_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_destroy')); - sk4d_paragraph_did_exceed_max_lines := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_did_exceed_max_lines')); - sk4d_paragraph_get_alphabetic_baseline := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_alphabetic_baseline')); - sk4d_paragraph_get_glyph_position_at_coordinate := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_glyph_position_at_coordinate')); - sk4d_paragraph_get_height := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_height')); - sk4d_paragraph_get_ideographic_baseline := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_ideographic_baseline')); - sk4d_paragraph_get_line_metrics := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_line_metrics')); - sk4d_paragraph_get_longest_line := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_longest_line')); - sk4d_paragraph_get_max_intrinsic_width := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_max_intrinsic_width')); - sk4d_paragraph_get_max_width := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_max_width')); - sk4d_paragraph_get_min_intrinsic_width := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_min_intrinsic_width')); - sk4d_paragraph_get_rects_for_placeholders := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_rects_for_placeholders')); - sk4d_paragraph_get_rects_for_range := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_rects_for_range')); - sk4d_paragraph_get_word_boundary := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_get_word_boundary')); - sk4d_paragraph_layout := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_layout')); - sk4d_paragraph_paint := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_paint')); - sk4d_paragraph_to_path := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_to_path')); - sk4d_paragraph_visit := GetProcAddress(LibraryHandle, PChar('sk4d_paragraph_visit')); -{$ELSE} -procedure sk4d_paragraph_destroy; external LibraryName name 'sk4d_paragraph_destroy'; -function sk4d_paragraph_did_exceed_max_lines; external LibraryName name 'sk4d_paragraph_did_exceed_max_lines'; -function sk4d_paragraph_get_alphabetic_baseline; external LibraryName name 'sk4d_paragraph_get_alphabetic_baseline'; -procedure sk4d_paragraph_get_glyph_position_at_coordinate; external LibraryName name 'sk4d_paragraph_get_glyph_position_at_coordinate'; -function sk4d_paragraph_get_height; external LibraryName name 'sk4d_paragraph_get_height'; -function sk4d_paragraph_get_ideographic_baseline; external LibraryName name 'sk4d_paragraph_get_ideographic_baseline'; -function sk4d_paragraph_get_line_metrics; external LibraryName name 'sk4d_paragraph_get_line_metrics'; -function sk4d_paragraph_get_longest_line; external LibraryName name 'sk4d_paragraph_get_longest_line'; -function sk4d_paragraph_get_max_intrinsic_width; external LibraryName name 'sk4d_paragraph_get_max_intrinsic_width'; -function sk4d_paragraph_get_max_width; external LibraryName name 'sk4d_paragraph_get_max_width'; -function sk4d_paragraph_get_min_intrinsic_width; external LibraryName name 'sk4d_paragraph_get_min_intrinsic_width'; -function sk4d_paragraph_get_rects_for_placeholders; external LibraryName name 'sk4d_paragraph_get_rects_for_placeholders'; -function sk4d_paragraph_get_rects_for_range; external LibraryName name 'sk4d_paragraph_get_rects_for_range'; -procedure sk4d_paragraph_get_word_boundary; external LibraryName name 'sk4d_paragraph_get_word_boundary'; -procedure sk4d_paragraph_layout; external LibraryName name 'sk4d_paragraph_layout'; -procedure sk4d_paragraph_paint; external LibraryName name 'sk4d_paragraph_paint'; -function sk4d_paragraph_to_path; external LibraryName name 'sk4d_paragraph_to_path'; -procedure sk4d_paragraph_visit; external LibraryName name 'sk4d_paragraph_visit'; -{$ENDIF} - - -{ modules/skparagraph/include/sk4d_paragraphbuilder.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_paragraphbuilder_add_placeholder := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphbuilder_add_placeholder')); - sk4d_paragraphbuilder_add_text := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphbuilder_add_text')); - sk4d_paragraphbuilder_build := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphbuilder_build')); - sk4d_paragraphbuilder_create := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphbuilder_create')); - sk4d_paragraphbuilder_create2 := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphbuilder_create2')); - sk4d_paragraphbuilder_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphbuilder_destroy')); - sk4d_paragraphbuilder_pop := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphbuilder_pop')); - sk4d_paragraphbuilder_push_style := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphbuilder_push_style')); -{$ELSE} -procedure sk4d_paragraphbuilder_add_placeholder; external LibraryName name 'sk4d_paragraphbuilder_add_placeholder'; -procedure sk4d_paragraphbuilder_add_text; external LibraryName name 'sk4d_paragraphbuilder_add_text'; -function sk4d_paragraphbuilder_build; external LibraryName name 'sk4d_paragraphbuilder_build'; -function sk4d_paragraphbuilder_create; external LibraryName name 'sk4d_paragraphbuilder_create'; -function sk4d_paragraphbuilder_create2; external LibraryName name 'sk4d_paragraphbuilder_create2'; -procedure sk4d_paragraphbuilder_destroy; external LibraryName name 'sk4d_paragraphbuilder_destroy'; -procedure sk4d_paragraphbuilder_pop; external LibraryName name 'sk4d_paragraphbuilder_pop'; -procedure sk4d_paragraphbuilder_push_style; external LibraryName name 'sk4d_paragraphbuilder_push_style'; -{$ENDIF} - - -{ modules/skparagraph/include/sk4d_paragraphstyle.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_paragraphstyle_create := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_create')); - sk4d_paragraphstyle_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_destroy')); - sk4d_paragraphstyle_disable_hinting := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_disable_hinting')); - sk4d_paragraphstyle_get_ellipsis := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_get_ellipsis')); - sk4d_paragraphstyle_get_height := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_get_height')); - sk4d_paragraphstyle_get_max_lines := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_get_max_lines')); - sk4d_paragraphstyle_get_strut_style := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_get_strut_style')); - sk4d_paragraphstyle_get_text_align := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_get_text_align')); - sk4d_paragraphstyle_get_text_direction := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_get_text_direction')); - sk4d_paragraphstyle_get_text_height_behaviors := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_get_text_height_behaviors')); - sk4d_paragraphstyle_get_text_style := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_get_text_style')); - sk4d_paragraphstyle_set_ellipsis := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_set_ellipsis')); - sk4d_paragraphstyle_set_height := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_set_height')); - sk4d_paragraphstyle_set_max_lines := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_set_max_lines')); - sk4d_paragraphstyle_set_strut_style := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_set_strut_style')); - sk4d_paragraphstyle_set_text_align := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_set_text_align')); - sk4d_paragraphstyle_set_text_direction := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_set_text_direction')); - sk4d_paragraphstyle_set_text_height_behaviors := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_set_text_height_behaviors')); - sk4d_paragraphstyle_set_text_style := GetProcAddress(LibraryHandle, PChar('sk4d_paragraphstyle_set_text_style')); - sk4d_strutstyle_create := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_create')); - sk4d_strutstyle_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_destroy')); - sk4d_strutstyle_get_enabled := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_get_enabled')); - sk4d_strutstyle_get_font_families := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_get_font_families')); - sk4d_strutstyle_get_font_size := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_get_font_size')); - sk4d_strutstyle_get_font_style := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_get_font_style')); - sk4d_strutstyle_get_force_height := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_get_force_height')); - sk4d_strutstyle_get_half_leading := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_get_half_leading')); - sk4d_strutstyle_get_height_multiplier := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_get_height_multiplier')); - sk4d_strutstyle_get_leading := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_get_leading')); - sk4d_strutstyle_is_equal := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_is_equal')); - sk4d_strutstyle_set_enabled := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_set_enabled')); - sk4d_strutstyle_set_font_families := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_set_font_families')); - sk4d_strutstyle_set_font_size := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_set_font_size')); - sk4d_strutstyle_set_font_style := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_set_font_style')); - sk4d_strutstyle_set_force_height := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_set_force_height')); - sk4d_strutstyle_set_half_leading := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_set_half_leading')); - sk4d_strutstyle_set_height_multiplier := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_set_height_multiplier')); - sk4d_strutstyle_set_leading := GetProcAddress(LibraryHandle, PChar('sk4d_strutstyle_set_leading')); -{$ELSE} -function sk4d_paragraphstyle_create; external LibraryName name 'sk4d_paragraphstyle_create'; -procedure sk4d_paragraphstyle_destroy; external LibraryName name 'sk4d_paragraphstyle_destroy'; -procedure sk4d_paragraphstyle_disable_hinting; external LibraryName name 'sk4d_paragraphstyle_disable_hinting'; -function sk4d_paragraphstyle_get_ellipsis; external LibraryName name 'sk4d_paragraphstyle_get_ellipsis'; -function sk4d_paragraphstyle_get_height; external LibraryName name 'sk4d_paragraphstyle_get_height'; -function sk4d_paragraphstyle_get_max_lines; external LibraryName name 'sk4d_paragraphstyle_get_max_lines'; -function sk4d_paragraphstyle_get_strut_style; external LibraryName name 'sk4d_paragraphstyle_get_strut_style'; -function sk4d_paragraphstyle_get_text_align; external LibraryName name 'sk4d_paragraphstyle_get_text_align'; -function sk4d_paragraphstyle_get_text_direction; external LibraryName name 'sk4d_paragraphstyle_get_text_direction'; -function sk4d_paragraphstyle_get_text_height_behaviors; external LibraryName name 'sk4d_paragraphstyle_get_text_height_behaviors'; -function sk4d_paragraphstyle_get_text_style; external LibraryName name 'sk4d_paragraphstyle_get_text_style'; -procedure sk4d_paragraphstyle_set_ellipsis; external LibraryName name 'sk4d_paragraphstyle_set_ellipsis'; -procedure sk4d_paragraphstyle_set_height; external LibraryName name 'sk4d_paragraphstyle_set_height'; -procedure sk4d_paragraphstyle_set_max_lines; external LibraryName name 'sk4d_paragraphstyle_set_max_lines'; -procedure sk4d_paragraphstyle_set_strut_style; external LibraryName name 'sk4d_paragraphstyle_set_strut_style'; -procedure sk4d_paragraphstyle_set_text_align; external LibraryName name 'sk4d_paragraphstyle_set_text_align'; -procedure sk4d_paragraphstyle_set_text_direction; external LibraryName name 'sk4d_paragraphstyle_set_text_direction'; -procedure sk4d_paragraphstyle_set_text_height_behaviors; external LibraryName name 'sk4d_paragraphstyle_set_text_height_behaviors'; -procedure sk4d_paragraphstyle_set_text_style; external LibraryName name 'sk4d_paragraphstyle_set_text_style'; -function sk4d_strutstyle_create; external LibraryName name 'sk4d_strutstyle_create'; -procedure sk4d_strutstyle_destroy; external LibraryName name 'sk4d_strutstyle_destroy'; -function sk4d_strutstyle_get_enabled; external LibraryName name 'sk4d_strutstyle_get_enabled'; -function sk4d_strutstyle_get_font_families; external LibraryName name 'sk4d_strutstyle_get_font_families'; -function sk4d_strutstyle_get_font_size; external LibraryName name 'sk4d_strutstyle_get_font_size'; -procedure sk4d_strutstyle_get_font_style; external LibraryName name 'sk4d_strutstyle_get_font_style'; -function sk4d_strutstyle_get_force_height; external LibraryName name 'sk4d_strutstyle_get_force_height'; -function sk4d_strutstyle_get_half_leading; external LibraryName name 'sk4d_strutstyle_get_half_leading'; -function sk4d_strutstyle_get_height_multiplier; external LibraryName name 'sk4d_strutstyle_get_height_multiplier'; -function sk4d_strutstyle_get_leading; external LibraryName name 'sk4d_strutstyle_get_leading'; -function sk4d_strutstyle_is_equal; external LibraryName name 'sk4d_strutstyle_is_equal'; -procedure sk4d_strutstyle_set_enabled; external LibraryName name 'sk4d_strutstyle_set_enabled'; -procedure sk4d_strutstyle_set_font_families; external LibraryName name 'sk4d_strutstyle_set_font_families'; -procedure sk4d_strutstyle_set_font_size; external LibraryName name 'sk4d_strutstyle_set_font_size'; -procedure sk4d_strutstyle_set_font_style; external LibraryName name 'sk4d_strutstyle_set_font_style'; -procedure sk4d_strutstyle_set_force_height; external LibraryName name 'sk4d_strutstyle_set_force_height'; -procedure sk4d_strutstyle_set_half_leading; external LibraryName name 'sk4d_strutstyle_set_half_leading'; -procedure sk4d_strutstyle_set_height_multiplier; external LibraryName name 'sk4d_strutstyle_set_height_multiplier'; -procedure sk4d_strutstyle_set_leading; external LibraryName name 'sk4d_strutstyle_set_leading'; -{$ENDIF} - - -{ modules/skparagraph/include/sk4d_textstyle.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_textstyle_add_font_feature := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_add_font_feature')); - sk4d_textstyle_add_shadow := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_add_shadow')); - sk4d_textstyle_clear_background_color := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_clear_background_color')); - sk4d_textstyle_clear_foreground_color := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_clear_foreground_color')); - sk4d_textstyle_create := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_create')); - sk4d_textstyle_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_destroy')); - sk4d_textstyle_get_background := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_background')); - sk4d_textstyle_get_color := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_color')); - sk4d_textstyle_get_decoration_color := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_decoration_color')); - sk4d_textstyle_get_decoration_style := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_decoration_style')); - sk4d_textstyle_get_decoration_thickness := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_decoration_thickness')); - sk4d_textstyle_get_decorations := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_decorations')); - sk4d_textstyle_get_font_families := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_font_families')); - sk4d_textstyle_get_font_metrics := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_font_metrics')); - sk4d_textstyle_get_font_size := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_font_size')); - sk4d_textstyle_get_font_style := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_font_style')); - sk4d_textstyle_get_foreground := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_foreground')); - sk4d_textstyle_get_half_leading := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_half_leading')); - sk4d_textstyle_get_height_multiplier := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_height_multiplier')); - sk4d_textstyle_get_letter_spacing := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_letter_spacing')); - sk4d_textstyle_get_locale := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_locale')); - sk4d_textstyle_get_word_spacing := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_get_word_spacing')); - sk4d_textstyle_is_equal := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_is_equal')); - sk4d_textstyle_reset_font_features := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_reset_font_features')); - sk4d_textstyle_reset_shadows := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_reset_shadows')); - sk4d_textstyle_set_background_color := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_background_color')); - sk4d_textstyle_set_color := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_color')); - sk4d_textstyle_set_decoration_color := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_decoration_color')); - sk4d_textstyle_set_decoration_style := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_decoration_style')); - sk4d_textstyle_set_decoration_thickness := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_decoration_thickness')); - sk4d_textstyle_set_decorations := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_decorations')); - sk4d_textstyle_set_font_families := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_font_families')); - sk4d_textstyle_set_font_size := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_font_size')); - sk4d_textstyle_set_font_style := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_font_style')); - sk4d_textstyle_set_foreground_color := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_foreground_color')); - sk4d_textstyle_set_half_leading := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_half_leading')); - sk4d_textstyle_set_height_multiplier := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_height_multiplier')); - sk4d_textstyle_set_letter_spacing := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_letter_spacing')); - sk4d_textstyle_set_locale := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_locale')); - sk4d_textstyle_set_word_spacing := GetProcAddress(LibraryHandle, PChar('sk4d_textstyle_set_word_spacing')); -{$ELSE} -procedure sk4d_textstyle_add_font_feature; external LibraryName name 'sk4d_textstyle_add_font_feature'; -procedure sk4d_textstyle_add_shadow; external LibraryName name 'sk4d_textstyle_add_shadow'; -procedure sk4d_textstyle_clear_background_color; external LibraryName name 'sk4d_textstyle_clear_background_color'; -procedure sk4d_textstyle_clear_foreground_color; external LibraryName name 'sk4d_textstyle_clear_foreground_color'; -function sk4d_textstyle_create; external LibraryName name 'sk4d_textstyle_create'; -procedure sk4d_textstyle_destroy; external LibraryName name 'sk4d_textstyle_destroy'; -function sk4d_textstyle_get_background; external LibraryName name 'sk4d_textstyle_get_background'; -function sk4d_textstyle_get_color; external LibraryName name 'sk4d_textstyle_get_color'; -function sk4d_textstyle_get_decoration_color; external LibraryName name 'sk4d_textstyle_get_decoration_color'; -function sk4d_textstyle_get_decoration_style; external LibraryName name 'sk4d_textstyle_get_decoration_style'; -function sk4d_textstyle_get_decoration_thickness; external LibraryName name 'sk4d_textstyle_get_decoration_thickness'; -function sk4d_textstyle_get_decorations; external LibraryName name 'sk4d_textstyle_get_decorations'; -function sk4d_textstyle_get_font_families; external LibraryName name 'sk4d_textstyle_get_font_families'; -procedure sk4d_textstyle_get_font_metrics; external LibraryName name 'sk4d_textstyle_get_font_metrics'; -function sk4d_textstyle_get_font_size; external LibraryName name 'sk4d_textstyle_get_font_size'; -procedure sk4d_textstyle_get_font_style; external LibraryName name 'sk4d_textstyle_get_font_style'; -function sk4d_textstyle_get_foreground; external LibraryName name 'sk4d_textstyle_get_foreground'; -function sk4d_textstyle_get_half_leading; external LibraryName name 'sk4d_textstyle_get_half_leading'; -function sk4d_textstyle_get_height_multiplier; external LibraryName name 'sk4d_textstyle_get_height_multiplier'; -function sk4d_textstyle_get_letter_spacing; external LibraryName name 'sk4d_textstyle_get_letter_spacing'; -function sk4d_textstyle_get_locale; external LibraryName name 'sk4d_textstyle_get_locale'; -function sk4d_textstyle_get_word_spacing; external LibraryName name 'sk4d_textstyle_get_word_spacing'; -function sk4d_textstyle_is_equal; external LibraryName name 'sk4d_textstyle_is_equal'; -procedure sk4d_textstyle_reset_font_features; external LibraryName name 'sk4d_textstyle_reset_font_features'; -procedure sk4d_textstyle_reset_shadows; external LibraryName name 'sk4d_textstyle_reset_shadows'; -procedure sk4d_textstyle_set_background_color; external LibraryName name 'sk4d_textstyle_set_background_color'; -procedure sk4d_textstyle_set_color; external LibraryName name 'sk4d_textstyle_set_color'; -procedure sk4d_textstyle_set_decoration_color; external LibraryName name 'sk4d_textstyle_set_decoration_color'; -procedure sk4d_textstyle_set_decoration_style; external LibraryName name 'sk4d_textstyle_set_decoration_style'; -procedure sk4d_textstyle_set_decoration_thickness; external LibraryName name 'sk4d_textstyle_set_decoration_thickness'; -procedure sk4d_textstyle_set_decorations; external LibraryName name 'sk4d_textstyle_set_decorations'; -procedure sk4d_textstyle_set_font_families; external LibraryName name 'sk4d_textstyle_set_font_families'; -procedure sk4d_textstyle_set_font_size; external LibraryName name 'sk4d_textstyle_set_font_size'; -procedure sk4d_textstyle_set_font_style; external LibraryName name 'sk4d_textstyle_set_font_style'; -procedure sk4d_textstyle_set_foreground_color; external LibraryName name 'sk4d_textstyle_set_foreground_color'; -procedure sk4d_textstyle_set_half_leading; external LibraryName name 'sk4d_textstyle_set_half_leading'; -procedure sk4d_textstyle_set_height_multiplier; external LibraryName name 'sk4d_textstyle_set_height_multiplier'; -procedure sk4d_textstyle_set_letter_spacing; external LibraryName name 'sk4d_textstyle_set_letter_spacing'; -procedure sk4d_textstyle_set_locale; external LibraryName name 'sk4d_textstyle_set_locale'; -procedure sk4d_textstyle_set_word_spacing; external LibraryName name 'sk4d_textstyle_set_word_spacing'; -{$ENDIF} - - -{ modules/skparagraph/include/sk4d_typefacefontprovider.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_typefacefontprovider_create := GetProcAddress(LibraryHandle, PChar('sk4d_typefacefontprovider_create')); - sk4d_typefacefontprovider_register_typeface := GetProcAddress(LibraryHandle, PChar('sk4d_typefacefontprovider_register_typeface')); - sk4d_typefacefontprovider_register_typeface2 := GetProcAddress(LibraryHandle, PChar('sk4d_typefacefontprovider_register_typeface2')); -{$ELSE} -function sk4d_typefacefontprovider_create; external LibraryName name 'sk4d_typefacefontprovider_create'; -procedure sk4d_typefacefontprovider_register_typeface; external LibraryName name 'sk4d_typefacefontprovider_register_typeface'; -procedure sk4d_typefacefontprovider_register_typeface2; external LibraryName name 'sk4d_typefacefontprovider_register_typeface2'; -{$ENDIF} - - -{ modules/skresources/include/sk4d_resources.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_resourceproviderbaseclass_create := GetProcAddress(LibraryHandle, PChar('sk4d_resourceproviderbaseclass_create')); - sk4d_resourceproviderbaseclass_set_procs := GetProcAddress(LibraryHandle, PChar('sk4d_resourceproviderbaseclass_set_procs')); -{$ELSE} -function sk4d_resourceproviderbaseclass_create; external LibraryName name 'sk4d_resourceproviderbaseclass_create'; -procedure sk4d_resourceproviderbaseclass_set_procs; external LibraryName name 'sk4d_resourceproviderbaseclass_set_procs'; -{$ENDIF} - - -{ modules/skshaper/include/sk4d_shaper.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_shaper_create := GetProcAddress(LibraryHandle, PChar('sk4d_shaper_create')); - sk4d_shaper_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_shaper_destroy')); - sk4d_shaper_shape := GetProcAddress(LibraryHandle, PChar('sk4d_shaper_shape')); -{$ELSE} -function sk4d_shaper_create; external LibraryName name 'sk4d_shaper_create'; -procedure sk4d_shaper_destroy; external LibraryName name 'sk4d_shaper_destroy'; -function sk4d_shaper_shape; external LibraryName name 'sk4d_shaper_shape'; -{$ENDIF} - - -{ modules/skunicode/include/sk4d_unicode.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_unicode_create := GetProcAddress(LibraryHandle, PChar('sk4d_unicode_create')); - sk4d_unicode_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_unicode_destroy')); - sk4d_unicode_for_each_bidi_region := GetProcAddress(LibraryHandle, PChar('sk4d_unicode_for_each_bidi_region')); - sk4d_unicode_for_each_break := GetProcAddress(LibraryHandle, PChar('sk4d_unicode_for_each_break')); - sk4d_unicode_for_each_codepoint := GetProcAddress(LibraryHandle, PChar('sk4d_unicode_for_each_codepoint')); - sk4d_unicodebreakiterator_create := GetProcAddress(LibraryHandle, PChar('sk4d_unicodebreakiterator_create')); - sk4d_unicodebreakiterator_create2 := GetProcAddress(LibraryHandle, PChar('sk4d_unicodebreakiterator_create2')); - sk4d_unicodebreakiterator_destroy := GetProcAddress(LibraryHandle, PChar('sk4d_unicodebreakiterator_destroy')); - sk4d_unicodebreakiterator_next := GetProcAddress(LibraryHandle, PChar('sk4d_unicodebreakiterator_next')); -{$ELSE} -function sk4d_unicode_create; external LibraryName name 'sk4d_unicode_create'; -procedure sk4d_unicode_destroy; external LibraryName name 'sk4d_unicode_destroy'; -procedure sk4d_unicode_for_each_bidi_region; external LibraryName name 'sk4d_unicode_for_each_bidi_region'; -procedure sk4d_unicode_for_each_break; external LibraryName name 'sk4d_unicode_for_each_break'; -procedure sk4d_unicode_for_each_codepoint; external LibraryName name 'sk4d_unicode_for_each_codepoint'; -function sk4d_unicodebreakiterator_create; external LibraryName name 'sk4d_unicodebreakiterator_create'; -function sk4d_unicodebreakiterator_create2; external LibraryName name 'sk4d_unicodebreakiterator_create2'; -procedure sk4d_unicodebreakiterator_destroy; external LibraryName name 'sk4d_unicodebreakiterator_destroy'; -function sk4d_unicodebreakiterator_next; external LibraryName name 'sk4d_unicodebreakiterator_next'; -{$ENDIF} - - -{ modules/svg/include/sk4d_svgdom.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_svgdom_find_node_by_id := GetProcAddress(LibraryHandle, PChar('sk4d_svgdom_find_node_by_id')); - sk4d_svgdom_get_root := GetProcAddress(LibraryHandle, PChar('sk4d_svgdom_get_root')); - sk4d_svgdom_make_from_file := GetProcAddress(LibraryHandle, PChar('sk4d_svgdom_make_from_file')); - sk4d_svgdom_make_from_stream := GetProcAddress(LibraryHandle, PChar('sk4d_svgdom_make_from_stream')); - sk4d_svgdom_render := GetProcAddress(LibraryHandle, PChar('sk4d_svgdom_render')); - sk4d_svgdom_set_container_size := GetProcAddress(LibraryHandle, PChar('sk4d_svgdom_set_container_size')); -{$ELSE} -function sk4d_svgdom_find_node_by_id; external LibraryName name 'sk4d_svgdom_find_node_by_id'; -function sk4d_svgdom_get_root; external LibraryName name 'sk4d_svgdom_get_root'; -function sk4d_svgdom_make_from_file; external LibraryName name 'sk4d_svgdom_make_from_file'; -function sk4d_svgdom_make_from_stream; external LibraryName name 'sk4d_svgdom_make_from_stream'; -procedure sk4d_svgdom_render; external LibraryName name 'sk4d_svgdom_render'; -procedure sk4d_svgdom_set_container_size; external LibraryName name 'sk4d_svgdom_set_container_size'; -{$ENDIF} - - -{ modules/svg/include/sk4d_svgnode.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_svgnode_set_attribute := GetProcAddress(LibraryHandle, PChar('sk4d_svgnode_set_attribute')); -{$ELSE} -function sk4d_svgnode_set_attribute; external LibraryName name 'sk4d_svgnode_set_attribute'; -{$ENDIF} - - -{ modules/svg/include/sk4d_svgsvg.h } - -{$IFNDEF SK_STATIC_LIBRARY} - sk4d_svgsvg_get_height := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_get_height')); - sk4d_svgsvg_get_intrinsic_size := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_get_intrinsic_size')); - sk4d_svgsvg_get_preserve_aspect_ratio := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_get_preserve_aspect_ratio')); - sk4d_svgsvg_get_view_box := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_get_view_box')); - sk4d_svgsvg_get_width := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_get_width')); - sk4d_svgsvg_get_x := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_get_x')); - sk4d_svgsvg_get_y := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_get_y')); - sk4d_svgsvg_set_height := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_set_height')); - sk4d_svgsvg_set_preserve_aspect_ratio := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_set_preserve_aspect_ratio')); - sk4d_svgsvg_set_view_box := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_set_view_box')); - sk4d_svgsvg_set_width := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_set_width')); - sk4d_svgsvg_set_x := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_set_x')); - sk4d_svgsvg_set_y := GetProcAddress(LibraryHandle, PChar('sk4d_svgsvg_set_y')); -{$ELSE} -procedure sk4d_svgsvg_get_height; external LibraryName name 'sk4d_svgsvg_get_height'; -procedure sk4d_svgsvg_get_intrinsic_size; external LibraryName name 'sk4d_svgsvg_get_intrinsic_size'; -procedure sk4d_svgsvg_get_preserve_aspect_ratio; external LibraryName name 'sk4d_svgsvg_get_preserve_aspect_ratio'; -function sk4d_svgsvg_get_view_box; external LibraryName name 'sk4d_svgsvg_get_view_box'; -procedure sk4d_svgsvg_get_width; external LibraryName name 'sk4d_svgsvg_get_width'; -procedure sk4d_svgsvg_get_x; external LibraryName name 'sk4d_svgsvg_get_x'; -procedure sk4d_svgsvg_get_y; external LibraryName name 'sk4d_svgsvg_get_y'; -procedure sk4d_svgsvg_set_height; external LibraryName name 'sk4d_svgsvg_set_height'; -procedure sk4d_svgsvg_set_preserve_aspect_ratio; external LibraryName name 'sk4d_svgsvg_set_preserve_aspect_ratio'; -procedure sk4d_svgsvg_set_view_box; external LibraryName name 'sk4d_svgsvg_set_view_box'; -procedure sk4d_svgsvg_set_width; external LibraryName name 'sk4d_svgsvg_set_width'; -procedure sk4d_svgsvg_set_x; external LibraryName name 'sk4d_svgsvg_set_x'; -procedure sk4d_svgsvg_set_y; external LibraryName name 'sk4d_svgsvg_set_y'; -{$ENDIF} - - -{$IFNDEF SK_STATIC_LIBRARY} -end; -{$ELSE} -procedure SkInitialize; -begin -end; -{$ENDIF} - -{$IFNDEF SK_STATIC_LIBRARY} -procedure SkFinalize; -begin - if AtomicDecrement(InitCount) <> 0 then - Exit; - FreeLibrary(LibraryHandle); -end; -{$ELSE} -procedure SkFinalize; -begin -end; -{$ENDIF} - -{$IFDEF SK_STATIC_LIBRARY} - {$IF DEFINED(IOS) and NOT DEFINED(IOSSIMULATOR)} - procedure libcpp; external '/usr/lib/libc++.dylib'; - procedure libcompiler_rt; external '/usr/lib/clang/lib/darwin/libclang_rt.ios.a'; - {$ENDIF} -{$ENDIF} - -end. diff --git a/skia4delphi/Source/Skia.pas b/skia4delphi/Source/Skia.pas deleted file mode 100644 index 2f55ad4..0000000 --- a/skia4delphi/Source/Skia.pas +++ /dev/null @@ -1,13494 +0,0 @@ -{************************************************************************} -{ } -{ Skia4Delphi } -{ } -{ Copyright (c) 2011-2022 Google LLC. } -{ Copyright (c) 2021-2022 Skia4Delphi Project. } -{ } -{ Use of this source code is governed by a BSD-style license that can be } -{ found in the LICENSE file. } -{ } -{************************************************************************} -unit Skia; - -interface - -{$ALIGN ON} - -{$MINENUMSIZE 4} -{$SCOPEDENUMS ON} - -uses - { Delphi } - System.Classes, - System.DateUtils, - System.Math.Vectors, - System.SysUtils, - System.Types, - System.UITypes, - - { Skia } - Skia.API; - -const - SkVersion = '4.0.2'; - -type - TGrBackendAPI = (OpenGl, Vulkan, Metal); - TGrShaderCacheStrategy = (SkSL, BackendSource, BackendBinary); - TGrSurfaceOrigin = (TopLeft, BottomLeft); - TGrVkAllocFlag = (Noncoherent, Mappable, LazilyAllocated); - TSkAffinity = (Upstream, Downstream); - TSkAlphaType = (Unknown, Opaque, Premul, Unpremul); - TSkBlendMode = (Clear, Src, Dest, SrcOver, DestOver, SrcIn, DestIn, SrcOut, DestOut, SrcATop, DestATop, &Xor, Plus, Modulate, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion, Multiply, Hue, Saturation, Color, Luminosity); - TSkBlurStyle = (Normal, Solid, Outer, Inner); - TSkBreakType = (Words, Graphemes, Lines); - TSkClipOp = (Difference, Intersect); - TSkColorChannel = (R, G, B, A); - TSkColorType = (Unknown, Alpha8, RGB565, ARGB4444, RGBA8888, RGB888X, BGRA8888, RGBA1010102, BGRA1010102, RGB101010X, BGR101010X, Gray8, RGBAF16, RGBAF16Clamped, RGBAF32, RG88, AlphaF16, RGF16, Alpha16, RG1616, RGBA16161616, SRGBA8888, R8); - TSkContrastInvertStyle = (NoInvert, InvertBrightness, InvertLightness); - TSkDirection = (LeftToRight, RightToLeft); - TSkDrawPointsMode = (Points, Lines, Polygon); - TSkEncodedImageFormat = (BMP, GIF, ICO, JPEG, PNG, WBMP, WEBP, PKM, KTX, ASTC, DNG, HEIF, AVIF); - TSkFilterMode = (Nearest, Linear); - TSkFontEdging = (Alias, AntiAlias, SubpixelAntiAlias); - TSkFontHinting = (None, Slight, Normal, Full); - TSkFontMetricsFlag = (UnderlineThicknessIsValid, UnderlinePositionIsValid, StrikeoutThicknessIsValid, StrikeoutPositionIsValid, BoundsInvalid); - TSkFontSlant = (Upright, Italic, Oblique); - TSkFontWeight = (Invisible, Thin = 100, ExtraLight = 200, Light = 300, Normal = 400, Medium = 500, SemiBold = 600, Bold = 700, ExtraBold = 800, Black = 900, ExtraBlack = 1000); - TSkFontWidth = (UltraCondensed = 1, ExtraCondensed, Condensed, SemiCondensed, Normal, SemiExpanded, Expanded, ExtraExpanded, UltraExpanded); - TSkImageCachingHint = (Allow, Disallow); - TSkLatticeRectType = (Default, Transparent, FixedColor); - TSkMipmapMode = (None, Nearest, Linear); - TSkottieAnimationRenderFlag = (SkipTopLevelIsolation, DisableTopLevelClipping); - TSkPaintStyle = (Fill, Stroke, StrokeAndFill); - TSkParagraphVisitorFlag = (WhiteSpace); - TSkPathArcSize = (Small, Large); - TSkPathDirection = (CW, CCW); - TSkPathEffect1DStyle = (Translate, Rotate, Morph); - TSkPathEffectTrimMode = (Normal, Inverted); - TSkPathFillType = (Winding, EvenOdd, InverseWinding, InverseEvenOdd); - TSkPathMeasureMatrixFlag = (Position, Tangent); - TSkPathOp = (Difference, Intersect, Union, &Xor, ReverseDifference); - TSkPathVerb = (Move, Line, Quad, Conic, Cubic, Close); - TSkPixelGeometry = (Unknown, RGBHorizontal, BGRHorizontal, RGBVertical, BGRVertical); - TSkPlaceholderAlignment = (Baseline, AboveBaseline, BelowBaseline, Top, Bottom, Middle); - TSkRectHeightStyle = (Tight, Max, IncludeLineSpacingMiddle, IncludeLineSpacingTop, IncludeLineSpacingBottom, Strut); - TSkRectWidthStyle = (Tight, Max); - TSkRegionOp = (Difference, Intersect, Union, &Xor, ReverseDifference, Replace); - TSkRoundRectCorner = (UpperLeft, UpperRight, LowerRight, LowerLeft); - TSkRuntimeEffectChildType = (Shader, ColorFilter, Blender); - TSkRuntimeEffectUniformType = (Float, Float2, Float3, Float4, Float2x2, Float3x3, Float4x4, Int, Int2, Int3, Int4); - TSkSegmentMask = (Line, Quad, Conic, Cubic); - TSkSrcRectConstraint = (Close, Fast); - TSkStrokeCap = (Butt, Round, Square); - TSkStrokeJoin = (Miter, Round, Bevel); - TSkSurfacePropertiesFlag = (UseDeviceIndependentFonts, DynamicMSAA); - TSkSVGAspectAlign = (XMinYMin, XMidYMin, XMaxYMin, XMinYMid = 4, XMidYMid, XMaxYMid, XMinYMax = 8, XMidYMax, XMaxYMax, None = 16); - TSkSVGAspectScale = (Meet, Slice); - TSkSVGCanvasFlag = (ConvertTextToPaths, NoPrettyXML, RelativePathEncoding); - TSkSVGLengthUnit = (Unknown, Number, Percentage, EmUnit, ExUnit, Pixel, Centimeter, Millimeter, Inch, Point, Pica); - TSkTextAlign = (Left, Right, Center, Justify, Start, Terminate); - TSkTextBaseline = (Alphabetic, Ideographic); - TSkTextDecoration = (Underline, Overline, LineThrough); - TSkTextDecorationStyle = (Solid, Double, Dotted, Dashed, Wavy); - TSkTextDirection = (RightToLeft, LeftToRight); - TSkTextHeightBehavior = (DisableFirstAscent, DisableLastDescent); - TSkTileMode = (Clamp, &Repeat, Mirror, Decal); - TSkVertexMode = (Triangles, TriangleStrip, TriangleFan); - - TGrVkAllocFlags = set of TGrVkAllocFlag; - TSkFontMetricsFlags = set of TSkFontMetricsFlag; - TSkottieAnimationRenderFlags = set of TSkottieAnimationRenderFlag; - TSkParagraphVisitorFlags = set of TSkParagraphVisitorFlag; - TSkPathMeasureMatrixFlags = set of TSkPathMeasureMatrixFlag; - TSkSegmentMasks = set of TSkSegmentMask; - TSkSurfacePropertiesFlags = set of TSkSurfacePropertiesFlag; - TSkSVGCanvasFlags = set of TSkSVGCanvasFlag; - TSkTextDecorations = set of TSkTextDecoration; - TSkTextHeightBehaviors = set of TSkTextHeightBehavior; - - IGrGlInterface = interface; - IGrPersistentCache = interface; - IGrShaderErrorHandler = interface; - IGrVkExtensions = interface; - ISkColorSpace = interface; - ISkColorSpaceICCProfile = interface; - ISkFont = interface; - ISkImage = interface; - ISkImageFilter = interface; - ISkPaint = interface; - ISkParagraphStyle = interface; - ISkPath = interface; - ISkPathEffect = interface; - ISkPicture = interface; - ISkPixmap = interface; - ISkRegion = interface; - ISkResourceProvider = interface; - ISkRoundRect = interface; - ISkShader = interface; - ISkSurface = interface; - ISkSVGNode = interface; - ISkSVGSVG = interface; - ISkTextBlob = interface; - ISkTextStyle = interface; - ISkTraceMemoryDump = interface; - ISkTypeface = interface; - ISkTypefaceFontProvider = interface; - ISkVertices = interface; - - GrGlenum = Cardinal; - GrGluint = Cardinal; - GrMtlHandle = Pointer; - GrVkBool32 = Cardinal; - GrVkChromaLocation = Integer; - GrVkDevice = Pointer; - GrVkDeviceMemory = UInt64; - GrVkDeviceSize = UInt64; - GrVkFilter = Integer; - GrVkFormat = Integer; - GrVkFormatFeatureFlags = Cardinal; - GrVkImage = UInt64; - GrVkImageLayout = Integer; - GrVkImageUsageFlags = Cardinal; - GrVkInstance = Pointer; - GrVkPhysicalDevice = Pointer; - GrVkPhysicalDeviceFeatures = Pointer; - GrVkPhysicalDeviceFeatures2 = Pointer; - GrVkQueue = Pointer; - GrVkSamplerYcbcrModelConversion = Integer; - GrVkSharingMode = Integer; - GrVkVkImageTiling = Integer; - GrVkVkSamplerYcbcrRange = Integer; - - TSkOverdrawColor = array[0..5] of TAlphaColor; - TSkParticleUniformData = array[0..0] of Single; - TSkPatchColors = array[0..3] of TAlphaColor; - TSkPatchCubics = array[0..11] of TPointF; - TSkPatchTexCoords = array[0..3] of TPointF; - TSkPathPoints = array[0..3] of TPointF; - TSkRoundRectRadii = array[TSkRoundRectCorner] of Single; - TSkTableFilter = array[0..255] of Byte; - - {$POINTERMATH ON} - PCardinalArray = ^Cardinal; - PPointFArray = ^TPointF; - PSingleArray = ^Single; - PWordArray = ^Word; - {$POINTERMATH OFF} - - TGrGlGetProc = reference to function (const AName: string): Pointer; - TSkFontPathProc = reference to procedure (const APathOrNil: ISkPath; const AMatrix: TMatrix); - TSkImageRasterReleaseProc = reference to procedure (const APixels: Pointer); - TSkImageTextureReleaseProc = reference to procedure (); - TSkUnicodeBidiRegionProc = reference to procedure (const AStart, AEnd: Integer; const ALevel: Byte); - TGrVkGetProc = reference to function (const AName: string; const AInstance: GrVkInstance; const ADevice: GrVkDevice): Pointer; - TSkSurfaceRasterReleaseProc = reference to procedure (const APixels: Pointer); - TSkUnicodeBreakProc = reference to procedure (const APosition, AStatus: Integer); - TSkUnicodeCodepointProc = reference to procedure (const AUnichar, AStart, AEnd: Integer); - - ESkArgumentException = class(Exception); - ESkException = class(Exception); - - { TGrContextOptions } - - TGrContextOptions = record - BufferMapThreshold: Integer; - DoManualMipmapping: Boolean; - AllowPathMaskCaching: Boolean; - GlyphCacheTextureMaximumBytes: NativeUInt; - AvoidStencilBuffers: Boolean; - RuntimeProgramCacheSize: Integer; - PersistentCache: IGrPersistentCache; - ShaderCacheStrategy: TGrShaderCacheStrategy; - ShaderErrorHandler: IGrShaderErrorHandler; - end; - - { TGrGlFramebufferInfo } - - TGrGlFramebufferInfo = record - FBOID: GrGluint; - Format: GrGlenum; - end; - - { TGrGlTextureInfo } - - TGrGlTextureInfo = record - Target: GrGlenum; - ID: GrGluint; - Format: GrGlenum; - end; - - { TGrMtlBackendContext } - - TGrMtlBackendContext = record - Device: GrMtlHandle; - Queue: GrMtlHandle; - BinaryArchive: GrMtlHandle; - end; - - { TGrMtlTextureInfo } - - TGrMtlTextureInfo = record - Texture: GrMtlHandle; - end; - - { TGrVkAlloc } - - TGrVkAlloc = record - DeviceMemory: GrVkDeviceMemory; - Offset: GrVkDeviceSize; - Size: GrVkDeviceSize; - Flags: TGrVkAllocFlags; - Memory: THandle; - end; - - { TGrVkBackendContext } - - TGrVkBackendContext = record - Instance: GrVkInstance; - PhysicalDevice: GrVkPhysicalDevice; - Device: GrVkDevice; - Queue: GrVkQueue; - GraphicsQueueIndex: Cardinal; - MaxVersion: Cardinal; - Extensions: IGrVkExtensions; - PhysicalDeviceFeatures: GrVkPhysicalDeviceFeatures; - PhysicalDeviceFeatures2: GrVkPhysicalDeviceFeatures2; - GetProc: TGrVkGetProc; - ProtectedContext: Boolean; - end; - - { TGrVkYcbcrConversionInfo } - - TGrVkYcbcrConversionInfo = record - Format: GrVkFormat; - FExternalFormat: UInt64; - YcbcrModel: GrVkSamplerYcbcrModelConversion; - YcbcrRange: GrVkVkSamplerYcbcrRange; - XChromaOffset: GrVkChromaLocation; - YChromaOffset: GrVkChromaLocation; - ChromaFilter: GrVkFilter; - ForceExplicitReconstruction: GrVkBool32; - FormatFeatures: GrVkFormatFeatureFlags; - end; - - { TGrVkImageInfo } - - TGrVkImageInfo = record - Image: GrVkImage; - Alloc: TGrVkAlloc; - ImageTiling: GrVkVkImageTiling; - ImageLayout: GrVkImageLayout; - Format: GrVkFormat; - ImageUsageFlags: GrVkImageUsageFlags; - SampleCount: Cardinal; - LevelCount: Cardinal; - CurrentQueueFamily: Cardinal; - ProtectedImage: Boolean; - YcbcrConversionInfo: TGrVkYcbcrConversionInfo; - SharingMode: GrVkSharingMode; - end; - - { TSkColorMatrix } - - TSkColorMatrix = record - constructor Create(const AM11, AM12, AM13, AM14, AM15, AM21, AM22, AM23, AM24, AM25, AM31, AM32, AM33, AM34, AM35, AM41, AM42, AM43, AM44, AM45: Single); - class function CreateSaturation(const ASaturation: Single): TSkColorMatrix; static; - class function CreateScale(const AScaleR, AScaleG, AScaleB: Single; const AScaleA: Single = 1): TSkColorMatrix; static; - class function Identity: TSkColorMatrix; static; inline; - class operator Equal(const AColorMatrix1, AColorMatrix2: TSkColorMatrix): Boolean; - class operator NotEqual(const AColorMatrix1, AColorMatrix2: TSkColorMatrix): Boolean; - class operator Multiply(const AColorMatrix1, AColorMatrix2: TSkColorMatrix): TSkColorMatrix; - case Integer of - 0: (M11, M12, M13, M14, M15, - M21, M22, M23, M24, M25, - M31, M32, M33, M34, M35, - M41, M42, M43, M44, M45: Single); - 1: (Vector: array[0..3] of array[0..4] of Single); - end; - - { TSkColorSpaceXyz } - - TSkColorSpaceXyz = record - public const - FixedToFloat = 1.52587890625e-5; - public - constructor Create(const AM11, AM12, AM13, AM21, AM22, AM23, AM31, AM32, AM33: Single); - function Adjoint: TSkColorSpaceXyz; - function Determinant: Single; - function Inverse: TSkColorSpaceXyz; - class function AdobeRGB: TSkColorSpaceXyz; static; inline; - class function DisplayP3: TSkColorSpaceXyz; static; inline; - class function Identity: TSkColorSpaceXyz; static; inline; - class function Rec2020: TSkColorSpaceXyz; static; inline; - class function SRGB: TSkColorSpaceXyz; static; inline; - class operator Equal(const AColorSpaceXyz1, AColorSpaceXyz2: TSkColorSpaceXyz): Boolean; - class operator NotEqual(const AColorSpaceXyz1, AColorSpaceXyz2: TSkColorSpaceXyz): Boolean; - class operator Multiply(const AColorSpaceXyz1, AColorSpaceXyz2: TSkColorSpaceXyz): TSkColorSpaceXyz; - case Integer of - 0: (M11, M12, M13, - M21, M22, M23, - M31, M32, M33: Single); - 1: (Vector: array[0..2] of array[0..2] of Single); - end; - - { TSkColorSpacePrimaries } - - TSkColorSpacePrimaries = record - RX: Single; - RY: Single; - GX: Single; - GY: Single; - BX: Single; - BY: Single; - WX: Single; - WY: Single; - constructor Create(const ARX, ARY, AGX, AGY, ABX, ABY, AWX, AWY: Single); - class operator Equal(const AColorSpacePrimaries1, AColorSpacePrimaries2: TSkColorSpacePrimaries): Boolean; - class operator NotEqual(const AColorSpacePrimaries1, AColorSpacePrimaries2: TSkColorSpacePrimaries): Boolean; - class operator Implicit(const AColorSpacePrimaries: TSkColorSpacePrimaries): TSkColorSpaceXyz; - end; - - { TSkColorSpaceTransferFunction } - - TSkColorSpaceTransferFunction = record - G: Single; - A: Single; - B: Single; - C: Single; - D: Single; - E: Single; - F: Single; - constructor Create(const AG, AA, AB, AC, AD, AE, AF: Single); - function Invert(out ATransferFunction: TSkColorSpaceTransferFunction): Boolean; - function Transform(const AX: Single): Single; - class function HLG: TSkColorSpaceTransferFunction; static; inline; - class function Linear: TSkColorSpaceTransferFunction; static; inline; - class function PQ: TSkColorSpaceTransferFunction; static; inline; - class function Rec2020: TSkColorSpaceTransferFunction; static; inline; - class function SRGB: TSkColorSpaceTransferFunction; static; inline; - class function TwoDotTwo: TSkColorSpaceTransferFunction; static; inline; - class operator Equal(const AColorSpaceTransferFunction1, AColorSpaceTransferFunction2: TSkColorSpaceTransferFunction): Boolean; - class operator NotEqual(const AColorSpaceTransferFunction1, AColorSpaceTransferFunction2: TSkColorSpaceTransferFunction): Boolean; - end; - - { TSkCubicResampler } - - TSkCubicResampler = record - B: Single; - C: Single; - constructor Create(const AB, AC: Single); - class function CatmullRom: TSkCubicResampler; static; inline; - class function Mitchell: TSkCubicResampler; static; inline; - class operator Equal(const ACubicResampler1, ACubicResampler2: TSkCubicResampler): Boolean; - class operator NotEqual(const ACubicResampler1, ACubicResampler2: TSkCubicResampler): Boolean; - end; - - { TSkFontMetrics } - - TSkFontMetrics = record - Flags: TSkFontMetricsFlags; - Top: Single; - Ascent: Single; - Descent: Single; - Bottom: Single; - Leading: Single; - AvgCharWidth: Single; - MaxCharWidth: Single; - XMin: Single; - XMax: Single; - XHeight: Single; - CapHeight: Single; - UnderlineThickness: Single; - UnderlinePosition: Single; - StrikeoutThickness: Single; - StrikeoutPosition: Single; - class operator Equal(const AFontMetrics1, AFontMetrics2: TSkFontMetrics): Boolean; - class operator NotEqual(const AFontMetrics1, AFontMetrics2: TSkFontMetrics): Boolean; - end; - - { TSkFontStyle } - - TSkFontStyle = record - Weight: Integer; - Width: Integer; - Slant: TSkFontSlant; - constructor Create(const AWeight, AWidth: Integer; const ASlant: TSkFontSlant); overload; - constructor Create(const AWeight: TSkFontWeight; const AWidth: TSkFontWidth; const ASlant: TSkFontSlant); overload; - class function Bold: TSkFontStyle; static; inline; - class function BoldItalic: TSkFontStyle; static; inline; - class function Italic: TSkFontStyle; static; inline; - class function Normal: TSkFontStyle; static; inline; - class operator Equal(const AFontStyle1, AFontStyle2: TSkFontStyle): Boolean; - class operator NotEqual(const AFontStyle1, AFontStyle2: TSkFontStyle): Boolean; - end; - - { TSkGraphics } - - TSkGraphics = record - class procedure AllowJIT; static; - class procedure DumpMemoryStatistics(const ATraceMemoryDump: ISkTraceMemoryDump); static; - class function GetFontCacheCountLimit: Integer; static; - class function GetFontCacheCountUsed: Integer; static; - class function GetFontCacheLimit: NativeUInt; static; - class function GetFontCacheUsed: NativeUInt; static; - class function GetResourceCacheSingleAllocationByteLimit: NativeUInt; static; - class function GetResourceCacheTotalByteLimit: NativeUInt; static; - class function GetResourceCacheTotalBytesUsed: NativeUInt; static; - class procedure Init; static; - class procedure PurgeAllCaches; static; - class procedure PurgeFontCache; static; - class procedure PurgeResourceCache; static; - class procedure SetFontCacheCountLimit(const AValue: Integer); static; - class procedure SetFontCacheLimit(const AValue: NativeUInt); static; - class procedure SetResourceCacheSingleAllocationByteLimit(const AValue: NativeUInt); static; - class procedure SetResourceCacheTotalByteLimit(const AValue: NativeUInt); static; - class property FontCacheCountLimit: Integer read GetFontCacheCountLimit write SetFontCacheCountLimit; - class property FontCacheCountUsed: Integer read GetFontCacheCountUsed; - class property FontCacheLimit: NativeUInt read GetFontCacheLimit write SetFontCacheLimit; - class property FontCacheUsed: NativeUInt read GetFontCacheUsed; - class property ResourceCacheSingleAllocationByteLimit: NativeUInt read GetResourceCacheSingleAllocationByteLimit write SetResourceCacheSingleAllocationByteLimit; - class property ResourceCacheTotalByteLimit: NativeUInt read GetResourceCacheTotalByteLimit write SetResourceCacheTotalByteLimit; - class property ResourceCacheTotalBytesUsed: NativeUInt read GetResourceCacheTotalBytesUsed; - end; - - { TSkHighContrastConfig } - - TSkHighContrastConfig = record - Grayscale: Boolean; - InvertStyle: TSkContrastInvertStyle; - Contrast: Single; - constructor Create(const AGrayscale: Boolean; const AInvertStyle: TSkContrastInvertStyle; const AContrast: Single); - class operator Equal(const AHighContrastConfig1, AHighContrastConfig2: TSkHighContrastConfig): Boolean; - class operator NotEqual(const AHighContrastConfig1, AHighContrastConfig2: TSkHighContrastConfig): Boolean; - end; - - { TSkImageInfo } - - TSkImageInfo = record - Width: Integer; - Height: Integer; - ColorType: TSkColorType; - AlphaType: TSkAlphaType; - ColorSpace: ISkColorSpace; - constructor Create(const AWidth, AHeight: Integer); overload; - constructor Create(const AWidth, AHeight: Integer; const AColorType: TSkColorType; const AAlphaType: TSkAlphaType = TSkAlphaType.Premul; AColorSpace: ISkColorSpace = nil); overload; - function ByteSize(const ARowBytes: NativeUInt): NativeUInt; - function BytesPerPixel: Integer; inline; - function IsEmpty: Boolean; - function IsOpaque: Boolean; - function IsValid: Boolean; - function IsValidRowBytes(const ARowBytes: NativeUInt): Boolean; - function MakeAlphaType(const AAlphaType: TSkAlphaType): TSkImageInfo; - function MakeColorSpace(AColorSpace: ISkColorSpace): TSkImageInfo; - function MakeColorType(const AColorType: TSkColorType): TSkImageInfo; - function MakeDimensions(const AWidth, AHeight: Integer): TSkImageInfo; - function MinByteSize: NativeUInt; - function MinRowBytes: NativeUInt; - function ShiftPerPixel: Integer; inline; - class operator Equal(const AImageInfo1, AImageInfo2: TSkImageInfo): Boolean; - class operator NotEqual(const AImageInfo1, AImageInfo2: TSkImageInfo): Boolean; - end; - - { TSkImageEncoder } - - TSkImageEncoder = record - class function Encode(const ASrc: ISkPixmap; const AEncodedImageFormat: TSkEncodedImageFormat = TSkEncodedImageFormat.PNG; const AQuality: Integer = 80): TBytes; overload; static; - class function Encode(const ASrcImageInfo: TSkImageInfo; const ASrcPixels: Pointer; const ASrcRowBytes: NativeUInt; const AEncodedImageFormat: TSkEncodedImageFormat = TSkEncodedImageFormat.PNG; const AQuality: Integer = 80): TBytes; overload; static; inline; - class function EncodeToFile(const AFileName: string; const ASrc: ISkPixmap; const AQuality: Integer = 80): Boolean; overload; static; - class function EncodeToFile(const AFileName: string; const ASrc: ISkPixmap; const AEncodedImageFormat: TSkEncodedImageFormat; const AQuality: Integer = 80): Boolean; overload; static; - class function EncodeToFile(const AFileName: string; const ASrcImageInfo: TSkImageInfo; const ASrcPixels: Pointer; const ASrcRowBytes: NativeUInt; const AQuality: Integer = 80): Boolean; overload; static; - class function EncodeToFile(const AFileName: string; const ASrcImageInfo: TSkImageInfo; const ASrcPixels: Pointer; const ASrcRowBytes: NativeUInt; const AEncodedImageFormat: TSkEncodedImageFormat; const AQuality: Integer = 80): Boolean; overload; static; inline; - class function EncodeToStream(const AStream: TStream; const ASrc: ISkPixmap; const AEncodedImageFormat: TSkEncodedImageFormat = TSkEncodedImageFormat.PNG; const AQuality: Integer = 80): Boolean; overload; static; - class function EncodeToStream(const AStream: TStream; const ASrcImageInfo: TSkImageInfo; const ASrcPixels: Pointer; const ASrcRowBytes: NativeUInt; const AEncodedImageFormat: TSkEncodedImageFormat = TSkEncodedImageFormat.PNG; const AQuality: Integer = 80): Boolean; overload; static; inline; - end; - - { TSkLattice } - - TSkLattice = record - private - FXDivs: TArray; - FYDivs: TArray; - FRectTypes: TArray; - FColors: TArray; - FUseBounds: Boolean; - FBounds: TRect; - public - constructor Create(const AXDivs, AYDivs: TArray; const ARectTypes: TArray = nil; const AColors: TArray = nil); overload; - constructor Create(const AXDivs, AYDivs: TArray; ABounds: TRect; const ARectTypes: TArray = nil; const AColors: TArray = nil); overload; - property XDivs: TArray read FXDivs; - property YDivs: TArray read FYDivs; - property RectTypes: TArray read FRectTypes; - property Colors: TArray read FColors; - property UseBounds: Boolean read FUseBounds; - property Bounds: TRect read FBounds; - end; - - { TSkMetrics } - - TSkMetrics = record - StartIndex: NativeUInt; - EndIndex: NativeUInt; - EndExcludingWhitespaces: NativeUInt; - EndIncludingNewline: NativeUInt; - IsHardBreak: Boolean; - Ascent: Double; - Descent: Double; - Height: Double; - Width: Double; - Left: Double; - Baseline: Double; - LineNumber: NativeUInt; - class operator Equal(const AMetrics1, AMetrics2: TSkMetrics): Boolean; - class operator NotEqual(const AMetrics1, AMetrics2: TSkMetrics): Boolean; - end; - - { TSkParagraphVisitorInfo } - - TSkParagraphVisitorInfo = record - Font: ISkFont; - Origin: TPointF; - AdvanceX: Single; - Count: Integer; - Glyphs: PWordArray; - Positions: PPointFArray; - Utf8Starts: PCardinalArray; - Flags: TSkParagraphVisitorFlags; - end; - - { TSkParticleUniform } - - TSkParticleUniform = record - Columns: Integer; - Rows: Integer; - Slot: Integer; - end; - - { TSkPathIteratorElem } - - TSkPathIteratorElem = record - Verb: TSkPathVerb; - Points: TSkPathPoints; - ConicWeight: Single; - end; - - { TSkPDFMetadata } - - TSkPDFMetadata = record - Title: string; - Author: string; - Subject: string; - Keywords: string; - Creator: string; - Producer: string; - Creation: TDateTime; - Modified: TDateTime; - RasterDPI: Single; - PDFA: Boolean; - EncodingQuality: Integer; - constructor Create(const ATitle, AAuthor, ASubject, AKeywords, ACreator: string; const AProducer: string = 'Skia/PDF'; const ARasterDPI: Single = 72; const APDFA: Boolean = False; const AEncodingQuality: Integer = 101); overload; - constructor Create(const ATitle, AAuthor, ASubject, AKeywords, ACreator: string; const ACreation, AModified: TDateTime; const AProducer: string = 'Skia/PDF'; const ARasterDPI: Single = 72; const APDFA: Boolean = False; const AEncodingQuality: Integer = 101); overload; - class operator Equal(const APDFMetadata1, APDFMetadata2: TSkPDFMetadata): Boolean; - class operator NotEqual(const APDFMetadata1, APDFMetadata2: TSkPDFMetadata): Boolean; - end; - - { TSkPlaceholderStyle } - - TSkPlaceholderStyle = record - Width: Single; - Height: Single; - Alignment: TSkPlaceholderAlignment; - Baseline: TSkTextBaseline; - BaselineOffset: Single; - constructor Create(const AWidth, AHeight: Single; const AAlignment: TSkPlaceholderAlignment; const ABaseline: TSkTextBaseline; const ABaselineOffset: Single); - class operator Equal(const APlaceholderStyle1, APlaceholderStyle2: TSkPlaceholderStyle): Boolean; - class operator NotEqual(const APlaceholderStyle1, APlaceholderStyle2: TSkPlaceholderStyle): Boolean; - end; - - { TSkPositionAffinity } - - TSkPositionAffinity = record - Position: Integer; - Affinity: TSkAffinity; - class operator Equal(const APositionAffinity1, APositionAffinity2: TSkPositionAffinity): Boolean; - class operator NotEqual(const APositionAffinity1, APositionAffinity2: TSkPositionAffinity): Boolean; - end; - - { TSkRotationScaleMatrix } - - TSkRotationScaleMatrix = record - SCosinus: Single; - SSinus: Single; - TranslateX: Single; - TranslateY: Single; - constructor Create(const ASCosinus, ASSinus, ATranslateX, ATranslateY: Single); - class function CreateDegrees(const AScale, ADegrees, ATranslateX, ATranslateY, AAnchorX, AAnchorY: Single): TSkRotationScaleMatrix; static; - class function CreateRadians(const AScale, ARadians, ATranslateX, ATranslateY, AAnchorX, AAnchorY: Single): TSkRotationScaleMatrix; static; - class function Identity: TSkRotationScaleMatrix; static; inline; - class operator Equal(const ARotationScaleMatrix1, ARotationScaleMatrix2: TSkRotationScaleMatrix): Boolean; - class operator NotEqual(const ARotationScaleMatrix1, ARotationScaleMatrix2: TSkRotationScaleMatrix): Boolean; - class operator Implicit(const ARotationScaleMatrix: TSkRotationScaleMatrix): TMatrix; - end; - - {$ALIGN 4} - - { TSkRuntimeEffectFloat2 } - - TSkRuntimeEffectFloat2 = packed record - constructor Create(const AV1, AV2: Single); - case Integer of - 0: (V1, V2: Single); - 1: (Values: array[0..1] of Single); - end; - - { TSkRuntimeEffectFloat3 } - - TSkRuntimeEffectFloat3 = packed record - constructor Create(const AV1, AV2, AV3: Single); - case Integer of - 0: (V1, V2, V3: Single); - 1: (Values: array[0..2] of Single); - end; - - { TSkRuntimeEffectFloat4 } - - TSkRuntimeEffectFloat4 = packed record - constructor Create(const AV1, AV2, AV3, AV4: Single); - case Integer of - 0: (V1, V2, V3, V4: Single); - 1: (Values: array[0..3] of Single); - end; - - { TSkRuntimeEffectFloat2x2 } - - TSkRuntimeEffectFloat2x2 = packed record - constructor Create(const AV11, AV12, AV21, AV22: Single); - case Integer of - 0: (V11, V12, - V21, V22: Single); - 1: (Values: array[0..3] of Single); - end; - - { TSkRuntimeEffectFloat3x3 } - - TSkRuntimeEffectFloat3x3 = packed record - constructor Create(const AV11, AV12, AV13, AV21, AV22, AV23, AV31, AV32, AV33: Single); - case Integer of - 0: (V11, V12, V13, - V21, V22, V23, - V31, V32, V33: Single); - 1: (Values: array[0..8] of Single); - end; - - { TSkRuntimeEffectFloat4x4 } - - TSkRuntimeEffectFloat4x4 = packed record - constructor Create(const AV11, AV12, AV13, AV14, AV21, AV22, AV23, AV24, AV31, AV32, AV33, AV34, AV41, AV42, AV43, AV44: Single); - case Integer of - 0: (V11, V12, V13, V14, - V21, V22, V23, V24, - V31, V32, V33, V34, - V41, V42, V43, V44: Single); - 1: (Values: array[0..15] of Single); - end; - - { TSkRuntimeEffectInt2 } - - TSkRuntimeEffectInt2 = packed record - constructor Create(const AV1, AV2: Integer); - case Integer of - 0: (V1, V2: Integer); - 1: (Values: array[0..1] of Integer); - end; - - { TSkRuntimeEffectInt3 } - - TSkRuntimeEffectInt3 = packed record - constructor Create(const AV1, AV2, AV3: Integer); - case Integer of - 0: (V1, V2, V3: Integer); - 1: (Values: array[0..2] of Integer); - end; - - { TSkRuntimeEffectInt4 } - - TSkRuntimeEffectInt4 = packed record - constructor Create(const AV1, AV2, AV3, AV4: Integer); - case Integer of - 0: (V1, V2, V3, V4: Integer); - 1: (Values: array[0..3] of Integer); - end; - - {$ALIGN ON} - - { TSkSamplingOptions } - - TSkSamplingOptions = record - strict private - FMaxAnisotropic: Integer; - FUseCubic: Boolean; - FCubic: TSkCubicResampler; - FFilter: TSkFilterMode; - FMipmap: TSkMipmapMode; - public - constructor Create(const ACubic: TSkCubicResampler); overload; - constructor Create(const AFilter: TSkFilterMode; const AMipmap: TSkMipmapMode); overload; - constructor Create(const AMaxAnisotropic: Integer); overload; - property MaxAnisotropic: Integer read FMaxAnisotropic; - property UseCubic: Boolean read FUseCubic; - property Cubic: TSkCubicResampler read FCubic; - property Filter: TSkFilterMode read FFilter; - property Mipmap: TSkMipmapMode read FMipmap; - class function High: TSkSamplingOptions; static; inline; - class function Low: TSkSamplingOptions; static; inline; - class function Medium: TSkSamplingOptions; static; inline; - class operator Equal(const ASamplingOptions1, ASamplingOptions2: TSkSamplingOptions): Boolean; - class operator NotEqual(const ASamplingOptions1, ASamplingOptions2: TSkSamplingOptions): Boolean; - end; - - { TSkSurfaceProperties } - - TSkSurfaceProperties = record - Flags: TSkSurfacePropertiesFlags; - PixelGeometry: TSkPixelGeometry; - constructor Create(const AFlags: TSkSurfacePropertiesFlags; const APixelGeometry: TSkPixelGeometry); - class operator Equal(const ASurfaceProperties1, ASurfaceProperties2: TSkSurfaceProperties): Boolean; - class operator NotEqual(const ASurfaceProperties1, ASurfaceProperties2: TSkSurfaceProperties): Boolean; - end; - - { TSkSVGLength } - - TSkSVGLength = record - Value: Single; - &Unit: TSkSVGLengthUnit; - constructor Create(const AValue: Single; const AUnit: TSkSVGLengthUnit = TSkSVGLengthUnit.Number); - class operator Equal(const ASVGLength1, ASVGLength2: TSkSVGLength): Boolean; - class operator NotEqual(const ASVGLength1, ASVGLength2: TSkSVGLength): Boolean; - end; - - { TSkSVGPreserveAspectRatio } - - TSkSVGPreserveAspectRatio = record - Align: TSkSVGAspectAlign; - Scale: TSkSVGAspectScale; - constructor Create(const AAlign: TSkSVGAspectAlign; const AScale: TSkSVGAspectScale); - class operator Equal(const ASVGPreserveAspectRatio1, ASVGPreserveAspectRatio2: TSkSVGPreserveAspectRatio): Boolean; - class operator NotEqual(const ASVGPreserveAspectRatio1, ASVGPreserveAspectRatio2: TSkSVGPreserveAspectRatio): Boolean; - end; - - { TSkTextBox } - - TSkTextBox = record - Rect: TRectF; - Direction: TSkTextDirection; - class operator Equal(const ATextBox1, ATextBox2: TSkTextBox): Boolean; - class operator NotEqual(const ATextBox1, ATextBox2: TSkTextBox): Boolean; - end; - - { TSkTextShadow } - - TSkTextShadow = record - Color: TAlphaColor; - Offset: TPointF; - BlurRadius: Double; - constructor Create(const AColor: TAlphaColor; const AOffset: TPointF; const ABlurRadius: Double); - class operator Equal(const ATextShadow1, ATextShadow2: TSkTextShadow): Boolean; - class operator NotEqual(const ATextShadow1, ATextShadow2: TSkTextShadow): Boolean; - end; - - { TSkUnicodeBreakIteratorElem } - - TSkUnicodeBreakIteratorElem = record - Position: Integer; - Status: Integer; - end; - - TSkParagraphVisitProc = reference to procedure (const ALineNumber: Integer; const AInfo: TSkParagraphVisitorInfo); - - (*$HPPEMIT END '#define __SkCreate(AClass, AIntf, ...) \' *) - (*$HPPEMIT END ' ({ \' *) - (*$HPPEMIT END ' using namespace ::Skia; \' *) - (*$HPPEMIT END ' _di_##AIntf __Result; \' *) - (*$HPPEMIT END ' (new AClass(__VA_ARGS__))->GetInterface(__Result); \' *) - (*$HPPEMIT END ' __Result; \' *) - (*$HPPEMIT END ' })' *) - - { ISkObject } - - ISkObject = interface - function GetHandle: THandle; - property Handle: THandle read GetHandle; - end; - - { TSkObject } - - TSkObject = class abstract(TInterfacedObject, ISkObject) - {$IFNDEF AUTOREFCOUNT} - strict private const - objDestroyingFlag = Integer($80000000); - {$ENDIF} - strict private - FHandle: THandle; - FOwnsHandle: Boolean; - {$IFNDEF AUTOREFCOUNT} - [Volatile] FRefCount: Integer; - {$ENDIF} - function GetHandle: THandle; - {$IFNDEF AUTOREFCOUNT} - function GetRefCount: Integer; inline; - {$ENDIF} - class constructor Create; - class destructor Destroy; - strict protected - function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; - function _AddRef: Integer; stdcall; - function _Release: Integer; stdcall; - class procedure __DestroyHandle(const AHandle: THandle); virtual; - {$IFNDEF AUTOREFCOUNT} - class procedure __MarkDestroying(const Obj); static; inline; - {$ENDIF} - class procedure __RefHandle(const AHandle: THandle); virtual; - class procedure __UnrefHandle(const AHandle: THandle); virtual; - public - constructor Create(const AHandle: THandle); - constructor Wrap(const AHandle: THandle; const AOwnsHandle: Boolean = True); - destructor Destroy; override; - {$IFNDEF AUTOREFCOUNT} - procedure AfterConstruction; override; - procedure BeforeDestruction; override; - {$ENDIF} - property Handle: THandle read FHandle; - {$IFNDEF AUTOREFCOUNT} - property RefCount: Integer read GetRefCount; - class function NewInstance: TObject; override; - {$ENDIF} - class function __ReleaseHandle(const AObject: ISkObject): THandle; - end; - - { ISkReferenceCounted } - - ISkReferenceCounted = interface(ISkObject) - end; - - { TSkReferenceCounted } - - TSkReferenceCounted = class abstract(TSkObject, ISkReferenceCounted) - public - class procedure __RefHandle(const AHandle: THandle); override; final; - class procedure __UnrefHandle(const AHandle: THandle); override; final; - end; - - { ISkNonVirtualReferenceCounted } - - ISkNonVirtualReferenceCounted = interface(ISkObject) - end; - - { TSkNonVirtualReferenceCounted } - - TSkNonVirtualReferenceCounted = class abstract(TSkObject, ISkNonVirtualReferenceCounted); - - TSkEnumerable = class; - - { TSkEnumerator } - - TSkEnumerator = class - strict private - FEnumerable: TSkEnumerable; - public - constructor Create(const AEnumerable: TSkEnumerable); - function GetCurrent: T; - function MoveNext: Boolean; - property Current: T read GetCurrent; - end; - - { ISkEnumerable } - - ISkEnumerable = interface(ISkObject) - function MoveNext: Boolean; - end; - - { TSkEnumerable } - - TSkEnumerable = class abstract(TSkObject, ISkEnumerable) - public - function GetCurrent: T; virtual; abstract; - function GetEnumerator: TSkEnumerator; - function MoveNext: Boolean; virtual; abstract; - end; - - { IGrBackendRenderTarget } - - IGrBackendRenderTarget = interface(ISkObject) - ['{2E56D489-6BCB-472F-8A69-93B2B18624DB}'] - function GetBackendAPI: TGrBackendAPI; - function GetHeight: Integer; - function GetSampleCount: Integer; - function GetStencilBits: Integer; - function GetWidth: Integer; - function IsValid: Boolean; - property BackendAPI: TGrBackendAPI read GetBackendAPI; - property Height: Integer read GetHeight; - property SampleCount: Integer read GetSampleCount; - property StencilBits: Integer read GetStencilBits; - property Width: Integer read GetWidth; - end; - - { TGrBackendRenderTarget } - - TGrBackendRenderTarget = class(TSkObject, IGrBackendRenderTarget) - strict private - function GetBackendAPI: TGrBackendAPI; - function GetHeight: Integer; - function GetSampleCount: Integer; - function GetStencilBits: Integer; - function GetWidth: Integer; - function IsValid: Boolean; - public - constructor CreateGl(const AWidth, AHeight, ASampleCount, AStencilBits: Integer; const AFramebufferInfo: TGrGlFramebufferInfo); - constructor CreateMetal(const AWidth, AHeight: Integer; const ATextureInfo: TGrMtlTextureInfo); - constructor CreateVulkan(const AWidth, AHeight: Integer; const AImageInfo: TGrVkImageInfo); - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define GrBackendRenderTarget(...) __SkCreate(TGrBackendRenderTarget, IGrBackendRenderTarget, __VA_ARGS__)'} - - { IGrBackendTexture } - - IGrBackendTexture = interface(ISkObject) - ['{2725242E-7CA7-41A5-A79B-3802E99557C4}'] - function GetBackendAPI: TGrBackendAPI; - function GetGlTextureInfo(out ATextureInfo: TGrGlTextureInfo): Boolean; - function GetHeight: Integer; - function GetWidth: Integer; - function HasMipmaps: Boolean; - function IsValid: Boolean; - property BackendAPI: TGrBackendAPI read GetBackendAPI; - property Height: Integer read GetHeight; - property Width: Integer read GetWidth; - end; - - { TGrBackendTexture } - - TGrBackendTexture = class(TSkObject, IGrBackendTexture) - strict private - function GetBackendAPI: TGrBackendAPI; - function GetGlTextureInfo(out ATextureInfo: TGrGlTextureInfo): Boolean; - function GetHeight: Integer; - function GetWidth: Integer; - function HasMipmaps: Boolean; - function IsValid: Boolean; - public - constructor CreateGl(const AWidth, AHeight: Integer; const AIsMipmapped: Boolean; const ATextureInfo: TGrGlTextureInfo); - constructor CreateMetal(const AWidth, AHeight: Integer; const AIsMipmapped: Boolean; const ATextureInfo: TGrMtlTextureInfo); - constructor CreateVulkan(const AWidth, AHeight: Integer; const AImageInfo: TGrVkImageInfo); - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define GrBackendTexture(...) __SkCreate(TGrBackendTexture, IGrBackendTexture, __VA_ARGS__)'} - - { IGrDirectContext } - - IGrDirectContext = interface(ISkReferenceCounted) - ['{8B4304D7-385A-4165-ADE2-F052DAAA70D3}'] - procedure AbandonContext; - procedure DumpMemoryStatistics(const ATraceMemoryDump: ISkTraceMemoryDump); - procedure Flush; - procedure FlushAndSubmit(const ASyncCpu: Boolean = False); - procedure FreeGpuResources; - function GetBackendAPI: TGrBackendAPI; - function GetMaxSurfaceSampleCountForColorType(const AColorType: TSkColorType): Integer; - function GetResourceCacheLimit: NativeUInt; - procedure GetResourceCacheUsage(out AResources: Integer; out AResourcesBytes: NativeUInt); - function IsAbandoned: Boolean; - procedure PerformDeferredCleanup(const AMilliseconds: Int64); - procedure PurgeUnlockedResources(const AScratchResourcesOnly: Boolean); overload; - procedure PurgeUnlockedResources(const ABytesToPurge: NativeUInt; const APreferScratchResources: Boolean); overload; - procedure ReleaseResourcesAndAbandonContext; - procedure ResetContext; - procedure SetResourceCacheLimit(const AValue: NativeUInt); - function Submit(const ASyncCpu: Boolean = False): Boolean; - property BackendAPI: TGrBackendAPI read GetBackendAPI; - property ResourceCacheLimit: NativeUInt read GetResourceCacheLimit write SetResourceCacheLimit; - end; - - { TGrDirectContext } - - TGrDirectContext = class(TSkReferenceCounted, IGrDirectContext) - strict private - procedure AbandonContext; - procedure DumpMemoryStatistics(const ATraceMemoryDump: ISkTraceMemoryDump); - procedure Flush; - procedure FlushAndSubmit(const ASyncCpu: Boolean = False); - procedure FreeGpuResources; - function GetBackendAPI: TGrBackendAPI; - function GetMaxSurfaceSampleCountForColorType(const AColorType: TSkColorType): Integer; - function GetResourceCacheLimit: NativeUInt; - procedure GetResourceCacheUsage(out AResources: Integer; out AResourcesBytes: NativeUInt); - function IsAbandoned: Boolean; - procedure PerformDeferredCleanup(const AMilliseconds: Int64); - procedure PurgeUnlockedResources(const AScratchResourcesOnly: Boolean); overload; - procedure PurgeUnlockedResources(const ABytesToPurge: NativeUInt; const APreferScratchResources: Boolean); overload; - procedure ReleaseResourcesAndAbandonContext; - procedure ResetContext; - procedure SetResourceCacheLimit(const AValue: NativeUInt); - function Submit(const ASyncCpu: Boolean = False): Boolean; - public - class function MakeGl(AInterface: IGrGlInterface = nil): IGrDirectContext; overload; static; - class function MakeGl(const AOptions: TGrContextOptions; const AInterface: IGrGlInterface = nil): IGrDirectContext; overload; static; - class function MakeMetal(const ABackendContext: TGrMtlBackendContext): IGrDirectContext; overload; static; - class function MakeMetal(const ABackendContext: TGrMtlBackendContext; const AOptions: TGrContextOptions): IGrDirectContext; overload; static; - class function MakeVulkan(const ABackendContext: TGrVkBackendContext): IGrDirectContext; overload; static; - class function MakeVulkan(const ABackendContext: TGrVkBackendContext; const AOptions: TGrContextOptions): IGrDirectContext; overload; static; - end; - - { IGrGlInterface } - - IGrGlInterface = interface(ISkReferenceCounted) - ['{77860D76-5A77-45FB-9F62-03C1DD694489}'] - function HasExtension(const AName: string): Boolean; - function Validate: Boolean; - end; - - { TGrGlInterface } - - TGrGlInterface = class(TSkReferenceCounted, IGrGlInterface) - strict private - function HasExtension(const AName: string): Boolean; - function Validate: Boolean; - public - class function MakeAssembled(const AProc: TGrGlGetProc): IGrGlInterface; static; - class function MakeAssembledGl(const AProc: TGrGlGetProc): IGrGlInterface; static; - class function MakeAssembledGles(const AProc: TGrGlGetProc): IGrGlInterface; static; - class function MakeAssembledWebGl(const AProc: TGrGlGetProc): IGrGlInterface; static; - class function MakeNative: IGrGlInterface; static; - end; - - { IGrPersistentCache } - - IGrPersistentCache = interface(ISkObject) - ['{AF624E98-7525-44E4-90EB-D6D21826011A}'] - end; - - { TGrPersistentCacheBaseClass } - - TGrPersistentCacheBaseClass = class abstract(TSkObject, IGrPersistentCache) - strict private - class constructor Create; - class function load_proc(context: Pointer; const key_data: Pointer; key_size: size_t): sk_data_t; cdecl; static; - class procedure store_proc(context: Pointer; const key_data: Pointer; key_size: size_t; const data: Pointer; size: size_t); cdecl; static; - strict protected - function Load(const AKey: TBytes): TBytes; virtual; abstract; - procedure Store(const AKey, AData: TBytes); virtual; abstract; - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - { IGrShaderErrorHandler } - - IGrShaderErrorHandler = interface(ISkObject) - ['{7CCA8C48-CB40-4FBD-B70D-986BC2FC1D58}'] - end; - - { TGrShaderErrorHandlerBaseClass } - - TGrShaderErrorHandlerBaseClass = class abstract(TSkObject, IGrShaderErrorHandler) - strict private - class constructor Create; - class procedure compile_error_proc(context: Pointer; const shader, errors: MarshaledAString); cdecl; static; - strict protected - procedure CompileError(const AShader, AErrors: string); virtual; abstract; - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - { IGrVkExtensions } - - IGrVkExtensions = interface(ISkObject) - ['{A3F62993-F17A-4D8D-BA85-725AFE2ACDF4}'] - function HasExtension(const AName: string; const AMinVersion: Cardinal): Boolean; - procedure Init(const AProc: TGrVkGetProc; const AInstance: GrVkInstance; const APhysicalDevice: GrVkPhysicalDevice; const AInstanceExtensions, ADeviceExtensions: TArray); - end; - - { TGrVkExtensions } - - TGrVkExtensions = class(TSkObject, IGrVkExtensions) - strict private - function HasExtension(const AName: string; const AMinVersion: Cardinal): Boolean; - procedure Init(const AProc: TGrVkGetProc; const AInstance: GrVkInstance; const APhysicalDevice: GrVkPhysicalDevice; const AInstanceExtensions, ADeviceExtensions: TArray); - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define GrVkExtensions(...) __SkCreate(TGrVkExtensions, IGrVkExtensions, __VA_ARGS__)'} - - { ISkBlender } - - ISkBlender = interface(ISkReferenceCounted) - ['{78342141-22D6-4D38-A87D-38D70DE65A8C}'] - end; - - { TSkBlender } - - TSkBlender = class(TSkReferenceCounted, ISkBlender) - public - class function MakeArithmetic(const AK1, AK2, AK3, AK4: Single; const AEnforcePremultipliedColor: Boolean): ISkBlender; static; - class function MakeMode(const AMode: TSkBlendMode): ISkBlender; static; - end; - - { ISkCanvas } - - ISkCanvas = interface(ISkObject) - ['{FC12079A-38A3-4078-88D7-30F550F1B49E}'] - procedure Clear(const AColor: TAlphaColor); overload; - procedure Clear(const AColor: TAlphaColorF); overload; - procedure Discard; - procedure ClipPath(const APath: ISkPath; const AOp: TSkClipOp = TSkClipOp.Intersect; const AAntiAlias: Boolean = False); - procedure ClipRect(const ARect: TRectF; const AOp: TSkClipOp = TSkClipOp.Intersect; const AAntiAlias: Boolean = False); - procedure ClipRegion(const ARegion: ISkRegion; const AOp: TSkClipOp = TSkClipOp.Intersect); - procedure ClipRoundRect(const ARoundRect: ISkRoundRect; const AOp: TSkClipOp = TSkClipOp.Intersect; const AAntiAlias: Boolean = False); - procedure ClipShader(const AShader: ISkShader; const AOp: TSkClipOp = TSkClipOp.Intersect); - procedure Concat(const AMatrix: TMatrix); overload; - procedure Concat(const AMatrix: TMatrix3D); overload; - procedure DrawAnnotation(const ARect: TRectF; const AKey: string); overload; - procedure DrawAnnotation(const ARect: TRectF; const AKey: string; const AValue; const ASize: NativeUInt); overload; - procedure DrawArc(const AOval: TRectF; const AStartAngle, ASweepAngle: Single; const AUseCenter: Boolean; const APaint: ISkPaint); - procedure DrawAtlas(const AAtlas: ISkImage; const ATansforms: TArray; const ASprites: TArray; const ABlendMode: TSkBlendMode; const AColors: TArray = nil; const APaint: ISkPaint = nil); overload; - procedure DrawAtlas(const AAtlas: ISkImage; const ATansforms: TArray; const ASprites: TArray; const ABlendMode: TSkBlendMode; const ASampling: TSkSamplingOptions; const AColors: TArray = nil; const APaint: ISkPaint = nil); overload; - procedure DrawAtlas(const AAtlas: ISkImage; const ATansforms: TArray; const ASprites: TArray; const ABlendMode: TSkBlendMode; const ACullRect: TRectF; const AColors: TArray = nil; const APaint: ISkPaint = nil); overload; - procedure DrawAtlas(const AAtlas: ISkImage; const ATansforms: TArray; const ASprites: TArray; const ABlendMode: TSkBlendMode; const ASampling: TSkSamplingOptions; const ACullRect: TRectF; const AColors: TArray = nil; const APaint: ISkPaint = nil); overload; - procedure DrawCircle(const ACenter: TPointF; ARadius: Single; const APaint: ISkPaint); overload; - procedure DrawCircle(const ACenterX, ACenterY, ARadius: Single; const APaint: ISkPaint); overload; - procedure DrawColor(const AColor: TAlphaColor; const ABlendMode: TSkBlendMode = TSkBlendMode.SrcOver); overload; - procedure DrawColor(const AColor: TAlphaColorF; const ABlendMode: TSkBlendMode = TSkBlendMode.SrcOver); overload; - procedure DrawGlyphs(const AGlyphs: TArray; const APositions: TArray; const AOrigin: TPointF; const AFont: ISkFont; const APaint: ISkPaint); overload; - procedure DrawGlyphs(const AGlyphs: TArray; const AMatrices: TArray; const AOrigin: TPointF; const AFont: ISkFont; const APaint: ISkPaint); overload; - procedure DrawImage(const AImage: ISkImage; const AX, AY: Single; const APaint: ISkPaint = nil); overload; - procedure DrawImage(const AImage: ISkImage; const AX, AY: Single; const ASampling: TSkSamplingOptions; const APaint: ISkPaint = nil); overload; - procedure DrawImageLattice(const AImage: ISkImage; const ALattice: TSkLattice; const ADest: TRectF; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear; const APaint: ISkPaint = nil); - procedure DrawImageNine(const AImage: ISkImage; const ACenter: TRect; const ADest: TRectF; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear; const APaint: ISkPaint = nil); - procedure DrawImageRect(const AImage: ISkImage; const ADest: TRectF; const APaint: ISkPaint = nil; const AConstraint: TSkSrcRectConstraint = TSkSrcRectConstraint.Fast); overload; - procedure DrawImageRect(const AImage: ISkImage; const ADest: TRectF; const ASampling: TSkSamplingOptions; const APaint: ISkPaint = nil; const AConstraint: TSkSrcRectConstraint = TSkSrcRectConstraint.Fast); overload; - procedure DrawImageRect(const AImage: ISkImage; const ASrc, ADest: TRectF; const APaint: ISkPaint = nil; const AConstraint: TSkSrcRectConstraint = TSkSrcRectConstraint.Fast); overload; - procedure DrawImageRect(const AImage: ISkImage; const ASrc, ADest: TRectF; const ASampling: TSkSamplingOptions; const APaint: ISkPaint = nil; const AConstraint: TSkSrcRectConstraint = TSkSrcRectConstraint.Fast); overload; - procedure DrawLine(const APoint1, APoint2: TPointF; const APaint: ISkPaint); overload; - procedure DrawLine(const AX1, AY1, AX2, AY2: Single; const APaint: ISkPaint); overload; - procedure DrawOval(const AOval: TRectF; const APaint: ISkPaint); - procedure DrawPaint(const APaint: ISkPaint); - procedure DrawPatch(const ACubics: TSkPatchCubics; const AColors: TSkPatchColors; const ATexCoords: TSkPatchTexCoords; const ABlendMode: TSkBlendMode; const APaint: ISkPaint); - procedure DrawPath(const APath: ISkPath; const APaint: ISkPaint); - procedure DrawPicture(const APicture: ISkPicture; const APaint: ISkPaint = nil); overload; - procedure DrawPicture(const APicture: ISkPicture; const AMatrix: TMatrix; const APaint: ISkPaint = nil); overload; - procedure DrawPoint(const APoint: TPointF; const APaint: ISkPaint); overload; - procedure DrawPoint(const AX, AY: Single; const APaint: ISkPaint); overload; - procedure DrawPoints(const AMode: TSkDrawPointsMode; const APoints: TArray; const APaint: ISkPaint); - procedure DrawRect(const ARect: TRectF; const APaint: ISkPaint); - procedure DrawRegion(const ARegion: ISkRegion; const APaint: ISkPaint); - procedure DrawRoundRect(const ARoundRect: ISkRoundRect; const APaint: ISkPaint); overload; - procedure DrawRoundRect(const ARect: TRectF; const ARadiusX, ARadiusY: Single; const APaint: ISkPaint); overload; - procedure DrawRoundRectDifference(const AOuter, AInner: ISkRoundRect; const APaint: ISkPaint); overload; - procedure DrawSimpleText(const AText: string; const AX, AY: Single; const AFont: ISkFont; const APaint: ISkPaint); - procedure DrawSimpleTextGlyphs(const AGlyphs: TArray; const AX, AY: Single; const AFont: ISkFont; const APaint: ISkPaint); - procedure DrawTextBlob(const ATextBlob: ISkTextBlob; const AX, AY: Single; const APaint: ISkPaint); overload; - procedure DrawVertices(const AVertices: ISkVertices; const ABlendMode: TSkBlendMode; const APaint: ISkPaint); - function GetBaseProperties: TSkSurfaceProperties; - function GetDeviceClipBounds: TRect; - function GetLocalClipBounds: TRectF; - function GetLocalToDevice: TMatrix3D; - function GetLocalToDeviceAs3x3: TMatrix; - function GetSaveCount: Integer; - function GetTopProperties: TSkSurfaceProperties; - function MakeSurface(const AImageInfo: TSkImageInfo): ISkSurface; overload; - function MakeSurface(const AImageInfo: TSkImageInfo; const AProperties: TSkSurfaceProperties): ISkSurface; overload; - function QuickReject(const ARect: TRectF): Boolean; overload; - function QuickReject(const APath: ISkPath): Boolean; overload; - procedure ResetMatrix; - procedure Restore; - procedure RestoreToCount(const ASaveCount: Integer); - procedure Rotate(const ADegrees: Single); overload; - procedure Rotate(const ADegrees, APX, APY: Single); overload; - procedure RotateRadians(const ARadians: Single); - function Save: Integer; - procedure SaveLayer(const APaint: ISkPaint = nil); overload; - procedure SaveLayer(const ABounds: TRectF; const APaint: ISkPaint = nil); overload; - procedure SaveLayerAlpha(const AAlpha: Byte); overload; - procedure SaveLayerAlpha(const ABounds: TRectF; const AAlpha: Byte); overload; - procedure Scale(const AScaleX, AScaleY: Single); - procedure SetMatrix(const AMatrix: TMatrix); overload; - procedure SetMatrix(const AMatrix: TMatrix3D); overload; - procedure Skew(const ASkewX, ASkewY: Single); - procedure Translate(const ADeltaX, ADeltaY: Single); - property BaseProperties: TSkSurfaceProperties read GetBaseProperties; - property TopProperties: TSkSurfaceProperties read GetTopProperties; - end; - - { TSkCanvas } - - TSkCanvas = class(TSkObject, ISkCanvas) - strict private - procedure Clear(const AColor: TAlphaColor); overload; - procedure Clear(const AColor: TAlphaColorF); overload; - procedure Discard; - procedure ClipPath(const APath: ISkPath; const AOp: TSkClipOp = TSkClipOp.Intersect; const AAntiAlias: Boolean = False); - procedure ClipRect(const ARect: TRectF; const AOp: TSkClipOp = TSkClipOp.Intersect; const AAntiAlias: Boolean = False); - procedure ClipRegion(const ARegion: ISkRegion; const AOp: TSkClipOp = TSkClipOp.Intersect); - procedure ClipRoundRect(const ARoundRect: ISkRoundRect; const AOp: TSkClipOp = TSkClipOp.Intersect; const AAntiAlias: Boolean = False); - procedure ClipShader(const AShader: ISkShader; const AOp: TSkClipOp = TSkClipOp.Intersect); - procedure Concat(const AMatrix: TMatrix); overload; - procedure Concat(const AMatrix: TMatrix3D); overload; - procedure DrawAnnotation(const ARect: TRectF; const AKey: string); overload; - procedure DrawAnnotation(const ARect: TRectF; const AKey: string; const AValue; const ASize: NativeUInt); overload; - procedure DrawArc(const AOval: TRectF; const AStartAngle, ASweepAngle: Single; const AUseCenter: Boolean; const APaint: ISkPaint); - procedure DrawAtlas(const AAtlas: ISkImage; const ATansforms: TArray; const ASprites: TArray; const ABlendMode: TSkBlendMode; const AColors: TArray = nil; const APaint: ISkPaint = nil); overload; - procedure DrawAtlas(const AAtlas: ISkImage; const ATansforms: TArray; const ASprites: TArray; const ABlendMode: TSkBlendMode; const ASampling: TSkSamplingOptions; const AColors: TArray = nil; const APaint: ISkPaint = nil); overload; - procedure DrawAtlas(const AAtlas: ISkImage; const ATansforms: TArray; const ASprites: TArray; const ABlendMode: TSkBlendMode; const ACullRect: TRectF; const AColors: TArray = nil; const APaint: ISkPaint = nil); overload; - procedure DrawAtlas(const AAtlas: ISkImage; const ATansforms: TArray; const ASprites: TArray; const ABlendMode: TSkBlendMode; const ASampling: TSkSamplingOptions; const ACullRect: TRectF; const AColors: TArray = nil; const APaint: ISkPaint = nil); overload; - procedure DrawCircle(const ACenter: TPointF; ARadius: Single; const APaint: ISkPaint); overload; - procedure DrawCircle(const ACenterX, ACenterY, ARadius: Single; const APaint: ISkPaint); overload; - procedure DrawColor(const AColor: TAlphaColor; const ABlendMode: TSkBlendMode = TSkBlendMode.SrcOver); overload; - procedure DrawColor(const AColor: TAlphaColorF; const ABlendMode: TSkBlendMode = TSkBlendMode.SrcOver); overload; - procedure DrawGlyphs(const AGlyphs: TArray; const APositions: TArray; const AOrigin: TPointF; const AFont: ISkFont; const APaint: ISkPaint); overload; - procedure DrawGlyphs(const AGlyphs: TArray; const AMatrices: TArray; const AOrigin: TPointF; const AFont: ISkFont; const APaint: ISkPaint); overload; - procedure DrawImage(const AImage: ISkImage; const AX, AY: Single; const APaint: ISkPaint = nil); overload; - procedure DrawImage(const AImage: ISkImage; const AX, AY: Single; const ASampling: TSkSamplingOptions; const APaint: ISkPaint = nil); overload; - procedure DrawImageLattice(const AImage: ISkImage; const ALattice: TSkLattice; const ADest: TRectF; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear; const APaint: ISkPaint = nil); - procedure DrawImageNine(const AImage: ISkImage; const ACenter: TRect; const ADest: TRectF; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear; const APaint: ISkPaint = nil); - procedure DrawImageRect(const AImage: ISkImage; const ADest: TRectF; const APaint: ISkPaint = nil; const AConstraint: TSkSrcRectConstraint = TSkSrcRectConstraint.Fast); overload; - procedure DrawImageRect(const AImage: ISkImage; const ADest: TRectF; const ASampling: TSkSamplingOptions; const APaint: ISkPaint = nil; const AConstraint: TSkSrcRectConstraint = TSkSrcRectConstraint.Fast); overload; - procedure DrawImageRect(const AImage: ISkImage; const ASrc, ADest: TRectF; const APaint: ISkPaint = nil; const AConstraint: TSkSrcRectConstraint = TSkSrcRectConstraint.Fast); overload; - procedure DrawImageRect(const AImage: ISkImage; const ASrc, ADest: TRectF; const ASampling: TSkSamplingOptions; const APaint: ISkPaint = nil; const AConstraint: TSkSrcRectConstraint = TSkSrcRectConstraint.Fast); overload; - procedure DrawLine(const APoint1, APoint2: TPointF; const APaint: ISkPaint); overload; - procedure DrawLine(const AX1, AY1, AX2, AY2: Single; const APaint: ISkPaint); overload; - procedure DrawOval(const AOval: TRectF; const APaint: ISkPaint); - procedure DrawPaint(const APaint: ISkPaint); - procedure DrawPatch(const ACubics: TSkPatchCubics; const AColors: TSkPatchColors; const ATexCoords: TSkPatchTexCoords; const ABlendMode: TSkBlendMode; const APaint: ISkPaint); - procedure DrawPath(const APath: ISkPath; const APaint: ISkPaint); - procedure DrawPicture(const APicture: ISkPicture; const APaint: ISkPaint = nil); overload; - procedure DrawPicture(const APicture: ISkPicture; const AMatrix: TMatrix; const APaint: ISkPaint = nil); overload; - procedure DrawPoint(const APoint: TPointF; const APaint: ISkPaint); overload; - procedure DrawPoint(const AX, AY: Single; const APaint: ISkPaint); overload; - procedure DrawPoints(const AMode: TSkDrawPointsMode; const APoints: TArray; const APaint: ISkPaint); - procedure DrawRect(const ARect: TRectF; const APaint: ISkPaint); - procedure DrawRegion(const ARegion: ISkRegion; const APaint: ISkPaint); - procedure DrawRoundRect(const ARoundRect: ISkRoundRect; const APaint: ISkPaint); overload; - procedure DrawRoundRect(const ARect: TRectF; const ARadiusX, ARadiusY: Single; const APaint: ISkPaint); overload; - procedure DrawRoundRectDifference(const AOuter, AInner: ISkRoundRect; const APaint: ISkPaint); overload; - procedure DrawSimpleText(const AText: string; const AX, AY: Single; const AFont: ISkFont; const APaint: ISkPaint); - procedure DrawSimpleTextGlyphs(const AGlyphs: TArray; const AX, AY: Single; const AFont: ISkFont; const APaint: ISkPaint); - procedure DrawTextBlob(const ATextBlob: ISkTextBlob; const AX, AY: Single; const APaint: ISkPaint); overload; - procedure DrawVertices(const AVertices: ISkVertices; const ABlendMode: TSkBlendMode; const APaint: ISkPaint); - function GetBaseProperties: TSkSurfaceProperties; - function GetDeviceClipBounds: TRect; - function GetLocalClipBounds: TRectF; - function GetLocalToDevice: TMatrix3D; - function GetLocalToDeviceAs3x3: TMatrix; - function GetSaveCount: Integer; - function GetTopProperties: TSkSurfaceProperties; - function MakeSurface(const AImageInfo: TSkImageInfo): ISkSurface; overload; - function MakeSurface(const AImageInfo: TSkImageInfo; const AProperties: TSkSurfaceProperties): ISkSurface; overload; - function QuickReject(const ARect: TRectF): Boolean; overload; - function QuickReject(const APath: ISkPath): Boolean; overload; - procedure ResetMatrix; - procedure Restore; - procedure RestoreToCount(const ASaveCount: Integer); - procedure Rotate(const ADegrees: Single); overload; - procedure Rotate(const ADegrees, APX, APY: Single); overload; - procedure RotateRadians(const ARadians: Single); - function Save: Integer; - procedure SaveLayer(const APaint: ISkPaint = nil); overload; - procedure SaveLayer(const ABounds: TRectF; const APaint: ISkPaint = nil); overload; - procedure SaveLayerAlpha(const AAlpha: Byte); overload; - procedure SaveLayerAlpha(const ABounds: TRectF; const AAlpha: Byte); overload; - procedure Scale(const AScaleX, AScaleY: Single); - procedure SetMatrix(const AMatrix: TMatrix); overload; - procedure SetMatrix(const AMatrix: TMatrix3D); overload; - procedure Skew(const ASkewX, ASkewY: Single); - procedure Translate(const ADeltaX, ADeltaY: Single); - public - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - { ISkCodec } - - ISkCodec = interface(ISkObject) - ['{7FE13F05-959F-462B-8001-0DE5A0878CD8}'] - function GetDimensions: TSize; - function GetEncodedImageFormat: TSkEncodedImageFormat; - function GetHeight: Integer; - function GetImage(const AColorType: TSkColorType; const AAlphaType: TSkAlphaType = TSkAlphaType.Premul; AColorSpace: ISkColorSpace = nil): ISkImage; - function GetPixels(const APixels: Pointer; const ARowBytes: NativeUInt; const AColorType: TSkColorType; const AAlphaType: TSkAlphaType = TSkAlphaType.Premul; AColorSpace: ISkColorSpace = nil): Boolean; - function GetWidth: Integer; - property Dimensions: TSize read GetDimensions; - property EncodedImageFormat: TSkEncodedImageFormat read GetEncodedImageFormat; - property Height: Integer read GetHeight; - property Width: Integer read GetWidth; - end; - - { TSkCodec } - - TSkCodec = class(TSkObject, ISkCodec) - strict private - function GetDimensions: TSize; - function GetEncodedImageFormat: TSkEncodedImageFormat; - function GetHeight: Integer; - function GetImage(const AColorType: TSkColorType; const AAlphaType: TSkAlphaType = TSkAlphaType.Premul; AColorSpace: ISkColorSpace = nil): ISkImage; - function GetPixels(const APixels: Pointer; const ARowBytes: NativeUInt; const AColorType: TSkColorType; const AAlphaType: TSkAlphaType = TSkAlphaType.Premul; AColorSpace: ISkColorSpace = nil): Boolean; - function GetWidth: Integer; - public - class function MakeFromFile(const AFileName: string): ISkCodec; static; - class function MakeFromStream(const AStream: TStream): ISkCodec; static; - class function MakeWithCopy(const AData: Pointer; const ASize: NativeUInt): ISkCodec; static; - class function MakeWithoutCopy(const AData: Pointer; const ASize: NativeUInt): ISkCodec; static; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - { ISkAnimationCodecPlayer } - - ISkAnimationCodecPlayer = interface(ISkObject) - ['{F900E95B-3B21-4CA1-B2BC-B6D060A2773D}'] - function GetDimensions: TSize; - function GetDuration: Cardinal; - function GetFrame: ISkImage; - function GetHeight: Integer; - function GetWidth: Integer; - function Seek(const AMilliseconds: Cardinal): Boolean; - property Dimensions: TSize read GetDimensions; - property Duration: Cardinal read GetDuration; - property Frame: ISkImage read GetFrame; - property Height: Integer read GetHeight; - property Width: Integer read GetWidth; - end; - - { TSkAnimationCodecPlayer } - - TSkAnimationCodecPlayer = class(TSkObject, ISkAnimationCodecPlayer) - strict private - function GetDimensions: TSize; - function GetDuration: Cardinal; - function GetFrame: ISkImage; - function GetHeight: Integer; - function GetWidth: Integer; - function Seek(const AMilliseconds: Cardinal): Boolean; - public - class function MakeFromFile(const AFileName: string): ISkAnimationCodecPlayer; static; - class function MakeFromStream(const AStream: TStream): ISkAnimationCodecPlayer; static; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - { ISkColorFilter } - - ISkColorFilter = interface(ISkReferenceCounted) - ['{A7F1A527-A796-4387-8957-5D5C2DAB0924}'] - end; - - { TSkColorFilter } - - TSkColorFilter = class(TSkReferenceCounted, ISkColorFilter) - public - class function MakeBlend(const AColor: TAlphaColor; const AMode: TSkBlendMode): ISkColorFilter; overload; static; - class function MakeBlend(const AColor: TAlphaColorF; AColorSpace: ISkColorSpace; const AMode: TSkBlendMode): ISkColorFilter; overload; static; - class function MakeCompose(const AOuter, AInner: ISkColorFilter): ISkColorFilter; static; - class function MakeHighContrast(const AConfig: TSkHighContrastConfig): ISkColorFilter; static; - class function MakeHSLAMatrix(const AMatrix: TSkColorMatrix): ISkColorFilter; static; - class function MakeLighting(const AMultiply, AAdd: TAlphaColor): ISkColorFilter; static; - class function MakeLinearToSRGBGamma: ISkColorFilter; - class function MakeLumaColor: ISkColorFilter; static; - class function MakeMatrix(const AMatrix: TSkColorMatrix): ISkColorFilter; static; - class function MakeOverdraw(const AColors: TSkOverdrawColor): ISkColorFilter; static; - class function MakeTable(const ATable: TSkTableFilter): ISkColorFilter; overload; static; - class function MakeTable(const ATableA, ATableR, ATableG, ATableB: TSkTableFilter): ISkColorFilter; overload; static; - end; - - { ISkColorSpace } - - ISkColorSpace = interface(ISkNonVirtualReferenceCounted) - ['{0581D967-BDFC-4F6D-A821-D0BFA2DCCBAC}'] - function GammaCloseToSRGB: Boolean; - function GammaIsLinear: Boolean; - function IsEqual(const AColorSpace: ISkColorSpace): Boolean; - function IsNumericalTransferFunction(out ATransferFunction: TSkColorSpaceTransferFunction): Boolean; - function IsSRGB: Boolean; - function MakeLinearGamma: ISkColorSpace; - function MakeSRGBGamma: ISkColorSpace; - function ToProfile: ISkColorSpaceICCProfile; - function ToXyz(out ADest: TSkColorSpaceXyz): Boolean; - end; - - { TSkColorSpace } - - TSkColorSpace = class(TSkNonVirtualReferenceCounted, ISkColorSpace) - strict private - function GammaCloseToSRGB: Boolean; - function GammaIsLinear: Boolean; - function IsEqual(const AColorSpace: ISkColorSpace): Boolean; - function IsNumericalTransferFunction(out ATransferFunction: TSkColorSpaceTransferFunction): Boolean; - function IsSRGB: Boolean; - function MakeLinearGamma: ISkColorSpace; - function MakeSRGBGamma: ISkColorSpace; - function ToProfile: ISkColorSpaceICCProfile; - function ToXyz(out ADest: TSkColorSpaceXyz): Boolean; - public - class function Make(const AProfile: ISkColorSpaceICCProfile): ISkColorSpace; static; - class function MakeRGB(const ATransferFunction: TSkColorSpaceTransferFunction; const AToXyzD50: TSkColorSpaceXyz): ISkColorSpace; static; - class function MakeSRGB: ISkColorSpace; static; - class function MakeSRGBLinear: ISkColorSpace; static; - class procedure __RefHandle(const AHandle: THandle); override; - class procedure __UnrefHandle(const AHandle: THandle); override; - end; - - { ISkColorSpaceICCProfile } - - ISkColorSpaceICCProfile = interface(ISkObject) - ['{F5645A9F-F9AE-4B59-BA03-931E56B32422}'] - function ToBytes: TBytes; - function ToXyz(out ADest: TSkColorSpaceXyz): Boolean; - end; - - { TSkColorSpaceICCProfile } - - TSkColorSpaceICCProfile = class(TSkObject, ISkColorSpaceICCProfile) - strict private - function ToBytes: TBytes; - function ToXyz(out ADest: TSkColorSpaceXyz): Boolean; - public - class function MakeFromBytes(const ABytes: TBytes): ISkColorSpaceICCProfile; static; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - { ISkDocument } - - ISkDocument = interface(ISkReferenceCounted) - ['{E41A23F2-F67A-487A-9830-21908617EC48}'] - function BeginPage(const AWidth, AHeight: Single): ISkCanvas; overload; - function BeginPage(const AWidth, AHeight: Single; const AContent: TRectF): ISkCanvas; overload; - procedure Close; - procedure EndPage; - procedure Terminate; - end; - - { TSkDocument } - - TSkDocument = class(TSkReferenceCounted, ISkDocument) - strict private - FHolder: ISkObject; - function BeginPage(const AWidth, AHeight: Single): ISkCanvas; overload; - function BeginPage(const AWidth, AHeight: Single; const AContent: TRectF): ISkCanvas; overload; - procedure Close; - procedure EndPage; - procedure Terminate; - public - class function MakePDF(const AStream: TStream): ISkDocument; overload; - class function MakePDF(const AStream: TStream; const AMetadata: TSkPDFMetadata): ISkDocument; overload; - class function MakeXPS(const AStream: TStream; const ADPI: Single = 72): ISkDocument; - end; - - { ISkFont } - - ISkFont = interface(ISkObject) - ['{034205CA-029A-428B-9037-45CBF160C3F1}'] - function GetBaselineSnap: Boolean; - function GetBounds(const AGlyphs: TArray; const APaint: ISkPaint = nil): TArray; - function GetEdging: TSkFontEdging; - function GetEmbeddedBitmaps: Boolean; - function GetEmbolden: Boolean; - function GetForceAutoHinting: Boolean; - function GetGlyphs(const AText: string): TArray; - function GetHinting: TSkFontHinting; - function GetHorizontalPositions(const AGlyphs: TArray; const AOrigin: Single = 0): TArray; - function GetIntercepts(const AGlyphs: TArray; const APositions: TArray; const AUpperBounds, ALowerBounds: Single; const APaint: ISkPaint = nil): TArray; - function GetLinearMetrics: Boolean; - function GetMetrics(out AMetrics: TSkFontMetrics): Single; - function GetPath(const AGlyph: Word): ISkPath; - procedure GetPaths(const AGlyphs: TArray; const AProc: TSkFontPathProc); - function GetPositions(const AGlyphs: TArray): TArray; overload; - function GetPositions(const AGlyphs: TArray; const AOrigin: TPointF): TArray; overload; - function GetScaleX: Single; - function GetSize: Single; - function GetSkewX: Single; - function GetSpacing: Single; - function GetSubpixel: Boolean; - function GetTypeface: ISkTypeface; - function GetTypefaceOrDefault: ISkTypeface; - function GetWidths(const AGlyphs: TArray; const APaint: ISkPaint = nil): TArray; - procedure GetWidthsAndBounds(const AGlyphs: TArray; out AWidths: TArray; out ABounds: TArray; const APaint: ISkPaint = nil); - function IsEqual(const AFont: ISkFont): Boolean; - function MakeWithSize(const ASize: Single): ISkFont; - function MeasureText(const AText: string; const APaint: ISkPaint = nil): Single; overload; - function MeasureText(const AText: string; out ABounds: TRectF; const APaint: ISkPaint = nil): Single; overload; - function MeasureTextGlyphs(const AGlyphs: TArray; const APaint: ISkPaint = nil): Single; overload; - function MeasureTextGlyphs(const AGlyphs: TArray; out ABounds: TRectF; const APaint: ISkPaint = nil): Single; overload; - procedure SetBaselineSnap(const AValue: Boolean); - procedure SetEdging(const AValue: TSkFontEdging); - procedure SetEmbeddedBitmaps(const AValue: Boolean); - procedure SetEmbolden(const AValue: Boolean); - procedure SetForceAutoHinting(const AValue: Boolean); - procedure SetHinting(const AValue: TSkFontHinting); - procedure SetLinearMetrics(const AValue: Boolean); - procedure SetScaleX(const AValue: Single); - procedure SetSize(const AValue: Single); - procedure SetSkewX(const AValue: Single); - procedure SetSubpixel(const AValue: Boolean); - procedure SetTypeface(AValue: ISkTypeface); - function UnicharToGlyph(const AUnichar: Integer): Word; - function UnicharsToGlyphs(const AUnichars: TArray): TArray; - property BaselineSnap: Boolean read GetBaselineSnap write SetBaselineSnap; - property Edging: TSkFontEdging read GetEdging write SetEdging; - property EmbeddedBitmaps: Boolean read GetEmbeddedBitmaps write SetEmbeddedBitmaps; - property Embolden: Boolean read GetEmbolden write SetEmbolden; - property ForceAutoHinting: Boolean read GetForceAutoHinting write SetForceAutoHinting; - property Hinting: TSkFontHinting read GetHinting write SetHinting; - property LinearMetrics: Boolean read GetLinearMetrics write SetLinearMetrics; - property ScaleX: Single read GetScaleX write SetScaleX; - property Size: Single read GetSize write SetSize; - property SkewX: Single read GetSkewX write SetSkewX; - property Spacing: Single read GetSpacing; - property Subpixel: Boolean read GetSubpixel write SetSubpixel; - property Typeface: ISkTypeface read GetTypeface write SetTypeface; - end; - - { TSkFont } - - TSkFont = class(TSkObject, ISkFont) - strict private - function GetBaselineSnap: Boolean; - function GetBounds(const AGlyphs: TArray; const APaint: ISkPaint = nil): TArray; - function GetEdging: TSkFontEdging; - function GetEmbeddedBitmaps: Boolean; - function GetEmbolden: Boolean; - function GetForceAutoHinting: Boolean; - function GetGlyphs(const AText: string): TArray; - function GetHinting: TSkFontHinting; - function GetHorizontalPositions(const AGlyphs: TArray; const AOrigin: Single = 0): TArray; - function GetIntercepts(const AGlyphs: TArray; const APositions: TArray; const AUpperBounds, ALowerBounds: Single; const APaint: ISkPaint = nil): TArray; - function GetLinearMetrics: Boolean; - function GetMetrics(out AMetrics: TSkFontMetrics): Single; - function GetPath(const AGlyph: Word): ISkPath; - procedure GetPaths(const AGlyphs: TArray; const AProc: TSkFontPathProc); - function GetPositions(const AGlyphs: TArray): TArray; overload; - function GetPositions(const AGlyphs: TArray; const AOrigin: TPointF): TArray; overload; - function GetScaleX: Single; - function GetSize: Single; - function GetSkewX: Single; - function GetSpacing: Single; - function GetSubpixel: Boolean; - function GetTypeface: ISkTypeface; - function GetTypefaceOrDefault: ISkTypeface; - function GetWidths(const AGlyphs: TArray; const APaint: ISkPaint = nil): TArray; - procedure GetWidthsAndBounds(const AGlyphs: TArray; out AWidths: TArray; out ABounds: TArray; const APaint: ISkPaint = nil); - function IsEqual(const AFont: ISkFont): Boolean; - function MakeWithSize(const ASize: Single): ISkFont; - function MeasureText(const AText: string; const APaint: ISkPaint = nil): Single; overload; - function MeasureText(const AText: string; out ABounds: TRectF; const APaint: ISkPaint = nil): Single; overload; - function MeasureTextGlyphs(const AGlyphs: TArray; const APaint: ISkPaint = nil): Single; overload; - function MeasureTextGlyphs(const AGlyphs: TArray; out ABounds: TRectF; const APaint: ISkPaint = nil): Single; overload; - procedure SetBaselineSnap(const AValue: Boolean); - procedure SetEdging(const AValue: TSkFontEdging); - procedure SetEmbeddedBitmaps(const AValue: Boolean); - procedure SetEmbolden(const AValue: Boolean); - procedure SetForceAutoHinting(const AValue: Boolean); - procedure SetHinting(const AValue: TSkFontHinting); - procedure SetLinearMetrics(const AValue: Boolean); - procedure SetScaleX(const AValue: Single); - procedure SetSize(const AValue: Single); - procedure SetSkewX(const AValue: Single); - procedure SetSubpixel(const AValue: Boolean); - procedure SetTypeface(AValue: ISkTypeface); - function UnicharToGlyph(const AUnichar: Integer): Word; - function UnicharsToGlyphs(const AUnichars: TArray): TArray; - class procedure path_proc(const path: sk_path_t; const matrix: psk_matrix_t; context: Pointer); cdecl; static; - public - constructor Create(ATypeface: ISkTypeface = nil; const ASize: Single = 12; const AScaleX: Single = 1; const ASkewX: Single = 0); overload; - constructor Create(const AFont: ISkFont); overload; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkFont(...) __SkCreate(TSkFont, ISkFont, __VA_ARGS__)'} - - { ISkImage } - - ISkImage = interface(ISkReferenceCounted) - ['{E10DF07F-583F-4700-B14F-4DA7433FFB0F}'] - function Encode(const AEncodedImageFormat: TSkEncodedImageFormat = TSkEncodedImageFormat.PNG; const AQuality: Integer = 80): TBytes; - function EncodeToFile(const AFileName: string; const AQuality: Integer = 80): Boolean; overload; - function EncodeToFile(const AFileName: string; const AEncodedImageFormat: TSkEncodedImageFormat; const AQuality: Integer = 80): Boolean; overload; - function EncodeToStream(const AStream: TStream; const AEncodedImageFormat: TSkEncodedImageFormat = TSkEncodedImageFormat.PNG; const AQuality: Integer = 80): Boolean; - function GetAlphaType: TSkAlphaType; - function GetColorSpace: ISkColorSpace; - function GetColorType: TSkColorType; - function GetHeight: Integer; - function GetImageInfo: TSkImageInfo; - function GetUniqueId: NativeUInt; - function GetWidth: Integer; - function IsAlphaOnly: Boolean; - function IsLazyGenerated: Boolean; - function IsOpaque: Boolean; - function IsTextureBacked: Boolean; - function IsValid(AContext: IGrDirectContext = nil): Boolean; - function MakeNonTextureImage: ISkImage; - function MakeRasterImage: ISkImage; - function MakeRawShader(const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeRawShader(const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeRawShader(const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeRawShader(const ALocalMatrix: TMatrix; const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeShader(const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeShader(const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeShader(const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeShader(const ALocalMatrix: TMatrix; const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeSubset(const ASubset: TRect; AContext: IGrDirectContext = nil): ISkImage; - function MakeTextureImage(const AContext: IGrDirectContext; const AIsMipmapped: Boolean = False): ISkImage; - function MakeWithFilter(const AFilter: ISkImageFilter; const ASubset, AClipBounds: TRect; out AOutSubset: TRect; out AOffset: TPoint; AContext: IGrDirectContext = nil): ISkImage; - function PeekPixels: ISkPixmap; - function ReadPixels(const ADest: ISkPixmap; const ASrcX: Integer = 0; const ASrcY: Integer = 0; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow; AContext: IGrDirectContext = nil): Boolean; overload; - function ReadPixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASrcX: Integer = 0; const ASrcY: Integer = 0; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow; AContext: IGrDirectContext = nil): Boolean; overload; - function ScalePixels(const ADest: ISkPixmap; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow): Boolean; overload; - function ScalePixels(const ADest: ISkPixmap; const ASampling: TSkSamplingOptions; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow): Boolean; overload; - function ScalePixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow): Boolean; overload; - function ScalePixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASampling: TSkSamplingOptions; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow): Boolean; overload; - property AlphaType: TSkAlphaType read GetAlphaType; - property ColorSpace: ISkColorSpace read GetColorSpace; - property ColorType: TSkColorType read GetColorType; - property Height: Integer read GetHeight; - property ImageInfo: TSkImageInfo read GetImageInfo; - property UniqueId: NativeUInt read GetUniqueId; - property Width: Integer read GetWidth; - end; - - { TSkImage } - - TSkImage = class(TSkReferenceCounted, ISkImage) - strict private - function Encode(const AEncodedImageFormat: TSkEncodedImageFormat = TSkEncodedImageFormat.PNG; const AQuality: Integer = 80): TBytes; - function EncodeToFile(const AFileName: string; const AQuality: Integer = 80): Boolean; overload; - function EncodeToFile(const AFileName: string; const AEncodedImageFormat: TSkEncodedImageFormat; const AQuality: Integer = 80): Boolean; overload; - function EncodeToStream(const AStream: TStream; const AEncodedImageFormat: TSkEncodedImageFormat = TSkEncodedImageFormat.PNG; const AQuality: Integer = 80): Boolean; - function GetAlphaType: TSkAlphaType; - function GetColorSpace: ISkColorSpace; - function GetColorType: TSkColorType; - function GetHeight: Integer; - function GetImageInfo: TSkImageInfo; - function GetUniqueId: NativeUInt; - function GetWidth: Integer; - function IsAlphaOnly: Boolean; - function IsLazyGenerated: Boolean; - function IsOpaque: Boolean; - function IsTextureBacked: Boolean; - function IsValid(AContext: IGrDirectContext = nil): Boolean; - function MakeNonTextureImage: ISkImage; - function MakeRasterImage: ISkImage; - function MakeRawShader(const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeRawShader(const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeRawShader(const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeRawShader(const ALocalMatrix: TMatrix; const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeShader(const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeShader(const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeShader(const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeShader(const ALocalMatrix: TMatrix; const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - function MakeSubset(const ASubset: TRect; AContext: IGrDirectContext = nil): ISkImage; - function MakeTextureImage(const AContext: IGrDirectContext; const AIsMipmapped: Boolean = False): ISkImage; - function MakeWithFilter(const AFilter: ISkImageFilter; const ASubset, AClipBounds: TRect; out AOutSubset: TRect; out AOffset: TPoint; AContext: IGrDirectContext = nil): ISkImage; - function PeekPixels: ISkPixmap; - function ReadPixels(const ADest: ISkPixmap; const ASrcX: Integer = 0; const ASrcY: Integer = 0; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow; AContext: IGrDirectContext = nil): Boolean; overload; - function ReadPixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASrcX: Integer = 0; const ASrcY: Integer = 0; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow; AContext: IGrDirectContext = nil): Boolean; overload; - function ScalePixels(const ADest: ISkPixmap; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow): Boolean; overload; - function ScalePixels(const ADest: ISkPixmap; const ASampling: TSkSamplingOptions; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow): Boolean; overload; - function ScalePixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow): Boolean; overload; - function ScalePixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASampling: TSkSamplingOptions; const ACachingHint: TSkImageCachingHint = TSkImageCachingHint.Allow): Boolean; overload; - class procedure raster_release_proc(const pixels: Pointer; context: Pointer); cdecl; static; - class procedure texture_release_proc(context: Pointer); cdecl; static; - public - class function MakeCrossContext(const AContext: IGrDirectContext; const APixmap: ISkPixmap; const ABuildMips: Boolean; const ALimitToMaxTextureSize: Boolean = False): ISkImage; overload; static; - class function MakeCrossContext(const AContext: IGrDirectContext; const AImageInfo: TSkImageInfo; const APixels: Pointer; const ARowBytes: NativeUInt; const ABuildMips: Boolean; const ALimitToMaxTextureSize: Boolean = False): ISkImage; overload; static; inline; - class function MakeFromAdoptedTexture(const AContext: IGrDirectContext; const ATexture: IGrBackendTexture; const AOrigin: TGrSurfaceOrigin; AColorType: TSkColorType; const AAlphaType: TSkAlphaType = TSkAlphaType.Premul; AColorSpace: ISkColorSpace = nil): ISkImage; static; - class function MakeFromEncoded(const ABytes: TBytes): ISkImage; overload; static; - class function MakeFromEncodedFile(const AFileName: string): ISkImage; overload; static; - class function MakeFromEncodedStream(const AStream: TStream): ISkImage; overload; static; - class function MakeFromPicture(const APicture: ISkPicture; const ADimensions: TSize; const APaint: ISkPaint = nil; AColorSpace: ISkColorSpace = nil): ISkImage; overload; static; - class function MakeFromPicture(const APicture: ISkPicture; const ADimensions: TSize; const AMatrix: TMatrix; const APaint: ISkPaint = nil; AColorSpace: ISkColorSpace = nil): ISkImage; overload; static; - class function MakeFromPicture(const APicture: ISkPicture; const ADimensions: TSize; const AProperties: TSkSurfaceProperties; const APaint: ISkPaint = nil; AColorSpace: ISkColorSpace = nil): ISkImage; overload; static; - class function MakeFromPicture(const APicture: ISkPicture; const ADimensions: TSize; const AMatrix: TMatrix; const AProperties: TSkSurfaceProperties; const APaint: ISkPaint = nil; AColorSpace: ISkColorSpace = nil): ISkImage; overload; static; - class function MakeFromRaster(const APixmap: ISkPixmap; const ARasterReleaseProc: TSkImageRasterReleaseProc = nil): ISkImage; overload; static; - class function MakeFromRaster(const AImageInfo: TSkImageInfo; const APixels: Pointer; const ARowBytes: NativeUInt; const ARasterReleaseProc: TSkImageRasterReleaseProc = nil): ISkImage; overload; static; inline; - class function MakeFromTexture(const AContext: IGrDirectContext; const ATexture: IGrBackendTexture; const AOrigin: TGrSurfaceOrigin; AColorType: TSkColorType; const AAlphaType: TSkAlphaType = TSkAlphaType.Premul; AColorSpace: ISkColorSpace = nil; const ATextureReleaseProc: TSkImageTextureReleaseProc = nil): ISkImage; static; - class function MakeRasterCopy(const APixmap: ISkPixmap): ISkImage; overload; static; - class function MakeRasterCopy(const AImageInfo: TSkImageInfo; const APixels: Pointer; const ARowBytes: NativeUInt): ISkImage; overload; static; inline; - end; - - { ISkImageFilter } - - ISkImageFilter = interface(ISkReferenceCounted) - ['{C3156B37-98A5-489F-BFB7-C0EB5DDDEDB6}'] - function MakeWithLocalMatrix(const AMatrix: TMatrix): ISkImageFilter; - end; - - { TSkImageFilter } - - TSkImageFilter = class(TSkReferenceCounted, ISkImageFilter) - strict private - function MakeWithLocalMatrix(const AMatrix: TMatrix): ISkImageFilter; - public - class function MakeAlphaThreshold(const ARegion: TRect; const AInnerMin, AOuterMax: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; inline; - class function MakeAlphaThreshold(const ARegion: ISkRegion; const AInnerMin, AOuterMax: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeArithmetic(const AK1, AK2, AK3, AK4: Single; const AEnforcePremultipliedColor: Boolean; const ABackground: ISkImageFilter; AForeground: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeArithmetic(const AK1, AK2, AK3, AK4: Single; const AEnforcePremultipliedColor: Boolean; const ABackground: ISkImageFilter; const ACropRect: TRectF; AForeground: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeBlend(const AMode: TSkBlendMode; const ABackground: ISkImageFilter; AForeground: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeBlend(const AMode: TSkBlendMode; const ABackground: ISkImageFilter; const ACropRect: TRectF; AForeground: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeBlur(const ASigmaX, ASigmaY: Single; AInput: ISkImageFilter = nil; const ATileMode: TSkTileMode = TSkTileMode.Decal): ISkImageFilter; overload; static; - class function MakeBlur(const ASigmaX, ASigmaY: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil; const ATileMode: TSkTileMode = TSkTileMode.Decal): ISkImageFilter; overload; static; - class function MakeColorFilter(const AColorFilter: ISkColorFilter; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeColorFilter(const AColorFilter: ISkColorFilter; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeCompose(const AOuter, AInner: ISkImageFilter): ISkImageFilter; static; - class function MakeDilate(const ARadiusX, ARadiusY: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDilate(const ARadiusX, ARadiusY: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDisplacementMap(const AXChannelSelector, AYChannelSelector: TSkColorChannel; const AScale: Single; const ADisplacement: ISkImageFilter; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDisplacementMap(const AXChannelSelector, AYChannelSelector: TSkColorChannel; const AScale: Single; const ADisplacement: ISkImageFilter; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDistantLitDiffuse(const ADirection: TPoint3D; const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDistantLitDiffuse(const ADirection: TPoint3D; const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDistantLitSpecular(const ADirection: TPoint3D; const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDistantLitSpecular(const ADirection: TPoint3D; const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDropShadow(const ADeltaX, ADeltaY, ASigmaX, ASigmaY: Single; const AColor: TAlphaColor; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDropShadow(const ADeltaX, ADeltaY, ASigmaX, ASigmaY: Single; const AColor: TAlphaColor; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDropShadowOnly(const ADeltaX, ADeltaY, ASigmaX, ASigmaY: Single; const AColor: TAlphaColor; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeDropShadowOnly(const ADeltaX, ADeltaY, ASigmaX, ASigmaY: Single; const AColor: TAlphaColor; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeErode(const ARadiusX, ARadiusY: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeErode(const ARadiusX, ARadiusY: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeImage(const AImage: ISkImage): ISkImageFilter; overload; static; inline; - class function MakeImage(const AImage: ISkImage; const ASampling: TSkSamplingOptions): ISkImageFilter; overload; static; inline; - class function MakeImage(const AImage: ISkImage; const ASrc, ADest: TRectF): ISkImageFilter; overload; static; inline; - class function MakeImage(const AImage: ISkImage; const ASrc, ADest: TRectF; const ASampling: TSkSamplingOptions): ISkImageFilter; overload; static; - class function MakeMagnifier(const ASrc: TRectF; const AInset: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeMagnifier(const ASrc: TRectF; const AInset: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeMatrixConvolution(const AKernelSize: TSize; const AKernel: TArray; const AGain, ABias: Single; const AKernelOffset: TPoint; const ATileMode: TSkTileMode; const AConvolveAlpha: Boolean; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeMatrixConvolution(const AKernelSize: TSize; const AKernel: TArray; const AGain, ABias: Single; const AKernelOffset: TPoint; const ATileMode: TSkTileMode; const AConvolveAlpha: Boolean; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeMatrixTransform(const AMatrix: TMatrix; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; inline; - class function MakeMatrixTransform(const AMatrix: TMatrix; const ASampling: TSkSamplingOptions; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeMerge(const AFilter1, AFilter2: ISkImageFilter): ISkImageFilter; overload; static; inline; - class function MakeMerge(const AFilter1, AFilter2: ISkImageFilter; const ACropRect: TRectF): ISkImageFilter; overload; static; inline; - class function MakeMerge(const AFilters: TArray): ISkImageFilter; overload; static; - class function MakeMerge(const AFilters: TArray; const ACropRect: TRectF): ISkImageFilter; overload; static; - class function MakeOffset(const ADeltaX, ADeltaY: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeOffset(const ADeltaX, ADeltaY: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakePicture(const APicture: ISkPicture): ISkImageFilter; overload; static; - class function MakePicture(const APicture: ISkPicture; const ACropRect: TRectF): ISkImageFilter; overload; static; - class function MakePointLitDiffuse(const ALocation: TPoint3D; const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakePointLitDiffuse(const ALocation: TPoint3D; const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakePointLitSpecular(const ALocation: TPoint3D; const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakePointLitSpecular(const ALocation: TPoint3D; const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeShader(const AShader: ISkShader; const ADither: Boolean): ISkImageFilter; overload; static; - class function MakeShader(const AShader: ISkShader; const ADither: Boolean; const ACropRect: TRectF): ISkImageFilter; overload; static; - class function MakeSpotLitDiffuse(const ALocation, ATarget: TPoint3D; const AFalloffExponent, ACutoffAngle: Single; const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeSpotLitDiffuse(const ALocation, ATarget: TPoint3D; const AFalloffExponent, ACutoffAngle: Single; const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeSpotLitSpecular(const ALocation, ATarget: TPoint3D; const AFalloffExponent, ACutoffAngle: Single; const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeSpotLitSpecular(const ALocation, ATarget: TPoint3D; const AFalloffExponent, ACutoffAngle: Single; const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; const ACropRect: TRectF; AInput: ISkImageFilter = nil): ISkImageFilter; overload; static; - class function MakeTile(const ASrc, ADest: TRect; AInput: ISkImageFilter = nil): ISkImageFilter; static; - end; - - { ISkMaskFilter } - - ISkMaskFilter = interface(ISkReferenceCounted) - ['{BBA0BC39-23F1-43B2-A924-526E7D089CAF}'] - end; - - { TSkMaskFilter } - - TSkMaskFilter = class(TSkReferenceCounted, ISkMaskFilter) - public - class function MakeBlur(const AStyle: TSkBlurStyle; const ASigma: Single; const ARespectCTM: Boolean = True): ISkMaskFilter; static; - class function MakeShader(const AShader: ISkShader): ISkMaskFilter; static; - class function MakeTable(const ATable: TSkTableFilter): ISkMaskFilter; static; - class function MakeTableClip(const AMin, AMax: Byte): ISkMaskFilter; static; - class function MakeTableGamma(const AGamma: Single): ISkMaskFilter; static; - end; - - { ISkPaint } - - ISkPaint = interface(ISkObject) - ['{C95825F8-0D51-4BCE-8945-84AFE6264213}'] - function GetAlpha: Byte; - function GetAlphaF: Single; - function GetAntiAlias: Boolean; - function GetBlender: ISkBlender; - function GetColor: TAlphaColor; - function GetColorF: TAlphaColorF; - function GetColorFilter: ISkColorFilter; - function GetDither: Boolean; - function GetFillPath(const APath: ISkPath): ISkPath; overload; - function GetFillPath(const APath: ISkPath; const ACullRect: TRectF; const AResScale: Single = 1): ISkPath; overload; - function GetImageFilter: ISkImageFilter; - function GetMaskFilter: ISkMaskFilter; - function GetPathEffect: ISkPathEffect; - function GetShader: ISkShader; - function GetStrokeCap: TSkStrokeCap; - function GetStrokeJoin: TSkStrokeJoin; - function GetStrokeMiter: Single; - function GetStrokeWidth: Single; - function GetStyle: TSkPaintStyle; - procedure Reset; - procedure SetAlpha(const AValue: Byte); - procedure SetAlphaF(const AValue: Single); - procedure SetAntiAlias(const AValue: Boolean); - procedure SetARGB(const A, R, G, B: Byte); - procedure SetBlender(AValue: ISkBlender); - procedure SetColor(const AValue: TAlphaColor); - procedure SetColorF(const AValue: TAlphaColorF; AColorSpace: ISkColorSpace = nil); - procedure SetColorFilter(AValue: ISkColorFilter); - procedure SetDither(const AValue: Boolean); - procedure SetImageFilter(AValue: ISkImageFilter); - procedure SetMaskFilter(AValue: ISkMaskFilter); - procedure SetPathEffect(AValue: ISkPathEffect); - procedure SetShader(AValue: ISkShader); - procedure SetStrokeCap(const AValue: TSkStrokeCap); - procedure SetStrokeJoin(const AValue: TSkStrokeJoin); - procedure SetStrokeMiter(const AValue: Single); - procedure SetStrokeWidth(const AValue: Single); - procedure SetStyle(const AValue: TSkPaintStyle); - property Alpha: Byte read GetAlpha write SetAlpha; - property AlphaF: Single read GetAlphaF write SetAlphaF; - property AntiAlias: Boolean read GetAntiAlias write SetAntiAlias; - property Blender: ISkBlender read GetBlender write SetBlender; - property Color: TAlphaColor read GetColor write SetColor; - property ColorFilter: ISkColorFilter read GetColorFilter write SetColorFilter; - property Dither: Boolean read GetDither write SetDither; - property ImageFilter: ISkImageFilter read GetImageFilter write SetImageFilter; - property MaskFilter: ISkMaskFilter read GetMaskFilter write SetMaskFilter; - property PathEffect: ISkPathEffect read GetPathEffect write SetPathEffect; - property Shader: ISkShader read GetShader write SetShader; - property StrokeCap: TSkStrokeCap read GetStrokeCap write SetStrokeCap; - property StrokeJoin: TSkStrokeJoin read GetStrokeJoin write SetStrokeJoin; - property StrokeMiter: Single read GetStrokeMiter write SetStrokeMiter; - property StrokeWidth: Single read GetStrokeWidth write SetStrokeWidth; - property Style: TSkPaintStyle read GetStyle write SetStyle; - end; - - { TSkPaint } - - TSkPaint = class(TSkObject, ISkPaint) - strict private - function GetAlpha: Byte; - function GetAlphaF: Single; - function GetAntiAlias: Boolean; - function GetBlender: ISkBlender; - function GetColor: TAlphaColor; - function GetColorF: TAlphaColorF; - function GetColorFilter: ISkColorFilter; - function GetDither: Boolean; - function GetFillPath(const APath: ISkPath): ISkPath; overload; - function GetFillPath(const APath: ISkPath; const ACullRect: TRectF; const AResScale: Single = 1): ISkPath; overload; - function GetImageFilter: ISkImageFilter; - function GetMaskFilter: ISkMaskFilter; - function GetPathEffect: ISkPathEffect; - function GetShader: ISkShader; - function GetStrokeCap: TSkStrokeCap; - function GetStrokeJoin: TSkStrokeJoin; - function GetStrokeMiter: Single; - function GetStrokeWidth: Single; - function GetStyle: TSkPaintStyle; - procedure Reset; - procedure SetAlpha(const AValue: Byte); - procedure SetAlphaF(const AValue: Single); - procedure SetAntiAlias(const AValue: Boolean); - procedure SetARGB(const A, R, G, B: Byte); - procedure SetBlender(AValue: ISkBlender); - procedure SetColor(const AValue: TAlphaColor); - procedure SetColorF(const AValue: TAlphaColorF; AColorSpace: ISkColorSpace = nil); - procedure SetColorFilter(AValue: ISkColorFilter); - procedure SetDither(const AValue: Boolean); - procedure SetImageFilter(AValue: ISkImageFilter); - procedure SetMaskFilter(AValue: ISkMaskFilter); - procedure SetPathEffect(AValue: ISkPathEffect); - procedure SetShader(AValue: ISkShader); - procedure SetStrokeCap(const AValue: TSkStrokeCap); - procedure SetStrokeJoin(const AValue: TSkStrokeJoin); - procedure SetStrokeMiter(const AValue: Single); - procedure SetStrokeWidth(const AValue: Single); - procedure SetStyle(const AValue: TSkPaintStyle); - public - constructor Create; overload; - constructor Create(const APaint: ISkPaint); overload; - constructor Create(const AStyle: TSkPaintStyle); overload; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkPaint(...) __SkCreate(TSkPaint, ISkPaint, __VA_ARGS__)'} - - { ISkOpBuilder } - - ISkOpBuilder = interface(ISkObject) - ['{A0F0AB29-477D-4AA2-A4AD-4AEBC3C6D630}'] - procedure Add(const APath: ISkPath; const AOp: TSkPathOp); - function Detach: ISkPath; - end; - - { TSkOpBuilder } - - TSkOpBuilder = class(TSkObject, ISkOpBuilder) - strict private - procedure Add(const APath: ISkPath; const AOp: TSkPathOp); - function Detach: ISkPath; - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkOpBuilder(...) __SkCreate(TSkOpBuilder, ISkOpBuilder, __VA_ARGS__)'} - - { ISkPathIterator } - - ISkPathIterator = interface(ISkEnumerable) - ['{AD3EC8F2-01C0-4685-B098-6850AEA6D8A6}'] - function GetCurrent: TSkPathIteratorElem; - function GetEnumerator: TSkEnumerator; - end; - - { ISkPath } - - ISkPath = interface(ISkObject) - ['{0801E1D4-5426-4B7E-A3CD-9B40B21C26F0}'] - function Contains(const AX, AY: Single): Boolean; - function GetBounds: TRectF; - function GetFillType: TSkPathFillType; - function GetIterator(const AForceClose: Boolean): ISkPathIterator; - function GetLastPoint: TPointF; - function GetSegmentMasks: TSkSegmentMasks; - function GetTightBounds: TRectF; - function Interpolate(const AEnding: ISkPath; const AWeight: Single): ISkPath; - function IsConvex: Boolean; - function IsEmpty: Boolean; - function IsFinite: Boolean; - function IsInterpolatable(const APath: ISkPath): Boolean; - function IsLastContourClosed: Boolean; - function IsLine: Boolean; overload; - function IsLine(out APoint1, APoint2: TPointF): Boolean; overload; - function IsOval: Boolean; overload; - function IsOval(out ARect: TRectF): Boolean; overload; - function IsRect: Boolean; overload; - function IsRect(out ARect: TRectF): Boolean; overload; - function IsRoundRect: Boolean; overload; - function IsRoundRect(out ARoundRect: ISkRoundRect): Boolean; overload; - function Op(const APath: ISkPath; const AOp: TSkPathOp): ISkPath; - function Serialize: TBytes; - procedure SerializeToStream(const AStream: TStream); - function ToSVG: string; - function Transform(const AMatrix: TMatrix): ISkPath; - property Bounds: TRectF read GetBounds; - property FillType: TSkPathFillType read GetFillType; - property LastPoint: TPointF read GetLastPoint; - property SegmentMasks: TSkSegmentMasks read GetSegmentMasks; - property TightBounds: TRectF read GetTightBounds; - end; - - { TSkPath } - - TSkPath = class(TSkObject, ISkPath) - strict private type - TPathIterator = class(TSkEnumerable, ISkPathIterator) - strict private - FCurrent: TSkPathIteratorElem; - public - constructor Create(const APath: ISkPath; const AForceClose: Boolean); - function GetCurrent: TSkPathIteratorElem; override; - function MoveNext: Boolean; override; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - strict private - function Contains(const AX, AY: Single): Boolean; - function GetBounds: TRectF; - function GetFillType: TSkPathFillType; - function GetIterator(const AForceClose: Boolean): ISkPathIterator; - function GetLastPoint: TPointF; - function GetSegmentMasks: TSkSegmentMasks; - function GetTightBounds: TRectF; - function Interpolate(const AEnding: ISkPath; const AWeight: Single): ISkPath; - function IsConvex: Boolean; - function IsEmpty: Boolean; - function IsFinite: Boolean; - function IsInterpolatable(const APath: ISkPath): Boolean; - function IsLastContourClosed: Boolean; - function IsLine: Boolean; overload; - function IsLine(out APoint1, APoint2: TPointF): Boolean; overload; - function IsOval: Boolean; overload; - function IsOval(out ARect: TRectF): Boolean; overload; - function IsRect: Boolean; overload; - function IsRect(out ARect: TRectF): Boolean; overload; - function IsRoundRect: Boolean; overload; - function IsRoundRect(out ARoundRect: ISkRoundRect): Boolean; overload; - function Op(const APath: ISkPath; const AOp: TSkPathOp): ISkPath; - function Serialize: TBytes; - procedure SerializeToStream(const AStream: TStream); - function ToSVG: string; - function Transform(const AMatrix: TMatrix): ISkPath; - public - constructor Create(const ASVG: string); overload; - constructor Create(const ABytes: TBytes); overload; - constructor Create(const AStream: TStream); overload; - class function ConvertConicToQuads(const APoint1, APoint2, APoint3: TPointF; const AWeight: Single; const APower2: Integer): TArray; static; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkPath(...) __SkCreate(TSkPath, ISkPath, __VA_ARGS__)'} - - { ISkPathBuilder } - - ISkPathBuilder = interface(ISkObject) - ['{F0976C6D-4474-4290-B9CD-22DB130F8EB5}'] - procedure AddArc(const AOval: TRectF; const AStartAngle, ASweepAngle: Single); - procedure AddCircle(const ACenter: TPointF; ARadius: Single; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddCircle(const ACenterX, ACenterY, ARadius: Single; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddOval(const ARect: TRectF; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddOval(const ARect: TRectF; ADirection: TSkPathDirection; AStartIndex: Cardinal); overload; - procedure AddPath(const APath: ISkPath); - procedure AddPolygon(const APolygon: TPolygon; const IsClosed: Boolean); - procedure AddRect(const ARect: TRectF; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddRect(const ARect: TRectF; ADirection: TSkPathDirection; AStartIndex: Cardinal); overload; - procedure AddRoundRect(const ARoundRect: ISkRoundRect; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddRoundRect(const ARoundRect: ISkRoundRect; ADirection: TSkPathDirection; AStartIndex: Cardinal); overload; - procedure ArcTo(const APoint1, APoint2: TPointF; const ARadius: Single); overload; - procedure ArcTo(const AOval: TRectF; const AStartAngle, ASweepAngle: Single; const AForceMoveTo: Boolean); overload; - procedure ArcTo(const ARadius: TPointF; const XAxisRotate: Single; const ALargeArc: TSkPathArcSize; const ASweep: TSkPathDirection; const AXY: TPointF); overload; - procedure Close; - procedure ConicTo(const APoint1, APoint2: TPointF; const AWeight: Single); overload; - procedure ConicTo(const AX1, AY1, AX2, AY2, AWeight: Single); overload; - procedure CubicTo(const APoint1, APoint2, APoint3: TPointF); overload; - procedure CubicTo(const AX1, AY1, AX2, AY2, AX3, AY3: Single); overload; - function Detach: ISkPath; - function GetBounds: TRectF; - function GetFillType: TSkPathFillType; - procedure IncReserve(const AExtraPointCount: Integer); overload; - procedure IncReserve(const AExtraPointCount, AExtraVerbCount: Integer); overload; - procedure LineTo(const APoint: TPointF); overload; - procedure LineTo(const AX, AY: Single); overload; - procedure MoveTo(const APoint: TPointF); overload; - procedure MoveTo(const AX, AY: Single); overload; - procedure Offset(const ADeltaX, ADeltaY: Single); - procedure PolylineTo(const APoints: TArray); - procedure QuadTo(const APoint1, APoint2: TPointF); overload; - procedure QuadTo(const AX1, AY1, AX2, AY2: Single); overload; - procedure RConicTo(const APoint1, APoint2: TPointF; const AWeight: Single); overload; - procedure RConicTo(const AX1, AY1, AX2, AY2, AWeight: Single); overload; - procedure RCubicTo(const APoint1, APoint2, APoint3: TPointF); overload; - procedure RCubicTo(const AX1, AY1, AX2, AY2, AX3, AY3: Single); overload; - procedure Reset; - procedure RLineTo(const APoint: TPointF); overload; - procedure RLineTo(const AX, AY: Single); overload; - procedure RQuadTo(const APoint1, APoint2: TPointF); overload; - procedure RQuadTo(const AX1, AY1, AX2, AY2: Single); overload; - procedure SetFillType(const AValue: TSkPathFillType); - function Snapshot: ISkPath; - procedure ToggleInverseFillType; - property Bounds: TRectF read GetBounds; - property FillType: TSkPathFillType read GetFillType write SetFillType; - end; - - { TSkPathBuilder } - - TSkPathBuilder = class(TSkObject, ISkPathBuilder) - strict private - procedure AddArc(const AOval: TRectF; const AStartAngle, ASweepAngle: Single); - procedure AddCircle(const ACenter: TPointF; ARadius: Single; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddCircle(const ACenterX, ACenterY, ARadius: Single; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddOval(const ARect: TRectF; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddOval(const ARect: TRectF; ADirection: TSkPathDirection; AStartIndex: Cardinal); overload; - procedure AddPath(const APath: ISkPath); - procedure AddPolygon(const APolygon: TPolygon; const IsClosed: Boolean); - procedure AddRect(const ARect: TRectF; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddRect(const ARect: TRectF; ADirection: TSkPathDirection; AStartIndex: Cardinal); overload; - procedure AddRoundRect(const ARoundRect: ISkRoundRect; ADirection: TSkPathDirection = TSkPathDirection.CW); overload; - procedure AddRoundRect(const ARoundRect: ISkRoundRect; ADirection: TSkPathDirection; AStartIndex: Cardinal); overload; - procedure ArcTo(const APoint1, APoint2: TPointF; const ARadius: Single); overload; - procedure ArcTo(const AOval: TRectF; const AStartAngle, ASweepAngle: Single; const AForceMoveTo: Boolean); overload; - procedure ArcTo(const ARadius: TPointF; const XAxisRotate: Single; const ALargeArc: TSkPathArcSize; const ASweep: TSkPathDirection; const AXY: TPointF); overload; - procedure Close; - procedure ConicTo(const APoint1, APoint2: TPointF; const AWeight: Single); overload; - procedure ConicTo(const AX1, AY1, AX2, AY2, AWeight: Single); overload; - procedure CubicTo(const APoint1, APoint2, APoint3: TPointF); overload; - procedure CubicTo(const AX1, AY1, AX2, AY2, AX3, AY3: Single); overload; - function Detach: ISkPath; - function GetBounds: TRectF; - function GetFillType: TSkPathFillType; - procedure IncReserve(const AExtraPointCount: Integer); overload; - procedure IncReserve(const AExtraPointCount, AExtraVerbCount: Integer); overload; - procedure LineTo(const APoint: TPointF); overload; - procedure LineTo(const AX, AY: Single); overload; - procedure MoveTo(const APoint: TPointF); overload; - procedure MoveTo(const AX, AY: Single); overload; - procedure Offset(const ADeltaX, ADeltaY: Single); - procedure PolylineTo(const APoints: TArray); - procedure QuadTo(const APoint1, APoint2: TPointF); overload; - procedure QuadTo(const AX1, AY1, AX2, AY2: Single); overload; - procedure RConicTo(const APoint1, APoint2: TPointF; const AWeight: Single); overload; - procedure RConicTo(const AX1, AY1, AX2, AY2, AWeight: Single); overload; - procedure RCubicTo(const APoint1, APoint2, APoint3: TPointF); overload; - procedure RCubicTo(const AX1, AY1, AX2, AY2, AX3, AY3: Single); overload; - procedure Reset; - procedure RLineTo(const APoint: TPointF); overload; - procedure RLineTo(const AX, AY: Single); overload; - procedure RQuadTo(const APoint1, APoint2: TPointF); overload; - procedure RQuadTo(const AX1, AY1, AX2, AY2: Single); overload; - procedure SetFillType(const AValue: TSkPathFillType); - function Snapshot: ISkPath; - procedure ToggleInverseFillType; - public - constructor Create; overload; - constructor Create(const APathBuilder: ISkPathBuilder); overload; - constructor Create(const AFillType: TSkPathFillType); overload; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkPathBuilder(...) __SkCreate(TSkPathBuilder, ISkPathBuilder, __VA_ARGS__)'} - - { ISkPathEffect } - - ISkPathEffect = interface(ISkReferenceCounted) - ['{6229C1C7-5DBB-4525-B9B8-9E50F644AB3F}'] - end; - - { TSkPathEffect } - - TSkPathEffect = class(TSkReferenceCounted, ISkPathEffect) - public - class function Make1DPath(const APath: ISkPath; const AAdvance, APhase: Single; const AStyle: TSkPathEffect1DStyle): ISkPathEffect; static; - class function Make2DLine(const AWidth: Single; const AMatrix: TMatrix): ISkPathEffect; static; - class function Make2DPath(const AMatrix: TMatrix; const APath: ISkPath): ISkPathEffect; static; - class function MakeCompose(const AOuter, AInner: ISkPathEffect): ISkPathEffect; static; - class function MakeCorner(const ARadius: Single): ISkPathEffect; static; - class function MakeDash(const AIntervals: TArray; const APhase: Single): ISkPathEffect; static; - class function MakeDiscrete(const ASegLength, ADeviation: Single; const ASeedAssist: Cardinal = 0): ISkPathEffect; static; - class function MakeMatrix(const AMatrix: TMatrix): ISkPathEffect; static; - class function MakeMerge(const AEffect1, AEffect2: ISkPathEffect; const AOp: TSkPathOp): ISkPathEffect; static; - class function MakeStroke(const AWidth: Single; const AJoin: TSkStrokeJoin; const ACap: TSkStrokeCap; const AMiter: Single = 4): ISkPathEffect; static; - class function MakeStrokeAndFill: ISkPathEffect; static; - class function MakeSum(const AEffect1, AEffect2: ISkPathEffect): ISkPathEffect; static; - class function MakeTranslate(const ADeltaX, ADeltaY: Single): ISkPathEffect; static; - class function MakeTrim(const AStart, AStop: Single; const AMode: TSkPathEffectTrimMode): ISkPathEffect; static; - end; - - { ISkPathMeasure } - - ISkPathMeasure = interface(ISkObject) - ['{33A4DFAF-069C-44BE-8AEF-333B88187B78}'] - function GetLength: Single; - function GetMatrix(const ADistance: Single; out AMatrix: TMatrix; const AMatrixFlags: TSkPathMeasureMatrixFlags = [TSkPathMeasureMatrixFlag.Position, TSkPathMeasureMatrixFlag.Tangent]): Boolean; - function GetPositionAndTangent(const ADistance: Single; out APosition, ATangent: TPointF): Boolean; - function GetSegment(const AStart, AStop: Single; const AStartWithMoveTo: Boolean): ISkPath; - function IsClosed: Boolean; - function NextContour: Boolean; - property Length: Single read GetLength; - end; - - { TSkPathMeasure } - - TSkPathMeasure = class(TSkObject, ISkPathMeasure) - strict private - function GetLength: Single; - function GetMatrix(const ADistance: Single; out AMatrix: TMatrix; const AMatrixFlags: TSkPathMeasureMatrixFlags = [TSkPathMeasureMatrixFlag.Position, TSkPathMeasureMatrixFlag.Tangent]): Boolean; - function GetPositionAndTangent(const ADistance: Single; out APosition, ATangent: TPointF): Boolean; - function GetSegment(const AStart, AStop: Single; const AStartWithMoveTo: Boolean): ISkPath; - function IsClosed: Boolean; - function NextContour: Boolean; - public - constructor Create(const APath: ISkPath; const AForceClosed: Boolean = False; const AResScale: Single = 1); - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkPathMeasure(...) __SkCreate(TSkPathMeasure, ISkPathMeasure, __VA_ARGS__)'} - - { ISkPicture } - - ISkPicture = interface(ISkReferenceCounted) - ['{5FBF6D75-3A44-4012-AAC9-AD22E1C955D2}'] - function GetCullRect: TRectF; - function MakeShader(const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - function MakeShader(const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - function MakeShader(const ATileRect: TRectF; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - function MakeShader(const ATileRect: TRectF; const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - procedure Playback(const ACanvas: ISkCanvas); - function Serialize: TBytes; - procedure SerializeToStream(const AStream: TStream); - property CullRect: TRectF read GetCullRect; - end; - - { TSkPicture } - - TSkPicture = class(TSkReferenceCounted, ISkPicture) - strict private - function GetCullRect: TRectF; - function MakeShader(const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - function MakeShader(const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - function MakeShader(const ATileRect: TRectF; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - function MakeShader(const ATileRect: TRectF; const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - procedure Playback(const ACanvas: ISkCanvas); - function Serialize: TBytes; - procedure SerializeToStream(const AStream: TStream); - public - class function MakeFromBytes(const ABytes: TBytes): ISkPicture; static; - class function MakeFromStream(const AStream: TStream): ISkPicture; static; - end; - - { ISkPictureRecorder } - - ISkPictureRecorder = interface(ISkObject) - ['{46663FA5-57B9-4289-9381-0433E3A70EB9}'] - function BeginRecording(const AWidth, AHeight: Single): ISkCanvas; overload; - function BeginRecording(const ABounds: TRectF): ISkCanvas; overload; - function FinishRecording: ISkPicture; overload; - function FinishRecording(const ACullRect: TRectF): ISkPicture; overload; - end; - - { TSkPictureRecorder } - - TSkPictureRecorder = class(TSkObject, ISkPictureRecorder) - strict private - function BeginRecording(const AWidth, AHeight: Single): ISkCanvas; overload; - function BeginRecording(const ABounds: TRectF): ISkCanvas; overload; - function FinishRecording: ISkPicture; overload; - function FinishRecording(const ACullRect: TRectF): ISkPicture; overload; - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkPictureRecorder(...) __SkCreate(TSkPictureRecorder, ISkPictureRecorder, __VA_ARGS__)'} - - { ISkPixmap } - - ISkPixmap = interface(ISkObject) - ['{EFEDBF69-4C8D-4124-83A6-68A9B1DF239E}'] - function Erase(const AColor: TAlphaColor): Boolean; overload; - function Erase(const AColor: TAlphaColor; const ASubset: TRectF): Boolean; overload; - function Erase(const AColor: TAlphaColorF; AColorSpace: ISkColorSpace = nil): Boolean; overload; - function Erase(const AColor: TAlphaColorF; const ASubset: TRectF; AColorSpace: ISkColorSpace = nil): Boolean; overload; - function ExtractSubset(const ADest: ISkPixmap; const AArea: TRect): Boolean; - function GetAlpha(const AX, AY: Integer): Single; - function GetAlphaType: TSkAlphaType; - function GetColor(const AX, AY: Integer): TAlphaColor; - function GetColorF(const AX, AY: Integer): TAlphaColorF; - function GetColorSpace: ISkColorSpace; - function GetColorType: TSkColorType; - function GetHeight: Integer; - function GetImageInfo: TSkImageInfo; - function GetPixelAddr(const AX, AY: Integer): Pointer; - function GetPixels: Pointer; - function GetRowBytes: NativeUInt; - function GetWidth: Integer; - function ReadPixels(const ADest: ISkPixmap; const ASrcX: Integer = 0; const ASrcY: Integer = 0): Boolean; overload; - function ReadPixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASrcX: Integer = 0; const ASrcY: Integer = 0): Boolean; overload; - function ScalePixels(const ADest: ISkPixmap): Boolean; overload; - function ScalePixels(const ADest: ISkPixmap; const ASampling: TSkSamplingOptions): Boolean; overload; - function ScalePixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt): Boolean; overload; - function ScalePixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASampling: TSkSamplingOptions): Boolean; overload; - procedure SetColorSpace(AValue: ISkColorSpace); - property Alphas[const AX, AY: Integer]: Single read GetAlpha; - property AlphaType: TSkAlphaType read GetAlphaType; - property Colors[const AX, AY: Integer]: TAlphaColor read GetColor; - property ColorsF[const AX, AY: Integer]: TAlphaColorF read GetColorF; - property ColorSpace: ISkColorSpace read GetColorSpace write SetColorSpace; - property ColorType: TSkColorType read GetColorType; - property Height: Integer read GetHeight; - property ImageInfo: TSkImageInfo read GetImageInfo; - property PixelAddr[const AX, AY: Integer]: Pointer read GetPixelAddr; - property Pixels: Pointer read GetPixels; - property RowBytes: NativeUInt read GetRowBytes; - property Width: Integer read GetWidth; - end; - - { TSkPixmap } - - TSkPixmap = class(TSkObject, ISkPixmap) - strict private - function Erase(const AColor: TAlphaColor): Boolean; overload; - function Erase(const AColor: TAlphaColor; const ASubset: TRectF): Boolean; overload; - function Erase(const AColor: TAlphaColorF; AColorSpace: ISkColorSpace = nil): Boolean; overload; - function Erase(const AColor: TAlphaColorF; const ASubset: TRectF; AColorSpace: ISkColorSpace = nil): Boolean; overload; - function ExtractSubset(const ADest: ISkPixmap; const AArea: TRect): Boolean; - function GetAlpha(const AX, AY: Integer): Single; - function GetAlphaType: TSkAlphaType; - function GetColor(const AX, AY: Integer): TAlphaColor; - function GetColorF(const AX, AY: Integer): TAlphaColorF; - function GetColorSpace: ISkColorSpace; - function GetColorType: TSkColorType; - function GetHeight: Integer; - function GetImageInfo: TSkImageInfo; - function GetPixelAddr(const AX, AY: Integer): Pointer; - function GetPixels: Pointer; - function GetRowBytes: NativeUInt; - function GetWidth: Integer; - function ReadPixels(const ADest: ISkPixmap; const ASrcX: Integer = 0; const ASrcY: Integer = 0): Boolean; overload; - function ReadPixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASrcX: Integer = 0; const ASrcY: Integer = 0): Boolean; overload; - function ScalePixels(const ADest: ISkPixmap): Boolean; overload; - function ScalePixels(const ADest: ISkPixmap; const ASampling: TSkSamplingOptions): Boolean; overload; - function ScalePixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt): Boolean; overload; - function ScalePixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASampling: TSkSamplingOptions): Boolean; overload; - procedure SetColorSpace(AValue: ISkColorSpace); - public - constructor Create(const AImageInfo: TSkImageInfo; const APixels: Pointer; const ARowBytes: NativeUInt); - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkPixmap(...) __SkCreate(TSkPixmap, ISkPixmap, __VA_ARGS__)'} - - { ISkRegionCliperator } - - ISkRegionCliperator = interface(ISkEnumerable) - ['{2A8DA4E7-1B52-4311-9398-E3A93BACDB02}'] - function GetCurrent: TRect; - function GetEnumerator: TSkEnumerator; - end; - - { ISkRegionIterator } - - ISkRegionIterator = interface(ISkEnumerable) - ['{2A0AC6C3-6101-4A9C-83BE-8F56B67F4239}'] - function GetCurrent: TRect; - function GetEnumerator: TSkEnumerator; - end; - - { ISkRegionSpanerator } - - ISkRegionSpanerator = interface(ISkEnumerable) - ['{E6980A05-9F49-4B3E-BD03-7A305C69B9AE}'] - function GetCurrent: TPoint; - function GetEnumerator: TSkEnumerator; - end; - - { ISkRegion } - - ISkRegion = interface(ISkObject) - ['{9ED1C7B2-BF4E-4E4E-9A69-DDDB615C0319}'] - function Contains(const AX, AY: Integer): Boolean; overload; - function Contains(const ARect: TRect): Boolean; overload; - function Contains(const ARegion: ISkRegion): Boolean; overload; - function GetBoundaryPath: ISkPath; - function GetBounds: TRect; - function GetCliperator(const AClip: TRect): ISkRegionCliperator; - function GetIterator: ISkRegionIterator; - function GetSpanerator(const AY, ALeft, ARight: Integer): ISkRegionSpanerator; - function Intersects(const ARect: TRect): Boolean; overload; - function Intersects(const ARegion: ISkRegion): Boolean; overload; - function IsComplex: Boolean; - function IsEmpty: Boolean; - function IsEqual(const ARegion: ISkRegion): Boolean; - function IsRect: Boolean; - function Op(const ARect: TRect; const AOp: TSkRegionOp): Boolean; overload; - function Op(const ARegion: ISkRegion; const AOp: TSkRegionOp): Boolean; overload; - function QuickContains(const ARect: TRect): Boolean; - function QuickReject(const ARect: TRect): Boolean; overload; - function QuickReject(const ARegion: ISkRegion): Boolean; overload; - procedure SetEmpty; - function SetPath(const APath: ISkPath; const AClip: ISkRegion): Boolean; - function SetRect(const ARect: TRect): Boolean; - function SetRects(const ARects: TArray): Boolean; - procedure Translate(const ADeltaX, ADeltaY: Integer); - property Bounds: TRect read GetBounds; - end; - - { TSkRegion } - - TSkRegion = class(TSkObject, ISkRegion) - strict private type - TRegionCliperator = class(TSkEnumerable, ISkRegionCliperator) - public - constructor Create(const ARegion: ISkRegion; const AClip: TRect); - function GetCurrent: TRect; override; - function MoveNext: Boolean; override; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - TRegionIterator = class(TSkEnumerable, ISkRegionIterator) - public - constructor Create(const ARegion: ISkRegion); - function GetCurrent: TRect; override; - function MoveNext: Boolean; override; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - TRegionSpanerator = class(TSkEnumerable, ISkRegionSpanerator) - strict private - FCurrent: TPoint; - public - constructor Create(const ARegion: ISkRegion; const AY, ALeft, ARight: Integer); - function GetCurrent: TPoint; override; - function MoveNext: Boolean; override; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - strict private - function Contains(const AX, AY: Integer): Boolean; overload; - function Contains(const ARect: TRect): Boolean; overload; - function Contains(const ARegion: ISkRegion): Boolean; overload; - function GetBoundaryPath: ISkPath; - function GetBounds: TRect; - function GetCliperator(const AClip: TRect): ISkRegionCliperator; - function GetIterator: ISkRegionIterator; - function GetSpanerator(const AY, ALeft, ARight: Integer): ISkRegionSpanerator; - function Intersects(const ARect: TRect): Boolean; overload; - function Intersects(const ARegion: ISkRegion): Boolean; overload; - function IsComplex: Boolean; - function IsEmpty: Boolean; - function IsEqual(const ARegion: ISkRegion): Boolean; - function IsRect: Boolean; - function Op(const ARect: TRect; const AOp: TSkRegionOp): Boolean; overload; - function Op(const ARegion: ISkRegion; const AOp: TSkRegionOp): Boolean; overload; - function QuickContains(const ARect: TRect): Boolean; - function QuickReject(const ARect: TRect): Boolean; overload; - function QuickReject(const ARegion: ISkRegion): Boolean; overload; - procedure SetEmpty; - function SetPath(const APath: ISkPath; const AClip: ISkRegion): Boolean; - function SetRect(const ARect: TRect): Boolean; - function SetRects(const ARects: TArray): Boolean; - procedure Translate(const ADeltaX, ADeltaY: Integer); - public - constructor Create; overload; - constructor Create(const ARegion: ISkRegion); overload; - constructor Create(const ARect: TRect); overload; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkRegion(...) __SkCreate(TSkRegion, ISkRegion, __VA_ARGS__)'} - - { ISkRoundRect } - - ISkRoundRect = interface(ISkObject) - ['{A828D0E5-98C6-42EC-A44B-494DF41183DA}'] - function Contains(const ARect: TRect): Boolean; - procedure Deflate(const ADeltaX, ADeltaY: Single); - function GetHeight: Single; - function GetRadii(const ACorner: TSkRoundRectCorner): TPointF; - function GetRect: TRectF; - function GetSimpleRadii: TPointF; - function GetWidth: Single; - procedure Inflate(const ADeltaX, ADeltaY: Single); - function IsComplex: Boolean; - function IsEmpty: Boolean; - function IsEqual(const ARoundRect: ISkRoundRect): Boolean; - function IsNinePatch: Boolean; - function IsOval: Boolean; - function IsRect: Boolean; - function IsSimple: Boolean; - function IsValid: Boolean; - procedure Offset(const ADeltaX, ADeltaY: Single); - procedure SetEmpty; - procedure SetNinePatch(const ARect: TRectF; const ARadiusLeft, ARadiusTop, ARadiusRight, ARadiusBottom: Single); - procedure SetOval(const ARect: TRectF); - procedure SetRect(const ARect: TRectF); overload; - procedure SetRect(const ARect: TRectF; const ARadiusX, ARadiusY: Single); overload; - procedure SetRect(const ARect: TRectF; const ARadii: TSkRoundRectRadii); overload; - function Transform(const AMatrix: TMatrix): ISkRoundRect; - property Height: Single read GetHeight; - property Radii[const ACorner: TSkRoundRectCorner]: TPointF read GetRadii; - property Rect: TRectF read GetRect; - property SimpleRadii: TPointF read GetSimpleRadii; - property Width: Single read GetWidth; - end; - - { TSkRoundRect } - - TSkRoundRect = class(TSkObject, ISkRoundRect) - strict private - function Contains(const ARect: TRect): Boolean; - procedure Deflate(const ADeltaX, ADeltaY: Single); - function GetHeight: Single; - function GetRadii(const ACorner: TSkRoundRectCorner): TPointF; - function GetRect: TRectF; - function GetSimpleRadii: TPointF; - function GetWidth: Single; - procedure Inflate(const ADeltaX, ADeltaY: Single); - function IsComplex: Boolean; - function IsEmpty: Boolean; - function IsEqual(const ARoundRect: ISkRoundRect): Boolean; - function IsNinePatch: Boolean; - function IsOval: Boolean; - function IsRect: Boolean; - function IsSimple: Boolean; - function IsValid: Boolean; - procedure Offset(const ADeltaX, ADeltaY: Single); - procedure SetEmpty; - procedure SetNinePatch(const ARect: TRectF; const ARadiusLeft, ARadiusTop, ARadiusRight, ARadiusBottom: Single); - procedure SetOval(const ARect: TRectF); - procedure SetRect(const ARect: TRectF); overload; - procedure SetRect(const ARect: TRectF; const ARadiusX, ARadiusY: Single); overload; - procedure SetRect(const ARect: TRectF; const ARadii: TSkRoundRectRadii); overload; - function Transform(const AMatrix: TMatrix): ISkRoundRect; - public - constructor Create; overload; - constructor Create(const ARoundRect: ISkRoundRect); overload; - constructor Create(const ARect: TRectF; const ARadiusX, ARadiusY: Single); overload; - constructor Create(const ARect: TRectF; const ARadii: TSkRoundRectRadii); overload; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkRoundRect(...) __SkCreate(TSkRoundRect, ISkRoundRect, __VA_ARGS__)'} - - { ISkRuntimeEffect } - - ISkRuntimeEffect = interface(ISkReferenceCounted) - ['{BC1BDAAE-9331-47E5-A869-E7EC2D15ED52}'] - function ChildExists(const AName: string): Boolean; - function GetChildColorFilter(const AIndex: Integer): ISkColorFilter; - function GetChildColorFilterByName(const AName: string): ISkColorFilter; - function GetChildCount: Integer; - function GetChildName(const AIndex: Integer): string; - function GetChildBlender(const AIndex: Integer): ISkBlender; - function GetChildBlenderByName(const AName: string): ISkBlender; - function GetChildShader(const AIndex: Integer): ISkShader; - function GetChildShaderByName(const AName: string): ISkShader; - function GetChildType(const AIndex: Integer): TSkRuntimeEffectChildType; - function GetChildTypeByName(const AName: string): TSkRuntimeEffectChildType; - function GetUniform(const AIndex: Integer): Pointer; - function GetUniformByName(const AName: string): Pointer; - function GetUniformCount: Integer; - function GetUniformData: Pointer; - function GetUniformDataSize: NativeUInt; - function GetUniformName(const AIndex: Integer): string; - function GetUniformOffset(const AIndex: Integer): NativeUInt; - function GetUniformOffsetByName(const AName: string): NativeUInt; - function GetUniformType(const AIndex: Integer): TSkRuntimeEffectUniformType; - function GetUniformTypeByName(const AName: string): TSkRuntimeEffectUniformType; - function GetUniformTypeCount(const AIndex: Integer): Integer; - function GetUniformTypeCountByName(const AName: string): Integer; - function IndexOfChild(const AName: string): Integer; - function IndexOfUniform(const AName: string): Integer; - function IsUniformTypeOrdinal(const AIndex: Integer): Boolean; - function IsUniformTypeOrdinalByName(const AName: string): Boolean; - function MakeBlender: ISkBlender; - function MakeColorFilter: ISkColorFilter; - function MakeImage(const AImageInfo: TSkImageInfo; const AMipmapped: Boolean = False; const AContext: IGrDirectContext = nil): ISkImage; overload; - function MakeImage(const AImageInfo: TSkImageInfo; const ALocalMatrix: TMatrix; const AMipmapped: Boolean = False; const AContext: IGrDirectContext = nil): ISkImage; overload; - function MakeShader: ISkShader; overload; - function MakeShader(const ALocalMatrix: TMatrix): ISkShader; overload; - procedure SetChildBlender(const AIndex: Integer; const AValue: ISkBlender); - procedure SetChildBlenderByName(const AName: string; const AValue: ISkBlender); - procedure SetChildColorFilter(const AIndex: Integer; const AValue: ISkColorFilter); - procedure SetChildColorFilterByName(const AName: string; const AValue: ISkColorFilter); - procedure SetChildShader(const AIndex: Integer; const AValue: ISkShader); - procedure SetChildShaderByName(const AName: string; const AValue: ISkShader); - procedure SetUniform(const AIndex: Integer; const AData; const ASize: NativeUInt); overload; - procedure SetUniform(const AIndex: Integer; const AValue: Integer); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TArray); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TPoint); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectInt2); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectInt3); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectInt4); overload; - procedure SetUniform(const AIndex: Integer; const AValue: Single); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TArray); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TPointF); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TAlphaColorF); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat2); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat3); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat4); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat2x2); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat3x3); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat4x4); overload; - procedure SetUniform(const AName: string; const AData; const ASize: NativeUInt); overload; - procedure SetUniform(const AName: string; const AValue: Integer); overload; - procedure SetUniform(const AName: string; const AValue: TArray); overload; - procedure SetUniform(const AName: string; const AValue: TPoint); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectInt2); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectInt3); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectInt4); overload; - procedure SetUniform(const AName: string; const AValue: Single); overload; - procedure SetUniform(const AName: string; const AValue: TArray); overload; - procedure SetUniform(const AName: string; const AValue: TPointF); overload; - procedure SetUniform(const AName: string; const AValue: TAlphaColorF); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat2); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat3); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat4); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat2x2); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat3x3); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat4x4); overload; - function UniformExists(const AName: string): Boolean; - procedure WriteUniform(const AOffset: NativeUInt; const AData; const ASize: NativeUInt); - property ChildCount: Integer read GetChildCount; - property ChildrenBlenders[const AIndex: Integer]: ISkBlender read GetChildBlender write SetChildBlender; - property ChildrenBlendersByName[const AName: string]: ISkBlender read GetChildBlenderByName write SetChildBlenderByName; - property ChildrenColorFilters[const AIndex: Integer]: ISkColorFilter read GetChildColorFilter write SetChildColorFilter; - property ChildrenColorFiltersByName[const AName: string]: ISkColorFilter read GetChildColorFilterByName write SetChildColorFilterByName; - property ChildrenNames[const AIndex: Integer]: string read GetChildName; - property ChildrenShaders[const AIndex: Integer]: ISkShader read GetChildShader write SetChildShader; - property ChildrenShadersByName[const AName: string]: ISkShader read GetChildShaderByName write SetChildShaderByName; - property ChildType[const AIndex: Integer]: TSkRuntimeEffectChildType read GetChildType; - property ChildTypeByName[const AName: string]: TSkRuntimeEffectChildType read GetChildTypeByName; - property UniformCount: Integer read GetUniformCount; - property UniformData: Pointer read GetUniformData; - property UniformDataSize: NativeUInt read GetUniformDataSize; - property UniformNames[const AIndex: Integer]: string read GetUniformName; - property UniformOffset[const AIndex: Integer]: NativeUInt read GetUniformOffset; - property UniformOffsetByName[const AName: string]: NativeUInt read GetUniformOffsetByName; - property Uniforms[const AIndex: Integer]: Pointer read GetUniform; - property UniformsByName[const AName: string]: Pointer read GetUniformByName; - property UniformType[const AIndex: Integer]: TSkRuntimeEffectUniformType read GetUniformType; - property UniformTypeByName[const AName: string]: TSkRuntimeEffectUniformType read GetUniformTypeByName; - property UniformTypeCount[const AIndex: Integer]: Integer read GetUniformTypeCount; - property UniformTypeCountByName[const AName: string]: Integer read GetUniformTypeCountByName; - end; - - { TSkRuntimeEffect } - - TSkRuntimeEffect = class(TSkReferenceCounted, ISkRuntimeEffect) - strict private - FChildren: TArray; - FUniformData: Pointer; - function ChildExists(const AName: string): Boolean; - function GetChildColorFilter(const AIndex: Integer): ISkColorFilter; - function GetChildColorFilterByName(const AName: string): ISkColorFilter; - function GetChildCount: Integer; - function GetChildName(const AIndex: Integer): string; - function GetChildBlender(const AIndex: Integer): ISkBlender; - function GetChildBlenderByName(const AName: string): ISkBlender; - function GetChildShader(const AIndex: Integer): ISkShader; - function GetChildShaderByName(const AName: string): ISkShader; - function GetChildType(const AIndex: Integer): TSkRuntimeEffectChildType; - function GetChildTypeByName(const AName: string): TSkRuntimeEffectChildType; - function GetUniform(const AIndex: Integer): Pointer; - function GetUniformByName(const AName: string): Pointer; - function GetUniformCount: Integer; - function GetUniformData: Pointer; - function GetUniformDataSize: NativeUInt; - function GetUniformName(const AIndex: Integer): string; - function GetUniformOffset(const AIndex: Integer): NativeUInt; - function GetUniformOffsetByName(const AName: string): NativeUInt; - function GetUniformType(const AIndex: Integer): TSkRuntimeEffectUniformType; - function GetUniformTypeByName(const AName: string): TSkRuntimeEffectUniformType; - function GetUniformTypeCount(const AIndex: Integer): Integer; - function GetUniformTypeCountByName(const AName: string): Integer; - function IndexOfChild(const AName: string): Integer; - function IndexOfUniform(const AName: string): Integer; - function IsUniformTypeOrdinal(const AIndex: Integer): Boolean; - function IsUniformTypeOrdinalByName(const AName: string): Boolean; - function MakeBlender: ISkBlender; - function MakeColorFilter: ISkColorFilter; - function MakeImage(const AImageInfo: TSkImageInfo; const AMipmapped: Boolean = False; const AContext: IGrDirectContext = nil): ISkImage; overload; - function MakeImage(const AImageInfo: TSkImageInfo; const ALocalMatrix: TMatrix; const AMipmapped: Boolean = False; const AContext: IGrDirectContext = nil): ISkImage; overload; - function MakeShader: ISkShader; overload; - function MakeShader(const ALocalMatrix: TMatrix): ISkShader; overload; - procedure SetChildBlender(const AIndex: Integer; const AValue: ISkBlender); - procedure SetChildBlenderByName(const AName: string; const AValue: ISkBlender); - procedure SetChildColorFilter(const AIndex: Integer; const AValue: ISkColorFilter); - procedure SetChildColorFilterByName(const AName: string; const AValue: ISkColorFilter); - procedure SetChildShader(const AIndex: Integer; const AValue: ISkShader); - procedure SetChildShaderByName(const AName: string; const AValue: ISkShader); - procedure SetUniform(const AIndex: Integer; const AData; const ASize: NativeUInt); overload; - procedure SetUniform(const AIndex: Integer; const AValue: Integer); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TArray); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TPoint); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectInt2); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectInt3); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectInt4); overload; - procedure SetUniform(const AIndex: Integer; const AValue: Single); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TArray); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TPointF); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TAlphaColorF); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat2); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat3); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat4); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat2x2); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat3x3); overload; - procedure SetUniform(const AIndex: Integer; const AValue: TSkRuntimeEffectFloat4x4); overload; - procedure SetUniform(const AName: string; const AData; const ASize: NativeUInt); overload; - procedure SetUniform(const AName: string; const AValue: Integer); overload; - procedure SetUniform(const AName: string; const AValue: TArray); overload; - procedure SetUniform(const AName: string; const AValue: TPoint); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectInt2); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectInt3); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectInt4); overload; - procedure SetUniform(const AName: string; const AValue: Single); overload; - procedure SetUniform(const AName: string; const AValue: TArray); overload; - procedure SetUniform(const AName: string; const AValue: TPointF); overload; - procedure SetUniform(const AName: string; const AValue: TAlphaColorF); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat2); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat3); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat4); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat2x2); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat3x3); overload; - procedure SetUniform(const AName: string; const AValue: TSkRuntimeEffectFloat4x4); overload; - function UniformExists(const AName: string): Boolean; - procedure WriteUniform(const AOffset: NativeUInt; const AData; const ASize: NativeUInt); - public - procedure AfterConstruction; override; - procedure BeforeDestruction; override; - class function MakeForBlender(const ASkSL: string): ISkRuntimeEffect; overload; static; - class function MakeForBlender(const ASkSL: string; out AErrorText: string): ISkRuntimeEffect; overload; static; - class function MakeForColorFilter(const ASkSL: string): ISkRuntimeEffect; overload; static; - class function MakeForColorFilter(const ASkSL: string; out AErrorText: string): ISkRuntimeEffect; overload; static; - class function MakeForShader(const ASkSL: string): ISkRuntimeEffect; overload; static; - class function MakeForShader(const ASkSL: string; out AErrorText: string): ISkRuntimeEffect; overload; static; - end; - - { ISkShader } - - ISkShader = interface(ISkReferenceCounted) - ['{7CB71D93-131A-4C89-96C5-B966D39F43AF}'] - function MakeWithColorFilter(const AColorFilter: ISkColorFilter): ISkShader; - function MakeWithLocalMatrix(const AMatrix: TMatrix): ISkShader; - end; - - { TSkShader } - - TSkShader = class(TSkReferenceCounted, ISkShader) - strict private - function MakeWithColorFilter(const AColorFilter: ISkColorFilter): ISkShader; - function MakeWithLocalMatrix(const AMatrix: TMatrix): ISkShader; - public - class function MakeBlend(const AMode: TSkBlendMode; const ADest, ASrc: ISkShader): ISkShader; static; - class function MakeColor(const AColor: TAlphaColor): ISkShader; overload; static; - class function MakeColor(const AColor: TAlphaColorF; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; - class function MakeGradientLinear(const AStart, AEnd: TPointF; const AColor1, AColor2: TAlphaColor; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; inline; - class function MakeGradientLinear(const AStart, AEnd: TPointF; const AColor1, AColor2: TAlphaColor; const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; inline; - class function MakeGradientLinear(const AStart, AEnd: TPointF; const AColor1, AColor2: TAlphaColorF; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; inline; - class function MakeGradientLinear(const AStart, AEnd: TPointF; const AColor1, AColor2: TAlphaColorF; const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; inline; - class function MakeGradientLinear(const AStart, AEnd: TPointF; const AColors: TArray; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; - class function MakeGradientLinear(const AStart, AEnd: TPointF; const AColors: TArray; const ALocalMatrix: TMatrix; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; - class function MakeGradientLinear(const AStart, AEnd: TPointF; const AColors: TArray; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; - class function MakeGradientLinear(const AStart, AEnd: TPointF; const AColors: TArray; const ALocalMatrix: TMatrix; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; - class function MakeGradientRadial(const ACenter: TPointF; const ARadius: Single; const ACenterColor, AEdgeColor: TAlphaColor; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; inline; - class function MakeGradientRadial(const ACenter: TPointF; const ARadius: Single; const ACenterColor, AEdgeColor: TAlphaColor; const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; inline; - class function MakeGradientRadial(const ACenter: TPointF; const ARadius: Single; const ACenterColor, AEdgeColor: TAlphaColorF; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; inline; - class function MakeGradientRadial(const ACenter: TPointF; const ARadius: Single; const ACenterColor, AEdgeColor: TAlphaColorF; const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; inline; - class function MakeGradientRadial(const ACenter: TPointF; const ARadius: Single; const AColors: TArray; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; - class function MakeGradientRadial(const ACenter: TPointF; const ARadius: Single; const AColors: TArray; const ALocalMatrix: TMatrix; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; - class function MakeGradientRadial(const ACenter: TPointF; const ARadius: Single; const AColors: TArray; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; - class function MakeGradientRadial(const ACenter: TPointF; const ARadius: Single; const AColors: TArray; const ALocalMatrix: TMatrix; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; - class function MakeGradientSweep(const ACenter: TPointF; const AColor1, AColor2: TAlphaColor; const ATileMode: TSkTileMode = TSkTileMode.Clamp; const AStartAngle: Single = 0; const AEndAngle: Single = 360): ISkShader; overload; static; inline; - class function MakeGradientSweep(const ACenter: TPointF; const AColor1, AColor2: TAlphaColor; const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode = TSkTileMode.Clamp; const AStartAngle: Single = 0; const AEndAngle: Single = 360): ISkShader; overload; static; inline; - class function MakeGradientSweep(const ACenter: TPointF; const AColor1, AColor2: TAlphaColorF; const ATileMode: TSkTileMode = TSkTileMode.Clamp; const AStartAngle: Single = 0; const AEndAngle: Single = 360; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; inline; - class function MakeGradientSweep(const ACenter: TPointF; const AColor1, AColor2: TAlphaColorF; const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode = TSkTileMode.Clamp; const AStartAngle: Single = 0; const AEndAngle: Single = 360; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; inline; - class function MakeGradientSweep(const ACenter: TPointF; const AColors: TArray; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; const AStartAngle: Single = 0; const AEndAngle: Single = 360): ISkShader; overload; static; - class function MakeGradientSweep(const ACenter: TPointF; const AColors: TArray; const ALocalMatrix: TMatrix; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; const AStartAngle: Single = 0; const AEndAngle: Single = 360): ISkShader; overload; static; - class function MakeGradientSweep(const ACenter: TPointF; const AColors: TArray; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; const AStartAngle: Single = 0; const AEndAngle: Single = 360; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; - class function MakeGradientSweep(const ACenter: TPointF; const AColors: TArray; const ALocalMatrix: TMatrix; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; const AStartAngle: Single = 0; const AEndAngle: Single = 360; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; - class function MakeGradientTwoPointConical(const AStart: TPointF; const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; const AColor1, AColor2: TAlphaColor; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; inline; - class function MakeGradientTwoPointConical(const AStart: TPointF; const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; const AColor1, AColor2: TAlphaColor; const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; inline; - class function MakeGradientTwoPointConical(const AStart: TPointF; const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; const AColor1, AColor2: TAlphaColorF; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; inline; - class function MakeGradientTwoPointConical(const AStart: TPointF; const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; const AColor1, AColor2: TAlphaColorF; const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; inline; - class function MakeGradientTwoPointConical(const AStart: TPointF; const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; const AColors: TArray; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; - class function MakeGradientTwoPointConical(const AStart: TPointF; const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; const AColors: TArray; const ALocalMatrix: TMatrix; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; static; - class function MakeGradientTwoPointConical(const AStart: TPointF; const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; const AColors: TArray; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; - class function MakeGradientTwoPointConical(const AStart: TPointF; const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; const AColors: TArray; const ALocalMatrix: TMatrix; const APositions: TArray = nil; const ATileMode: TSkTileMode = TSkTileMode.Clamp; AColorSpace: ISkColorSpace = nil): ISkShader; overload; static; - class function MakeImage(const AImage: ISkImage; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - class function MakeImage(const AImage: ISkImage; const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - class function MakeImage(const AImage: ISkImage; const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - class function MakeImage(const AImage: ISkImage; const ALocalMatrix: TMatrix; const ASampling: TSkSamplingOptions; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp): ISkShader; overload; - class function MakePerlinNoiseFractalNoise(const ABaseFrequencyX, ABaseFrequencyY: Single; const ANumOctaves: Integer; const ASeed: Single): ISkShader; overload; static; - class function MakePerlinNoiseFractalNoise(const ABaseFrequencyX, ABaseFrequencyY: Single; const ANumOctaves: Integer; const ASeed: Single; const ATileSize: TSize): ISkShader; overload; static; - class function MakePerlinNoiseTurbulence(const ABaseFrequencyX, ABaseFrequencyY: Single; const ANumOctaves: Integer; const ASeed: Single): ISkShader; overload; static; - class function MakePerlinNoiseTurbulence(const ABaseFrequencyX, ABaseFrequencyY: Single; const ANumOctaves: Integer; const ASeed: Single; const ATileSize: TSize): ISkShader; overload; static; - class function MakePicture(const APicture: ISkPicture; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - class function MakePicture(const APicture: ISkPicture; const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - class function MakePicture(const APicture: ISkPicture; const ATileRect: TRectF; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - class function MakePicture(const APicture: ISkPicture; const ATileRect: TRectF; const ALocalMatrix: TMatrix; const ATileModeX: TSkTileMode = TSkTileMode.Clamp; const ATileModeY: TSkTileMode = TSkTileMode.Clamp; const AFilterMode: TSkFilterMode = TSkFilterMode.Linear): ISkShader; overload; - end; - - { ISkSurface } - - ISkSurface = interface(ISkReferenceCounted) - ['{69826677-0632-4D9E-ABAB-B210BE9309C3}'] - function GetCanvas: ISkCanvas; - function GetProperties: TSkSurfaceProperties; - function MakeImageSnapshot: ISkImage; overload; - function MakeImageSnapshot(const ABounds: TRect): ISkImage; overload; - function PeekPixels: ISkPixmap; - function ReadPixels(const ADest: ISkPixmap; const ASrcX: Integer = 0; const ASrcY: Integer = 0): Boolean; overload; - function ReadPixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASrcX: Integer = 0; const ASrcY: Integer = 0): Boolean; overload; - procedure Draw(const ACanvas: ISkCanvas; const AX, AY: Single; const APaint: ISkPaint = nil); - procedure Flush; - procedure FlushAndSubmit(const ASyncCpu: Boolean = False); - property Canvas: ISkCanvas read GetCanvas; - property Properties: TSkSurfaceProperties read GetProperties; - end; - - { TSkSurface } - - TSkSurface = class(TSkReferenceCounted, ISkSurface) - strict private - FCanvas: ISkCanvas; - function GetCanvas: ISkCanvas; - function GetProperties: TSkSurfaceProperties; - function MakeImageSnapshot: ISkImage; overload; - function MakeImageSnapshot(const ABounds: TRect): ISkImage; overload; - function PeekPixels: ISkPixmap; - function ReadPixels(const ADest: ISkPixmap; const ASrcX: Integer = 0; const ASrcY: Integer = 0): Boolean; overload; - function ReadPixels(const ADestImageInfo: TSkImageInfo; const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASrcX: Integer = 0; const ASrcY: Integer = 0): Boolean; overload; - procedure Draw(const ACanvas: ISkCanvas; const AX, AY: Single; const APaint: ISkPaint = nil); - procedure Flush; - procedure FlushAndSubmit(const ASyncCpu: Boolean = False); - class procedure raster_release_proc(pixels: Pointer; context: Pointer); cdecl; static; - public - class function MakeFromMTKView(const AContext: IGrDirectContext; const AView: GrMtlHandle; const AOrigin: TGrSurfaceOrigin; const ASampleCount: Integer; const AColorType: TSkColorType; AColorSpace: ISkColorSpace = nil): ISkSurface; overload; static; - class function MakeFromMTKView(const AContext: IGrDirectContext; const AView: GrMtlHandle; const AOrigin: TGrSurfaceOrigin; const ASampleCount: Integer; const AColorType: TSkColorType; const AProperties: TSkSurfaceProperties; AColorSpace: ISkColorSpace = nil): ISkSurface; overload; static; - class function MakeFromRenderTarget(const AContext: IGrDirectContext; const ARenderTarget: IGrBackendRenderTarget; const AOrigin: TGrSurfaceOrigin; const AColorType: TSkColorType; AColorSpace: ISkColorSpace = nil): ISkSurface; overload; static; - class function MakeFromRenderTarget(const AContext: IGrDirectContext; const ARenderTarget: IGrBackendRenderTarget; const AOrigin: TGrSurfaceOrigin; const AColorType: TSkColorType; const AProperties: TSkSurfaceProperties; AColorSpace: ISkColorSpace = nil): ISkSurface; overload; static; - class function MakeFromTexture(const AContext: IGrDirectContext; const ATexture: IGrBackendTexture; const AOrigin: TGrSurfaceOrigin; const ASampleCount: Integer; const AColorType: TSkColorType; AColorSpace: ISkColorSpace = nil): ISkSurface; overload; static; - class function MakeFromTexture(const AContext: IGrDirectContext; const ATexture: IGrBackendTexture; const AOrigin: TGrSurfaceOrigin; const ASampleCount: Integer; const AColorType: TSkColorType; const AProperties: TSkSurfaceProperties; AColorSpace: ISkColorSpace = nil): ISkSurface; overload; static; - class function MakeRaster(const AWidth, AHeight: Integer; const AColorType: TSkColorType = {$IFDEF BIGENDIAN}TSkColorType.RGBA8888{$ELSE}TSkColorType.BGRA8888{$ENDIF}; const AAlphaType: TSkAlphaType = TSkAlphaType.Premul; AColorSpace: ISkColorSpace = nil): ISkSurface; overload; static; inline; - class function MakeRaster(const AWidth, AHeight: Integer; const AProperties: TSkSurfaceProperties; const AColorType: TSkColorType = {$IFDEF BIGENDIAN}TSkColorType.RGBA8888{$ELSE}TSkColorType.BGRA8888{$ENDIF}; const AAlphaType: TSkAlphaType = TSkAlphaType.Premul; AColorSpace: ISkColorSpace = nil): ISkSurface; overload; static; inline; - class function MakeRaster(const AImageInfo: TSkImageInfo): ISkSurface; overload; static; inline; - class function MakeRaster(const AImageInfo: TSkImageInfo; const AProperties: TSkSurfaceProperties): ISkSurface; overload; static; inline; - class function MakeRaster(const AImageInfo: TSkImageInfo; const ARowBytes: NativeUInt): ISkSurface; overload; static; - class function MakeRaster(const AImageInfo: TSkImageInfo; const ARowBytes: NativeUInt; const AProperties: TSkSurfaceProperties): ISkSurface; overload; static; - class function MakeRasterDirect(const APixmap: ISkPixmap; const ARasterReleaseProc: TSkSurfaceRasterReleaseProc = nil): ISkSurface; overload; static; - class function MakeRasterDirect(const APixmap: ISkPixmap; const AProperties: TSkSurfaceProperties; const ARasterReleaseProc: TSkSurfaceRasterReleaseProc = nil): ISkSurface; overload; static; - class function MakeRasterDirect(const AImageInfo: TSkImageInfo; const APixels: Pointer; const ARowBytes: NativeUInt; const ARasterReleaseProc: TSkSurfaceRasterReleaseProc = nil): ISkSurface; overload; static; - class function MakeRasterDirect(const AImageInfo: TSkImageInfo; const APixels: Pointer; const ARowBytes: NativeUInt; const AProperties: TSkSurfaceProperties; const ARasterReleaseProc: TSkSurfaceRasterReleaseProc = nil): ISkSurface; overload; static; - class function MakeRenderTarget(const AContext: IGrDirectContext; const AIsBudgeted: Boolean; const AImageInfo: TSkImageInfo; const ASampleCount: Integer = 0; const AOrigin: TGrSurfaceOrigin = TGrSurfaceOrigin.BottomLeft; const AShouldCreateWithMips: Boolean = False): ISkSurface; overload; static; - class function MakeRenderTarget(const AContext: IGrDirectContext; const AIsBudgeted: Boolean; const AImageInfo: TSkImageInfo; const AProperties: TSkSurfaceProperties; const ASampleCount: Integer = 0; const AOrigin: TGrSurfaceOrigin = TGrSurfaceOrigin.BottomLeft; const AShouldCreateWithMips: Boolean = False): ISkSurface; overload; static; - end; - - { ISkTextBlob } - - ISkTextBlob = interface(ISkNonVirtualReferenceCounted) - ['{EC17FBCB-9578-402C-86B9-55ECA69E78E0}'] - function GetIntercepts(const AUpperBounds, ALowerBounds: Single; const APaint: ISkPaint = nil): TArray; - end; - - { TSkTextBlob } - - TSkTextBlob = class(TSkNonVirtualReferenceCounted, ISkTextBlob) - strict private - function GetIntercepts(const AUpperBounds, ALowerBounds: Single; const APaint: ISkPaint = nil): TArray; - public - class function MakeFromText(const AText: string; const AFont: ISkFont): ISkTextBlob; static; - class function MakeFromTextHorizontallyPositioned(const AText: string; const AXPositions: TArray; const AY: Single; const AFont: ISkFont): ISkTextBlob; static; - class function MakeFromTextPositioned(const AText: string; const APositions: TArray; const AFont: ISkFont): ISkTextBlob; static; - class function MakeFromTextTransform(const AText: string; const AMatrices: TArray; const AFont: ISkFont): ISkTextBlob; static; - class procedure __RefHandle(const AHandle: THandle); override; - class procedure __UnrefHandle(const AHandle: THandle); override; - end; - - { ISkTraceMemoryDump } - - ISkTraceMemoryDump = interface(ISkObject) - ['{7736D6EF-9FCA-46C5-AD45-AFBB92086D33}'] - end; - - { TSkTraceMemoryDumpBaseClass } - - TSkTraceMemoryDumpBaseClass = class abstract(TSkObject, ISkTraceMemoryDump) - strict private - class constructor Create; - class procedure dump_numeric_value_proc(context: Pointer; const dump_name, value_name, units: MarshaledAString; value: uint64_t); cdecl; static; - class procedure dump_string_value_proc(context: Pointer; const dump_name, value_name, value: MarshaledAString); cdecl; static; - strict protected - procedure DumpNumericValue(const ADumpName, AValueName, AUnits: string; const AValue: UInt64); virtual; abstract; - procedure DumpStringValue(const ADumpName, AValueName, AValue: string); virtual; abstract; - public - constructor Create(const ADetailedDump, ADumpWrappedObjects: Boolean); - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - { ISkTypeface } - - ISkTypeface = interface(ISkReferenceCounted) - ['{A6ECEB69-E0EB-4CFF-941F-75B8D1702FE5}'] - function GetFamilyName: string; - function GetSlant: TSkFontSlant; - function GetStyle: TSkFontStyle; - function GetWeight: Integer; - function GetWidth: Integer; - function IsBold: Boolean; - function IsItalic: Boolean; - property FamilyName: string read GetFamilyName; - property Slant: TSkFontSlant read GetSlant; - property Style: TSkFontStyle read GetStyle; - property Weight: Integer read GetWeight; - property Width: Integer read GetWidth; - end; - - { TSkTypeface } - - TSkTypeface = class(TSkReferenceCounted, ISkTypeface) - strict private - function GetFamilyName: string; - function GetSlant: TSkFontSlant; - function GetStyle: TSkFontStyle; - function GetWeight: Integer; - function GetWidth: Integer; - function IsBold: Boolean; - function IsItalic: Boolean; - public - class function MakeDefault: ISkTypeface; static; - class function MakeFromFile(const AFileName: string; const ATTCIndex: Integer = 0): ISkTypeface; static; - class function MakeFromName(const AFamilyName: string; const AStyle: TSkFontStyle): ISkTypeface; static; - class function MakeFromStream(const AStream: TStream; const ATTCIndex: Integer = 0): ISkTypeface; static; - end; - - { ISkVertices } - - ISkVertices = interface(ISkNonVirtualReferenceCounted) - ['{C4D307F3-E77A-4270-8559-E27ED245E86A}'] - end; - - { TSkVertices } - - TSkVertices = class(TSkNonVirtualReferenceCounted, ISkVertices) - public - class function MakeCopy(const AVertexMode: TSkVertexMode; const APositions, ATextures: TArray; const AColors: TArray; const AIndices: TArray = nil): ISkVertices; static; - class procedure __RefHandle(const AHandle: THandle); override; - class procedure __UnrefHandle(const AHandle: THandle); override; - end; - - { ISkParticleEffect } - - ISkParticleEffect = interface(ISkReferenceCounted) - ['{A8AAC230-E76B-4BBE-84F2-82D09D38E0D4}'] - function GetPosition: TPointF; - function GetRate: Single; - function GetUniform(const AIndex: NativeUInt): TSkParticleUniform; - function GetUniformCount: NativeUInt; - function GetUniformData: PSingleArray; - function GetUniformDataCount: Integer; - function GetUniformName(const AIndex: NativeUInt): string; - procedure Render(const ACanvas: ISkCanvas); - procedure SetPosition(const AValue: TPointF); - procedure SetRate(const AValue: Single); - function SetUniform(const AName: string; const AData: TArray): Boolean; - procedure Start(const ANow: Double; const ALooping: Boolean); - procedure Update(const ANow: Double); - property Position: TPointF read GetPosition write SetPosition; - property Rate: Single read GetRate write SetRate; - property Uniforms[const AIndex: NativeUInt]: TSkParticleUniform read GetUniform; - property UniformCount: NativeUInt read GetUniformCount; - property UniformData: PSingleArray read GetUniformData; - property UniformDataCount: Integer read GetUniformDataCount; - property UniformName[const AIndex: NativeUInt]: string read GetUniformName; - end; - - { TSkParticleEffect } - - TSkParticleEffect = class(TSkReferenceCounted, ISkParticleEffect) - strict private - function GetPosition: TPointF; - function GetRate: Single; - function GetUniform(const AIndex: NativeUInt): TSkParticleUniform; - function GetUniformCount: NativeUInt; - function GetUniformData: PSingleArray; - function GetUniformDataCount: Integer; - function GetUniformName(const AIndex: NativeUInt): string; - procedure Render(const ACanvas: ISkCanvas); - procedure SetPosition(const AValue: TPointF); - procedure SetRate(const AValue: Single); - function SetUniform(const AName: string; const AData: TArray): Boolean; - procedure Start(const ANow: Double; const ALooping: Boolean); - procedure Update(const ANow: Double); - class constructor Create; - public - class function Make(const AData: string; const AResourceProvider: ISkResourceProvider = nil): ISkParticleEffect; static; - class function MakeFromFile(const AFileName: string): ISkParticleEffect; static; - class function MakeFromStream(const AStream: TStream; const AResourceProvider: ISkResourceProvider = nil): ISkParticleEffect; static; - end; - - { ISkottieAnimation } - - ISkottieAnimation = interface(ISkNonVirtualReferenceCounted) - ['{3B87EFFF-8184-4576-A4AC-B73342834211}'] - function GetDuration: Double; - function GetFPS: Double; - function GetInPoint: Double; - function GetOutPoint: Double; - function GetSize: TSizeF; - function GetVersion: string; - procedure Render(const ACanvas: ISkCanvas; const ARenderFlags: TSkottieAnimationRenderFlags = []); overload; - procedure Render(const ACanvas: ISkCanvas; const ADest: TRectF; const ARenderFlags: TSkottieAnimationRenderFlags = []); overload; - procedure SeekFrame(const ATick: Double); - procedure SeekFrameTime(const ATick: Double); - property Duration: Double read GetDuration; - property FPS: Double read GetFPS; - property InPoint: Double read GetInPoint; - property OutPoint: Double read GetOutPoint; - property Size: TSizeF read GetSize; - property Version: string read GetVersion; - end; - - { TSkottieAnimation } - - TSkottieAnimation = class(TSkNonVirtualReferenceCounted, ISkottieAnimation) - strict private - function GetDuration: Double; - function GetFPS: Double; - function GetInPoint: Double; - function GetOutPoint: Double; - function GetSize: TSizeF; - function GetVersion: string; - procedure Render(const ACanvas: ISkCanvas; const ARenderFlags: TSkottieAnimationRenderFlags = []); overload; - procedure Render(const ACanvas: ISkCanvas; const ADest: TRectF; const ARenderFlags: TSkottieAnimationRenderFlags = []); overload; - procedure SeekFrame(const ATick: Double); - procedure SeekFrameTime(const ATick: Double); - public - class function Make(const AData: string; const AResourceProvider: ISkResourceProvider = nil): ISkottieAnimation; static; - class function MakeFromFile(const AFileName: string): ISkottieAnimation; static; - class function MakeFromStream(const AStream: TStream; const AResourceProvider: ISkResourceProvider = nil): ISkottieAnimation; static; - class procedure __RefHandle(const AHandle: THandle); override; - class procedure __UnrefHandle(const AHandle: THandle); override; - end; - - { ISkParagraph } - - ISkParagraph = interface(ISkObject) - ['{CB618EF9-C99E-4079-8637-9E282FAA64DD}'] - function DidExceedMaxLines: Boolean; - function GetAlphabeticBaseline: Single; - function GetGlyphPositionAtCoordinate(const ADeltaX, ADeltaY: Single): TSkPositionAffinity; - function GetHeight: Single; - function GetIdeographicBaseline: Single; - function GetLineMetrics: TArray; - function GetLongestLine: Single; - function GetMaxIntrinsicWidth: Single; - function GetMaxWidth: Single; - function GetMinIntrinsicWidth: Single; - function GetRectsForPlaceholders: TArray; - function GetRectsForRange(const AStart, AEnd: Cardinal; const ARectHeightStyle: TSkRectHeightStyle; const ARectWidthStyle: TSkRectWidthStyle): TArray; - procedure GetWordBoundary(const AOffset: Cardinal; out AStart, AEnd: Cardinal); - procedure Layout(const AWidth: Single); - procedure Paint(const ACanvas: ISkCanvas; const AX, AY: Single); - function ToPath: ISkPath; - procedure Visit(const AProc: TSkParagraphVisitProc); - property AlphabeticBaseline: Single read GetAlphabeticBaseline; - property Height: Single read GetHeight; - property IdeographicBaseline: Single read GetIdeographicBaseline; - property LineMetrics: TArray read GetLineMetrics; - property LongestLine: Single read GetLongestLine; - property MaxIntrinsicWidth: Single read GetMaxIntrinsicWidth; - property MaxWidth: Single read GetMaxWidth; - property MinIntrinsicWidth: Single read GetMinIntrinsicWidth; - end; - - { TSkParagraph } - - TSkParagraph = class(TSkObject, ISkParagraph) - strict private - function DidExceedMaxLines: Boolean; - function GetAlphabeticBaseline: Single; - function GetGlyphPositionAtCoordinate(const ADeltaX, ADeltaY: Single): TSkPositionAffinity; - function GetHeight: Single; - function GetIdeographicBaseline: Single; - function GetLineMetrics: TArray; - function GetLongestLine: Single; - function GetMaxIntrinsicWidth: Single; - function GetMaxWidth: Single; - function GetMinIntrinsicWidth: Single; - function GetRectsForPlaceholders: TArray; - function GetRectsForRange(const AStart, AEnd: Cardinal; const ARectHeightStyle: TSkRectHeightStyle; const ARectWidthStyle: TSkRectWidthStyle): TArray; - procedure GetWordBoundary(const AOffset: Cardinal; out AStart, AEnd: Cardinal); - procedure Layout(const AWidth: Single); - procedure Paint(const ACanvas: ISkCanvas; const AX, AY: Single); - function ToPath: ISkPath; - procedure Visit(const AProc: TSkParagraphVisitProc); - class procedure visit_proc(line_number: int32_t; const info: psk_paragraphvisitorinfo_t; context: Pointer); cdecl; static; - public - - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkParagraph(...) __SkCreate(TSkParagraph, ISkParagraph, __VA_ARGS__)'} - - { ISkParagraphBuilder } - - ISkParagraphBuilder = interface(ISkObject) - ['{1D484C30-D4E1-49BC-AF2E-7D7E7FF568BE}'] - procedure AddPlaceholder(const APlaceholder: TSkPlaceholderStyle); - procedure AddText(const AText: string); - function Build: ISkParagraph; - procedure Pop; - procedure PushStyle(const ATextStyle: ISkTextStyle); - end; - - { TSkParagraphBuilder } - - TSkParagraphBuilder = class(TSkObject, ISkParagraphBuilder) - strict private - procedure AddPlaceholder(const APlaceholder: TSkPlaceholderStyle); - procedure AddText(const AText: string); - function Build: ISkParagraph; - procedure Pop; - procedure PushStyle(const ATextStyle: ISkTextStyle); - public - constructor Create(const AParagraphStyle: ISkParagraphStyle); overload; - constructor Create(const AParagraphStyle: ISkParagraphStyle; const AFontProvider: ISkTypefaceFontProvider; const AEnableFontFallback: Boolean = True); overload; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkParagraphBuilder(...) __SkCreate(TSkParagraphBuilder, ISkParagraphBuilder, __VA_ARGS__)'} - - { ISkStrutStyle } - - ISkStrutStyle = interface(ISkObject) - ['{B5275BA1-4FEE-4300-9BCE-6B6C4C6681A8}'] - function GetEnabled: Boolean; - function GetFontFamilies: TArray; - function GetFontSize: Single; - function GetFontStyle: TSkFontStyle; - function GetForceHeight: Boolean; - function GetHalfLeading: Boolean; - function GetHeightMultiplier: Single; - function GetLeading: Single; - function IsEqual(const AStrutStyle: ISkStrutStyle): Boolean; - procedure SetEnabled(const AValue: Boolean); - procedure SetFontFamilies(const AValue: TArray); - procedure SetFontSize(const AValue: Single); - procedure SetFontStyle(const AValue: TSkFontStyle); - procedure SetForceHeight(const AValue: Boolean); - procedure SetHalfLeading(const AValue: Boolean); - procedure SetHeightMultiplier(const AValue: Single); - procedure SetLeading(const AValue: Single); - property Enabled: Boolean read GetEnabled write SetEnabled; - property FontFamilies: TArray read GetFontFamilies write SetFontFamilies; - property FontSize: Single read GetFontSize write SetFontSize; - property FontStyle: TSkFontStyle read GetFontStyle write SetFontStyle; - property ForceHeight: Boolean read GetForceHeight write SetForceHeight; - property HalfLeading: Boolean read GetHalfLeading write SetHalfLeading; - property HeightMultiplier: Single read GetHeightMultiplier write SetHeightMultiplier; - property Leading: Single read GetLeading write SetLeading; - end; - - { TSkStrutStyle } - - TSkStrutStyle = class(TSkObject, ISkStrutStyle) - strict private - function GetEnabled: Boolean; - function GetFontFamilies: TArray; - function GetFontSize: Single; - function GetFontStyle: TSkFontStyle; - function GetForceHeight: Boolean; - function GetHalfLeading: Boolean; - function GetHeightMultiplier: Single; - function GetLeading: Single; - function IsEqual(const AStrutStyle: ISkStrutStyle): Boolean; - procedure SetEnabled(const AValue: Boolean); - procedure SetFontFamilies(const AValue: TArray); - procedure SetFontSize(const AValue: Single); - procedure SetFontStyle(const AValue: TSkFontStyle); - procedure SetForceHeight(const AValue: Boolean); - procedure SetHalfLeading(const AValue: Boolean); - procedure SetHeightMultiplier(const AValue: Single); - procedure SetLeading(const AValue: Single); - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkStrutStyle(...) __SkCreate(TSkStrutStyle, ISkStrutStyle, __VA_ARGS__)'} - - { ISkParagraphStyle } - - ISkParagraphStyle = interface(ISkObject) - ['{A0D8108C-233E-4DF0-B728-6961730E57B9}'] - procedure DisableHinting; - function GetEllipsis: string; - function GetHeight: Single; - function GetMaxLines: NativeUInt; - function GetStrutStyle: ISkStrutStyle; - function GetTextAlign: TSkTextAlign; - function GetTextDirection: TSkTextDirection; - function GetTextHeightBehaviors: TSkTextHeightBehaviors; - function GetTextStyle: ISkTextStyle; - procedure SetEllipsis(const AValue: string); - procedure SetHeight(const AValue: Single); - procedure SetMaxLines(const AValue: NativeUInt); - procedure SetStrutStyle(AValue: ISkStrutStyle); - procedure SetTextAlign(const AValue: TSkTextAlign); - procedure SetTextDirection(const AValue: TSkTextDirection); - procedure SetTextHeightBehaviors(const AValue: TSkTextHeightBehaviors); - procedure SetTextStyle(AValue: ISkTextStyle); - property Ellipsis: string read GetEllipsis write SetEllipsis; - property Height: Single read GetHeight write SetHeight; - property MaxLines: NativeUInt read GetMaxLines write SetMaxLines; - property StrutStyle: ISkStrutStyle read GetStrutStyle write SetStrutStyle; - property TextAlign: TSkTextAlign read GetTextAlign write SetTextAlign; - property TextDirection: TSkTextDirection read GetTextDirection write SetTextDirection; - property TextHeightBehaviors: TSkTextHeightBehaviors read GetTextHeightBehaviors write SetTextHeightBehaviors; - property TextStyle: ISkTextStyle read GetTextStyle write SetTextStyle; - end; - - { TSkParagraphStyle } - - TSkParagraphStyle = class(TSkObject, ISkParagraphStyle) - strict private - procedure DisableHinting; - function GetEllipsis: string; - function GetHeight: Single; - function GetMaxLines: NativeUInt; - function GetStrutStyle: ISkStrutStyle; - function GetTextAlign: TSkTextAlign; - function GetTextDirection: TSkTextDirection; - function GetTextHeightBehaviors: TSkTextHeightBehaviors; - function GetTextStyle: ISkTextStyle; - procedure SetEllipsis(const AValue: string); - procedure SetHeight(const AValue: Single); - procedure SetMaxLines(const AValue: NativeUInt); - procedure SetStrutStyle(AValue: ISkStrutStyle); - procedure SetTextAlign(const AValue: TSkTextAlign); - procedure SetTextDirection(const AValue: TSkTextDirection); - procedure SetTextHeightBehaviors(const AValue: TSkTextHeightBehaviors); - procedure SetTextStyle(AValue: ISkTextStyle); - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkParagraphStyle(...) __SkCreate(TSkParagraphStyle, ISkParagraphStyle, __VA_ARGS__)'} - - { ISkTextStyle } - - ISkTextStyle = interface(ISkObject) - ['{36B7F057-D721-4FDF-84C0-AF0864732F29}'] - procedure AddFontFeature(const AFeature: string; const AValue: Integer); - procedure AddShadow(const AShadow: TSkTextShadow); - procedure ClearBackgroundColor; - procedure ClearForegroundColor; - function GetBackground: ISkPaint; - function GetColor: TAlphaColor; - function GetDecorationColor: TAlphaColor; - function GetDecorations: TSkTextDecorations; - function GetDecorationStyle: TSkTextDecorationStyle; - function GetDecorationThickness: Single; - function GetFontFamilies: TArray; - function GetFontMetrics: TSkFontMetrics; - function GetFontSize: Single; - function GetFontStyle: TSkFontStyle; - function GetForeground: ISkPaint; - function GetHalfLeading: Boolean; - function GetHeightMultiplier: Single; - function GetLetterSpacing: Single; - function GetLocale: string; - function GetWordSpacing: Single; - function IsEqual(const ATextStyle: ISkTextStyle): Boolean; - procedure ResetFontFeatures; - procedure ResetShadows; - procedure SetBackgroundColor(const APaint: ISkPaint); - procedure SetColor(const AValue: TAlphaColor); - procedure SetDecorationColor(const AValue: TAlphaColor); - procedure SetDecorations(const AValue: TSkTextDecorations); - procedure SetDecorationStyle(const AValue: TSkTextDecorationStyle); - procedure SetDecorationThickness(const AValue: Single); - procedure SetFontFamilies(const AValue: TArray); - procedure SetFontSize(const AValue: Single); - procedure SetFontStyle(const AValue: TSkFontStyle); - procedure SetForegroundColor(const APaint: ISkPaint); - procedure SetHalfLeading(const AValue: Boolean); - procedure SetHeightMultiplier(const AValue: Single); - procedure SetLetterSpacing(const AValue: Single); - procedure SetLocale(const AValue: string); - procedure SetWordSpacing(const AValue: Single); - property Color: TAlphaColor read GetColor write SetColor; - property DecorationColor: TAlphaColor read GetDecorationColor write SetDecorationColor; - property Decorations: TSkTextDecorations read GetDecorations write SetDecorations; - property DecorationStyle: TSkTextDecorationStyle read GetDecorationStyle write SetDecorationStyle; - property DecorationThickness: Single read GetDecorationThickness write SetDecorationThickness; - property FontFamilies: TArray read GetFontFamilies write SetFontFamilies; - property FontMetrics: TSkFontMetrics read GetFontMetrics; - property FontSize: Single read GetFontSize write SetFontSize; - property FontStyle: TSkFontStyle read GetFontStyle write SetFontStyle; - property HalfLeading: Boolean read GetHalfLeading write SetHalfLeading; - property HeightMultiplier: Single read GetHeightMultiplier write SetHeightMultiplier; - property LetterSpacing: Single read GetLetterSpacing write SetLetterSpacing; - property Locale: string read GetLocale write SetLocale; - property WordSpacing: Single read GetWordSpacing write SetWordSpacing; - end; - - { TSkTextStyle } - - TSkTextStyle = class(TSkObject, ISkTextStyle) - strict private - procedure AddFontFeature(const AFeature: string; const AValue: Integer); - procedure AddShadow(const AShadow: TSkTextShadow); - procedure ClearBackgroundColor; - procedure ClearForegroundColor; - function GetBackground: ISkPaint; - function GetColor: TAlphaColor; - function GetDecorationColor: TAlphaColor; - function GetDecorations: TSkTextDecorations; - function GetDecorationStyle: TSkTextDecorationStyle; - function GetDecorationThickness: Single; - function GetFontFamilies: TArray; - function GetFontMetrics: TSkFontMetrics; - function GetFontSize: Single; - function GetFontStyle: TSkFontStyle; - function GetForeground: ISkPaint; - function GetHalfLeading: Boolean; - function GetHeightMultiplier: Single; - function GetLetterSpacing: Single; - function GetLocale: string; - function GetWordSpacing: Single; - function IsEqual(const ATextStyle: ISkTextStyle): Boolean; - procedure ResetFontFeatures; - procedure ResetShadows; - procedure SetBackgroundColor(const APaint: ISkPaint); - procedure SetColor(const AValue: TAlphaColor); - procedure SetDecorationColor(const AValue: TAlphaColor); - procedure SetDecorations(const AValue: TSkTextDecorations); - procedure SetDecorationStyle(const AValue: TSkTextDecorationStyle); - procedure SetDecorationThickness(const AValue: Single); - procedure SetFontFamilies(const AValue: TArray); - procedure SetFontSize(const AValue: Single); - procedure SetFontStyle(const AValue: TSkFontStyle); - procedure SetForegroundColor(const APaint: ISkPaint); - procedure SetHalfLeading(const AValue: Boolean); - procedure SetHeightMultiplier(const AValue: Single); - procedure SetLetterSpacing(const AValue: Single); - procedure SetLocale(const AValue: string); - procedure SetWordSpacing(const AValue: Single); - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkTextStyle(...) __SkCreate(TSkTextStyle, ISkTextStyle, __VA_ARGS__)'} - - { ISkTypefaceFontProvider } - - ISkTypefaceFontProvider = interface(ISkReferenceCounted) - ['{04D29164-65B8-4733-A742-9FBE0B2178A2}'] - procedure RegisterTypeface(const ATypeface: ISkTypeface); overload; - procedure RegisterTypeface(const ATypeface: ISkTypeface; const AFamilyName: string); overload; - end; - - { TSkTypefaceFontProvider } - - TSkTypefaceFontProvider = class(TSkReferenceCounted, ISkTypefaceFontProvider) - strict private - procedure RegisterTypeface(const ATypeface: ISkTypeface); overload; - procedure RegisterTypeface(const ATypeface: ISkTypeface; const AFamilyName: string); overload; - public - constructor Create; - end; - - {$HPPEMIT END '#define SkTypefaceFontProvider(...) __SkCreate(TSkTypefaceFontProvider, ISkTypefaceFontProvider, __VA_ARGS__)'} - - { ISkResourceProvider } - - ISkResourceProvider = interface(ISkReferenceCounted) - ['{0CC1E668-7D3A-4E7E-9F08-F967499E8381}'] - end; - - { TSkResourceProviderBaseClass } - - TSkResourceProviderBaseClass = class abstract(TSkReferenceCounted, ISkResourceProvider) - strict private - class constructor Create; - class function load_proc(context: Pointer; const path, name: MarshaledAString): sk_data_t; cdecl; static; - strict protected - function Load(const APath, AName: string): TBytes; virtual; abstract; - public - constructor Create(const APredecode: Boolean = False); - end; - - { ISkFileResourceProvider } - - ISkFileResourceProvider = interface(ISkResourceProvider) - ['{2B7EFDD2-9E20-4E50-ACFF-FFBCB5E532A1}'] - end; - - { TSkFileResourceProvider } - - TSkFileResourceProvider = class(TSkResourceProviderBaseClass, ISkFileResourceProvider) - strict private - FBaseDir: string; - strict protected - function Load(const APath, AName: string): TBytes; override; - public - constructor Create(const APredecode: Boolean = False); overload; - constructor Create(const ABaseDir: string; const APredecode: Boolean = False); overload; - end; - - {$HPPEMIT END '#define SkFileResourceProvider(...) __SkCreate(TSkFileResourceProvider, ISkResourceProvider, __VA_ARGS__)'} - - { ISkShaper } - - ISkShaper = interface(ISkObject) - ['{2FDC50D7-2024-45A3-B281-6DD6904FC301}'] - function Shape(const AText: string; const AFont: ISkFont; const ALeftToRight: Boolean; const AWidth: Single): ISkTextBlob; overload; - function Shape(const AText: string; const AFont: ISkFont; const ALeftToRight: Boolean; const AWidth: Single; const AOffset: TPointF; out AEndPoint: TPointF): ISkTextBlob; overload; - end; - - { TSkShaper } - - TSkShaper = class(TSkObject, ISkShaper) - strict private - function Shape(const AText: string; const AFont: ISkFont; const ALeftToRight: Boolean; const AWidth: Single): ISkTextBlob; overload; - function Shape(const AText: string; const AFont: ISkFont; const ALeftToRight: Boolean; const AWidth: Single; const AOffset: TPointF; out AEndPoint: TPointF): ISkTextBlob; overload; - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkShaper(...) __SkCreate(TSkShaper, ISkShaper, __VA_ARGS__)'} - - { TSkSVGCanvas } - - TSkSVGCanvas = class(TSkCanvas) - strict private - FHolder: ISkObject; - public - class function Make(const ABounds: TRectF; const AStream: TStream; const AFlags: TSkSVGCanvasFlags = []): ISkCanvas; static; - end; - - { ISkSVGDOM } - - ISkSVGDOM = interface(ISkReferenceCounted) - ['{5CF1CAA2-825B-4538-A64C-522134DB0415}'] - function FindNodeById(const AId: string): ISkSVGNode; - function GetRoot: ISkSVGSVG; - procedure Render(const ACanvas: ISkCanvas); - procedure SetContainerSize(const ASize: TSizeF); - property Root: ISkSVGSVG read GetRoot; - end; - - { TSkSVGDOM } - - TSkSVGDOM = class(TSkReferenceCounted, ISkSVGDOM) - strict private - FRoot: ISkSVGSVG; - function FindNodeById(const AId: string): ISkSVGNode; - function GetRoot: ISkSVGSVG; - procedure Render(const ACanvas: ISkCanvas); - procedure SetContainerSize(const ASize: TSizeF); - public - class function Make(const AData: string; const AResourceProvider: ISkResourceProvider = nil): ISkSVGDOM; static; - class function MakeFromFile(const AFileName: string): ISkSVGDOM; static; - class function MakeFromStream(const AStream: TStream; const AResourceProvider: ISkResourceProvider = nil): ISkSVGDOM; static; - end; - - { ISkSVGNode } - - ISkSVGNode = interface(ISkReferenceCounted) - ['{44A79F6C-4A16-49BA-937D-D892BA5FB453}'] - function TrySetAttribute(const AName, AValue: string): Boolean; - end; - - { TSkSVGNode } - - TSkSVGNode = class(TSkReferenceCounted, ISkSVGNode) - strict private - function TrySetAttribute(const AName, AValue: string): Boolean; - end; - - { ISkSVGSVG } - - ISkSVGSVG = interface(ISkSVGNode) - ['{4DC9309C-664F-4997-B826-B65347C63944}'] - function GetHeight: TSkSVGLength; - function GetIntrinsicSize(const AViewPort: TSizeF; const ADPI: Single = 90): TSizeF; - function GetPreserveAspectRatio: TSkSVGPreserveAspectRatio; - function GetWidth: TSkSVGLength; - function GetX: TSkSVGLength; - function GetY: TSkSVGLength; - procedure SetHeight(const AValue: TSkSVGLength); - procedure SetPreserveAspectRatio(const AValue: TSkSVGPreserveAspectRatio); - procedure SetViewBox(const AViewBox: TRectF); - procedure SetWidth(const AValue: TSkSVGLength); - procedure SetX(const AValue: TSkSVGLength); - procedure SetY(const AValue: TSkSVGLength); - function TryGetViewBox(out AViewBox: TRectF): Boolean; - property Height: TSkSVGLength read GetHeight write SetHeight; - property PreserveAspectRatio: TSkSVGPreserveAspectRatio read GetPreserveAspectRatio write SetPreserveAspectRatio; - property Width: TSkSVGLength read GetWidth write SetWidth; - property X: TSkSVGLength read GetX write SetX; - property Y: TSkSVGLength read GetY write SetY; - end; - - { TSkSVGSVG } - - TSkSVGSVG = class(TSkSVGNode, ISkSVGSVG) - strict private - function GetHeight: TSkSVGLength; - function GetIntrinsicSize(const AViewPort: TSizeF; const ADPI: Single = 90): TSizeF; - function GetPreserveAspectRatio: TSkSVGPreserveAspectRatio; - function GetWidth: TSkSVGLength; - function GetX: TSkSVGLength; - function GetY: TSkSVGLength; - procedure SetHeight(const AValue: TSkSVGLength); - procedure SetPreserveAspectRatio(const AValue: TSkSVGPreserveAspectRatio); - procedure SetViewBox(const AViewBox: TRectF); - procedure SetWidth(const AValue: TSkSVGLength); - procedure SetX(const AValue: TSkSVGLength); - procedure SetY(const AValue: TSkSVGLength); - function TryGetViewBox(out AViewBox: TRectF): Boolean; - end; - - { ISkUnicodeBreakIterator } - - ISkUnicodeBreakIterator = interface(ISkEnumerable) - ['{A21F8622-2A3B-413D-BF03-18D393DEF49A}'] - function GetCurrent: TSkUnicodeBreakIteratorElem; - function GetEnumerator: TSkEnumerator; - end; - - { ISkUnicode } - - ISkUnicode = interface(ISkObject) - ['{DFD6FE56-0C2E-45C9-BA18-95C750981554}'] - procedure ForEachBidiRegion(const AText: string; const ADirection: TSkDirection; const AProc: TSkUnicodeBidiRegionProc); - procedure ForEachBreak(const AText: string; const AType: TSkBreakType; const AProc: TSkUnicodeBreakProc); - procedure ForEachCodepoint(const AText: string; const AProc: TSkUnicodeCodepointProc); - function GetBreakIterator(const AType: TSkBreakType; const AText: string): ISkUnicodeBreakIterator; - function GetBreakIteratorUTF8(const AType: TSkBreakType; const AText: UTF8String): ISkUnicodeBreakIterator; - function GetBreaks(const AText: string; const AType: TSkBreakType): TArray; - end; - - { TSkUnicode } - - TSkUnicode = class(TSkObject, ISkUnicode) - strict private type - TUnicodeBreakIterator = class(TSkEnumerable, ISkUnicodeBreakIterator) - strict private - FCurrent: TSkUnicodeBreakIteratorElem; - public - constructor Create(const AUnicode: ISkUnicode; const AType: TSkBreakType; const AText: string); overload; - constructor Create(const AUnicode: ISkUnicode; const AType: TSkBreakType; const AText: UTF8String); overload; - function GetCurrent: TSkUnicodeBreakIteratorElem; override; - function MoveNext: Boolean; override; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - strict private - procedure ForEachBidiRegion(const AText: string; const ADirection: TSkDirection; const AProc: TSkUnicodeBidiRegionProc); - procedure ForEachBreak(const AText: string; const AType: TSkBreakType; const AProc: TSkUnicodeBreakProc); - procedure ForEachCodepoint(const AText: string; const AProc: TSkUnicodeCodepointProc); - function GetBreakIterator(const AType: TSkBreakType; const AText: string): ISkUnicodeBreakIterator; - function GetBreakIteratorUTF8(const AType: TSkBreakType; const AText: UTF8String): ISkUnicodeBreakIterator; - function GetBreaks(const AText: string; const AType: TSkBreakType): TArray; - class procedure bidi_region_proc(start, &end: int32_t; level: uint8_t; context: Pointer); cdecl; static; - class procedure break_proc(position, status: int32_t; context: Pointer); cdecl; static; - class procedure codepoint_proc(unichar: sk_unichar_t; start, &end: int32_t; context: Pointer); cdecl; static; - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - {$HPPEMIT END '#define SkUnicode(...) __SkCreate(TSkUnicode, ISkUnicode, __VA_ARGS__)'} - -function ExtensionToEncodedImageFormat(const AExtension: string): TSkEncodedImageFormat; inline; - -const - GrGlTexture2D = $0DE1; - GrGlTextureRectangle = $84F5; - GrGlTextureExternal = $8D65; - - GrGlSizedFormat: array[TSkColorType] of GrGlenum = ( - { Unknown } 0, - { Alpha8 - GR_GL_ALPHA8 } $803C, - { RGB565 - GR_GL_RGB565 } $8D62, - { ARGB4444 - GR_GL_RGBA4 } $8056, - { RGBA8888 - GR_GL_RGBA8 } $8058, - { RGB888X - GR_GL_RGBX8 } $96BA, - { BGRA8888 - GR_GL_BGRA8 } $93A1, - { RGBA1010102 - GR_GL_RGB10_A2 } $8059, - { BGRA1010102 } 0, - { RGB101010X } 0, - { BGR101010X } 0, - { Gray8 - GR_GL_LUMINANCE8 } $8040, - { RGBAF16 - GR_GL_RGBA16F } $881A, - { RGBAF16Clamped - GR_GL_RGBA16F } $881A, - { RGBAF32 - GR_GL_RGBA32F } $8814, - { RG88 - GR_GL_RG8 } $822B, - { AlphaF16 - GR_GL_R16F } $822D, - { RGF16 - GR_GL_RG16F } $822F, - { Alpha16 - GR_GL_R16 } $822A, - { RG1616 - GR_GL_RG16 } $822C, - { RGBA16161616 - GR_GL_RGBA16 } $805B, - { SRGBA8888 - GR_GL_SRGB8_ALPHA8 } $8C43, - { R8 - GR_GL_R8 } $8229 - ); - - SkBytesPerPixel: array[TSkColorType] of Integer = ( - { Unknown } 0, - { Alpha8 } 1, - { RGB565 } 2, - { ARGB4444 } 2, - { RGBA8888 } 4, - { RGB888X } 4, - { BGRA8888 } 4, - { RGBA1010102 } 4, - { BGRA1010102 } 4, - { RGB101010X } 4, - { BGR101010X } 4, - { Gray8 } 1, - { RGBAF16 } 8, - { RGBAF16Clamped } 8, - { RGBAF32 } 16, - { RG88 } 2, - { AlphaF16 } 2, - { RGF16 } 4, - { Alpha16 } 2, - { RG1616 } 4, - { RGBA16161616 } 8, - { SRGBA8888 } 4, - { R8 } 1 - ); - - SkColorMatrixIdentity: TSkColorMatrix = (M11: 1; M12: 0; M13: 0; M14: 0; M15: 0; - M21: 0; M22: 1; M23: 0; M24: 0; M25: 0; - M31: 0; M32: 0; M33: 1; M34: 0; M35: 0; - M41: 0; M42: 0; M43: 0; M44: 1; M45: 0); - - SkColorSpaceTransferFunctionHLG : TSkColorSpaceTransferFunction = (G: -3; A: 2; B: 2; C: 1 / 0.17883277; D: 0.28466892; E: 0.55991073; F: 0); - SkColorSpaceTransferFunctionLinear : TSkColorSpaceTransferFunction = (G: 1; A: 1; B: 0; C: 0; D: 0; E: 0; F: 0); - SkColorSpaceTransferFunctionPQ : TSkColorSpaceTransferFunction = (G: -2; A: -107 / 128; B: 1; C: 32 / 2523; D: 2413 / 128; E: -2392 / 128; F: 8192 / 1305); - SkColorSpaceTransferFunctionRec2020 : TSkColorSpaceTransferFunction = (G: 2.22222; A: 0.909672; B: 0.0903276; C: 0.222222; D: 0.0812429; E: 0; F: 0); - SkColorSpaceTransferFunctionSRGB : TSkColorSpaceTransferFunction = (G: 2.4; A: 1 / 1.055; B: 0.055 / 1.055; C: 1 / 12.92; D: 0.04045; E: 0; F: 0); - SkColorSpaceTransferFunctionTwoDotTwo: TSkColorSpaceTransferFunction = (G: 2.2; A: 1; B: 0; C: 0; D: 0; E: 0; F: 0); - - SkColorSpaceXyzAdobeRGB : TSkColorSpaceXyz = (M11: $9C18 * TSkColorSpaceXyz.FixedToFloat; M12: $348D * TSkColorSpaceXyz.FixedToFloat; M13: $2631 * TSkColorSpaceXyz.FixedToFloat; - M21: $4FA5 * TSkColorSpaceXyz.FixedToFloat; M22: $A02C * TSkColorSpaceXyz.FixedToFloat; M23: $102F * TSkColorSpaceXyz.FixedToFloat; - M31: $04FC * TSkColorSpaceXyz.FixedToFloat; M32: $0F95 * TSkColorSpaceXyz.FixedToFloat; M33: $BE9C * TSkColorSpaceXyz.FixedToFloat); - - SkColorSpaceXyzDisplayP3: TSkColorSpaceXyz = (M11: 0.515102; M12: 0.291965; M13: 0.157153; - M21: 0.241182; M22: 0.692236; M23: 0.0665819; - M31: -0.00104941; M32: 0.0418818; M33: 0.784378); - - SkColorSpaceXyzIdentity : TSkColorSpaceXyz = (M11: 1; M12: 0; M13: 0; - M21: 0; M22: 1; M23: 0; - M31: 0; M32: 0; M33: 1); - - SkColorSpaceXyzRec2020 : TSkColorSpaceXyz = (M11: 0.673459; M12: 0.165661; M13: 0.125100; - M21: 0.279033; M22: 0.675338; M23: 0.0456288; - M31: -0.00193139; M32: 0.0299794; M33: 0.797162); - - SkColorSpaceXyzSRGB : TSkColorSpaceXyz = (M11: $6FA2 * TSkColorSpaceXyz.FixedToFloat; M12: $6299 * TSkColorSpaceXyz.FixedToFloat; M13: $24A0 * TSkColorSpaceXyz.FixedToFloat; - M21: $38F5 * TSkColorSpaceXyz.FixedToFloat; M22: $B785 * TSkColorSpaceXyz.FixedToFloat; M23: $0F84 * TSkColorSpaceXyz.FixedToFloat; - M31: $0390 * TSkColorSpaceXyz.FixedToFloat; M32: $18DA * TSkColorSpaceXyz.FixedToFloat; M33: $B6CF * TSkColorSpaceXyz.FixedToFloat); - - SkCubicResamplerCatmullRom: TSkCubicResampler = (B: 0; C: 1 / 2); - SkCubicResamplerMitchell : TSkCubicResampler = (B: 1 / 3; C: 1 / 3); - - SkFontSlantRegular = TSkFontSlant.Upright; - - SkFontStyleBold : TSkFontStyle = (Weight: Ord(TSkFontWeight.Bold); Width: Ord(TSkFontWidth.Normal); Slant: TSkFontSlant.Upright); - SkFontStyleBoldItalic: TSkFontStyle = (Weight: Ord(TSkFontWeight.Bold); Width: Ord(TSkFontWidth.Normal); Slant: TSkFontSlant.Italic); - SkFontStyleItalic : TSkFontStyle = (Weight: Ord(TSkFontWeight.Normal); Width: Ord(TSkFontWidth.Normal); Slant: TSkFontSlant.Italic); - SkFontStyleNormal : TSkFontStyle = (Weight: Ord(TSkFontWeight.Normal); Width: Ord(TSkFontWidth.Normal); Slant: TSkFontSlant.Upright); - - SkFontWeightDemiBold = TSkFontWeight.SemiBold; - SkFontWeightHairline = TSkFontWeight.Thin; - SkFontWeightHeavy = TSkFontWeight.Black; - SkFontWeightRegular = TSkFontWeight.Normal; - SkFontWeightUltraBlack = TSkFontWeight.ExtraBlack; - SkFontWeightUltraBold = TSkFontWeight.ExtraBold; - SkFontWeightUltraLight = TSkFontWeight.ExtraLight; - - SkFontWidthRegular = TSkFontWidth.Normal; - - SkNative32ColorType: TSkColorType = {$IFDEF BIGENDIAN}TSkColorType.RGBA8888{$ELSE}TSkColorType.BGRA8888{$ENDIF}; - - SkRotationScaleMatrixIdentity: TSkRotationScaleMatrix = (SCosinus : 1; SSinus : 0; - TranslateX : 0; TranslateY : 0); - - SkSamplingOptionsHigh : TSkSamplingOptions = (FUseCubic: True; FCubic: (B: 1 / 3; C: 1 / 3); FFilter: TSkFilterMode.Nearest; FMipmap: TSkMipmapMode.None); - SkSamplingOptionsLow : TSkSamplingOptions = (FUseCubic: False; FCubic: (B: 0; C: 0); FFilter: TSkFilterMode.Nearest; FMipmap: TSkMipmapMode.Nearest); - SkSamplingOptionsMedium: TSkSamplingOptions = (FUseCubic: False; FCubic: (B: 0; C: 0); FFilter: TSkFilterMode.Linear; FMipmap: TSkMipmapMode.Nearest); - - SkShiftPerPixel: array[TSkColorType] of Integer = ( - { Unknown } 0, - { Alpha8 } 0, - { RGB565 } 1, - { ARGB4444 } 1, - { RGBA8888 } 2, - { RGB888X } 2, - { BGRA8888 } 2, - { RGBA1010102 } 2, - { BGRA1010102 } 2, - { RGB101010X } 2, - { BGR101010X } 2, - { Gray8 } 0, - { RGBAF16 } 3, - { RGBAF16Clamped } 3, - { RGBAF32 } 4, - { RG88 } 1, - { AlphaF16 } 1, - { RGF16 } 2, - { Alpha16 } 1, - { RG1616 } 2, - { RGBA16161616 } 3, - { SRGBA8888 } 2, - { R8 } 0 - ); - - SFileNameIsEmpty = 'File name cannot be empty'; - SInvalidOperation = 'Operation is invalid'; - SOutOfMemory = 'Out of memory'; - SParamElementIsNil = 'Parameter %s[%d] cannot be nil'; - SParamIsEmpty = 'Parameter %s cannot be empty'; - SParamIsNil = 'Parameter %s cannot be nil'; - SParamOutOfRange = 'Parameter %s out of range (%d). Must be >= %d and < %d'; - SParamSizeIsOdd = 'Parameter %s size cannot be odd'; - SParamSizeMismatch = 'Parameter %s size mismatch'; - -implementation - -uses - { Delphi } - {$IFDEF MSWINDOWS} - Winapi.Windows, - {$ENDIF} - System.Generics.Collections, - System.IOUtils, - System.Math, - System.RTLConsts, - System.TimeSpan; - -type - ISkWStream = interface; - - TSkDelegateInitializeFunc = reference to function (const AContextProc: Pointer): I; - TSkDelegateInvokeProc = reference to procedure (const AProc: T); - TSkGetStringsFunc = reference to function (const AHandle: THandle; const AStrings: PMarshaledAString): Integer; - TSkSetStringsProc = reference to procedure (const AHandle: THandle; const AStrings: PMarshaledAString); - TSkSetTwoStringsProc = reference to procedure (const AHandle: THandle; const AStrings1, AStrings2: PMarshaledAString); - - { TSkBindings } - - TSkBindings = record - class function AsDateTime(const AValue: TDateTime): sk_datetime_t; static; inline; - class function AsGrContextOptions(const AValue: TGrContextOptions): gr_contextoptions_t; static; inline; - class function AsGrVkAlloc(const AValue: TGrVkAlloc): gr_vk_alloc_t; static; inline; - class function AsGrVkBackendContext(const AValue: TGrVkBackendContext): gr_vk_backendcontext_t; static; inline; - class function AsGrVkImageInfo(const AValue: TGrVkImageInfo): gr_vk_imageinfo_t; static; inline; - class function AsImageInfo(const AValue: TSkImageInfo): sk_imageinfo_t; static; inline; - class function AsLattice(const AValue: TSkLattice): sk_lattice_t; static; inline; - class function AsPDFMetadata(const AValue: TSkPDFMetadata): sk_pdfmetadata_t; static; inline; - class function AsSurfaceProperties(const AValue: TSkSurfaceProperties): sk_surfaceprops_t; static; inline; - class function GetStrings(const AHandle: THandle; const AFunc: TSkGetStringsFunc): TArray; static; inline; - class function SafeCreate(const AHandle: THandle; const AOwnsHandle: Boolean = True): T; static; inline; - class function SafeHandle(const AObject: ISkObject): THandle; static; inline; - class function ToFontMetrics(const AValue: sk_fontmetrics_t): TSkFontMetrics; static; inline; - class function ToImageInfo(const AValue: sk_imageinfo_t): TSkImageInfo; static; inline; - class function ToParagraphVisitorInfo(const AValue: sk_paragraphvisitorinfo_t): TSkParagraphVisitorInfo; static; inline; - class function ToSurfaceProperties(const AValue: sk_surfaceprops_t): TSkSurfaceProperties; static; inline; - class procedure SetStrings(const AHandle: THandle; const AStrings: TArray; const AProc: TSkSetStringsProc); overload; static; inline; - class procedure SetStrings(const AHandle: THandle; const AStrings1, AStrings2: TArray; const AProc: TSkSetTwoStringsProc); overload; static; inline; - class function __gr_gl_get_proc(context: Pointer; const name: MarshaledAString): Pointer; cdecl; static; - class function __gr_vk_get_proc(context: Pointer; const name: MarshaledAString; instance: gr_vk_instance_t; device: gr_vk_device_t): Pointer; cdecl; static; - end; - - { TSkDelegate } - - TSkDelegate = record - strict private type - TProcWrapper = record - Proc: T; - end; - PProcWrapper = ^TProcWrapper; - - public - class function Initialize(const AProc: T; const AInitializeFunc: TSkDelegateInitializeFunc): I; static; inline; - class procedure Finalize(const AContextProc: Pointer); static; inline; - class procedure Invoke(const AContextProc: Pointer; const AInvokeProc: TSkDelegateInvokeProc); static; inline; - end; - - { ISkData } - - ISkData = interface(ISkNonVirtualReferenceCounted) - ['{7C1D6B87-6DCC-4398-B5F1-954E60BDB085}'] - end; - - { TSkData } - - TSkData = class(TSkNonVirtualReferenceCounted, ISkData) - public - class function MakeFromBytes(const ABytes: TBytes): ISkData; static; - class procedure __RefHandle(const AHandle: THandle); override; - class procedure __UnrefHandle(const AHandle: THandle); override; - end; - - { ISkStream } - - ISkStream = interface(ISkObject) - ['{E99AB460-4CEE-4F50-85A7-29896A1407AC}'] - end; - - { TSkStreamAdapter } - - TSkStreamAdapter = class(TSkObject, ISkStream) - strict private - class constructor Create; - class function get_length_proc(context: Pointer): size_t; cdecl; static; - class function get_position_proc(context: Pointer): size_t; cdecl; static; - class function read_proc(context: Pointer; buffer: Pointer; size: size_t): size_t; cdecl; static; - class function seek_proc(context: Pointer; position: size_t): _bool; cdecl; static; - public - constructor Create(const AStream: TStream); - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - { ISkWStream } - - ISkWStream = interface(ISkObject) - ['{C20D663E-459B-495A-9E19-017FE7A08227}'] - end; - - { TSkWStreamAdapter } - - TSkWStreamAdapter = class(TSkObject, ISkWStream) - strict private - class constructor Create; - class function write_proc(context: Pointer; const buffer: Pointer; size: size_t): _bool; cdecl; static; - public - constructor Create(const AStream: TStream); - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - - { ISkString } - - ISkString = interface(ISkObject) - ['{2648646C-8DC1-4289-A9E2-2F658BB11C1C}'] - function GetText: string; - property Text: string read GetText; - end; - - { TSkString } - - TSkString = class(TSkObject, ISkString) - strict private - function GetText: string; - public - constructor Create; - class procedure __DestroyHandle(const AHandle: THandle); override; - end; - -{ TSkObject } - -{$IFNDEF AUTOREFCOUNT} - -procedure TSkObject.AfterConstruction; -begin - inherited; - AtomicDecrement(FRefCount); -end; - -procedure TSkObject.BeforeDestruction; -begin - if RefCount <> 0 then - System.Error(reInvalidPtr); - inherited; -end; - -{$ENDIF} - -class constructor TSkObject.Create; -begin - SkInitialize; -end; - -constructor TSkObject.Create(const AHandle: THandle); -begin - Wrap(AHandle); -end; - -destructor TSkObject.Destroy; -begin - if FOwnsHandle then - __DestroyHandle(FHandle); - inherited; -end; - -class destructor TSkObject.Destroy; -begin - SkFinalize; -end; - -function TSkObject.GetHandle: THandle; -begin - Result := FHandle; -end; - -{$IFNDEF AUTOREFCOUNT} - -function TSkObject.GetRefCount: Integer; -begin - Result := FRefCount and not objDestroyingFlag; -end; - -class function TSkObject.NewInstance: TObject; -begin - Result := inherited NewInstance; - TSkObject(Result).FRefCount := 1; -end; - -{$ENDIF} - -function TSkObject.QueryInterface(const IID: TGUID; out Obj): HResult; -begin - if GetInterface(IID, Obj) then - Result := 0 - else - Result := E_NOINTERFACE; -end; - -constructor TSkObject.Wrap(const AHandle: THandle; const AOwnsHandle: Boolean); -begin - inherited Create; - Assert(AHandle <> 0); - FHandle := AHandle; - FOwnsHandle := AOwnsHandle; -end; - -function TSkObject._AddRef: Integer; -begin - {$IFNDEF AUTOREFCOUNT} - Result := AtomicIncrement(FRefCount); - {$ELSE} - Result := __ObjAddRef; - {$ENDIF} - if Result > 1 then - __RefHandle(FHandle); -end; - -function TSkObject._Release: Integer; -begin - {$IFNDEF AUTOREFCOUNT} - Result := AtomicDecrement(FRefCount); - if Result = 0 then - begin - __MarkDestroying(Self); - Destroy; - end; - {$ELSE} - Result := __ObjRelease; - {$ENDIF} - if Result > 0 then - __UnrefHandle(FHandle); -end; - -class procedure TSkObject.__DestroyHandle(const AHandle: THandle); -begin - __UnrefHandle(AHandle); -end; - -{$IFNDEF AUTOREFCOUNT} - -class procedure TSkObject.__MarkDestroying(const Obj); -var - LRef: Integer; -begin - repeat - LRef := TSkObject(Obj).FRefCount; - until AtomicCmpExchange(TSkObject(Obj).FRefCount, LRef or objDestroyingFlag, LRef) = LRef; -end; - -{$ENDIF} - -class procedure TSkObject.__RefHandle(const AHandle: THandle); -begin -end; - -class function TSkObject.__ReleaseHandle(const AObject: ISkObject): THandle; -var - LObject: TSkObject; -begin - if not Assigned(AObject) then - Exit(0); - LObject := AObject as TSkObject; - Result := LObject.GetHandle; - if not LObject.FOwnsHandle then - raise ESkException.Create('Current object is not owner of the handle'); - LObject.FOwnsHandle := False; -end; - -class procedure TSkObject.__UnrefHandle(const AHandle: THandle); -begin -end; - -{ TSkReferenceCounted } - -class procedure TSkReferenceCounted.__RefHandle(const AHandle: THandle); -begin - sk4d_refcnt_ref(AHandle); -end; - -class procedure TSkReferenceCounted.__UnrefHandle(const AHandle: THandle); -begin - sk4d_refcnt_unref(AHandle); -end; - -{ TSkEnumerator } - -constructor TSkEnumerator.Create(const AEnumerable: TSkEnumerable); -begin - inherited Create; - FEnumerable := AEnumerable; -end; - -function TSkEnumerator.GetCurrent: T; -begin - Result := FEnumerable.GetCurrent; -end; - -function TSkEnumerator.MoveNext: Boolean; -begin - Result := FEnumerable.MoveNext; -end; - -{ TSkEnumerable } - -function TSkEnumerable.GetEnumerator: TSkEnumerator; -begin - Result := TSkEnumerator.Create(Self); -end; - -{ TSkColorMatrix } - -constructor TSkColorMatrix.Create(const AM11, AM12, AM13, AM14, AM15, AM21, - AM22, AM23, AM24, AM25, AM31, AM32, AM33, AM34, AM35, AM41, AM42, AM43, AM44, - AM45: Single); -begin - M11 := AM11; - M12 := AM12; - M13 := AM13; - M14 := AM14; - M15 := AM15; - M21 := AM21; - M22 := AM22; - M23 := AM23; - M24 := AM24; - M25 := AM25; - M31 := AM31; - M32 := AM32; - M33 := AM33; - M34 := AM34; - M35 := AM35; - M41 := AM41; - M42 := AM42; - M43 := AM43; - M44 := AM44; - M45 := AM45; -end; - -class function TSkColorMatrix.CreateSaturation( - const ASaturation: Single): TSkColorMatrix; -const - HueR = 0.213; - HueG = 0.715; - HueB = 0.072; -var - LB: Single; - LG: Single; - LR: Single; -begin - LR := HueR * (1 - ASaturation); - LG := HueG * (1 - ASaturation); - LB := HueB * (1 - ASaturation); - Result.M11 := LR + ASaturation; - Result.M12 := LG; - Result.M13 := LB; - Result.M14 := 0; - Result.M15 := 0; - Result.M21 := LR; - Result.M22 := LG + ASaturation; - Result.M23 := LB; - Result.M24 := 0; - Result.M25 := 0; - Result.M31 := LR; - Result.M32 := LG; - Result.M33 := LB + ASaturation; - Result.M34 := 0; - Result.M35 := 0; - Result.M41 := 0; - Result.M42 := 0; - Result.M43 := 0; - Result.M44 := 1; - Result.M45 := 0; -end; - -class function TSkColorMatrix.CreateScale(const AScaleR, AScaleG, AScaleB, - AScaleA: Single): TSkColorMatrix; -begin - Result.M11 := AScaleR; - Result.M12 := 0; - Result.M13 := 0; - Result.M14 := 0; - Result.M15 := 0; - Result.M21 := 0; - Result.M22 := AScaleG; - Result.M23 := 0; - Result.M24 := 0; - Result.M25 := 0; - Result.M31 := 0; - Result.M32 := 0; - Result.M33 := AScaleB; - Result.M34 := 0; - Result.M35 := 0; - Result.M41 := 0; - Result.M42 := 0; - Result.M43 := 0; - Result.M44 := AScaleA; - Result.M45 := 0; -end; - -class operator TSkColorMatrix.Equal(const AColorMatrix1, - AColorMatrix2: TSkColorMatrix): Boolean; -begin - Result := (SameValue(AColorMatrix1.M11, AColorMatrix2.M11, Epsilon)) and - (SameValue(AColorMatrix1.M12, AColorMatrix2.M12, Epsilon)) and - (SameValue(AColorMatrix1.M13, AColorMatrix2.M13, Epsilon)) and - (SameValue(AColorMatrix1.M14, AColorMatrix2.M14, Epsilon)) and - (SameValue(AColorMatrix1.M15, AColorMatrix2.M15, Epsilon)) and - (SameValue(AColorMatrix1.M21, AColorMatrix2.M21, Epsilon)) and - (SameValue(AColorMatrix1.M22, AColorMatrix2.M22, Epsilon)) and - (SameValue(AColorMatrix1.M23, AColorMatrix2.M23, Epsilon)) and - (SameValue(AColorMatrix1.M24, AColorMatrix2.M24, Epsilon)) and - (SameValue(AColorMatrix1.M25, AColorMatrix2.M25, Epsilon)) and - (SameValue(AColorMatrix1.M31, AColorMatrix2.M31, Epsilon)) and - (SameValue(AColorMatrix1.M32, AColorMatrix2.M32, Epsilon)) and - (SameValue(AColorMatrix1.M33, AColorMatrix2.M33, Epsilon)) and - (SameValue(AColorMatrix1.M34, AColorMatrix2.M34, Epsilon)) and - (SameValue(AColorMatrix1.M35, AColorMatrix2.M35, Epsilon)) and - (SameValue(AColorMatrix1.M41, AColorMatrix2.M41, Epsilon)) and - (SameValue(AColorMatrix1.M42, AColorMatrix2.M42, Epsilon)) and - (SameValue(AColorMatrix1.M43, AColorMatrix2.M43, Epsilon)) and - (SameValue(AColorMatrix1.M44, AColorMatrix2.M44, Epsilon)) and - (SameValue(AColorMatrix1.M45, AColorMatrix2.M45, Epsilon)); -end; - -class function TSkColorMatrix.Identity: TSkColorMatrix; -begin - Result := SkColorMatrixIdentity; -end; - -class operator TSkColorMatrix.Multiply(const AColorMatrix1, - AColorMatrix2: TSkColorMatrix): TSkColorMatrix; -begin - Result.M11 := AColorMatrix2.M11 * AColorMatrix1.M11 + AColorMatrix2.M12 * AColorMatrix1.M21 + AColorMatrix2.M13 * AColorMatrix1.M31 + AColorMatrix2.M14 * AColorMatrix1.M41; - Result.M12 := AColorMatrix2.M11 * AColorMatrix1.M12 + AColorMatrix2.M12 * AColorMatrix1.M22 + AColorMatrix2.M13 * AColorMatrix1.M32 + AColorMatrix2.M14 * AColorMatrix1.M42; - Result.M13 := AColorMatrix2.M11 * AColorMatrix1.M13 + AColorMatrix2.M12 * AColorMatrix1.M23 + AColorMatrix2.M13 * AColorMatrix1.M33 + AColorMatrix2.M14 * AColorMatrix1.M43; - Result.M14 := AColorMatrix2.M11 * AColorMatrix1.M14 + AColorMatrix2.M12 * AColorMatrix1.M24 + AColorMatrix2.M13 * AColorMatrix1.M34 + AColorMatrix2.M14 * AColorMatrix1.M44; - Result.M15 := AColorMatrix2.M11 * AColorMatrix1.M15 + AColorMatrix2.M12 * AColorMatrix1.M25 + AColorMatrix2.M13 * AColorMatrix1.M35 + AColorMatrix2.M14 * AColorMatrix1.M45 + AColorMatrix2.M15; - Result.M21 := AColorMatrix2.M21 * AColorMatrix1.M11 + AColorMatrix2.M22 * AColorMatrix1.M21 + AColorMatrix2.M23 * AColorMatrix1.M31 + AColorMatrix2.M24 * AColorMatrix1.M41; - Result.M22 := AColorMatrix2.M21 * AColorMatrix1.M12 + AColorMatrix2.M22 * AColorMatrix1.M22 + AColorMatrix2.M23 * AColorMatrix1.M32 + AColorMatrix2.M24 * AColorMatrix1.M42; - Result.M23 := AColorMatrix2.M21 * AColorMatrix1.M13 + AColorMatrix2.M22 * AColorMatrix1.M23 + AColorMatrix2.M23 * AColorMatrix1.M33 + AColorMatrix2.M24 * AColorMatrix1.M43; - Result.M24 := AColorMatrix2.M21 * AColorMatrix1.M14 + AColorMatrix2.M22 * AColorMatrix1.M24 + AColorMatrix2.M23 * AColorMatrix1.M34 + AColorMatrix2.M24 * AColorMatrix1.M44; - Result.M25 := AColorMatrix2.M21 * AColorMatrix1.M15 + AColorMatrix2.M22 * AColorMatrix1.M25 + AColorMatrix2.M23 * AColorMatrix1.M35 + AColorMatrix2.M24 * AColorMatrix1.M45 + AColorMatrix2.M25; - Result.M31 := AColorMatrix2.M31 * AColorMatrix1.M11 + AColorMatrix2.M32 * AColorMatrix1.M21 + AColorMatrix2.M33 * AColorMatrix1.M31 + AColorMatrix2.M34 * AColorMatrix1.M41; - Result.M32 := AColorMatrix2.M31 * AColorMatrix1.M12 + AColorMatrix2.M32 * AColorMatrix1.M22 + AColorMatrix2.M33 * AColorMatrix1.M32 + AColorMatrix2.M34 * AColorMatrix1.M42; - Result.M33 := AColorMatrix2.M31 * AColorMatrix1.M13 + AColorMatrix2.M32 * AColorMatrix1.M23 + AColorMatrix2.M33 * AColorMatrix1.M33 + AColorMatrix2.M34 * AColorMatrix1.M43; - Result.M34 := AColorMatrix2.M31 * AColorMatrix1.M14 + AColorMatrix2.M32 * AColorMatrix1.M24 + AColorMatrix2.M33 * AColorMatrix1.M34 + AColorMatrix2.M34 * AColorMatrix1.M44; - Result.M35 := AColorMatrix2.M31 * AColorMatrix1.M15 + AColorMatrix2.M32 * AColorMatrix1.M25 + AColorMatrix2.M33 * AColorMatrix1.M35 + AColorMatrix2.M34 * AColorMatrix1.M45 + AColorMatrix2.M35; - Result.M41 := AColorMatrix2.M41 * AColorMatrix1.M11 + AColorMatrix2.M42 * AColorMatrix1.M21 + AColorMatrix2.M43 * AColorMatrix1.M31 + AColorMatrix2.M44 * AColorMatrix1.M41; - Result.M42 := AColorMatrix2.M41 * AColorMatrix1.M12 + AColorMatrix2.M42 * AColorMatrix1.M22 + AColorMatrix2.M43 * AColorMatrix1.M32 + AColorMatrix2.M44 * AColorMatrix1.M42; - Result.M43 := AColorMatrix2.M41 * AColorMatrix1.M13 + AColorMatrix2.M42 * AColorMatrix1.M23 + AColorMatrix2.M43 * AColorMatrix1.M33 + AColorMatrix2.M44 * AColorMatrix1.M43; - Result.M44 := AColorMatrix2.M41 * AColorMatrix1.M14 + AColorMatrix2.M42 * AColorMatrix1.M24 + AColorMatrix2.M43 * AColorMatrix1.M34 + AColorMatrix2.M44 * AColorMatrix1.M44; - Result.M45 := AColorMatrix2.M41 * AColorMatrix1.M15 + AColorMatrix2.M42 * AColorMatrix1.M25 + AColorMatrix2.M43 * AColorMatrix1.M35 + AColorMatrix2.M44 * AColorMatrix1.M45 + AColorMatrix2.M45; -end; - -class operator TSkColorMatrix.NotEqual(const AColorMatrix1, - AColorMatrix2: TSkColorMatrix): Boolean; -begin - Result := not (AColorMatrix1 = AColorMatrix2); -end; - -{ TSkColorSpaceXyz } - -function TSkColorSpaceXyz.Adjoint: TSkColorSpaceXyz; -begin - Result.M11 := (M22 * M33 - M32 * M23); - Result.M12 := -(M12 * M33 - M32 * M13); - Result.M13 := (M12 * M23 - M22 * M13); - Result.M21 := -(M21 * M33 - M31 * M23); - Result.M22 := (M11 * M33 - M31 * M13); - Result.M23 := -(M11 * M23 - M21 * M13); - Result.M31 := (M21 * M32 - M31 * M22); - Result.M32 := -(M11 * M32 - M31 * M12); - Result.M33 := (M11 * M22 - M21 * M12); -end; - -class function TSkColorSpaceXyz.AdobeRGB: TSkColorSpaceXyz; -begin - Result := SkColorSpaceXyzAdobeRGB; -end; - -constructor TSkColorSpaceXyz.Create(const AM11, AM12, AM13, AM21, AM22, AM23, - AM31, AM32, AM33: Single); -begin - M11 := AM11; - M12 := AM12; - M13 := AM13; - M21 := AM21; - M22 := AM22; - M23 := AM23; - M31 := AM31; - M32 := AM32; - M33 := AM33; -end; - -function TSkColorSpaceXyz.Determinant: Single; -begin - Result := M11 * (M22 * M33 - M32 * M23) - - M12 * (M21 * M33 - M31 * M23) + - M13 * (M21 * M32 - M31 * M22); -end; - -class function TSkColorSpaceXyz.DisplayP3: TSkColorSpaceXyz; -begin - Result := SkColorSpaceXyzDisplayP3; -end; - -class operator TSkColorSpaceXyz.Equal(const AColorSpaceXyz1, - AColorSpaceXyz2: TSkColorSpaceXyz): Boolean; -begin - Result := (SameValue(AColorSpaceXyz1.M11, AColorSpaceXyz2.M11, Epsilon)) and - (SameValue(AColorSpaceXyz1.M12, AColorSpaceXyz2.M12, Epsilon)) and - (SameValue(AColorSpaceXyz1.M13, AColorSpaceXyz2.M13, Epsilon)) and - (SameValue(AColorSpaceXyz1.M21, AColorSpaceXyz2.M21, Epsilon)) and - (SameValue(AColorSpaceXyz1.M22, AColorSpaceXyz2.M22, Epsilon)) and - (SameValue(AColorSpaceXyz1.M23, AColorSpaceXyz2.M23, Epsilon)) and - (SameValue(AColorSpaceXyz1.M31, AColorSpaceXyz2.M31, Epsilon)) and - (SameValue(AColorSpaceXyz1.M32, AColorSpaceXyz2.M32, Epsilon)) and - (SameValue(AColorSpaceXyz1.M33, AColorSpaceXyz2.M33, Epsilon)); -end; - -class function TSkColorSpaceXyz.Identity: TSkColorSpaceXyz; -begin - Result := SkColorSpaceXyzIdentity; -end; - -function TSkColorSpaceXyz.Inverse: TSkColorSpaceXyz; -var - LDeterminant: Single; - LFactor: Single; -begin - LDeterminant := Self.Determinant; - if IsZero(LDeterminant) then - Exit(TSkColorSpaceXyz.Identity); - LFactor := 1 / LDeterminant; - Result.M11 := M11 * LFactor; - Result.M12 := M12 * LFactor; - Result.M13 := M13 * LFactor; - Result.M21 := M21 * LFactor; - Result.M22 := M22 * LFactor; - Result.M23 := M23 * LFactor; - Result.M31 := M31 * LFactor; - Result.M32 := M32 * LFactor; - Result.M33 := M33 * LFactor; -end; - -class operator TSkColorSpaceXyz.Multiply(const AColorSpaceXyz1, - AColorSpaceXyz2: TSkColorSpaceXyz): TSkColorSpaceXyz; -begin - Result.M11 := AColorSpaceXyz1.M11 * AColorSpaceXyz2.M11 + AColorSpaceXyz1.M12 * AColorSpaceXyz2.M21 + AColorSpaceXyz1.M13 * AColorSpaceXyz2.M31; - Result.M12 := AColorSpaceXyz1.M11 * AColorSpaceXyz2.M12 + AColorSpaceXyz1.M12 * AColorSpaceXyz2.M22 + AColorSpaceXyz1.M13 * AColorSpaceXyz2.M32; - Result.M13 := AColorSpaceXyz1.M11 * AColorSpaceXyz2.M13 + AColorSpaceXyz1.M12 * AColorSpaceXyz2.M23 + AColorSpaceXyz1.M13 * AColorSpaceXyz2.M33; - Result.M21 := AColorSpaceXyz1.M21 * AColorSpaceXyz2.M11 + AColorSpaceXyz1.M22 * AColorSpaceXyz2.M21 + AColorSpaceXyz1.M23 * AColorSpaceXyz2.M31; - Result.M22 := AColorSpaceXyz1.M21 * AColorSpaceXyz2.M12 + AColorSpaceXyz1.M22 * AColorSpaceXyz2.M22 + AColorSpaceXyz1.M23 * AColorSpaceXyz2.M32; - Result.M23 := AColorSpaceXyz1.M21 * AColorSpaceXyz2.M13 + AColorSpaceXyz1.M22 * AColorSpaceXyz2.M23 + AColorSpaceXyz1.M23 * AColorSpaceXyz2.M33; - Result.M31 := AColorSpaceXyz1.M31 * AColorSpaceXyz2.M11 + AColorSpaceXyz1.M32 * AColorSpaceXyz2.M21 + AColorSpaceXyz1.M33 * AColorSpaceXyz2.M31; - Result.M32 := AColorSpaceXyz1.M31 * AColorSpaceXyz2.M12 + AColorSpaceXyz1.M32 * AColorSpaceXyz2.M22 + AColorSpaceXyz1.M33 * AColorSpaceXyz2.M32; - Result.M33 := AColorSpaceXyz1.M31 * AColorSpaceXyz2.M13 + AColorSpaceXyz1.M32 * AColorSpaceXyz2.M23 + AColorSpaceXyz1.M33 * AColorSpaceXyz2.M33; -end; - -class operator TSkColorSpaceXyz.NotEqual(const AColorSpaceXyz1, - AColorSpaceXyz2: TSkColorSpaceXyz): Boolean; -begin - Result := not (AColorSpaceXyz1 = AColorSpaceXyz2); -end; - -class function TSkColorSpaceXyz.Rec2020: TSkColorSpaceXyz; -begin - Result := SkColorSpaceXyzRec2020; -end; - -class function TSkColorSpaceXyz.SRGB: TSkColorSpaceXyz; -begin - Result := SkColorSpaceXyzSRGB; -end; - -{ TSkColorSpacePrimaries } - -constructor TSkColorSpacePrimaries.Create(const ARX, ARY, AGX, AGY, ABX, ABY, - AWX, AWY: Single); -begin - RX := ARX; - RY := ARY; - GX := AGX; - GY := AGY; - BX := ABX; - BY := ABY; - WX := AWX; - WY := AWY; -end; - -class operator TSkColorSpacePrimaries.Equal(const AColorSpacePrimaries1, - AColorSpacePrimaries2: TSkColorSpacePrimaries): Boolean; -begin - Result := (SameValue(AColorSpacePrimaries1.RX, AColorSpacePrimaries2.RX, Epsilon)) and - (SameValue(AColorSpacePrimaries1.RY, AColorSpacePrimaries2.RY, Epsilon)) and - (SameValue(AColorSpacePrimaries1.GX, AColorSpacePrimaries2.GX, Epsilon)) and - (SameValue(AColorSpacePrimaries1.GY, AColorSpacePrimaries2.GY, Epsilon)) and - (SameValue(AColorSpacePrimaries1.BX, AColorSpacePrimaries2.BX, Epsilon)) and - (SameValue(AColorSpacePrimaries1.BY, AColorSpacePrimaries2.BY, Epsilon)) and - (SameValue(AColorSpacePrimaries1.WX, AColorSpacePrimaries2.WX, Epsilon)) and - (SameValue(AColorSpacePrimaries1.WY, AColorSpacePrimaries2.WY, Epsilon)); -end; - -class operator TSkColorSpacePrimaries.Implicit( - const AColorSpacePrimaries: TSkColorSpacePrimaries): TSkColorSpaceXyz; -begin - if not sk4d_colorspaceprimaries_to_xyz(@sk_colorspaceprimaries_t(AColorSpacePrimaries), sk_colorspacexyz_t(Result)) then - Result := TSkColorSpaceXyz.Identity; -end; - -class operator TSkColorSpacePrimaries.NotEqual(const AColorSpacePrimaries1, - AColorSpacePrimaries2: TSkColorSpacePrimaries): Boolean; -begin - Result := not (AColorSpacePrimaries1 = AColorSpacePrimaries2); -end; - -{ TSkColorSpaceTransferFunction } - -constructor TSkColorSpaceTransferFunction.Create(const AG, AA, AB, AC, AD, AE, - AF: Single); -begin - G := AG; - A := AA; - B := AB; - C := AC; - D := AD; - E := AE; - F := AF; -end; - -class operator TSkColorSpaceTransferFunction.Equal( - const AColorSpaceTransferFunction1, - AColorSpaceTransferFunction2: TSkColorSpaceTransferFunction): Boolean; -begin - Result := (SameValue(AColorSpaceTransferFunction1.G, AColorSpaceTransferFunction2.G, Epsilon)) and - (SameValue(AColorSpaceTransferFunction1.A, AColorSpaceTransferFunction2.A, Epsilon)) and - (SameValue(AColorSpaceTransferFunction1.B, AColorSpaceTransferFunction2.B, Epsilon)) and - (SameValue(AColorSpaceTransferFunction1.C, AColorSpaceTransferFunction2.C, Epsilon)) and - (SameValue(AColorSpaceTransferFunction1.D, AColorSpaceTransferFunction2.D, Epsilon)) and - (SameValue(AColorSpaceTransferFunction1.E, AColorSpaceTransferFunction2.E, Epsilon)) and - (SameValue(AColorSpaceTransferFunction1.F, AColorSpaceTransferFunction2.F, Epsilon)); -end; - -class function TSkColorSpaceTransferFunction.HLG: TSkColorSpaceTransferFunction; -begin - Result := SkColorSpaceTransferFunctionHLG; -end; - -function TSkColorSpaceTransferFunction.Invert( - out ATransferFunction: TSkColorSpaceTransferFunction): Boolean; -begin - Result := sk4d_colorspacetransferfn_invert(@sk_colorspacetransferfn_t(Self), sk_colorspacetransferfn_t(ATransferFunction)); -end; - -class function TSkColorSpaceTransferFunction.Linear: TSkColorSpaceTransferFunction; -begin - Result := SkColorSpaceTransferFunctionLinear; -end; - -class operator TSkColorSpaceTransferFunction.NotEqual( - const AColorSpaceTransferFunction1, - AColorSpaceTransferFunction2: TSkColorSpaceTransferFunction): Boolean; -begin - Result := not (AColorSpaceTransferFunction1 = AColorSpaceTransferFunction2); -end; - -class function TSkColorSpaceTransferFunction.PQ: TSkColorSpaceTransferFunction; -begin - Result := SkColorSpaceTransferFunctionPQ; -end; - -class function TSkColorSpaceTransferFunction.Rec2020: TSkColorSpaceTransferFunction; -begin - Result := SkColorSpaceTransferFunctionRec2020; -end; - -class function TSkColorSpaceTransferFunction.SRGB: TSkColorSpaceTransferFunction; -begin - Result := SkColorSpaceTransferFunctionSRGB; -end; - -function TSkColorSpaceTransferFunction.Transform(const AX: Single): Single; -begin - Result := sk4d_colorspacetransferfn_transform(@sk_colorspacetransferfn_t(Self), AX); -end; - -class function TSkColorSpaceTransferFunction.TwoDotTwo: TSkColorSpaceTransferFunction; -begin - Result := SkColorSpaceTransferFunctionTwoDotTwo; -end; - -{ TSkCubicResampler } - -class function TSkCubicResampler.CatmullRom: TSkCubicResampler; -begin - Result := SkCubicResamplerCatmullRom; -end; - -constructor TSkCubicResampler.Create(const AB, AC: Single); -begin - B := AB; - C := AC; -end; - -class operator TSkCubicResampler.Equal(const ACubicResampler1, - ACubicResampler2: TSkCubicResampler): Boolean; -begin - Result := (SameValue(ACubicResampler1.B, ACubicResampler2.B, Epsilon)) and - (SameValue(ACubicResampler1.C, ACubicResampler2.C, Epsilon)); -end; - -class function TSkCubicResampler.Mitchell: TSkCubicResampler; -begin - Result := SkCubicResamplerMitchell; -end; - -class operator TSkCubicResampler.NotEqual(const ACubicResampler1, - ACubicResampler2: TSkCubicResampler): Boolean; -begin - Result := not (ACubicResampler1 = ACubicResampler2); -end; - -{ TSkFontMetrics } - -class operator TSkFontMetrics.Equal(const AFontMetrics1, - AFontMetrics2: TSkFontMetrics): Boolean; -begin - Result := (AFontMetrics1.Flags = AFontMetrics2.Flags) and - (SameValue(AFontMetrics1.Top, AFontMetrics2.Top, Epsilon)) and - (SameValue(AFontMetrics1.Ascent, AFontMetrics2.Ascent, Epsilon)) and - (SameValue(AFontMetrics1.Descent, AFontMetrics2.Descent, Epsilon)) and - (SameValue(AFontMetrics1.Bottom, AFontMetrics2.Bottom, Epsilon)) and - (SameValue(AFontMetrics1.Leading, AFontMetrics2.Leading, Epsilon)) and - (SameValue(AFontMetrics1.AvgCharWidth, AFontMetrics2.AvgCharWidth, Epsilon)) and - (SameValue(AFontMetrics1.MaxCharWidth, AFontMetrics2.MaxCharWidth, Epsilon)) and - (SameValue(AFontMetrics1.XMin, AFontMetrics2.XMin, Epsilon)) and - (SameValue(AFontMetrics1.XMax, AFontMetrics2.XMax, Epsilon)) and - (SameValue(AFontMetrics1.XMax, AFontMetrics2.XMax, Epsilon)) and - (SameValue(AFontMetrics1.XHeight, AFontMetrics2.XHeight, Epsilon)) and - (SameValue(AFontMetrics1.UnderlineThickness, AFontMetrics2.UnderlineThickness, Epsilon)) and - (SameValue(AFontMetrics1.UnderlinePosition, AFontMetrics2.UnderlinePosition, Epsilon)) and - (SameValue(AFontMetrics1.StrikeoutThickness, AFontMetrics2.StrikeoutThickness, Epsilon)) and - (SameValue(AFontMetrics1.StrikeoutPosition, AFontMetrics2.StrikeoutPosition, Epsilon)); -end; - -class operator TSkFontMetrics.NotEqual(const AFontMetrics1, - AFontMetrics2: TSkFontMetrics): Boolean; -begin - Result := not (AFontMetrics1 = AFontMetrics2); -end; - -{ TSkFontStyle } - -class function TSkFontStyle.Bold: TSkFontStyle; -begin - Result := SkFontStyleBold; -end; - -class function TSkFontStyle.BoldItalic: TSkFontStyle; -begin - Result := SkFontStyleBoldItalic; -end; - -constructor TSkFontStyle.Create(const AWeight, AWidth: Integer; - const ASlant: TSkFontSlant); -begin - Weight := AWeight; - Width := AWidth; - Slant := ASlant; -end; - -constructor TSkFontStyle.Create(const AWeight: TSkFontWeight; - const AWidth: TSkFontWidth; const ASlant: TSkFontSlant); -begin - Weight := Ord(AWeight); - Width := Ord(AWidth); - Slant := ASlant; -end; - -class operator TSkFontStyle.Equal(const AFontStyle1, - AFontStyle2: TSkFontStyle): Boolean; -begin - Result := (AFontStyle1.Weight = AFontStyle2.Weight) and - (AFontStyle1.Width = AFontStyle2.Width ) and - (AFontStyle1.Slant = AFontStyle2.Slant ); -end; - -class function TSkFontStyle.Italic: TSkFontStyle; -begin - Result := SkFontStyleItalic; -end; - -class function TSkFontStyle.Normal: TSkFontStyle; -begin - Result := SkFontStyleNormal; -end; - -class operator TSkFontStyle.NotEqual(const AFontStyle1, - AFontStyle2: TSkFontStyle): Boolean; -begin - Result := not (AFontStyle1 = AFontStyle2); -end; - -{ TSkGraphics } - -class procedure TSkGraphics.AllowJIT; -begin - sk4d_graphics_allow_jit(); -end; - -class procedure TSkGraphics.DumpMemoryStatistics( - const ATraceMemoryDump: ISkTraceMemoryDump); -begin - if not Assigned(ATraceMemoryDump) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATraceMemoryDump']); - sk4d_graphics_dump_memory_statistics(ATraceMemoryDump.Handle); -end; - -class function TSkGraphics.GetFontCacheCountLimit: Integer; -begin - Result := sk4d_graphics_get_font_cache_count_limit(); -end; - -class function TSkGraphics.GetFontCacheCountUsed: Integer; -begin - Result := sk4d_graphics_get_font_cache_count_used(); -end; - -class function TSkGraphics.GetFontCacheLimit: NativeUInt; -begin - Result := sk4d_graphics_get_font_cache_limit(); -end; - -class function TSkGraphics.GetFontCacheUsed: NativeUInt; -begin - Result := sk4d_graphics_get_font_cache_used(); -end; - -class function TSkGraphics.GetResourceCacheSingleAllocationByteLimit: NativeUInt; -begin - Result := sk4d_graphics_get_resource_cache_single_allocation_byte_limit(); -end; - -class function TSkGraphics.GetResourceCacheTotalByteLimit: NativeUInt; -begin - Result := sk4d_graphics_get_resource_cache_total_byte_limit(); -end; - -class function TSkGraphics.GetResourceCacheTotalBytesUsed: NativeUInt; -begin - Result := sk4d_graphics_get_resource_cache_total_bytes_used(); -end; - -class procedure TSkGraphics.Init; -begin - sk4d_graphics_init(); -end; - -class procedure TSkGraphics.PurgeAllCaches; -begin - sk4d_graphics_purge_all_caches(); -end; - -class procedure TSkGraphics.PurgeFontCache; -begin - sk4d_graphics_purge_font_cache(); -end; - -class procedure TSkGraphics.PurgeResourceCache; -begin - sk4d_graphics_purge_resource_cache(); -end; - -class procedure TSkGraphics.SetFontCacheCountLimit(const AValue: Integer); -begin - sk4d_graphics_set_font_cache_count_limit(AValue); -end; - -class procedure TSkGraphics.SetFontCacheLimit(const AValue: NativeUInt); -begin - sk4d_graphics_set_font_cache_limit(AValue); -end; - -class procedure TSkGraphics.SetResourceCacheSingleAllocationByteLimit( - const AValue: NativeUInt); -begin - sk4d_graphics_set_resource_cache_single_allocation_byte_limit(AValue); -end; - -class procedure TSkGraphics.SetResourceCacheTotalByteLimit( - const AValue: NativeUInt); -begin - sk4d_graphics_set_resource_cache_total_byte_limit(AValue); -end; - -{ TSkHighContrastConfig } - -constructor TSkHighContrastConfig.Create(const AGrayscale: Boolean; - const AInvertStyle: TSkContrastInvertStyle; const AContrast: Single); -begin - Grayscale := AGrayscale; - InvertStyle := AInvertStyle; - Contrast := AContrast; -end; - -class operator TSkHighContrastConfig.Equal(const AHighContrastConfig1, - AHighContrastConfig2: TSkHighContrastConfig): Boolean; -begin - Result := (AHighContrastConfig1.Grayscale = AHighContrastConfig2.Grayscale ) and - (AHighContrastConfig1.InvertStyle = AHighContrastConfig2.InvertStyle) and - (SameValue(AHighContrastConfig1.Contrast, AHighContrastConfig2.Contrast, Epsilon)); -end; - -class operator TSkHighContrastConfig.NotEqual(const AHighContrastConfig1, - AHighContrastConfig2: TSkHighContrastConfig): Boolean; -begin - Result := not (AHighContrastConfig1 <> AHighContrastConfig2); -end; - -{ TSkImageInfo } - -function TSkImageInfo.ByteSize(const ARowBytes: NativeUInt): NativeUInt; -begin - Result := ARowBytes * NativeUInt(Height); -end; - -function TSkImageInfo.BytesPerPixel: Integer; -begin - Result := SkBytesPerPixel[ColorType]; -end; - -constructor TSkImageInfo.Create(const AWidth, AHeight: Integer); -begin - Width := AWidth; - Height := AHeight; - ColorType := SkNative32ColorType; - AlphaType := TSkAlphaType.Premul; - ColorSpace := nil; -end; - -constructor TSkImageInfo.Create(const AWidth, AHeight: Integer; - const AColorType: TSkColorType; const AAlphaType: TSkAlphaType; - AColorSpace: ISkColorSpace); -begin - Width := AWidth; - Height := AHeight; - ColorType := AColorType; - AlphaType := AAlphaType; - ColorSpace := AColorSpace; -end; - -class operator TSkImageInfo.Equal(const AImageInfo1, - AImageInfo2: TSkImageInfo): Boolean; -begin - Result := (AImageInfo1.Width = AImageInfo2.Width ) and - (AImageInfo1.Height = AImageInfo2.Height ) and - (AImageInfo1.ColorType = AImageInfo2.ColorType) and - (AImageInfo1.AlphaType = AImageInfo2.AlphaType) and - (Assigned(AImageInfo1.ColorSpace) = Assigned(AImageInfo1.ColorSpace)) and ((not Assigned(AImageInfo1.ColorSpace)) or (AImageInfo1.ColorSpace.IsEqual(AImageInfo2.ColorSpace))); -end; - -function TSkImageInfo.IsEmpty: Boolean; -begin - Result := (Width <= 0) or (Height <= 0); -end; - -function TSkImageInfo.IsOpaque: Boolean; -begin - Result := AlphaType = TSkAlphaType.Opaque; -end; - -function TSkImageInfo.IsValid: Boolean; -const - MaxDimension = MaxInt shr 2; -begin - if (IsEmpty) or (Width > MaxDimension) or (Height > MaxDimension) or (ColorType = TSkColorType.Unknown) or (AlphaType = TSkAlphaType.Unknown) then - Exit(False); - case ColorType of - TSkColorType.Alpha8, - TSkColorType.AlphaF16, - TSkColorType.Alpha16: - begin - if (AlphaType <> TSkAlphaType.Opaque) and (AlphaType <> TSkAlphaType.Premul) then - Exit(False); - end; - TSkColorType.RGB565, - TSkColorType.RGB888X, - TSkColorType.RGB101010X, - TSkColorType.BGR101010X, - TSkColorType.Gray8, - TSkColorType.RG88, - TSkColorType.RGF16, - TSkColorType.RG1616: - begin - if AlphaType <> TSkAlphaType.Opaque then - Exit(False); - end; - end; - Result := True; -end; - -function TSkImageInfo.IsValidRowBytes(const ARowBytes: NativeUInt): Boolean; -begin - if ARowBytes < MinRowBytes then - Exit(False); - Result := ARowBytes = (ARowBytes shr ShiftPerPixel shl ShiftPerPixel); -end; - -function TSkImageInfo.MakeAlphaType( - const AAlphaType: TSkAlphaType): TSkImageInfo; -begin - Result.Width := Width; - Result.Height := Height; - Result.ColorType := ColorType; - Result.AlphaType := AAlphaType; - Result.ColorSpace := ColorSpace; -end; - -function TSkImageInfo.MakeColorSpace(AColorSpace: ISkColorSpace): TSkImageInfo; -begin - Result.Width := Width; - Result.Height := Height; - Result.ColorType := ColorType; - Result.AlphaType := AlphaType; - Result.ColorSpace := AColorSpace; -end; - -function TSkImageInfo.MakeColorType( - const AColorType: TSkColorType): TSkImageInfo; -begin - Result.Width := Width; - Result.Height := Height; - Result.ColorType := AColorType; - Result.AlphaType := AlphaType; - Result.ColorSpace := ColorSpace; -end; - -function TSkImageInfo.MakeDimensions(const AWidth, - AHeight: Integer): TSkImageInfo; -begin - Result.Width := AWidth; - Result.Height := AHeight; - Result.ColorType := ColorType; - Result.AlphaType := AlphaType; - Result.ColorSpace := ColorSpace; -end; - -function TSkImageInfo.MinByteSize: NativeUInt; -begin - Result := ByteSize(MinRowBytes); -end; - -function TSkImageInfo.MinRowBytes: NativeUInt; -begin - Result := Width * BytesPerPixel; -end; - -class operator TSkImageInfo.NotEqual(const AImageInfo1, - AImageInfo2: TSkImageInfo): Boolean; -begin - Result := not (AImageInfo1 = AImageInfo2); -end; - -function TSkImageInfo.ShiftPerPixel: Integer; -begin - Result := SkShiftPerPixel[ColorType]; -end; - -{ TSkImageEncoder } - -class function TSkImageEncoder.Encode(const ASrc: ISkPixmap; - const AEncodedImageFormat: TSkEncodedImageFormat; - const AQuality: Integer): TBytes; -var - LBytesStream: TBytesStream; -begin - LBytesStream := TBytesStream.Create; - try - EncodeToStream(LBytesStream, ASrc, AEncodedImageFormat, AQuality); - Result := Copy(LBytesStream.Bytes, 0, LBytesStream.Size); - finally - LBytesStream.Free; - end; -end; - -class function TSkImageEncoder.Encode(const ASrcImageInfo: TSkImageInfo; - const ASrcPixels: Pointer; const ASrcRowBytes: NativeUInt; - const AEncodedImageFormat: TSkEncodedImageFormat; - const AQuality: Integer): TBytes; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ASrcImageInfo, ASrcPixels, ASrcRowBytes); - Result := Encode(LPixmap, AEncodedImageFormat, AQuality); -end; - -class function TSkImageEncoder.EncodeToFile(const AFileName: string; - const ASrcImageInfo: TSkImageInfo; const ASrcPixels: Pointer; - const ASrcRowBytes: NativeUInt; const AQuality: Integer): Boolean; -begin - Result := EncodeToFile(AFileName, ASrcImageInfo, ASrcPixels, ASrcRowBytes, ExtensionToEncodedImageFormat(TPath.GetExtension(AFileName)), AQuality); -end; - -class function TSkImageEncoder.EncodeToFile(const AFileName: string; - const ASrc: ISkPixmap; const AEncodedImageFormat: TSkEncodedImageFormat; - const AQuality: Integer): Boolean; -var - LMarshaller: TMarshaller; -begin - if AFileName.IsEmpty then - raise ESkException.Create(SFileNameIsEmpty); - if not Assigned(ASrc) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ASrc']); - Result := sk4d_imageencoder_encode_to_file(LMarshaller.AsUtf8(AFileName).ToPointer, ASrc.Handle, sk_encodedimageformat_t(AEncodedImageFormat), AQuality); -end; - -class function TSkImageEncoder.EncodeToFile(const AFileName: string; - const ASrc: ISkPixmap; const AQuality: Integer): Boolean; -begin - Result := EncodeToFile(AFileName, ASrc, ExtensionToEncodedImageFormat(TPath.GetExtension(AFileName)), AQuality); -end; - -class function TSkImageEncoder.EncodeToFile(const AFileName: string; - const ASrcImageInfo: TSkImageInfo; const ASrcPixels: Pointer; - const ASrcRowBytes: NativeUInt; - const AEncodedImageFormat: TSkEncodedImageFormat; - const AQuality: Integer): Boolean; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ASrcImageInfo, ASrcPixels, ASrcRowBytes); - Result := EncodeToFile(AFileName, LPixmap, AEncodedImageFormat, AQuality); -end; - -class function TSkImageEncoder.EncodeToStream(const AStream: TStream; - const ASrc: ISkPixmap; const AEncodedImageFormat: TSkEncodedImageFormat; - const AQuality: Integer): Boolean; -var - LWStream: ISkWStream; -begin - if not Assigned(ASrc) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ASrc']); - LWStream := TSkWStreamAdapter.Create(AStream); - Result := sk4d_imageencoder_encode_to_stream(LWStream.Handle, ASrc.Handle, sk_encodedimageformat_t(AEncodedImageFormat), AQuality); -end; - -class function TSkImageEncoder.EncodeToStream(const AStream: TStream; - const ASrcImageInfo: TSkImageInfo; const ASrcPixels: Pointer; - const ASrcRowBytes: NativeUInt; - const AEncodedImageFormat: TSkEncodedImageFormat; - const AQuality: Integer): Boolean; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ASrcImageInfo, ASrcPixels, ASrcRowBytes); - Result := EncodeToStream(AStream, LPixmap, AEncodedImageFormat, AQuality); -end; - -{ TSkLattice } - -constructor TSkLattice.Create(const AXDivs, AYDivs: TArray; - ABounds: TRect; const ARectTypes: TArray; - const AColors: TArray); -begin - if Length(AXDivs) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AXDivs']); - if Length(AYDivs) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AYDivs']); - if (Length(ARectTypes) > 0) then - begin - if Length(ARectTypes) <> ((Length(AXDivs) + 1) * (Length(AYDivs) + 1)) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['ARectTypes']); - if Length(AColors) <> Length(ARectTypes) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AColors']); - end; - FXDivs := AXDivs; - FYDivs := AYDivs; - FRectTypes := ARectTypes; - FColors := AColors; - FUseBounds := True; - FBounds := ABounds; -end; - -constructor TSkLattice.Create(const AXDivs, AYDivs: TArray; - const ARectTypes: TArray; - const AColors: TArray); -begin - if Length(AXDivs) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AXDivs']); - if Length(AYDivs) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AYDivs']); - if (Length(ARectTypes) > 0) then - begin - if Length(ARectTypes) <> ((Length(AXDivs) + 1) * (Length(AYDivs) + 1)) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['ARectTypes']); - if Length(AColors) <> Length(ARectTypes) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AColors']); - end; - FXDivs := AXDivs; - FYDivs := AYDivs; - FRectTypes := ARectTypes; - FColors := AColors; - FUseBounds := False; -end; - -{ TSkMetrics } - -class operator TSkMetrics.Equal(const AMetrics1, - AMetrics2: TSkMetrics): Boolean; -begin - Result := (AMetrics1.StartIndex = AMetrics2.StartIndex ) and - (AMetrics1.EndIndex = AMetrics2.EndIndex ) and - (AMetrics1.EndExcludingWhitespaces = AMetrics2.EndExcludingWhitespaces) and - (AMetrics1.EndIncludingNewline = AMetrics2.EndIncludingNewline ) and - (AMetrics1.IsHardBreak = AMetrics2.IsHardBreak ) and - (AMetrics1.LineNumber = AMetrics2.LineNumber ) and - (SameValue(AMetrics1.Ascent, AMetrics2.Ascent, Epsilon)) and - (SameValue(AMetrics1.Descent, AMetrics2.Descent, Epsilon)) and - (SameValue(AMetrics1.Height, AMetrics2.Height, Epsilon)) and - (SameValue(AMetrics1.Width, AMetrics2.Width, Epsilon)) and - (SameValue(AMetrics1.Left, AMetrics2.Left, Epsilon)) and - (SameValue(AMetrics1.Baseline, AMetrics2.Baseline, Epsilon)); -end; - -class operator TSkMetrics.NotEqual(const AMetrics1, - AMetrics2: TSkMetrics): Boolean; -begin - Result := not (AMetrics1 = AMetrics2); -end; - -{ TSkPDFMetadata } - -constructor TSkPDFMetadata.Create(const ATitle, AAuthor, ASubject, AKeywords, - ACreator, AProducer: string; const ARasterDPI: Single; const APDFA: Boolean; - const AEncodingQuality: Integer); -begin - Title := ATitle; - Author := AAuthor; - Subject := ASubject; - Keywords := AKeywords; - Creator := ACreator; - Producer := AProducer; - Creation := Now; - Modified := Now; - RasterDPI := ARasterDPI; - PDFA := APDFA; - EncodingQuality := AEncodingQuality; -end; - -constructor TSkPDFMetadata.Create(const ATitle, AAuthor, ASubject, AKeywords, - ACreator: string; const ACreation, AModified: TDateTime; - const AProducer: string; const ARasterDPI: Single; const APDFA: Boolean; - const AEncodingQuality: Integer); -begin - Title := ATitle; - Author := AAuthor; - Subject := ASubject; - Keywords := AKeywords; - Creator := ACreator; - Producer := AProducer; - Creation := ACreation; - Modified := AModified; - RasterDPI := ARasterDPI; - PDFA := APDFA; - EncodingQuality := AEncodingQuality; -end; - -class operator TSkPDFMetadata.Equal(const APDFMetadata1, - APDFMetadata2: TSkPDFMetadata): Boolean; -begin - Result := (APDFMetadata1.Title = APDFMetadata2.Title ) and - (APDFMetadata1.Author = APDFMetadata2.Author ) and - (APDFMetadata1.Subject = APDFMetadata2.Subject ) and - (APDFMetadata1.Keywords = APDFMetadata2.Keywords ) and - (APDFMetadata1.Creator = APDFMetadata2.Creator ) and - (APDFMetadata1.Producer = APDFMetadata2.Producer ) and - (APDFMetadata1.Creation = APDFMetadata2.Creation ) and - (APDFMetadata1.Modified = APDFMetadata2.Modified ) and - (APDFMetadata1.PDFA = APDFMetadata2.PDFA ) and - (APDFMetadata1.EncodingQuality = APDFMetadata2.EncodingQuality) and - (SameValue(APDFMetadata1.RasterDPI, APDFMetadata2.RasterDPI, Epsilon)); -end; - -class operator TSkPDFMetadata.NotEqual(const APDFMetadata1, - APDFMetadata2: TSkPDFMetadata): Boolean; -begin - Result := not (APDFMetadata1 = APDFMetadata2); -end; - -{ TSkPlaceholderStyle } - -constructor TSkPlaceholderStyle.Create(const AWidth, AHeight: Single; - const AAlignment: TSkPlaceholderAlignment; const ABaseline: TSkTextBaseline; - const ABaselineOffset: Single); -begin - Width := AWidth; - Height := AHeight; - Alignment := AAlignment; - Baseline := ABaseline; - BaselineOffset := ABaselineOffset; -end; - -class operator TSkPlaceholderStyle.Equal(const APlaceholderStyle1, - APlaceholderStyle2: TSkPlaceholderStyle): Boolean; -begin - Result := (APlaceholderStyle1.Alignment = APlaceholderStyle2.Alignment) and - (APlaceholderStyle1.Baseline = APlaceholderStyle2.Baseline ) and - (SameValue(APlaceholderStyle1.Width, APlaceholderStyle2.Width, Epsilon)) and - (SameValue(APlaceholderStyle1.Height, APlaceholderStyle2.Height, Epsilon)) and - ((APlaceholderStyle1.Alignment <> TSkPlaceholderAlignment.Baseline) or (SameValue(APlaceholderStyle1.BaselineOffset, APlaceholderStyle2.BaselineOffset, Epsilon))); -end; - -class operator TSkPlaceholderStyle.NotEqual(const APlaceholderStyle1, - APlaceholderStyle2: TSkPlaceholderStyle): Boolean; -begin - Result := not (APlaceholderStyle1 = APlaceholderStyle2); -end; - -{ TSkPositionAffinity } - -class operator TSkPositionAffinity.Equal(const APositionAffinity1, - APositionAffinity2: TSkPositionAffinity): Boolean; -begin - Result := (APositionAffinity1.Position = APositionAffinity2.Position) and - (APositionAffinity1.Affinity = APositionAffinity2.Affinity); -end; - -class operator TSkPositionAffinity.NotEqual(const APositionAffinity1, - APositionAffinity2: TSkPositionAffinity): Boolean; -begin - Result := not (APositionAffinity1 = APositionAffinity2); -end; - -{ TSkRotationScaleMatrix } - -constructor TSkRotationScaleMatrix.Create(const ASCosinus, ASSinus, ATranslateX, - ATranslateY: Single); -begin - SCosinus := ASCosinus; - SSinus := ASSinus; - TranslateX := ATranslateX; - TranslateY := ATranslateY; -end; - -class function TSkRotationScaleMatrix.CreateDegrees(const AScale, ADegrees, - ATranslateX, ATranslateY, AAnchorX, AAnchorY: Single): TSkRotationScaleMatrix; -begin - SinCos(DegToRad(ADegrees), Result.SSinus, Result.SCosinus); - Result.SSinus := Result.SSinus * AScale; - Result.SCosinus := Result.SCosinus * AScale; - Result.TranslateX := ATranslateX + -Result.SCosinus * AAnchorX + Result.SSinus * AAnchorY; - Result.TranslateY := ATranslateY + -Result.SSinus * AAnchorX - Result.SCosinus * AAnchorY; -end; - -class function TSkRotationScaleMatrix.CreateRadians(const AScale, ARadians, - ATranslateX, ATranslateY, AAnchorX, AAnchorY: Single): TSkRotationScaleMatrix; -begin - SinCos(ARadians, Result.SSinus, Result.SCosinus); - Result.SSinus := Result.SSinus * AScale; - Result.SCosinus := Result.SCosinus * AScale; - Result.TranslateX := ATranslateX + -Result.SCosinus * AAnchorX + Result.SSinus * AAnchorY; - Result.TranslateY := ATranslateY + -Result.SSinus * AAnchorX - Result.SCosinus * AAnchorY; -end; - -class operator TSkRotationScaleMatrix.Equal(const ARotationScaleMatrix1, - ARotationScaleMatrix2: TSkRotationScaleMatrix): Boolean; -begin - Result := (SameValue(ARotationScaleMatrix1.SCosinus, ARotationScaleMatrix2.SCosinus, Epsilon)) and - (SameValue(ARotationScaleMatrix1.SSinus, ARotationScaleMatrix2.SSinus, Epsilon)) and - (SameValue(ARotationScaleMatrix1.TranslateX, ARotationScaleMatrix2.TranslateX, Epsilon)) and - (SameValue(ARotationScaleMatrix1.TranslateY, ARotationScaleMatrix2.TranslateY, Epsilon)); -end; - -class function TSkRotationScaleMatrix.Identity: TSkRotationScaleMatrix; -begin - Result := SkRotationScaleMatrixIdentity; -end; - -class operator TSkRotationScaleMatrix.Implicit( - const ARotationScaleMatrix: TSkRotationScaleMatrix): TMatrix; -begin - Result.m11 := ARotationScaleMatrix.SCosinus; - Result.m12 := ARotationScaleMatrix.SSinus; - Result.m13 := 0; - Result.m21 := -ARotationScaleMatrix.SSinus; - Result.m22 := ARotationScaleMatrix.SCosinus; - Result.m23 := 0; - Result.m31 := ARotationScaleMatrix.TranslateX; - Result.m32 := ARotationScaleMatrix.TranslateY; - Result.m33 := 1; -end; - -class operator TSkRotationScaleMatrix.NotEqual(const ARotationScaleMatrix1, - ARotationScaleMatrix2: TSkRotationScaleMatrix): Boolean; -begin - Result := not (ARotationScaleMatrix1 = ARotationScaleMatrix2); -end; - -{ TSkRuntimeEffectFloat2 } - -constructor TSkRuntimeEffectFloat2.Create(const AV1, AV2: Single); -begin - V1 := AV1; - V2 := AV2; -end; - -{ TSkRuntimeEffectFloat3 } - -constructor TSkRuntimeEffectFloat3.Create(const AV1, AV2, AV3: Single); -begin - V1 := AV1; - V2 := AV2; - V3 := AV3; -end; - -{ TSkRuntimeEffectFloat4 } - -constructor TSkRuntimeEffectFloat4.Create(const AV1, AV2, AV3, AV4: Single); -begin - V1 := AV1; - V2 := AV2; - V3 := AV3; - V4 := AV4; -end; - -{ TSkRuntimeEffectFloat2x2 } - -constructor TSkRuntimeEffectFloat2x2.Create(const AV11, AV12, AV21, - AV22: Single); -begin - V11 := AV11; - V12 := AV12; - V21 := AV21; - V22 := AV22; -end; - -{ TSkRuntimeEffectFloat3x3 } - -constructor TSkRuntimeEffectFloat3x3.Create(const AV11, AV12, AV13, AV21, AV22, - AV23, AV31, AV32, AV33: Single); -begin - V11 := AV11; - V12 := AV12; - V13 := AV13; - V21 := AV21; - V22 := AV22; - V23 := AV23; - V31 := AV31; - V32 := AV32; - V33 := AV33; -end; - -{ TSkRuntimeEffectFloat4x4 } - -constructor TSkRuntimeEffectFloat4x4.Create(const AV11, AV12, AV13, AV14, AV21, - AV22, AV23, AV24, AV31, AV32, AV33, AV34, AV41, AV42, AV43, AV44: Single); -begin - V11 := AV11; - V12 := AV12; - V13 := AV13; - V14 := AV14; - V21 := AV21; - V22 := AV22; - V23 := AV23; - V24 := AV24; - V31 := AV31; - V32 := AV32; - V33 := AV33; - V34 := AV34; - V41 := AV41; - V42 := AV42; - V43 := AV43; - V44 := AV44; -end; - -{ TSkRuntimeEffectInt2 } - -constructor TSkRuntimeEffectInt2.Create(const AV1, AV2: Integer); -begin - V1 := AV1; - V2 := AV2; -end; - -{ TSkRuntimeEffectInt3 } - -constructor TSkRuntimeEffectInt3.Create(const AV1, AV2, AV3: Integer); -begin - V1 := AV1; - V2 := AV2; - V3 := AV3; -end; - -{ TSkRuntimeEffectInt4 } - -constructor TSkRuntimeEffectInt4.Create(const AV1, AV2, AV3, AV4: Integer); -begin - V1 := AV1; - V2 := AV2; - V3 := AV3; - V4 := AV4; -end; - -{ TSkSamplingOptions } - -constructor TSkSamplingOptions.Create(const ACubic: TSkCubicResampler); -begin - FMaxAnisotropic := 0; - FUseCubic := True; - FCubic := ACubic; - FFilter := TSkFilterMode.Nearest; - FMipmap := TSkMipmapMode.None; -end; - -constructor TSkSamplingOptions.Create(const AFilter: TSkFilterMode; - const AMipmap: TSkMipmapMode); -begin - FMaxAnisotropic := 0; - FUseCubic := False; - FCubic := TSkCubicResampler.Create(0, 0); - FFilter := AFilter; - FMipmap := AMipmap; -end; - -constructor TSkSamplingOptions.Create(const AMaxAnisotropic: Integer); -begin - FMaxAnisotropic := Max(AMaxAnisotropic, 1); - FUseCubic := False; - FCubic := TSkCubicResampler.Create(0, 0); - FFilter := TSkFilterMode.Nearest; - FMipmap := TSkMipmapMode.None; -end; - -class operator TSkSamplingOptions.Equal(const ASamplingOptions1, - ASamplingOptions2: TSkSamplingOptions): Boolean; -begin - Result := (ASamplingOptions1.FMaxAnisotropic = ASamplingOptions2.FMaxAnisotropic) and - (ASamplingOptions1.FUseCubic = ASamplingOptions2.FUseCubic ) and - (ASamplingOptions1.FCubic = ASamplingOptions2.FCubic ) and - (ASamplingOptions1.FFilter = ASamplingOptions2.FFilter ) and - (ASamplingOptions1.FMipmap = ASamplingOptions2.FMipmap ); -end; - -class function TSkSamplingOptions.High: TSkSamplingOptions; -begin - Result := SkSamplingOptionsHigh; -end; - -class function TSkSamplingOptions.Low: TSkSamplingOptions; -begin - Result := SkSamplingOptionsLow; -end; - -class function TSkSamplingOptions.Medium: TSkSamplingOptions; -begin - Result := SkSamplingOptionsMedium; -end; - -class operator TSkSamplingOptions.NotEqual(const ASamplingOptions1, - ASamplingOptions2: TSkSamplingOptions): Boolean; -begin - Result := not (ASamplingOptions1 = ASamplingOptions2); -end; - -{ TSkSurfaceProperties } - -constructor TSkSurfaceProperties.Create(const AFlags: TSkSurfacePropertiesFlags; - const APixelGeometry: TSkPixelGeometry); -begin - Flags := AFlags; - PixelGeometry := APixelGeometry; -end; - -class operator TSkSurfaceProperties.Equal(const ASurfaceProperties1, - ASurfaceProperties2: TSkSurfaceProperties): Boolean; -begin - Result := (ASurfaceProperties1.Flags = ASurfaceProperties2.Flags ) and - (ASurfaceProperties1.PixelGeometry = ASurfaceProperties2.PixelGeometry); -end; - -class operator TSkSurfaceProperties.NotEqual(const ASurfaceProperties1, - ASurfaceProperties2: TSkSurfaceProperties): Boolean; -begin - Result := not (ASurfaceProperties1 = ASurfaceProperties2); -end; - -{ TSkSVGLength } - -constructor TSkSVGLength.Create(const AValue: Single; - const AUnit: TSkSVGLengthUnit); -begin - Value := AValue; - &Unit := AUnit; -end; - -class operator TSkSVGLength.Equal(const ASVGLength1, - ASVGLength2: TSkSVGLength): Boolean; -begin - Result := (ASVGLength1.&Unit = ASVGLength2.&Unit) and - (SameValue(ASVGLength1.Value, ASVGLength2.Value, Epsilon)); -end; - -class operator TSkSVGLength.NotEqual(const ASVGLength1, - ASVGLength2: TSkSVGLength): Boolean; -begin - Result := not (ASVGLength1 = ASVGLength2); -end; - -{ TSkSVGPreserveAspectRatio } - -constructor TSkSVGPreserveAspectRatio.Create(const AAlign: TSkSVGAspectAlign; - const AScale: TSkSVGAspectScale); -begin - Align := AAlign; - Scale := AScale; -end; - -class operator TSkSVGPreserveAspectRatio.Equal(const ASVGPreserveAspectRatio1, - ASVGPreserveAspectRatio2: TSkSVGPreserveAspectRatio): Boolean; -begin - Result := (ASVGPreserveAspectRatio1.Align = ASVGPreserveAspectRatio2.Align) and - (ASVGPreserveAspectRatio1.Scale = ASVGPreserveAspectRatio2.Scale); -end; - -class operator TSkSVGPreserveAspectRatio.NotEqual( - const ASVGPreserveAspectRatio1, - ASVGPreserveAspectRatio2: TSkSVGPreserveAspectRatio): Boolean; -begin - Result := not (ASVGPreserveAspectRatio1 = ASVGPreserveAspectRatio2); -end; - -{ TSkTextBox } - -class operator TSkTextBox.Equal(const ATextBox1, - ATextBox2: TSkTextBox): Boolean; -begin - Result := (ATextBox1.Rect = ATextBox2.Rect ) and - (ATextBox1.Direction = ATextBox2.Direction); -end; - -class operator TSkTextBox.NotEqual(const ATextBox1, - ATextBox2: TSkTextBox): Boolean; -begin - Result := not (ATextBox1 = ATextBox2) -end; - -{ TSkTextShadow } - -constructor TSkTextShadow.Create(const AColor: TAlphaColor; - const AOffset: TPointF; const ABlurRadius: Double); -begin - Color := AColor; - Offset := AOffset; - BlurRadius := ABlurRadius; -end; - -class operator TSkTextShadow.Equal(const ATextShadow1, - ATextShadow2: TSkTextShadow): Boolean; -begin - Result := (ATextShadow1.Color = ATextShadow2.Color ) and - (ATextShadow1.Offset = ATextShadow2.Offset) and - (SameValue(ATextShadow1.BlurRadius, ATextShadow2.BlurRadius, Epsilon)); -end; - -class operator TSkTextShadow.NotEqual(const ATextShadow1, - ATextShadow2: TSkTextShadow): Boolean; -begin - Result := not (ATextShadow1 = ATextShadow2); -end; - -{ TGrBackendRenderTarget } - -constructor TGrBackendRenderTarget.CreateGl(const AWidth, AHeight, ASampleCount, - AStencilBits: Integer; const AFramebufferInfo: TGrGlFramebufferInfo); -begin - inherited Create(gr4d_backendrendertarget_create_gl(AWidth, AHeight, ASampleCount, AStencilBits, @gr_gl_framebufferinfo_t(AFramebufferInfo))) -end; - -constructor TGrBackendRenderTarget.CreateMetal(const AWidth, AHeight: Integer; - const ATextureInfo: TGrMtlTextureInfo); -begin - inherited Create(gr4d_backendrendertarget_create_mtl(AWidth, AHeight, @gr_mtl_textureinfo_t(ATextureInfo))); -end; - -constructor TGrBackendRenderTarget.CreateVulkan(const AWidth, AHeight: Integer; - const AImageInfo: TGrVkImageInfo); -var - LImageInfo: gr_vk_imageinfo_t; -begin - LImageInfo := TSkBindings.AsGrVkImageInfo(AImageInfo); - inherited Create(gr4d_backendrendertarget_create_vk(AWidth, AHeight, @LImageInfo)); -end; - -function TGrBackendRenderTarget.GetBackendAPI: TGrBackendAPI; -begin - Result := TGrBackendAPI(gr4d_backendrendertarget_get_backend_api(Handle)); -end; - -function TGrBackendRenderTarget.GetHeight: Integer; -begin - Result := gr4d_backendrendertarget_get_height(Handle); -end; - -function TGrBackendRenderTarget.GetSampleCount: Integer; -begin - Result := gr4d_backendrendertarget_get_sample_count(Handle); -end; - -function TGrBackendRenderTarget.GetStencilBits: Integer; -begin - Result := gr4d_backendrendertarget_get_stencil_bits(Handle); -end; - -function TGrBackendRenderTarget.GetWidth: Integer; -begin - Result := gr4d_backendrendertarget_get_width(Handle); -end; - -function TGrBackendRenderTarget.IsValid: Boolean; -begin - Result := gr4d_backendrendertarget_is_valid(Handle); -end; - -class procedure TGrBackendRenderTarget.__DestroyHandle(const AHandle: THandle); -begin - gr4d_backendrendertarget_destroy(AHandle); -end; - -{ TGrBackendTexture } - -constructor TGrBackendTexture.CreateGl(const AWidth, AHeight: Integer; - const AIsMipmapped: Boolean; const ATextureInfo: TGrGlTextureInfo); -begin - inherited Create(gr4d_backendtexture_create_gl(AWidth, AHeight, AIsMipmapped, @gr_gl_textureinfo_t(ATextureInfo))); -end; - -constructor TGrBackendTexture.CreateMetal(const AWidth, AHeight: Integer; - const AIsMipmapped: Boolean; const ATextureInfo: TGrMtlTextureInfo); -begin - inherited Create(gr4d_backendtexture_create_mtl(AWidth, AHeight, AIsMipmapped, @gr_mtl_textureinfo_t(ATextureInfo))); -end; - -constructor TGrBackendTexture.CreateVulkan(const AWidth, AHeight: Integer; - const AImageInfo: TGrVkImageInfo); -var - LImageInfo: gr_vk_imageinfo_t; -begin - LImageInfo := TSkBindings.AsGrVkImageInfo(AImageInfo); - inherited Create(gr4d_backendtexture_create_vk(AWidth, AHeight, @LImageInfo)); -end; - -function TGrBackendTexture.GetBackendAPI: TGrBackendAPI; -begin - Result := TGrBackendAPI(gr4d_backendtexture_get_backend_api(Handle)); -end; - -function TGrBackendTexture.GetGlTextureInfo( - out ATextureInfo: TGrGlTextureInfo): Boolean; -begin - Result := gr4d_backendtexture_get_gl_framebuffer_info(Handle, gr_gl_textureinfo_t(ATextureInfo)); -end; - -function TGrBackendTexture.GetHeight: Integer; -begin - Result := gr4d_backendtexture_get_height(Handle); -end; - -function TGrBackendTexture.GetWidth: Integer; -begin - Result := gr4d_backendtexture_get_width(Handle); -end; - -function TGrBackendTexture.HasMipmaps: Boolean; -begin - Result := gr4d_backendtexture_has_mipmaps(Handle); -end; - -function TGrBackendTexture.IsValid: Boolean; -begin - Result := gr4d_backendtexture_is_valid(Handle); -end; - -class procedure TGrBackendTexture.__DestroyHandle(const AHandle: THandle); -begin - gr4d_backendtexture_destroy(AHandle); -end; - -{ TGrDirectContext } - -procedure TGrDirectContext.AbandonContext; -begin - gr4d_directcontext_abandon_context(Handle); -end; - -procedure TGrDirectContext.DumpMemoryStatistics( - const ATraceMemoryDump: ISkTraceMemoryDump); -begin - if not Assigned(ATraceMemoryDump) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATraceMemoryDump']); - gr4d_directcontext_dump_memory_statistics(Handle, ATraceMemoryDump.Handle); -end; - -procedure TGrDirectContext.Flush; -begin - gr4d_directcontext_flush(Handle); -end; - -procedure TGrDirectContext.FlushAndSubmit(const ASyncCpu: Boolean); -begin - gr4d_directcontext_flush_and_submit(Handle, ASyncCpu); -end; - -procedure TGrDirectContext.FreeGpuResources; -begin - gr4d_directcontext_free_gpu_resources(Handle); -end; - -function TGrDirectContext.GetBackendAPI: TGrBackendAPI; -begin - Result := TGrBackendAPI(gr4d_directcontext_get_backend_api(Handle)); -end; - -function TGrDirectContext.GetMaxSurfaceSampleCountForColorType( - const AColorType: TSkColorType): Integer; -begin - Result := gr4d_directcontext_get_max_surface_sample_count_for_color_type(Handle, sk_colortype_t(AColorType)); -end; - -function TGrDirectContext.GetResourceCacheLimit: NativeUInt; -begin - Result := gr4d_directcontext_get_resource_cache_limit(Handle); -end; - -procedure TGrDirectContext.GetResourceCacheUsage(out AResources: Integer; - out AResourcesBytes: NativeUInt); -begin - gr4d_directcontext_get_resource_cache_usage(Handle, AResources, AResourcesBytes); -end; - -function TGrDirectContext.IsAbandoned: Boolean; -begin - Result := gr4d_directcontext_is_abandoned(Handle); -end; - -class function TGrDirectContext.MakeGl(const AOptions: TGrContextOptions; - const AInterface: IGrGlInterface): IGrDirectContext; -var - LOptions: gr_contextoptions_t; -begin - LOptions := TSkBindings.AsGrContextOptions(AOptions); - Result := TSkBindings.SafeCreate(gr4d_directcontext_make_gl(TSkBindings.SafeHandle(AInterface), @LOptions)); -end; - -class function TGrDirectContext.MakeGl( - AInterface: IGrGlInterface): IGrDirectContext; -begin - Result := TSkBindings.SafeCreate(gr4d_directcontext_make_gl(TSkBindings.SafeHandle(AInterface), nil)); -end; - -class function TGrDirectContext.MakeMetal( - const ABackendContext: TGrMtlBackendContext): IGrDirectContext; -begin - Result := TSkBindings.SafeCreate(gr4d_directcontext_make_metal(@gr_mtl_backendcontext_t(ABackendContext), nil)); -end; - -class function TGrDirectContext.MakeMetal( - const ABackendContext: TGrMtlBackendContext; - const AOptions: TGrContextOptions): IGrDirectContext; -var - LOptions: gr_contextoptions_t; -begin - LOptions := TSkBindings.AsGrContextOptions(AOptions); - Result := TSkBindings.SafeCreate(gr4d_directcontext_make_metal(@gr_mtl_backendcontext_t(ABackendContext), @LOptions)); -end; - -class function TGrDirectContext.MakeVulkan( - const ABackendContext: TGrVkBackendContext; - const AOptions: TGrContextOptions): IGrDirectContext; -var - LBackendContext: gr_vk_backendcontext_t; - LOptions: gr_contextoptions_t; -begin - LBackendContext := TSkBindings.AsGrVkBackendContext(ABackendContext); - LOptions := TSkBindings.AsGrContextOptions(AOptions); - Result := TSkBindings.SafeCreate(gr4d_directcontext_make_vulkan(@LBackendContext, @LOptions)); -end; - -class function TGrDirectContext.MakeVulkan( - const ABackendContext: TGrVkBackendContext): IGrDirectContext; -var - LBackendContext: gr_vk_backendcontext_t; -begin - LBackendContext := TSkBindings.AsGrVkBackendContext(ABackendContext); - Result := TSkBindings.SafeCreate(gr4d_directcontext_make_vulkan(@LBackendContext, nil)); -end; - -procedure TGrDirectContext.PerformDeferredCleanup(const AMilliseconds: Int64); -begin - gr4d_directcontext_perform_deferred_cleanup(Handle, AMilliseconds); -end; - -procedure TGrDirectContext.PurgeUnlockedResources( - const AScratchResourcesOnly: Boolean); -begin - gr4d_directcontext_purge_unlocked_resources(Handle, AScratchResourcesOnly); -end; - -procedure TGrDirectContext.PurgeUnlockedResources( - const ABytesToPurge: NativeUInt; const APreferScratchResources: Boolean); -begin - gr4d_directcontext_purge_unlocked_resources2(Handle, ABytesToPurge, APreferScratchResources); -end; - -procedure TGrDirectContext.ReleaseResourcesAndAbandonContext; -begin - gr4d_directcontext_release_resources_and_abandon_context(Handle); -end; - -procedure TGrDirectContext.ResetContext; -begin - gr4d_directcontext_reset_context(Handle); -end; - -procedure TGrDirectContext.SetResourceCacheLimit(const AValue: NativeUInt); -begin - gr4d_directcontext_set_resource_cache_limit(Handle, AValue); -end; - -function TGrDirectContext.Submit(const ASyncCpu: Boolean): Boolean; -begin - Result := gr4d_directcontext_submit(Handle, ASyncCpu); -end; - -{ TGrGlInterface } - -function TGrGlInterface.HasExtension(const AName: string): Boolean; -var - LMarshaller: TMarshaller; -begin - Result := gr4d_gl_interface_has_extension(Handle, LMarshaller.AsUtf8(AName).ToPointer); -end; - -class function TGrGlInterface.MakeAssembled( - const AProc: TGrGlGetProc): IGrGlInterface; -begin - if not Assigned(AProc) then - Exit(nil); - Result := TSkBindings.SafeCreate(gr4d_gl_interface_make_assembled(@AProc, TSkBindings.__gr_gl_get_proc)); -end; - -class function TGrGlInterface.MakeAssembledGl( - const AProc: TGrGlGetProc): IGrGlInterface; -begin - if not Assigned(AProc) then - Exit(nil); - Result := TSkBindings.SafeCreate(gr4d_gl_interface_make_assembled_gl(@AProc, TSkBindings.__gr_gl_get_proc)); -end; - -class function TGrGlInterface.MakeAssembledGles( - const AProc: TGrGlGetProc): IGrGlInterface; -begin - if not Assigned(AProc) then - Exit(nil); - Result := TSkBindings.SafeCreate(gr4d_gl_interface_make_assembled_gles(@AProc, TSkBindings.__gr_gl_get_proc)); -end; - -class function TGrGlInterface.MakeAssembledWebGl( - const AProc: TGrGlGetProc): IGrGlInterface; -begin - if not Assigned(AProc) then - Exit(nil); - Result := TSkBindings.SafeCreate(gr4d_gl_interface_make_assembled_webgl(@AProc, TSkBindings.__gr_gl_get_proc)); -end; - -class function TGrGlInterface.MakeNative: IGrGlInterface; -begin - Result := TSkBindings.SafeCreate(gr4d_gl_interface_make_native()); -end; - -function TGrGlInterface.Validate: Boolean; -begin - Result := gr4d_gl_interface_validate(Handle); -end; - -{ TGrPersistentCacheBaseClass } - -class constructor TGrPersistentCacheBaseClass.Create; -var - LProcs: gr_persistentcachebaseclass_procs_t; -begin - LProcs.load := load_proc; - LProcs.store := store_proc; - gr4d_persistentcachebaseclass_set_procs(@LProcs); -end; - -constructor TGrPersistentCacheBaseClass.Create; -begin - inherited Create(gr4d_persistentcachebaseclass_create(Self)); -end; - -class function TGrPersistentCacheBaseClass.load_proc(context: Pointer; - const key_data: Pointer; key_size: size_t): sk_data_t; -var - LKey: TBytes; -begin - SetLength(LKey, key_size); - Move(key_data^, LKey[0], Length(LKey)); - Result := TSkObject.__ReleaseHandle(TSkData.MakeFromBytes(TGrPersistentCacheBaseClass(context).Load(LKey))); -end; - -class procedure TGrPersistentCacheBaseClass.store_proc(context: Pointer; - const key_data: Pointer; key_size: size_t; const data: Pointer; size: size_t); -var - LData: TBytes; - LKey: TBytes; -begin - SetLength(LKey, key_size); - Move(key_data^, LKey[0], Length(LKey)); - SetLength(LData, size); - Move(data^, LData[0], Length(LData)); - TGrPersistentCacheBaseClass(context).Store(LKey, LData); -end; - -class procedure TGrPersistentCacheBaseClass.__DestroyHandle( - const AHandle: THandle); -begin - gr4d_persistentcachebaseclass_destroy(AHandle); -end; - -{ TGrShaderErrorHandlerBaseClass } - -class procedure TGrShaderErrorHandlerBaseClass.compile_error_proc( - context: Pointer; const shader, errors: MarshaledAString); -begin - TGrShaderErrorHandlerBaseClass(context).CompileError(string(shader), string(errors)); -end; - -class constructor TGrShaderErrorHandlerBaseClass.Create; -var - LProcs: gr_shadererrorhandlerbaseclass_procs_t; -begin - LProcs.compile_error := compile_error_proc; - gr4d_shadererrorhandlerbaseclass_set_procs(@LProcs); -end; - -constructor TGrShaderErrorHandlerBaseClass.Create; -begin - inherited Create(gr4d_shadererrorhandlerbaseclass_create(Self)); -end; - -class procedure TGrShaderErrorHandlerBaseClass.__DestroyHandle( - const AHandle: THandle); -begin - gr4d_shadererrorhandlerbaseclass_destroy(AHandle); -end; - -{ TGrVkExtensions } - -constructor TGrVkExtensions.Create; -begin - inherited Create(gr4d_vk_extensions_create()); -end; - -function TGrVkExtensions.HasExtension(const AName: string; - const AMinVersion: Cardinal): Boolean; -var - LMarshaller: TMarshaller; -begin - Result := gr4d_vk_extensions_has_extension(Handle, LMarshaller.AsUtf8(AName).ToPointer, AMinVersion); -end; - -procedure TGrVkExtensions.Init(const AProc: TGrVkGetProc; - const AInstance: GrVkInstance; const APhysicalDevice: GrVkPhysicalDevice; - const AInstanceExtensions, ADeviceExtensions: TArray); -begin - if not Assigned(AProc) then - Exit; - TSkBindings.SetStrings(Handle, AInstanceExtensions, ADeviceExtensions, - procedure (const AHandle: THandle; const AStrings1, AStrings2: PMarshaledAString) - begin - gr4d_vk_extensions_init(Handle, @AProc, TSkBindings.__gr_vk_get_proc, AInstance, APhysicalDevice, AStrings1, Length(AInstanceExtensions), AStrings2, Length(ADeviceExtensions)); - end); -end; - -class procedure TGrVkExtensions.__DestroyHandle(const AHandle: THandle); -begin - gr4d_vk_extensions_destroy(AHandle); -end; - -{ TSkBlender } - -class function TSkBlender.MakeArithmetic(const AK1, AK2, AK3, AK4: Single; - const AEnforcePremultipliedColor: Boolean): ISkBlender; -begin - Result := TSkBindings.SafeCreate(sk4d_blender_make_arithmetic(AK1, AK2, AK3, AK4, AEnforcePremultipliedColor)); -end; - -class function TSkBlender.MakeMode(const AMode: TSkBlendMode): ISkBlender; -begin - Result := TSkBindings.SafeCreate(sk4d_blender_make_mode(sk_blendmode_t(AMode))); -end; - -{ TSkCanvas } - -procedure TSkCanvas.Clear(const AColor: TAlphaColor); -begin - sk4d_canvas_clear(Handle, AColor); -end; - -procedure TSkCanvas.Clear(const AColor: TAlphaColorF); -begin - sk4d_canvas_clear2(Handle, @sk_color4f_t(AColor)); -end; - -procedure TSkCanvas.ClipPath(const APath: ISkPath; const AOp: TSkClipOp; - const AAntiAlias: Boolean); -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - sk4d_canvas_clip_path(Handle, APath.Handle, sk_clipop_t(AOp), AAntiAlias); -end; - -procedure TSkCanvas.ClipRect(const ARect: TRectF; const AOp: TSkClipOp; - const AAntiAlias: Boolean); -begin - sk4d_canvas_clip_rect(Handle, @sk_rect_t(ARect), sk_clipop_t(AOp), AAntiAlias); -end; - -procedure TSkCanvas.ClipRegion(const ARegion: ISkRegion; const AOp: TSkClipOp); -begin - if not Assigned(ARegion) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARegion']); - sk4d_canvas_clip_region(Handle, ARegion.Handle, sk_clipop_t(AOp)); -end; - -procedure TSkCanvas.ClipRoundRect(const ARoundRect: ISkRoundRect; - const AOp: TSkClipOp; const AAntiAlias: Boolean); -begin - if not Assigned(ARoundRect) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARoundRect']); - sk4d_canvas_clip_rrect(Handle, ARoundRect.Handle, sk_clipop_t(AOp), AAntiAlias); -end; - -procedure TSkCanvas.ClipShader(const AShader: ISkShader; const AOp: TSkClipOp); -begin - if not Assigned(AShader) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AShader']); - sk4d_canvas_clip_shader(Handle, AShader.Handle, sk_clipop_t(AOp)); -end; - -procedure TSkCanvas.Concat(const AMatrix: TMatrix); -begin - sk4d_canvas_concat2(Handle, @sk_matrix_t(AMatrix)); -end; - -procedure TSkCanvas.Concat(const AMatrix: TMatrix3D); -begin - sk4d_canvas_concat(Handle, @sk_matrix44_t(AMatrix)); -end; - -procedure TSkCanvas.Discard; -begin - sk4d_canvas_discard(Handle); -end; - -procedure TSkCanvas.DrawAnnotation(const ARect: TRectF; const AKey: string; - const AValue; const ASize: NativeUInt); -var - LMarshaller: TMarshaller; -begin - sk4d_canvas_draw_annotation(Handle, @sk_rect_t(ARect), LMarshaller.AsUtf8(AKey).ToPointer, @AValue, ASize); -end; - -procedure TSkCanvas.DrawAnnotation(const ARect: TRectF; const AKey: string); -var - LMarshaller: TMarshaller; -begin - sk4d_canvas_draw_annotation(Handle, @sk_rect_t(ARect), LMarshaller.AsUtf8(AKey).ToPointer, nil, 0); -end; - -procedure TSkCanvas.DrawArc(const AOval: TRectF; const AStartAngle, - ASweepAngle: Single; const AUseCenter: Boolean; const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_arc(Handle, @sk_rect_t(AOval), AStartAngle, ASweepAngle, AUseCenter, APaint.Handle); -end; - -procedure TSkCanvas.DrawAtlas(const AAtlas: ISkImage; - const ATansforms: TArray; - const ASprites: TArray; const ABlendMode: TSkBlendMode; - const ASampling: TSkSamplingOptions; const AColors: TArray; - const APaint: ISkPaint); -var - LColors: psk_color_t; -begin - if not Assigned(AAtlas) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AAtlas']); - if Length(ATansforms) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ATansforms']); - if Length(ASprites) <> Length(ATansforms) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['ASprites']); - if Length(AColors) > 0 then - begin - if Length(AColors) <> Length(ASprites) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AColors']); - LColors := @AColors[0]; - end - else - LColors := nil; - sk4d_canvas_draw_atlas(Handle, AAtlas.Handle, @sk_rotationscalematrix_t(ATansforms[0]), @sk_rect_t(ASprites[0]), LColors, Length(ATansforms), sk_blendmode_t(ABlendMode), @sk_samplingoptions_t(ASampling), nil, TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkCanvas.DrawAtlas(const AAtlas: ISkImage; - const ATansforms: TArray; - const ASprites: TArray; const ABlendMode: TSkBlendMode; - const ACullRect: TRectF; const AColors: TArray; - const APaint: ISkPaint); -begin - DrawAtlas(AAtlas, ATansforms, ASprites, ABlendMode, TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), ACullRect, AColors, APaint); -end; - -procedure TSkCanvas.DrawAtlas(const AAtlas: ISkImage; - const ATansforms: TArray; - const ASprites: TArray; const ABlendMode: TSkBlendMode; - const ASampling: TSkSamplingOptions; const ACullRect: TRectF; - const AColors: TArray; const APaint: ISkPaint); -var - LColors: psk_color_t; -begin - if not Assigned(AAtlas) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AAtlas']); - if Length(ATansforms) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ATansforms']); - if Length(ASprites) <> Length(ATansforms) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['ASprites']); - if Length(AColors) > 0 then - begin - if Length(AColors) <> Length(ASprites) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AColors']); - LColors := @AColors[0]; - end - else - LColors := nil; - sk4d_canvas_draw_atlas(Handle, AAtlas.Handle, @sk_rotationscalematrix_t(ATansforms[0]), @sk_rect_t(ASprites[0]), LColors, Length(ATansforms), sk_blendmode_t(ABlendMode), @sk_samplingoptions_t(ASampling), @sk_rect_t(ACullRect), TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkCanvas.DrawAtlas(const AAtlas: ISkImage; - const ATansforms: TArray; - const ASprites: TArray; const ABlendMode: TSkBlendMode; - const AColors: TArray; const APaint: ISkPaint); -begin - DrawAtlas(AAtlas, ATansforms, ASprites, ABlendMode, TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), AColors, APaint); -end; - -procedure TSkCanvas.DrawCircle(const ACenter: TPointF; ARadius: Single; - const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_circle(Handle, @sk_point_t(ACenter), ARadius, APaint.Handle); -end; - -procedure TSkCanvas.DrawCircle(const ACenterX, ACenterY, ARadius: Single; - const APaint: ISkPaint); -begin - DrawCircle(TPointF.Create(ACenterX, ACenterY), ARadius, APaint); -end; - -procedure TSkCanvas.DrawColor(const AColor: TAlphaColorF; - const ABlendMode: TSkBlendMode); -begin - sk4d_canvas_draw_color2(Handle, @sk_color4f_t(AColor), sk_blendmode_t(ABlendMode)); -end; - -procedure TSkCanvas.DrawColor(const AColor: TAlphaColor; - const ABlendMode: TSkBlendMode); -begin - sk4d_canvas_draw_color(Handle, AColor, sk_blendmode_t(ABlendMode)); -end; - -procedure TSkCanvas.DrawGlyphs(const AGlyphs: TArray; - const AMatrices: TArray; const AOrigin: TPointF; - const AFont: ISkFont; const APaint: ISkPaint); -begin - if Length(AMatrices) <> Length(AGlyphs) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AMatrices']); - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - if Length(AGlyphs) > 0 then - sk4d_canvas_draw_glyphs2(Handle, Length(AGlyphs), @AGlyphs[0], @sk_rotationscalematrix_t(AMatrices[0]), @sk_point_t(AOrigin), AFont.Handle, APaint.Handle); -end; - -procedure TSkCanvas.DrawGlyphs(const AGlyphs: TArray; - const APositions: TArray; const AOrigin: TPointF; - const AFont: ISkFont; const APaint: ISkPaint); -begin - if Length(APositions) <> Length(AGlyphs) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - if Length(AGlyphs) > 0 then - sk4d_canvas_draw_glyphs(Handle, Length(AGlyphs), @AGlyphs[0], @sk_point_t(APositions[0]), @sk_point_t(AOrigin), AFont.Handle, APaint.Handle); -end; - -procedure TSkCanvas.DrawImage(const AImage: ISkImage; const AX, AY: Single; - const APaint: ISkPaint); -begin - DrawImage(AImage, AX, AY, TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), APaint); -end; - -procedure TSkCanvas.DrawImage(const AImage: ISkImage; const AX, AY: Single; - const ASampling: TSkSamplingOptions; const APaint: ISkPaint); -begin - if not Assigned(AImage) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AImage']); - sk4d_canvas_draw_image(Handle, AImage.Handle, AX, AY, @sk_samplingoptions_t(ASampling), TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkCanvas.DrawImageLattice(const AImage: ISkImage; - const ALattice: TSkLattice; const ADest: TRectF; - const AFilterMode: TSkFilterMode; const APaint: ISkPaint); -var - LLattice: sk_lattice_t; -begin - if not Assigned(AImage) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AImage']); - LLattice := TSkBindings.AsLattice(ALattice); - sk4d_canvas_draw_image_lattice(Handle, AImage.Handle, @LLattice, @sk_rect_t(ADest), sk_filtermode_t(AFilterMode), TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkCanvas.DrawImageNine(const AImage: ISkImage; const ACenter: TRect; - const ADest: TRectF; const AFilterMode: TSkFilterMode; - const APaint: ISkPaint); -begin - if not Assigned(AImage) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AImage']); - sk4d_canvas_draw_image_nine(Handle, AImage.Handle, @sk_irect_t(ACenter), @sk_rect_t(ADest), sk_filtermode_t(AFilterMode), TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkCanvas.DrawImageRect(const AImage: ISkImage; const ADest: TRectF; - const ASampling: TSkSamplingOptions; const APaint: ISkPaint; - const AConstraint: TSkSrcRectConstraint); -begin - DrawImageRect(AImage, TRectF.Create(0, 0, AImage.Width, AImage.Height), ADest, ASampling, APaint, AConstraint); -end; - -procedure TSkCanvas.DrawImageRect(const AImage: ISkImage; const ASrc, - ADest: TRectF; const ASampling: TSkSamplingOptions; const APaint: ISkPaint; - const AConstraint: TSkSrcRectConstraint); -begin - if not Assigned(AImage) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AImage']); - sk4d_canvas_draw_image_rect(Handle, AImage.Handle, @sk_rect_t(ASrc), @sk_rect_t(ADest), @sk_samplingoptions_t(ASampling), TSkBindings.SafeHandle(APaint), sk_srcrectconstraint_t(AConstraint)); -end; - -procedure TSkCanvas.DrawImageRect(const AImage: ISkImage; const ASrc, - ADest: TRectF; const APaint: ISkPaint; - const AConstraint: TSkSrcRectConstraint); -begin - DrawImageRect(AImage, ASrc, ADest, TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), APaint, AConstraint); -end; - -procedure TSkCanvas.DrawImageRect(const AImage: ISkImage; const ADest: TRectF; - const APaint: ISkPaint; const AConstraint: TSkSrcRectConstraint); -begin - DrawImageRect(AImage, ADest, TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), APaint, AConstraint); -end; - -procedure TSkCanvas.DrawLine(const APoint1, APoint2: TPointF; - const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_line(Handle, @sk_point_t(APoint1), @sk_point_t(APoint2), APaint.Handle); -end; - -procedure TSkCanvas.DrawLine(const AX1, AY1, AX2, AY2: Single; - const APaint: ISkPaint); -begin - DrawLine(TPointF.Create(AX1, AY1), TPointF.Create(AX2, AY2), APaint); -end; - -procedure TSkCanvas.DrawOval(const AOval: TRectF; const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_oval(Handle, @sk_rect_t(AOval), APaint.Handle); -end; - -procedure TSkCanvas.DrawPaint(const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_paint(Handle, APaint.Handle); -end; - -procedure TSkCanvas.DrawPatch(const ACubics: TSkPatchCubics; - const AColors: TSkPatchColors; const ATexCoords: TSkPatchTexCoords; - const ABlendMode: TSkBlendMode; const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_patch(Handle, @sk_point_t(ACubics[0]), @AColors[0], @sk_point_t(ATexCoords[0]), sk_blendmode_t(ABlendMode), APaint.Handle); -end; - -procedure TSkCanvas.DrawPath(const APath: ISkPath; const APaint: ISkPaint); -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_path(Handle, APath.Handle, APaint.Handle); -end; - -procedure TSkCanvas.DrawPicture(const APicture: ISkPicture; - const APaint: ISkPaint); -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - sk4d_canvas_draw_picture(Handle, APicture.Handle, nil, TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkCanvas.DrawPicture(const APicture: ISkPicture; - const AMatrix: TMatrix; const APaint: ISkPaint); -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - sk4d_canvas_draw_picture(Handle, APicture.Handle, @sk_matrix_t(AMatrix), TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkCanvas.DrawPoint(const APoint: TPointF; const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_point(Handle, @sk_point_t(APoint), APaint.Handle); -end; - -procedure TSkCanvas.DrawPoint(const AX, AY: Single; const APaint: ISkPaint); -begin - DrawPoint(TPointF.Create(AX, AY), APaint); -end; - -procedure TSkCanvas.DrawPoints(const AMode: TSkDrawPointsMode; - const APoints: TArray; const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - if Length(APoints) > 0 then - sk4d_canvas_draw_points(Handle, sk_drawpointsmode_t(AMode), Length(APoints), @sk_point_t(APoints[0]), APaint.Handle); -end; - -procedure TSkCanvas.DrawRect(const ARect: TRectF; const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_rect(Handle, @sk_rect_t(ARect), APaint.Handle); -end; - -procedure TSkCanvas.DrawRegion(const ARegion: ISkRegion; - const APaint: ISkPaint); -begin - if not Assigned(ARegion) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARegion']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_region(Handle, ARegion.Handle, APaint.Handle); -end; - -procedure TSkCanvas.DrawRoundRect(const ARect: TRectF; const ARadiusX, - ARadiusY: Single; const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_rrect2(Handle, @sk_rect_t(ARect), ARadiusX, ARadiusY, APaint.Handle); -end; - -procedure TSkCanvas.DrawRoundRect(const ARoundRect: ISkRoundRect; - const APaint: ISkPaint); -begin - if not Assigned(ARoundRect) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARoundRect']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_rrect(Handle, ARoundRect.Handle, APaint.Handle); -end; - -procedure TSkCanvas.DrawRoundRectDifference(const AOuter, AInner: ISkRoundRect; - const APaint: ISkPaint); -begin - if not Assigned(AOuter) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AOuter']); - if not Assigned(AInner) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AInner']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_rrect_difference(Handle, AOuter.Handle, AInner.Handle, APaint.Handle); -end; - -procedure TSkCanvas.DrawSimpleText(const AText: string; const AX, AY: Single; - const AFont: ISkFont; const APaint: ISkPaint); -begin - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - if not AText.IsEmpty then - sk4d_canvas_draw_simple_text(Handle, @AText[Low(AText)], Length(AText) * 2, sk_textencoding_t.UTF16_SK_TEXTENCODING, AX, AY, AFont.Handle, APaint.Handle); -end; - -procedure TSkCanvas.DrawSimpleTextGlyphs(const AGlyphs: TArray; const AX, - AY: Single; const AFont: ISkFont; const APaint: ISkPaint); -begin - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - if Length(AGlyphs) > 0 then - sk4d_canvas_draw_simple_text(Handle, @AGlyphs[Low(AGlyphs)], Length(AGlyphs) * SizeOf(Word), sk_textencoding_t.GLYPH_ID_SK_TEXTENCODING, AX, AY, AFont.Handle, APaint.Handle); -end; - -procedure TSkCanvas.DrawTextBlob(const ATextBlob: ISkTextBlob; const AX, - AY: Single; const APaint: ISkPaint); -begin - if not Assigned(ATextBlob) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATextBlob']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_text_blob(Handle, ATextBlob.Handle, AX, AY, APaint.Handle); -end; - -procedure TSkCanvas.DrawVertices(const AVertices: ISkVertices; - const ABlendMode: TSkBlendMode; const APaint: ISkPaint); -begin - if not Assigned(AVertices) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AVertices']); - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_canvas_draw_vertices(Handle, AVertices.Handle, sk_blendmode_t(ABlendMode), APaint.Handle); -end; - -function TSkCanvas.GetBaseProperties: TSkSurfaceProperties; -var - LResult: sk_surfaceprops_t; -begin - sk4d_canvas_get_base_props(Handle, LResult); - Result := TSkBindings.ToSurfaceProperties(LResult); -end; - -function TSkCanvas.GetDeviceClipBounds: TRect; -begin - sk4d_canvas_get_device_clip_bounds(Handle, sk_irect_t(Result)); -end; - -function TSkCanvas.GetLocalClipBounds: TRectF; -begin - sk4d_canvas_get_local_clip_bounds(Handle, sk_rect_t(Result)); -end; - -function TSkCanvas.GetLocalToDevice: TMatrix3D; -begin - sk4d_canvas_get_local_to_device(Handle, sk_matrix44_t(Result)); -end; - -function TSkCanvas.GetLocalToDeviceAs3x3: TMatrix; -begin - sk4d_canvas_get_local_to_device_as_3x3(Handle, sk_matrix_t(Result)); -end; - -function TSkCanvas.GetSaveCount: Integer; -begin - Result := sk4d_canvas_get_save_count(Handle); -end; - -function TSkCanvas.GetTopProperties: TSkSurfaceProperties; -var - LResult: sk_surfaceprops_t; -begin - sk4d_canvas_get_top_props(Handle, LResult); - Result := TSkBindings.ToSurfaceProperties(LResult); -end; - -function TSkCanvas.MakeSurface(const AImageInfo: TSkImageInfo): ISkSurface; -var - LImageInfo: sk_imageinfo_t; -begin - LImageInfo := TSkBindings.AsImageInfo(AImageInfo); - Result := TSkBindings.SafeCreate(sk4d_canvas_make_surface(Handle, @LImageInfo, nil)); -end; - -function TSkCanvas.MakeSurface(const AImageInfo: TSkImageInfo; - const AProperties: TSkSurfaceProperties): ISkSurface; -var - LImageInfo: sk_imageinfo_t; - LProperties: sk_surfaceprops_t; -begin - LImageInfo := TSkBindings.AsImageInfo(AImageInfo); - LProperties := TSkBindings.AsSurfaceProperties(AProperties); - Result := TSkBindings.SafeCreate(sk4d_canvas_make_surface(Handle, @LImageInfo, @LProperties)); -end; - - -function TSkCanvas.QuickReject(const ARect: TRectF): Boolean; -begin - Result := sk4d_canvas_quick_reject(Handle, @sk_rect_t(ARect)); -end; - -function TSkCanvas.QuickReject(const APath: ISkPath): Boolean; -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - Result := sk4d_canvas_quick_reject2(Handle, APath.Handle); -end; - -procedure TSkCanvas.ResetMatrix; -begin - sk4d_canvas_reset_matrix(Handle); -end; - -procedure TSkCanvas.Restore; -begin - sk4d_canvas_restore(Handle); -end; - -procedure TSkCanvas.RestoreToCount(const ASaveCount: Integer); -begin - sk4d_canvas_restore_to_count(Handle, ASaveCount); -end; - -procedure TSkCanvas.Rotate(const ADegrees, APX, APY: Single); -begin - sk4d_canvas_rotate2(Handle, ADegrees, APX, APY); -end; - -procedure TSkCanvas.Rotate(const ADegrees: Single); -begin - sk4d_canvas_rotate(Handle, ADegrees); -end; - -procedure TSkCanvas.RotateRadians(const ARadians: Single); -begin - Rotate(RadToDeg(ARadians)); -end; - -function TSkCanvas.Save: Integer; -begin - Result := sk4d_canvas_save(Handle); -end; - -procedure TSkCanvas.SaveLayer(const APaint: ISkPaint); -begin - sk4d_canvas_save_layer(Handle, nil, TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkCanvas.SaveLayer(const ABounds: TRectF; const APaint: ISkPaint); -begin - sk4d_canvas_save_layer(Handle, @sk_rect_t(ABounds), TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkCanvas.SaveLayerAlpha(const AAlpha: Byte); -begin - sk4d_canvas_save_layer_alpha(Handle, nil, AAlpha); -end; - -procedure TSkCanvas.SaveLayerAlpha(const ABounds: TRectF; const AAlpha: Byte); -begin - sk4d_canvas_save_layer_alpha(Handle, @sk_rect_t(ABounds), AAlpha); -end; - -procedure TSkCanvas.Scale(const AScaleX, AScaleY: Single); -begin - sk4d_canvas_scale(Handle, AScaleX, AScaleY); -end; - -procedure TSkCanvas.SetMatrix(const AMatrix: TMatrix); -begin - sk4d_canvas_set_matrix2(Handle, @sk_matrix_t(AMatrix)); -end; - -procedure TSkCanvas.SetMatrix(const AMatrix: TMatrix3D); -begin - sk4d_canvas_set_matrix(Handle, @sk_matrix44_t(AMatrix)); -end; - -procedure TSkCanvas.Skew(const ASkewX, ASkewY: Single); -begin - sk4d_canvas_skew(Handle, ASkewX, ASkewY); -end; - -procedure TSkCanvas.Translate(const ADeltaX, ADeltaY: Single); -begin - sk4d_canvas_translate(Handle, ADeltaX, ADeltaY); -end; - -class procedure TSkCanvas.__DestroyHandle(const AHandle: THandle); -begin - sk4d_canvas_destroy(AHandle); -end; - -{ TSkCodec } - -function TSkCodec.GetDimensions: TSize; -begin - sk4d_codec_get_dimensions(Handle, sk_isize_t(Result)); -end; - -function TSkCodec.GetEncodedImageFormat: TSkEncodedImageFormat; -begin - Result := TSkEncodedImageFormat(sk4d_codec_get_encoded_image_format(Handle)); -end; - -function TSkCodec.GetHeight: Integer; -begin - Result := GetDimensions.cy; -end; - -function TSkCodec.GetImage(const AColorType: TSkColorType; - const AAlphaType: TSkAlphaType; AColorSpace: ISkColorSpace): ISkImage; -begin - Result := TSkBindings.SafeCreate(sk4d_codec_get_image(Handle, sk_colortype_t(AColorType), sk_alphatype_t(AAlphaType), TSkBindings.SafeHandle(AColorSpace))); -end; - -function TSkCodec.GetPixels(const APixels: Pointer; const ARowBytes: NativeUInt; - const AColorType: TSkColorType; const AAlphaType: TSkAlphaType; - AColorSpace: ISkColorSpace): Boolean; -begin - Result := sk4d_codec_get_pixels(Handle, APixels, ARowBytes, sk_colortype_t(AColorType), sk_alphatype_t(AAlphaType), TSkBindings.SafeHandle(AColorSpace)); -end; - -function TSkCodec.GetWidth: Integer; -begin - Result := GetDimensions.cx; -end; - -class function TSkCodec.MakeFromFile(const AFileName: string): ISkCodec; -var - LMarshaller: TMarshaller; -begin - if AFileName.IsEmpty then - raise ESkException.Create(SFileNameIsEmpty); - Result := TSkBindings.SafeCreate(sk4d_codec_make_from_file(LMarshaller.AsUtf8(AFileName).ToPointer)); -end; - -class function TSkCodec.MakeFromStream(const AStream: TStream): ISkCodec; -var - LStream: ISkStream; -begin - LStream := TSkStreamAdapter.Create(AStream); - Result := TSkBindings.SafeCreate(sk4d_codec_make_from_stream(TSkObject.__ReleaseHandle(LStream))); -end; - -class function TSkCodec.MakeWithCopy(const AData: Pointer; - const ASize: NativeUInt): ISkCodec; -begin - if ASize = 0 then - Exit(nil); - Result := TSkBindings.SafeCreate(sk4d_codec_make_with_copy(AData, ASize)); -end; - -class function TSkCodec.MakeWithoutCopy(const AData: Pointer; - const ASize: NativeUInt): ISkCodec; -begin - if ASize = 0 then - Exit(nil); - Result := TSkBindings.SafeCreate(sk4d_codec_make_without_copy(AData, ASize)); -end; - -class procedure TSkCodec.__DestroyHandle(const AHandle: THandle); -begin - sk4d_codec_destroy(AHandle); -end; - -{ TSkAnimationCodecPlayer } - -function TSkAnimationCodecPlayer.GetDimensions: TSize; -begin - sk4d_animcodecplayer_get_dimensions(Handle, sk_isize_t(Result)); -end; - -function TSkAnimationCodecPlayer.GetDuration: Cardinal; -begin - Result := sk4d_animcodecplayer_get_duration(Handle); -end; - -function TSkAnimationCodecPlayer.GetFrame: ISkImage; -begin - Result := TSkBindings.SafeCreate(sk4d_animcodecplayer_get_frame(Handle)); -end; - -function TSkAnimationCodecPlayer.GetHeight: Integer; -begin - Result := GetDimensions.cy; -end; - -function TSkAnimationCodecPlayer.GetWidth: Integer; -begin - Result := GetDimensions.cx; -end; - -class function TSkAnimationCodecPlayer.MakeFromFile( - const AFileName: string): ISkAnimationCodecPlayer; -var - LMarshaller: TMarshaller; -begin - if AFileName.IsEmpty then - raise ESkException.Create(SFileNameIsEmpty); - Result := TSkBindings.SafeCreate(sk4d_animcodecplayer_make_from_file(LMarshaller.AsUtf8(AFileName).ToPointer)); -end; - -class function TSkAnimationCodecPlayer.MakeFromStream( - const AStream: TStream): ISkAnimationCodecPlayer; -var - LStream: ISkStream; -begin - LStream := TSkStreamAdapter.Create(AStream); - Result := TSkBindings.SafeCreate(sk4d_animcodecplayer_make_from_stream(TSkObject.__ReleaseHandle(LStream))); -end; - -function TSkAnimationCodecPlayer.Seek(const AMilliseconds: Cardinal): Boolean; -begin - Result := sk4d_animcodecplayer_seek(Handle, AMilliseconds); -end; - -class procedure TSkAnimationCodecPlayer.__DestroyHandle(const AHandle: THandle); -begin - sk4d_animcodecplayer_destroy(AHandle); -end; - -{ TSkColorFilter } - -class function TSkColorFilter.MakeBlend(const AColor: TAlphaColorF; - AColorSpace: ISkColorSpace; const AMode: TSkBlendMode): ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_blend2(@sk_color4f_t(AColor), TSkBindings.SafeHandle(AColorSpace), sk_blendmode_t(AMode))); -end; - -class function TSkColorFilter.MakeBlend(const AColor: TAlphaColor; - const AMode: TSkBlendMode): ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_blend(AColor, sk_blendmode_t(AMode))); -end; - -class function TSkColorFilter.MakeCompose(const AOuter, - AInner: ISkColorFilter): ISkColorFilter; -begin - if not Assigned(AOuter) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AOuter']); - if not Assigned(AInner) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AInner']); - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_compose(AOuter.Handle, AInner.Handle)); -end; - -class function TSkColorFilter.MakeHighContrast( - const AConfig: TSkHighContrastConfig): ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_high_contrast(@sk_highcontrastconfig_t(AConfig))); -end; - -class function TSkColorFilter.MakeHSLAMatrix( - const AMatrix: TSkColorMatrix): ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_hsla_matrix(@sk_colormatrix_t(AMatrix))); -end; - -class function TSkColorFilter.MakeLighting(const AMultiply, - AAdd: TAlphaColor): ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_lighting(AMultiply, AAdd)); -end; - -class function TSkColorFilter.MakeLinearToSRGBGamma: ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_linear_to_srgb_gamma()); -end; - -class function TSkColorFilter.MakeLumaColor: ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_luma_color()); -end; - -class function TSkColorFilter.MakeMatrix( - const AMatrix: TSkColorMatrix): ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_matrix(@sk_colormatrix_t(AMatrix))); -end; - -class function TSkColorFilter.MakeOverdraw( - const AColors: TSkOverdrawColor): ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_overdraw(@AColors)); -end; - -class function TSkColorFilter.MakeTable(const ATableA, ATableR, ATableG, - ATableB: TSkTableFilter): ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_colorfilter_make_table(@ATableA, @ATableR, @ATableG, @ATableB)); -end; - -class function TSkColorFilter.MakeTable( - const ATable: TSkTableFilter): ISkColorFilter; -begin - Result := MakeTable(ATable, ATable, ATable, ATable); -end; - -{ TSkColorSpace } - -function TSkColorSpace.GammaCloseToSRGB: Boolean; -begin - Result := sk4d_colorspace_gamma_close_to_srgb(Handle); -end; - -function TSkColorSpace.GammaIsLinear: Boolean; -begin - Result := sk4d_colorspace_gamma_is_linear(Handle); -end; - -function TSkColorSpace.IsEqual(const AColorSpace: ISkColorSpace): Boolean; -begin - if not Assigned(AColorSpace) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AColorSpace']); - Result := sk4d_colorspace_is_equal(Handle, AColorSpace.Handle); -end; - -function TSkColorSpace.IsNumericalTransferFunction( - out ATransferFunction: TSkColorSpaceTransferFunction): Boolean; -begin - Result := sk4d_colorspace_is_numerical_transfer_fn(Handle, sk_colorspacetransferfn_t(ATransferFunction)); -end; - -function TSkColorSpace.IsSRGB: Boolean; -begin - Result := sk4d_colorspace_is_srgb(Handle); -end; - -class function TSkColorSpace.Make( - const AProfile: ISkColorSpaceICCProfile): ISkColorSpace; -begin - if not Assigned(AProfile) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AProfile']); - Result := TSkBindings.SafeCreate(sk4d_colorspace_make(AProfile.Handle)); -end; - -function TSkColorSpace.MakeLinearGamma: ISkColorSpace; -begin - Result := TSkBindings.SafeCreate(sk4d_colorspace_make_linear_gamma(Handle)); -end; - -class function TSkColorSpace.MakeRGB( - const ATransferFunction: TSkColorSpaceTransferFunction; - const AToXyzD50: TSkColorSpaceXyz): ISkColorSpace; -begin - Result := TSkBindings.SafeCreate(sk4d_colorspace_make_rgb(@sk_colorspacetransferfn_t(ATransferFunction), @sk_colorspacexyz_t(AToXyzD50))); -end; - -class function TSkColorSpace.MakeSRGB: ISkColorSpace; -begin - Result := TSkBindings.SafeCreate(sk4d_colorspace_make_srgb()); -end; - -function TSkColorSpace.MakeSRGBGamma: ISkColorSpace; -begin - Result := TSkBindings.SafeCreate(sk4d_colorspace_make_srgb_gamma(Handle)); -end; - -class function TSkColorSpace.MakeSRGBLinear: ISkColorSpace; -begin - Result := TSkBindings.SafeCreate(sk4d_colorspace_make_srgb_linear()); -end; - -function TSkColorSpace.ToProfile: ISkColorSpaceICCProfile; -begin - Result := TSkColorSpaceICCProfile.Wrap(sk4d_colorspace_to_profile(Handle)); -end; - -function TSkColorSpace.ToXyz(out ADest: TSkColorSpaceXyz): Boolean; -begin - Result := sk4d_colorspace_to_xyz(Handle, sk_colorspacexyz_t(ADest)); -end; - -class procedure TSkColorSpace.__RefHandle(const AHandle: THandle); -begin - sk4d_colorspace_ref(AHandle); -end; - -class procedure TSkColorSpace.__UnrefHandle(const AHandle: THandle); -begin - sk4d_colorspace_unref(AHandle); -end; - -{ TSkColorSpaceICCProfile } - -class function TSkColorSpaceICCProfile.MakeFromBytes( - const ABytes: TBytes): ISkColorSpaceICCProfile; -begin - if Length(ABytes) < 1 then - Exit(nil); - Result := TSkBindings.SafeCreate(sk4d_colorspaceiccprofile_make_with_parse(@ABytes[0], Length(ABytes))); -end; - -function TSkColorSpaceICCProfile.ToBytes: TBytes; -var - LBuffer: Pointer; - LSize: Cardinal; -begin - LBuffer := sk4d_colorspaceiccprofile_get_buffer(Handle, @LSize); - SetLength(Result, LSize); - if Length(Result) > 0 then - Move(LBuffer^, Result[0], Length(Result)); -end; - -function TSkColorSpaceICCProfile.ToXyz(out ADest: TSkColorSpaceXyz): Boolean; -begin - Result := sk4d_colorspaceiccprofile_to_xyz(Handle, sk_colorspacexyz_t(ADest)); -end; - -class procedure TSkColorSpaceICCProfile.__DestroyHandle(const AHandle: THandle); -begin - sk4d_colorspaceiccprofile_destroy(AHandle); -end; - -{ TSkDocument } - -function TSkDocument.BeginPage(const AWidth, AHeight: Single): ISkCanvas; -begin - Result := TSkBindings.SafeCreate(sk4d_document_begin_page(Handle, AWidth, AHeight, nil), False); -end; - -function TSkDocument.BeginPage(const AWidth, AHeight: Single; - const AContent: TRectF): ISkCanvas; -begin - Result := TSkBindings.SafeCreate(sk4d_document_begin_page(Handle, AWidth, AHeight, @sk_rect_t(AContent)), False); -end; - -procedure TSkDocument.Close; -begin - sk4d_document_close(Handle); -end; - -procedure TSkDocument.EndPage; -begin - sk4d_document_end_page(Handle); -end; - -class function TSkDocument.MakePDF(const AStream: TStream): ISkDocument; -var - LDocument: TSkDocument; - LHandle: THandle; - LWStream: ISkWStream; -begin - LWStream := TSkWStreamAdapter.Create(AStream); - LHandle := sk4d_document_make_pdf(LWStream.Handle); - if LHandle = 0 then - Exit(nil); - LDocument := TSkDocument.Wrap(LHandle); - LDocument.FHolder := LWStream; - Result := LDocument; -end; - -class function TSkDocument.MakePDF(const AStream: TStream; - const AMetadata: TSkPDFMetadata): ISkDocument; -var - LDocument: TSkDocument; - LHandle: THandle; - LMetadata: sk_pdfmetadata_t; - LWStream: ISkWStream; -begin - LWStream := TSkWStreamAdapter.Create(AStream); - LMetadata := TSkBindings.AsPDFMetadata(AMetadata); - LHandle := sk4d_document_make_pdf2(LWStream.Handle, @LMetadata); - if LHandle = 0 then - Exit(nil); - LDocument := TSkDocument.Wrap(LHandle); - LDocument.FHolder := LWStream; - Result := LDocument; -end; - -class function TSkDocument.MakeXPS(const AStream: TStream; - const ADPI: Single): ISkDocument; -var - LDocument: TSkDocument; - LHandle: THandle; - LWStream: ISkWStream; -begin - LWStream := TSkWStreamAdapter.Create(AStream); - LHandle := sk4d_document_make_xps(LWStream.Handle, ADPI); - if LHandle = 0 then - Exit(nil); - LDocument := TSkDocument.Wrap(LHandle); - LDocument.FHolder := LWStream; - Result := LDocument; -end; - -procedure TSkDocument.Terminate; -begin - sk4d_document_terminate(Handle); -end; - -{ TSkFont } - -constructor TSkFont.Create(ATypeface: ISkTypeface; const ASize, AScaleX, - ASkewX: Single); -begin - inherited Create(sk4d_font_create(TSkBindings.SafeHandle(ATypeface), ASize, AScaleX, ASkewX)); -end; - -constructor TSkFont.Create(const AFont: ISkFont); -begin - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - inherited Create(sk4d_font_create2(AFont.Handle)); -end; - -function TSkFont.GetBaselineSnap: Boolean; -begin - Result := sk4d_font_get_baseline_snap(Handle); -end; - -function TSkFont.GetBounds(const AGlyphs: TArray; - const APaint: ISkPaint): TArray; -begin - if Length(AGlyphs) = 0 then - Exit(nil); - SetLength(Result, Length(AGlyphs)); - sk4d_font_get_widths_bounds(Handle, @AGlyphs[0], Length(AGlyphs), nil, @sk_rect_t(Result[0]), TSkBindings.SafeHandle(APaint)); -end; - -function TSkFont.GetEdging: TSkFontEdging; -begin - Result := TSkFontEdging(sk4d_font_get_edging(Handle)); -end; - -function TSkFont.GetEmbeddedBitmaps: Boolean; -begin - Result := sk4d_font_get_embedded_bitmaps(Handle); -end; - -function TSkFont.GetEmbolden: Boolean; -begin - Result := sk4d_font_get_embolden(Handle); -end; - -function TSkFont.GetForceAutoHinting: Boolean; -begin - Result := sk4d_font_get_force_auto_hinting(Handle); -end; - -function TSkFont.GetGlyphs(const AText: string): TArray; -var - LCount: Integer; -begin - if AText.IsEmpty then - Exit(nil); - LCount := sk4d_font_get_glyphs_count(Handle, @AText[Low(AText)], Length(AText) * 2, sk_textencoding_t.UTF16_SK_TEXTENCODING); - if LCount = 0 then - Exit(nil); - SetLength(Result, LCount); - sk4d_font_get_glyphs(Handle, @AText[Low(AText)], Length(AText) * 2, sk_textencoding_t.UTF16_SK_TEXTENCODING, @Result[0], LCount); -end; - -function TSkFont.GetHinting: TSkFontHinting; -begin - Result := TSkFontHinting(sk4d_font_get_hinting(Handle)); -end; - -function TSkFont.GetHorizontalPositions(const AGlyphs: TArray; - const AOrigin: Single): TArray; -begin - if Length(AGlyphs) = 0 then - Exit(nil); - SetLength(Result, Length(AGlyphs)); - sk4d_font_get_horizontal_positions(Handle, @AGlyphs[0], Length(AGlyphs), @Result[0], AOrigin); -end; - -function TSkFont.GetIntercepts(const AGlyphs: TArray; - const APositions: TArray; const AUpperBounds, ALowerBounds: Single; - const APaint: ISkPaint): TArray; -var - LBounds: array[0..1] of Single; - LCount: Integer; -begin - if Length(AGlyphs) = 0 then - Exit(nil); - if Length(APositions) <> Length(AGlyphs) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LBounds[0] := AUpperBounds; - LBounds[1] := ALowerBounds; - LCount := sk4d_textblob_get_intercepts(Handle, @LBounds[0], nil, TSkBindings.SafeHandle(APaint)); - if LCount = 0 then - Exit(nil); - SetLength(Result, LCount); - sk4d_font_get_intercepts(Handle, @AGlyphs[0], Length(AGlyphs), @sk_point_t(APositions[0]), @LBounds[0], @Result[0], TSkBindings.SafeHandle(APaint)); -end; - -function TSkFont.GetLinearMetrics: Boolean; -begin - Result := sk4d_font_get_linear_metrics(Handle); -end; - -function TSkFont.GetMetrics(out AMetrics: TSkFontMetrics): Single; -var - LMetrics: sk_fontmetrics_t; -begin - Result := sk4d_font_get_metrics(Handle, @LMetrics); - AMetrics := TSkBindings.ToFontMetrics(LMetrics); -end; - -function TSkFont.GetPath(const AGlyph: Word): ISkPath; -begin - Result := TSkBindings.SafeCreate(sk4d_font_get_path(Handle, AGlyph)); -end; - -procedure TSkFont.GetPaths(const AGlyphs: TArray; - const AProc: TSkFontPathProc); -begin - if (Length(AGlyphs) > 0) and (Assigned(AProc)) then - sk4d_font_get_paths(Handle, @AGlyphs[0], Length(AGlyphs), path_proc, @AProc); -end; - -function TSkFont.GetPositions(const AGlyphs: TArray): TArray; -begin - Result := GetPositions(AGlyphs, TPointF.Create(0, 0)); -end; - -function TSkFont.GetPositions(const AGlyphs: TArray; - const AOrigin: TPointF): TArray; -begin - if Length(AGlyphs) = 0 then - Exit(nil); - SetLength(Result, Length(AGlyphs)); - sk4d_font_get_positions(Handle, @AGlyphs[0], Length(AGlyphs), @sk_point_t(Result[0]), @sk_point_t(AOrigin)); -end; - -function TSkFont.GetScaleX: Single; -begin - Result := sk4d_font_get_scale_x(Handle); -end; - -function TSkFont.GetSize: Single; -begin - Result := sk4d_font_get_size(Handle); -end; - -function TSkFont.GetSkewX: Single; -begin - Result := sk4d_font_get_skew_x(Handle); -end; - -function TSkFont.GetSpacing: Single; -begin - Result := sk4d_font_get_metrics(Handle, nil); -end; - -function TSkFont.GetSubpixel: Boolean; -begin - Result := sk4d_font_get_subpixel(Handle); -end; - -function TSkFont.GetTypeface: ISkTypeface; -begin - Result := TSkBindings.SafeCreate(sk4d_font_get_typeface(Handle)); -end; - -function TSkFont.GetTypefaceOrDefault: ISkTypeface; -begin - Result := TSkBindings.SafeCreate(sk4d_font_get_typeface_or_default(Handle)); -end; - -function TSkFont.GetWidths(const AGlyphs: TArray; - const APaint: ISkPaint): TArray; -begin - if Length(AGlyphs) = 0 then - Exit(nil); - SetLength(Result, Length(AGlyphs)); - sk4d_font_get_widths_bounds(Handle, @AGlyphs[0], Length(AGlyphs), @Result[0], nil, TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkFont.GetWidthsAndBounds(const AGlyphs: TArray; - out AWidths: TArray; out ABounds: TArray; - const APaint: ISkPaint); -begin - SetLength(AWidths, Length(AGlyphs)); - SetLength(ABounds, Length(AGlyphs)); - if Length(AGlyphs) = 0 then - Exit; - sk4d_font_get_widths_bounds(Handle, @AGlyphs[0], Length(AGlyphs), @AWidths[0], @sk_rect_t(ABounds[0]), TSkBindings.SafeHandle(APaint)); -end; - -function TSkFont.IsEqual(const AFont: ISkFont): Boolean; -begin - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - Result := sk4d_font_is_equal(Handle, AFont.Handle); -end; - -function TSkFont.MakeWithSize(const ASize: Single): ISkFont; -begin - Result := TSkFont.Create(Self); - Result.Size := ASize; -end; - -function TSkFont.MeasureText(const AText: string; out ABounds: TRectF; - const APaint: ISkPaint): Single; -begin - if AText.IsEmpty then - begin - ABounds := TRectF.Empty; - Exit(0); - end; - Result := sk4d_font_measure_text(Handle, @AText[Low(AText)], Length(AText) * 2, sk_textencoding_t.UTF16_SK_TEXTENCODING, @sk_rect_t(ABounds), TSkBindings.SafeHandle(APaint)); -end; - -function TSkFont.MeasureText(const AText: string; - const APaint: ISkPaint): Single; -begin - if AText.IsEmpty then - Exit(0); - Result := sk4d_font_measure_text(Handle, @AText[Low(AText)], Length(AText) * 2, sk_textencoding_t.UTF16_SK_TEXTENCODING, nil, TSkBindings.SafeHandle(APaint)); -end; - -function TSkFont.MeasureTextGlyphs(const AGlyphs: TArray; - out ABounds: TRectF; const APaint: ISkPaint): Single; -begin - if Length(AGlyphs) = 0 then - begin - ABounds := TRectF.Empty; - Exit(0); - end; - Result := sk4d_font_measure_text(Handle, @AGlyphs[Low(AGlyphs)], Length(AGlyphs) * SizeOf(Word), sk_textencoding_t.GLYPH_ID_SK_TEXTENCODING, @sk_rect_t(ABounds), TSkBindings.SafeHandle(APaint)); -end; - -function TSkFont.MeasureTextGlyphs(const AGlyphs: TArray; - const APaint: ISkPaint): Single; -begin - if Length(AGlyphs) = 0 then - Exit(0); - Result := sk4d_font_measure_text(Handle, @AGlyphs[Low(AGlyphs)], Length(AGlyphs) * SizeOf(Word), sk_textencoding_t.GLYPH_ID_SK_TEXTENCODING, nil, TSkBindings.SafeHandle(APaint)); -end; - -class procedure TSkFont.path_proc(const path: sk_path_t; - const matrix: psk_matrix_t; context: Pointer); -var - LPath: ISkPath; -begin - LPath := TSkBindings.SafeCreate(path, False); - TSkFontPathProc(context^)(LPath, TMatrix(matrix^)); -end; - -procedure TSkFont.SetBaselineSnap(const AValue: Boolean); -begin - sk4d_font_set_baseline_snap(Handle, AValue); -end; - -procedure TSkFont.SetEdging(const AValue: TSkFontEdging); -begin - sk4d_font_set_edging(Handle, sk_fontedging_t(AValue)); -end; - -procedure TSkFont.SetEmbeddedBitmaps(const AValue: Boolean); -begin - sk4d_font_set_embedded_bitmaps(Handle, AValue); -end; - -procedure TSkFont.SetEmbolden(const AValue: Boolean); -begin - sk4d_font_set_embolden(Handle, AValue); -end; - -procedure TSkFont.SetForceAutoHinting(const AValue: Boolean); -begin - sk4d_font_set_force_auto_hinting(Handle, AValue); -end; - -procedure TSkFont.SetHinting(const AValue: TSkFontHinting); -begin - sk4d_font_set_hinting(Handle, sk_fonthinting_t(AValue)); -end; - -procedure TSkFont.SetLinearMetrics(const AValue: Boolean); -begin - sk4d_font_set_linear_metrics(Handle, AValue); -end; - -procedure TSkFont.SetScaleX(const AValue: Single); -begin - sk4d_font_set_scale_x(Handle, AValue); -end; - -procedure TSkFont.SetSize(const AValue: Single); -begin - sk4d_font_set_size(Handle, AValue); -end; - -procedure TSkFont.SetSkewX(const AValue: Single); -begin - sk4d_font_set_skew_x(Handle, AValue); -end; - -procedure TSkFont.SetSubpixel(const AValue: Boolean); -begin - sk4d_font_set_subpixel(Handle, AValue); -end; - -procedure TSkFont.SetTypeface(AValue: ISkTypeface); -begin - sk4d_font_set_typeface(Handle, TSkBindings.SafeHandle(AValue)); -end; - -function TSkFont.UnicharsToGlyphs( - const AUnichars: TArray): TArray; -begin - if Length(AUnichars) = 0 then - Exit(nil); - SetLength(Result, Length(AUnichars)); - sk4d_font_unichars_to_glyphs(Handle, @AUnichars[0], Length(AUnichars), @Result[0]); -end; - -function TSkFont.UnicharToGlyph(const AUnichar: Integer): Word; -begin - Result := sk4d_font_unichar_to_glyph(Handle, AUnichar); -end; - -class procedure TSkFont.__DestroyHandle(const AHandle: THandle); -begin - sk4d_font_destroy(AHandle); -end; - -{ TSkImage } - -function TSkImage.Encode(const AEncodedImageFormat: TSkEncodedImageFormat; - const AQuality: Integer): TBytes; -var - LBytesStream: TBytesStream; -begin - LBytesStream := TBytesStream.Create; - try - EncodeToStream(LBytesStream, AEncodedImageFormat, AQuality); - Result := Copy(LBytesStream.Bytes, 0, LBytesStream.Size); - finally - LBytesStream.Free; - end; -end; - -function TSkImage.EncodeToFile(const AFileName: string; - const AQuality: Integer): Boolean; -begin - Result := EncodeToFile(AFileName, ExtensionToEncodedImageFormat(TPath.GetExtension(AFileName)), AQuality); -end; - -function TSkImage.EncodeToFile(const AFileName: string; - const AEncodedImageFormat: TSkEncodedImageFormat; - const AQuality: Integer): Boolean; -var - LMarshaller: TMarshaller; -begin - if AFileName.IsEmpty then - raise ESkException.Create(SFileNameIsEmpty); - Result := sk4d_image_encode_to_file(Handle, LMarshaller.AsUtf8(AFileName).ToPointer, sk_encodedimageformat_t(AEncodedImageFormat), AQuality); -end; - -function TSkImage.EncodeToStream(const AStream: TStream; - const AEncodedImageFormat: TSkEncodedImageFormat; - const AQuality: Integer): Boolean; -var - LWStream: ISkWStream; -begin - LWStream := TSkWStreamAdapter.Create(AStream); - Result := sk4d_image_encode_to_stream(Handle, LWStream.Handle, sk_encodedimageformat_t(AEncodedImageFormat), AQuality); -end; - -function TSkImage.GetAlphaType: TSkAlphaType; -begin - Result := TSkAlphaType(sk4d_image_get_alpha_type(Handle)); -end; - -function TSkImage.GetColorSpace: ISkColorSpace; -begin - Result := TSkBindings.SafeCreate(sk4d_image_get_color_space(Handle)); -end; - -function TSkImage.GetColorType: TSkColorType; -begin - Result := TSkColorType(sk4d_image_get_color_type(Handle)); -end; - -function TSkImage.GetHeight: Integer; -begin - Result := sk4d_image_get_height(Handle); -end; - -function TSkImage.GetImageInfo: TSkImageInfo; -var - LResult: sk_imageinfo_t; -begin - sk4d_image_get_image_info(Handle, LResult); - Result := TSkBindings.ToImageInfo(LResult); -end; - -function TSkImage.GetUniqueId: NativeUInt; -begin - Result := sk4d_image_get_unique_id(Handle); -end; - -function TSkImage.GetWidth: Integer; -begin - Result := sk4d_image_get_width(Handle); -end; - -function TSkImage.IsAlphaOnly: Boolean; -begin - case GetColorType of - TSkColorType.Alpha8, - TSkColorType.AlphaF16, - TSkColorType.Alpha16: Result := True; - else - Result := False; - end; -end; - -function TSkImage.IsLazyGenerated: Boolean; -begin - Result := sk4d_image_is_lazy_generated(Handle); -end; - -function TSkImage.IsOpaque: Boolean; -begin - Result := GetAlphaType = TSkAlphaType.Opaque; -end; - -function TSkImage.IsTextureBacked: Boolean; -begin - Result := sk4d_image_is_texture_backed(Handle); -end; - -function TSkImage.IsValid(AContext: IGrDirectContext): Boolean; -begin - Result := sk4d_image_is_valid(Handle, TSkBindings.SafeHandle(AContext)); -end; - -class function TSkImage.MakeCrossContext(const AContext: IGrDirectContext; - const APixmap: ISkPixmap; const ABuildMips, - ALimitToMaxTextureSize: Boolean): ISkImage; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - if not Assigned(APixmap) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APixmap']); - Result := TSkBindings.SafeCreate(sk4d_image_make_cross_context(AContext.Handle, APixmap.Handle, ABuildMips, ALimitToMaxTextureSize)); -end; - -class function TSkImage.MakeCrossContext(const AContext: IGrDirectContext; - const AImageInfo: TSkImageInfo; const APixels: Pointer; - const ARowBytes: NativeUInt; const ABuildMips, - ALimitToMaxTextureSize: Boolean): ISkImage; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(AImageInfo, APixels, ARowBytes); - Result := MakeCrossContext(AContext, LPixmap, ABuildMips, ALimitToMaxTextureSize); -end; - -class function TSkImage.MakeFromAdoptedTexture(const AContext: IGrDirectContext; - const ATexture: IGrBackendTexture; const AOrigin: TGrSurfaceOrigin; - AColorType: TSkColorType; const AAlphaType: TSkAlphaType; - AColorSpace: ISkColorSpace): ISkImage; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - if not Assigned(ATexture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATexture']); - Result := TSkBindings.SafeCreate(sk4d_image_make_from_adopted_texture(AContext.Handle, ATexture.Handle, gr_surfaceorigin_t(AOrigin), sk_colortype_t(AColorType), sk_alphatype_t(AAlphaType), TSkBindings.SafeHandle(AColorSpace))); -end; - -class function TSkImage.MakeFromEncoded(const ABytes: TBytes): ISkImage; -var - LStream: TStream; -begin - if Length(ABytes) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ABytes']); - LStream := TBytesStream.Create(ABytes); - try - Result := MakeFromEncodedStream(LStream); - finally - LStream.Free; - end; -end; - -class function TSkImage.MakeFromEncodedFile(const AFileName: string): ISkImage; -var - LMarshaller: TMarshaller; -begin - if AFileName.IsEmpty then - raise ESkException.Create(SFileNameIsEmpty); - Result := TSkBindings.SafeCreate(sk4d_image_make_from_encoded_file(LMarshaller.AsUtf8(AFileName).ToPointer)); -end; - -class function TSkImage.MakeFromEncodedStream(const AStream: TStream): ISkImage; -var - LStream: ISkStream; -begin - LStream := TSkStreamAdapter.Create(AStream); - Result := TSkBindings.SafeCreate(sk4d_image_make_from_encoded_stream(LStream.Handle)); -end; - -class function TSkImage.MakeFromPicture(const APicture: ISkPicture; - const ADimensions: TSize; const AMatrix: TMatrix; - const AProperties: TSkSurfaceProperties; const APaint: ISkPaint; - AColorSpace: ISkColorSpace): ISkImage; -var - LProperties: sk_surfaceprops_t; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - LProperties := TSkBindings.AsSurfaceProperties(AProperties); - Result := TSkBindings.SafeCreate(sk4d_image_make_from_picture(APicture.Handle, @sk_isize_t(ADimensions), @sk_matrix_t(AMatrix), TSkBindings.SafeHandle(APaint), TSkBindings.SafeHandle(AColorSpace), @LProperties)); -end; - -class function TSkImage.MakeFromPicture(const APicture: ISkPicture; - const ADimensions: TSize; const AProperties: TSkSurfaceProperties; - const APaint: ISkPaint; AColorSpace: ISkColorSpace): ISkImage; -var - LProperties: sk_surfaceprops_t; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - LProperties := TSkBindings.AsSurfaceProperties(AProperties); - Result := TSkBindings.SafeCreate(sk4d_image_make_from_picture(APicture.Handle, @sk_isize_t(ADimensions), nil, TSkBindings.SafeHandle(APaint), TSkBindings.SafeHandle(AColorSpace), @LProperties)); -end; - -class function TSkImage.MakeFromPicture(const APicture: ISkPicture; - const ADimensions: TSize; const APaint: ISkPaint; - AColorSpace: ISkColorSpace): ISkImage; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - Result := TSkBindings.SafeCreate(sk4d_image_make_from_picture(APicture.Handle, @sk_isize_t(ADimensions), nil, TSkBindings.SafeHandle(APaint), TSkBindings.SafeHandle(AColorSpace), nil)); -end; - -class function TSkImage.MakeFromPicture(const APicture: ISkPicture; - const ADimensions: TSize; const AMatrix: TMatrix; const APaint: ISkPaint; - AColorSpace: ISkColorSpace): ISkImage; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - Result := TSkBindings.SafeCreate(sk4d_image_make_from_picture(APicture.Handle, @sk_isize_t(ADimensions), @sk_matrix_t(AMatrix), TSkBindings.SafeHandle(APaint), TSkBindings.SafeHandle(AColorSpace), nil)); -end; - -class function TSkImage.MakeFromRaster(const APixmap: ISkPixmap; - const ARasterReleaseProc: TSkImageRasterReleaseProc): ISkImage; -begin - if not Assigned(APixmap) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APixmap']); - if Assigned(ARasterReleaseProc) then - begin - Result := TSkDelegate.Initialize(ARasterReleaseProc, - function (const AContextProc: Pointer): ISkImage - begin - Result := TSkBindings.SafeCreate(sk4d_image_make_from_raster(APixmap.Handle, raster_release_proc, AContextProc)); - end); - end - else - Result := TSkBindings.SafeCreate(sk4d_image_make_from_raster(APixmap.Handle, nil, nil)); -end; - -class function TSkImage.MakeFromRaster(const AImageInfo: TSkImageInfo; - const APixels: Pointer; const ARowBytes: NativeUInt; - const ARasterReleaseProc: TSkImageRasterReleaseProc): ISkImage; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(AImageInfo, APixels, ARowBytes); - Result := MakeFromRaster(LPixmap, ARasterReleaseProc); -end; - -class function TSkImage.MakeFromTexture(const AContext: IGrDirectContext; - const ATexture: IGrBackendTexture; const AOrigin: TGrSurfaceOrigin; - AColorType: TSkColorType; const AAlphaType: TSkAlphaType; - AColorSpace: ISkColorSpace; - const ATextureReleaseProc: TSkImageTextureReleaseProc): ISkImage; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - if not Assigned(ATexture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATexture']); - if Assigned(ATextureReleaseProc) then - begin - Result := TSkDelegate.Initialize(ATextureReleaseProc, - function (const AContextProc: Pointer): ISkImage - begin - Result := TSkBindings.SafeCreate(sk4d_image_make_from_texture(AContext.Handle, ATexture.Handle, gr_surfaceorigin_t(AOrigin), sk_colortype_t(AColorType), sk_alphatype_t(AAlphaType), TSkBindings.SafeHandle(AColorSpace), texture_release_proc, AContextProc)); - end); - end - else - Result := TSkBindings.SafeCreate(sk4d_image_make_from_texture(AContext.Handle, ATexture.Handle, gr_surfaceorigin_t(AOrigin), sk_colortype_t(AColorType), sk_alphatype_t(AAlphaType), TSkBindings.SafeHandle(AColorSpace), nil, nil)); -end; - -function TSkImage.MakeNonTextureImage: ISkImage; -begin - Result := TSkBindings.SafeCreate(sk4d_image_make_non_texture_image(Handle)); -end; - -class function TSkImage.MakeRasterCopy(const AImageInfo: TSkImageInfo; - const APixels: Pointer; const ARowBytes: NativeUInt): ISkImage; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(AImageInfo, APixels, ARowBytes); - Result := MakeRasterCopy(LPixmap); -end; - -class function TSkImage.MakeRasterCopy(const APixmap: ISkPixmap): ISkImage; -begin - if not Assigned(APixmap) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APixmap']); - Result := TSkBindings.SafeCreate(sk4d_image_make_raster_copy(APixmap.Handle)); -end; - -function TSkImage.MakeRasterImage: ISkImage; -begin - Result := TSkBindings.SafeCreate(sk4d_image_make_raster_image(Handle)); -end; - -function TSkImage.MakeRawShader(const ALocalMatrix: TMatrix; const ATileModeX, - ATileModeY: TSkTileMode): ISkShader; -begin - Result := MakeRawShader(ALocalMatrix, TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), ATileModeX, ATileModeY); -end; - -function TSkImage.MakeRawShader(const ASampling: TSkSamplingOptions; - const ATileModeX, ATileModeY: TSkTileMode): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_image_make_raw_shader(Handle, sk_tilemode_t(ATileModeX), sk_tilemode_t(ATileModeY), @sk_samplingoptions_t(ASampling), nil)); -end; - -function TSkImage.MakeRawShader(const ALocalMatrix: TMatrix; - const ASampling: TSkSamplingOptions; const ATileModeX, - ATileModeY: TSkTileMode): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_image_make_raw_shader(Handle, sk_tilemode_t(ATileModeX), sk_tilemode_t(ATileModeY), @sk_samplingoptions_t(ASampling), @sk_matrix_t(ALocalMatrix))); -end; - -function TSkImage.MakeRawShader(const ATileModeX, - ATileModeY: TSkTileMode): ISkShader; -begin - Result := MakeRawShader(TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), ATileModeX, ATileModeY); -end; - -function TSkImage.MakeShader(const ATileModeX, - ATileModeY: TSkTileMode): ISkShader; -begin - Result := MakeShader(TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), ATileModeX, ATileModeY); -end; - -function TSkImage.MakeShader(const ALocalMatrix: TMatrix; const ATileModeX, - ATileModeY: TSkTileMode): ISkShader; -begin - Result := MakeShader(ALocalMatrix, TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), ATileModeX, ATileModeY); -end; - -function TSkImage.MakeShader(const ASampling: TSkSamplingOptions; - const ATileModeX, ATileModeY: TSkTileMode): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_image_make_shader(Handle, sk_tilemode_t(ATileModeX), sk_tilemode_t(ATileModeY), @sk_samplingoptions_t(ASampling), nil)); -end; - -function TSkImage.MakeShader(const ALocalMatrix: TMatrix; - const ASampling: TSkSamplingOptions; const ATileModeX, - ATileModeY: TSkTileMode): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_image_make_shader(Handle, sk_tilemode_t(ATileModeX), sk_tilemode_t(ATileModeY), @sk_samplingoptions_t(ASampling), @sk_matrix_t(ALocalMatrix))); -end; - -function TSkImage.MakeSubset(const ASubset: TRect; - AContext: IGrDirectContext): ISkImage; -begin - Result := TSkBindings.SafeCreate(sk4d_image_make_subset(Handle, @sk_irect_t(ASubset), TSkBindings.SafeHandle(AContext))); -end; - -function TSkImage.MakeTextureImage(const AContext: IGrDirectContext; - const AIsMipmapped: Boolean): ISkImage; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - Result := TSkBindings.SafeCreate(sk4d_image_make_texture_image(Handle, AContext.Handle, AIsMipmapped)); -end; - -function TSkImage.MakeWithFilter(const AFilter: ISkImageFilter; const ASubset, - AClipBounds: TRect; out AOutSubset: TRect; out AOffset: TPoint; - AContext: IGrDirectContext): ISkImage; -begin - if not Assigned(AFilter) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFilter']); - Result := TSkBindings.SafeCreate(sk4d_image_make_with_filter(Handle, TSkBindings.SafeHandle(AContext), AFilter.Handle, @sk_irect_t(ASubset), @sk_irect_t(AClipBounds), sk_irect_t(AOutSubset), sk_ipoint_t(AOffset))); -end; - -function TSkImage.PeekPixels: ISkPixmap; -begin - Result := TSkBindings.SafeCreate(sk4d_image_peek_pixels(Handle)); -end; - -class procedure TSkImage.raster_release_proc(const pixels: Pointer; - context: Pointer); -begin - TSkDelegate.Invoke(context, - procedure (const AProc: TSkImageRasterReleaseProc) - begin - AProc(pixels); - end); - TSkDelegate.Finalize(context); -end; - -function TSkImage.ReadPixels(const ADest: ISkPixmap; const ASrcX, - ASrcY: Integer; const ACachingHint: TSkImageCachingHint; - AContext: IGrDirectContext): Boolean; -begin - if not Assigned(ADest) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ADest']); - Result := sk4d_image_read_pixels(Handle, TSkBindings.SafeHandle(AContext), ADest.Handle, ASrcX, ASrcY, sk_imagecachinghint_t(ACachingHint)); -end; - -function TSkImage.ReadPixels(const ADestImageInfo: TSkImageInfo; - const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASrcX, - ASrcY: Integer; const ACachingHint: TSkImageCachingHint; - AContext: IGrDirectContext): Boolean; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ADestImageInfo, ADestPixels, ADestRowBytes); - Result := ReadPixels(LPixmap, ASrcX, ASrcY, ACachingHint, AContext); -end; - -function TSkImage.ScalePixels(const ADestImageInfo: TSkImageInfo; - const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; - const ASampling: TSkSamplingOptions; - const ACachingHint: TSkImageCachingHint): Boolean; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ADestImageInfo, ADestPixels, ADestRowBytes); - Result := ScalePixels(LPixmap, ASampling, ACachingHint); -end; - -function TSkImage.ScalePixels(const ADestImageInfo: TSkImageInfo; - const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; - const ACachingHint: TSkImageCachingHint): Boolean; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ADestImageInfo, ADestPixels, ADestRowBytes); - Result := ScalePixels(LPixmap, ACachingHint); -end; - -function TSkImage.ScalePixels(const ADest: ISkPixmap; - const ASampling: TSkSamplingOptions; - const ACachingHint: TSkImageCachingHint): Boolean; -begin - if not Assigned(ADest) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ADest']); - Result := sk4d_image_scale_pixels(Handle, ADest.Handle, @sk_samplingoptions_t(ASampling), sk_imagecachinghint_t(ACachingHint)); -end; - -function TSkImage.ScalePixels(const ADest: ISkPixmap; - const ACachingHint: TSkImageCachingHint): Boolean; -begin - Result := ScalePixels(ADest, TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None), ACachingHint); -end; - -class procedure TSkImage.texture_release_proc(context: Pointer); -begin - TSkDelegate.Invoke(context, - procedure (const AProc: TSkImageTextureReleaseProc) - begin - AProc(); - end); - TSkDelegate.Finalize(context); -end; - -{ TSkImageFilter } - -class function TSkImageFilter.MakeAlphaThreshold(const ARegion: TRect; - const AInnerMin, AOuterMax: Single; AInput: ISkImageFilter): ISkImageFilter; -var - LRegion: ISkRegion; -begin - LRegion := TSkRegion.Create; - LRegion.SetRect(ARegion); - Result := MakeAlphaThreshold(LRegion, AInnerMin, AOuterMax, AInput); -end; - -class function TSkImageFilter.MakeAlphaThreshold(const ARegion: ISkRegion; - const AInnerMin, AOuterMax: Single; AInput: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(ARegion) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARegion']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_alpha_threshold(ARegion.Handle, AInnerMin, AOuterMax, TSkBindings.SafeHandle(AInput))); -end; - -class function TSkImageFilter.MakeArithmetic(const AK1, AK2, AK3, AK4: Single; - const AEnforcePremultipliedColor: Boolean; const ABackground: ISkImageFilter; - AForeground: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(ABackground) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ABackground']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_arithmetic(AK1, AK2, AK3, AK4, AEnforcePremultipliedColor, ABackground.Handle, TSkBindings.SafeHandle(AForeground), nil)); -end; - -class function TSkImageFilter.MakeArithmetic(const AK1, AK2, AK3, AK4: Single; - const AEnforcePremultipliedColor: Boolean; const ABackground: ISkImageFilter; - const ACropRect: TRectF; AForeground: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(ABackground) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ABackground']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_arithmetic(AK1, AK2, AK3, AK4, AEnforcePremultipliedColor, ABackground.Handle, TSkBindings.SafeHandle(AForeground), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeBlend(const AMode: TSkBlendMode; - const ABackground: ISkImageFilter; - AForeground: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(ABackground) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ABackground']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_blend(sk_blendmode_t(AMode), ABackground.Handle, TSkBindings.SafeHandle(AForeground), nil)); -end; - -class function TSkImageFilter.MakeBlend(const AMode: TSkBlendMode; - const ABackground: ISkImageFilter; const ACropRect: TRectF; - AForeground: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(ABackground) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ABackground']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_blend(sk_blendmode_t(AMode), ABackground.Handle, TSkBindings.SafeHandle(AForeground), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeBlur(const ASigmaX, ASigmaY: Single; - AInput: ISkImageFilter; const ATileMode: TSkTileMode): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_blur(ASigmaX, ASigmaY, sk_tilemode_t(ATileMode), TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeBlur(const ASigmaX, ASigmaY: Single; - const ACropRect: TRectF; AInput: ISkImageFilter; - const ATileMode: TSkTileMode): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_blur(ASigmaX, ASigmaY, sk_tilemode_t(ATileMode), TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeColorFilter( - const AColorFilter: ISkColorFilter; const ACropRect: TRectF; - AInput: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(AColorFilter) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AColorFilter']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_colorfilter(AColorFilter.Handle, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeColorFilter( - const AColorFilter: ISkColorFilter; AInput: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(AColorFilter) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AColorFilter']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_colorfilter(AColorFilter.Handle, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeCompose(const AOuter, - AInner: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(AOuter) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AOuter']); - if not Assigned(AInner) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AInner']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_compose(AOuter.Handle, AInner.Handle)); -end; - -class function TSkImageFilter.MakeDilate(const ARadiusX, ARadiusY: Single; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_dilate(ARadiusX, ARadiusY, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeDilate(const ARadiusX, ARadiusY: Single; - const ACropRect: TRectF; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_dilate(ARadiusX, ARadiusY, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeDisplacementMap(const AXChannelSelector, - AYChannelSelector: TSkColorChannel; const AScale: Single; - const ADisplacement: ISkImageFilter; AInput: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(ADisplacement) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ADisplacement']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_displacement_map(sk_colorchannel_t(AXChannelSelector), sk_colorchannel_t(AYChannelSelector), AScale, ADisplacement.Handle, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeDisplacementMap(const AXChannelSelector, - AYChannelSelector: TSkColorChannel; const AScale: Single; - const ADisplacement: ISkImageFilter; const ACropRect: TRectF; - AInput: ISkImageFilter): ISkImageFilter; -begin - if not Assigned(ADisplacement) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ADisplacement']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_displacement_map(sk_colorchannel_t(AXChannelSelector), sk_colorchannel_t(AYChannelSelector), AScale, ADisplacement.Handle, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeDistantLitDiffuse(const ADirection: TPoint3D; - const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; - const ACropRect: TRectF; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_distant_lit_diffuse(@sk_point3_t(ADirection), ALightColor, ASurfaceScale, AKd, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeDistantLitDiffuse(const ADirection: TPoint3D; - const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_distant_lit_diffuse(@sk_point3_t(ADirection), ALightColor, ASurfaceScale, AKd, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeDistantLitSpecular(const ADirection: TPoint3D; - const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_distant_lit_specular(@sk_point3_t(ADirection), ALightColor, ASurfaceScale, AKs, AShininess, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeDistantLitSpecular(const ADirection: TPoint3D; - const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; - const ACropRect: TRectF; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_distant_lit_specular(@sk_point3_t(ADirection), ALightColor, ASurfaceScale, AKs, AShininess, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeDropShadow(const ADeltaX, ADeltaY, ASigmaX, - ASigmaY: Single; const AColor: TAlphaColor; const ACropRect: TRectF; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_drop_shadow(ADeltaX, ADeltaY, ASigmaX, ASigmaY, AColor, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeDropShadow(const ADeltaX, ADeltaY, ASigmaX, - ASigmaY: Single; const AColor: TAlphaColor; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_drop_shadow(ADeltaX, ADeltaY, ASigmaX, ASigmaY, AColor, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeDropShadowOnly(const ADeltaX, ADeltaY, - ASigmaX, ASigmaY: Single; const AColor: TAlphaColor; const ACropRect: TRectF; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_drop_shadow_only(ADeltaX, ADeltaY, ASigmaX, ASigmaY, AColor, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeDropShadowOnly(const ADeltaX, ADeltaY, - ASigmaX, ASigmaY: Single; const AColor: TAlphaColor; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_drop_shadow_only(ADeltaX, ADeltaY, ASigmaX, ASigmaY, AColor, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeErode(const ARadiusX, ARadiusY: Single; - const ACropRect: TRectF; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_erode(ARadiusX, ARadiusY, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeErode(const ARadiusX, ARadiusY: Single; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_erode(ARadiusX, ARadiusY, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeImage(const AImage: ISkImage; - const ASampling: TSkSamplingOptions): ISkImageFilter; -begin - Result := MakeImage(AImage, TRectF.Create(0, 0, AImage.Width, AImage.Height), TRectF.Create(0, 0, AImage.Width, AImage.Height), ASampling); -end; - -class function TSkImageFilter.MakeImage(const AImage: ISkImage): ISkImageFilter; -begin - Result := MakeImage(AImage, TRectF.Create(0, 0, AImage.Width, AImage.Height), TRectF.Create(0, 0, AImage.Width, AImage.Height), TSkSamplingOptions.Create(TSkCubicResampler.Mitchell)); -end; - -class function TSkImageFilter.MakeImage(const AImage: ISkImage; const ASrc, - ADest: TRectF): ISkImageFilter; -begin - Result := MakeImage(AImage, ASrc, ADest, TSkSamplingOptions.Create(TSkCubicResampler.Mitchell)); -end; - -class function TSkImageFilter.MakeImage(const AImage: ISkImage; const ASrc, - ADest: TRectF; const ASampling: TSkSamplingOptions): ISkImageFilter; -begin - if not Assigned(AImage) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AImage']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_image(AImage.Handle, @sk_rect_t(ASrc), @sk_rect_t(ADest), @sk_samplingoptions_t(ASampling))); -end; - -class function TSkImageFilter.MakeMagnifier(const ASrc: TRectF; - const AInset: Single; const ACropRect: TRectF; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_magnifier(@sk_rect_t(ASrc), AInset, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeMagnifier(const ASrc: TRectF; - const AInset: Single; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_magnifier(@sk_rect_t(ASrc), AInset, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeMatrixConvolution(const AKernelSize: TSize; - const AKernel: TArray; const AGain, ABias: Single; - const AKernelOffset: TPoint; const ATileMode: TSkTileMode; - const AConvolveAlpha: Boolean; const ACropRect: TRectF; - AInput: ISkImageFilter): ISkImageFilter; -begin - if Length(AKernel) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AKernel']); - if Length(AKernel) <> (AKernelSize.Width * AKernelSize.Height) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AKernel']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_matrix_convolution(@sk_isize_t(AKernelSize), @AKernel[0], AGain, ABias, @sk_ipoint_t(AKernelOffset), sk_tilemode_t(ATileMode), AConvolveAlpha, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeMatrixConvolution(const AKernelSize: TSize; - const AKernel: TArray; const AGain, ABias: Single; - const AKernelOffset: TPoint; const ATileMode: TSkTileMode; - const AConvolveAlpha: Boolean; AInput: ISkImageFilter): ISkImageFilter; -begin - if Length(AKernel) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AKernel']); - if Length(AKernel) <> (AKernelSize.Width * AKernelSize.Height) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AKernel']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_matrix_convolution(@sk_isize_t(AKernelSize), @AKernel[0], AGain, ABias, @sk_ipoint_t(AKernelOffset), sk_tilemode_t(ATileMode), AConvolveAlpha, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeMatrixTransform(const AMatrix: TMatrix; - const ASampling: TSkSamplingOptions; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_matrix_transform(@sk_matrix_t(AMatrix), @sk_samplingoptions_t(ASampling), TSkBindings.SafeHandle(AInput))); -end; - -class function TSkImageFilter.MakeMatrixTransform(const AMatrix: TMatrix; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := MakeMatrixTransform(AMatrix, AInput); -end; - -class function TSkImageFilter.MakeMerge(const AFilter1, - AFilter2: ISkImageFilter): ISkImageFilter; -begin - Result := MakeMerge([AFilter1, AFilter2]); -end; - -class function TSkImageFilter.MakeMerge(const AFilters: TArray; - const ACropRect: TRectF): ISkImageFilter; -var - I: Integer; - LFilters: TArray; -begin - if Length(AFilters) < 2 then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AFilters']); - SetLength(LFilters, Length(AFilters)); - for I := 0 to Length(AFilters) - 1 do - begin - if not Assigned(AFilters[I]) then - raise ESkArgumentException.CreateFmt(SParamElementIsNil, ['AFilters', I]); - LFilters[I] := AFilters[I].Handle; - end; - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_merge(@LFilters[0], Length(LFilters), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeMerge(const AFilter1, - AFilter2: ISkImageFilter; const ACropRect: TRectF): ISkImageFilter; -begin - Result := MakeMerge([AFilter1, AFilter2], ACropRect); -end; - -class function TSkImageFilter.MakeMerge( - const AFilters: TArray): ISkImageFilter; -var - I: Integer; - LFilters: TArray; -begin - if Length(AFilters) < 2 then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AFilters']); - SetLength(LFilters, Length(AFilters)); - for I := 0 to Length(AFilters) - 1 do - begin - if not Assigned(AFilters[I]) then - raise ESkArgumentException.CreateFmt(SParamElementIsNil, ['AFilters', I]); - LFilters[I] := AFilters[I].Handle; - end; - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_merge(@LFilters[0], Length(LFilters), nil)); -end; - -class function TSkImageFilter.MakeOffset(const ADeltaX, ADeltaY: Single; - const ACropRect: TRectF; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_offset(ADeltaX, ADeltaY, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeOffset(const ADeltaX, ADeltaY: Single; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_offset(ADeltaX, ADeltaY, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakePicture(const APicture: ISkPicture; - const ACropRect: TRectF): ISkImageFilter; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_picture(APicture.Handle, @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakePicture( - const APicture: ISkPicture): ISkImageFilter; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_picture(APicture.Handle, nil)); -end; - -class function TSkImageFilter.MakePointLitDiffuse(const ALocation: TPoint3D; - const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_point_lit_diffuse(@sk_point3_t(ALocation), ALightColor, ASurfaceScale, AKd, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakePointLitDiffuse(const ALocation: TPoint3D; - const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; - const ACropRect: TRectF; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_point_lit_diffuse(@sk_point3_t(ALocation), ALightColor, ASurfaceScale, AKd, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakePointLitSpecular(const ALocation: TPoint3D; - const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_point_lit_specular(@sk_point3_t(ALocation), ALightColor, ASurfaceScale, AKs, AShininess, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakePointLitSpecular(const ALocation: TPoint3D; - const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; - const ACropRect: TRectF; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_point_lit_specular(@sk_point3_t(ALocation), ALightColor, ASurfaceScale, AKs, AShininess, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeShader(const AShader: ISkShader; - const ADither: Boolean; const ACropRect: TRectF): ISkImageFilter; -begin - if not Assigned(AShader) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AShader']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_shader(AShader.Handle, ADither, @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeShader(const AShader: ISkShader; - const ADither: Boolean): ISkImageFilter; -begin - if not Assigned(AShader) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AShader']); - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_shader(AShader.Handle, ADither, nil)); -end; - -class function TSkImageFilter.MakeSpotLitDiffuse(const ALocation, - ATarget: TPoint3D; const AFalloffExponent, ACutoffAngle: Single; - const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_spot_lit_diffuse(@sk_point3_t(ALocation), @sk_point3_t(ATarget), AFalloffExponent, ACutoffAngle, ALightColor, ASurfaceScale, AKd, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeSpotLitDiffuse(const ALocation, - ATarget: TPoint3D; const AFalloffExponent, ACutoffAngle: Single; - const ALightColor: TAlphaColor; const ASurfaceScale, AKd: Single; - const ACropRect: TRectF; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_spot_lit_diffuse(@sk_point3_t(ALocation), @sk_point3_t(ATarget), AFalloffExponent, ACutoffAngle, ALightColor, ASurfaceScale, AKd, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeSpotLitSpecular(const ALocation, - ATarget: TPoint3D; const AFalloffExponent, ACutoffAngle: Single; - const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_spot_lit_specular(@sk_point3_t(ALocation), @sk_point3_t(ATarget), AFalloffExponent, ACutoffAngle, ALightColor, ASurfaceScale, AKs, AShininess, TSkBindings.SafeHandle(AInput), nil)); -end; - -class function TSkImageFilter.MakeSpotLitSpecular(const ALocation, - ATarget: TPoint3D; const AFalloffExponent, ACutoffAngle: Single; - const ALightColor: TAlphaColor; const ASurfaceScale, AKs, AShininess: Single; - const ACropRect: TRectF; AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_spot_lit_specular(@sk_point3_t(ALocation), @sk_point3_t(ATarget), AFalloffExponent, ACutoffAngle, ALightColor, ASurfaceScale, AKs, AShininess, TSkBindings.SafeHandle(AInput), @sk_rect_t(ACropRect))); -end; - -class function TSkImageFilter.MakeTile(const ASrc, ADest: TRect; - AInput: ISkImageFilter): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_tile(@sk_rect_t(ASrc), @sk_rect_t(ADest), TSkBindings.SafeHandle(AInput))); -end; - -function TSkImageFilter.MakeWithLocalMatrix( - const AMatrix: TMatrix): ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_imagefilter_make_with_local_matrix(Handle, @sk_matrix_t(AMatrix))); -end; - -{ TSkMaskFilter } - -class function TSkMaskFilter.MakeBlur(const AStyle: TSkBlurStyle; - const ASigma: Single; const ARespectCTM: Boolean): ISkMaskFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_maskfilter_make_blur(sk_blurstyle_t(AStyle), ASigma, ARespectCTM)); -end; - -class function TSkMaskFilter.MakeShader( - const AShader: ISkShader): ISkMaskFilter; -begin - if not Assigned(AShader) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AShader']); - Result := TSkBindings.SafeCreate(sk4d_maskfilter_make_shader(AShader.Handle)); -end; - -class function TSkMaskFilter.MakeTable( - const ATable: TSkTableFilter): ISkMaskFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_maskfilter_make_table(@ATable)); -end; - -class function TSkMaskFilter.MakeTableClip(const AMin, - AMax: Byte): ISkMaskFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_maskfilter_make_table_clip(AMin, AMax)); -end; - -class function TSkMaskFilter.MakeTableGamma( - const AGamma: Single): ISkMaskFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_maskfilter_make_table_gamma(AGamma)); -end; - -{ TSkPaint } - -constructor TSkPaint.Create; -begin - inherited Create(sk4d_paint_create()); -end; - -constructor TSkPaint.Create(const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - inherited Create(sk4d_paint_create2(APaint.Handle)); -end; - -constructor TSkPaint.Create(const AStyle: TSkPaintStyle); -begin - Create; - SetStyle(AStyle); -end; - -function TSkPaint.GetAlpha: Byte; -begin - Result := sk4d_paint_get_alpha(Handle); -end; - -function TSkPaint.GetAlphaF: Single; -begin - Result := sk4d_paint_get_alphaf(Handle); -end; - -function TSkPaint.GetAntiAlias: Boolean; -begin - Result := sk4d_paint_get_anti_alias(Handle); -end; - -function TSkPaint.GetBlender: ISkBlender; -begin - Result := TSkBindings.SafeCreate(sk4d_paint_get_blender(Handle)); -end; - -function TSkPaint.GetColor: TAlphaColor; -begin - Result := sk4d_paint_get_color(Handle); -end; - -function TSkPaint.GetColorF: TAlphaColorF; -begin - sk4d_paint_get_colorf(Handle, sk_color4f_t(Result)); -end; - -function TSkPaint.GetColorFilter: ISkColorFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_paint_get_color_filter(Handle)); -end; - -function TSkPaint.GetDither: Boolean; -begin - Result := sk4d_paint_get_dither(Handle); -end; - -function TSkPaint.GetFillPath(const APath: ISkPath; const ACullRect: TRectF; - const AResScale: Single): ISkPath; -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - Result := TSkBindings.SafeCreate(sk4d_paint_get_fill_path(Handle, APath.Handle, @sk_rect_t(ACullRect), AResScale)); -end; - -function TSkPaint.GetFillPath(const APath: ISkPath): ISkPath; -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - Result := TSkBindings.SafeCreate(sk4d_paint_get_fill_path(Handle, APath.Handle, nil, 1)); -end; - -function TSkPaint.GetImageFilter: ISkImageFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_paint_get_image_filter(Handle)); -end; - -function TSkPaint.GetMaskFilter: ISkMaskFilter; -begin - Result := TSkBindings.SafeCreate(sk4d_paint_get_mask_filter(Handle)); -end; - -function TSkPaint.GetPathEffect: ISkPathEffect; -begin - Result := TSkBindings.SafeCreate(sk4d_paint_get_path_effect(Handle)); -end; - -function TSkPaint.GetShader: ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_paint_get_shader(Handle)); -end; - -function TSkPaint.GetStrokeCap: TSkStrokeCap; -begin - Result := TSkStrokeCap(sk4d_paint_get_stroke_cap(Handle)); -end; - -function TSkPaint.GetStrokeJoin: TSkStrokeJoin; -begin - Result := TSkStrokeJoin(sk4d_paint_get_stroke_join(Handle)); -end; - -function TSkPaint.GetStrokeMiter: Single; -begin - Result := sk4d_paint_get_stroke_miter(Handle); -end; - -function TSkPaint.GetStrokeWidth: Single; -begin - Result := sk4d_paint_get_stroke_width(Handle); -end; - -function TSkPaint.GetStyle: TSkPaintStyle; -begin - Result := TSkPaintStyle(sk4d_paint_get_style(Handle)) -end; - -procedure TSkPaint.Reset; -begin - sk4d_paint_reset(Handle); -end; - -procedure TSkPaint.SetAlpha(const AValue: Byte); -begin - sk4d_paint_set_alpha(Handle, AValue); -end; - -procedure TSkPaint.SetAlphaF(const AValue: Single); -begin - sk4d_paint_set_alphaf(Handle, AValue); -end; - -procedure TSkPaint.SetAntiAlias(const AValue: Boolean); -begin - sk4d_paint_set_antialias(Handle, AValue); -end; - -procedure TSkPaint.SetARGB(const A, R, G, B: Byte); -begin - sk4d_paint_set_argb(Handle, A, R, G, B); -end; - -procedure TSkPaint.SetBlender(AValue: ISkBlender); -begin - sk4d_paint_set_blender(Handle, TSkBindings.SafeHandle(AValue)); -end; - -procedure TSkPaint.SetColor(const AValue: TAlphaColor); -begin - sk4d_paint_set_color(Handle, AValue); -end; - -procedure TSkPaint.SetColorF(const AValue: TAlphaColorF; - AColorSpace: ISkColorSpace); -begin - sk4d_paint_set_colorf(Handle, @sk_color4f_t(AValue), TSkBindings.SafeHandle(AColorSpace)); -end; - -procedure TSkPaint.SetColorFilter(AValue: ISkColorFilter); -begin - sk4d_paint_set_color_filter(Handle, TSkBindings.SafeHandle(AValue)); -end; - -procedure TSkPaint.SetDither(const AValue: Boolean); -begin - sk4d_paint_set_dither(Handle, AValue); -end; - -procedure TSkPaint.SetImageFilter(AValue: ISkImageFilter); -begin - sk4d_paint_set_image_filter(Handle, TSkBindings.SafeHandle(AValue)); -end; - -procedure TSkPaint.SetMaskFilter(AValue: ISkMaskFilter); -begin - sk4d_paint_set_mask_filter(Handle, TSkBindings.SafeHandle(AValue)); -end; - -procedure TSkPaint.SetPathEffect(AValue: ISkPathEffect); -begin - sk4d_paint_set_path_effect(Handle, TSkBindings.SafeHandle(AValue)); -end; - -procedure TSkPaint.SetShader(AValue: ISkShader); -begin - sk4d_paint_set_shader(Handle, TSkBindings.SafeHandle(AValue)); -end; - -procedure TSkPaint.SetStrokeCap(const AValue: TSkStrokeCap); -begin - sk4d_paint_set_stroke_cap(Handle, sk_strokecap_t(AValue)); -end; - -procedure TSkPaint.SetStrokeJoin(const AValue: TSkStrokeJoin); -begin - sk4d_paint_set_stroke_join(Handle, sk_strokejoin_t(AValue)); -end; - -procedure TSkPaint.SetStrokeMiter(const AValue: Single); -begin - sk4d_paint_set_stroke_miter(Handle, AValue); -end; - -procedure TSkPaint.SetStrokeWidth(const AValue: Single); -begin - sk4d_paint_set_stroke_width(Handle, AValue); -end; - -procedure TSkPaint.SetStyle(const AValue: TSkPaintStyle); -begin - sk4d_paint_set_style(Handle, sk_paintstyle_t(AValue)); -end; - -class procedure TSkPaint.__DestroyHandle(const AHandle: THandle); -begin - sk4d_paint_destroy(AHandle); -end; - -{ TSkOpBuilder } - -procedure TSkOpBuilder.Add(const APath: ISkPath; const AOp: TSkPathOp); -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - sk4d_opbuilder_add(Handle, APath.Handle, sk_pathop_t(AOp)); -end; - -constructor TSkOpBuilder.Create; -begin - inherited Create(sk4d_opbuilder_create()); -end; - -function TSkOpBuilder.Detach: ISkPath; -begin - Result := TSkBindings.SafeCreate(sk4d_opbuilder_detach(Handle)); -end; - -class procedure TSkOpBuilder.__DestroyHandle(const AHandle: THandle); -begin - sk4d_opbuilder_destroy(AHandle); -end; - -{ TSkPath } - -function TSkPath.Contains(const AX, AY: Single): Boolean; -begin - Result := sk4d_path_contains(Handle, AX, AY); -end; - -class function TSkPath.ConvertConicToQuads(const APoint1, APoint2, - APoint3: TPointF; const AWeight: Single; - const APower2: Integer): TArray; -begin - SetLength(Result, 1 + 2 * (1 shl APower2)); - if Length(Result) > 0 then - sk4d_path_convert_conic_to_quads(@sk_point_t(APoint1), @sk_point_t(APoint2), @sk_point_t(APoint3), AWeight, @sk_point_t(Result[0]), APower2); -end; - -constructor TSkPath.Create(const ASVG: string); -var - LMarshaller: TMarshaller; -begin - inherited Create(sk4d_path_create(MarshaledAString(LMarshaller.AsUtf8(ASVG).ToPointer))); -end; - -constructor TSkPath.Create(const ABytes: TBytes); -var - LStream: TStream; -begin - LStream := TBytesStream.Create(ABytes); - try - Create(LStream); - finally - LStream.Free; - end; -end; - -constructor TSkPath.Create(const AStream: TStream); -var - LStream: ISkStream; -begin - LStream := TSkStreamAdapter.Create(AStream); - inherited Create(sk4d_path_create2(LStream.Handle)); -end; - -function TSkPath.GetBounds: TRectF; -begin - sk4d_path_get_bounds(Handle, sk_rect_t(Result)); -end; - -function TSkPath.GetFillType: TSkPathFillType; -begin - Result := TSkPathFillType(sk4d_path_get_fill_type(Handle)); -end; - -function TSkPath.GetIterator(const AForceClose: Boolean): ISkPathIterator; -begin - Result := TPathIterator.Create(Self, AForceClose); -end; - -function TSkPath.GetLastPoint: TPointF; -begin - if not sk4d_path_get_last_point(Handle, sk_point_t(Result)) then - Result := TPointF.Create(0, 0); -end; - -function TSkPath.GetSegmentMasks: TSkSegmentMasks; -begin - Result := TSkSegmentMasks(Byte(sk4d_path_get_segment_masks(Handle))); -end; - -function TSkPath.GetTightBounds: TRectF; -begin - sk4d_path_get_tight_bounds(Handle, sk_rect_t(Result)); -end; - -function TSkPath.Interpolate(const AEnding: ISkPath; - const AWeight: Single): ISkPath; -begin - if not Assigned(AEnding) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AEnding']); - Result := TSkBindings.SafeCreate(sk4d_path_interpolate(Handle, AEnding.Handle, AWeight)); -end; - -function TSkPath.IsConvex: Boolean; -begin - Result := sk4d_path_is_convex(Handle); -end; - -function TSkPath.IsEmpty: Boolean; -begin - Result := sk4d_path_is_empty(Handle); -end; - -function TSkPath.IsFinite: Boolean; -begin - Result := sk4d_path_is_finite(Handle); -end; - -function TSkPath.IsInterpolatable(const APath: ISkPath): Boolean; -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - Result := sk4d_path_is_interpolatable(Handle, APath.Handle); -end; - -function TSkPath.IsLastContourClosed: Boolean; -begin - Result := sk4d_path_is_last_contour_closed(Handle); -end; - -function TSkPath.IsLine: Boolean; -begin - Result := sk4d_path_is_line(Handle, nil); -end; - -function TSkPath.IsLine(out APoint1, APoint2: TPointF): Boolean; -var - LLines: array[0..1] of TPointF; -begin - LLines[0] := APoint1; - LLines[1] := APoint2; - Result := sk4d_path_is_line(Handle, @sk_point_t(LLines[0])); -end; - -function TSkPath.IsOval(out ARect: TRectF): Boolean; -begin - Result := sk4d_path_is_oval(Handle, @sk_rect_t(ARect)); -end; - -function TSkPath.IsOval: Boolean; -begin - Result := sk4d_path_is_oval(Handle, nil); -end; - -function TSkPath.IsRect(out ARect: TRectF): Boolean; -begin - Result := sk4d_path_is_rect(Handle, @sk_rect_t(ARect)); -end; - -function TSkPath.IsRect: Boolean; -begin - Result := sk4d_path_is_rect(Handle, nil); -end; - -function TSkPath.IsRoundRect(out ARoundRect: ISkRoundRect): Boolean; -var - LRoundRect: ISkRoundRect; -begin - LRoundRect := TSkRoundRect.Create; - Result := sk4d_path_is_rrect(Handle, TSkBindings.SafeHandle(LRoundRect)); - if Result then - ARoundRect := LRoundRect; -end; - -function TSkPath.IsRoundRect: Boolean; -begin - Result := sk4d_path_is_rrect(Handle, 0); -end; - -function TSkPath.Op(const APath: ISkPath; const AOp: TSkPathOp): ISkPath; -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - Result := TSkBindings.SafeCreate(sk4d_path_op(Handle, APath.Handle, sk_pathop_t(AOp))); -end; - -function TSkPath.Serialize: TBytes; -var - LBytesStream: TBytesStream; -begin - LBytesStream := TBytesStream.Create; - try - SerializeToStream(LBytesStream); - Result := Copy(LBytesStream.Bytes, 0, LBytesStream.Size); - finally - LBytesStream.Free; - end; -end; - -procedure TSkPath.SerializeToStream(const AStream: TStream); -var - LWStream: ISkWStream; -begin - LWStream := TSkWStreamAdapter.Create(AStream); - sk4d_path_serialize_to_stream(Handle, LWStream.Handle); -end; - -function TSkPath.ToSVG: string; -var - LResult: ISkString; -begin - LResult := TSkString.Wrap(sk4d_path_to_svg(Handle)); - Result := LResult.Text; -end; - -function TSkPath.Transform(const AMatrix: TMatrix): ISkPath; -begin - Result := TSkPath.Wrap(sk4d_path_transform(Handle, @sk_matrix_t(AMatrix))); -end; - -class procedure TSkPath.__DestroyHandle(const AHandle: THandle); -begin - sk4d_path_destroy(AHandle); -end; - -{ TSkPath.TPathIterator } - -constructor TSkPath.TPathIterator.Create(const APath: ISkPath; - const AForceClose: Boolean); -begin - inherited Create(sk4d_pathiterator_create(APath.Handle, AForceClose)); -end; - -function TSkPath.TPathIterator.GetCurrent: TSkPathIteratorElem; -begin - Result := FCurrent; -end; - -function TSkPath.TPathIterator.MoveNext: Boolean; -begin - Result := sk4d_pathiterator_next(Handle, sk_pathiteratorelem_t(FCurrent)); -end; - -class procedure TSkPath.TPathIterator.__DestroyHandle(const AHandle: THandle); -begin - sk4d_pathiterator_destroy(AHandle); -end; - -{ TSkPathBuilder } - -procedure TSkPathBuilder.AddArc(const AOval: TRectF; const AStartAngle, - ASweepAngle: Single); -begin - sk4d_pathbuilder_add_arc(Handle, @sk_rect_t(AOval), AStartAngle, ASweepAngle); -end; - -procedure TSkPathBuilder.AddCircle(const ACenterX, ACenterY, ARadius: Single; - ADirection: TSkPathDirection); -begin - sk4d_pathbuilder_add_circle(Handle,ACenterX, ACenterY, ARadius, sk_pathdirection_t(ADirection)); -end; - -procedure TSkPathBuilder.AddCircle(const ACenter: TPointF; ARadius: Single; - ADirection: TSkPathDirection); -begin - AddCircle(ACenter.X, ACenter.Y, ARadius, ADirection); -end; - -procedure TSkPathBuilder.AddOval(const ARect: TRectF; - ADirection: TSkPathDirection; AStartIndex: Cardinal); -begin - sk4d_pathbuilder_add_oval(Handle, @sk_rect_t(ARect), sk_pathdirection_t(ADirection), AStartIndex); -end; - -procedure TSkPathBuilder.AddOval(const ARect: TRectF; - ADirection: TSkPathDirection); -begin - AddOval(ARect, ADirection, 1); -end; - -procedure TSkPathBuilder.AddPath(const APath: ISkPath); -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - sk4d_pathbuilder_add_path(Handle, APath.Handle); -end; - -procedure TSkPathBuilder.AddPolygon(const APolygon: TPolygon; - const IsClosed: Boolean); -begin - if Length(APolygon) > 0 then - sk4d_pathbuilder_add_polygon(Handle, @sk_point_t(APolygon[0]), Length(APolygon), IsClosed); -end; - -procedure TSkPathBuilder.AddRect(const ARect: TRectF; - ADirection: TSkPathDirection; AStartIndex: Cardinal); -begin - if AStartIndex > 3 then - raise ESkArgumentException.CreateFmt(SParamOutOfRange, ['AStartIndex', AStartIndex, 0, 4]); - sk4d_pathbuilder_add_rect(Handle, @sk_rect_t(ARect), sk_pathdirection_t(ADirection), AStartIndex); -end; - -procedure TSkPathBuilder.AddRect(const ARect: TRectF; - ADirection: TSkPathDirection); -begin - AddRect(ARect, ADirection, 0); -end; - -procedure TSkPathBuilder.AddRoundRect(const ARoundRect: ISkRoundRect; - ADirection: TSkPathDirection); -begin - AddRoundRect(ARoundRect, ADirection, IfThen(ADirection = TSkPathDirection.CW, 6, 7)); -end; - -procedure TSkPathBuilder.AddRoundRect(const ARoundRect: ISkRoundRect; - ADirection: TSkPathDirection; AStartIndex: Cardinal); -begin - if not Assigned(ARoundRect) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARoundRect']); - sk4d_pathbuilder_add_rrect(Handle, ARoundRect.Handle, sk_pathdirection_t(ADirection), AStartIndex); -end; - -procedure TSkPathBuilder.ArcTo(const APoint1, APoint2: TPointF; - const ARadius: Single); -begin - sk4d_pathbuilder_arc_to3(Handle, @sk_point_t(APoint1), @sk_point_t(APoint2), ARadius); -end; - -procedure TSkPathBuilder.ArcTo(const AOval: TRectF; const AStartAngle, - ASweepAngle: Single; const AForceMoveTo: Boolean); -begin - sk4d_pathbuilder_arc_to2(Handle, @sk_rect_t(AOval), AStartAngle, ASweepAngle, AForceMoveTo); -end; - -procedure TSkPathBuilder.ArcTo(const ARadius: TPointF; - const XAxisRotate: Single; const ALargeArc: TSkPathArcSize; - const ASweep: TSkPathDirection; const AXY: TPointF); -begin - sk4d_pathbuilder_arc_to(Handle, @sk_point_t(ARadius), XAxisRotate, sk_patharcsize_t(ALargeArc), sk_pathdirection_t(ASweep), @sk_point_t(AXY)); -end; - -procedure TSkPathBuilder.Close; -begin - sk4d_pathbuilder_close(Handle); -end; - -procedure TSkPathBuilder.ConicTo(const APoint1, APoint2: TPointF; - const AWeight: Single); -begin - sk4d_pathbuilder_conic_to(Handle, @sk_point_t(APoint1), @sk_point_t(APoint2), AWeight); -end; - -procedure TSkPathBuilder.ConicTo(const AX1, AY1, AX2, AY2, AWeight: Single); -begin - ConicTo(TPointF.Create(AX1, AY1), TPointF.Create(AX2, AY2), AWeight); -end; - -constructor TSkPathBuilder.Create; -begin - inherited Create(sk4d_pathbuilder_create()); -end; - -constructor TSkPathBuilder.Create(const AFillType: TSkPathFillType); -begin - Create; - SetFillType(AFillType); -end; - -constructor TSkPathBuilder.Create(const APathBuilder: ISkPathBuilder); -begin - if not Assigned(APathBuilder) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APathBuilder']); - inherited Create(sk4d_pathbuilder_create2(APathBuilder.Handle)); -end; - -procedure TSkPathBuilder.CubicTo(const APoint1, APoint2, APoint3: TPointF); -begin - sk4d_pathbuilder_cubic_to(Handle, @sk_point_t(APoint1), @sk_point_t(APoint2), @sk_point_t(APoint3)); -end; - -procedure TSkPathBuilder.CubicTo(const AX1, AY1, AX2, AY2, AX3, AY3: Single); -begin - CubicTo(TPointF.Create(AX1, AY1), TPointF.Create(AX2, AY2), TPointF.Create(AX3, AY3)); -end; - -function TSkPathBuilder.Detach: ISkPath; -begin - Result := TSkPath.Wrap(sk4d_pathbuilder_detach(Handle)); -end; - -function TSkPathBuilder.GetBounds: TRectF; -begin - sk4d_pathbuilder_get_bounds(Handle, sk_rect_t(Result)); -end; - -function TSkPathBuilder.GetFillType: TSkPathFillType; -begin - Result := TSkPathFillType(sk4d_pathbuilder_get_fill_type(Handle)); -end; - -procedure TSkPathBuilder.IncReserve(const AExtraPointCount: Integer); -begin - IncReserve(AExtraPointCount, AExtraPointCount); -end; - -procedure TSkPathBuilder.IncReserve(const AExtraPointCount, - AExtraVerbCount: Integer); -begin - sk4d_pathbuilder_inc_reserve(Handle, AExtraPointCount, AExtraVerbCount); -end; - -procedure TSkPathBuilder.LineTo(const AX, AY: Single); -begin - LineTo(TPointF.Create(AX, AY)); -end; - -procedure TSkPathBuilder.LineTo(const APoint: TPointF); -begin - sk4d_pathbuilder_line_to(Handle, @sk_point_t(APoint)); -end; - -procedure TSkPathBuilder.MoveTo(const AX, AY: Single); -begin - MoveTo(TPointF.Create(AX, AY)); -end; - -procedure TSkPathBuilder.MoveTo(const APoint: TPointF); -begin - sk4d_pathbuilder_move_to(Handle, @sk_point_t(APoint)); -end; - -procedure TSkPathBuilder.Offset(const ADeltaX, ADeltaY: Single); -begin - sk4d_pathbuilder_offset(Handle, ADeltaX, ADeltaY); -end; - -procedure TSkPathBuilder.PolylineTo(const APoints: TArray); -begin - if Length(APoints) > 0 then - sk4d_pathbuilder_polyline_to(Handle, @sk_point_t(APoints[0]), Length(APoints)); -end; - -procedure TSkPathBuilder.QuadTo(const AX1, AY1, AX2, AY2: Single); -begin - QuadTo(TPointF.Create(AX1, AY1), TPointF.Create(AX2, AY2)); -end; - -procedure TSkPathBuilder.QuadTo(const APoint1, APoint2: TPointF); -begin - sk4d_pathbuilder_quad_to(Handle, @sk_point_t(APoint1), @sk_point_t(APoint2)); -end; - -procedure TSkPathBuilder.RConicTo(const APoint1, APoint2: TPointF; - const AWeight: Single); -begin - sk4d_pathbuilder_r_conic_to(Handle, @sk_point_t(APoint1), @sk_point_t(APoint2), AWeight); -end; - -procedure TSkPathBuilder.RConicTo(const AX1, AY1, AX2, AY2, AWeight: Single); -begin - RConicTo(TPointF.Create(AX1, AY1), TPointF.Create(AX2, AY2), AWeight); -end; - -procedure TSkPathBuilder.RCubicTo(const AX1, AY1, AX2, AY2, AX3, AY3: Single); -begin - RCubicTo(TPointF.Create(AX1, AY1), TPointF.Create(AX2, AY2), TPointF.Create(AX3, AY3)); -end; - -procedure TSkPathBuilder.RCubicTo(const APoint1, APoint2, APoint3: TPointF); -begin - sk4d_pathbuilder_r_cubic_to(Handle, @sk_point_t(APoint1), @sk_point_t(APoint2), @sk_point_t(APoint3)); -end; - -procedure TSkPathBuilder.Reset; -begin - sk4d_pathbuilder_reset(Handle); -end; - -procedure TSkPathBuilder.RLineTo(const AX, AY: Single); -begin - RLineTo(TPointF.Create(AX, AY)); -end; - -procedure TSkPathBuilder.RLineTo(const APoint: TPointF); -begin - sk4d_pathbuilder_r_line_to(Handle, @sk_point_t(APoint)); -end; - -procedure TSkPathBuilder.RQuadTo(const AX1, AY1, AX2, AY2: Single); -begin - RQuadTo(TPointF.Create(AX1, AY1), TPointF.Create(AX2, AY2)); -end; - -procedure TSkPathBuilder.RQuadTo(const APoint1, APoint2: TPointF); -begin - sk4d_pathbuilder_r_quad_to(Handle, @sk_point_t(APoint1), @sk_point_t(APoint2)); -end; - -procedure TSkPathBuilder.SetFillType(const AValue: TSkPathFillType); -begin - sk4d_pathbuilder_set_filltype(Handle, sk_pathfilltype_t(AValue)); -end; - -function TSkPathBuilder.Snapshot: ISkPath; -begin - Result := TSkPath.Wrap(sk4d_pathbuilder_snapshot(Handle)); -end; - -procedure TSkPathBuilder.ToggleInverseFillType; -begin - sk4d_pathbuilder_toggle_inverse_filltype(Handle); -end; - -class procedure TSkPathBuilder.__DestroyHandle(const AHandle: THandle); -begin - sk4d_pathbuilder_destroy(AHandle); -end; - -{ TSkPathEffect } - -class function TSkPathEffect.Make1DPath(const APath: ISkPath; const AAdvance, - APhase: Single; const AStyle: TSkPathEffect1DStyle): ISkPathEffect; -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_1dpath(APath.Handle, AAdvance, APhase, sk_patheffect1dstyle_t(AStyle))); -end; - -class function TSkPathEffect.Make2DLine(const AWidth: Single; - const AMatrix: TMatrix): ISkPathEffect; -begin - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_2dline(AWidth, @sk_matrix_t(AMatrix))); -end; - -class function TSkPathEffect.Make2DPath(const AMatrix: TMatrix; - const APath: ISkPath): ISkPathEffect; -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_2dpath(@sk_matrix_t(AMatrix), APath.Handle)); -end; - -class function TSkPathEffect.MakeCompose(const AOuter, - AInner: ISkPathEffect): ISkPathEffect; -begin - if not Assigned(AOuter) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AOuter']); - if not Assigned(AInner) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AInner']); - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_compose(AOuter.Handle, AInner.Handle)); -end; - -class function TSkPathEffect.MakeCorner(const ARadius: Single): ISkPathEffect; -begin - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_corner(ARadius)); -end; - -class function TSkPathEffect.MakeDash(const AIntervals: TArray; - const APhase: Single): ISkPathEffect; -begin - if Length(AIntervals) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AIntervals']); - if Odd(Length(AIntervals)) then - raise ESkArgumentException.CreateFmt(SParamSizeIsOdd, ['AIntervals']); - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_dash(@AIntervals[0], Length(AIntervals), APhase)); -end; - -class function TSkPathEffect.MakeDiscrete(const ASegLength, ADeviation: Single; - const ASeedAssist: Cardinal): ISkPathEffect; -begin - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_discrete(ASegLength, ADeviation, ASeedAssist)); -end; - -class function TSkPathEffect.MakeMatrix(const AMatrix: TMatrix): ISkPathEffect; -begin - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_matrix(@sk_matrix_t(AMatrix))); -end; - -class function TSkPathEffect.MakeMerge(const AEffect1, AEffect2: ISkPathEffect; - const AOp: TSkPathOp): ISkPathEffect; -begin - if not Assigned(AEffect1) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AEffect1']); - if not Assigned(AEffect2) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AEffect2']); - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_merge(AEffect1.Handle, AEffect2.Handle, sk_pathop_t(AOp))); -end; - -class function TSkPathEffect.MakeStroke(const AWidth: Single; - const AJoin: TSkStrokeJoin; const ACap: TSkStrokeCap; - const AMiter: Single): ISkPathEffect; -begin - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_stroke(AWidth, sk_strokejoin_t(AJoin), sk_strokecap_t(ACap), AMiter)); -end; - -class function TSkPathEffect.MakeStrokeAndFill: ISkPathEffect; -begin - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_stroke_and_fill()); -end; - -class function TSkPathEffect.MakeSum(const AEffect1, - AEffect2: ISkPathEffect): ISkPathEffect; -begin - if not Assigned(AEffect1) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AEffect1']); - if not Assigned(AEffect2) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AEffect2']); - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_sum(AEffect1.Handle, AEffect2.Handle)); -end; - -class function TSkPathEffect.MakeTranslate(const ADeltaX, - ADeltaY: Single): ISkPathEffect; -begin - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_translate(ADeltaX, ADeltaY)); -end; - -class function TSkPathEffect.MakeTrim(const AStart, AStop: Single; - const AMode: TSkPathEffectTrimMode): ISkPathEffect; -begin - Result := TSkBindings.SafeCreate(sk4d_patheffect_make_trim(AStart, AStop, sk_patheffecttrimmode_t(AMode))); -end; - -{ TSkPathMeasure } - -constructor TSkPathMeasure.Create(const APath: ISkPath; - const AForceClosed: Boolean; const AResScale: Single); -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - inherited Create(sk4d_pathmeasure_create(APath.Handle, AForceClosed, AResScale)); -end; - -function TSkPathMeasure.GetLength: Single; -begin - Result := sk4d_pathmeasure_get_length(Handle); -end; - -function TSkPathMeasure.GetMatrix(const ADistance: Single; out AMatrix: TMatrix; - const AMatrixFlags: TSkPathMeasureMatrixFlags): Boolean; -begin - Result := sk4d_pathmeasure_get_matrix(Handle, ADistance, sk_matrix_t(AMatrix), Byte(AMatrixFlags)); -end; - -function TSkPathMeasure.GetPositionAndTangent(const ADistance: Single; - out APosition, ATangent: TPointF): Boolean; -begin - Result := sk4d_pathmeasure_get_position_and_tangent(Handle, ADistance, sk_point_t(APosition), sk_vector_t(ATangent)); -end; - -function TSkPathMeasure.GetSegment(const AStart, AStop: Single; - const AStartWithMoveTo: Boolean): ISkPath; -begin - Result := TSkBindings.SafeCreate(sk4d_pathmeasure_get_segment(Handle, AStart, AStop, AStartWithMoveTo)); -end; - -function TSkPathMeasure.IsClosed: Boolean; -begin - Result := sk4d_pathmeasure_is_closed(Handle); -end; - -function TSkPathMeasure.NextContour: Boolean; -begin - Result := sk4d_pathmeasure_next_contour(Handle); -end; - -class procedure TSkPathMeasure.__DestroyHandle(const AHandle: THandle); -begin - sk4d_pathmeasure_destroy(AHandle); -end; - -{ TSkPicture } - -function TSkPicture.GetCullRect: TRectF; -begin - sk4d_picture_get_cull_rect(Handle, sk_rect_t(Result)); -end; - -class function TSkPicture.MakeFromBytes(const ABytes: TBytes): ISkPicture; -var - LStream: TStream; -begin - LStream := TBytesStream.Create(ABytes); - try - Result := MakeFromStream(LStream); - finally - LStream.Free; - end; -end; - -class function TSkPicture.MakeFromStream(const AStream: TStream): ISkPicture; -var - LStream: ISkStream; -begin - LStream := TSkStreamAdapter.Create(AStream); - Result := TSkBindings.SafeCreate(sk4d_picture_make_from_stream(LStream.Handle)); -end; - -function TSkPicture.MakeShader(const ALocalMatrix: TMatrix; const ATileModeX, - ATileModeY: TSkTileMode; const AFilterMode: TSkFilterMode): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_picture_make_shader(Handle, sk_tilemode_t(ATileModeX), sk_tilemode_t(ATileModeY), sk_filtermode_t(AFilterMode), @sk_matrix_t(ALocalMatrix), nil)); -end; - -function TSkPicture.MakeShader(const ATileModeX, ATileModeY: TSkTileMode; - const AFilterMode: TSkFilterMode): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_picture_make_shader(Handle, sk_tilemode_t(ATileModeX), sk_tilemode_t(ATileModeY), sk_filtermode_t(AFilterMode), nil, nil)); -end; - -function TSkPicture.MakeShader(const ATileRect: TRectF; const ATileModeX, - ATileModeY: TSkTileMode; const AFilterMode: TSkFilterMode): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_picture_make_shader(Handle, sk_tilemode_t(ATileModeX), sk_tilemode_t(ATileModeY), sk_filtermode_t(AFilterMode), nil, @sk_rect_t(ATileRect))); -end; - -function TSkPicture.MakeShader(const ATileRect: TRectF; - const ALocalMatrix: TMatrix; const ATileModeX, ATileModeY: TSkTileMode; - const AFilterMode: TSkFilterMode): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_picture_make_shader(Handle, sk_tilemode_t(ATileModeX), sk_tilemode_t(ATileModeY), sk_filtermode_t(AFilterMode), @sk_matrix_t(ALocalMatrix), @sk_rect_t(ATileRect))); -end; - -procedure TSkPicture.Playback(const ACanvas: ISkCanvas); -begin - if not Assigned(ACanvas) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ACanvas']); - sk4d_picture_playback(Handle, ACanvas.Handle); -end; - -function TSkPicture.Serialize: TBytes; -var - LBytesStream: TBytesStream; -begin - LBytesStream := TBytesStream.Create; - try - SerializeToStream(LBytesStream); - Result := Copy(LBytesStream.Bytes, 0, LBytesStream.Size); - finally - LBytesStream.Free; - end; -end; - -procedure TSkPicture.SerializeToStream(const AStream: TStream); -var - LWStream: ISkWStream; -begin - LWStream := TSkWStreamAdapter.Create(AStream); - sk4d_picture_serialize_to_stream(Handle, LWStream.Handle); -end; - -{ TSkPictureRecorder } - -function TSkPictureRecorder.BeginRecording(const AWidth, - AHeight: Single): ISkCanvas; -begin - Result := BeginRecording(TRectF.Create(0, 0, AWidth, AHeight)); -end; - -function TSkPictureRecorder.BeginRecording(const ABounds: TRectF): ISkCanvas; -begin - Result := TSkBindings.SafeCreate(sk4d_picturerecorder_begin_recording(Handle, @sk_rect_t(ABounds)), False); -end; - -constructor TSkPictureRecorder.Create; -begin - inherited Create(sk4d_picturerecorder_create()); -end; - -function TSkPictureRecorder.FinishRecording: ISkPicture; -begin - Result := TSkBindings.SafeCreate(sk4d_picturerecorder_finish_recording(Handle)); -end; - -function TSkPictureRecorder.FinishRecording( - const ACullRect: TRectF): ISkPicture; -begin - Result := TSkBindings.SafeCreate(sk4d_picturerecorder_finish_recording2(Handle, @sk_rect_t(ACullRect))); -end; - -class procedure TSkPictureRecorder.__DestroyHandle(const AHandle: THandle); -begin - sk4d_picturerecorder_destroy(AHandle); -end; - -{ TSkPixmap } - -constructor TSkPixmap.Create(const AImageInfo: TSkImageInfo; - const APixels: Pointer; const ARowBytes: NativeUInt); -var - LImageInfo: sk_imageinfo_t; -begin - LImageInfo := TSkBindings.AsImageInfo(AImageInfo); - inherited Create(sk4d_pixmap_create(@LImageInfo, APixels, ARowBytes)); -end; - -function TSkPixmap.Erase(const AColor: TAlphaColorF; const ASubset: TRectF; - AColorSpace: ISkColorSpace): Boolean; -begin - Result := sk4d_pixmap_erase2(Handle, @sk_color4f_t(AColor), TSkBindings.SafeHandle(AColorSpace), @sk_irect_t(ASubset)); -end; - -function TSkPixmap.Erase(const AColor: TAlphaColor): Boolean; -begin - Result := sk4d_pixmap_erase(Handle, AColor, nil); -end; - -function TSkPixmap.Erase(const AColor: TAlphaColorF; - AColorSpace: ISkColorSpace): Boolean; -begin - Result := sk4d_pixmap_erase2(Handle, @sk_color4f_t(AColor), TSkBindings.SafeHandle(AColorSpace), nil); -end; - -function TSkPixmap.Erase(const AColor: TAlphaColor; - const ASubset: TRectF): Boolean; -begin - Result := sk4d_pixmap_erase(Handle, AColor, @sk_irect_t(ASubset)); -end; - -function TSkPixmap.ExtractSubset(const ADest: ISkPixmap; - const AArea: TRect): Boolean; -begin - if not Assigned(ADest) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ADest']); - Result := sk4d_pixmap_extract_subset(Handle, ADest.Handle, @sk_irect_t(AArea)); -end; - -function TSkPixmap.GetAlpha(const AX, AY: Integer): Single; -begin - Result := sk4d_pixmap_get_alpha(Handle, AX, AY); -end; - -function TSkPixmap.GetAlphaType: TSkAlphaType; -begin - Result := TSkAlphaType(sk4d_pixmap_get_alpha_type(Handle)); -end; - -function TSkPixmap.GetColor(const AX, AY: Integer): TAlphaColor; -begin - Result := sk4d_pixmap_get_color(Handle, AX, AY); -end; - -function TSkPixmap.GetColorF(const AX, AY: Integer): TAlphaColorF; -begin - sk4d_pixmap_get_colorf(Handle, AX, AY, sk_color4f_t(Result)); -end; - -function TSkPixmap.GetColorSpace: ISkColorSpace; -begin - Result := TSkBindings.SafeCreate(sk4d_pixmap_get_color_space(Handle)); -end; - -function TSkPixmap.GetColorType: TSkColorType; -begin - Result := TSkColorType(sk4d_pixmap_get_color_type(Handle)); -end; - -function TSkPixmap.GetHeight: Integer; -begin - Result := sk4d_pixmap_get_height(Handle); -end; - -function TSkPixmap.GetImageInfo: TSkImageInfo; -var - LResult: sk_imageinfo_t; -begin - sk4d_pixmap_get_image_info(Handle, LResult); - Result := TSkBindings.ToImageInfo(LResult); -end; - -function TSkPixmap.GetPixelAddr(const AX, AY: Integer): Pointer; -begin - Result := sk4d_pixmap_get_pixel_addr(Handle, AX, AY); -end; - -function TSkPixmap.GetPixels: Pointer; -begin - Result := sk4d_pixmap_get_pixels(Handle); -end; - -function TSkPixmap.GetRowBytes: NativeUInt; -begin - Result := sk4d_pixmap_get_row_bytes(Handle); -end; - -function TSkPixmap.GetWidth: Integer; -begin - Result := sk4d_pixmap_get_width(Handle); -end; - -function TSkPixmap.ReadPixels(const ADest: ISkPixmap; const ASrcX, - ASrcY: Integer): Boolean; -begin - if not Assigned(ADest) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ADest']); - Result := sk4d_pixmap_read_pixels(Handle, ADest.Handle, ASrcX, ASrcY); -end; - -function TSkPixmap.ReadPixels(const ADestImageInfo: TSkImageInfo; - const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASrcX, - ASrcY: Integer): Boolean; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ADestImageInfo, ADestPixels, ADestRowBytes); - Result := ReadPixels(LPixmap, ASrcX, ASrcY); -end; - -function TSkPixmap.ScalePixels(const ADestImageInfo: TSkImageInfo; - const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; - const ASampling: TSkSamplingOptions): Boolean; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ADestImageInfo, ADestPixels, ADestRowBytes); - Result := ScalePixels(LPixmap, ASampling); -end; - -function TSkPixmap.ScalePixels(const ADestImageInfo: TSkImageInfo; - const ADestPixels: Pointer; const ADestRowBytes: NativeUInt): Boolean; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ADestImageInfo, ADestPixels, ADestRowBytes); - Result := ScalePixels(LPixmap); -end; - -function TSkPixmap.ScalePixels(const ADest: ISkPixmap; - const ASampling: TSkSamplingOptions): Boolean; -begin - if not Assigned(ADest) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ADest']); - Result := sk4d_pixmap_scale_pixels(Handle, ADest.Handle, @sk_samplingoptions_t(ASampling)); -end; - -function TSkPixmap.ScalePixels(const ADest: ISkPixmap): Boolean; -begin - Result := ScalePixels(ADest, TSkSamplingOptions.Create(TSkFilterMode.Nearest, TSkMipmapMode.None)); -end; - -procedure TSkPixmap.SetColorSpace(AValue: ISkColorSpace); -begin - sk4d_pixmap_set_colorspace(Handle, TSkBindings.SafeHandle(AValue)); -end; - -class procedure TSkPixmap.__DestroyHandle(const AHandle: THandle); -begin - sk4d_pixmap_destroy(AHandle); -end; - -{ TSkRegion } - -function TSkRegion.Contains(const ARegion: ISkRegion): Boolean; -begin - if not Assigned(ARegion) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARegion']); - Result := sk4d_region_contains(Handle, ARegion.Handle); -end; - -function TSkRegion.Contains(const ARect: TRect): Boolean; -begin - Result := sk4d_region_contains2(Handle, @sk_irect_t(ARect)); -end; - -function TSkRegion.Contains(const AX, AY: Integer): Boolean; -begin - Result := sk4d_region_contains3(Handle, AX, AY); -end; - -constructor TSkRegion.Create(const ARect: TRect); -begin - Create; - SetRect(ARect); -end; - -constructor TSkRegion.Create(const ARegion: ISkRegion); -begin - if not Assigned(ARegion) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARegion']); - inherited Create(sk4d_region_create2(ARegion.Handle)); -end; - -constructor TSkRegion.Create; -begin - inherited Create(sk4d_region_create()); -end; - -function TSkRegion.GetBoundaryPath: ISkPath; -begin - Result := TSkBindings.SafeCreate(sk4d_region_get_boundary_path(Handle)); -end; - -function TSkRegion.GetBounds: TRect; -begin - sk4d_region_get_bounds(Handle, sk_irect_t(Result)); -end; - -function TSkRegion.GetCliperator(const AClip: TRect): ISkRegionCliperator; -begin - Result := TRegionCliperator.Create(Self, AClip); -end; - -function TSkRegion.GetIterator: ISkRegionIterator; -begin - Result := TRegionIterator.Create(Self); -end; - -function TSkRegion.GetSpanerator(const AY, ALeft, - ARight: Integer): ISkRegionSpanerator; -begin - Result := TRegionSpanerator.Create(Self, AY, ALeft, ARight); -end; - -function TSkRegion.Intersects(const ARect: TRect): Boolean; -begin - Result := sk4d_region_intersects2(Handle, @sk_irect_t(ARect)); -end; - -function TSkRegion.Intersects(const ARegion: ISkRegion): Boolean; -begin - if not Assigned(ARegion) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARegion']); - Result := sk4d_region_intersects(Handle, ARegion.Handle); -end; - -function TSkRegion.IsComplex: Boolean; -begin - Result := sk4d_region_is_complex(Handle); -end; - -function TSkRegion.IsEmpty: Boolean; -begin - Result := sk4d_region_is_empty(Handle); -end; - -function TSkRegion.IsEqual(const ARegion: ISkRegion): Boolean; -begin - if not Assigned(ARegion) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARegion']); - Result := sk4d_region_is_equal(Handle, ARegion.Handle); -end; - -function TSkRegion.IsRect: Boolean; -begin - Result := sk4d_region_is_rect(Handle); -end; - -function TSkRegion.Op(const ARegion: ISkRegion; - const AOp: TSkRegionOp): Boolean; -begin - if not Assigned(ARegion) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARegion']); - Result := sk4d_region_op(Handle, ARegion.Handle, sk_regionop_t(AOp)); -end; - -function TSkRegion.Op(const ARect: TRect; const AOp: TSkRegionOp): Boolean; -begin - Result := sk4d_region_op2(Handle, @sk_irect_t(ARect), sk_regionop_t(AOp)); -end; - -function TSkRegion.QuickContains(const ARect: TRect): Boolean; -begin - Result := sk4d_region_quick_contains(Handle, @sk_irect_t(ARect)); -end; - -function TSkRegion.QuickReject(const ARect: TRect): Boolean; -begin - Result := sk4d_region_quick_reject2(Handle, @sk_irect_t(ARect)); -end; - -function TSkRegion.QuickReject(const ARegion: ISkRegion): Boolean; -begin - if not Assigned(ARegion) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARegion']); - Result := sk4d_region_quick_reject(Handle, ARegion.Handle); -end; - -procedure TSkRegion.SetEmpty; -begin - sk4d_region_set_empty(Handle); -end; - -function TSkRegion.SetPath(const APath: ISkPath; - const AClip: ISkRegion): Boolean; -begin - if not Assigned(APath) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APath']); - if not Assigned(AClip) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AClip']); - Result := sk4d_region_set_path(Handle, APath.Handle, AClip.Handle); -end; - -function TSkRegion.SetRect(const ARect: TRect): Boolean; -begin - Result := sk4d_region_set_rect(Handle, @sk_irect_t(ARect)); -end; - -function TSkRegion.SetRects(const ARects: TArray): Boolean; -begin - if Length(ARects) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ARects']); - Result := sk4d_region_set_rects(Handle, @sk_rect_t(ARects[0]), Length(ARects)); -end; - -procedure TSkRegion.Translate(const ADeltaX, ADeltaY: Integer); -begin - sk4d_region_translate(Handle, ADeltaX, ADeltaY); -end; - -class procedure TSkRegion.__DestroyHandle(const AHandle: THandle); -begin - sk4d_region_destroy(AHandle); -end; - -{ TSkRegion.TRegionCliperator } - -constructor TSkRegion.TRegionCliperator.Create(const ARegion: ISkRegion; - const AClip: TRect); -begin - inherited Create(sk4d_regioncliperator_create(ARegion.Handle, @sk_irect_t(AClip))); -end; - -function TSkRegion.TRegionCliperator.GetCurrent: TRect; -begin - sk4d_regioncliperator_get_current(Handle, sk_irect_t(Result)); -end; - -function TSkRegion.TRegionCliperator.MoveNext: Boolean; -begin - Result := sk4d_regioncliperator_move_next(Handle); -end; - -class procedure TSkRegion.TRegionCliperator.__DestroyHandle( - const AHandle: THandle); -begin - sk4d_regioncliperator_destroy(AHandle); -end; - -{ TSkRegion.TRegionIterator } - -constructor TSkRegion.TRegionIterator.Create(const ARegion: ISkRegion); -begin - inherited Create(sk4d_regioniterator_create(ARegion.Handle)); -end; - -function TSkRegion.TRegionIterator.GetCurrent: TRect; -begin - sk4d_regioniterator_get_current(Handle, sk_irect_t(Result)); -end; - -function TSkRegion.TRegionIterator.MoveNext: Boolean; -begin - Result := sk4d_regioniterator_move_next(Handle); -end; - -class procedure TSkRegion.TRegionIterator.__DestroyHandle( - const AHandle: THandle); -begin - sk4d_regioniterator_destroy(AHandle); -end; - -{ TSkRegion.TRegionSpanerator } - -constructor TSkRegion.TRegionSpanerator.Create(const ARegion: ISkRegion; - const AY, ALeft, ARight: Integer); -begin - inherited Create(sk4d_regionspanerator_create(ARegion.Handle, AY, ALeft, ARight)); -end; - -function TSkRegion.TRegionSpanerator.GetCurrent: TPoint; -begin - Result := FCurrent; -end; - -function TSkRegion.TRegionSpanerator.MoveNext: Boolean; -begin - Result := sk4d_regionspanerator_next(Handle, sk_ipoint_t(FCurrent)); -end; - -class procedure TSkRegion.TRegionSpanerator.__DestroyHandle( - const AHandle: THandle); -begin - sk4d_regionspanerator_destroy(AHandle); -end; - -{ TSkRoundRect } - -function TSkRoundRect.Contains(const ARect: TRect): Boolean; -begin - Result := sk4d_rrect_contains(Handle, @sk_rect_t(ARect)); -end; - -constructor TSkRoundRect.Create(const ARect: TRectF; const ARadiusX, - ARadiusY: Single); -begin - Create; - SetRect(ARect, ARadiusX, ARadiusY); -end; - -constructor TSkRoundRect.Create(const ARoundRect: ISkRoundRect); -begin - if not Assigned(ARoundRect) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARoundRect']); - inherited Create(sk4d_rrect_create2(ARoundRect.Handle)); -end; - -constructor TSkRoundRect.Create; -begin - inherited Create(sk4d_rrect_create()); -end; - -constructor TSkRoundRect.Create(const ARect: TRectF; - const ARadii: TSkRoundRectRadii); -begin - Create; - SetRect(ARect, ARadii); -end; - -procedure TSkRoundRect.Deflate(const ADeltaX, ADeltaY: Single); -begin - sk4d_rrect_deflate(Handle, ADeltaX, ADeltaY); -end; - -function TSkRoundRect.GetHeight: Single; -begin - Result := sk4d_rrect_get_height(Handle); -end; - -function TSkRoundRect.GetRadii(const ACorner: TSkRoundRectCorner): TPointF; -begin - sk4d_rrect_get_radii(Handle, sk_rrectcorner_t(ACorner), sk_vector_t(Result)); -end; - -function TSkRoundRect.GetRect: TRectF; -begin - sk4d_rrect_get_rect(Handle, sk_rect_t(Result)); -end; - -function TSkRoundRect.GetSimpleRadii: TPointF; -begin - sk4d_rrect_get_simple_radii(Handle, sk_vector_t(Result)); -end; - -function TSkRoundRect.GetWidth: Single; -begin - Result := sk4d_rrect_get_width(Handle); -end; - -procedure TSkRoundRect.Inflate(const ADeltaX, ADeltaY: Single); -begin - sk4d_rrect_inflate(Handle, ADeltaX, ADeltaY); -end; - -function TSkRoundRect.IsComplex: Boolean; -begin - Result := sk4d_rrect_is_complex(Handle); -end; - -function TSkRoundRect.IsEmpty: Boolean; -begin - Result := sk4d_rrect_is_empty(Handle); -end; - -function TSkRoundRect.IsEqual(const ARoundRect: ISkRoundRect): Boolean; -begin - if not Assigned(ARoundRect) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARoundRect']); - Result := sk4d_rrect_is_equal(Handle, ARoundRect.Handle); -end; - -function TSkRoundRect.IsNinePatch: Boolean; -begin - Result := sk4d_rrect_is_nine_patch(Handle); -end; - -function TSkRoundRect.IsOval: Boolean; -begin - Result := sk4d_rrect_is_oval(Handle); -end; - -function TSkRoundRect.IsRect: Boolean; -begin - Result := sk4d_rrect_is_rect(Handle); -end; - -function TSkRoundRect.IsSimple: Boolean; -begin - Result := sk4d_rrect_is_simple(Handle); -end; - -function TSkRoundRect.IsValid: Boolean; -begin - Result := sk4d_rrect_is_valid(Handle); -end; - -procedure TSkRoundRect.Offset(const ADeltaX, ADeltaY: Single); -begin - sk4d_rrect_offset(Handle, ADeltaX, ADeltaY); -end; - -procedure TSkRoundRect.SetEmpty; -begin - sk4d_rrect_set_empty(Handle); -end; - -procedure TSkRoundRect.SetNinePatch(const ARect: TRectF; const ARadiusLeft, - ARadiusTop, ARadiusRight, ARadiusBottom: Single); -begin - sk4d_rrect_set_nine_patch(Handle, @sk_rect_t(ARect), ARadiusLeft, ARadiusTop, ARadiusRight, ARadiusBottom); -end; - -procedure TSkRoundRect.SetOval(const ARect: TRectF); -begin - sk4d_rrect_set_oval(Handle, @sk_rect_t(ARect)); -end; - -procedure TSkRoundRect.SetRect(const ARect: TRectF; - const ARadii: TSkRoundRectRadii); -begin - sk4d_rrect_set_rect2(Handle, @sk_rect_t(ARect), @ARadii); -end; - -procedure TSkRoundRect.SetRect(const ARect: TRectF; const ARadiusX, - ARadiusY: Single); -begin - sk4d_rrect_set_rect3(Handle, @sk_rect_t(ARect), ARadiusX, ARadiusY); -end; - -procedure TSkRoundRect.SetRect(const ARect: TRectF); -begin - sk4d_rrect_set_rect(Handle, @sk_rect_t(ARect)); -end; - -function TSkRoundRect.Transform(const AMatrix: TMatrix): ISkRoundRect; -begin - Result := TSkBindings.SafeCreate(sk4d_rrect_transform(Handle, @sk_matrix_t(AMatrix))); -end; - -class procedure TSkRoundRect.__DestroyHandle(const AHandle: THandle); -begin - sk4d_rrect_destroy(AHandle); -end; - -{ TSkRuntimeEffect } - -procedure TSkRuntimeEffect.AfterConstruction; -begin - SetLength(FChildren, GetChildCount); - FUniformData := AllocMem(GetUniformDataSize); - inherited; -end; - -procedure TSkRuntimeEffect.BeforeDestruction; -begin - inherited; - FreeMem(FUniformData); -end; - -function TSkRuntimeEffect.ChildExists(const AName: string): Boolean; -begin - Result := IndexOfChild(AName) >= 0; -end; - -function TSkRuntimeEffect.GetChildBlender(const AIndex: Integer): ISkBlender; -begin - if GetChildType(AIndex) <> TSkRuntimeEffectChildType.Blender then - raise ESkException.Create(SInvalidOperation); - Result := FChildren[AIndex] as ISkBlender; -end; - -function TSkRuntimeEffect.GetChildBlenderByName( - const AName: string): ISkBlender; -begin - Result := GetChildBlender(IndexOfChild(AName)); -end; - -function TSkRuntimeEffect.GetChildColorFilter( - const AIndex: Integer): ISkColorFilter; -begin - if GetChildType(AIndex) <> TSkRuntimeEffectChildType.ColorFilter then - raise ESkException.Create(SInvalidOperation); - Result := FChildren[AIndex] as ISkColorFilter; -end; - -function TSkRuntimeEffect.GetChildColorFilterByName( - const AName: string): ISkColorFilter; -begin - Result := GetChildColorFilter(IndexOfChild(AName)); -end; - -function TSkRuntimeEffect.GetChildCount: Integer; -begin - Result := sk4d_runtimeeffect_get_child_count(Handle); -end; - -function TSkRuntimeEffect.GetChildName(const AIndex: Integer): string; -begin - if (AIndex < 0) or (AIndex >= GetChildCount) then - raise ESkArgumentException.CreateFmt(SParamOutOfRange, ['AIndex', AIndex, 0, GetChildCount]); - Result := string(sk4d_runtimeeffect_get_child_name(Handle, AIndex)); -end; - -function TSkRuntimeEffect.GetChildShader(const AIndex: Integer): ISkShader; -begin - if GetChildType(AIndex) <> TSkRuntimeEffectChildType.Shader then - raise ESkException.Create(SInvalidOperation); - Result := FChildren[AIndex] as ISkShader; -end; - -function TSkRuntimeEffect.GetChildShaderByName(const AName: string): ISkShader; -begin - Result := GetChildShader(IndexOfChild(AName)); -end; - -function TSkRuntimeEffect.GetChildType( - const AIndex: Integer): TSkRuntimeEffectChildType; -begin - if (AIndex < 0) or (AIndex >= GetChildCount) then - raise ESkArgumentException.CreateFmt(SParamOutOfRange, ['AIndex', AIndex, 0, GetChildCount]); - Result := TSkRuntimeEffectChildType(sk4d_runtimeeffect_get_child_type(Handle, AIndex)); -end; - -function TSkRuntimeEffect.GetChildTypeByName( - const AName: string): TSkRuntimeEffectChildType; -begin - Result := GetChildType(IndexOfChild(AName)); -end; - -function TSkRuntimeEffect.GetUniform(const AIndex: Integer): Pointer; -begin - if (AIndex < 0) or (AIndex >= GetUniformCount) then - raise ESkArgumentException.CreateFmt(SParamOutOfRange, ['AIndex', AIndex, 0, GetUniformCount]); - Result := Pointer(NativeUInt(FUniformData) + GetUniformOffset(AIndex)); -end; - -function TSkRuntimeEffect.GetUniformByName(const AName: string): Pointer; -begin - Result := GetUniform(IndexOfUniform(AName)); -end; - -function TSkRuntimeEffect.GetUniformCount: Integer; -begin - Result := sk4d_runtimeeffect_get_uniform_count(Handle); -end; - -function TSkRuntimeEffect.GetUniformData: Pointer; -begin - Result := FUniformData; -end; - -function TSkRuntimeEffect.GetUniformDataSize: NativeUInt; -begin - Result := sk4d_runtimeeffect_get_uniform_data_size(Handle); -end; - -function TSkRuntimeEffect.GetUniformName(const AIndex: Integer): string; -begin - if (AIndex < 0) or (AIndex >= GetUniformCount) then - raise ESkArgumentException.CreateFmt(SParamOutOfRange, ['AIndex', AIndex, 0, GetUniformCount]); - Result := string(sk4d_runtimeeffect_get_uniform_name(Handle, AIndex)); -end; - -function TSkRuntimeEffect.GetUniformOffset(const AIndex: Integer): NativeUInt; -begin - if (AIndex < 0) or (AIndex >= GetUniformCount) then - raise ESkArgumentException.CreateFmt(SParamOutOfRange, ['AIndex', AIndex, 0, GetUniformCount]); - Result := sk4d_runtimeeffect_get_uniform_offset(Handle, AIndex); -end; - -function TSkRuntimeEffect.GetUniformOffsetByName( - const AName: string): NativeUInt; -begin - Result := GetUniformOffset(IndexOfUniform(AName)); -end; - -function TSkRuntimeEffect.GetUniformType( - const AIndex: Integer): TSkRuntimeEffectUniformType; -begin - if (AIndex < 0) or (AIndex >= GetUniformCount) then - raise ESkArgumentException.CreateFmt(SParamOutOfRange, ['AIndex', AIndex, 0, GetUniformCount]); - Result := TSkRuntimeEffectUniformType(sk4d_runtimeeffect_get_uniform_type(Handle, AIndex)); -end; - -function TSkRuntimeEffect.GetUniformTypeByName( - const AName: string): TSkRuntimeEffectUniformType; -begin - Result := GetUniformType(IndexOfUniform(AName)); -end; - -function TSkRuntimeEffect.GetUniformTypeCount(const AIndex: Integer): Integer; -begin - if (AIndex < 0) or (AIndex >= GetUniformCount) then - raise ESkArgumentException.CreateFmt(SParamOutOfRange, ['AIndex', AIndex, 0, GetUniformCount]); - Result := sk4d_runtimeeffect_get_uniform_type_count(Handle, AIndex); -end; - -function TSkRuntimeEffect.GetUniformTypeCountByName( - const AName: string): Integer; -begin - Result := GetUniformTypeCount(IndexOfUniform(AName)); -end; - -function TSkRuntimeEffect.IndexOfChild(const AName: string): Integer; -var - LMarshaller: TMarshaller; -begin - Result := sk4d_runtimeeffect_index_of_child(Handle, LMarshaller.AsUtf8(AName).ToPointer); -end; - -function TSkRuntimeEffect.IndexOfUniform(const AName: string): Integer; -var - LMarshaller: TMarshaller; -begin - Result := sk4d_runtimeeffect_index_of_uniform(Handle, LMarshaller.AsUtf8(AName).ToPointer); -end; - -function TSkRuntimeEffect.IsUniformTypeOrdinal(const AIndex: Integer): Boolean; -begin - Result := (GetUniformType(AIndex) in [TSkRuntimeEffectUniformType.Int, TSkRuntimeEffectUniformType.Int2, TSkRuntimeEffectUniformType.Int3, TSkRuntimeEffectUniformType.Int4]); -end; - -function TSkRuntimeEffect.IsUniformTypeOrdinalByName( - const AName: string): Boolean; -begin - Result := IsUniformTypeOrdinal(IndexOfUniform(AName)); -end; - -function TSkRuntimeEffect.MakeBlender: ISkBlender; -var - I: Integer; - LChildren: Pointer; - LHandles: TArray; -begin - if Length(FChildren) > 0 then - begin - SetLength(LHandles, Length(FChildren)); - for I := 0 to Length(FChildren) - 1 do - LHandles[I] := TSkBindings.SafeHandle(FChildren[I]); - LChildren := @LHandles[0]; - end - else - LChildren := nil; - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_blender(Handle, GetUniformData, LChildren)); -end; - -function TSkRuntimeEffect.MakeColorFilter: ISkColorFilter; -var - I: Integer; - LChildren: Pointer; - LHandles: TArray; -begin - if Length(FChildren) > 0 then - begin - SetLength(LHandles, Length(FChildren)); - for I := 0 to Length(FChildren) - 1 do - LHandles[I] := TSkBindings.SafeHandle(FChildren[I]); - LChildren := @LHandles[0]; - end - else - LChildren := nil; - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_color_filter(Handle, GetUniformData, LChildren)); -end; - -class function TSkRuntimeEffect.MakeForBlender(const ASkSL: string; - out AErrorText: string): ISkRuntimeEffect; -var - LErrorText: ISkString; - LMarshaller: TMarshaller; -begin - if ASKSL.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ASKSL']); - LErrorText := TSkString.Create; - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_for_blender(LMarshaller.AsUtf8(ASkSL).ToPointer, LErrorText.Handle)); - AErrorText := LErrorText.Text; -end; - -class function TSkRuntimeEffect.MakeForBlender( - const ASkSL: string): ISkRuntimeEffect; -var - LMarshaller: TMarshaller; -begin - if ASKSL.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ASKSL']); - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_for_blender(LMarshaller.AsUtf8(ASkSL).ToPointer, 0)); -end; - -class function TSkRuntimeEffect.MakeForColorFilter( - const ASkSL: string): ISkRuntimeEffect; -var - LMarshaller: TMarshaller; -begin - if ASKSL.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ASKSL']); - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_for_color_filter(LMarshaller.AsUtf8(ASkSL).ToPointer, 0)); -end; - -class function TSkRuntimeEffect.MakeForColorFilter(const ASkSL: string; - out AErrorText: string): ISkRuntimeEffect; -var - LErrorText: ISkString; - LMarshaller: TMarshaller; -begin - if ASKSL.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ASKSL']); - LErrorText := TSkString.Create; - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_for_color_filter(LMarshaller.AsUtf8(ASkSL).ToPointer, LErrorText.Handle)); - AErrorText := LErrorText.Text; -end; - -class function TSkRuntimeEffect.MakeForShader(const ASkSL: string; - out AErrorText: string): ISkRuntimeEffect; -var - LErrorText: ISkString; - LMarshaller: TMarshaller; -begin - if ASKSL.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ASKSL']); - LErrorText := TSkString.Create; - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_for_shader(LMarshaller.AsUtf8(ASkSL).ToPointer, LErrorText.Handle)); - AErrorText := LErrorText.Text; -end; - -class function TSkRuntimeEffect.MakeForShader( - const ASkSL: string): ISkRuntimeEffect; -var - LMarshaller: TMarshaller; -begin - if ASKSL.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['ASKSL']); - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_for_shader(LMarshaller.AsUtf8(ASkSL).ToPointer, 0)); -end; - -function TSkRuntimeEffect.MakeImage(const AImageInfo: TSkImageInfo; - const AMipmapped: Boolean; const AContext: IGrDirectContext): ISkImage; -var - I: Integer; - LChildren: Pointer; - LHandles: TArray; - LImageInfo: sk_imageinfo_t; -begin - if Length(FChildren) > 0 then - begin - SetLength(LHandles, Length(FChildren)); - for I := 0 to Length(FChildren) - 1 do - LHandles[I] := TSkBindings.SafeHandle(FChildren[I]); - LChildren := @LHandles[0]; - end - else - LChildren := nil; - LImageInfo := TSkBindings.AsImageInfo(AImageInfo); - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_image(Handle, TSkBindings.SafeHandle(AContext), GetUniformData, LChildren, nil, @LImageInfo, AMipmapped)); -end; - -function TSkRuntimeEffect.MakeImage(const AImageInfo: TSkImageInfo; - const ALocalMatrix: TMatrix; const AMipmapped: Boolean; - const AContext: IGrDirectContext): ISkImage; -var - I: Integer; - LChildren: Pointer; - LHandles: TArray; - LImageInfo: sk_imageinfo_t; -begin - if Length(FChildren) > 0 then - begin - SetLength(LHandles, Length(FChildren)); - for I := 0 to Length(FChildren) - 1 do - LHandles[I] := TSkBindings.SafeHandle(FChildren[I]); - LChildren := @LHandles[0]; - end - else - LChildren := nil; - LImageInfo := TSkBindings.AsImageInfo(AImageInfo); - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_image(Handle, TSkBindings.SafeHandle(AContext), GetUniformData, LChildren, @sk_matrix_t(ALocalMatrix), @LImageInfo, AMipmapped)); -end; - -function TSkRuntimeEffect.MakeShader(const ALocalMatrix: TMatrix): ISkShader; -var - I: Integer; - LChildren: Pointer; - LHandles: TArray; -begin - if Length(FChildren) > 0 then - begin - SetLength(LHandles, Length(FChildren)); - for I := 0 to Length(FChildren) - 1 do - LHandles[I] := TSkBindings.SafeHandle(FChildren[I]); - LChildren := @LHandles[0]; - end - else - LChildren := nil; - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_shader(Handle, GetUniformData, LChildren, @sk_matrix_t(ALocalMatrix))); -end; - -function TSkRuntimeEffect.MakeShader: ISkShader; -var - I: Integer; - LChildren: Pointer; - LHandles: TArray; -begin - if Length(FChildren) > 0 then - begin - SetLength(LHandles, Length(FChildren)); - for I := 0 to Length(FChildren) - 1 do - LHandles[I] := TSkBindings.SafeHandle(FChildren[I]); - LChildren := @LHandles[0]; - end - else - LChildren := nil; - Result := TSkBindings.SafeCreate(sk4d_runtimeeffect_make_shader(Handle, GetUniformData, LChildren, nil)); -end; - -procedure TSkRuntimeEffect.SetChildBlender(const AIndex: Integer; - const AValue: ISkBlender); -begin - if GetChildType(AIndex) <> TSkRuntimeEffectChildType.Blender then - raise ESkException.Create(SInvalidOperation); - FChildren[AIndex] := AValue; -end; - -procedure TSkRuntimeEffect.SetChildBlenderByName(const AName: string; - const AValue: ISkBlender); -begin - SetChildBlender(IndexOfChild(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetChildColorFilter(const AIndex: Integer; - const AValue: ISkColorFilter); -begin - if GetChildType(AIndex) <> TSkRuntimeEffectChildType.ColorFilter then - raise ESkException.Create(SInvalidOperation); - FChildren[AIndex] := AValue; -end; - -procedure TSkRuntimeEffect.SetChildColorFilterByName(const AName: string; - const AValue: ISkColorFilter); -begin - SetChildColorFilter(IndexOfChild(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetChildShader(const AIndex: Integer; - const AValue: ISkShader); -begin - if GetChildType(AIndex) <> TSkRuntimeEffectChildType.Shader then - raise ESkException.Create(SInvalidOperation); - FChildren[AIndex] := AValue; -end; - -procedure TSkRuntimeEffect.SetChildShaderByName(const AName: string; - const AValue: ISkShader); -begin - SetChildShader(IndexOfChild(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TPoint); -var - LValue: TSkRuntimeEffectFloat2; -begin - if not IsUniformTypeOrdinal(AIndex) then - begin - LValue := TSkRuntimeEffectFloat2.Create(AValue.X, AValue.Y); - SetUniform(AIndex, LValue); - end - else - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TSkRuntimeEffectInt2); -var - LValue: TSkRuntimeEffectFloat2; -begin - if not IsUniformTypeOrdinal(AIndex) then - begin - LValue := TSkRuntimeEffectFloat2.Create(AValue.V1, AValue.V2); - SetUniform(AIndex, LValue); - end - else - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TSkRuntimeEffectInt3); -var - LValue: TSkRuntimeEffectFloat3; -begin - if not IsUniformTypeOrdinal(AIndex) then - begin - LValue := TSkRuntimeEffectFloat3.Create(AValue.V1, AValue.V2, AValue.V3); - SetUniform(AIndex, LValue); - end - else - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; const AData; - const ASize: NativeUInt); -const - UniformCount: array[TSkRuntimeEffectUniformType] of Integer = (1, 2, 3, 4, 4, 9, 16, 1, 2, 3, 4); -var - LSize: NativeUInt; -begin - if IsUniformTypeOrdinal(AIndex) then - LSize := UniformCount[GetUniformType(AIndex)] * GetUniformTypeCount(AIndex) * SizeOf(Integer) - else - LSize := UniformCount[GetUniformType(AIndex)] * GetUniformTypeCount(AIndex) * SizeOf(Single); - if ASize <> LSize then - raise ESkException.Create(SInvalidOperation); - WriteUniform(GetUniformOffset(AIndex), AData, ASize); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex, AValue: Integer); -var - LValue: Single; -begin - if not IsUniformTypeOrdinal(AIndex) then - begin - LValue := AValue; - SetUniform(AIndex, LValue); - end - else - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TArray); -var - I: Integer; - LValue: TArray; -begin - if Length(AValue) = 0 then - raise ESkException.Create(SInvalidOperation); - if not IsUniformTypeOrdinal(AIndex) then - begin - SetLength(LValue, Length(AValue)); - for I := 0 to Length(AValue) - 1 do - LValue[I] := AValue[I]; - SetUniform(AIndex, LValue); - end - else - SetUniform(AIndex, AValue[0], Length(AValue) * SizeOf(Integer)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TSkRuntimeEffectInt4); -var - LValue: TSkRuntimeEffectFloat4; -begin - if not IsUniformTypeOrdinal(AIndex) then - begin - LValue := TSkRuntimeEffectFloat4.Create(AValue.V1, AValue.V2, AValue.V3, AValue.V4); - SetUniform(AIndex, LValue); - end - else - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: Single); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TArray); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TPointF); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TSkRuntimeEffectInt2); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TSkRuntimeEffectInt3); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TSkRuntimeEffectInt4); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TAlphaColorF); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TSkRuntimeEffectFloat2x2); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TSkRuntimeEffectFloat3x3); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TSkRuntimeEffectFloat4x4); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TSkRuntimeEffectFloat2); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TSkRuntimeEffectFloat3); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TSkRuntimeEffectFloat4); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TPoint); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TAlphaColorF); -begin - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TSkRuntimeEffectFloat2); -begin - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TSkRuntimeEffectFloat3); -begin - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: Single); -begin - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TArray); -begin - if Length(AValue) = 0 then - raise ESkException.Create(SInvalidOperation); - SetUniform(AIndex, AValue[0], Length(AValue) * SizeOf(Single)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TPointF); -begin - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TSkRuntimeEffectFloat4); -begin - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; const AData; - const ASize: NativeUInt); -begin - SetUniform(IndexOfUniform(AName), AData, ASize); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: Integer); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AName: string; - const AValue: TArray); -begin - SetUniform(IndexOfUniform(AName), AValue); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TSkRuntimeEffectFloat4x4); -begin - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TSkRuntimeEffectFloat3x3); -begin - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -procedure TSkRuntimeEffect.SetUniform(const AIndex: Integer; - const AValue: TSkRuntimeEffectFloat2x2); -begin - SetUniform(AIndex, AValue, SizeOf(AValue)); -end; - -function TSkRuntimeEffect.UniformExists(const AName: string): Boolean; -begin - Result := IndexOfUniform(AName) >= 0; -end; - -procedure TSkRuntimeEffect.WriteUniform(const AOffset: NativeUInt; const AData; - const ASize: NativeUInt); -begin - if (AOffset + ASize) > GetUniformDataSize then - raise ESkException.Create(SOutOfMemory); - Move(AData, Pointer(NativeUInt(FUniformData) + AOffset)^, ASize); -end; - -{ TSkShader } - -class function TSkShader.MakeBlend(const AMode: TSkBlendMode; const ADest, - ASrc: ISkShader): ISkShader; -begin - if not Assigned(ADest) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ADest']); - if not Assigned(ASrc) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ASrc']); - Result := TSkBindings.SafeCreate(sk4d_shader_make_blend(sk_blendmode_t(AMode), ADest.Handle, ASrc.Handle)); -end; - -class function TSkShader.MakeColor(const AColor: TAlphaColor): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_shader_make_color(AColor)); -end; - -class function TSkShader.MakeColor(const AColor: TAlphaColorF; - AColorSpace: ISkColorSpace): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_shader_make_color2(@sk_color4f_t(AColor), TSkBindings.SafeHandle(AColorSpace))); -end; - -class function TSkShader.MakeGradientLinear(const AStart, AEnd: TPointF; - const AColor1, AColor2: TAlphaColorF; const ATileMode: TSkTileMode; - AColorSpace: ISkColorSpace): ISkShader; -begin - Result := MakeGradientLinear(AStart, AEnd, [AColor1, AColor2], nil, ATileMode, AColorSpace); -end; - -class function TSkShader.MakeGradientLinear(const AStart, AEnd: TPointF; - const AColor1, AColor2: TAlphaColorF; const ALocalMatrix: TMatrix; - const ATileMode: TSkTileMode; AColorSpace: ISkColorSpace): ISkShader; -begin - Result := MakeGradientLinear(AStart, AEnd, [AColor1, AColor2], ALocalMatrix, nil, ATileMode, AColorSpace); -end; - -class function TSkShader.MakeGradientLinear(const AStart, AEnd: TPointF; - const AColor1, AColor2: TAlphaColor; const ALocalMatrix: TMatrix; - const ATileMode: TSkTileMode): ISkShader; -begin - Result := MakeGradientLinear(AStart, AEnd, [AColor1, AColor2], ALocalMatrix, nil, ATileMode); -end; - -class function TSkShader.MakeGradientLinear(const AStart, AEnd: TPointF; - const AColor1, AColor2: TAlphaColor; const ATileMode: TSkTileMode): ISkShader; -begin - Result := MakeGradientLinear(AStart, AEnd, [AColor1, AColor2], nil, ATileMode); -end; - -class function TSkShader.MakeGradientLinear(const AStart, AEnd: TPointF; - const AColors: TArray; const APositions: TArray; - const ATileMode: TSkTileMode): ISkShader; -var - LPoints: array[0..1] of sk_point_t; - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - LPoints[0] := sk_point_t(AStart); - LPoints[1] := sk_point_t(AEnd); - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_linear(@LPoints[0], @AColors[0], LPositions, Length(AColors), sk_tilemode_t(ATileMode), nil)); -end; - -class function TSkShader.MakeGradientLinear(const AStart, AEnd: TPointF; - const AColors: TArray; const ALocalMatrix: TMatrix; - const APositions: TArray; const ATileMode: TSkTileMode; - AColorSpace: ISkColorSpace): ISkShader; -var - LPoints: array[0..1] of sk_point_t; - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - LPoints[0] := sk_point_t(AStart); - LPoints[1] := sk_point_t(AEnd); - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_linear2(@LPoints[0], @sk_color4f_t(AColors[0]), TSkBindings.SafeHandle(AColorSpace), LPositions, Length(AColors), sk_tilemode_t(ATileMode), @sk_matrix_t(ALocalMatrix))); -end; - -class function TSkShader.MakeGradientLinear(const AStart, AEnd: TPointF; - const AColors: TArray; const APositions: TArray; - const ATileMode: TSkTileMode; AColorSpace: ISkColorSpace): ISkShader; -var - LPoints: array[0..1] of sk_point_t; - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - LPoints[0] := sk_point_t(AStart); - LPoints[1] := sk_point_t(AEnd); - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_linear2(@LPoints[0], @sk_color4f_t(AColors[0]), TSkBindings.SafeHandle(AColorSpace), LPositions, Length(AColors), sk_tilemode_t(ATileMode), nil)); -end; - -class function TSkShader.MakeGradientLinear(const AStart, AEnd: TPointF; - const AColors: TArray; const ALocalMatrix: TMatrix; - const APositions: TArray; const ATileMode: TSkTileMode): ISkShader; -var - LPoints: array[0..1] of sk_point_t; - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - LPoints[0] := sk_point_t(AStart); - LPoints[1] := sk_point_t(AEnd); - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_linear(@LPoints[0], @AColors[0], LPositions, Length(AColors), sk_tilemode_t(ATileMode), @sk_matrix_t(ALocalMatrix))); -end; - -class function TSkShader.MakeGradientRadial(const ACenter: TPointF; - const ARadius: Single; const ACenterColor, AEdgeColor: TAlphaColorF; - const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode; - AColorSpace: ISkColorSpace): ISkShader; -begin - Result := MakeGradientRadial(ACenter, ARadius, [ACenterColor, AEdgeColor], ALocalMatrix, nil, ATileMode, AColorSpace); -end; - -class function TSkShader.MakeGradientRadial(const ACenter: TPointF; - const ARadius: Single; const AColors: TArray; - const APositions: TArray; const ATileMode: TSkTileMode): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_radial(@sk_point_t(ACenter), ARadius, @AColors[0], LPositions, Length(AColors), sk_tilemode_t(ATileMode), nil)); -end; - -class function TSkShader.MakeGradientRadial(const ACenter: TPointF; - const ARadius: Single; const ACenterColor, AEdgeColor: TAlphaColorF; - const ATileMode: TSkTileMode; AColorSpace: ISkColorSpace): ISkShader; -begin - Result := MakeGradientRadial(ACenter, ARadius, [ACenterColor, AEdgeColor], nil, ATileMode, AColorSpace); -end; - -class function TSkShader.MakeGradientRadial(const ACenter: TPointF; - const ARadius: Single; const ACenterColor, AEdgeColor: TAlphaColor; - const ALocalMatrix: TMatrix; const ATileMode: TSkTileMode): ISkShader; -begin - Result := MakeGradientRadial(ACenter, ARadius, [ACenterColor, AEdgeColor], ALocalMatrix, nil, ATileMode); -end; - -class function TSkShader.MakeGradientRadial(const ACenter: TPointF; - const ARadius: Single; const ACenterColor, AEdgeColor: TAlphaColor; - const ATileMode: TSkTileMode): ISkShader; -begin - Result := MakeGradientRadial(ACenter, ARadius, [ACenterColor, AEdgeColor], nil, ATileMode); -end; - -class function TSkShader.MakeGradientRadial(const ACenter: TPointF; - const ARadius: Single; const AColors: TArray; - const ALocalMatrix: TMatrix; const APositions: TArray; - const ATileMode: TSkTileMode): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_radial(@sk_point_t(ACenter), ARadius, @AColors[0], LPositions, Length(AColors), sk_tilemode_t(ATileMode), @sk_matrix_t(ALocalMatrix))); -end; - -class function TSkShader.MakeGradientRadial(const ACenter: TPointF; - const ARadius: Single; const AColors: TArray; - const ALocalMatrix: TMatrix; const APositions: TArray; - const ATileMode: TSkTileMode; AColorSpace: ISkColorSpace): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_radial2(@sk_point_t(ACenter), ARadius, @sk_color4f_t(AColors[0]), TSkBindings.SafeHandle(AColorSpace), LPositions, Length(AColors), sk_tilemode_t(ATileMode), @sk_matrix_t(ALocalMatrix))); -end; - -class function TSkShader.MakeGradientRadial(const ACenter: TPointF; - const ARadius: Single; const AColors: TArray; - const APositions: TArray; const ATileMode: TSkTileMode; - AColorSpace: ISkColorSpace): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_radial2(@sk_point_t(ACenter), ARadius, @sk_color4f_t(AColors[0]), TSkBindings.SafeHandle(AColorSpace), LPositions, Length(AColors), sk_tilemode_t(ATileMode), nil)); -end; - -class function TSkShader.MakeGradientSweep(const ACenter: TPointF; - const AColors: TArray; const ALocalMatrix: TMatrix; - const APositions: TArray; const ATileMode: TSkTileMode; - const AStartAngle, AEndAngle: Single; AColorSpace: ISkColorSpace): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_sweep2(ACenter.X, ACenter.Y, @sk_color4f_t(AColors[0]), TSkBindings.SafeHandle(AColorSpace), LPositions, Length(AColors), sk_tilemode_t(ATileMode), AStartAngle, AEndAngle, @sk_matrix_t(ALocalMatrix))); -end; - -class function TSkShader.MakeGradientSweep(const ACenter: TPointF; - const AColors: TArray; const APositions: TArray; - const ATileMode: TSkTileMode; const AStartAngle, AEndAngle: Single; - AColorSpace: ISkColorSpace): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_sweep2(ACenter.X, ACenter.Y, @sk_color4f_t(AColors[0]), TSkBindings.SafeHandle(AColorSpace), LPositions, Length(AColors), sk_tilemode_t(ATileMode), AStartAngle, AEndAngle, nil)); -end; - -class function TSkShader.MakeGradientSweep(const ACenter: TPointF; - const AColor1, AColor2: TAlphaColor; const ALocalMatrix: TMatrix; - const ATileMode: TSkTileMode; const AStartAngle, - AEndAngle: Single): ISkShader; -begin - Result := MakeGradientSweep(ACenter, [AColor1, AColor2], ALocalMatrix, nil, ATileMode, AStartAngle, AEndAngle); -end; - -class function TSkShader.MakeGradientSweep(const ACenter: TPointF; - const AColor1, AColor2: TAlphaColor; const ATileMode: TSkTileMode; - const AStartAngle, AEndAngle: Single): ISkShader; -begin - Result := MakeGradientSweep(ACenter, [AColor1, AColor2], nil, ATileMode, AStartAngle, AEndAngle); -end; - -class function TSkShader.MakeGradientSweep(const ACenter: TPointF; - const AColors: TArray; const APositions: TArray; - const ATileMode: TSkTileMode; const AStartAngle, - AEndAngle: Single): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_sweep(ACenter.X, ACenter.Y, @AColors[0], LPositions, Length(AColors), sk_tilemode_t(ATileMode), AStartAngle, AEndAngle, nil)); -end; - -class function TSkShader.MakeGradientSweep(const ACenter: TPointF; - const AColors: TArray; const ALocalMatrix: TMatrix; - const APositions: TArray; const ATileMode: TSkTileMode; - const AStartAngle, AEndAngle: Single): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_sweep(ACenter.X, ACenter.Y, @AColors[0], LPositions, Length(AColors), sk_tilemode_t(ATileMode), AStartAngle, AEndAngle, @sk_matrix_t(ALocalMatrix))); -end; - -class function TSkShader.MakeGradientSweep(const ACenter: TPointF; - const AColor1, AColor2: TAlphaColorF; const ALocalMatrix: TMatrix; - const ATileMode: TSkTileMode; const AStartAngle, AEndAngle: Single; - AColorSpace: ISkColorSpace): ISkShader; -begin - Result := MakeGradientSweep(ACenter, [AColor1, AColor2], ALocalMatrix, nil, ATileMode, AStartAngle, AEndAngle, AColorSpace); -end; - -class function TSkShader.MakeGradientSweep(const ACenter: TPointF; - const AColor1, AColor2: TAlphaColorF; const ATileMode: TSkTileMode; - const AStartAngle, AEndAngle: Single; AColorSpace: ISkColorSpace): ISkShader; -begin - Result := MakeGradientSweep(ACenter, [AColor1, AColor2], nil, ATileMode, AStartAngle, AEndAngle, AColorSpace); -end; - -class function TSkShader.MakeGradientTwoPointConical(const AStart: TPointF; - const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; - const AColors: TArray; const APositions: TArray; - const ATileMode: TSkTileMode): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_two_point_conical(@sk_point_t(AStart), AStartRadius, @sk_point_t(AEnd), AEndRadius, @AColors[0], LPositions, Length(AColors), sk_tilemode_t(ATileMode), nil)); -end; - -class function TSkShader.MakeGradientTwoPointConical(const AStart: TPointF; - const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; - const AColors: TArray; const ALocalMatrix: TMatrix; - const APositions: TArray; const ATileMode: TSkTileMode): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_two_point_conical(@sk_point_t(AStart), AStartRadius, @sk_point_t(AEnd), AEndRadius, @AColors[0], LPositions, Length(AColors), sk_tilemode_t(ATileMode), @sk_matrix_t(ALocalMatrix))); -end; - -class function TSkShader.MakeGradientTwoPointConical(const AStart: TPointF; - const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; - const AColor1, AColor2: TAlphaColorF; const ALocalMatrix: TMatrix; - const ATileMode: TSkTileMode; AColorSpace: ISkColorSpace): ISkShader; -begin - Result := MakeGradientTwoPointConical(AStart, AStartRadius, AEnd, AEndRadius, [AColor1, AColor2], ALocalMatrix, nil, ATileMode, AColorSpace); -end; - -class function TSkShader.MakeGradientTwoPointConical(const AStart: TPointF; - const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; - const AColor1, AColor2: TAlphaColorF; const ATileMode: TSkTileMode; - AColorSpace: ISkColorSpace): ISkShader; -begin - Result := MakeGradientTwoPointConical(AStart, AStartRadius, AEnd, AEndRadius, [AColor1, AColor2], nil, ATileMode, AColorSpace); -end; - -class function TSkShader.MakeGradientTwoPointConical(const AStart: TPointF; - const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; - const AColor1, AColor2: TAlphaColor; const ATileMode: TSkTileMode): ISkShader; -begin - Result := MakeGradientTwoPointConical(AStart, AStartRadius, AEnd, AEndRadius, [AColor1, AColor2], nil, ATileMode); -end; - -class function TSkShader.MakeGradientTwoPointConical(const AStart: TPointF; - const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; - const AColor1, AColor2: TAlphaColor; const ALocalMatrix: TMatrix; - const ATileMode: TSkTileMode): ISkShader; -begin - Result := MakeGradientTwoPointConical(AStart, AStartRadius, AEnd, AEndRadius, [AColor1, AColor2], ALocalMatrix, nil, ATileMode); -end; - -class function TSkShader.MakeGradientTwoPointConical(const AStart: TPointF; - const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; - const AColors: TArray; const ALocalMatrix: TMatrix; - const APositions: TArray; const ATileMode: TSkTileMode; - AColorSpace: ISkColorSpace): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_two_point_conical2(@sk_point_t(AStart), AStartRadius, @sk_point_t(AEnd), AEndRadius, @sk_color4f_t(AColors[0]), TSkBindings.SafeHandle(AColorSpace), LPositions, Length(AColors), sk_tilemode_t(ATileMode), @sk_matrix_t(ALocalMatrix))); -end; - -class function TSkShader.MakeGradientTwoPointConical(const AStart: TPointF; - const AStartRadius: Single; AEnd: TPointF; const AEndRadius: Single; - const AColors: TArray; const APositions: TArray; - const ATileMode: TSkTileMode; AColorSpace: ISkColorSpace): ISkShader; -var - LPositions: pfloat; -begin - if Length(AColors) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AColors']); - if Length(APositions) > 0 then - begin - if Length(APositions) <> Length(AColors) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - LPositions := @APositions[0]; - end - else - LPositions := nil; - Result := TSkBindings.SafeCreate(sk4d_shader_make_gradient_two_point_conical2(@sk_point_t(AStart), AStartRadius, @sk_point_t(AEnd), AEndRadius, @sk_color4f_t(AColors[0]), TSkBindings.SafeHandle(AColorSpace), LPositions, Length(AColors), sk_tilemode_t(ATileMode), nil)); -end; - -class function TSkShader.MakeImage(const AImage: ISkImage; - const ALocalMatrix: TMatrix; const ASampling: TSkSamplingOptions; - const ATileModeX, ATileModeY: TSkTileMode): ISkShader; -begin - if not Assigned(AImage) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AImage']); - Result := AImage.MakeShader(ALocalMatrix, ASampling, ATileModeX, ATileModeY); -end; - -class function TSkShader.MakeImage(const AImage: ISkImage; - const ASampling: TSkSamplingOptions; const ATileModeX, - ATileModeY: TSkTileMode): ISkShader; -begin - if not Assigned(AImage) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AImage']); - Result := AImage.MakeShader(ASampling, ATileModeX, ATileModeY); -end; - -class function TSkShader.MakeImage(const AImage: ISkImage; const ATileModeX, - ATileModeY: TSkTileMode): ISkShader; -begin - if not Assigned(AImage) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AImage']); - Result := AImage.MakeShader(ATileModeX, ATileModeY); -end; - -class function TSkShader.MakeImage(const AImage: ISkImage; - const ALocalMatrix: TMatrix; const ATileModeX, - ATileModeY: TSkTileMode): ISkShader; -begin - if not Assigned(AImage) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AImage']); - Result := AImage.MakeShader(ALocalMatrix, ATileModeX, ATileModeY); -end; - -class function TSkShader.MakePerlinNoiseFractalNoise(const ABaseFrequencyX, - ABaseFrequencyY: Single; const ANumOctaves: Integer; const ASeed: Single; - const ATileSize: TSize): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_shader_make_perlin_noise_fractal_noise(ABaseFrequencyX, ABaseFrequencyY, ANumOctaves, ASeed, @sk_isize_t(ATileSize))); -end; - -class function TSkShader.MakePerlinNoiseFractalNoise(const ABaseFrequencyX, - ABaseFrequencyY: Single; const ANumOctaves: Integer; - const ASeed: Single): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_shader_make_perlin_noise_fractal_noise(ABaseFrequencyX, ABaseFrequencyY, ANumOctaves, ASeed, nil)); -end; - -class function TSkShader.MakePerlinNoiseTurbulence(const ABaseFrequencyX, - ABaseFrequencyY: Single; const ANumOctaves: Integer; const ASeed: Single; - const ATileSize: TSize): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_shader_make_perlin_noise_turbulence(ABaseFrequencyX, ABaseFrequencyY, ANumOctaves, ASeed, @sk_isize_t(ATileSize))); -end; - -class function TSkShader.MakePerlinNoiseTurbulence(const ABaseFrequencyX, - ABaseFrequencyY: Single; const ANumOctaves: Integer; - const ASeed: Single): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_shader_make_perlin_noise_turbulence(ABaseFrequencyX, ABaseFrequencyY, ANumOctaves, ASeed, nil)); -end; - -class function TSkShader.MakePicture(const APicture: ISkPicture; - const ATileRect: TRectF; const ALocalMatrix: TMatrix; const ATileModeX, - ATileModeY: TSkTileMode; const AFilterMode: TSkFilterMode): ISkShader; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - Result := APicture.MakeShader(ATileRect, ALocalMatrix, ATileModeX, ATileModeY, AFilterMode); -end; - -class function TSkShader.MakePicture(const APicture: ISkPicture; - const ATileModeX, ATileModeY: TSkTileMode; - const AFilterMode: TSkFilterMode): ISkShader; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - Result := APicture.MakeShader(ATileModeX, ATileModeY, AFilterMode); -end; - -class function TSkShader.MakePicture(const APicture: ISkPicture; - const ALocalMatrix: TMatrix; const ATileModeX, ATileModeY: TSkTileMode; - const AFilterMode: TSkFilterMode): ISkShader; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - Result := APicture.MakeShader(ALocalMatrix, ATileModeX, ATileModeY, AFilterMode); -end; - -class function TSkShader.MakePicture(const APicture: ISkPicture; - const ATileRect: TRectF; const ATileModeX, ATileModeY: TSkTileMode; - const AFilterMode: TSkFilterMode): ISkShader; -begin - if not Assigned(APicture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APicture']); - Result := APicture.MakeShader(ATileRect, ATileModeX, ATileModeY, AFilterMode); -end; - -function TSkShader.MakeWithColorFilter( - const AColorFilter: ISkColorFilter): ISkShader; -begin - if not Assigned(AColorFilter) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AColorFilter']); - Result := TSkBindings.SafeCreate(sk4d_shader_make_with_color_filter(Handle, AColorFilter.Handle)); -end; - -function TSkShader.MakeWithLocalMatrix(const AMatrix: TMatrix): ISkShader; -begin - Result := TSkBindings.SafeCreate(sk4d_shader_make_with_local_matrix(Handle, @sk_matrix_t(AMatrix))); -end; - -{ TSkSurface } - -procedure TSkSurface.Draw(const ACanvas: ISkCanvas; const AX, AY: Single; - const APaint: ISkPaint); -begin - if not Assigned(ACanvas) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ACanvas']); - sk4d_surface_draw(Handle, ACanvas.Handle, AX, AY, TSkBindings.SafeHandle(APaint)); -end; - -procedure TSkSurface.Flush; -begin - sk4d_surface_flush(Handle); -end; - -procedure TSkSurface.FlushAndSubmit(const ASyncCpu: Boolean); -begin - sk4d_surface_flush_and_submit(Handle, ASyncCpu); -end; - -function TSkSurface.GetCanvas: ISkCanvas; -begin - if not Assigned(FCanvas) then - FCanvas := TSkBindings.SafeCreate(sk4d_surface_get_canvas(Handle), False); - Result := FCanvas; -end; - -function TSkSurface.GetProperties: TSkSurfaceProperties; -var - LResult: sk_surfaceprops_t; -begin - sk4d_surface_get_props(Handle, LResult); - Result := TSkBindings.ToSurfaceProperties(LResult); -end; - -class function TSkSurface.MakeFromMTKView(const AContext: IGrDirectContext; - const AView: GrMtlHandle; const AOrigin: TGrSurfaceOrigin; - const ASampleCount: Integer; const AColorType: TSkColorType; - const AProperties: TSkSurfaceProperties; - AColorSpace: ISkColorSpace): ISkSurface; -var - LProperties: sk_surfaceprops_t; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - LProperties := TSkBindings.AsSurfaceProperties(AProperties); - Result := TSkBindings.SafeCreate(sk4d_surface_make_from_mtk_view(AContext.Handle, AView, gr_surfaceorigin_t(AOrigin), ASampleCount, sk_colortype_t(AColorType), TSkBindings.SafeHandle(AColorSpace), @LProperties)); -end; - -class function TSkSurface.MakeFromMTKView(const AContext: IGrDirectContext; - const AView: GrMtlHandle; const AOrigin: TGrSurfaceOrigin; - const ASampleCount: Integer; const AColorType: TSkColorType; - AColorSpace: ISkColorSpace): ISkSurface; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - Result := TSkBindings.SafeCreate(sk4d_surface_make_from_mtk_view(AContext.Handle, AView, gr_surfaceorigin_t(AOrigin), ASampleCount, sk_colortype_t(AColorType), TSkBindings.SafeHandle(AColorSpace), nil)); -end; - -class function TSkSurface.MakeFromRenderTarget(const AContext: IGrDirectContext; - const ARenderTarget: IGrBackendRenderTarget; const AOrigin: TGrSurfaceOrigin; - const AColorType: TSkColorType; const AProperties: TSkSurfaceProperties; - AColorSpace: ISkColorSpace): ISkSurface; -var - LProperties: sk_surfaceprops_t; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - if not Assigned(ARenderTarget) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARenderTarget']); - LProperties := TSkBindings.AsSurfaceProperties(AProperties); - Result := TSkBindings.SafeCreate(sk4d_surface_make_from_render_target(AContext.Handle, ARenderTarget.Handle, gr_surfaceorigin_t(AOrigin), sk_colortype_t(AColorType), TSkBindings.SafeHandle(AColorSpace), @LProperties)); -end; - -class function TSkSurface.MakeFromRenderTarget(const AContext: IGrDirectContext; - const ARenderTarget: IGrBackendRenderTarget; const AOrigin: TGrSurfaceOrigin; - const AColorType: TSkColorType; AColorSpace: ISkColorSpace): ISkSurface; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - if not Assigned(ARenderTarget) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ARenderTarget']); - Result := TSkBindings.SafeCreate(sk4d_surface_make_from_render_target(AContext.Handle, ARenderTarget.Handle, gr_surfaceorigin_t(AOrigin), sk_colortype_t(AColorType), TSkBindings.SafeHandle(AColorSpace), nil)); -end; - -class function TSkSurface.MakeFromTexture(const AContext: IGrDirectContext; - const ATexture: IGrBackendTexture; const AOrigin: TGrSurfaceOrigin; - const ASampleCount: Integer; const AColorType: TSkColorType; - const AProperties: TSkSurfaceProperties; - AColorSpace: ISkColorSpace): ISkSurface; -var - LProperties: sk_surfaceprops_t; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - if not Assigned(ATexture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATexture']); - LProperties := TSkBindings.AsSurfaceProperties(AProperties); - Result := TSkBindings.SafeCreate(sk4d_surface_make_from_texture(AContext.Handle, ATexture.Handle, gr_surfaceorigin_t(AOrigin), ASampleCount, sk_colortype_t(AColorType), TSkBindings.SafeHandle(AColorSpace), @LProperties)); -end; - -class function TSkSurface.MakeFromTexture(const AContext: IGrDirectContext; - const ATexture: IGrBackendTexture; const AOrigin: TGrSurfaceOrigin; - const ASampleCount: Integer; const AColorType: TSkColorType; - AColorSpace: ISkColorSpace): ISkSurface; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - if not Assigned(ATexture) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATexture']); - Result := TSkBindings.SafeCreate(sk4d_surface_make_from_texture(AContext.Handle, ATexture.Handle, gr_surfaceorigin_t(AOrigin), ASampleCount, sk_colortype_t(AColorType), TSkBindings.SafeHandle(AColorSpace), nil)); -end; - -function TSkSurface.MakeImageSnapshot(const ABounds: TRect): ISkImage; -begin - Result := TSkBindings.SafeCreate(sk4d_surface_make_image_snapshot2(Handle, @sk_irect_t(ABounds))); -end; - -function TSkSurface.MakeImageSnapshot: ISkImage; -begin - Result := TSkBindings.SafeCreate(sk4d_surface_make_image_snapshot(Handle)); -end; - -class function TSkSurface.MakeRaster(const AImageInfo: TSkImageInfo; - const ARowBytes: NativeUInt): ISkSurface; -var - LImageInfo: sk_imageinfo_t; -begin - LImageInfo := TSkBindings.AsImageInfo(AImageInfo); - Result := TSkBindings.SafeCreate(sk4d_surface_make_raster(@LImageInfo, ARowBytes, nil)); -end; - -class function TSkSurface.MakeRaster(const AImageInfo: TSkImageInfo; - const ARowBytes: NativeUInt; - const AProperties: TSkSurfaceProperties): ISkSurface; -var - LImageInfo: sk_imageinfo_t; - LProperties: sk_surfaceprops_t; -begin - LImageInfo := TSkBindings.AsImageInfo(AImageInfo); - LProperties := TSkBindings.AsSurfaceProperties(AProperties); - Result := TSkBindings.SafeCreate(sk4d_surface_make_raster(@LImageInfo, ARowBytes, @LProperties)); -end; - -class function TSkSurface.MakeRaster(const AWidth, AHeight: Integer; - const AColorType: TSkColorType; const AAlphaType: TSkAlphaType; - AColorSpace: ISkColorSpace): ISkSurface; -begin - Result := MakeRaster(TSkImageInfo.Create(AWidth, AHeight, AColorType, AAlphaType, AColorSpace)); -end; - -class function TSkSurface.MakeRaster(const AWidth, AHeight: Integer; - const AProperties: TSkSurfaceProperties; const AColorType: TSkColorType; - const AAlphaType: TSkAlphaType; AColorSpace: ISkColorSpace): ISkSurface; -begin - Result := MakeRaster(TSkImageInfo.Create(AWidth, AHeight, AColorType, AAlphaType, AColorSpace), AProperties); -end; - -class function TSkSurface.MakeRaster( - const AImageInfo: TSkImageInfo): ISkSurface; -begin - Result := MakeRaster(AImageInfo, AImageInfo.MinRowBytes); -end; - -class function TSkSurface.MakeRaster(const AImageInfo: TSkImageInfo; - const AProperties: TSkSurfaceProperties): ISkSurface; -begin - Result := MakeRaster(AImageInfo, AImageInfo.MinRowBytes, AProperties); -end; - -class function TSkSurface.MakeRasterDirect(const APixmap: ISkPixmap; - const AProperties: TSkSurfaceProperties; - const ARasterReleaseProc: TSkSurfaceRasterReleaseProc): ISkSurface; -var - LProperties: sk_surfaceprops_t; -begin - if not Assigned(APixmap) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APixmap']); - LProperties := TSkBindings.AsSurfaceProperties(AProperties); - if Assigned(ARasterReleaseProc) then - begin - Result := TSkDelegate.Initialize(ARasterReleaseProc, - function (const AContextProc: Pointer): ISkSurface - begin - Result := TSkBindings.SafeCreate(sk4d_surface_make_raster_direct(APixmap.Handle, raster_release_proc, AContextProc, @LProperties)); - end); - end - else - Result := TSkBindings.SafeCreate(sk4d_surface_make_raster_direct(APixmap.Handle, nil, nil, @LProperties)); -end; - -class function TSkSurface.MakeRasterDirect(const AImageInfo: TSkImageInfo; - const APixels: Pointer; const ARowBytes: NativeUInt; - const ARasterReleaseProc: TSkSurfaceRasterReleaseProc): ISkSurface; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(AImageInfo, APixels, ARowBytes); - Result := MakeRasterDirect(LPixmap, ARasterReleaseProc); -end; - -class function TSkSurface.MakeRasterDirect(const AImageInfo: TSkImageInfo; - const APixels: Pointer; const ARowBytes: NativeUInt; - const AProperties: TSkSurfaceProperties; - const ARasterReleaseProc: TSkSurfaceRasterReleaseProc): ISkSurface; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(AImageInfo, APixels, ARowBytes); - Result := MakeRasterDirect(LPixmap, AProperties, ARasterReleaseProc); -end; - -class function TSkSurface.MakeRasterDirect(const APixmap: ISkPixmap; - const ARasterReleaseProc: TSkSurfaceRasterReleaseProc): ISkSurface; -begin - if not Assigned(APixmap) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APixmap']); - if Assigned(ARasterReleaseProc) then - begin - Result := TSkDelegate.Initialize(ARasterReleaseProc, - function (const AContextProc: Pointer): ISkSurface - begin - Result := TSkBindings.SafeCreate(sk4d_surface_make_raster_direct(APixmap.Handle, raster_release_proc, AContextProc, nil)); - end); - end - else - Result := TSkBindings.SafeCreate(sk4d_surface_make_raster_direct(APixmap.Handle, nil, nil, nil)); -end; - -class function TSkSurface.MakeRenderTarget(const AContext: IGrDirectContext; - const AIsBudgeted: Boolean; const AImageInfo: TSkImageInfo; - const ASampleCount: Integer; const AOrigin: TGrSurfaceOrigin; - const AShouldCreateWithMips: Boolean): ISkSurface; -var - LImageInfo: sk_imageinfo_t; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - LImageInfo := TSkBindings.AsImageInfo(AImageInfo); - Result := TSkBindings.SafeCreate(sk4d_surface_make_render_target(AContext.Handle, AIsBudgeted, @LImageInfo, ASampleCount, gr_surfaceorigin_t(AOrigin), nil, AShouldCreateWithMips)); -end; - -class function TSkSurface.MakeRenderTarget(const AContext: IGrDirectContext; - const AIsBudgeted: Boolean; const AImageInfo: TSkImageInfo; - const AProperties: TSkSurfaceProperties; const ASampleCount: Integer; - const AOrigin: TGrSurfaceOrigin; - const AShouldCreateWithMips: Boolean): ISkSurface; -var - LImageInfo: sk_imageinfo_t; - LProperties: sk_surfaceprops_t; -begin - if not Assigned(AContext) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AContext']); - LImageInfo := TSkBindings.AsImageInfo(AImageInfo); - LProperties := TSkBindings.AsSurfaceProperties(AProperties); - Result := TSkBindings.SafeCreate(sk4d_surface_make_render_target(AContext.Handle, AIsBudgeted, @LImageInfo, ASampleCount, gr_surfaceorigin_t(AOrigin), @LProperties, AShouldCreateWithMips)); -end; - -function TSkSurface.PeekPixels: ISkPixmap; -begin - Result := TSkBindings.SafeCreate(sk4d_surface_peek_pixels(Handle)); -end; - -class procedure TSkSurface.raster_release_proc(pixels, context: Pointer); -begin - TSkDelegate.Invoke(context, - procedure (const AProc: TSkSurfaceRasterReleaseProc) - begin - AProc(pixels); - end); - TSkDelegate.Finalize(context); -end; - -function TSkSurface.ReadPixels(const ADestImageInfo: TSkImageInfo; - const ADestPixels: Pointer; const ADestRowBytes: NativeUInt; const ASrcX, - ASrcY: Integer): Boolean; -var - LPixmap: ISkPixmap; -begin - LPixmap := TSkPixmap.Create(ADestImageInfo, ADestPixels, ADestRowBytes); - Result := ReadPixels(LPixmap, ASrcX, ASrcY); -end; - -function TSkSurface.ReadPixels(const ADest: ISkPixmap; const ASrcX, - ASrcY: Integer): Boolean; -begin - if not Assigned(ADest) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ADest']); - Result := sk4d_surface_read_pixels(Handle, ADest.Handle, ASrcX, ASrcY); -end; - -{ TSkTextBlob } - -function TSkTextBlob.GetIntercepts(const AUpperBounds, ALowerBounds: Single; - const APaint: ISkPaint): TArray; -var - LBounds: array[0..1] of Single; - LCount: Integer; -begin - LBounds[0] := AUpperBounds; - LBounds[1] := ALowerBounds; - LCount := sk4d_textblob_get_intercepts(Handle, @LBounds[0], nil, TSkBindings.SafeHandle(APaint)); - if LCount = 0 then - Exit(nil); - SetLength(Result, LCount); - sk4d_textblob_get_intercepts(Handle, @LBounds[0], @Result[0], TSkBindings.SafeHandle(APaint)); -end; - -class function TSkTextBlob.MakeFromText(const AText: string; - const AFont: ISkFont): ISkTextBlob; -begin - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - if AText.IsEmpty then - Exit(nil); - Result := TSkBindings.SafeCreate(sk4d_textblob_make_from_text(@AText[Low(AText)], Length(AText) * 2, AFont.Handle, sk_textencoding_t.UTF16_SK_TEXTENCODING)); -end; - -class function TSkTextBlob.MakeFromTextHorizontallyPositioned( - const AText: string; const AXPositions: TArray; const AY: Single; - const AFont: ISkFont): ISkTextBlob; -begin - if Length(AXPositions) <> Length(AText) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AXPositions']); - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - if AText.IsEmpty then - Exit(nil); - Result := TSkBindings.SafeCreate(sk4d_textblob_make_from_text_horizontally_positioned(@AText[Low(AText)], Length(AText) * 2, @AXPositions[0], AY, AFont.Handle, sk_textencoding_t.UTF16_SK_TEXTENCODING)); -end; - -class function TSkTextBlob.MakeFromTextPositioned(const AText: string; - const APositions: TArray; const AFont: ISkFont): ISkTextBlob; -begin - if Length(APositions) <> Length(AText) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['APositions']); - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - if AText.IsEmpty then - Exit(nil); - Result := TSkBindings.SafeCreate(sk4d_textblob_make_from_text_positioned(@AText[Low(AText)], Length(AText) * 2, @sk_point_t(APositions[0]), AFont.Handle, sk_textencoding_t.UTF16_SK_TEXTENCODING)); -end; - -class function TSkTextBlob.MakeFromTextTransform(const AText: string; - const AMatrices: TArray; - const AFont: ISkFont): ISkTextBlob; -begin - if Length(AMatrices) <> Length(AText) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AMatrices']); - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - if AText.IsEmpty then - Exit(nil); - Result := TSkBindings.SafeCreate(sk4d_textblob_make_from_text_transform(@AText[Low(AText)], Length(AText) * 2, @sk_rotationscalematrix_t(AMatrices[0]), AFont.Handle, sk_textencoding_t.UTF16_SK_TEXTENCODING)); -end; - -class procedure TSkTextBlob.__RefHandle(const AHandle: THandle); -begin - sk4d_textblob_ref(AHandle); -end; - -class procedure TSkTextBlob.__UnrefHandle(const AHandle: THandle); -begin - sk4d_textblob_unref(AHandle); -end; - -{ TSkTraceMemoryDumpBaseClass } - -constructor TSkTraceMemoryDumpBaseClass.Create(const ADetailedDump, - ADumpWrappedObjects: Boolean); -begin - inherited Create(sk4d_tracememorydumpbaseclass_create(ADetailedDump, ADumpWrappedObjects, Self)); -end; - -class constructor TSkTraceMemoryDumpBaseClass.Create; -var - LProcs: sk_tracememorydumpbaseclass_procs_t; -begin - LProcs.dump_numeric_value := dump_numeric_value_proc; - LProcs.dump_string_value := dump_string_value_proc; - sk4d_tracememorydumpbaseclass_set_procs(@LProcs); -end; - -class procedure TSkTraceMemoryDumpBaseClass.dump_numeric_value_proc( - context: Pointer; const dump_name, value_name, units: MarshaledAString; - value: uint64_t); -begin - TSkTraceMemoryDumpBaseClass(context).DumpNumericValue(string(dump_name), string(value_name), string(units), value); -end; - -class procedure TSkTraceMemoryDumpBaseClass.dump_string_value_proc( - context: Pointer; const dump_name, value_name, value: MarshaledAString); -begin - TSkTraceMemoryDumpBaseClass(context).DumpStringValue(string(dump_name), string(value_name), string(value)); -end; - -class procedure TSkTraceMemoryDumpBaseClass.__DestroyHandle( - const AHandle: THandle); -begin - sk4d_tracememorydumpbaseclass_destroy(AHandle); -end; - -{ TSkTypeface } - -function TSkTypeface.GetFamilyName: string; -var - LResult: ISkString; -begin - LResult := TSkString.Wrap(sk4d_typeface_get_family_name(Handle)); - Result := LResult.Text; -end; - -function TSkTypeface.GetSlant: TSkFontSlant; -begin - Result := TSkFontSlant(sk4d_typeface_get_slant(Handle)); -end; - -function TSkTypeface.GetStyle: TSkFontStyle; -begin - sk4d_typeface_get_style(Handle, sk_fontstyle_t(Result)); -end; - -function TSkTypeface.GetWeight: Integer; -begin - Result := sk4d_typeface_get_weight(Handle); -end; - -function TSkTypeface.GetWidth: Integer; -begin - Result := sk4d_typeface_get_width(Handle); -end; - -function TSkTypeface.IsBold: Boolean; -begin - Result := GetWeight >= Ord(TSkFontWeight.SemiBold); -end; - -function TSkTypeface.IsItalic: Boolean; -begin - Result := GetSlant <> TSkFontSlant.Upright; -end; - -class function TSkTypeface.MakeDefault: ISkTypeface; -begin - Result := TSkBindings.SafeCreate(sk4d_typeface_make_default()); -end; - -class function TSkTypeface.MakeFromFile(const AFileName: string; - const ATTCIndex: Integer): ISkTypeface; -var - LMarshaller: TMarshaller; -begin - if AFileName.IsEmpty then - raise ESkException.Create(SFileNameIsEmpty); - Result := TSkBindings.SafeCreate(sk4d_typeface_make_from_file(LMarshaller.AsUtf8(AFileName).ToPointer, ATTCIndex)); -end; - -class function TSkTypeface.MakeFromName(const AFamilyName: string; - const AStyle: TSkFontStyle): ISkTypeface; -var - LMarshaller: TMarshaller; -begin - if AFamilyName.IsEmpty then - Result := TSkBindings.SafeCreate(sk4d_typeface_make_from_name(nil, @sk_fontstyle_t(AStyle))) - else - Result := TSkBindings.SafeCreate(sk4d_typeface_make_from_name(LMarshaller.AsUtf8(AFamilyName).ToPointer, @sk_fontstyle_t(AStyle))); -end; - -class function TSkTypeface.MakeFromStream(const AStream: TStream; - const ATTCIndex: Integer): ISkTypeface; -var - LStream: ISkStream; -begin - LStream := TSkStreamAdapter.Create(AStream); - Result := TSkBindings.SafeCreate(sk4d_typeface_make_from_stream(LStream.Handle, ATTCIndex)); -end; - -{ TSkVertices } - -class function TSkVertices.MakeCopy(const AVertexMode: TSkVertexMode; - const APositions, ATextures: TArray; - const AColors: TArray; - const AIndices: TArray): ISkVertices; -var - LColors: psk_color_t; - LIndices: puint16_t; - LTextures: psk_point_t; -begin - if Length(APositions) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['APositions']); - if Length(ATextures) > 0 then - begin - if Length(ATextures) <> Length(APositions) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['ATextures']); - LTextures := @sk_point_t(ATextures[0]); - end - else - LTextures := nil; - if Length(AColors) > 0 then - begin - if Length(AColors) <> Length(APositions) then - raise ESkArgumentException.CreateFmt(SParamSizeMismatch, ['AColors']); - LColors := @AColors[0]; - end - else - LColors := nil; - if Length(AIndices) > 0 then - LIndices := @AIndices[0] - else - LIndices := nil; - Result := TSkBindings.SafeCreate(sk4d_vertices_make_copy(sk_vertexmode_t(AVerTexMode), Length(APositions), @sk_point_t(APositions[0]), LTextures, LColors, Length(AIndices), LIndices)); -end; - -class procedure TSkVertices.__RefHandle(const AHandle: THandle); -begin - sk4d_vertices_ref(AHandle); -end; - -class procedure TSkVertices.__UnrefHandle(const AHandle: THandle); -begin - sk4d_vertices_unref(AHandle); -end; - -{ TSkParticleEffect } - -class constructor TSkParticleEffect.Create; -begin - sk4d_particleeffect_init(); -end; - -function TSkParticleEffect.GetPosition: TPointF; -begin - sk4d_particleeffect_get_position(Handle, sk_point_t(Result)); -end; - -function TSkParticleEffect.GetRate: Single; -begin - Result := sk4d_particleeffect_get_rate(Handle); -end; - -function TSkParticleEffect.GetUniform( - const AIndex: NativeUInt): TSkParticleUniform; -begin - sk4d_particleeffect_get_uniform(Handle, AIndex, sk_particleuniform_t(Result)); -end; - -function TSkParticleEffect.GetUniformCount: NativeUInt; -begin - Result := sk4d_particleeffect_get_uniform_count(Handle); -end; - -function TSkParticleEffect.GetUniformData: PSingleArray; -begin - Result := PSingleArray(sk4d_particleeffect_get_uniform_data(Handle)); -end; - -function TSkParticleEffect.GetUniformDataCount: Integer; -begin - Result := sk4d_particleeffect_get_uniform_data_count(Handle); -end; - -function TSkParticleEffect.GetUniformName(const AIndex: NativeUInt): string; -var - LResult: ISkString; -begin - LResult := TSkString.Wrap(sk4d_particleeffect_get_uniform_name(Handle, AIndex)); - Result := LResult.Text; -end; - -class function TSkParticleEffect.Make(const AData: string; - const AResourceProvider: ISkResourceProvider): ISkParticleEffect; -var - LStream: TStream; -begin - LStream := TStringStream.Create(AData, TEncoding.UTF8); - try - Result := MakeFromStream(LStream, AResourceProvider); - finally - LStream.Free; - end; -end; - -class function TSkParticleEffect.MakeFromFile( - const AFileName: string): ISkParticleEffect; -var - LMarshaller: TMarshaller; -begin - if AFileName.IsEmpty then - raise ESkException.Create(SFileNameIsEmpty); - Result := TSkBindings.SafeCreate(sk4d_particleeffect_make_from_file(LMarshaller.AsUtf8(AFileName).ToPointer)); -end; - -class function TSkParticleEffect.MakeFromStream(const AStream: TStream; - const AResourceProvider: ISkResourceProvider): ISkParticleEffect; -var - LStream: ISkStream; -begin - LStream := TSkStreamAdapter.Create(AStream); - Result := TSkBindings.SafeCreate(sk4d_particleeffect_make_from_stream(LStream.Handle, TSkBindings.SafeHandle(AResourceProvider))); -end; - -procedure TSkParticleEffect.Render(const ACanvas: ISkCanvas); -begin - if not Assigned(ACanvas) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ACanvas']); - sk4d_particleeffect_render(Handle, ACanvas.Handle); -end; - -procedure TSkParticleEffect.SetPosition(const AValue: TPointF); -begin - sk4d_particleeffect_set_position(Handle, @sk_point_t(AValue)); -end; - -procedure TSkParticleEffect.SetRate(const AValue: Single); -begin - sk4d_particleeffect_set_rate(Handle, AValue); -end; - -function TSkParticleEffect.SetUniform(const AName: string; - const AData: TArray): Boolean; -var - LMarshaller: TMarshaller; -begin - if Length(AData) < 1 then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AData']); - Result := sk4d_particleeffect_set_uniform(Handle, LMarshaller.AsUtf8(AName).ToPointer, @AData[0], Length(AData)); -end; - -procedure TSkParticleEffect.Start(const ANow: Double; const ALooping: Boolean); -begin - sk4d_particleeffect_start(Handle, ANow, ALooping); -end; - -procedure TSkParticleEffect.Update(const ANow: Double); -begin - sk4d_particleeffect_update(Handle, ANow); -end; - -{ TSkottieAnimation } - -function TSkottieAnimation.GetDuration: Double; -begin - Result := sk4d_skottieanimation_get_duration(Handle); -end; - -function TSkottieAnimation.GetFPS: Double; -begin - Result := sk4d_skottieanimation_get_fps(Handle); -end; - -function TSkottieAnimation.GetInPoint: Double; -begin - Result := sk4d_skottieanimation_get_in_point(Handle); -end; - -function TSkottieAnimation.GetOutPoint: Double; -begin - Result := sk4d_skottieanimation_get_out_point(Handle); -end; - -function TSkottieAnimation.GetSize: TSizeF; -begin - sk4d_skottieanimation_get_size(Handle, sk_size_t(Result)); -end; - -function TSkottieAnimation.GetVersion: string; -begin - Result := string(sk4d_skottieanimation_get_version(Handle)); -end; - -class function TSkottieAnimation.Make(const AData: string; - const AResourceProvider: ISkResourceProvider): ISkottieAnimation; -var - LStream: TStream; -begin - LStream := TStringStream.Create(AData, TEncoding.UTF8); - try - Result := MakeFromStream(LStream, AResourceProvider); - finally - LStream.Free; - end; -end; - -class function TSkottieAnimation.MakeFromFile( - const AFileName: string): ISkottieAnimation; -var - LMarshaller: TMarshaller; -begin - if AFileName.IsEmpty then - raise ESkException.Create(SFileNameIsEmpty); - Result := TSkBindings.SafeCreate(sk4d_skottieanimation_make_from_file(LMarshaller.AsUtf8(AFileName).ToPointer)); -end; - -class function TSkottieAnimation.MakeFromStream(const AStream: TStream; - const AResourceProvider: ISkResourceProvider): ISkottieAnimation; -var - LStream: ISkStream; -begin - LStream := TSkStreamAdapter.Create(AStream); - Result := TSkBindings.SafeCreate(sk4d_skottieanimation_make_from_stream(LStream.Handle, TSkBindings.SafeHandle(AResourceProvider))); -end; - -procedure TSkottieAnimation.Render(const ACanvas: ISkCanvas; - const ARenderFlags: TSkottieAnimationRenderFlags); -begin - if not Assigned(ACanvas) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ACanvas']); - sk4d_skottieanimation_render(Handle, ACanvas.Handle, nil, Byte(ARenderFlags)); -end; - -procedure TSkottieAnimation.Render(const ACanvas: ISkCanvas; - const ADest: TRectF; const ARenderFlags: TSkottieAnimationRenderFlags); -begin - if not Assigned(ACanvas) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ACanvas']); - sk4d_skottieanimation_render(Handle, ACanvas.Handle, @sk_rect_t(ADest), Byte(ARenderFlags)); -end; - -procedure TSkottieAnimation.SeekFrame(const ATick: Double); -begin - sk4d_skottieanimation_seek_frame(Handle, ATick); -end; - -procedure TSkottieAnimation.SeekFrameTime(const ATick: Double); -begin - sk4d_skottieanimation_seek_frame_time(Handle, ATick); -end; - -class procedure TSkottieAnimation.__RefHandle(const AHandle: THandle); -begin - sk4d_skottieanimation_ref(AHandle); -end; - -class procedure TSkottieAnimation.__UnrefHandle(const AHandle: THandle); -begin - sk4d_skottieanimation_unref(AHandle); -end; - -{ TSkParagraph } - -function TSkParagraph.DidExceedMaxLines: Boolean; -begin - Result := sk4d_paragraph_did_exceed_max_lines(Handle); -end; - -function TSkParagraph.GetAlphabeticBaseline: Single; -begin - Result := sk4d_paragraph_get_alphabetic_baseline(Handle); -end; - -function TSkParagraph.GetGlyphPositionAtCoordinate(const ADeltaX, - ADeltaY: Single): TSkPositionAffinity; -begin - sk4d_paragraph_get_glyph_position_at_coordinate(Handle, ADeltaX, ADeltaY, sk_positionaffinity_t(Result)); -end; - -function TSkParagraph.GetHeight: Single; -begin - Result := sk4d_paragraph_get_height(Handle); -end; - -function TSkParagraph.GetIdeographicBaseline: Single; -begin - Result := sk4d_paragraph_get_ideographic_baseline(Handle); -end; - -function TSkParagraph.GetLineMetrics: TArray; -var - I: Integer; - LCount: NativeUInt; - LResult: TArray; -begin - LCount := sk4d_paragraph_get_line_metrics(Handle, nil); - if LCount = 0 then - Exit(nil); - SetLength(LResult, LCount); - sk4d_paragraph_get_line_metrics(Handle, @sk_metrics_t(LResult[0])); - SetLength(Result, Length(LResult)); - for I := 0 to Length(LResult) - 1 do - Result[I] := TSkMetrics(LResult[I]); -end; - -function TSkParagraph.GetLongestLine: Single; -begin - Result := sk4d_paragraph_get_longest_line(Handle); -end; - -function TSkParagraph.GetMaxIntrinsicWidth: Single; -begin - Result := sk4d_paragraph_get_max_intrinsic_width(Handle); -end; - -function TSkParagraph.GetMaxWidth: Single; -begin - Result := sk4d_paragraph_get_max_width(Handle); -end; - -function TSkParagraph.GetMinIntrinsicWidth: Single; -begin - Result := sk4d_paragraph_get_min_intrinsic_width(Handle); -end; - -function TSkParagraph.GetRectsForPlaceholders: TArray; -var - LCount: NativeUInt; -begin - LCount := sk4d_paragraph_get_rects_for_placeholders(Handle, nil); - if LCount = 0 then - Exit(nil); - SetLength(Result, LCount); - sk4d_paragraph_get_rects_for_placeholders(Handle, @sk_textbox_t(Result[0])); -end; - -function TSkParagraph.GetRectsForRange(const AStart, AEnd: Cardinal; - const ARectHeightStyle: TSkRectHeightStyle; - const ARectWidthStyle: TSkRectWidthStyle): TArray; -var - LCount: NativeUInt; -begin - LCount := sk4d_paragraph_get_rects_for_range(Handle, AStart, AEnd, sk_rectheightstyle_t(ARectHeightStyle), sk_rectwidthstyle_t(ARectWidthStyle), nil); - if LCount = 0 then - Exit(nil); - SetLength(Result, LCount); - sk4d_paragraph_get_rects_for_range(Handle, AStart, AEnd, sk_rectheightstyle_t(ARectHeightStyle), sk_rectwidthstyle_t(ARectWidthStyle), @sk_textbox_t(Result[0])); -end; - -procedure TSkParagraph.GetWordBoundary(const AOffset: Cardinal; out AStart, - AEnd: Cardinal); -begin - sk4d_paragraph_get_word_boundary(Handle, AOffset, AStart, AEnd); -end; - -procedure TSkParagraph.Layout(const AWidth: Single); -begin - sk4d_paragraph_layout(Handle, AWidth); -end; - -procedure TSkParagraph.Paint(const ACanvas: ISkCanvas; const AX, AY: Single); -begin - if not Assigned(ACanvas) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ACanvas']); - sk4d_paragraph_paint(Handle, ACanvas.Handle, AX, AY); -end; - -function TSkParagraph.ToPath: ISkPath; -begin - Result := TSkPath.Wrap(sk4d_paragraph_to_path(Handle)); -end; - -procedure TSkParagraph.Visit(const AProc: TSkParagraphVisitProc); -begin - sk4d_paragraph_visit(Handle, visit_proc, @AProc); -end; - -class procedure TSkParagraph.visit_proc(line_number: int32_t; - const info: psk_paragraphvisitorinfo_t; context: Pointer); -begin - if info <> nil then - TSkParagraphVisitProc(context^)(line_number, TSkBindings.ToParagraphVisitorInfo(info^)); -end; - -class procedure TSkParagraph.__DestroyHandle(const AHandle: THandle); -begin - sk4d_paragraph_destroy(AHandle); -end; - -{ TSkParagraphBuilder } - -procedure TSkParagraphBuilder.AddPlaceholder( - const APlaceholder: TSkPlaceholderStyle); -begin - sk4d_paragraphbuilder_add_placeholder(Handle, @sk_placeholderstyle_t(APlaceholder)); -end; - -procedure TSkParagraphBuilder.AddText(const AText: string); -var - LMarshaller: TMarshaller; -begin - sk4d_paragraphbuilder_add_text(Handle, LMarshaller.AsUtf8(AText).ToPointer); -end; - -function TSkParagraphBuilder.Build: ISkParagraph; -begin - Result := TSkParagraph.Wrap(sk4d_paragraphbuilder_build(Handle)); -end; - -constructor TSkParagraphBuilder.Create(const AParagraphStyle: ISkParagraphStyle; - const AFontProvider: ISkTypefaceFontProvider; - const AEnableFontFallback: Boolean); -begin - if not Assigned(AParagraphStyle) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AParagraphStyle']); - if not Assigned(AFontProvider) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFontProvider']); - inherited Create(sk4d_paragraphbuilder_create2(AParagraphStyle.Handle, AFontProvider.Handle, AEnableFontFallback)); -end; - -constructor TSkParagraphBuilder.Create( - const AParagraphStyle: ISkParagraphStyle); -begin - if not Assigned(AParagraphStyle) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AParagraphStyle']); - inherited Create(sk4d_paragraphbuilder_create(AParagraphStyle.Handle)); -end; - -procedure TSkParagraphBuilder.Pop; -begin - sk4d_paragraphbuilder_pop(Handle); -end; - -procedure TSkParagraphBuilder.PushStyle(const ATextStyle: ISkTextStyle); -begin - if not Assigned(ATextStyle) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATextStyle']); - sk4d_paragraphbuilder_push_style(Handle, ATextStyle.Handle); -end; - -class procedure TSkParagraphBuilder.__DestroyHandle(const AHandle: THandle); -begin - sk4d_paragraphbuilder_destroy(AHandle); -end; - -{ TSkStrutStyle } - -constructor TSkStrutStyle.Create; -begin - inherited Create(sk4d_strutstyle_create()); -end; - -function TSkStrutStyle.GetEnabled: Boolean; -begin - Result := sk4d_strutstyle_get_enabled(Handle); -end; - -function TSkStrutStyle.GetFontFamilies: TArray; -begin - Result := TSkBindings.GetStrings(Handle, - function (const AHandle: THandle; const AStrings: PMarshaledAString): Integer - begin - Result := sk4d_strutstyle_get_font_families(AHandle, AStrings); - end); -end; - -function TSkStrutStyle.GetFontSize: Single; -begin - Result := sk4d_strutstyle_get_font_size(Handle); -end; - -function TSkStrutStyle.GetFontStyle: TSkFontStyle; -begin - sk4d_strutstyle_get_font_style(Handle, sk_fontstyle_t(Result)); -end; - -function TSkStrutStyle.GetForceHeight: Boolean; -begin - Result := sk4d_strutstyle_get_force_height(Handle); -end; - -function TSkStrutStyle.GetHalfLeading: Boolean; -begin - Result := sk4d_strutstyle_get_half_leading(Handle); -end; - -function TSkStrutStyle.GetHeightMultiplier: Single; -begin - Result := sk4d_strutstyle_get_height_multiplier(Handle); -end; - -function TSkStrutStyle.GetLeading: Single; -begin - Result := sk4d_strutstyle_get_leading(Handle); -end; - -function TSkStrutStyle.IsEqual(const AStrutStyle: ISkStrutStyle): Boolean; -begin - if not Assigned(AStrutStyle) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AStrutStyle']); - Result := sk4d_strutstyle_is_equal(Handle, AStrutStyle.Handle); -end; - -procedure TSkStrutStyle.SetEnabled(const AValue: Boolean); -begin - sk4d_strutstyle_set_enabled(Handle, AValue); -end; - -procedure TSkStrutStyle.SetFontFamilies(const AValue: TArray); -begin - TSkBindings.SetStrings(Handle, AValue, - procedure (const AHandle: THandle; const AStrings: PMarshaledAString) - begin - sk4d_strutstyle_set_font_families(AHandle, AStrings, Length(AValue)); - end); -end; - -procedure TSkStrutStyle.SetFontSize(const AValue: Single); -begin - sk4d_strutstyle_set_font_size(Handle, AValue); -end; - -procedure TSkStrutStyle.SetFontStyle(const AValue: TSkFontStyle); -begin - sk4d_strutstyle_set_font_style(Handle, @sk_fontstyle_t(AValue)); -end; - -procedure TSkStrutStyle.SetForceHeight(const AValue: Boolean); -begin - sk4d_strutstyle_set_force_height(Handle, AValue); -end; - -procedure TSkStrutStyle.SetHalfLeading(const AValue: Boolean); -begin - sk4d_strutstyle_set_half_leading(Handle, AValue); -end; - -procedure TSkStrutStyle.SetHeightMultiplier(const AValue: Single); -begin - sk4d_strutstyle_set_height_multiplier(Handle, AValue); -end; - -procedure TSkStrutStyle.SetLeading(const AValue: Single); -begin - sk4d_strutstyle_set_leading(Handle, AValue); -end; - -class procedure TSkStrutStyle.__DestroyHandle(const AHandle: THandle); -begin - sk4d_strutstyle_destroy(AHandle); -end; - -{ TSkParagraphStyle } - -constructor TSkParagraphStyle.Create; -begin - inherited Create(sk4d_paragraphstyle_create()); -end; - -procedure TSkParagraphStyle.DisableHinting; -begin - sk4d_paragraphstyle_disable_hinting(Handle); -end; - -function TSkParagraphStyle.GetEllipsis: string; -var - LResult: ISkString; -begin - LResult := TSkString.Wrap(sk4d_paragraphstyle_get_ellipsis(Handle)); - Result := LResult.Text; -end; - -function TSkParagraphStyle.GetHeight: Single; -begin - Result := sk4d_paragraphstyle_get_height(Handle); -end; - -function TSkParagraphStyle.GetMaxLines: NativeUInt; -begin - Result := sk4d_paragraphstyle_get_max_lines(Handle); -end; - -function TSkParagraphStyle.GetStrutStyle: ISkStrutStyle; -begin - Result := TSkStrutStyle.Wrap(sk4d_paragraphstyle_get_strut_style(Handle), False); -end; - -function TSkParagraphStyle.GetTextAlign: TSkTextAlign; -begin - Result := TSkTextAlign(sk4d_paragraphstyle_get_text_align(Handle)); -end; - -function TSkParagraphStyle.GetTextDirection: TSkTextDirection; -begin - Result := TSkTextDirection(sk4d_paragraphstyle_get_text_direction(Handle)); -end; - -function TSkParagraphStyle.GetTextHeightBehaviors: TSkTextHeightBehaviors; -begin - Result := TSkTextHeightBehaviors(Byte(sk4d_paragraphstyle_get_text_height_behaviors(Handle))); -end; - -function TSkParagraphStyle.GetTextStyle: ISkTextStyle; -begin - Result := TSkTextStyle.Wrap(sk4d_paragraphstyle_get_text_style(Handle), False); -end; - -procedure TSkParagraphStyle.SetEllipsis(const AValue: string); -var - LMarshaller: TMarshaller; -begin - if AValue.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AValue']); - sk4d_paragraphstyle_set_ellipsis(Handle, LMarshaller.AsUtf8(AValue).ToPointer); -end; - -procedure TSkParagraphStyle.SetHeight(const AValue: Single); -begin - sk4d_paragraphstyle_set_height(Handle, AValue); -end; - -procedure TSkParagraphStyle.SetMaxLines(const AValue: NativeUInt); -begin - sk4d_paragraphstyle_set_max_lines(Handle, AValue); -end; - -procedure TSkParagraphStyle.SetStrutStyle(AValue: ISkStrutStyle); -begin - sk4d_paragraphstyle_set_strut_style(Handle, TSkBindings.SafeHandle(AValue)); -end; - -procedure TSkParagraphStyle.SetTextAlign(const AValue: TSkTextAlign); -begin - sk4d_paragraphstyle_set_text_align(Handle, sk_textalign_t(AValue)); -end; - -procedure TSkParagraphStyle.SetTextDirection(const AValue: TSkTextDirection); -begin - sk4d_paragraphstyle_set_text_direction(Handle, sk_textdirection_t(AValue)); -end; - -procedure TSkParagraphStyle.SetTextHeightBehaviors( - const AValue: TSkTextHeightBehaviors); -begin - sk4d_paragraphstyle_set_text_height_behaviors(Handle, Byte(AValue)); -end; - -procedure TSkParagraphStyle.SetTextStyle(AValue: ISkTextStyle); -begin - sk4d_paragraphstyle_set_text_style(Handle, TSkBindings.SafeHandle(AValue)); -end; - -class procedure TSkParagraphStyle.__DestroyHandle(const AHandle: THandle); -begin - sk4d_paragraphstyle_destroy(AHandle); -end; - -{ TSkTextStyle } - -procedure TSkTextStyle.AddFontFeature(const AFeature: string; - const AValue: Integer); -var - LMarshaller: TMarshaller; -begin - if AFeature.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AFeature']); - sk4d_textstyle_add_font_feature(Handle, LMarshaller.AsUtf8(AFeature).ToPointer, AValue); -end; - -procedure TSkTextStyle.AddShadow(const AShadow: TSkTextShadow); -begin - sk4d_textstyle_add_shadow(Handle, @sk_textshadow_t(AShadow)); -end; - -procedure TSkTextStyle.ClearBackgroundColor; -begin - sk4d_textstyle_clear_background_color(Handle); -end; - -procedure TSkTextStyle.ClearForegroundColor; -begin - sk4d_textstyle_clear_foreground_color(Handle); -end; - - -constructor TSkTextStyle.Create; -begin - inherited Create(sk4d_textstyle_create()); -end; - -function TSkTextStyle.GetBackground: ISkPaint; -begin - Result := TSkPaint.Wrap(sk4d_textstyle_get_background(Handle)); -end; - -function TSkTextStyle.GetColor: TAlphaColor; -begin - Result := sk4d_textstyle_get_color(Handle); -end; - -function TSkTextStyle.GetDecorationColor: TAlphaColor; -begin - Result := sk4d_textstyle_get_decoration_color(Handle); -end; - -function TSkTextStyle.GetDecorations: TSkTextDecorations; -begin - Result := TSkTextDecorations(Byte(sk4d_textstyle_get_decorations(Handle))); -end; - -function TSkTextStyle.GetDecorationStyle: TSkTextDecorationStyle; -begin - Result := TSkTextDecorationStyle(sk4d_textstyle_get_decoration_style(Handle)); -end; - -function TSkTextStyle.GetDecorationThickness: Single; -begin - Result := sk4d_textstyle_get_decoration_thickness(Handle); -end; - -function TSkTextStyle.GetFontFamilies: TArray; -begin - Result := TSkBindings.GetStrings(Handle, - function (const AHandle: THandle; const AStrings: PMarshaledAString): Integer - begin - Result := sk4d_textstyle_get_font_families(AHandle, AStrings); - end); -end; - -function TSkTextStyle.GetFontMetrics: TSkFontMetrics; -var - LResult: sk_fontmetrics_t; -begin - sk4d_textstyle_get_font_metrics(Handle, LResult); - Result := TSkBindings.ToFontMetrics(LResult); -end; - -function TSkTextStyle.GetFontSize: Single; -begin - Result := sk4d_textstyle_get_font_size(Handle); -end; - -function TSkTextStyle.GetFontStyle: TSkFontStyle; -begin - sk4d_textstyle_get_font_style(Handle, sk_fontstyle_t(Result)); -end; - -function TSkTextStyle.GetForeground: ISkPaint; -begin - Result := TSkPaint.Wrap(sk4d_textstyle_get_foreground(Handle)); -end; - -function TSkTextStyle.GetHalfLeading: Boolean; -begin - Result := sk4d_textstyle_get_half_leading(Handle); -end; - -function TSkTextStyle.GetHeightMultiplier: Single; -begin - Result := sk4d_textstyle_get_height_multiplier(Handle); -end; - -function TSkTextStyle.GetLetterSpacing: Single; -begin - Result := sk4d_textstyle_get_letter_spacing(Handle); -end; - -function TSkTextStyle.GetLocale: string; -var - LResult: ISkString; -begin - LResult := TSkString.Wrap(sk4d_textstyle_get_locale(Handle)); - Result := LResult.Text; -end; - -function TSkTextStyle.GetWordSpacing: Single; -begin - Result := sk4d_textstyle_get_word_spacing(Handle); -end; - -function TSkTextStyle.IsEqual(const ATextStyle: ISkTextStyle): Boolean; -begin - if not Assigned(ATextStyle) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATextStyle']); - Result := sk4d_textstyle_is_equal(Handle, ATextStyle.Handle); -end; - -procedure TSkTextStyle.ResetFontFeatures; -begin - sk4d_textstyle_reset_font_features(Handle); -end; - -procedure TSkTextStyle.ResetShadows; -begin - sk4d_textstyle_reset_shadows(Handle); -end; - -procedure TSkTextStyle.SetBackgroundColor(const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_textstyle_set_background_color(Handle, APaint.Handle); -end; - -procedure TSkTextStyle.SetColor(const AValue: TAlphaColor); -begin - sk4d_textstyle_set_color(Handle, AValue); -end; - -procedure TSkTextStyle.SetDecorationColor(const AValue: TAlphaColor); -begin - sk4d_textstyle_set_decoration_color(Handle, AValue); -end; - -procedure TSkTextStyle.SetDecorations(const AValue: TSkTextDecorations); -begin - sk4d_textstyle_set_decorations(Handle, Byte(AValue)); -end; - -procedure TSkTextStyle.SetDecorationStyle(const AValue: TSkTextDecorationStyle); -begin - sk4d_textstyle_set_decoration_style(Handle, sk_textdecorationstyle_t(AValue)); -end; - -procedure TSkTextStyle.SetDecorationThickness(const AValue: Single); -begin - sk4d_textstyle_set_decoration_thickness(Handle, AValue); -end; - -procedure TSkTextStyle.SetFontFamilies(const AValue: TArray); -begin - TSkBindings.SetStrings(Handle, AValue, - procedure (const AHandle: THandle; const AStrings: PMarshaledAString) - begin - sk4d_textstyle_set_font_families(AHandle, AStrings, Length(AValue)); - end); -end; - -procedure TSkTextStyle.SetFontSize(const AValue: Single); -begin - sk4d_textstyle_set_font_size(Handle, AValue); -end; - -procedure TSkTextStyle.SetFontStyle(const AValue: TSkFontStyle); -begin - sk4d_textstyle_set_font_style(Handle, @sk_fontstyle_t(AValue)); -end; - -procedure TSkTextStyle.SetForegroundColor(const APaint: ISkPaint); -begin - if not Assigned(APaint) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['APaint']); - sk4d_textstyle_set_foreground_color(Handle, APaint.Handle); -end; - -procedure TSkTextStyle.SetHalfLeading(const AValue: Boolean); -begin - sk4d_textstyle_set_half_leading(Handle, AValue); -end; - -procedure TSkTextStyle.SetHeightMultiplier(const AValue: Single); -begin - sk4d_textstyle_set_height_multiplier(Handle, AValue); -end; - -procedure TSkTextStyle.SetLetterSpacing(const AValue: Single); -begin - sk4d_textstyle_set_letter_spacing(Handle, AValue); -end; - -procedure TSkTextStyle.SetLocale(const AValue: string); -var - LMarshaller: TMarshaller; -begin - if AValue.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AValue']); - sk4d_textstyle_set_locale(Handle, LMarshaller.AsUtf8(AValue).ToPointer); -end; - -procedure TSkTextStyle.SetWordSpacing(const AValue: Single); -begin - sk4d_textstyle_set_word_spacing(Handle, AValue); -end; - -class procedure TSkTextStyle.__DestroyHandle(const AHandle: THandle); -begin - sk4d_textstyle_destroy(AHandle); -end; - -{ TSkTypefaceFontProvider } - -constructor TSkTypefaceFontProvider.Create; -begin - inherited Create(sk4d_typefacefontprovider_create()); -end; - -procedure TSkTypefaceFontProvider.RegisterTypeface( - const ATypeface: ISkTypeface); -begin - if not Assigned(ATypeface) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATypeface']); - sk4d_typefacefontprovider_register_typeface(Handle, ATypeface.Handle); -end; - -procedure TSkTypefaceFontProvider.RegisterTypeface(const ATypeface: ISkTypeface; - const AFamilyName: string); -var - LMarshaller: TMarshaller; -begin - if not Assigned(ATypeface) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ATypeface']); - if AFamilyName.IsEmpty then - raise ESkArgumentException.CreateFmt(SParamIsEmpty, ['AFamilyName']); - sk4d_typefacefontprovider_register_typeface2(Handle, ATypeface.Handle, LMarshaller.AsUtf8(AFamilyName).ToPointer); -end; - -{ TSkResourceProviderBaseClass } - -class constructor TSkResourceProviderBaseClass.Create; -var - LProcs: sk_resourceproviderbaseclass_procs_t; -begin - LProcs.load := load_proc; - sk4d_resourceproviderbaseclass_set_procs(@LProcs); -end; - -constructor TSkResourceProviderBaseClass.Create(const APredecode: Boolean); -begin - inherited Create(sk4d_resourceproviderbaseclass_create(APredecode, Self)); -end; - -class function TSkResourceProviderBaseClass.load_proc(context: Pointer; - const path, name: MarshaledAString): sk_data_t; -begin - Result := TSkObject.__ReleaseHandle(TSkData.MakeFromBytes(TSkResourceProviderBaseClass(context).Load(string(path), string(name)))); -end; - -{ TSkFileResourceProvider } - -constructor TSkFileResourceProvider.Create(const APredecode: Boolean); -begin - Create(TPath.GetDocumentsPath, APredecode); -end; - -constructor TSkFileResourceProvider.Create(const ABaseDir: string; - const APredecode: Boolean); -begin - inherited Create(APredecode); - FBaseDir := ABaseDir; -end; - -function TSkFileResourceProvider.Load(const APath, AName: string): TBytes; -var - LFileName: string; -begin - LFileName := TPath.Combine(TPath.Combine(FBaseDir, APath), AName); - if TFile.Exists(LFileName) then - Result := TFile.ReadAllBytes(LFileName) - else - Result := nil; -end; - -{ TSkShaper } - -constructor TSkShaper.Create; -begin - inherited Create(sk4d_shaper_create()); -end; - -function TSkShaper.Shape(const AText: string; const AFont: ISkFont; - const ALeftToRight: Boolean; const AWidth: Single): ISkTextBlob; -var - LMarshaller: TMarshaller; -begin - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - Result := TSkBindings.SafeCreate(sk4d_shaper_shape(Handle, LMarshaller.AsUtf8(AText).ToPointer, AFont.Handle, ALeftToRight, AWidth, nil, nil)); -end; - -function TSkShaper.Shape(const AText: string; const AFont: ISkFont; - const ALeftToRight: Boolean; const AWidth: Single; const AOffset: TPointF; - out AEndPoint: TPointF): ISkTextBlob; -var - LMarshaller: TMarshaller; -begin - if not Assigned(AFont) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['AFont']); - Result := TSkBindings.SafeCreate(sk4d_shaper_shape(Handle, LMarshaller.AsUtf8(AText).ToPointer, AFont.Handle, ALeftToRight, AWidth, @sk_point_t(AOffset), @sk_point_t(AEndPoint))); -end; - -class procedure TSkShaper.__DestroyHandle(const AHandle: THandle); -begin - sk4d_shaper_destroy(AHandle); -end; - -{ TSkSVGCanvas } - -class function TSkSVGCanvas.Make(const ABounds: TRectF; const AStream: TStream; - const AFlags: TSkSVGCanvasFlags): ISkCanvas; -var - LCanvas: TSkSVGCanvas; - LHandle: THandle; - LWStream: ISkWStream; -begin - LWStream := TSkWStreamAdapter.Create(AStream); - LHandle := sk4d_svgcanvas_make(@sk_rect_t(ABounds), LWStream.Handle, Byte(AFlags)); - if LHandle = 0 then - Exit(nil); - LCanvas := TSkSVGCanvas.Wrap(LHandle); - LCanvas.FHolder := LWStream; - Result := LCanvas; -end; - -{ TSkSVGDOM } - -function TSkSVGDOM.FindNodeById(const AId: string): ISkSVGNode; -var - LMarshaller: TMarshaller; -begin - Result := TSkBindings.SafeCreate(sk4d_svgdom_find_node_by_id(Handle, LMarshaller.AsUtf8(AId).ToPointer), False); -end; - -function TSkSVGDOM.GetRoot: ISkSVGSVG; -begin - if not Assigned(FRoot) then - FRoot := TSkBindings.SafeCreate(sk4d_svgdom_get_root(Handle), False); - Result := FRoot; -end; - -class function TSkSVGDOM.Make(const AData: string; - const AResourceProvider: ISkResourceProvider): ISkSVGDOM; -var - LStream: TStream; -begin - LStream := TStringStream.Create(AData, TEncoding.UTF8); - try - Result := MakeFromStream(LStream, AResourceProvider); - finally - LStream.Free; - end; -end; - -class function TSkSVGDOM.MakeFromFile(const AFileName: string): ISkSVGDOM; -var - LMarshaller: TMarshaller; -begin - if AFileName.IsEmpty then - raise ESkException.Create(SFileNameIsEmpty); - Result := TSkBindings.SafeCreate(sk4d_svgdom_make_from_file(LMarshaller.AsUtf8(AFileName).ToPointer)); -end; - -class function TSkSVGDOM.MakeFromStream(const AStream: TStream; - const AResourceProvider: ISkResourceProvider): ISkSVGDOM; -var - LStream: ISkStream; -begin - LStream := TSkStreamAdapter.Create(AStream); - Result := TSkBindings.SafeCreate(sk4d_svgdom_make_from_stream(LStream.Handle, TSkBindings.SafeHandle(AResourceProvider))); -end; - -procedure TSkSVGDOM.Render(const ACanvas: ISkCanvas); -begin - if not Assigned(ACanvas) then - raise ESkArgumentException.CreateFmt(SParamIsNil, ['ACanvas']); - sk4d_svgdom_render(Handle, ACanvas.Handle); -end; - -procedure TSkSVGDOM.SetContainerSize(const ASize: TSizeF); -begin - sk4d_svgdom_set_container_size(Handle, @sk_size_t(ASize)); -end; - -{ TSkSVGNode } - -function TSkSVGNode.TrySetAttribute(const AName, AValue: string): Boolean; -var - LMarshaller: TMarshaller; -begin - Result := sk4d_svgnode_set_attribute(Handle, LMarshaller.AsUtf8(AName).ToPointer, LMarshaller.AsUtf8(AValue).ToPointer); -end; - -{ TSkSVGSVG } - -function TSkSVGSVG.GetHeight: TSkSVGLength; -begin - sk4d_svgsvg_get_height(Handle, sk_svglength_t(Result)); -end; - -function TSkSVGSVG.GetIntrinsicSize(const AViewPort: TSizeF; - const ADPI: Single): TSizeF; -begin - sk4d_svgsvg_get_intrinsic_size(Handle, @sk_size_t(AViewPort), ADPI, sk_size_t(Result)); -end; - -function TSkSVGSVG.GetPreserveAspectRatio: TSkSVGPreserveAspectRatio; -begin - sk4d_svgsvg_get_preserve_aspect_ratio(Handle, sk_svgpreserveaspectratio_t(Result)); -end; - -function TSkSVGSVG.GetWidth: TSkSVGLength; -begin - sk4d_svgsvg_get_width(Handle, sk_svglength_t(Result)); -end; - -function TSkSVGSVG.GetX: TSkSVGLength; -begin - sk4d_svgsvg_get_x(Handle, sk_svglength_t(Result)); -end; - -function TSkSVGSVG.GetY: TSkSVGLength; -begin - sk4d_svgsvg_get_y(Handle, sk_svglength_t(Result)); -end; - -procedure TSkSVGSVG.SetHeight(const AValue: TSkSVGLength); -begin - sk4d_svgsvg_set_height(Handle, @sk_svglength_t(AValue)); -end; - -procedure TSkSVGSVG.SetPreserveAspectRatio( - const AValue: TSkSVGPreserveAspectRatio); -begin - sk4d_svgsvg_set_preserve_aspect_ratio(Handle, @sk_svgpreserveaspectratio_t(AValue)); -end; - -procedure TSkSVGSVG.SetViewBox(const AViewBox: TRectF); -begin - sk4d_svgsvg_set_view_box(Handle, @sk_rect_t(AViewBox)); -end; - -procedure TSkSVGSVG.SetWidth(const AValue: TSkSVGLength); -begin - sk4d_svgsvg_set_width(Handle, @sk_svglength_t(AValue)); -end; - -procedure TSkSVGSVG.SetX(const AValue: TSkSVGLength); -begin - sk4d_svgsvg_set_x(Handle, @sk_svglength_t(AValue)); -end; - -procedure TSkSVGSVG.SetY(const AValue: TSkSVGLength); -begin - sk4d_svgsvg_set_y(Handle, @sk_svglength_t(AValue)); -end; - -function TSkSVGSVG.TryGetViewBox(out AViewBox: TRectF): Boolean; -begin - Result := sk4d_svgsvg_get_view_box(Handle, sk_rect_t(AViewBox)); -end; - -{ TSkUnicode } - -class procedure TSkUnicode.bidi_region_proc(start, &end: int32_t; - level: uint8_t; context: Pointer); -begin - TSkUnicodeBidiRegionProc(context^)(start, &end, level); -end; - -class procedure TSkUnicode.break_proc(position, status: int32_t; - context: Pointer); -begin - TSkUnicodeBreakProc(context^)(position, status); -end; - -class procedure TSkUnicode.codepoint_proc(unichar: sk_unichar_t; start, - &end: int32_t; context: Pointer); -begin - TSkUnicodeCodepointProc(context^)(unichar, start, &end); -end; - -constructor TSkUnicode.Create; -begin - inherited Create(sk4d_unicode_create()); -end; - -procedure TSkUnicode.ForEachBidiRegion(const AText: string; - const ADirection: TSkDirection; const AProc: TSkUnicodeBidiRegionProc); -begin - if (not AText.IsEmpty) and (Assigned(AProc)) then - sk4d_unicode_for_each_bidi_region(Handle, @AText[Low(AText)], Length(AText), sk_direction_t(ADirection), bidi_region_proc, @AProc); -end; - -procedure TSkUnicode.ForEachBreak(const AText: string; - const AType: TSkBreakType; const AProc: TSkUnicodeBreakProc); -begin - if (not AText.IsEmpty) and (Assigned(AProc)) then - sk4d_unicode_for_each_break(Handle, @AText[Low(AText)], Length(AText), sk_breaktype_t(AType), break_proc, @AProc); -end; - -procedure TSkUnicode.ForEachCodepoint(const AText: string; - const AProc: TSkUnicodeCodepointProc); -begin - if (not AText.IsEmpty) and (Assigned(AProc)) then - sk4d_unicode_for_each_codepoint(Handle, @AText[Low(AText)], Length(AText), codepoint_proc, @AProc); -end; - -function TSkUnicode.GetBreakIterator(const AType: TSkBreakType; - const AText: string): ISkUnicodeBreakIterator; -begin - Result := TUnicodeBreakIterator.Create(Self, AType, AText); -end; - -function TSkUnicode.GetBreakIteratorUTF8(const AType: TSkBreakType; - const AText: UTF8String): ISkUnicodeBreakIterator; -begin - Result := TUnicodeBreakIterator.Create(Self, AType, AText); -end; - -function TSkUnicode.GetBreaks(const AText: string; - const AType: TSkBreakType): TArray; -var - LPStartIndex: PInteger; - LResult: TList; - LStartIndex: Integer; -begin - LStartIndex := 0; - LPStartIndex := @LStartIndex; - LResult := TList.Create; - try - ForEachBreak(AText, TSkBreakType.Graphemes, - procedure (const APosition, AStatus: Integer) - begin - if APosition = 0 then - Exit; - LResult.Add(AText.Substring(LPStartIndex^, APosition - LPStartIndex^)); - LPStartIndex^ := APosition; - end); - Result := LResult.ToArray; - finally - LResult.Free; - end; -end; - -class procedure TSkUnicode.__DestroyHandle(const AHandle: THandle); -begin - sk4d_unicode_destroy(AHandle); -end; - -function ExtensionToEncodedImageFormat(const AExtension: string): TSkEncodedImageFormat; -begin - if (string.Compare('.jpg', AExtension, [TCompareOption.coIgnoreCase]) = 0) or (string.Compare('.jpeg', AExtension, [TCompareOption.coIgnoreCase]) = 0) then - Result := TSkEncodedImageFormat.JPEG - else if string.Compare('.webp', AExtension, [TCompareOption.coIgnoreCase]) = 0 then - Result := TSkEncodedImageFormat.WEBP - else if string.Compare('.png', AExtension, [TCompareOption.coIgnoreCase]) = 0 then - Result := TSkEncodedImageFormat.PNG - else - raise ESkArgumentException.Create('Invalid extension'); -end; - -{ TSkUnicode.TUnicodeBreakIterator } - -constructor TSkUnicode.TUnicodeBreakIterator.Create(const AUnicode: ISkUnicode; - const AType: TSkBreakType; const AText: string); -var - LText: pchar16_t; -begin - if Length(AText) = 0 then - LText := nil - else - LText := @AText[Low(AText)]; - inherited Create(sk4d_unicodebreakiterator_create2(AUnicode.Handle, sk_breaktype_t(AType), LText, Length(AText))); -end; - -constructor TSkUnicode.TUnicodeBreakIterator.Create(const AUnicode: ISkUnicode; - const AType: TSkBreakType; const AText: UTF8String); -var - LText: _pchar; -begin - if Length(AText) = 0 then - LText := nil - else - LText := @AText[Low(AText)]; - inherited Create(sk4d_unicodebreakiterator_create(AUnicode.Handle, sk_breaktype_t(AType), LText, Length(AText))); -end; - -function TSkUnicode.TUnicodeBreakIterator.GetCurrent: TSkUnicodeBreakIteratorElem; -begin - Result := FCurrent; -end; - -function TSkUnicode.TUnicodeBreakIterator.MoveNext: Boolean; -begin - Result := sk4d_unicodebreakiterator_next(Handle, sk_unicodebreakiteratorelem_t(FCurrent)); -end; - -class procedure TSkUnicode.TUnicodeBreakIterator.__DestroyHandle( - const AHandle: THandle); -begin - sk4d_unicodebreakiterator_destroy(AHandle); -end; - -{ TSkBindings } - -class function TSkBindings.AsDateTime(const AValue: TDateTime): sk_datetime_t; -var - LDay: Word; - LHour: Word; - LMilliSecond: Word; - LMinute: Word; - LMonth: Word; - LSecond: Word; - LYear: Word; -begin - DecodeDateTime(AValue, LYear, LMonth, LDay, LHour, LMinute, LSecond, LMilliSecond); - Result.time_zone_minutes := Round(TTimeZone.Local.UtcOffset.TotalMinutes); - Result.year := LYear; - Result.month := LMonth; - Result.day_of_week := DayOfWeek(AValue) - 1; - Result.day := LDay; - Result.hour := LHour; - Result.minute := LMinute; - Result.second := LSecond; -end; - -class function TSkBindings.AsGrContextOptions( - const AValue: TGrContextOptions): gr_contextoptions_t; -begin - Result.buffer_map_threshold := AValue.BufferMapThreshold; - Result.do_manual_mipmapping := AValue.DoManualMipmapping; - Result.allow_path_mask_caching := AValue.AllowPathMaskCaching; - Result.glyph_cache_texture_maximum_bytes := AValue.GlyphCacheTextureMaximumBytes; - Result.avoid_stencil_buffers := AValue.AvoidStencilBuffers; - Result.runtime_program_cache_size := AValue.RuntimeProgramCacheSize; - Result.persistent_cache := TSkBindings.SafeHandle(AValue.PersistentCache); - Result.shader_cache_strategy := gr_shadercachestrategy_t(AValue.ShaderCacheStrategy); - Result.shader_error_handler := TSkBindings.SafeHandle(AValue.ShaderErrorHandler); -end; - -class function TSkBindings.AsGrVkAlloc(const AValue: TGrVkAlloc): gr_vk_alloc_t; -begin - Result.device_memory := AValue.DeviceMemory; - Result.offset := AValue.Offset; - Result.size := AValue.Size; - Result.flags := Byte(AValue.Flags); - Result.memory := AValue.Memory; -end; - -class function TSkBindings.AsGrVkBackendContext( - const AValue: TGrVkBackendContext): gr_vk_backendcontext_t; -begin - Result.instance := AValue.Instance; - Result.physical_device := AValue.PhysicalDevice; - Result.device := AValue.Device; - Result.queue := AValue.Queue; - Result.graphics_queue_index := AValue.GraphicsQueueIndex; - Result.max_version := AValue.MaxVersion; - Result.extensions := TSkBindings.SafeHandle(AValue.Extensions); - Result.physical_device_features := THandle(AValue.PhysicalDeviceFeatures); - Result.physical_device_features2 := THandle(AValue.PhysicalDeviceFeatures2); - Result.get_proc := __gr_vk_get_proc; - Result.protected_context := AValue.ProtectedContext; - if Assigned(AValue.GetProc) then - Result.get_context := @AValue.GetProc - else - Result.get_context := nil; -end; - -class function TSkBindings.AsGrVkImageInfo( - const AValue: TGrVkImageInfo): gr_vk_imageinfo_t; -begin - Result.image := AValue.Image; - Result.alloc := AsGrVkAlloc(AValue.Alloc); - Result.image_tiling := AValue.ImageTiling; - Result.image_layout := AValue.ImageLayout; - Result.format := AValue.Format; - Result.image_usage_flags := AValue.ImageUsageFlags; - Result.sample_count := AValue.SampleCount; - Result.level_count := AValue.LevelCount; - Result.current_queue_family := AValue.CurrentQueueFamily; - Result.protected_image := AValue.ProtectedImage; - Result.ycbcr_conversion_info := gr_vk_ycbcrconversioninfo_t(AValue.YcbcrConversionInfo); - Result.sharing_mode := AValue.SharingMode; -end; - -class function TSkBindings.AsImageInfo( - const AValue: TSkImageInfo): sk_imageinfo_t; -begin - Result.width := AValue.Width; - Result.height := AValue.Height; - Result.color_type := sk_colortype_t(AValue.ColorType); - Result.alpha_type := sk_alphatype_t(AValue.AlphaType); - Result.color_space := TSkBindings.SafeHandle(AValue.ColorSpace); -end; - -class function TSkBindings.AsLattice(const AValue: TSkLattice): sk_lattice_t; -begin - Result.x_divs := @AValue.FXDivs[0]; - Result.y_divs := @AValue.FYDivs[0]; - Result.x_count := Length(AValue.FXDivs); - Result.y_count := Length(AValue.FYDivs); - if Length(AValue.FRectTypes) > 0 then - begin - Result.rect_types := @AValue.FRectTypes[0]; - Result.colors := @AValue.FColors[0]; - end - else - begin - Result.rect_types := nil; - Result.colors := nil; - end; - if AValue.FUseBounds then - Result.bounds := @sk_irect_t(AValue.FBounds) - else - Result.bounds := nil; -end; - -class function TSkBindings.AsPDFMetadata( - const AValue: TSkPDFMetadata): sk_pdfmetadata_t; -var - LMarshaller: TMarshaller; -begin - Result.title := LMarshaller.AsUtf8(AValue.Title).ToPointer; - Result.author := LMarshaller.AsUtf8(AValue.Author).ToPointer; - Result.subject := LMarshaller.AsUtf8(AValue.Subject).ToPointer; - Result.keywords := LMarshaller.AsUtf8(AValue.Keywords).ToPointer; - Result.creator := LMarshaller.AsUtf8(AValue.Creator).ToPointer; - Result.producer := LMarshaller.AsUtf8(AValue.Producer).ToPointer; - Result.creation := TSkBindings.AsDateTime(AValue.Creation); - Result.modified := TSkBindings.AsDateTime(AValue.Modified); - Result.raster_dpi := AValue.RasterDPI; - Result.pdfa := AValue.PDFA; - Result.encoding_quality := AValue.EncodingQuality; -end; - -class function TSkBindings.AsSurfaceProperties( - const AValue: TSkSurfaceProperties): sk_surfaceprops_t; -begin - Result.flags := Byte(AValue.Flags); - Result.pixel_geometry := sk_pixelgeometry_t(AValue.PixelGeometry); -end; - -class function TSkBindings.GetStrings(const AHandle: THandle; - const AFunc: TSkGetStringsFunc): TArray; -var - I: Integer; - LMarshaledAStrings: TArray; -begin - SetLength(LMarshaledAStrings, AFunc(AHandle, nil)); - if Length(LMarshaledAStrings) = 0 then - Result := nil - else - begin - AFunc(AHandle, @LMarshaledAStrings[0]); - SetLength(Result, Length(LMarshaledAStrings)); - for I := 0 to Length(LMarshaledAStrings) - 1 do - Result[I] := string(LMarshaledAStrings[I]); - end; -end; - -class function TSkBindings.SafeCreate(const AHandle: THandle; - const AOwnsHandle: Boolean): T; -begin - if AHandle = 0 then - Exit(nil); - Result := T.Wrap(AHandle, AOwnsHandle); -end; - -class function TSkBindings.SafeHandle(const AObject: ISkObject): THandle; -begin - if not Assigned(AObject) then - Exit(0); - Result := AObject.Handle; -end; - -class procedure TSkBindings.SetStrings(const AHandle: THandle; const AStrings1, - AStrings2: TArray; const AProc: TSkSetTwoStringsProc); -var - I: Integer; - LMarshaller: TMarshaller; - LPStrings1: PMarshaledAString; - LPStrings2: PMarshaledAString; - LStrings1: TArray; - LStrings2: TArray; -begin - if Length(AStrings1) = 0 then - LPStrings1 := nil - else - begin - SetLength(LStrings1, Length(AStrings1)); - for I := 0 to Length(AStrings1) - 1 do - LStrings1[I] := LMarshaller.AsUtf8(AStrings1[I]).ToPointer; - LPStrings1 := @LStrings1[0]; - end; - if Length(AStrings2) = 0 then - LPStrings2 := nil - else - begin - SetLength(LStrings2, Length(AStrings2)); - for I := 0 to Length(AStrings2) - 1 do - LStrings2[I] := LMarshaller.AsUtf8(AStrings2[I]).ToPointer; - LPStrings2 := @LStrings2[0]; - end; - AProc(AHandle, LPStrings1, LPStrings2); -end; - -class procedure TSkBindings.SetStrings(const AHandle: THandle; - const AStrings: TArray; const AProc: TSkSetStringsProc); -var - I: Integer; - LMarshaller: TMarshaller; - LStrings: TArray; -begin - if Length(AStrings) = 0 then - AProc(AHandle, nil) - else - begin - SetLength(LStrings, Length(AStrings)); - for I := 0 to Length(AStrings) - 1 do - LStrings[I] := LMarshaller.AsUtf8(AStrings[I]).ToPointer; - AProc(AHandle, @LStrings[0]); - end; -end; - -class function TSkBindings.ToFontMetrics( - const AValue: sk_fontmetrics_t): TSkFontMetrics; -begin - Result.Flags := TSkFontMetricsFlags(Byte(AValue.flags)); - Result.Top := AValue.top; - Result.Ascent := AValue.ascent; - Result.Descent := AValue.descent; - Result.Bottom := AValue.bottom; - Result.Leading := AValue.leading; - Result.AvgCharWidth := AValue.avg_char_width; - Result.MaxCharWidth := AValue.max_char_width; - Result.XMin := AValue.x_min; - Result.XMax := AValue.x_max; - Result.XHeight := AValue.x_height; - Result.CapHeight := AValue.cap_height; - Result.UnderlineThickness := AValue.underline_thickness; - Result.UnderlinePosition := AValue.underline_position; - Result.StrikeoutThickness := AValue.strikeout_thickness; - Result.StrikeoutPosition := AValue.strikeout_position; -end; - -class function TSkBindings.ToImageInfo( - const AValue: sk_imageinfo_t): TSkImageInfo; -begin - Result.Width := AValue.width; - Result.Height := AValue.height; - Result.ColorType := TSkColorType(AValue.color_type); - Result.AlphaType := TSkAlphaType(AValue.alpha_type); - Result.ColorSpace := TSkBindings.SafeCreate(AValue.color_space); -end; - -class function TSkBindings.ToParagraphVisitorInfo( - const AValue: sk_paragraphvisitorinfo_t): TSkParagraphVisitorInfo; -begin - Result.Font := TSkFont.Wrap(AValue.font, False); - Result.Origin := TPointF(AValue.origin); - Result.AdvanceX := AValue.advance_x; - Result.Count := AValue.count; - Result.Glyphs := PWordArray(AValue.glyphs); - Result.Positions := PPointFArray(AValue.positions); - Result.Utf8Starts := PCardinalArray(AValue.utf8_starts); - Result.Flags := TSkParagraphVisitorFlags(Byte(AValue.flags)); -end; - -class function TSkBindings.ToSurfaceProperties( - const AValue: sk_surfaceprops_t): TSkSurfaceProperties; -begin - Result.Flags := TSkSurfacePropertiesFlags(Byte(AValue.flags)); - Result.PixelGeometry := TSkPixelGeometry(AValue.pixel_geometry); -end; - -class function TSkBindings.__gr_gl_get_proc(context: Pointer; - const name: MarshaledAString): Pointer; -begin - Result := TGrGlGetProc(context^)(string(name)); -end; - -class function TSkBindings.__gr_vk_get_proc(context: Pointer; - const name: MarshaledAString; instance: gr_vk_instance_t; - device: gr_vk_device_t): Pointer; -begin - Result := TGrVkGetProc(context^)(string(name), instance, device); -end; - -{ TSkDelegate } - -class procedure TSkDelegate.Finalize(const AContextProc: Pointer); -begin - Dispose(PProcWrapper(AContextProc)); -end; - -class function TSkDelegate.Initialize(const AProc: T; - const AInitializeFunc: TSkDelegateInitializeFunc): I; -var - LProcWrapper: PProcWrapper; -begin - New(LProcWrapper); - try - LProcWrapper.Proc := AProc; - Result := AInitializeFunc(LProcWrapper); - if not Assigned(Result) then - Dispose(LProcWrapper); - except - Dispose(LProcWrapper); - raise; - end; -end; - -class procedure TSkDelegate.Invoke(const AContextProc: Pointer; - const AInvokeProc: TSkDelegateInvokeProc); -begin - AInvokeProc(PProcWrapper(AContextProc).Proc) -end; - -{ TSkData } - -class function TSkData.MakeFromBytes(const ABytes: TBytes): ISkData; -begin - if Length(ABytes) = 0 then - Result := TSkBindings.SafeCreate(sk4d_data_make_empty()) - else - Result := TSkBindings.SafeCreate(sk4d_data_make_with_copy(@ABytes[0], Length(ABytes))); -end; - -class procedure TSkData.__RefHandle(const AHandle: THandle); -begin - sk4d_data_ref(AHandle); -end; - -class procedure TSkData.__UnrefHandle(const AHandle: THandle); -begin - sk4d_data_unref(AHandle); -end; - -{ TSkStreamAdapter } - -class constructor TSkStreamAdapter.Create; -var - LProcs: sk_streamadapter_procs_t; -begin - LProcs.get_length := get_length_proc; - LProcs.get_position := get_position_proc; - LProcs.read := read_proc; - LProcs.seek := seek_proc; - sk4d_streamadapter_set_procs(@LProcs); -end; - -constructor TSkStreamAdapter.Create(const AStream: TStream); -begin - inherited Create(sk4d_streamadapter_create(AStream)); -end; - -class function TSkStreamAdapter.get_length_proc(context: Pointer): size_t; -begin - Result := TStream(context).Size; -end; - -class function TSkStreamAdapter.get_position_proc(context: Pointer): size_t; -begin - Result := TStream(context).Position; -end; - -class function TSkStreamAdapter.read_proc(context, buffer: Pointer; - size: size_t): size_t; -begin - Result := TStream(context).Read(buffer^, size); -end; - -class function TSkStreamAdapter.seek_proc(context: Pointer; - position: size_t): _bool; -begin - TStream(context).Position := position; - Result := True; -end; - -class procedure TSkStreamAdapter.__DestroyHandle(const AHandle: THandle); -begin - sk4d_streamadapter_destroy(AHandle); -end; - -{ TSkWStreamAdapter } - -class constructor TSkWStreamAdapter.Create; -var - LProcs: sk_wstreamadapter_procs_t; -begin - LProcs.write := write_proc; - sk4d_wstreamadapter_set_procs(@LProcs); -end; - -constructor TSkWStreamAdapter.Create(const AStream: TStream); -begin - inherited Create(sk4d_wstreamadapter_create(AStream)); -end; - -class function TSkWStreamAdapter.write_proc(context: Pointer; - const buffer: Pointer; size: size_t): _bool; -begin - TStream(context).Write(buffer^, size); - Result := True; -end; - -class procedure TSkWStreamAdapter.__DestroyHandle(const AHandle: THandle); -begin - sk4d_wstreamadapter_destroy(AHandle); -end; - -{ TSkString } - -constructor TSkString.Create; -begin - inherited Create(sk4d_string_create()); -end; - -function TSkString.GetText: string; -begin - Result := string(sk4d_string_get_text(Handle)); -end; - -class procedure TSkString.__DestroyHandle(const AHandle: THandle); -begin - sk4d_string_destroy(AHandle); -end; - -{$HPPEMIT NOUSINGNAMESPACE} -{$HPPEMIT END '#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_SKIA)'} -{$HPPEMIT END ' using ::Skia::_di_IGrBackendRenderTarget;'} -{$HPPEMIT END ' using ::Skia::_di_IGrBackendTexture;'} -{$HPPEMIT END ' using ::Skia::_di_IGrDirectContext;'} -{$HPPEMIT END ' using ::Skia::_di_IGrGlInterface;'} -{$HPPEMIT END ' using ::Skia::_di_IGrPersistentCache;'} -{$HPPEMIT END ' using ::Skia::_di_IGrShaderErrorHandler;'} -{$HPPEMIT END ' using ::Skia::_di_IGrVkExtensions;'} -{$HPPEMIT END ' using ::Skia::_di_ISkAnimationCodecPlayer;'} -{$HPPEMIT END ' using ::Skia::_di_ISkBlender;'} -{$HPPEMIT END ' using ::Skia::_di_ISkCanvas;'} -{$HPPEMIT END ' using ::Skia::_di_ISkCodec;'} -{$HPPEMIT END ' using ::Skia::_di_ISkColorFilter;'} -{$HPPEMIT END ' using ::Skia::_di_ISkColorSpace;'} -{$HPPEMIT END ' using ::Skia::_di_ISkColorSpaceICCProfile;'} -{$HPPEMIT END ' using ::Skia::_di_ISkDocument;'} -{$HPPEMIT END ' using ::Skia::_di_ISkEnumerable;'} -{$HPPEMIT END ' using ::Skia::_di_ISkFileResourceProvider;'} -{$HPPEMIT END ' using ::Skia::_di_ISkFont;'} -{$HPPEMIT END ' using ::Skia::_di_ISkImage;'} -{$HPPEMIT END ' using ::Skia::_di_ISkImageFilter;'} -{$HPPEMIT END ' using ::Skia::_di_ISkMaskFilter;'} -{$HPPEMIT END ' using ::Skia::_di_ISkNonVirtualReferenceCounted;'} -{$HPPEMIT END ' using ::Skia::_di_ISkObject;'} -{$HPPEMIT END ' using ::Skia::_di_ISkOpBuilder;'} -{$HPPEMIT END ' using ::Skia::_di_ISkottieAnimation;'} -{$HPPEMIT END ' using ::Skia::_di_ISkPaint;'} -{$HPPEMIT END ' using ::Skia::_di_ISkParagraph;'} -{$HPPEMIT END ' using ::Skia::_di_ISkParagraphBuilder;'} -{$HPPEMIT END ' using ::Skia::_di_ISkParagraphStyle;'} -{$HPPEMIT END ' using ::Skia::_di_ISkParticleEffect;'} -{$HPPEMIT END ' using ::Skia::_di_ISkPath;'} -{$HPPEMIT END ' using ::Skia::_di_ISkPathBuilder;'} -{$HPPEMIT END ' using ::Skia::_di_ISkPathEffect;'} -{$HPPEMIT END ' using ::Skia::_di_ISkPathIterator;'} -{$HPPEMIT END ' using ::Skia::_di_ISkPathMeasure;'} -{$HPPEMIT END ' using ::Skia::_di_ISkPicture;'} -{$HPPEMIT END ' using ::Skia::_di_ISkPictureRecorder;'} -{$HPPEMIT END ' using ::Skia::_di_ISkPixmap;'} -{$HPPEMIT END ' using ::Skia::_di_ISkReferenceCounted;'} -{$HPPEMIT END ' using ::Skia::_di_ISkRegion;'} -{$HPPEMIT END ' using ::Skia::_di_ISkRegionCliperator;'} -{$HPPEMIT END ' using ::Skia::_di_ISkRegionIterator;'} -{$HPPEMIT END ' using ::Skia::_di_ISkRegionSpanerator;'} -{$HPPEMIT END ' using ::Skia::_di_ISkResourceProvider;'} -{$HPPEMIT END ' using ::Skia::_di_ISkRoundRect;'} -{$HPPEMIT END ' using ::Skia::_di_ISkRuntimeEffect;'} -{$HPPEMIT END ' using ::Skia::_di_ISkShader;'} -{$HPPEMIT END ' using ::Skia::_di_ISkShaper;'} -{$HPPEMIT END ' using ::Skia::_di_ISkStrutStyle;'} -{$HPPEMIT END ' using ::Skia::_di_ISkSurface;'} -{$HPPEMIT END ' using ::Skia::_di_ISkSVGDOM;'} -{$HPPEMIT END ' using ::Skia::_di_ISkSVGNode;'} -{$HPPEMIT END ' using ::Skia::_di_ISkSVGSVG;'} -{$HPPEMIT END ' using ::Skia::_di_ISkTextBlob;'} -{$HPPEMIT END ' using ::Skia::_di_ISkTextStyle;'} -{$HPPEMIT END ' using ::Skia::_di_ISkTraceMemoryDump;'} -{$HPPEMIT END ' using ::Skia::_di_ISkTypeface;'} -{$HPPEMIT END ' using ::Skia::_di_ISkTypefaceFontProvider;'} -{$HPPEMIT END ' using ::Skia::_di_ISkUnicode;'} -{$HPPEMIT END ' using ::Skia::_di_ISkUnicodeBreakIterator;'} -{$HPPEMIT END ' using ::Skia::_di_ISkVertices;'} -{$HPPEMIT END ' using ::Skia::_di_TGrGlGetProc;'} -{$HPPEMIT END ' using ::Skia::_di_TGrVkGetProc;'} -{$HPPEMIT END ' using ::Skia::_di_TSkFontPathProc;'} -{$HPPEMIT END ' using ::Skia::_di_TSkImageRasterReleaseProc;'} -{$HPPEMIT END ' using ::Skia::_di_TSkImageTextureReleaseProc;'} -{$HPPEMIT END ' using ::Skia::_di_TSkParagraphVisitProc;'} -{$HPPEMIT END ' using ::Skia::_di_TSkSurfaceRasterReleaseProc;'} -{$HPPEMIT END ' using ::Skia::_di_TSkUnicodeBidiRegionProc;'} -{$HPPEMIT END ' using ::Skia::_di_TSkUnicodeBreakProc;'} -{$HPPEMIT END ' using ::Skia::_di_TSkUnicodeCodepointProc;'} -{$HPPEMIT END ' using ::Skia::ESkArgumentException;'} -{$HPPEMIT END ' using ::Skia::ESkException;'} -{$HPPEMIT END ' using ::Skia::GrGlenum;'} -{$HPPEMIT END ' using ::Skia::GrGluint;'} -{$HPPEMIT END ' using ::Skia::GrMtlHandle;'} -{$HPPEMIT END ' using ::Skia::GrVkBool32;'} -{$HPPEMIT END ' using ::Skia::GrVkChromaLocation;'} -{$HPPEMIT END ' using ::Skia::GrVkDevice;'} -{$HPPEMIT END ' using ::Skia::GrVkDeviceMemory;'} -{$HPPEMIT END ' using ::Skia::GrVkDeviceSize;'} -{$HPPEMIT END ' using ::Skia::GrVkFilter;'} -{$HPPEMIT END ' using ::Skia::GrVkFormat;'} -{$HPPEMIT END ' using ::Skia::GrVkFormatFeatureFlags;'} -{$HPPEMIT END ' using ::Skia::GrVkImage;'} -{$HPPEMIT END ' using ::Skia::GrVkImageLayout;'} -{$HPPEMIT END ' using ::Skia::GrVkImageUsageFlags;'} -{$HPPEMIT END ' using ::Skia::GrVkInstance;'} -{$HPPEMIT END ' using ::Skia::GrVkPhysicalDevice;'} -{$HPPEMIT END ' using ::Skia::GrVkPhysicalDeviceFeatures;'} -{$HPPEMIT END ' using ::Skia::GrVkPhysicalDeviceFeatures2;'} -{$HPPEMIT END ' using ::Skia::GrVkQueue;'} -{$HPPEMIT END ' using ::Skia::GrVkSamplerYcbcrModelConversion;'} -{$HPPEMIT END ' using ::Skia::GrVkSharingMode;'} -{$HPPEMIT END ' using ::Skia::GrVkVkImageTiling;'} -{$HPPEMIT END ' using ::Skia::GrVkVkSamplerYcbcrRange;'} -{$HPPEMIT END ' using ::Skia::IGrBackendRenderTarget;'} -{$HPPEMIT END ' using ::Skia::IGrBackendTexture;'} -{$HPPEMIT END ' using ::Skia::IGrDirectContext;'} -{$HPPEMIT END ' using ::Skia::IGrGlInterface;'} -{$HPPEMIT END ' using ::Skia::IGrPersistentCache;'} -{$HPPEMIT END ' using ::Skia::IGrShaderErrorHandler;'} -{$HPPEMIT END ' using ::Skia::IGrVkExtensions;'} -{$HPPEMIT END ' using ::Skia::ISkAnimationCodecPlayer;'} -{$HPPEMIT END ' using ::Skia::ISkBlender;'} -{$HPPEMIT END ' using ::Skia::ISkCanvas;'} -{$HPPEMIT END ' using ::Skia::ISkCodec;'} -{$HPPEMIT END ' using ::Skia::ISkColorFilter;'} -{$HPPEMIT END ' using ::Skia::ISkColorSpace;'} -{$HPPEMIT END ' using ::Skia::ISkColorSpaceICCProfile;'} -{$HPPEMIT END ' using ::Skia::ISkDocument;'} -{$HPPEMIT END ' using ::Skia::ISkEnumerable;'} -{$HPPEMIT END ' using ::Skia::ISkFileResourceProvider;'} -{$HPPEMIT END ' using ::Skia::ISkFont;'} -{$HPPEMIT END ' using ::Skia::ISkImage;'} -{$HPPEMIT END ' using ::Skia::ISkImageFilter;'} -{$HPPEMIT END ' using ::Skia::ISkMaskFilter;'} -{$HPPEMIT END ' using ::Skia::ISkNonVirtualReferenceCounted;'} -{$HPPEMIT END ' using ::Skia::ISkObject;'} -{$HPPEMIT END ' using ::Skia::ISkOpBuilder;'} -{$HPPEMIT END ' using ::Skia::ISkottieAnimation;'} -{$HPPEMIT END ' using ::Skia::ISkPaint;'} -{$HPPEMIT END ' using ::Skia::ISkParagraph;'} -{$HPPEMIT END ' using ::Skia::ISkParagraphBuilder;'} -{$HPPEMIT END ' using ::Skia::ISkParagraphStyle;'} -{$HPPEMIT END ' using ::Skia::ISkParticleEffect;'} -{$HPPEMIT END ' using ::Skia::ISkPath;'} -{$HPPEMIT END ' using ::Skia::ISkPathBuilder;'} -{$HPPEMIT END ' using ::Skia::ISkPathEffect;'} -{$HPPEMIT END ' using ::Skia::ISkPathIterator;'} -{$HPPEMIT END ' using ::Skia::ISkPathMeasure;'} -{$HPPEMIT END ' using ::Skia::ISkPicture;'} -{$HPPEMIT END ' using ::Skia::ISkPictureRecorder;'} -{$HPPEMIT END ' using ::Skia::ISkPixmap;'} -{$HPPEMIT END ' using ::Skia::ISkReferenceCounted;'} -{$HPPEMIT END ' using ::Skia::ISkRegion;'} -{$HPPEMIT END ' using ::Skia::ISkRegionCliperator;'} -{$HPPEMIT END ' using ::Skia::ISkRegionIterator;'} -{$HPPEMIT END ' using ::Skia::ISkRegionSpanerator;'} -{$HPPEMIT END ' using ::Skia::ISkResourceProvider;'} -{$HPPEMIT END ' using ::Skia::ISkRoundRect;'} -{$HPPEMIT END ' using ::Skia::ISkRuntimeEffect;'} -{$HPPEMIT END ' using ::Skia::ISkShader;'} -{$HPPEMIT END ' using ::Skia::ISkShaper;'} -{$HPPEMIT END ' using ::Skia::ISkStrutStyle;'} -{$HPPEMIT END ' using ::Skia::ISkSurface;'} -{$HPPEMIT END ' using ::Skia::ISkSVGDOM;'} -{$HPPEMIT END ' using ::Skia::ISkSVGNode;'} -{$HPPEMIT END ' using ::Skia::ISkSVGSVG;'} -{$HPPEMIT END ' using ::Skia::ISkTextBlob;'} -{$HPPEMIT END ' using ::Skia::ISkTextStyle;'} -{$HPPEMIT END ' using ::Skia::ISkTraceMemoryDump;'} -{$HPPEMIT END ' using ::Skia::ISkTypeface;'} -{$HPPEMIT END ' using ::Skia::ISkTypefaceFontProvider;'} -{$HPPEMIT END ' using ::Skia::ISkUnicode;'} -{$HPPEMIT END ' using ::Skia::ISkUnicodeBreakIterator;'} -{$HPPEMIT END ' using ::Skia::ISkVertices;'} -{$HPPEMIT END ' using ::Skia::PCardinalArray;'} -{$HPPEMIT END ' using ::Skia::PPointFArray;'} -{$HPPEMIT END ' using ::Skia::PSingleArray;'} -{$HPPEMIT END ' using ::Skia::PWordArray;'} -{$HPPEMIT END ' using ::Skia::TGrBackendAPI;'} -{$HPPEMIT END ' using ::Skia::TGrBackendRenderTarget;'} -{$HPPEMIT END ' using ::Skia::TGrBackendTexture;'} -{$HPPEMIT END ' using ::Skia::TGrContextOptions;'} -{$HPPEMIT END ' using ::Skia::TGrDirectContext;'} -{$HPPEMIT END ' using ::Skia::TGrGlFramebufferInfo;'} -{$HPPEMIT END ' using ::Skia::TGrGlGetProc;'} -{$HPPEMIT END ' using ::Skia::TGrGlInterface;'} -{$HPPEMIT END ' using ::Skia::TGrGlTextureInfo;'} -{$HPPEMIT END ' using ::Skia::TGrMtlBackendContext;'} -{$HPPEMIT END ' using ::Skia::TGrMtlTextureInfo;'} -{$HPPEMIT END ' using ::Skia::TGrPersistentCacheBaseClass;'} -{$HPPEMIT END ' using ::Skia::TGrShaderCacheStrategy;'} -{$HPPEMIT END ' using ::Skia::TGrShaderErrorHandlerBaseClass;'} -{$HPPEMIT END ' using ::Skia::TGrSurfaceOrigin;'} -{$HPPEMIT END ' using ::Skia::TGrVkAlloc;'} -{$HPPEMIT END ' using ::Skia::TGrVkAllocFlag;'} -{$HPPEMIT END ' using ::Skia::TGrVkAllocFlags;'} -{$HPPEMIT END ' using ::Skia::TGrVkBackendContext;'} -{$HPPEMIT END ' using ::Skia::TGrVkExtensions;'} -{$HPPEMIT END ' using ::Skia::TGrVkGetProc;'} -{$HPPEMIT END ' using ::Skia::TGrVkImageInfo;'} -{$HPPEMIT END ' using ::Skia::TGrVkYcbcrConversionInfo;'} -{$HPPEMIT END ' using ::Skia::TSkAffinity;'} -{$HPPEMIT END ' using ::Skia::TSkAlphaType;'} -{$HPPEMIT END ' using ::Skia::TSkAnimationCodecPlayer;'} -{$HPPEMIT END ' using ::Skia::TSkBlender;'} -{$HPPEMIT END ' using ::Skia::TSkBlendMode;'} -{$HPPEMIT END ' using ::Skia::TSkBlurStyle;'} -{$HPPEMIT END ' using ::Skia::TSkBreakType;'} -{$HPPEMIT END ' using ::Skia::TSkCanvas;'} -{$HPPEMIT END ' using ::Skia::TSkClipOp;'} -{$HPPEMIT END ' using ::Skia::TSkCodec;'} -{$HPPEMIT END ' using ::Skia::TSkColorChannel;'} -{$HPPEMIT END ' using ::Skia::TSkColorFilter;'} -{$HPPEMIT END ' using ::Skia::TSkColorMatrix;'} -{$HPPEMIT END ' using ::Skia::TSkColorSpace;'} -{$HPPEMIT END ' using ::Skia::TSkColorSpaceICCProfile;'} -{$HPPEMIT END ' using ::Skia::TSkColorSpacePrimaries;'} -{$HPPEMIT END ' using ::Skia::TSkColorSpaceTransferFunction;'} -{$HPPEMIT END ' using ::Skia::TSkColorSpaceXyz;'} -{$HPPEMIT END ' using ::Skia::TSkColorType;'} -{$HPPEMIT END ' using ::Skia::TSkContrastInvertStyle;'} -{$HPPEMIT END ' using ::Skia::TSkCubicResampler;'} -{$HPPEMIT END ' using ::Skia::TSkDirection;'} -{$HPPEMIT END ' using ::Skia::TSkDocument;'} -{$HPPEMIT END ' using ::Skia::TSkDrawPointsMode;'} -{$HPPEMIT END ' using ::Skia::TSkEncodedImageFormat;'} -{$HPPEMIT END ' using ::Skia::TSkFileResourceProvider;'} -{$HPPEMIT END ' using ::Skia::TSkFilterMode;'} -{$HPPEMIT END ' using ::Skia::TSkFont;'} -{$HPPEMIT END ' using ::Skia::TSkFontEdging;'} -{$HPPEMIT END ' using ::Skia::TSkFontHinting;'} -{$HPPEMIT END ' using ::Skia::TSkFontMetrics;'} -{$HPPEMIT END ' using ::Skia::TSkFontMetricsFlag;'} -{$HPPEMIT END ' using ::Skia::TSkFontMetricsFlags;'} -{$HPPEMIT END ' using ::Skia::TSkFontPathProc;'} -{$HPPEMIT END ' using ::Skia::TSkFontSlant;'} -{$HPPEMIT END ' using ::Skia::TSkFontStyle;'} -{$HPPEMIT END ' using ::Skia::TSkFontWeight;'} -{$HPPEMIT END ' using ::Skia::TSkFontWidth;'} -{$HPPEMIT END ' using ::Skia::TSkGraphics;'} -{$HPPEMIT END ' using ::Skia::TSkHighContrastConfig;'} -{$HPPEMIT END ' using ::Skia::TSkImage;'} -{$HPPEMIT END ' using ::Skia::TSkImageCachingHint;'} -{$HPPEMIT END ' using ::Skia::TSkImageEncoder;'} -{$HPPEMIT END ' using ::Skia::TSkImageFilter;'} -{$HPPEMIT END ' using ::Skia::TSkImageInfo;'} -{$HPPEMIT END ' using ::Skia::TSkImageRasterReleaseProc;'} -{$HPPEMIT END ' using ::Skia::TSkImageTextureReleaseProc;'} -{$HPPEMIT END ' using ::Skia::TSkLattice;'} -{$HPPEMIT END ' using ::Skia::TSkLatticeRectType;'} -{$HPPEMIT END ' using ::Skia::TSkMaskFilter;'} -{$HPPEMIT END ' using ::Skia::TSkMetrics;'} -{$HPPEMIT END ' using ::Skia::TSkMipmapMode;'} -{$HPPEMIT END ' using ::Skia::TSkNonVirtualReferenceCounted;'} -{$HPPEMIT END ' using ::Skia::TSkObject;'} -{$HPPEMIT END ' using ::Skia::TSkOpBuilder;'} -{$HPPEMIT END ' using ::Skia::TSkottieAnimation;'} -{$HPPEMIT END ' using ::Skia::TSkottieAnimationRenderFlag;'} -{$HPPEMIT END ' using ::Skia::TSkottieAnimationRenderFlags;'} -{$HPPEMIT END ' using ::Skia::TSkOverdrawColor;'} -{$HPPEMIT END ' using ::Skia::TSkPaint;'} -{$HPPEMIT END ' using ::Skia::TSkPaintStyle;'} -{$HPPEMIT END ' using ::Skia::TSkParagraph;'} -{$HPPEMIT END ' using ::Skia::TSkParagraphBuilder;'} -{$HPPEMIT END ' using ::Skia::TSkParagraphStyle;'} -{$HPPEMIT END ' using ::Skia::TSkParagraphVisitorFlag;'} -{$HPPEMIT END ' using ::Skia::TSkParagraphVisitorFlags;'} -{$HPPEMIT END ' using ::Skia::TSkParagraphVisitorInfo;'} -{$HPPEMIT END ' using ::Skia::TSkParagraphVisitProc;'} -{$HPPEMIT END ' using ::Skia::TSkParticleEffect;'} -{$HPPEMIT END ' using ::Skia::TSkParticleUniform;'} -{$HPPEMIT END ' using ::Skia::TSkParticleUniformData;'} -{$HPPEMIT END ' using ::Skia::TSkPatchColors;'} -{$HPPEMIT END ' using ::Skia::TSkPatchCubics;'} -{$HPPEMIT END ' using ::Skia::TSkPatchTexCoords;'} -{$HPPEMIT END ' using ::Skia::TSkPath;'} -{$HPPEMIT END ' using ::Skia::TSkPathArcSize;'} -{$HPPEMIT END ' using ::Skia::TSkPathBuilder;'} -{$HPPEMIT END ' using ::Skia::TSkPathDirection;'} -{$HPPEMIT END ' using ::Skia::TSkPathEffect;'} -{$HPPEMIT END ' using ::Skia::TSkPathEffect1DStyle;'} -{$HPPEMIT END ' using ::Skia::TSkPathEffectTrimMode;'} -{$HPPEMIT END ' using ::Skia::TSkPathFillType;'} -{$HPPEMIT END ' using ::Skia::TSkPathIteratorElem;'} -{$HPPEMIT END ' using ::Skia::TSkPathMeasure;'} -{$HPPEMIT END ' using ::Skia::TSkPathMeasureMatrixFlag;'} -{$HPPEMIT END ' using ::Skia::TSkPathMeasureMatrixFlags;'} -{$HPPEMIT END ' using ::Skia::TSkPathOp;'} -{$HPPEMIT END ' using ::Skia::TSkPathPoints;'} -{$HPPEMIT END ' using ::Skia::TSkPathVerb;'} -{$HPPEMIT END ' using ::Skia::TSkPDFMetadata;'} -{$HPPEMIT END ' using ::Skia::TSkPicture;'} -{$HPPEMIT END ' using ::Skia::TSkPictureRecorder;'} -{$HPPEMIT END ' using ::Skia::TSkPixelGeometry;'} -{$HPPEMIT END ' using ::Skia::TSkPixmap;'} -{$HPPEMIT END ' using ::Skia::TSkPlaceholderAlignment;'} -{$HPPEMIT END ' using ::Skia::TSkPlaceholderStyle;'} -{$HPPEMIT END ' using ::Skia::TSkPositionAffinity;'} -{$HPPEMIT END ' using ::Skia::TSkRectHeightStyle;'} -{$HPPEMIT END ' using ::Skia::TSkRectWidthStyle;'} -{$HPPEMIT END ' using ::Skia::TSkReferenceCounted;'} -{$HPPEMIT END ' using ::Skia::TSkRegion;'} -{$HPPEMIT END ' using ::Skia::TSkRegionOp;'} -{$HPPEMIT END ' using ::Skia::TSkResourceProviderBaseClass;'} -{$HPPEMIT END ' using ::Skia::TSkRotationScaleMatrix;'} -{$HPPEMIT END ' using ::Skia::TSkRoundRect;'} -{$HPPEMIT END ' using ::Skia::TSkRoundRectCorner;'} -{$HPPEMIT END ' using ::Skia::TSkRoundRectRadii;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffect;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectChildType;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectFloat2;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectFloat2x2;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectFloat3;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectFloat3x3;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectFloat4;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectFloat4x4;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectInt2;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectInt3;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectInt4;'} -{$HPPEMIT END ' using ::Skia::TSkRuntimeEffectUniformType;'} -{$HPPEMIT END ' using ::Skia::TSkSamplingOptions;'} -{$HPPEMIT END ' using ::Skia::TSkSegmentMask;'} -{$HPPEMIT END ' using ::Skia::TSkSegmentMasks;'} -{$HPPEMIT END ' using ::Skia::TSkShader;'} -{$HPPEMIT END ' using ::Skia::TSkShaper;'} -{$HPPEMIT END ' using ::Skia::TSkSrcRectConstraint;'} -{$HPPEMIT END ' using ::Skia::TSkStrokeCap;'} -{$HPPEMIT END ' using ::Skia::TSkStrokeJoin;'} -{$HPPEMIT END ' using ::Skia::TSkStrutStyle;'} -{$HPPEMIT END ' using ::Skia::TSkSurface;'} -{$HPPEMIT END ' using ::Skia::TSkSurfaceProperties;'} -{$HPPEMIT END ' using ::Skia::TSkSurfacePropertiesFlag;'} -{$HPPEMIT END ' using ::Skia::TSkSurfacePropertiesFlags;'} -{$HPPEMIT END ' using ::Skia::TSkSurfaceRasterReleaseProc;'} -{$HPPEMIT END ' using ::Skia::TSkSVGAspectAlign;'} -{$HPPEMIT END ' using ::Skia::TSkSVGAspectScale;'} -{$HPPEMIT END ' using ::Skia::TSkSVGCanvas;'} -{$HPPEMIT END ' using ::Skia::TSkSVGCanvasFlag;'} -{$HPPEMIT END ' using ::Skia::TSkSVGCanvasFlags;'} -{$HPPEMIT END ' using ::Skia::TSkSVGDOM;'} -{$HPPEMIT END ' using ::Skia::TSkSVGLength;'} -{$HPPEMIT END ' using ::Skia::TSkSVGLengthUnit;'} -{$HPPEMIT END ' using ::Skia::TSkSVGNode;'} -{$HPPEMIT END ' using ::Skia::TSkSVGPreserveAspectRatio;'} -{$HPPEMIT END ' using ::Skia::TSkSVGSVG;'} -{$HPPEMIT END ' using ::Skia::TSkTableFilter;'} -{$HPPEMIT END ' using ::Skia::TSkTextAlign;'} -{$HPPEMIT END ' using ::Skia::TSkTextBaseline;'} -{$HPPEMIT END ' using ::Skia::TSkTextBlob;'} -{$HPPEMIT END ' using ::Skia::TSkTextBox;'} -{$HPPEMIT END ' using ::Skia::TSkTextDecoration;'} -{$HPPEMIT END ' using ::Skia::TSkTextDecorations;'} -{$HPPEMIT END ' using ::Skia::TSkTextDecorationStyle;'} -{$HPPEMIT END ' using ::Skia::TSkTextDirection;'} -{$HPPEMIT END ' using ::Skia::TSkTextHeightBehavior;'} -{$HPPEMIT END ' using ::Skia::TSkTextHeightBehaviors;'} -{$HPPEMIT END ' using ::Skia::TSkTextShadow;'} -{$HPPEMIT END ' using ::Skia::TSkTextStyle;'} -{$HPPEMIT END ' using ::Skia::TSkTileMode;'} -{$HPPEMIT END ' using ::Skia::TSkTraceMemoryDumpBaseClass;'} -{$HPPEMIT END ' using ::Skia::TSkTypeface;'} -{$HPPEMIT END ' using ::Skia::TSkTypefaceFontProvider;'} -{$HPPEMIT END ' using ::Skia::TSkUnicode;'} -{$HPPEMIT END ' using ::Skia::TSkUnicodeBidiRegionProc;'} -{$HPPEMIT END ' using ::Skia::TSkUnicodeBreakIteratorElem;'} -{$HPPEMIT END ' using ::Skia::TSkUnicodeBreakProc;'} -{$HPPEMIT END ' using ::Skia::TSkUnicodeCodepointProc;'} -{$HPPEMIT END ' using ::Skia::TSkVertexMode;'} -{$HPPEMIT END ' using ::Skia::TSkVertices;'} -{$HPPEMIT END ' typedef TSkEncodedImageFormat (__fastcall *TExtensionToEncodedImageFormatFunc)(const ::System::UnicodeString AExtension);'} -{$HPPEMIT END ' static const ::System::Word GrGlTexture2D = ::Skia::GrGlTexture2D;'} -{$HPPEMIT END ' static const ::System::Word GrGlTextureExternal = ::Skia::GrGlTextureExternal;'} -{$HPPEMIT END ' static const ::System::Word GrGlTextureRectangle = ::Skia::GrGlTextureRectangle;'} -{$HPPEMIT END ' static const TSkFontSlant SkFontSlantRegular = ::Skia::SkFontSlantRegular;'} -{$HPPEMIT END ' static const TSkFontWeight SkFontWeightDemiBold = ::Skia::SkFontWeightDemiBold;'} -{$HPPEMIT END ' static const TSkFontWeight SkFontWeightHairline = ::Skia::SkFontWeightHairline;'} -{$HPPEMIT END ' static const TSkFontWeight SkFontWeightHeavy = ::Skia::SkFontWeightHeavy;'} -{$HPPEMIT END ' static const TSkFontWeight SkFontWeightRegular = ::Skia::SkFontWeightRegular;'} -{$HPPEMIT END ' static const TSkFontWeight SkFontWeightUltraBlack = ::Skia::SkFontWeightUltraBlack;'} -{$HPPEMIT END ' static const TSkFontWeight SkFontWeightUltraBold = ::Skia::SkFontWeightUltraBold;'} -{$HPPEMIT END ' static const TSkFontWeight SkFontWeightUltraLight = ::Skia::SkFontWeightUltraLight;'} -{$HPPEMIT END ' static const TSkFontWidth SkFontWidthRegular = ::Skia::SkFontWidthRegular;'} -{$HPPEMIT END ' static ::System::StaticArray& GrGlSizedFormat = ::Skia::GrGlSizedFormat;'} -{$HPPEMIT END ' static ::System::StaticArray& SkBytesPerPixel = ::Skia::SkBytesPerPixel;'} -{$HPPEMIT END ' static TSkColorMatrix& SkColorMatrixIdentity = ::Skia::SkColorMatrixIdentity;'} -{$HPPEMIT END ' static TSkColorSpaceTransferFunction& SkColorSpaceTransferFunctionHLG = ::Skia::SkColorSpaceTransferFunctionHLG;'} -{$HPPEMIT END ' static TSkColorSpaceTransferFunction& SkColorSpaceTransferFunctionLinear = ::Skia::SkColorSpaceTransferFunctionLinear;'} -{$HPPEMIT END ' static TSkColorSpaceTransferFunction& SkColorSpaceTransferFunctionPQ = ::Skia::SkColorSpaceTransferFunctionPQ;'} -{$HPPEMIT END ' static TSkColorSpaceTransferFunction& SkColorSpaceTransferFunctionRec2020 = ::Skia::SkColorSpaceTransferFunctionRec2020;'} -{$HPPEMIT END ' static TSkColorSpaceTransferFunction& SkColorSpaceTransferFunctionSRGB = ::Skia::SkColorSpaceTransferFunctionSRGB;'} -{$HPPEMIT END ' static TSkColorSpaceTransferFunction& SkColorSpaceTransferFunctionTwoDotTwo = ::Skia::SkColorSpaceTransferFunctionTwoDotTwo;'} -{$HPPEMIT END ' static TSkColorSpaceXyz& SkColorSpaceXyzAdobeRGB = ::Skia::SkColorSpaceXyzAdobeRGB;'} -{$HPPEMIT END ' static TSkColorSpaceXyz& SkColorSpaceXyzDisplayP3 = ::Skia::SkColorSpaceXyzDisplayP3;'} -{$HPPEMIT END ' static TSkColorSpaceXyz& SkColorSpaceXyzIdentity = ::Skia::SkColorSpaceXyzIdentity;'} -{$HPPEMIT END ' static TSkColorSpaceXyz& SkColorSpaceXyzRec2020 = ::Skia::SkColorSpaceXyzRec2020;'} -{$HPPEMIT END ' static TSkColorSpaceXyz& SkColorSpaceXyzSRGB = ::Skia::SkColorSpaceXyzSRGB;'} -{$HPPEMIT END ' static TSkCubicResampler& SkCubicResamplerCatmullRom = ::Skia::SkCubicResamplerCatmullRom;'} -{$HPPEMIT END ' static TSkCubicResampler& SkCubicResamplerMitchell = ::Skia::SkCubicResamplerMitchell;'} -{$HPPEMIT END ' static TSkFontStyle& SkFontStyleBold = ::Skia::SkFontStyleBold;'} -{$HPPEMIT END ' static TSkFontStyle& SkFontStyleBoldItalic = ::Skia::SkFontStyleBoldItalic;'} -{$HPPEMIT END ' static TSkFontStyle& SkFontStyleItalic = ::Skia::SkFontStyleItalic;'} -{$HPPEMIT END ' static TSkFontStyle& SkFontStyleNormal = ::Skia::SkFontStyleNormal;'} -{$HPPEMIT END ' static TSkColorType& SkNative32ColorType = ::Skia::SkNative32ColorType;'} -{$HPPEMIT END ' static TSkRotationScaleMatrix& SkRotationScaleMatrixIdentity = ::Skia::SkRotationScaleMatrixIdentity;'} -{$HPPEMIT END ' static TSkSamplingOptions& SkSamplingOptionsHigh = ::Skia::SkSamplingOptionsHigh;'} -{$HPPEMIT END ' static TSkSamplingOptions& SkSamplingOptionsLow = ::Skia::SkSamplingOptionsLow;'} -{$HPPEMIT END ' static TSkSamplingOptions& SkSamplingOptionsMedium = ::Skia::SkSamplingOptionsMedium;'} -{$HPPEMIT END ' static ::System::StaticArray& SkShiftPerPixel = ::Skia::SkShiftPerPixel;'} -{$HPPEMIT END ' static const TExtensionToEncodedImageFormatFunc ExtensionToEncodedImageFormat = ::Skia::ExtensionToEncodedImageFormat;'} -{$HPPEMIT END '#endif'} -end. diff --git a/skia4delphi/Source/VCL/Skia.Vcl.pas b/skia4delphi/Source/VCL/Skia.Vcl.pas deleted file mode 100644 index 43ba285..0000000 --- a/skia4delphi/Source/VCL/Skia.Vcl.pas +++ /dev/null @@ -1,6196 +0,0 @@ -{************************************************************************} -{ } -{ Skia4Delphi } -{ } -{ Copyright (c) 2011-2022 Google LLC. } -{ Copyright (c) 2021-2022 Skia4Delphi Project. } -{ } -{ Use of this source code is governed by a BSD-style license that can be } -{ found in the LICENSE file. } -{ } -{************************************************************************} -unit Skia.Vcl; - -interface - -{$SCOPEDENUMS ON} - -uses - { Delphi } - Winapi.Windows, - Winapi.Messages, - System.SysUtils, - System.Types, - System.UITypes, - System.Classes, - System.Math, - System.Messaging, - System.Generics.Collections, - Vcl.Graphics, - Vcl.Controls, - Vcl.ExtCtrls, - - { Skia } - Skia; - -type - ESkVcl = class(Exception); - ESkBitmapHelper = class(ESkVcl); - ESkPersistentData = class(ESkVcl); - ESkTextSettingsInfo = class(ESkVcl); - ESkLabel = class(ESkVcl); - - TSkDrawProc = reference to procedure(const ACanvas: ISkCanvas); - - { TSkBitmapHelper } - - TSkBitmapHelper = class helper for TBitmap - strict private - procedure FlipPixels(const AWidth, AHeight: Integer; const ASrcPixels: PByte; const ASrcStride: Integer; const ADestPixels: PByte; const ADestStride: Integer); inline; - public - constructor CreateFromSkImage(const AImage: ISkImage); - procedure SkiaDraw(const AProc: TSkDrawProc; const AStartClean: Boolean = True); - function ToSkImage: ISkImage; - end; - - { TSkPersistent } - - TSkPersistent = class(TPersistent) - strict private - FChanged: Boolean; - FCreated: Boolean; - FIgnoringAllChanges: Boolean; - FOnChange: TNotifyEvent; - FUpdatingCount: Integer; - function GetUpdating: Boolean; - protected - procedure DoAssign(ASource: TPersistent); virtual; - procedure DoChanged; virtual; - function GetHasChanged: Boolean; virtual; - function SetValue(var AField: Byte; const AValue: Byte): Boolean; overload; - function SetValue(var AField: Word; const AValue: Word): Boolean; overload; - function SetValue(var AField: Cardinal; const AValue: Cardinal): Boolean; overload; - function SetValue(var AField: Boolean; const AValue: Boolean): Boolean; overload; - function SetValue(var AField: Integer; const AValue: Integer): Boolean; overload; - function SetValue(var AField: Int64; const AValue: Int64): Boolean; overload; - function SetValue(var AField: Single; const AValue: Single; const AEpsilon: Single = 0.0): Boolean; overload; - function SetValue(var AField: Double; const AValue: Double; const AEpsilon: Double = 0.0): Boolean; overload; - function SetValue(var AField: TBytes; const AValue: TBytes): Boolean; overload; - function SetValue(var AField: string; const AValue: string): Boolean; overload; - function SetValue(var AField: T; const AValue: T): Boolean; overload; - property Created: Boolean read FCreated; - property UpdatingCount: Integer read FUpdatingCount; - public - procedure AfterConstruction; override; - procedure Assign(ASource: TPersistent); override; final; - procedure BeginUpdate; overload; - procedure BeginUpdate(const AIgnoreAllChanges: Boolean); overload; virtual; - procedure Change; virtual; - procedure EndUpdate; overload; - procedure EndUpdate(const AIgnoreAllChanges: Boolean); overload; virtual; - property HasChanged: Boolean read GetHasChanged; - property Updating: Boolean read GetUpdating; - property OnChange: TNotifyEvent read FOnChange write FOnChange; - end; - - TSkDrawEvent = procedure(ASender: TObject; const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single) of object; - TSkDrawCacheKind = (Never, Raster, Always); - - { TSkCustomControl } - - TSkCustomControl = class abstract(TGraphicControl) - strict private - FDrawBuffer: HBITMAP; - FDrawBufferData: Pointer; - FDrawBufferStride: Integer; - FDrawCached: Boolean; - FDrawCacheKind: TSkDrawCacheKind; - FOnDraw: TSkDrawEvent; - FOpacity: Byte; - procedure CreateBuffer(const AMemDC: HDC; out ABuffer: HBITMAP; out AData: Pointer; out AStride: Integer); - procedure DeleteBuffers; - procedure SetDrawCacheKind(const AValue: TSkDrawCacheKind); - procedure SetOnDraw(const AValue: TSkDrawEvent); - procedure SetOpacity(const AValue: Byte); - {$IF CompilerVersion < 33} - strict protected - FScaleFactor: Single; - procedure ChangeScale(M, D: Integer); override; - {$ENDIF} - strict protected - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); virtual; - procedure DrawDesignBorder(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); - function NeedsRedraw: Boolean; virtual; - procedure Paint; override; final; - procedure Resize; override; - property DrawCacheKind: TSkDrawCacheKind read FDrawCacheKind write SetDrawCacheKind default TSkDrawCacheKind.Raster; - property OnDraw: TSkDrawEvent read FOnDraw write SetOnDraw; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure Redraw; - {$IF CompilerVersion < 33} - property ScaleFactor: Single read FScaleFactor; - {$ENDIF} - published - property Align; - property Anchors; - property Constraints; - property DragCursor; - property DragKind; - property DragMode; - property Enabled; - property Opacity: Byte read FOpacity write SetOpacity default 255; - property ParentShowHint; - property PopupMenu; - property ShowHint; - property Touch; - property Visible; - property OnClick; - property OnContextPopup; - property OnDblClick; - property OnDragDrop; - property OnDragOver; - property OnEndDock; - property OnEndDrag; - property OnGesture; - property OnMouseActivate; - property OnMouseDown; - property OnMouseEnter; - property OnMouseLeave; - property OnMouseMove; - property OnMouseUp; - property OnResize; - property OnStartDock; - property OnStartDrag; - end; - - { TSkPaintBox } - - TSkPaintBox = class(TSkCustomControl) - published - property OnDraw; - end; - - TSkSvgSource = type string; - TSkSvgWrapMode = (Default, Fit, FitCrop, Original, OriginalCenter, Place, Stretch, Tile); - - { TSkSvgBrush } - - TSkSvgBrush = class(TPersistent) - strict private const - DefaultGrayScale = False; - DefaultWrapMode = TSkSvgWrapMode.Fit; - strict private - FDOM: ISkSVGDOM; - FGrayScale: Boolean; - FOnChanged: TNotifyEvent; - FOriginalSize: TSizeF; - FOverrideColor: TAlphaColor; - FSource: TSkSvgSource; - FWrapMode: TSkSvgWrapMode; - function GetDOM: ISkSVGDOM; - function GetOriginalSize: TSizeF; - function IsGrayScaleStored: Boolean; - function IsOverrideColorStored: Boolean; - function IsWrapModeStored: Boolean; - procedure SetGrayScale(const AValue: Boolean); - procedure SetOverrideColor(const AValue: TAlphaColor); - procedure SetSource(const AValue: TSkSvgSource); - procedure SetWrapMode(const AValue: TSkSvgWrapMode); - strict protected - procedure DoAssign(ASource: TSkSvgBrush); virtual; - procedure DoChanged; virtual; - function HasContent: Boolean; virtual; - function MakeDOM: ISkSVGDOM; virtual; - procedure RecreateDOM; - public - constructor Create; - procedure Assign(ASource: TPersistent); override; - function Equals(AObject: TObject): Boolean; override; - procedure Render(const ACanvas: ISkCanvas; const ADestRect: TRectF; const AOpacity: Single); - property DOM: ISkSVGDOM read GetDOM; - property OriginalSize: TSizeF read GetOriginalSize; - property OnChanged: TNotifyEvent read FOnChanged write FOnChanged; - published - property GrayScale: Boolean read FGrayScale write SetGrayScale stored IsGrayScaleStored; - property OverrideColor: TAlphaColor read FOverrideColor write SetOverrideColor stored IsOverrideColorStored; - property Source: TSkSvgSource read FSource write SetSource; - property WrapMode: TSkSvgWrapMode read FWrapMode write SetWrapMode stored IsWrapModeStored; - end; - - { TSkSvg } - - TSkSvg = class(TSkCustomControl) - strict private - FSvg: TSkSvgBrush; - procedure SetSvg(const AValue: TSkSvgBrush); - procedure SvgChanged(ASender: TObject); - strict protected - function CreateSvgBrush: TSkSvgBrush; virtual; - 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; - property OnDraw; - end; - - { TSkCustomWinControl } - - TSkCustomWinControl = class abstract(TCustomControl) - strict private - FBackgroundBuffer: TBitmap; - FDrawBuffer: HBITMAP; - FDrawBufferData: Pointer; - FDrawBufferStride: Integer; - FDrawCached: Boolean; - FDrawCacheKind: TSkDrawCacheKind; - FDrawParentInBackground: Boolean; - FOnDraw: TSkDrawEvent; - FOpacity: Byte; - procedure CreateBuffer(const AMemDC: HDC; out ABuffer: HBITMAP; out AData: Pointer; out AStride: Integer); - procedure DeleteBuffers; - procedure DrawParentImage(ADC: HDC; AInvalidateParent: Boolean = False); - function GetOpaqueParent: TWinControl; - procedure SetDrawCacheKind(const AValue: TSkDrawCacheKind); - procedure SetDrawParentInBackground(const AValue: Boolean); - procedure SetOnDraw(const AValue: TSkDrawEvent); - procedure SetOpacity(const AValue: Byte); - procedure WMEraseBkgnd(var AMessage: TWMEraseBkgnd); message WM_ERASEBKGND; - {$IF CompilerVersion < 33} - strict protected - FScaleFactor: Single; - procedure ChangeScale(M, D: Integer); override; - {$ENDIF} - strict protected - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); virtual; - procedure DrawDesignBorder(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); - function NeedsRedraw: Boolean; virtual; - procedure Paint; override; final; - procedure Resize; override; - property DrawCacheKind: TSkDrawCacheKind read FDrawCacheKind write SetDrawCacheKind default TSkDrawCacheKind.Raster; - property DrawParentInBackground: Boolean read FDrawParentInBackground write SetDrawParentInBackground; - property OnDraw: TSkDrawEvent read FOnDraw write SetOnDraw; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure Redraw; - {$IF CompilerVersion < 33} - property ScaleFactor: Single read FScaleFactor; - {$ENDIF} - published - property Align; - property Anchors; - property Constraints; - property DragCursor; - property DragKind; - property DragMode; - property Enabled; - property Opacity: Byte read FOpacity write SetOpacity default 255; - property ParentShowHint; - property PopupMenu; - property ShowHint; - property Touch; - property Visible; - property OnClick; - property OnContextPopup; - property OnDblClick; - property OnDragDrop; - property OnDragOver; - property OnEndDock; - property OnEndDrag; - property OnGesture; - property OnMouseActivate; - property OnMouseDown; - property OnMouseEnter; - property OnMouseLeave; - property OnMouseMove; - property OnMouseUp; - property OnResize; - property OnStartDock; - property OnStartDrag; - end; - - { TSkCustomAnimation } - TSkCustomAnimation = class(TSkPersistent) - public const - DefaultFrameRate = 60; - public class var - FrameRate: Integer; - protected const - DefaultAutoReverse = False; - DefaultDelay = 0; - DefaultEnabled = True; - DefaultInverse = False; - DefaultLoop = True; - DefaultPause = False; - DefaultSpeed = 1; - DefaultStartFromCurrent = False; - DefaultStartProgress = 0; - DefaultStopProgress = 1; - ProgressEpsilon = 0; - SpeedEpsilon = 1E-3; - SpeedRoundTo = -3; - TimeEpsilon = 1E-3; - TimeRoundTo = -3; - strict private type - TProcess = class - strict private - // Unsafe referece for TSkAnimation in list - FAniList: TList; - FAniProcessingList: TList; - FAnimation: TTimer; - FPerformanceFrequency: Int64; - FTime: Double; - procedure DoAdd(const AAnimation: TSkCustomAnimation); - procedure DoRemove(const AAnimation: TSkCustomAnimation); - function GetTick: Double; - procedure OnProcess(ASender: TObject); - strict private - class var FProcess: TProcess; - class destructor Destroy; - public - constructor Create; - destructor Destroy; override; - class procedure Add(const AAnimation: TSkCustomAnimation); static; - class procedure Remove(const AAnimation: TSkCustomAnimation); static; - end; - strict private - FAllowAnimation: Boolean; - FAutoReverse: Boolean; - FCurrentTime: Double; - FCurrentTimeChanged: Boolean; - FDelay: Double; - FDelayTime: Double; - FDuration: Double; - FEnabled: Boolean; - FEnabledChanged: Boolean; - FInverse: Boolean; - FLoop: Boolean; - FNeedStart: Boolean; - FNeedStartRepaint: Boolean; - [unsafe] FOwner: TComponent; - FPause: Boolean; - FProcessDuration: Double; - FProcessing: Boolean; - FProcessTime: Double; - FProgress: Double; - FRunning: Boolean; - FSavedInverse: Boolean; - FSavedProgress: Double; - FSpeed: Double; - FStartFromCurrent: Boolean; - FStartProgress: Double; - FStopProgress: Double; - FTickCount: Integer; - function CanProcessing: Boolean; - function DoSetCurrentTime(const AValue: Double): Boolean; - procedure InternalStart(const ACanProcess: Boolean); - function IsDelayStored: Boolean; - function IsProgressStored: Boolean; - function IsSpeedStored: Boolean; - function IsStartProgressStored: Boolean; - function IsStopProgressStored: Boolean; - procedure ProcessTick(ADeltaTime: Double); - procedure SetAllowAnimation(const AValue: Boolean); - procedure SetCurrentTime(const AValue: Double); - procedure SetDelay(const AValue: Double); - procedure SetEnabled(const AValue: Boolean); - procedure SetLoop(const AValue: Boolean); - procedure SetPause(const AValue: Boolean); - procedure SetProcessing(const AValue: Boolean); - procedure SetProgress(const AValue: Double); - procedure SetRunning(const AValue: Boolean); - procedure SetSpeed(const AValue: Double); - procedure SetStartProgress(const AValue: Double); - procedure SetStartValues(const ADelayTime: Double; const AStartAtEnd: Boolean); - procedure SetStopProgress(const AValue: Double); - procedure UpdateCurrentTime(const AIsRunning, ARecalcProcessDuration: Boolean); inline; - private - property SavedProgress: Double read FSavedProgress write FSavedProgress; - protected - procedure BeforePaint; - procedure DoAssign(ASource: TPersistent); override; - procedure DoChanged; override; - procedure DoFinish; virtual; abstract; - procedure DoProcess; virtual; abstract; - procedure DoStart; virtual; abstract; - function GetDuration: Double; - procedure SetDuration(const AValue: Double); - property AllowAnimation: Boolean read FAllowAnimation write SetAllowAnimation; - property Owner: TComponent read FOwner; - property Processing: Boolean read FProcessing; - public - constructor Create(const AOwner: TComponent); - destructor Destroy; override; - function Equals(AObject: TObject): Boolean; override; - procedure Start; virtual; - procedure Stop; virtual; - procedure StopAtCurrent; virtual; - property AutoReverse: Boolean read FAutoReverse write FAutoReverse default DefaultAutoReverse; - /// Current time of the animation in seconds - property CurrentTime: Double read FCurrentTime write SetCurrentTime stored False nodefault; - /// Delay in seconds to start the animation - property Delay: Double read FDelay write SetDelay stored IsDelayStored; - /// Duration in seconds - property Duration: Double read GetDuration; - /// Enables the animation to run automatically (in the next control's paint). - property Enabled: Boolean read FEnabled write SetEnabled default DefaultEnabled; - property Inverse: Boolean read FInverse write FInverse default DefaultInverse; - property Loop: Boolean read FLoop write SetLoop default DefaultLoop; - property Pause: Boolean read FPause write SetPause default DefaultPause; - /// Normalized CurrentTime (value between 0..1) - property Progress: Double read FProgress write SetProgress stored IsProgressStored; - property Running: Boolean read FRunning; - property Speed: Double read FSpeed write SetSpeed stored IsSpeedStored; - property StartFromCurrent: Boolean read FStartFromCurrent write FStartFromCurrent default DefaultStartFromCurrent; - property StartProgress: Double read FStartProgress write SetStartProgress stored IsStartProgressStored; - property StopProgress: Double read FStopProgress write SetStopProgress stored IsStopProgressStored; - end; - - TSkAnimationDrawEvent = procedure(ASender: TObject; const ACanvas: ISkCanvas; const ADest: TRectF; const AProgress: Double; const AOpacity: Single) of object; - TSkAnimationDrawProc = reference to procedure(const ACanvas: ISkCanvas; const ADest: TRectF; const AProgress: Double; const AOpacity: Single); - - { TSkCustomAnimatedControl } - - TSkCustomAnimatedControl = class abstract(TSkCustomWinControl) - protected type - TAnimationBase = class(TSkCustomAnimation) - strict private - FInsideDoProcess: Boolean; - protected - procedure DoChanged; override; - procedure DoFinish; override; - procedure DoProcess; override; - procedure DoStart; override; - end; - strict private - FAbsoluteVisible: Boolean; - FAbsoluteVisibleCached: Boolean; - FOnAnimationDraw: TSkAnimationDrawEvent; - FOnAnimationFinish: TNotifyEvent; - FOnAnimationProcess: TNotifyEvent; - FOnAnimationStart: TNotifyEvent; - procedure CheckAbsoluteVisible; - procedure CheckDuration; - {$IF CompilerVersion >= 34} - procedure CMParentVisibleChanged(var AMessage: TMessage); message CM_PARENTVISIBLECHANGED; - {$ELSE} - procedure CMShowingChanged(var AMessage: TMessage); message CM_SHOWINGCHANGED; - {$ENDIF} - procedure CMVisibleChanged(var AMessage: TMessage); message CM_VISIBLECHANGED; - function GetAbsoluteVisible: Boolean; - procedure SetOnAnimationDraw(const AValue: TSkAnimationDrawEvent); - strict protected - FAnimation: TAnimationBase; - function CanRunAnimation: Boolean; virtual; - procedure CheckAnimation; - function CreateAnimation: TAnimationBase; virtual; abstract; - procedure DoAnimationChanged; virtual; - procedure DoAnimationFinish; virtual; - procedure DoAnimationProcess; virtual; - procedure DoAnimationStart; virtual; - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - procedure ReadState(AReader: TReader); override; - procedure RenderFrame(const ACanvas: ISkCanvas; const ADest: TRectF; const AProgress: Double; const AOpacity: Single); virtual; - property AbsoluteVisible: Boolean read GetAbsoluteVisible; - property OnAnimationDraw: TSkAnimationDrawEvent read FOnAnimationDraw write SetOnAnimationDraw; - property OnAnimationFinish: TNotifyEvent read FOnAnimationFinish write FOnAnimationFinish; - property OnAnimationProcess: TNotifyEvent read FOnAnimationProcess write FOnAnimationProcess; - property OnAnimationStart: TNotifyEvent read FOnAnimationStart write FOnAnimationStart; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - end; - - { TSkAnimatedPaintBox } - - TSkAnimatedPaintBox = class(TSkCustomAnimatedControl) - public type - { TAnimation } - - TAnimation = class(TAnimationBase) - protected const - DefaultDuration = 1; - strict private - function IsDurationStored: Boolean; - strict protected - procedure DoAssign(ASource: TPersistent); override; - public - constructor Create(const AOwner: TComponent); - function Equals(AObject: TObject): Boolean; override; - published - property AutoReverse; - property Delay; - property Duration: Double read GetDuration write SetDuration stored IsDurationStored; - property Enabled; - property Inverse; - property Loop; - property Progress; - property Speed; - property StartFromCurrent; - property StartProgress; - property StopProgress; - end; - strict private - function GetAnimation: TAnimation; - procedure ReadAnimate(AReader: TReader); - procedure ReadDuration(AReader: TReader); - procedure ReadLoop(AReader: TReader); - procedure SetAnimation(const AValue: TAnimation); - strict protected - function CreateAnimation: TSkCustomAnimatedControl.TAnimationBase; override; - procedure DefineProperties(AFiler: TFiler); override; - published - property Animation: TAnimation read GetAnimation write SetAnimation; - property OnAnimationDraw; - property OnAnimationFinish; - property OnAnimationProcess; - property OnAnimationStart; - end; - - { TSkAnimatedPaintBoxHelper } - - TSkAnimatedPaintBoxHelper = class helper for TSkAnimatedPaintBox - strict protected - function RunningAnimation: Boolean; deprecated 'Use Animation.Running instead'; - public - function Animate: Boolean; deprecated 'Use Animation.Enabled instead'; - function Duration: Double; deprecated 'Use Animation.Duration instead'; - function FixedProgress: Boolean; deprecated 'Use Animation.Enabled instead'; - function Loop: Boolean; deprecated 'Use Animation.Loop instead'; - function Progress: Double; deprecated 'Use Animation.Progress instead'; - end; - - TSkAnimatedImageWrapMode = (Fit, FitCrop, Original, OriginalCenter, Place, Stretch); - - { TSkAnimatedImage } - - TSkAnimatedImage = class(TSkCustomAnimatedControl) - public type - { TAnimation } - - TAnimation = class(TAnimationBase) - published - property AutoReverse; - property Delay; - property Duration; - property Enabled; - property Inverse; - property Loop; - property Progress; - property Speed; - property StartFromCurrent; - property StartProgress; - property StopProgress; - end; - - { TSource } - - TSource = class(TPersistent) - public type - TChangeProc = procedure of object; - strict private - FData: TBytes; - FOnChange: TChangeProc; - procedure SetData(const AValue: TBytes); - public - constructor Create(const AOnChange: TChangeProc); - procedure Assign(ASource: TPersistent); override; - function Equals(AObject: TObject): Boolean; override; - property Data: TBytes read FData write SetData; - end; - - { TFormatInfo } - - TFormatInfo = record - Description: string; - Extensions: TArray; - Name: string; - constructor Create(const AName, ADescription: string; const AExtensions: TArray); - end; - - { TAnimationCodec } - - TAnimationCodec = class - strict protected - function GetDuration: Double; virtual; abstract; - function GetFPS: Double; virtual; abstract; - function GetIsStatic: Boolean; virtual; abstract; - function GetSize: TSizeF; virtual; abstract; - public - procedure Render(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); virtual; abstract; - procedure SeekFrameTime(const ATime: Double); virtual; abstract; - class function SupportedFormats: TArray; virtual; abstract; - class function TryDetectFormat(const ABytes: TBytes; out AFormat: TFormatInfo): Boolean; virtual; abstract; - class function TryMakeFromStream(const AStream: TStream; out ACodec: TAnimationCodec): Boolean; virtual; abstract; - property Duration: Double read GetDuration; - property FPS: Double read GetFPS; - property IsStatic: Boolean read GetIsStatic; - property Size: TSizeF read GetSize; - end; - - TAnimationCodecClass = class of TAnimationCodec; - strict private class var - FRegisteredCodecs: TArray; - strict private - FCodec: TAnimationCodec; - FSource: TSource; - FWrapMode: TSkAnimatedImageWrapMode; - function GetAnimation: TAnimation; - function GetOriginalSize: TSizeF; - procedure ReadData(AStream: TStream); - procedure ReadLoop(AReader: TReader); - procedure ReadOnAnimationFinished(AReader: TReader); - procedure ReadOnAnimationProgress(AReader: TReader); - procedure SetAnimation(const AValue: TAnimation); - procedure SetSource(const AValue: TSource); - procedure SetWrapMode(const AValue: TSkAnimatedImageWrapMode); - procedure WriteData(AStream: TStream); - strict protected - function CreateAnimation: TSkCustomAnimatedControl.TAnimationBase; override; - procedure DefineProperties(AFiler: TFiler); override; - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - procedure RenderFrame(const ACanvas: ISkCanvas; const ADest: TRectF; const AProgress: Double; const AOpacity: Single); override; - procedure SourceChange; virtual; - property Codec: TAnimationCodec read FCodec; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure LoadFromFile(const AFileName: string); - procedure LoadFromStream(const AStream: TStream); - class procedure RegisterCodec(const ACodecClass: TAnimationCodecClass); static; - class property RegisteredCodecs: TArray read FRegisteredCodecs; - property OriginalSize: TSizeF read GetOriginalSize; - published - property Animation: TAnimation read GetAnimation write SetAnimation; - property Source: TSource read FSource write SetSource; - property WrapMode: TSkAnimatedImageWrapMode read FWrapMode write SetWrapMode default TSkAnimatedImageWrapMode.Fit; - property OnAnimationDraw; - property OnAnimationFinish; - property OnAnimationProcess; - property OnAnimationStart; - end; - - { TSkAnimatedImageHelper } - - TSkAnimatedImageHelper = class helper for TSkAnimatedImage - strict protected - function Duration: Double; deprecated 'Use Animation.Duration instead'; - public - function FixedProgress: Boolean; deprecated 'Use Animation.Enabled instead'; - function Loop: Boolean; deprecated 'Use Animation.Loop instead'; - function Progress: Double; deprecated 'Use Animation.Progress instead'; - function RunningAnimation: Boolean; deprecated 'Use Animation.Running instead'; - end; - - { TSkFontComponent } - - TSkFontComponent = class(TSkPersistent) - public type - TSkFontSlant = (Regular, Italic, Oblique); - TSkFontStretch = (UltraCondensed, ExtraCondensed, Condensed, SemiCondensed, Regular, SemiExpanded, Expanded, ExtraExpanded, UltraExpanded); - TSkFontWeight = (Thin, UltraLight, Light, SemiLight, Regular, Medium, Semibold, Bold, UltraBold, Black, UltraBlack); - strict protected const - DefaultFamilies = ''; - DefaultSize = 14; - DefaultSlant = TSkFontSlant.Regular; - DefaultStretch = TSkFontStretch.Regular; - DefaultWeight = TSkFontWeight.Regular; - strict private - FFamilies: string; - FSize: Single; - FSlant: TSkFontSlant; - FStretch: TSkFontStretch; - FWeight: TSkFontWeight; - procedure SetFamilies(const AValue: string); - procedure SetSize(const AValue: Single); - procedure SetSlant(const AValue: TSkFontSlant); - procedure SetStretch(const AValue: TSkFontStretch); - procedure SetWeight(const AValue: TSkFontWeight); - strict protected - procedure AssignTo(ADest: TPersistent); override; - procedure DoAssign(ASource: TPersistent); override; - function IsFamiliesStored: Boolean; virtual; - function IsSizeStored: Boolean; virtual; - public - constructor Create; - function Equals(AObject: TObject): Boolean; override; - published - property Families: string read FFamilies write SetFamilies stored IsFamiliesStored; - property Size: Single read FSize write SetSize stored IsSizeStored; - property Slant: TSkFontSlant read FSlant write SetSlant default DefaultSlant; - property Stretch: TSkFontStretch read FStretch write SetStretch default DefaultStretch; - property Weight: TSkFontWeight read FWeight write SetWeight default DefaultWeight; - end; - - TSkTextHorzAlign = (Center, Leading, Trailing, Justify); - TSkTextVertAlign = (Center, Leading, Trailing); - TSkTextTrimming = (None, Character, Word); - TSkStyledSetting = (Family, Size, Style, FontColor, Other); - TSkStyledSettings = set of TSkStyledSetting; - - { TSkTextSettings } - - TSkTextSettings = class(TSkPersistent) - public type - { TDecorations } - - TDecorations = class(TSkPersistent) - strict protected - const - DefaultColor = TAlphaColors.Null; - DefaultDecorations = []; - DefaultStrokeColor = TAlphaColors.Null; - DefaultStyle = TSkTextDecorationStyle.Solid; - DefaultThickness = 1; - strict private - FColor: TAlphaColor; - FDecorations: TSkTextDecorations; - FStrokeColor: TAlphaColor; - FStyle: TSkTextDecorationStyle; - FThickness: Single; - procedure SetColor(const AValue: TAlphaColor); - procedure SetDecorations(const AValue: TSkTextDecorations); - procedure SetStrokeColor(const AValue: TAlphaColor); - procedure SetStyle(const AValue: TSkTextDecorationStyle); - procedure SetThickness(const AValue: Single); - strict protected - procedure DoAssign(ASource: TPersistent); override; - function IsThicknessStored: Boolean; virtual; - public - constructor Create; - function Equals(AObject: TObject): Boolean; override; - published - property Color: TAlphaColor read FColor write SetColor default DefaultColor; - property Decorations: TSkTextDecorations read FDecorations write SetDecorations default DefaultDecorations; - property StrokeColor: TAlphaColor read FStrokeColor write SetStrokeColor default DefaultStrokeColor; - property Style: TSkTextDecorationStyle read FStyle write SetStyle default DefaultStyle; - property Thickness: Single read FThickness write SetThickness stored IsThicknessStored; - end; - strict protected const - DefaultFontColor = TAlphaColors.Black; - DefaultHeightMultiplier = 0; - DefaultHorzAlign = TSkTextHorzAlign.Leading; - DefaultLetterSpacing = 0; - DefaultMaxLines = 1; - DefaultTrimming = TSkTextTrimming.Word; - DefaultVertAlign = TSkTextVertAlign.Center; - strict private - FDecorations: TDecorations; - FFont: TSkFontComponent; - FFontColor: TAlphaColor; - FHeightMultiplier: Single; - FHorzAlign: TSkTextHorzAlign; - FLetterSpacing: Single; - FMaxLines: NativeUInt; - [unsafe] FOwner: TPersistent; - FTrimming: TSkTextTrimming; - FVertAlign: TSkTextVertAlign; - procedure DecorationsChange(ASender: TObject); - procedure FontChanged(ASender: TObject); - function IsHeightMultiplierStored: Boolean; - function IsLetterSpacingStored: Boolean; - procedure SetDecorations(const AValue: TDecorations); - procedure SetFont(const AValue: TSkFontComponent); - procedure SetFontColor(const AValue: TAlphaColor); - procedure SetHeightMultiplier(const AValue: Single); - procedure SetHorzAlign(const AValue: TSkTextHorzAlign); - procedure SetLetterSpacing(const AValue: Single); - procedure SetMaxLines(const AValue: NativeUInt); - procedure SetTrimming(const AValue: TSkTextTrimming); - procedure SetVertAlign(const AValue: TSkTextVertAlign); - strict protected - procedure DoAssign(ASource: TPersistent); override; - procedure DoAssignNotStyled(const ATextSettings: TSkTextSettings; const AStyledSettings: TSkStyledSettings); virtual; - public - constructor Create(const AOwner: TPersistent); virtual; - destructor Destroy; override; - procedure AssignNotStyled(const ATextSettings: TSkTextSettings; const AStyledSettings: TSkStyledSettings); - function Equals(AObject: TObject): Boolean; override; - procedure UpdateStyledSettings(const AOldTextSettings, ADefaultTextSettings: TSkTextSettings; - var AStyledSettings: TSkStyledSettings); virtual; - property Owner: TPersistent read FOwner; - published - property Decorations: TDecorations read FDecorations write SetDecorations; - property Font: TSkFontComponent read FFont write SetFont; - property FontColor: TAlphaColor read FFontColor write SetFontColor default DefaultFontColor; - property HeightMultiplier: Single read FHeightMultiplier write SetHeightMultiplier stored IsHeightMultiplierStored; - property HorzAlign: TSkTextHorzAlign read FHorzAlign write SetHorzAlign default DefaultHorzAlign; - property LetterSpacing: Single read FLetterSpacing write SetLetterSpacing stored IsLetterSpacingStored; - property MaxLines: NativeUInt read FMaxLines write SetMaxLines default DefaultMaxLines; - property Trimming: TSkTextTrimming read FTrimming write SetTrimming default DefaultTrimming; - property VertAlign: TSkTextVertAlign read FVertAlign write SetVertAlign default DefaultVertAlign; - end; - - TSkTextSettingsClass = class of TSkTextSettings; - - { ISkTextSettings } - - ISkTextSettings = interface - ['{CE7E837B-F927-4C78-B1D2-C62EF4A93014}'] - function GetDefaultTextSettings: TSkTextSettings; - function GetResultingTextSettings: TSkTextSettings; - function GetTextSettings: TSkTextSettings; - procedure SetTextSettings(const AValue: TSkTextSettings); - property DefaultTextSettings: TSkTextSettings read GetDefaultTextSettings; - property ResultingTextSettings: TSkTextSettings read GetResultingTextSettings; - property TextSettings: TSkTextSettings read GetTextSettings write SetTextSettings; - end; - - { TSkTextSettingsInfo } - - TSkTextSettingsInfo = class(TPersistent) - public type - TBaseTextSettings = class(TSkTextSettings) - strict private - [unsafe] FControl: TControl; - [unsafe] FInfo: TSkTextSettingsInfo; - public - constructor Create(const AOwner: TPersistent); override; - property Control: TControl read FControl; - property Info: TSkTextSettingsInfo read FInfo; - end; - - TCustomTextSettings = class(TBaseTextSettings) - public - constructor Create(const AOwner: TPersistent); override; - published - property MaxLines default 0; - end; - - TCustomTextSettingsClass = class of TCustomTextSettings; - strict private - FDefaultTextSettings: TSkTextSettings; - FDesign: Boolean; - FOldTextSettings: TSkTextSettings; - FOnChange: TNotifyEvent; - [unsafe] FOwner: TPersistent; - FResultingTextSettings: TSkTextSettings; - FStyledSettings: TSkStyledSettings; - FTextSettings: TSkTextSettings; - procedure OnCalculatedTextSettings(ASender: TObject); - procedure OnDefaultChanged(ASender: TObject); - procedure OnTextChanged(ASender: TObject); - procedure SetDefaultTextSettings(const AValue: TSkTextSettings); - procedure SetStyledSettings(const AValue: TSkStyledSettings); - procedure SetTextSettings(const AValue: TSkTextSettings); - strict protected - procedure DoCalculatedTextSettings; virtual; - procedure DoDefaultChanged; virtual; - procedure DoStyledSettingsChanged; virtual; - procedure DoTextChanged; virtual; - procedure RecalculateTextSettings; virtual; - public - constructor Create(AOwner: TPersistent; ATextSettingsClass: TSkTextSettingsInfo.TCustomTextSettingsClass); virtual; - destructor Destroy; override; - property DefaultTextSettings: TSkTextSettings read FDefaultTextSettings write SetDefaultTextSettings; - property Design: Boolean read FDesign write FDesign; - property Owner: TPersistent read FOwner; - property ResultingTextSettings: TSkTextSettings read FResultingTextSettings; - property StyledSettings: TSkStyledSettings read FStyledSettings write SetStyledSettings; - property TextSettings: TSkTextSettings read FTextSettings write SetTextSettings; - property OnChange: TNotifyEvent read FOnChange write FOnChange; - end; - - { TSkLabel } - - TSkLabel = class(TSkCustomControl, ISkTextSettings) - public type - TWordsCollection = class; - TCustomWordsItemClass = class of TCustomWordsItem; - - TCustomWordsItem = class(TCollectionItem) - strict protected - const - DefaultBackgroundColor = TAlphaColors.Null; - DefaultCaption = ''; - DefaultCursor = crDefault; - DefaultFontColor = TAlphaColors.Black; - DefaultHeightMultiplier = 0; - DefaultLetterSpacing = 0; - DefaultName = 'Item 0'; - strict private - FBackgroundColor: TAlphaColor; - FCaption: string; - FChanged: Boolean; - FCursor: TCursor; - FIgnoringAllChanges: Boolean; - FName: string; - FOnClick: TNotifyEvent; - FTag: NativeInt; - FTagFloat: Single; - [Weak] FTagObject: TObject; - FTagString: string; - FTextSettingsInfo: TSkTextSettingsInfo; - FUpdatingCount: Integer; - [unsafe] FWords: TWordsCollection; - procedure CheckName(const AName: string; AWordsCollection: TWordsCollection); - function GetDecorations: TSkTextSettings.TDecorations; - function GetFont: TSkFontComponent; - function GetFontColor: TAlphaColor; - function GetHeightMultiplier: Single; - function GetLetterSpacing: Single; - function GetStyledSettings: TSkStyledSettings; - function IsCaptionStored: Boolean; - function IsFontColorStored: Boolean; - function IsHeightMultiplierStored: Boolean; - function IsLetterSpacingStored: Boolean; - function IsNameStored: Boolean; - function IsStyledSettingsStored: Boolean; - procedure TextSettingsChange(ASender: TObject); - procedure SetBackgroundColor(const AValue: TAlphaColor); - procedure SetCaption(const AValue: string); - procedure SetCursor(const AValue: TCursor); - procedure SetDecorations(const AValue: TSkTextSettings.TDecorations); - procedure SetFont(const AValue: TSkFontComponent); - procedure SetFontColor(const AValue: TAlphaColor); - procedure SetHeightMultiplier(const AValue: Single); - procedure SetLetterSpacing(const AValue: Single); - procedure SetName(const AValue: string); - procedure SetStyledSettings(const AValue: TSkStyledSettings); - function UniqueName(const AName: string; const ACollection: TCollection): string; - strict protected - procedure DoAssign(ASource: TPersistent); virtual; - procedure DoChanged; virtual; - function GetDisplayName: string; override; - procedure SetCollection(AValue: TCollection); override; - public - constructor Create(ACollection: TCollection); override; - destructor Destroy; override; - procedure Assign(ASource: TPersistent); override; final; - procedure BeginUpdate; overload; - procedure Change; virtual; - procedure EndUpdate; overload; - procedure EndUpdate(const AIgnoreAllChanges: Boolean); overload; virtual; - property BackgroundColor: TAlphaColor read FBackgroundColor write SetBackgroundColor default DefaultBackgroundColor; - property Caption: string read FCaption write SetCaption stored IsCaptionStored; - property Cursor: TCursor read FCursor write SetCursor default crDefault; - property Decorations: TSkTextSettings.TDecorations read GetDecorations write SetDecorations; - property Font: TSkFontComponent read GetFont write SetFont; - property FontColor: TAlphaColor read GetFontColor write SetFontColor stored IsFontColorStored; - property HeightMultiplier: Single read GetHeightMultiplier write SetHeightMultiplier stored IsHeightMultiplierStored; - property LetterSpacing: Single read GetLetterSpacing write SetLetterSpacing stored IsLetterSpacingStored; - /// The case-insensitive name of the item in the collection. This field cannot be empty and must be unique for his collection - property Name: string read FName write SetName stored IsNameStored; - property StyledSettings: TSkStyledSettings read GetStyledSettings write SetStyledSettings stored IsStyledSettingsStored; - property Tag: NativeInt read FTag write FTag default 0; - property TagFloat: Single read FTagFloat write FTagFloat; - property TagObject: TObject read FTagObject write FTagObject; - property TagString: string read FTagString write FTagString; - property Words: TWordsCollection read FWords; - property OnClick: TNotifyEvent read FOnClick write FOnClick; - end; - - { TWordsCollection } - - TWordsCollection = class(TOwnedCollection) - strict protected - const - DefaultColor = TAlphaColors.Black; - DefaultFontSize = 14; - DefaultFontSlant = TSkFontComponent.TSkFontSlant.Regular; - DefaultFontWeight = TSkFontComponent.TSkFontWeight.Regular; - strict private - [unsafe] FLabel: TSkLabel; - FOnChange: TNotifyEvent; - function GetItem(AIndex: Integer): TCustomWordsItem; - function GetItemByName(const AName: string): TCustomWordsItem; - procedure SetItem(AIndex: Integer; const AValue: TCustomWordsItem); - strict protected - procedure Update(AItem: TCollectionItem); override; - public - constructor Create(AOwner: TPersistent; AItemClass: TCustomWordsItemClass); - function Add: TCustomWordsItem; overload; - function Add(const ACaption: string; const AColor: TAlphaColor = DefaultColor; - const AFontSize: Single = DefaultFontSize; - const AFontWeight: TSkFontComponent.TSkFontWeight = DefaultFontWeight; - const AFontSlant: TSkFontComponent.TSkFontSlant = DefaultFontSlant): TCustomWordsItem; overload; - function AddOrSet(const AName, ACaption: string; const AFontColor: TAlphaColor = DefaultColor; - const AFont: TSkFontComponent = nil; const AOnClick: TNotifyEvent = nil; - const ACursor: TCursor = crDefault): TCustomWordsItem; - function Insert(AIndex: Integer): TCustomWordsItem; - /// Case-insensitive search of item by name - function IndexOf(const AName: string): Integer; - /// Case-insensitive search of item by name - property ItemByName[const AName: string]: TCustomWordsItem read GetItemByName; - property Items[AIndex: Integer]: TCustomWordsItem read GetItem write SetItem; default; - property &Label: TSkLabel read FLabel; - property OnChange: TNotifyEvent read FOnChange write FOnChange; - end; - - { TWordsItem } - - TWordsItem = class(TCustomWordsItem) - published - property BackgroundColor; - property Caption; - property Cursor; - property Decorations; - property Font; - property FontColor; - property HeightMultiplier; - property LetterSpacing; - property Name; - property StyledSettings; - property TagString; - property OnClick; - end; - - { TItemClickedMessage } - - TItemClickedMessage = class(TMessage); - strict private - FBackgroundPicture: ISkPicture; - FClickedPosition: TPoint; - FHasCustomBackground: Boolean; - FHasCustomCursor: Boolean; - FIsMouseOver: Boolean; - FParagraph: ISkParagraph; - FParagraphBounds: TRectF; - FParagraphLayoutWidth: Single; - FParagraphStroked: ISkParagraph; - FPressedPosition: TPoint; - FTextSettingsInfo: TSkTextSettingsInfo; - FWords: TWordsCollection; - FWordsMouseOver: TCustomWordsItem; - procedure CMBiDiModeChanged(var AMessage: TMessage); message CM_BIDIMODECHANGED; - procedure CMControlChange(var AMessage: TMessage); message CM_CONTROLCHANGE; - procedure CMMouseEnter(var AMessage: TMessage); message CM_MOUSEENTER; - procedure CMMouseLeave(var AMessage: TMessage); message CM_MOUSELEAVE; - procedure CMParentBiDiModeChanged(var AMessage: TMessage); message CM_PARENTBIDIMODECHANGED; - procedure DeleteParagraph; - function GetCaption: string; - procedure GetFitSize(var AWidth, AHeight: Single); - function GetLinesCount: Integer; - function GetParagraph: ISkParagraph; - function GetParagraphBounds: TRectF; - function HasFitSizeChanged: Boolean; - procedure ParagraphLayout(const AWidth: Single); - procedure SetCaption(const AValue: string); - procedure SetWords(const AValue: TWordsCollection); - procedure SetWordsMouseOver(const AValue: TCustomWordsItem); - procedure TextSettingsChanged(AValue: TObject); - procedure WMLButtonUp(var AMessage: TWMLButtonUp); message WM_LBUTTONUP; - procedure WMMouseMove(var AMessage: TWMMouseMove); message WM_MOUSEMOVE; - procedure WordsChange(ASender: TObject); - strict private - { ISkTextSettings } - function GetDefaultTextSettings: TSkTextSettings; - function GetResultingTextSettings: TSkTextSettings; - function GetTextSettings: TSkTextSettings; - procedure SetTextSettings(const AValue: TSkTextSettings); - strict protected - function CanAutoSize(var ANewWidth, ANewHeight: Integer): Boolean; override; - procedure Click; override; - procedure Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - function GetTextSettingsClass: TSkTextSettingsInfo.TCustomTextSettingsClass; virtual; - function GetWordsItemAtPosition(const AX, AY: Integer): TCustomWordsItem; - procedure Loaded; override; - procedure MouseDown(AButton: TMouseButton; AShift: TShiftState; AX, AY: Integer); override; - procedure SetName(const AValue: TComponentName); override; - property IsMouseOver: Boolean read FIsMouseOver; - property Paragraph: ISkParagraph read GetParagraph; - property ParagraphBounds: TRectF read GetParagraphBounds; - public - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - function DidExceedMaxLines: Boolean; - function UseRightToLeftAlignment: Boolean; override; - property DefaultTextSettings: TSkTextSettings read GetDefaultTextSettings; - property LinesCount: Integer read GetLinesCount; - property ResultingTextSettings: TSkTextSettings read GetResultingTextSettings; - published - property AutoSize default True; - property BiDiMode; - property Caption: string read GetCaption write SetCaption stored False; - property ParentBiDiMode; - property TextSettings: TSkTextSettings read GetTextSettings write SetTextSettings; - property Words: TWordsCollection read FWords write SetWords; - end; - - { TSkDefaultProviders } - - TSkDefaultProviders = class sealed - strict private class var - FResource: ISkResourceProvider; - FTypefaceFont: ISkTypefaceFontProvider; - class constructor Create; - public - class procedure RegisterTypeface(const AFileName: string); overload; static; - class procedure RegisterTypeface(const AStream: TStream); overload; static; - class property Resource: ISkResourceProvider read FResource write FResource; - class property TypefaceFont: ISkTypefaceFontProvider read FTypefaceFont; - end; - - { TSkTypefaceManager } - - TSkTypefaceManager = class sealed - public - class function Provider: ISkTypefaceFontProvider; static; deprecated 'Use TSkDefaultProviders.TypefaceFont instead'; - class procedure RegisterTypeface(const AFileName: string); overload; static; deprecated 'Use TSkDefaultProviders.RegisterTypeface instead'; - class procedure RegisterTypeface(const AStream: TStream); overload; static; deprecated 'Use TSkDefaultProviders.RegisterTypeface instead'; - end; - -function BitmapToSkImage(const ABitmap: TBitmap): ISkImage; -procedure SkiaDraw(const ABitmap: TBitmap; const AProc: TSkDrawProc; const AStartClean: Boolean = True); -function SkImageToBitmap(const AImage: ISkImage): TBitmap; - -const - AllStyledSettings: TSkStyledSettings = [TSkStyledSetting.Family, TSkStyledSetting.Size, - TSkStyledSetting.Style, TSkStyledSetting.FontColor, TSkStyledSetting.Other]; - DefaultStyledSettings: TSkStyledSettings = [TSkStyledSetting.Family, TSkStyledSetting.Size, - TSkStyledSetting.Style, TSkStyledSetting.FontColor]; - -procedure Register; - -implementation - -uses - { Delphi } - Winapi.MMSystem, - System.Math.Vectors, - System.ZLib, - System.IOUtils, - System.TypInfo, - System.Character, - System.Generics.Defaults, - System.RTLConsts, - Vcl.Forms; - -type - { TSkDefaultAnimationCodec } - - TSkDefaultAnimationCodec = class(TSkAnimatedImage.TAnimationCodec) - strict private type - TImageFormat = (GIF, WebP); - strict private - FAnimationCodec: ISkAnimationCodecPlayer; - FStream: TStream; - strict protected - function GetDuration: Double; override; - function GetFPS: Double; override; - function GetIsStatic: Boolean; override; - function GetSize: TSizeF; override; - public - constructor Create(const AAnimationCodec: ISkAnimationCodecPlayer; const AStream: TStream); - destructor Destroy; override; - procedure Render(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - procedure SeekFrameTime(const ATime: Double); override; - class function SupportedFormats: TArray; override; - class function TryDetectFormat(const ABytes: TBytes; out AFormat: TSkAnimatedImage.TFormatInfo): Boolean; override; - class function TryMakeFromStream(const AStream: TStream; out ACodec: TSkAnimatedImage.TAnimationCodec): Boolean; override; - end; - - { TSkLottieAnimationCodec } - - TSkLottieAnimationCodec = class(TSkAnimatedImage.TAnimationCodec) - strict private type - TAnimationFormat = (Lottie, TGS); - strict private - FSkottie: ISkottieAnimation; - strict protected - function GetDuration: Double; override; - function GetFPS: Double; override; - function GetIsStatic: Boolean; override; - function GetSize: TSizeF; override; - public - constructor Create(const ASkottie: ISkottieAnimation); - procedure Render(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); override; - procedure SeekFrameTime(const ATime: Double); override; - class function SupportedFormats: TArray; override; - class function TryDetectFormat(const ABytes: TBytes; out AFormat: TSkAnimatedImage.TFormatInfo): Boolean; override; - class function TryMakeFromStream(const AStream: TStream; out ACodec: TSkAnimatedImage.TAnimationCodec): Boolean; override; - end; - - { TSkGraphic } - - TSkGraphic = class(TGraphic) - strict private - FBuffer: TBitmap; - FBufferOpacity: Byte; - FImage: ISkImage; - function GetBuffer(const ASize: TSize; const AOpacity: Byte): TBitmap; - strict protected - procedure Changed(ASender: TObject); override; - procedure Draw(ACanvas: TCanvas; const ARect: TRect); override; - procedure DrawTransparent(ACanvas: TCanvas; const ARect: TRect; AOpacity: Byte); override; - function Equals(AGraphic: TGraphic): Boolean; override; - function GetEmpty: Boolean; override; - function GetHeight: Integer; override; - function GetSupportsPartialTransparency: Boolean; override; - function GetWidth: Integer; override; - procedure SetHeight(AValue: Integer); override; - procedure SetWidth(AValue: Integer); override; - public - destructor Destroy; override; - procedure Assign(ASource: TPersistent); override; - {$IF CompilerVersion >= 32} - class function CanLoadFromStream(AStream: TStream): Boolean; override; - {$ENDIF} - procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle; APalette: HPALETTE); override; - procedure LoadFromStream(AStream: TStream); override; - procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle; var APalette: HPALETTE); override; - procedure SaveToFile(const AFileName: string); override; - procedure SaveToStream(AStream: TStream); override; - procedure SetSize(AWidth, AHeight: Integer); override; - end; - - { TSkSvgGraphic } - - TSkSvgGraphic = class(TGraphic) - strict private - FBuffer: TBitmap; - FBufferOpacity: Byte; - FSvgBrush: TSkSvgBrush; - function GetBuffer(const ASize: TSize; const AOpacity: Byte): TBitmap; - strict protected - procedure Changed(ASender: TObject); override; - procedure Draw(ACanvas: TCanvas; const ARect: TRect); override; - procedure DrawTransparent(ACanvas: TCanvas; const ARect: TRect; AOpacity: Byte); override; - function Equals(AGraphic: TGraphic): Boolean; override; - function GetEmpty: Boolean; override; - function GetHeight: Integer; override; - function GetSupportsPartialTransparency: Boolean; override; - function GetWidth: Integer; override; - procedure SetHeight(AValue: Integer); override; - procedure SetWidth(AValue: Integer); override; - public - constructor Create; override; - destructor Destroy; override; - procedure Assign(ASource: TPersistent); override; - procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle; APalette: HPALETTE); override; - procedure LoadFromStream(AStream: TStream); override; - procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle; var APalette: HPALETTE); override; - procedure SaveToFile(const AFileName: string); override; - procedure SaveToStream(AStream: TStream); override; - end; - - {$IF CompilerVersion < 33} - { TSkEpsilonHelper } - - TSkEpsilonHelper = record helper for TEpsilon - const - Scale = 1E-4; - FontSize = 1E-2; - Position = 1E-3; - end; - {$ENDIF} - - {$IF CompilerVersion < 32} - { TSkRectFHelper } - - TSkRectFHelper = record helper for TRectF - public - function FitInto(const ADesignatedArea: TRectF): TRectF; overload; - function FitInto(const ADesignatedArea: TRectF; out ARatio: Single): TRectF; overload; - end; - - function RectCenter(var R: TRectF; const Bounds: TRectF): TRectF; forward; - {$ENDIF} - -function BitmapToSkImage(const ABitmap: TBitmap): ISkImage; -begin - Result := ABitmap.ToSkImage; -end; - -function IsSameBytes(const ALeft, ARight: TBytes): Boolean; -begin - Result := (ALeft = ARight) or - ((Length(ALeft) = Length(ARight)) and - ((Length(ALeft) = 0) or CompareMem(PByte(@ALeft[0]), PByte(@ARight[0]), Length(ALeft)))); -end; - -function PlaceIntoTopLeft(const ASourceRect, ADesignatedArea: TRectF): TRectF; -begin - Result := ASourceRect; - if (ASourceRect.Width > ADesignatedArea.Width) or (ASourceRect.Height > ADesignatedArea.Height) then - Result := Result.FitInto(ADesignatedArea); - Result.SetLocation(ADesignatedArea.TopLeft); -end; - -procedure SkiaDraw(const ABitmap: TBitmap; const AProc: TSkDrawProc; const AStartClean: Boolean); -begin - ABitmap.SkiaDraw(AProc, AStartClean); -end; - -function SkImageToBitmap(const AImage: ISkImage): TBitmap; -begin - Result := TBitmap.CreateFromSkImage(AImage); -end; - -{$IF CompilerVersion < 32} -{ TSkRectFHelper } - -function TSkRectFHelper.FitInto(const ADesignatedArea: TRectF): TRectF; -var - LRatio: Single; -begin - Result := FitInto(ADesignatedArea, LRatio); -end; - -function TSkRectFHelper.FitInto(const ADesignatedArea: TRectF; out ARatio: Single): TRectF; -begin - if (ADesignatedArea.Width <= 0) or (ADesignatedArea.Height <= 0) then - begin - ARatio := 1; - Exit(Self); - end; - - if (Self.Width / ADesignatedArea.Width) > (Self.Height / ADesignatedArea.Height) then - ARatio := Self.Width / ADesignatedArea.Width - else - ARatio := Self.Height / ADesignatedArea.Height; - - if ARatio = 0 then - Exit(Self) - else - begin - Result := TRectF.Create(0, 0, Self.Width / ARatio, Self.Height / ARatio); - RectCenter(Result, ADesignatedArea); - end; -end; - -function RectCenter(var R: TRectF; const Bounds: TRectF): TRectF; -begin - OffsetRect(R, -R.Left, -R.Top); - OffsetRect(R, (RectWidth(Bounds)/2 - RectWidth(R)/2), (RectHeight(Bounds)/2 - RectHeight(R)/2)); - OffsetRect(R, Bounds.Left, Bounds.Top); - Result := R; -end; -{$ENDIF} - -type - TBitmapImageAccess = class(TBitmapImage); - -{ TSkBitmapHelper } - -constructor TSkBitmapHelper.CreateFromSkImage(const AImage: ISkImage); -var - LPixels: Pointer; - LStride: Integer; -begin - Assert(Assigned(AImage)); - Create; - PixelFormat := TPixelFormat.pf32bit; - AlphaFormat := TAlphaFormat.afPremultiplied; - SetSize(AImage.Width, AImage.Height); - if not Empty then - begin - LStride := BytesPerScanLine(Width, 32, 32); - GetMem(LPixels, LStride * Height); - try - AImage.ReadPixels(TSkImageInfo.Create(Width, Height), LPixels, LStride); - FlipPixels(Width, Height, LPixels, LStride, ScanLine[Height - 1], LStride); - finally - FreeMem(LPixels); - end; - end; -end; - -procedure TSkBitmapHelper.FlipPixels(const AWidth, AHeight: Integer; - const ASrcPixels: PByte; const ASrcStride: Integer; const ADestPixels: PByte; - const ADestStride: Integer); -var - I: Integer; -begin - for I := 0 to AHeight - 1 do - Move(ASrcPixels[I * ASrcStride], ADestPixels[(AHeight - I - 1) * ADestStride], AWidth * 4); -end; - -procedure TSkBitmapHelper.SkiaDraw(const AProc: TSkDrawProc; const AStartClean: Boolean); - - procedure ChangePixelFormat; - var - LOriginalSize: TSize; - begin - // Optimization to avoid unnecessary internal conversions of TBitmap as the - // image content will already be discarded. - - LOriginalSize := TSize.Create(Width, Height); - Assign(nil); - PixelFormat := TPixelFormat.pf32bit; - AlphaFormat := TAlphaFormat.afPremultiplied; - SetSize(LOriginalSize.Width, LOriginalSize.Height); - end; - -var - LOriginalImage: ISkImage; - LPixmap: ISkPixmap; - LSurface: ISkSurface; - LStride: Integer; -begin - Assert(Assigned(AProc)); - if Empty then - raise ESkBitmapHelper.Create('Invalid bitmap'); - LOriginalImage := nil; - if (PixelFormat <> TPixelFormat.pf32bit) or (AlphaFormat <> TAlphaFormat.afPremultiplied) then - begin - if not AStartClean then - LOriginalImage := ToSkImage; - ChangePixelFormat; - end; - LStride := BytesPerScanLine(Width, 32, 32); - LSurface := TSkSurface.MakeRaster(Width, Height); - LPixmap := LSurface.PeekPixels; - if AStartClean then - LSurface.Canvas.Clear(TAlphaColors.Null) - else if LOriginalImage <> nil then - begin - LSurface.Canvas.Clear(TAlphaColors.Null); - LSurface.Canvas.DrawImage(LOriginalImage, 0, 0); - end - else - FlipPixels(Width, Height, ScanLine[Height - 1], LStride, LPixmap.Pixels, LPixmap.RowBytes); - AProc(LSurface.Canvas); - FlipPixels(Width, Height, LPixmap.Pixels, LPixmap.RowBytes, ScanLine[Height - 1], LStride); -end; - -function TSkBitmapHelper.ToSkImage: ISkImage; - - function CodecConvert: ISkImage; - var - LStream: TMemoryStream; - begin - LStream := TMemoryStream.Create; - try - SaveToStream(LStream); - LStream.Position := 0; - Result := TSkImage.MakeFromEncodedStream(LStream); - finally - LStream.Free; - end; - end; - -var - LAlphaType: TSkAlphaType; - LPixels: Pointer; - LStride: Integer; -begin - if Empty then - raise ESkBitmapHelper.Create('Invalid bitmap'); - if PixelFormat = TPixelFormat.pf32bit then - begin - case AlphaFormat of - TAlphaFormat.afIgnored: LAlphaType := TSkAlphaType.Opaque; - TAlphaFormat.afDefined: LAlphaType := TSkAlphaType.Unpremul; - TAlphaFormat.afPremultiplied: LAlphaType := TSkAlphaType.Premul; - else - LAlphaType := TSkAlphaType.Unknown; - end; - LStride := BytesPerScanLine(Width, 32, 32); - GetMem(LPixels, LStride * Height); - try - FlipPixels(Width, Height, ScanLine[Height - 1], LStride, LPixels, LStride); - Result := TSkImage.MakeFromRaster(TSkImageInfo.Create(Width, Height, SkNative32ColorType, LAlphaType), LPixels, LStride, - procedure (const APixels: Pointer) - begin - FreeMem(APixels); - end); - except - FreeMem(LPixels); - raise; - end; - end - else - Result := CodecConvert; -end; - -{ TSkPersistent } - -procedure TSkPersistent.AfterConstruction; -begin - inherited; - FCreated := True; -end; - -procedure TSkPersistent.Assign(ASource: TPersistent); -begin - if ASource <> Self then - begin - BeginUpdate; - try - DoAssign(ASource); - finally - EndUpdate; - end; - end; -end; - -procedure TSkPersistent.BeginUpdate; -begin - BeginUpdate(False); -end; - -procedure TSkPersistent.BeginUpdate(const AIgnoreAllChanges: Boolean); -begin - Inc(FUpdatingCount); - FIgnoringAllChanges := FIgnoringAllChanges or AIgnoreAllChanges; -end; - -procedure TSkPersistent.Change; -begin - if FUpdatingCount > 0 then - FChanged := True - else - begin - FChanged := False; - DoChanged; - end; -end; - -procedure TSkPersistent.DoAssign(ASource: TPersistent); -begin - inherited Assign(ASource); -end; - -procedure TSkPersistent.DoChanged; -begin - if FCreated and Assigned(FOnChange) then - FOnChange(Self); -end; - -procedure TSkPersistent.EndUpdate; -begin - EndUpdate(False); -end; - -procedure TSkPersistent.EndUpdate(const AIgnoreAllChanges: Boolean); -var - LCallChange: Boolean; - LIgnoreChanges: Boolean; -begin - LIgnoreChanges := AIgnoreAllChanges or FIgnoringAllChanges; - LCallChange := False; - if FUpdatingCount <= 0 then - raise ESkPersistentData.Create('The object is not in update state'); - Dec(FUpdatingCount); - if (not LIgnoreChanges) and HasChanged then - LCallChange := True - else - FChanged := False; - if FUpdatingCount <= 0 then - FIgnoringAllChanges := False; - if LCallChange and (FUpdatingCount = 0) then - begin - FChanged := False; - DoChanged; - end; -end; - -function TSkPersistent.GetHasChanged: Boolean; -begin - Result := FChanged; -end; - -function TSkPersistent.GetUpdating: Boolean; -begin - Result := FUpdatingCount > 0; -end; - -function TSkPersistent.SetValue(var AField: Byte; const AValue: Byte): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Word; const AValue: Word): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Double; const AValue, - AEpsilon: Double): Boolean; -begin - Result := not SameValue(AField, AValue, AEpsilon); - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: TBytes; const AValue: TBytes): Boolean; -begin - Result := not IsSameBytes(AField, AValue); - if Result then - begin - AField := Copy(AValue); - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: string; const AValue: string): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Single; const AValue, - AEpsilon: Single): Boolean; -begin - Result := not SameValue(AField, AValue, AEpsilon); - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Boolean; - const AValue: Boolean): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Cardinal; - const AValue: Cardinal): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Integer; - const AValue: Integer): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: Int64; const AValue: Int64): Boolean; -begin - Result := AField <> AValue; - if Result then - begin - AField := AValue; - Change; - end; -end; - -function TSkPersistent.SetValue(var AField: T; const AValue: T): Boolean; -begin - if Assigned(TypeInfo(T)) and (PTypeInfo(TypeInfo(T)).Kind in [TTypeKind.tkSet, TTypeKind.tkEnumeration, TTypeKind.tkRecord{$IF CompilerVersion >= 33}, TTypeKind.tkMRecord{$ENDIF}]) then - Result := not CompareMem(@AField, @AValue, SizeOf(T)) - else - Result := TComparer.Default.Compare(AField, AValue) <> 0; - if Result then - begin - AField := AValue; - Change; - end; -end; - -{ TSkCustomControl } - -{$IF CompilerVersion < 33} -procedure TSkCustomControl.ChangeScale(M, D: Integer); -begin - if M <> D then - FScaleFactor := FScaleFactor * M / D; - inherited; -end; -{$ENDIF} - -constructor TSkCustomControl.Create(AOwner: TComponent); -begin - inherited; - ControlStyle := ControlStyle + [csReplicatable] - [csOpaque]; - FDrawCacheKind := TSkDrawCacheKind.Raster; - FOpacity := 255; - {$IF CompilerVersion < 33} - FScaleFactor := 1; - {$ENDIF} - Height := 50; - Width := 50; -end; - -procedure TSkCustomControl.CreateBuffer(const AMemDC: HDC; out ABuffer: HBITMAP; - out AData: Pointer; out AStride: Integer); -const - ColorMasks: array[0..2] of DWORD = ($00FF0000, $0000FF00, $000000FF); -var - LBitmapInfo: PBitmapInfo; -begin - AStride := BytesPerScanline(Width, 32, 32); - GetMem(LBitmapInfo, SizeOf(TBitmapInfoHeader) + SizeOf(ColorMasks)); - try - LBitmapInfo.bmiHeader := Default(TBitmapInfoHeader); - LBitmapInfo.bmiHeader.biSize := SizeOf(TBitmapInfoHeader); - LBitmapInfo.bmiHeader.biWidth := Width; - LBitmapInfo.bmiHeader.biHeight := -Height; - LBitmapInfo.bmiHeader.biPlanes := 1; - LBitmapInfo.bmiHeader.biBitCount := 32; - LBitmapInfo.bmiHeader.biCompression := BI_BITFIELDS; - LBitmapInfo.bmiHeader.biSizeImage := AStride * Height; - Move(ColorMasks[0], LBitmapInfo.bmiColors[0], SizeOf(ColorMasks)); - ABuffer := CreateDIBSection(AMemDC, LBitmapInfo^, DIB_RGB_COLORS, AData, 0, 0); - if ABuffer <> 0 then - GdiFlush; - finally - FreeMem(LBitmapInfo); - end; -end; - -procedure TSkCustomControl.DeleteBuffers; -begin - if FDrawBuffer <> 0 then - begin - FDrawCached := False; - DeleteObject(FDrawBuffer); - FDrawBuffer := 0; - end; -end; - -destructor TSkCustomControl.Destroy; -begin - DeleteBuffers; - inherited; -end; - -procedure TSkCustomControl.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; - const AOpacity: Single); -begin - if csDesigning in ComponentState then - DrawDesignBorder(ACanvas, ADest, AOpacity); -end; - -procedure TSkCustomControl.DrawDesignBorder(const ACanvas: ISkCanvas; - const ADest: TRectF; const AOpacity: Single); -const - DesignBorderColor = $A0909090; -var - R: TRectF; - LPaint: ISkPaint; -begin - R := ADest; - InflateRect(R, -0.5, -0.5); - ACanvas.Save; - try - LPaint := TSkPaint.Create(TSkPaintStyle.Stroke); - LPaint.AlphaF := AOpacity; - LPaint.Color := DesignBorderColor; - LPaint.StrokeWidth := 1; - LPaint.PathEffect := TSKPathEffect.MakeDash([3, 1], 0); - ACanvas.DrawRect(R, LPaint); - finally - ACanvas.Restore; - end; -end; - -function TSkCustomControl.NeedsRedraw: Boolean; -begin - Result := (not FDrawCached) or (FDrawCacheKind = TSkDrawCacheKind.Never) or (FDrawBuffer = 0); -end; - -procedure TSkCustomControl.Paint; - - procedure InternalDraw; - var - LSurface: ISkSurface; - LDestRect: TRectF; - begin - LSurface := TSkSurface.MakeRasterDirect(TSkImageInfo.Create(Width, Height), FDrawBufferData, FDrawBufferStride); - LSurface.Canvas.Clear(TAlphaColors.Null); - LSurface.Canvas.Concat(TMatrix.CreateScaling(ScaleFactor, ScaleFactor)); - LDestRect := RectF(0, 0, Width / ScaleFactor, Height / ScaleFactor); - Draw(LSurface.Canvas, LDestRect, 1); - if Assigned(FOnDraw) then - FOnDraw(Self, LSurface.Canvas, LDestRect, 1); - FDrawCached := True; - end; - -const - BlendFunction: TBlendFunction = (BlendOp: AC_SRC_OVER; BlendFlags: 0; SourceConstantAlpha: 255; AlphaFormat: AC_SRC_ALPHA); -var - LOldObj: HGDIOBJ; - LDrawBufferDC: HDC; - LBlendFunction: TBlendFunction; -begin - if (Width <= 0) or (Height <= 0) then - Exit; - - LDrawBufferDC := CreateCompatibleDC(0); - if LDrawBufferDC <> 0 then - try - if FDrawBuffer = 0 then - CreateBuffer(LDrawBufferDC, FDrawBuffer, FDrawBufferData, FDrawBufferStride); - if FDrawBuffer <> 0 then - begin - LOldObj := SelectObject(LDrawBufferDC, FDrawBuffer); - try - if NeedsRedraw then - InternalDraw; - LBlendFunction := BlendFunction; - LBlendFunction.SourceConstantAlpha := FOpacity; - AlphaBlend(Canvas.Handle, 0, 0, Width, Height, LDrawBufferDC, 0, 0, Width, Height, LBlendFunction); - finally - if LOldObj <> 0 then - SelectObject(LDrawBufferDC, LOldObj); - end; - end; - finally - DeleteDC(LDrawBufferDC); - end; -end; - -procedure TSkCustomControl.Redraw; -begin - FDrawCached := False; - Repaint; -end; - -procedure TSkCustomControl.Resize; -begin - DeleteBuffers; - inherited; -end; - -procedure TSkCustomControl.SetDrawCacheKind(const AValue: TSkDrawCacheKind); -begin - if FDrawCacheKind <> AValue then - begin - FDrawCacheKind := AValue; - if FDrawCacheKind <> TSkDrawCacheKind.Always then - Repaint; - end; -end; - -procedure TSkCustomControl.SetOnDraw(const AValue: TSkDrawEvent); -begin - if TMethod(FOnDraw) <> TMethod(AValue) then - begin - FOnDraw := AValue; - Redraw; - end; -end; - -procedure TSkCustomControl.SetOpacity(const AValue: Byte); -begin - if FOpacity <> AValue then - begin - FOpacity := AValue; - Repaint; - end; -end; - -{ TSkSvgBrush } - -procedure TSkSvgBrush.Assign(ASource: TPersistent); -var - LSourceSvgBrush: TSkSvgBrush absolute ASource; -begin - if ASource is TSkSvgBrush then - begin - if not Equals(LSourceSvgBrush) then - begin - DoAssign(LSourceSvgBrush); - DoChanged; - end; - end - else - inherited; -end; - -constructor TSkSvgBrush.Create; -begin - inherited Create; - FGrayScale := DefaultGrayScale; - FWrapMode := DefaultWrapMode; -end; - -procedure TSkSvgBrush.DoAssign(ASource: TSkSvgBrush); -begin - FDOM := ASource.FDOM; - FGrayScale := ASource.FGrayScale; - FOriginalSize := ASource.FOriginalSize; - FOverrideColor := ASource.FOverrideColor; - FSource := ASource.FSource; - FWrapMode := ASource.FWrapMode; -end; - -procedure TSkSvgBrush.DoChanged; -begin - if Assigned(FOnChanged) then - FOnChanged(Self); -end; - -function TSkSvgBrush.Equals(AObject: TObject): Boolean; -var - LObjectSvgBrush: TSkSvgBrush absolute AObject; -begin - Result := (AObject is TSkSvgBrush) and - (FGrayScale = LObjectSvgBrush.FGrayScale) and - (FOverrideColor = LObjectSvgBrush.FOverrideColor) and - (FWrapMode = LObjectSvgBrush.FWrapMode) and - (FSource = LObjectSvgBrush.FSource); -end; - -function TSkSvgBrush.GetDOM: ISkSVGDOM; -var - LSvgRect: TRectF; -begin - if (FDOM = nil) and HasContent then - begin - FDOM := MakeDOM; - if Assigned(FDOM) then - begin - LSvgRect.TopLeft := PointF(0, 0); - LSvgRect.Size := FDOM.Root.GetIntrinsicSize(TSizeF.Create(0, 0)); - if (not LSvgRect.IsEmpty) or (FDOM.Root.TryGetViewBox(LSvgRect) and not LSvgRect.IsEmpty) then - FOriginalSize := LSvgRect.Size; - end; - end; - Result := FDOM; -end; - -function TSkSvgBrush.GetOriginalSize: TSizeF; -begin - if (FDOM = nil) and HasContent then - GetDOM; - Result := FOriginalSize; -end; - -function TSkSvgBrush.HasContent: Boolean; -begin - Result := FSource <> ''; -end; - -function TSkSvgBrush.IsGrayScaleStored: Boolean; -begin - Result := FGrayScale <> DefaultGrayScale; -end; - -function TSkSvgBrush.IsOverrideColorStored: Boolean; -begin - Result := FOverrideColor <> Default(TAlphaColor); -end; - -function TSkSvgBrush.IsWrapModeStored: Boolean; -begin - Result := FWrapMode <> DefaultWrapMode; -end; - -function TSkSvgBrush.MakeDOM: ISkSVGDOM; -begin - Result := TSkSVGDOM.Make(FSource, TSkDefaultProviders.Resource); -end; - -procedure TSkSvgBrush.RecreateDOM; -begin - FDOM := nil; - FOriginalSize := TSizeF.Create(0, 0); -end; - -procedure TSkSvgBrush.Render(const ACanvas: ISkCanvas; const ADestRect: TRectF; - const AOpacity: Single); - - function GetWrappedDest(const ADOM: ISkSVGDOM; const ASvgRect, ADestRect: TRectF; const AIntrinsicSize: TSizeF): TRectF; - var - LRatio: Single; - begin - case FWrapMode of - TSkSvgWrapMode.Default: - begin - if AIntrinsicSize.IsZero then - Result := ADestRect - else - begin - Result := ASvgRect; - Result.Offset(ADestRect.TopLeft); - end; - ADOM.SetContainerSize(ADestRect.Size); - end; - TSkSvgWrapMode.Fit: Result := ASvgRect.FitInto(ADestRect); - TSkSvgWrapMode.FitCrop: - begin - if (ASvgRect.Width / ADestRect.Width) < (ASvgRect.Height / ADestRect.Height) then - LRatio := ASvgRect.Width / ADestRect.Width - else - LRatio := ASvgRect.Height / ADestRect.Height; - if SameValue(LRatio, 0, TEpsilon.Vector) then - Result := ADestRect - else - begin - Result := RectF(0, 0, Round(ASvgRect.Width / LRatio), Round(ASvgRect.Height / LRatio)); - RectCenter(Result, ADestRect); - end; - end; - TSkSvgWrapMode.Original, - TSkSvgWrapMode.Tile: Result := ASvgRect; - TSkSvgWrapMode.OriginalCenter: - begin - Result := ASvgRect; - RectCenter(Result, ADestRect); - end; - TSkSvgWrapMode.Place: Result := PlaceIntoTopLeft(ASvgRect, ADestRect); - TSkSvgWrapMode.Stretch: Result := ADestRect; - else - Result := ADestRect; - end; - end; - - procedure DrawTileOrCustomColor(const ACanvas: ISkCanvas; const ADOM: ISkSVGDOM; - const ASvgRect, ADestRect, AWrappedDest: TRectF; const AIntrinsicSize: TSizeF; - const AWrapMode: TSkSvgWrapMode); - var - LPicture: ISkPicture; - LPictureRecorder: ISkPictureRecorder; - LCanvas: ISkCanvas; - LPaint: ISkPaint; - begin - LPictureRecorder := TSkPictureRecorder.Create; - LCanvas := LPictureRecorder.BeginRecording(AWrappedDest.Width, AWrappedDest.Height); - if AIntrinsicSize.IsZero then - begin - if AWrapMode <> TSkSvgWrapMode.Default then - begin - ADOM.Root.Width := TSkSVGLength.Create(AWrappedDest.Width, TSkSVGLengthUnit.Pixel); - ADOM.Root.Height := TSkSVGLength.Create(AWrappedDest.Height, TSkSVGLengthUnit.Pixel); - end; - end - else - LCanvas.Scale(AWrappedDest.Width / ASvgRect.Width, AWrappedDest.Height / ASvgRect.Height); - ADOM.Render(LCanvas); - LPicture := LPictureRecorder.FinishRecording; - LPaint := TSkPaint.Create; - if FGrayScale then - LPaint.ColorFilter := TSkColorFilter.MakeMatrix(TSkColorMatrix.CreateSaturation(0)) - else if FOverrideColor <> TAlphaColors.Null then - LPaint.ColorFilter := TSkColorFilter.MakeBlend(FOverrideColor, TSkBlendMode.SrcIn); - if FWrapMode = TSkSvgWrapMode.Tile then - begin - LPaint.Shader := LPicture.MakeShader(TSkTileMode.Repeat, TSkTileMode.Repeat); - ACanvas.DrawRect(ADestRect, LPaint); - end - else - begin - ACanvas.Translate(AWrappedDest.Left, AWrappedDest.Top); - ACanvas.DrawPicture(LPicture, LPaint); - end; - end; - -var - LDOM: ISkSVGDOM; - LSvgRect: TRectF; - LWrappedDest: TRectF; - LIntrinsicSize: TSizeF; -begin - if not ADestRect.IsEmpty then - begin - LDOM := DOM; - if Assigned(LDOM) then - begin - LSvgRect.TopLeft := PointF(0, 0); - LIntrinsicSize := LDOM.Root.GetIntrinsicSize(TSizeF.Create(0, 0)); - LSvgRect.Size := LIntrinsicSize; - if LSvgRect.IsEmpty and ((not LDOM.Root.TryGetViewBox(LSvgRect)) or LSvgRect.IsEmpty) then - Exit; - - if SameValue(AOpacity, 1, TEpsilon.Position) then - ACanvas.Save - else - ACanvas.SaveLayerAlpha(Round(AOpacity * 255)); - try - LWrappedDest := GetWrappedDest(LDOM, LSvgRect, ADestRect, LIntrinsicSize); - if (FOverrideColor <> TAlphaColors.Null) or (FWrapMode = TSkSvgWrapMode.Tile) or FGrayScale then - DrawTileOrCustomColor(ACanvas, LDOM, LSvgRect, ADestRect, LWrappedDest, LIntrinsicSize, FWrapMode) - else - begin - ACanvas.Translate(LWrappedDest.Left, LWrappedDest.Top); - if LIntrinsicSize.IsZero then - begin - if FWrapMode <> TSkSvgWrapMode.Default then - begin - LDOM.Root.Width := TSkSVGLength.Create(LWrappedDest.Width, TSkSVGLengthUnit.Pixel); - LDOM.Root.Height := TSkSVGLength.Create(LWrappedDest.Height, TSkSVGLengthUnit.Pixel); - end; - end - else - ACanvas.Scale(LWrappedDest.Width / LSvgRect.Width, LWrappedDest.Height / LSvgRect.Height); - LDOM.Render(ACanvas); - end; - finally - ACanvas.Restore; - end; - end; - end; -end; - -procedure TSkSvgBrush.SetGrayScale(const AValue: Boolean); -begin - if FGrayScale <> AValue then - begin - FGrayScale := AValue; - if HasContent then - DoChanged; - end; -end; - -procedure TSkSvgBrush.SetOverrideColor(const AValue: TAlphaColor); -begin - if FOverrideColor <> AValue then - begin - FOverrideColor := AValue; - if HasContent then - DoChanged; - end; -end; - -procedure TSkSvgBrush.SetSource(const AValue: TSkSvgSource); -begin - if FSource <> AValue then - begin - FSource := AValue; - RecreateDOM; - DoChanged; - end; -end; - -procedure TSkSvgBrush.SetWrapMode(const AValue: TSkSvgWrapMode); -begin - if FWrapMode <> AValue then - begin - FWrapMode := AValue; - RecreateDOM; - if HasContent then - DoChanged; - end; -end; - -{ TSkSvg } - -constructor TSkSvg.Create(AOwner: TComponent); -begin - inherited; - FSvg := CreateSvgBrush; - FSvg.OnChanged := SvgChanged; - DrawCacheKind := TSkDrawCacheKind.Always; -end; - -function TSkSvg.CreateSvgBrush: TSkSvgBrush; -begin - Result := TSkSvgBrush.Create; -end; - -destructor TSkSvg.Destroy; -begin - FSvg.Free; - inherited; -end; - -procedure TSkSvg.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; const AOpacity: Single); -begin - inherited; - FSvg.Render(ACanvas, ADest, AOpacity); -end; - -procedure TSkSvg.SetSvg(const AValue: TSkSvgBrush); -begin - FSvg.Assign(AValue); -end; - -procedure TSkSvg.SvgChanged(ASender: TObject); -begin - Redraw; -end; - -type - TWinControlAccess = class(TWinControl); - -{ TSkCustomWinControl } - -{$IF CompilerVersion < 33} -procedure TSkCustomWinControl.ChangeScale(M, D: Integer); -begin - if M <> D then - FScaleFactor := FScaleFactor * M / D; - inherited; -end; -{$ENDIF} - -constructor TSkCustomWinControl.Create(AOwner: TComponent); -begin - inherited; - ControlStyle := ControlStyle - [csOpaque] + [csAcceptsControls]; - FDrawCacheKind := TSkDrawCacheKind.Raster; - FOpacity := 255; - {$IF CompilerVersion < 33} - FScaleFactor := 1; - {$ENDIF} - Height := 50; - Width := 50; -end; - -procedure TSkCustomWinControl.CreateBuffer(const AMemDC: HDC; out ABuffer: HBITMAP; - out AData: Pointer; out AStride: Integer); -const - ColorMasks: array[0..2] of DWORD = ($00FF0000, $0000FF00, $000000FF); -var - LBitmapInfo: PBitmapInfo; -begin - AStride := BytesPerScanline(Width, 32, 32); - GetMem(LBitmapInfo, SizeOf(TBitmapInfoHeader) + SizeOf(ColorMasks)); - try - LBitmapInfo.bmiHeader := Default(TBitmapInfoHeader); - LBitmapInfo.bmiHeader.biSize := SizeOf(TBitmapInfoHeader); - LBitmapInfo.bmiHeader.biWidth := Width; - LBitmapInfo.bmiHeader.biHeight := -Height; - LBitmapInfo.bmiHeader.biPlanes := 1; - LBitmapInfo.bmiHeader.biBitCount := 32; - LBitmapInfo.bmiHeader.biCompression := BI_BITFIELDS; - LBitmapInfo.bmiHeader.biSizeImage := AStride * Height; - Move(ColorMasks[0], LBitmapInfo.bmiColors[0], SizeOf(ColorMasks)); - ABuffer := CreateDIBSection(AMemDC, LBitmapInfo^, DIB_RGB_COLORS, AData, 0, 0); - if ABuffer <> 0 then - GdiFlush; - finally - FreeMem(LBitmapInfo); - end; -end; - -procedure TSkCustomWinControl.DeleteBuffers; -begin - FDrawCached := False; - if FDrawBuffer <> 0 then - begin - DeleteObject(FDrawBuffer); - FDrawBuffer := 0; - end; - FreeAndNil(FBackgroundBuffer); -end; - -destructor TSkCustomWinControl.Destroy; -begin - DeleteBuffers; - inherited; -end; - -procedure TSkCustomWinControl.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; - const AOpacity: Single); -begin - if csDesigning in ComponentState then - DrawDesignBorder(ACanvas, ADest, AOpacity); -end; - -procedure TSkCustomWinControl.DrawDesignBorder(const ACanvas: ISkCanvas; - const ADest: TRectF; const AOpacity: Single); -const - DesignBorderColor = $A0909090; -var - R: TRectF; - LPaint: ISkPaint; -begin - R := ADest; - InflateRect(R, -0.5, -0.5); - ACanvas.Save; - try - LPaint := TSkPaint.Create(TSkPaintStyle.Stroke); - LPaint.AlphaF := AOpacity; - LPaint.Color := DesignBorderColor; - LPaint.StrokeWidth := 1; - LPaint.PathEffect := TSKPathEffect.MakeDash([3, 1], 0); - ACanvas.DrawRect(R, LPaint); - finally - ACanvas.Restore; - end; -end; - -procedure TSkCustomWinControl.DrawParentImage(ADC: HDC; - AInvalidateParent: Boolean); - - function LocalToParent(const AParent: TWinControl): TPoint; - var - LControl: TWinControl; - begin - Result := Point(0, 0); - LControl := Self; - repeat - Result := Result + LControl.BoundsRect.TopLeft; - LControl := LControl.Parent; - until (LControl = AParent); - end; - - procedure DrawControl(const AControl: TControl; const AOffset: TPoint); - var - LSaveIndex: Integer; - LPoint: TPoint; - begin - LSaveIndex := SaveDC(ADC); - try - GetViewportOrgEx(ADC, LPoint); - SetViewportOrgEx(ADC, LPoint.X - AOffset.X, LPoint.Y - AOffset.Y, nil); - IntersectClipRect(ADC, 0, 0, AControl.ClientWidth, AControl.ClientHeight); - if AControl is TWinControl then - begin - AControl.Perform(WM_ERASEBKGND, ADC, 0); - AControl.Perform(WM_PRINTCLIENT, ADC, prf_Client); - end - else - AControl.Perform(WM_PAINT, ADC, 0); - finally - RestoreDC(ADC, LSaveIndex); - end; - end; - - procedure DrawParentChildControls; - var - I: Integer; - LControl: TControl; - LBoundsRect: TRect; - begin - if not Assigned(Parent) then - Exit; - LBoundsRect := BoundsRect; - for I := 0 to Parent.ControlCount - 1 do - begin - LControl := Parent.Controls[I]; - if LControl = Self then - Break; - if (LControl.BoundsRect * LBoundsRect <> TRect.Empty) and - (LControl.Visible and (not (csDesigning in LControl.ComponentState) or not (csDesignerHide in LControl.ControlState)) or - ((csDesigning in LControl.ComponentState) and not (csDesignerHide in LControl.ControlState)) and - not (csNoDesignVisible in LControl.ControlStyle)) then - begin - DrawControl(LControl, LBoundsRect.TopLeft - LControl.BoundsRect.TopLeft); - end; - end; - end; - -var - LOpaqueParent: TWinControl; -begin - LOpaqueParent := GetOpaqueParent; - if LOpaqueParent = nil then - Exit; - DrawControl(LOpaqueParent, LocalToParent(LOpaqueParent)); - DrawParentChildControls; - if AInvalidateParent and not (LOpaqueParent is TCustomControl) and - not (LOpaqueParent is TCustomForm) and not (csDesigning in ComponentState) then - begin - LOpaqueParent.Invalidate; - end; -end; - -function TSkCustomWinControl.GetOpaqueParent: TWinControl; -begin - if Parent = nil then - Exit(nil); - Result := Self; - while Result.Parent <> nil do - begin - Result := Result.Parent; - if not TWinControlAccess(Result).ParentBackground then - Break; - end; -end; - -function TSkCustomWinControl.NeedsRedraw: Boolean; -begin - Result := (not FDrawCached) or (FDrawCacheKind = TSkDrawCacheKind.Never) or (FDrawBuffer = 0); -end; - -procedure TSkCustomWinControl.Paint; - - procedure InternalDraw; - var - LSurface: ISkSurface; - LDestRect: TRectF; - begin - LSurface := TSkSurface.MakeRasterDirect(TSkImageInfo.Create(Width, Height), FDrawBufferData, FDrawBufferStride); - LSurface.Canvas.Clear(TAlphaColors.Null); - LSurface.Canvas.Concat(TMatrix.CreateScaling(ScaleFactor, ScaleFactor)); - LDestRect := RectF(0, 0, Width / ScaleFactor, Height / ScaleFactor); - Draw(LSurface.Canvas, LDestRect, 1); - if Assigned(FOnDraw) then - FOnDraw(Self, LSurface.Canvas, LDestRect, 1); - FDrawCached := True; - end; - -const - BlendFunction: TBlendFunction = (BlendOp: AC_SRC_OVER; BlendFlags: 0; SourceConstantAlpha: 255; AlphaFormat: AC_SRC_ALPHA); -var - LOldObj: HGDIOBJ; - LDrawBufferDC: HDC; - LBlendFunction: TBlendFunction; -begin - if (Width <= 0) or (Height <= 0) then - Exit; - - LDrawBufferDC := CreateCompatibleDC(0); - if LDrawBufferDC <> 0 then - try - if FDrawParentInBackground then - begin - if FBackgroundBuffer = nil then - begin - FBackgroundBuffer := TBitmap.Create; - FBackgroundBuffer.SetSize(Width, Height); - end; - if (Parent <> nil) and Parent.DoubleBuffered then - PerformEraseBackground(Self, FBackgroundBuffer.Canvas.Handle); - DrawParentImage(FBackgroundBuffer.Canvas.Handle); - end; - - if FDrawBuffer = 0 then - CreateBuffer(LDrawBufferDC, FDrawBuffer, FDrawBufferData, FDrawBufferStride); - if FDrawBuffer <> 0 then - begin - LOldObj := SelectObject(LDrawBufferDC, FDrawBuffer); - try - if NeedsRedraw then - InternalDraw; - LBlendFunction := BlendFunction; - LBlendFunction.SourceConstantAlpha := FOpacity; - if FDrawParentInBackground then - AlphaBlend(FBackgroundBuffer.Canvas.Handle, 0, 0, Width, Height, LDrawBufferDC, 0, 0, Width, Height, LBlendFunction) - else - AlphaBlend(Canvas.Handle, 0, 0, Width, Height, LDrawBufferDC, 0, 0, Width, Height, LBlendFunction); - finally - if LOldObj <> 0 then - SelectObject(LDrawBufferDC, LOldObj); - end; - end; - - if FDrawParentInBackground then - Canvas.Draw(0, 0, FBackgroundBuffer); - finally - DeleteDC(LDrawBufferDC); - end; -end; - -procedure TSkCustomWinControl.Redraw; -begin - FDrawCached := False; - Repaint; -end; - -procedure TSkCustomWinControl.Resize; -begin - DeleteBuffers; - inherited; -end; - -procedure TSkCustomWinControl.SetDrawCacheKind(const AValue: TSkDrawCacheKind); -begin - if FDrawCacheKind <> AValue then - begin - FDrawCacheKind := AValue; - if FDrawCacheKind <> TSkDrawCacheKind.Always then - Repaint; - end; -end; - -procedure TSkCustomWinControl.SetDrawParentInBackground(const AValue: Boolean); -begin - if FDrawParentInBackground <> AValue then - begin - FDrawParentInBackground := AValue; - Repaint; - end; -end; - -procedure TSkCustomWinControl.SetOnDraw(const AValue: TSkDrawEvent); -begin - if TMethod(FOnDraw) <> TMethod(AValue) then - begin - FOnDraw := AValue; - Redraw; - end; -end; - -procedure TSkCustomWinControl.SetOpacity(const AValue: Byte); -begin - if FOpacity <> AValue then - begin - FOpacity := AValue; - Repaint; - end; -end; - -procedure TSkCustomWinControl.WMEraseBkgnd(var AMessage: TWMEraseBkgnd); -var - LOpaqueParent: TWinControl; -begin - if FDrawParentInBackground then - begin - LOpaqueParent := GetOpaqueParent; - if (LOpaqueParent <> nil) and LOpaqueParent.DoubleBuffered then - PerformEraseBackground(Self, AMessage.DC); - DrawParentImage(AMessage.DC, True); - AMessage.Result := 1; - end - else - inherited; -end; - -{ TSkCustomAnimation.TProcess } - -class procedure TSkCustomAnimation.TProcess.Add(const AAnimation: TSkCustomAnimation); -begin - if FProcess = nil then - FProcess := TProcess.Create; - FProcess.DoAdd(AAnimation); -end; - -constructor TSkCustomAnimation.TProcess.Create; -begin - inherited Create; - FAniList := TList.Create; - FAniProcessingList := TList.Create; - FrameRate := EnsureRange(FrameRate, 5, 120); - FAnimation := TTimer.Create(nil); - FAnimation.Enabled := False; - FAnimation.Interval := Trunc(1000 / FrameRate); - FAnimation.OnTimer := OnProcess; - if not QueryPerformanceFrequency(FPerformanceFrequency) then - FPerformanceFrequency := 0; -end; - -destructor TSkCustomAnimation.TProcess.Destroy; -begin - FreeAndNil(FAniList); - FAniProcessingList.Free; - FAnimation.Free; - inherited; -end; - -class destructor TSkCustomAnimation.TProcess.Destroy; -begin - FProcess.Free; - inherited; -end; - -procedure TSkCustomAnimation.TProcess.DoAdd(const AAnimation: TSkCustomAnimation); -begin - if FAniList.IndexOf(AAnimation) < 0 then - FAniList.Add(AAnimation); - if not FAnimation.Enabled and (FAniList.Count > 0) then - FTime := GetTick; - FAnimation.Enabled := FAniList.Count > 0; -end; - -procedure TSkCustomAnimation.TProcess.DoRemove(const AAnimation: TSkCustomAnimation); -begin - if FAniList <> nil then - begin - FAniList.Remove(AAnimation); - FAniProcessingList.Remove(AAnimation); - FAnimation.Enabled := FAniList.Count > 0; - end; -end; - -function TSkCustomAnimation.TProcess.GetTick: Double; -var - LPerformanceCounter: Int64; -begin - if FPerformanceFrequency = 0 then - Result := timeGetTime / MSecsPerSec - else - begin - QueryPerformanceCounter(LPerformanceCounter); - Result := LPerformanceCounter / FPerformanceFrequency; - end; -end; - -procedure TSkCustomAnimation.TProcess.OnProcess(ASender: TObject); -var - I: Integer; - LNewTime: Double; - LDeltaTime: Double; - [unsafe] LAnimation: TSkCustomAnimation; -begin - FrameRate := EnsureRange(FrameRate, 5, 120); - FAnimation.Interval := Trunc(1000 / FrameRate); - LNewTime := GetTick; - LDeltaTime := LNewTime - FTime; - if LDeltaTime < TimeEpsilon then - Exit; - FTime := LNewTime; - if FAniList.Count > 0 then - begin - FAniProcessingList.AddRange(FAniList); - I := FAniProcessingList.Count - 1; - while I >= 0 do - begin - if I < FAniProcessingList.Count then - begin - LAnimation := FAniProcessingList[I]; - FAniProcessingList.Delete(I); - if LAnimation.Running then - LAnimation.ProcessTick(LDeltaTime); - Dec(I); - end - else - I := FAniProcessingList.Count - 1; - end; - end; -end; - -class procedure TSkCustomAnimation.TProcess.Remove( - const AAnimation: TSkCustomAnimation); -begin - if FProcess <> nil then - FProcess.DoRemove(AAnimation); -end; - -{ TSkCustomAnimation } - -procedure TSkCustomAnimation.BeforePaint; -begin - if FNeedStart then - begin - if FAllowAnimation then - InternalStart(False) - else - FNeedStartRepaint := True; - end; -end; - -function TSkCustomAnimation.CanProcessing: Boolean; -begin - Result := FRunning and (not FPause) and (FSpeed >= SpeedEpsilon) and (FProcessDuration >= TimeEpsilon) and (FAllowAnimation or not FLoop); -end; - -constructor TSkCustomAnimation.Create(const AOwner: TComponent); -begin - inherited Create; - FOwner := AOwner; - Assign(nil); -end; - -destructor TSkCustomAnimation.Destroy; -begin - SetProcessing(False); - inherited; -end; - -procedure TSkCustomAnimation.DoAssign(ASource: TPersistent); -var - LSourceAnimation: TSkCustomAnimation absolute ASource; -begin - if ASource = nil then - begin - AutoReverse := DefaultAutoReverse; - Delay := DefaultDelay; - Enabled := DefaultEnabled; - Inverse := DefaultInverse; - Loop := DefaultLoop; - Pause := DefaultPause; - Speed := DefaultSpeed; - StartFromCurrent := DefaultStartFromCurrent; - StartProgress := DefaultStartProgress; - StopProgress := DefaultStopProgress; - DoSetCurrentTime(0); - SetRunning(False); - end - else if ASource is TSkCustomAnimation then - begin - AutoReverse := LSourceAnimation.AutoReverse; - Delay := LSourceAnimation.Delay; - Enabled := LSourceAnimation.Enabled; - Inverse := LSourceAnimation.Inverse; - Loop := LSourceAnimation.Loop; - Pause := LSourceAnimation.Pause; - Speed := LSourceAnimation.Speed; - StartFromCurrent := LSourceAnimation.StartFromCurrent; - StartProgress := LSourceAnimation.StartProgress; - StopProgress := LSourceAnimation.StopProgress; - DoSetCurrentTime(LSourceAnimation.CurrentTime); - SetRunning(LSourceAnimation.Running); - end - else - inherited; -end; - -procedure TSkCustomAnimation.DoChanged; -var - LCanProcess: Boolean; -begin - UpdateCurrentTime(FRunning, True); - LCanProcess := FAllowAnimation; - - if FEnabledChanged then - begin - FEnabledChanged := False; - if not FEnabled then - Stop - else if (not Assigned(FOwner)) or (not (csDesigning in FOwner.ComponentState)) then - begin - FNeedStart := True; - FNeedStartRepaint := False; - end; - end; - if FNeedStart and FNeedStartRepaint and FAllowAnimation then - begin - Start; - LCanProcess := False; - end; - SetProcessing(CanProcessing); - inherited; - if LCanProcess then - DoProcess; -end; - -function TSkCustomAnimation.DoSetCurrentTime(const AValue: Double): Boolean; -begin - Result := SetValue(FDelayTime, 0, TimeEpsilon); - Result := SetValue(FCurrentTime, EnsureRange(AValue, 0, FDuration), TimeEpsilon) or Result; -end; - -function TSkCustomAnimation.Equals(AObject: TObject): Boolean; -var - LSourceAnimation: TSkCustomAnimation absolute AObject; -begin - Result := (AObject is TSkCustomAnimation) and - (FAutoReverse = LSourceAnimation.AutoReverse) and - (FEnabled = LSourceAnimation.Enabled) and - (FInverse = LSourceAnimation.Inverse) and - (FLoop = LSourceAnimation.Loop) and - (FPause = LSourceAnimation.Pause) and - (FStartFromCurrent = LSourceAnimation.StartFromCurrent) and - (FRunning = LSourceAnimation.Running) and - SameValue(FCurrentTime, LSourceAnimation.CurrentTime, TimeEpsilon) and - SameValue(FDelay, LSourceAnimation.Delay, TimeEpsilon) and - SameValue(FSpeed, LSourceAnimation.Speed, SpeedEpsilon) and - SameValue(FStartProgress, LSourceAnimation.StartProgress, ProgressEpsilon) and - SameValue(FStopProgress, LSourceAnimation.StopProgress, ProgressEpsilon); -end; - -function TSkCustomAnimation.GetDuration: Double; -begin - Result := FDuration; -end; - -procedure TSkCustomAnimation.InternalStart(const ACanProcess: Boolean); -begin - FNeedStart := False; - if not FLoop then - FTickCount := 0; - if FAutoReverse then - begin - if FRunning then - FInverse := FSavedInverse - else - FSavedInverse := FInverse; - end; - if FProcessDuration < TimeEpsilon then - begin - SetStartValues(0, True); - FRunning := True; - DoStart; - if ACanProcess and FAllowAnimation then - DoProcess; - FRunning := False; - FProcessTime := 0; - DoFinish; - end - else - begin - SetStartValues(FDelay, False); - FRunning := True; - FEnabled := True; - SetProcessing(CanProcessing); - - if FDelay < TimeEpsilon then - begin - DoStart; - if ACanProcess and FAllowAnimation then - DoProcess; - end - else - DoStart; - end; -end; - -function TSkCustomAnimation.IsDelayStored: Boolean; -begin - Result := not SameValue(FDelay, DefaultDelay, TimeEpsilon); -end; - -function TSkCustomAnimation.IsProgressStored: Boolean; -begin - Result := not SameValue(FProgress, DefaultStartProgress, ProgressEpsilon); -end; - -function TSkCustomAnimation.IsSpeedStored: Boolean; -begin - Result := not SameValue(FSpeed, DefaultSpeed, SpeedEpsilon); -end; - -function TSkCustomAnimation.IsStartProgressStored: Boolean; -begin - Result := not SameValue(FStartProgress, DefaultStartProgress, ProgressEpsilon); -end; - -function TSkCustomAnimation.IsStopProgressStored: Boolean; -begin - Result := not SameValue(FStopProgress, DefaultStopProgress, ProgressEpsilon); -end; - -procedure TSkCustomAnimation.ProcessTick(ADeltaTime: Double); -begin - if Assigned(FOwner) and (csDestroying in FOwner.ComponentState) then - Exit; - SetProcessing(CanProcessing); - if (not FRunning) or FPause or (FSpeed < SpeedEpsilon) or (not FProcessing) then - Exit; - - if FDelayTime >= TimeEpsilon then - begin - FDelayTime := FDelayTime - ADeltaTime; - if FDelayTime < TimeEpsilon then - begin - ADeltaTime := Max(-FDelayTime, 0); - SetStartValues(0, False); - if ADeltaTime < TimeEpsilon then - Exit; - end - else - Exit; - end; - - if FInverse then - FProcessTime := FProcessTime - ADeltaTime * FSpeed - else - FProcessTime := FProcessTime + ADeltaTime * FSpeed; - if FProcessTime >= FProcessDuration then - begin - FProcessTime := FProcessDuration; - if FLoop then - begin - if FAutoReverse then - begin - FInverse := True; - FProcessTime := FProcessDuration; - end - else - FProcessTime := 0; - end - else - if FAutoReverse and (FTickCount = 0) then - begin - Inc(FTickCount); - FInverse := True; - FProcessTime := FProcessDuration; - end - else - FRunning := False; - end - else if FProcessTime <= 0 then - begin - FProcessTime := 0; - if FLoop then - begin - if FAutoReverse then - begin - FInverse := False; - FProcessTime := 0; - end - else - FProcessTime := FProcessDuration; - end - else - if FAutoReverse and (FTickCount = 0) then - begin - Inc(FTickCount); - FInverse := False; - FProcessTime := 0; - end - else - FRunning := False; - end; - UpdateCurrentTime(True, Updating); - - if not FRunning then - begin - if FAutoReverse then - FInverse := FSavedInverse; - FEnabled := False; - SetProcessing(False); - end; - - if FAllowAnimation then - DoProcess; - if not FRunning then - DoFinish; -end; - -procedure TSkCustomAnimation.SetAllowAnimation(const AValue: Boolean); -begin - SetValue(FAllowAnimation, AValue); -end; - -procedure TSkCustomAnimation.SetCurrentTime(const AValue: Double); -begin - BeginUpdate; - try - FCurrentTimeChanged := DoSetCurrentTime(RoundTo(AValue, TimeRoundTo)) or FCurrentTimeChanged; - finally - EndUpdate; - end; -end; - -procedure TSkCustomAnimation.SetDelay(const AValue: Double); -begin - FDelay := Max(0, RoundTo(AValue, TimeRoundTo)); - FDelayTime := Min(FDelayTime, FDelay); -end; - -procedure TSkCustomAnimation.SetDuration(const AValue: Double); -begin - SetValue(FDuration, Max(RoundTo(AValue, TimeRoundTo), 0), TimeEpsilon); -end; - -procedure TSkCustomAnimation.SetEnabled(const AValue: Boolean); -begin - BeginUpdate; - try - FEnabledChanged := SetValue(FEnabled, AValue) or FEnabledChanged; - finally - EndUpdate; - end; -end; - -procedure TSkCustomAnimation.SetLoop(const AValue: Boolean); -begin - SetValue(FLoop, AValue); -end; - -procedure TSkCustomAnimation.SetPause(const AValue: Boolean); -begin - SetValue(FPause, AValue); -end; - -procedure TSkCustomAnimation.SetProcessing(const AValue: Boolean); -begin - if FProcessing <> AValue then - begin - FProcessing := AValue; - if FProcessing then - TProcess.Add(Self) - else - TProcess.Remove(Self); - end; -end; - -procedure TSkCustomAnimation.SetProgress(const AValue: Double); -begin - FSavedProgress := AValue; - CurrentTime := FDuration * EnsureRange(AValue, 0, 1); -end; - -procedure TSkCustomAnimation.SetRunning(const AValue: Boolean); -begin - SetValue(FRunning, AValue); -end; - -procedure TSkCustomAnimation.SetSpeed(const AValue: Double); -begin - SetValue(FSpeed, Max(RoundTo(AValue, SpeedRoundTo), 0), SpeedEpsilon); -end; - -procedure TSkCustomAnimation.SetStartProgress(const AValue: Double); -begin - SetValue(FStartProgress, EnsureRange(AValue, 0, 1), ProgressEpsilon); -end; - -procedure TSkCustomAnimation.SetStartValues(const ADelayTime: Double; const AStartAtEnd: Boolean); -begin - FDelayTime := ADelayTime; - if FStartFromCurrent and not AStartAtEnd then - FProcessTime := EnsureRange(FCurrentTime - Min(FStartProgress, FStopProgress) * FDuration, 0, FProcessDuration) - else - FProcessTime := IfThen(FInverse = AStartAtEnd, 0, FProcessDuration); - UpdateCurrentTime(True, Updating); -end; - -procedure TSkCustomAnimation.SetStopProgress(const AValue: Double); -begin - SetValue(FStopProgress, EnsureRange(AValue, 0, 1), ProgressEpsilon); -end; - -procedure TSkCustomAnimation.Start; -begin - InternalStart(True); -end; - -procedure TSkCustomAnimation.Stop; -begin - FNeedStart := False; - if not FRunning then - Exit; - if FAutoReverse then - FInverse := FSavedInverse; - if FInverse then - begin - FCurrentTime := 0; - FProgress := 0; - end - else - begin - FCurrentTime := FProcessDuration; - FProgress := 1; - end; - if FAllowAnimation then - DoProcess; - FRunning := False; - FEnabled := False; - SetProcessing(False); - DoFinish; -end; - -procedure TSkCustomAnimation.StopAtCurrent; -begin - FNeedStart := False; - if not FRunning then - Exit; - if FAutoReverse then - FInverse := FSavedInverse; - FRunning := False; - FEnabled := False; - SetProcessing(False); - DoFinish; -end; - -procedure TSkCustomAnimation.UpdateCurrentTime(const AIsRunning, ARecalcProcessDuration: Boolean); -begin - if ARecalcProcessDuration then - begin - FProcessDuration := Abs(FStopProgress - FStartProgress) * FDuration; - if FProcessDuration < TimeEpsilon then - FProcessDuration := 0; - end; - if FCurrentTimeChanged and AIsRunning then - FProcessTime := EnsureRange(FCurrentTime - Min(FStartProgress, FStopProgress) * FDuration, 0, FProcessDuration); - if AIsRunning then - FCurrentTime := Min(FStartProgress, FStopProgress) * FDuration + FProcessTime - else - FCurrentTime := EnsureRange(FCurrentTime, 0, FDuration); - FCurrentTimeChanged := False; - if FDuration < TimeEpsilon then - begin - if FInverse then - FProgress := FStopProgress - else - FProgress := FStartProgress; - end - else - FProgress := FCurrentTime / FDuration; -end; - -{ TSkCustomAnimatedControl.TAnimationBase } - -procedure TSkCustomAnimatedControl.TAnimationBase.DoChanged; -begin - inherited; - if Created then - TSkCustomAnimatedControl(Owner).DoAnimationChanged; -end; - -procedure TSkCustomAnimatedControl.TAnimationBase.DoFinish; -begin - TSkCustomAnimatedControl(Owner).DoAnimationFinish; -end; - -procedure TSkCustomAnimatedControl.TAnimationBase.DoProcess; -begin - if FInsideDoProcess then - Exit; - FInsideDoProcess := True; - try - TSkCustomAnimatedControl(Owner).DoAnimationProcess; - finally - FInsideDoProcess := False; - end; -end; - -procedure TSkCustomAnimatedControl.TAnimationBase.DoStart; -begin - TSkCustomAnimatedControl(Owner).DoAnimationStart; -end; - -{ TSkCustomAnimatedControl } - -function TSkCustomAnimatedControl.CanRunAnimation: Boolean; -begin - Result := Assigned(Parent) and ([csDestroying, csLoading] * ComponentState = []) and - AbsoluteVisible and (Width > 0) and (Height > 0) and (WindowHandle <> 0); -end; - -procedure TSkCustomAnimatedControl.CheckAbsoluteVisible; -begin - FAbsoluteVisibleCached := False; - if Assigned(FAnimation) and FAnimation.Loop and FAnimation.Running and (not FAbsoluteVisible) and AbsoluteVisible then - FAnimation.Start; - CheckAnimation; -end; - -procedure TSkCustomAnimatedControl.CheckAnimation; -begin - if Assigned(FAnimation) then - FAnimation.AllowAnimation := CanRunAnimation; -end; - -procedure TSkCustomAnimatedControl.CheckDuration; -begin - if Assigned(FAnimation) then - begin - if SameValue(FAnimation.Duration, 0, TAnimationBase.TimeEpsilon) then - DrawCacheKind := TSkDrawCacheKind.Raster - else - DrawCacheKind := TSkDrawCacheKind.Never; - end; -end; - -{$IF CompilerVersion >= 34} - -procedure TSkCustomAnimatedControl.CMParentVisibleChanged( - var AMessage: TMessage); -begin - CheckAbsoluteVisible; - inherited; -end; - -{$ELSE} - -procedure TSkCustomAnimatedControl.CMShowingChanged(var AMessage: TMessage); -begin - CheckAbsoluteVisible; - inherited; -end; - -{$ENDIF} - -procedure TSkCustomAnimatedControl.CMVisibleChanged(var AMessage: TMessage); -begin - CheckAbsoluteVisible; - inherited; -end; - -constructor TSkCustomAnimatedControl.Create(AOwner: TComponent); -begin - inherited; - FAnimation := CreateAnimation; - FAbsoluteVisible := Visible; - FAbsoluteVisibleCached := True; - CheckDuration; - DrawParentInBackground := True; -end; - -destructor TSkCustomAnimatedControl.Destroy; -begin - FAnimation.Free; - inherited; -end; - -procedure TSkCustomAnimatedControl.DoAnimationChanged; -begin - CheckDuration; - if csDesigning in ComponentState then - Repaint; -end; - -procedure TSkCustomAnimatedControl.DoAnimationFinish; -begin - if WindowHandle <> 0 then - Paint; - if Assigned(FOnAnimationFinish) then - FOnAnimationFinish(Self); -end; - -procedure TSkCustomAnimatedControl.DoAnimationProcess; -begin - CheckAnimation; - if WindowHandle <> 0 then - Paint; - if Assigned(FOnAnimationProcess) then - FOnAnimationProcess(Self); -end; - -procedure TSkCustomAnimatedControl.DoAnimationStart; -begin - if Assigned(FOnAnimationStart) then - FOnAnimationStart(Self); -end; - -procedure TSkCustomAnimatedControl.Draw(const ACanvas: ISkCanvas; - const ADest: TRectF; const AOpacity: Single); -begin - inherited; - if not FAnimation.AllowAnimation then - CheckAnimation; - FAnimation.BeforePaint; - RenderFrame(ACanvas, ADest, FAnimation.Progress, AOpacity); -end; - -function TSkCustomAnimatedControl.GetAbsoluteVisible: Boolean; - - function GetParentedVisible: Boolean; - var - LControl: TWinControl; - begin - if not Visible then - Exit(False); - LControl := Parent; - while LControl <> nil do - begin - if not LControl.Visible then - Exit(False); - LControl := LControl.Parent; - end; - Result := True; - end; - -begin - if not FAbsoluteVisibleCached then - begin - FAbsoluteVisible := GetParentedVisible; - FAbsoluteVisibleCached := True; - end; - Result := FAbsoluteVisible; -end; - -procedure TSkCustomAnimatedControl.ReadState(AReader: TReader); -begin - FAnimation.BeginUpdate; - try - FAnimation.SavedProgress := FAnimation.Progress; - inherited; - FAnimation.Progress := FAnimation.SavedProgress; - finally - FAnimation.EndUpdate; - end; -end; - -procedure TSkCustomAnimatedControl.RenderFrame(const ACanvas: ISkCanvas; - const ADest: TRectF; const AProgress: Double; const AOpacity: Single); -begin - if Assigned(FOnAnimationDraw) then - FOnAnimationDraw(Self, ACanvas, ADest, AProgress, AOpacity); -end; - -procedure TSkCustomAnimatedControl.SetOnAnimationDraw(const AValue: TSkAnimationDrawEvent); -begin - if TMethod(FOnAnimationDraw) <> TMethod(AValue) then - begin - FOnAnimationDraw := AValue; - Redraw; - end; -end; - -{ TSkAnimatedPaintBox.TAnimation } - -constructor TSkAnimatedPaintBox.TAnimation.Create(const AOwner: TComponent); -begin - inherited Create(AOwner); - Duration := DefaultDuration; -end; - -procedure TSkAnimatedPaintBox.TAnimation.DoAssign(ASource: TPersistent); -var - LSourceAnimation: TSkCustomAnimation absolute ASource; -begin - if ASource = nil then - Duration := DefaultDuration - else if ASource is TSkCustomAnimation then - Duration := LSourceAnimation.Duration; - inherited; -end; - -function TSkAnimatedPaintBox.TAnimation.Equals(AObject: TObject): Boolean; -var - LSourceAnimation: TSkCustomAnimation absolute AObject; -begin - Result := inherited and SameValue(Duration, LSourceAnimation.Duration, TimeEpsilon); -end; - -function TSkAnimatedPaintBox.TAnimation.IsDurationStored: Boolean; -begin - Result := not SameValue(Duration, DefaultDuration, TimeEpsilon); -end; - -{ TSkAnimatedPaintBox } - -function TSkAnimatedPaintBox.CreateAnimation: TSkCustomAnimatedControl.TAnimationBase; -begin - Result := TAnimation.Create(Self); -end; - -procedure TSkAnimatedPaintBox.DefineProperties(AFiler: TFiler); -begin - inherited; - // Backward compatibility with version 3 - AFiler.DefineProperty('Animate', ReadAnimate, nil, False); - AFiler.DefineProperty('Duration', ReadDuration, nil, False); - AFiler.DefineProperty('Loop', ReadLoop, nil, False); -end; - -function TSkAnimatedPaintBox.GetAnimation: TSkAnimatedPaintBox.TAnimation; -begin - Result := TSkAnimatedPaintBox.TAnimation(FAnimation); -end; - -procedure TSkAnimatedPaintBox.ReadAnimate(AReader: TReader); -begin - Animation.Enabled := AReader.ReadBoolean; -end; - -procedure TSkAnimatedPaintBox.ReadDuration(AReader: TReader); -begin - Animation.Duration := AReader.ReadFloat; -end; - -procedure TSkAnimatedPaintBox.ReadLoop(AReader: TReader); -begin - Animation.Loop := AReader.ReadBoolean; -end; - -procedure TSkAnimatedPaintBox.SetAnimation(const AValue: TSkAnimatedPaintBox.TAnimation); -begin - FAnimation.Assign(AValue); -end; - -{ TSkAnimatedPaintBoxHelper } - -function TSkAnimatedPaintBoxHelper.Animate: Boolean; -begin - Result := Animation.Enabled; -end; - -function TSkAnimatedPaintBoxHelper.Duration: Double; -begin - Result := Animation.Duration; -end; - -function TSkAnimatedPaintBoxHelper.FixedProgress: Boolean; -begin - Result := not Animation.Enabled; -end; - -function TSkAnimatedPaintBoxHelper.Loop: Boolean; -begin - Result := Animation.Loop; -end; - -function TSkAnimatedPaintBoxHelper.Progress: Double; -begin - Result := Animation.Progress; -end; - -function TSkAnimatedPaintBoxHelper.RunningAnimation: Boolean; -begin - Result := Animation.Running; -end; - -{ TSkAnimatedImage.TSource } - -procedure TSkAnimatedImage.TSource.Assign(ASource: TPersistent); -begin - if ASource is TSource then - Data := TSource(ASource).Data - else if ASource = nil then - Data := nil - else - inherited; -end; - -constructor TSkAnimatedImage.TSource.Create(const AOnChange: TChangeProc); -begin - inherited Create; - FOnChange := AOnChange; -end; - -function TSkAnimatedImage.TSource.Equals(AObject: TObject): Boolean; -begin - Result := (AObject is TSource) and IsSameBytes(FData, TSource(AObject).Data); -end; - -procedure TSkAnimatedImage.TSource.SetData(const AValue: TBytes); -begin - if not IsSameBytes(FData, AValue) then - begin - FData := Copy(AValue); - if Assigned(FOnChange) then - FOnChange(); - end; -end; - -{ TSkAnimatedImage.TFormatInfo } - -constructor TSkAnimatedImage.TFormatInfo.Create(const AName, - ADescription: string; const AExtensions: TArray); -begin - Name := AName; - Description := ADescription; - Extensions := AExtensions; -end; - -{ TSkAnimatedImage } - -constructor TSkAnimatedImage.Create(AOwner: TComponent); -begin - inherited; - FSource := TSource.Create(SourceChange); -end; - -function TSkAnimatedImage.CreateAnimation: TSkCustomAnimatedControl.TAnimationBase; -begin - Result := TAnimation.Create(Self); -end; - -procedure TSkAnimatedImage.DefineProperties(AFiler: TFiler); - - function DoWrite: Boolean; - begin - if AFiler.Ancestor <> nil then - Result := (not (AFiler.Ancestor is TSkAnimatedImage)) or not TSkAnimatedImage(AFiler.Ancestor).Source.Equals(FSource) - else - Result := FSource.Data <> nil; - end; - -begin - inherited; - AFiler.DefineBinaryProperty('Data', ReadData, WriteData, DoWrite); - // Backward compatibility with version 3 - AFiler.DefineProperty('Loop', ReadLoop, nil, False); - AFiler.DefineProperty('OnAnimationFinished', ReadOnAnimationFinished, nil, False); - AFiler.DefineProperty('OnAnimationProgress', ReadOnAnimationProgress, nil, False); -end; - -destructor TSkAnimatedImage.Destroy; -begin - FCodec.Free; - FSource.Free; - inherited; -end; - -procedure TSkAnimatedImage.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; - const AOpacity: Single); -begin - if Assigned(FCodec) then - inherited - else if csDesigning in ComponentState then - DrawDesignBorder(ACanvas, ADest, AOpacity); -end; - -function TSkAnimatedImage.GetAnimation: TAnimation; -begin - Result := TSkAnimatedImage.TAnimation(FAnimation); -end; - -function TSkAnimatedImage.GetOriginalSize: TSizeF; -begin - if Assigned(FCodec) then - Result := FCodec.Size - else - Result := TSizeF.Create(0, 0); -end; - -procedure TSkAnimatedImage.LoadFromFile(const AFileName: string); -begin - FSource.Data := TFile.ReadAllBytes(AFileName); -end; - -procedure TSkAnimatedImage.LoadFromStream(const AStream: TStream); -var - LBytes: TBytes; -begin - SetLength(LBytes, AStream.Size - AStream.Position); - if Length(LBytes) > 0 then - AStream.ReadBuffer(LBytes, 0, Length(LBytes)); - FSource.Data := LBytes; -end; - -procedure TSkAnimatedImage.ReadData(AStream: TStream); -begin - if AStream.Size = 0 then - FSource.Data := nil - else - LoadFromStream(AStream); -end; - -procedure TSkAnimatedImage.ReadLoop(AReader: TReader); -begin - Animation.Loop := AReader.ReadBoolean; -end; - -type - TReaderAccess = class(TReader) end; - -procedure TSkAnimatedImage.ReadOnAnimationFinished(AReader: TReader); -var - LMethod: TMethod; -begin - LMethod := TReaderAccess(AReader).FindMethodInstance(AReader.Root, AReader.ReadIdent); - if LMethod.Code <> nil then - OnAnimationFinish := TNotifyEvent(LMethod); -end; - -procedure TSkAnimatedImage.ReadOnAnimationProgress(AReader: TReader); -var - LMethod: TMethod; -begin - LMethod := TReaderAccess(AReader).FindMethodInstance(AReader.Root, AReader.ReadIdent); - if LMethod.Code <> nil then - OnAnimationProcess := TNotifyEvent(LMethod); -end; - -class procedure TSkAnimatedImage.RegisterCodec( - const ACodecClass: TAnimationCodecClass); -begin - FRegisteredCodecs := FRegisteredCodecs + [ACodecClass]; -end; - -procedure TSkAnimatedImage.RenderFrame(const ACanvas: ISkCanvas; - const ADest: TRectF; const AProgress: Double; const AOpacity: Single); - - function GetWrappedRect(const ADest: TRectF): TRectF; - var - LImageRect: TRectF; - LRatio: Single; - begin - LImageRect := TRectF.Create(PointF(0, 0), FCodec.Size); - case FWrapMode of - TSkAnimatedImageWrapMode.Fit: Result := LImageRect.FitInto(ADest); - TSkAnimatedImageWrapMode.FitCrop: - begin - if (LImageRect.Width / ADest.Width) < (LImageRect.Height / ADest.Height) then - LRatio := LImageRect.Width / ADest.Width - else - LRatio := LImageRect.Height / ADest.Height; - if SameValue(LRatio, 0, TEpsilon.Vector) then - Result := ADest - else - begin - Result := RectF(0, 0, Round(LImageRect.Width / LRatio), Round(LImageRect.Height / LRatio)); - RectCenter(Result, ADest); - end; - end; - TSkAnimatedImageWrapMode.Original: - begin - Result := LImageRect; - Result.Offset(ADest.TopLeft); - end; - TSkAnimatedImageWrapMode.OriginalCenter: - begin - Result := LImageRect; - RectCenter(Result, ADest); - end; - TSkAnimatedImageWrapMode.Place: Result := PlaceIntoTopLeft(LImageRect, ADest); - TSkAnimatedImageWrapMode.Stretch: Result := ADest; - end; - end; - -begin - if Assigned(FCodec) then - begin - if (csDesigning in ComponentState) and (not Animation.Running) and (AProgress = 0) then - FCodec.SeekFrameTime(Animation.Duration / 8) - else - FCodec.SeekFrameTime(Animation.CurrentTime); - ACanvas.Save; - try - ACanvas.ClipRect(ADest); - FCodec.Render(ACanvas, GetWrappedRect(ADest), AOpacity); - finally - ACanvas.Restore; - end; - end; - inherited; -end; - -procedure TSkAnimatedImage.SetAnimation(const AValue: TAnimation); -begin - FAnimation.Assign(AValue); -end; - -procedure TSkAnimatedImage.SetSource(const AValue: TSource); -begin - FSource.Assign(AValue); -end; - -procedure TSkAnimatedImage.SetWrapMode(const AValue: TSkAnimatedImageWrapMode); -begin - if FWrapMode <> AValue then - begin - FWrapMode := AValue; - Redraw; - end; -end; - -procedure TSkAnimatedImage.SourceChange; -var - LCodecClass: TAnimationCodecClass; - LStream: TStream; -begin - FreeAndNil(FCodec); - LStream := TBytesStream.Create(FSource.Data); - try - for LCodecClass in FRegisteredCodecs do - begin - LStream.Position := 0; - if LCodecClass.TryMakeFromStream(LStream, FCodec) then - Break; - end; - finally - LStream.Free; - end; - if Assigned(FCodec) then - begin - Animation.SetDuration(FCodec.Duration); - if Animation.Running then - Animation.Start; - end - else - Animation.SetDuration(0); - Redraw; -end; - -procedure TSkAnimatedImage.WriteData(AStream: TStream); -begin - if FSource.Data <> nil then - AStream.WriteBuffer(FSource.Data, Length(FSource.Data)); -end; - -{ TSkAnimatedImageHelper } - -function TSkAnimatedImageHelper.Duration: Double; -begin - Result := Animation.Duration; -end; - -function TSkAnimatedImageHelper.FixedProgress: Boolean; -begin - Result := not Animation.Enabled; -end; - -function TSkAnimatedImageHelper.Loop: Boolean; -begin - Result := Animation.Loop; -end; - -function TSkAnimatedImageHelper.Progress: Double; -begin - Result := Animation.Progress; -end; - -function TSkAnimatedImageHelper.RunningAnimation: Boolean; -begin - Result := Animation.Running; -end; - -{ TSkDefaultAnimationCodec } - -constructor TSkDefaultAnimationCodec.Create( - const AAnimationCodec: ISkAnimationCodecPlayer; const AStream: TStream); -begin - inherited Create; - FAnimationCodec := AAnimationCodec; - FStream := AStream; -end; - -destructor TSkDefaultAnimationCodec.Destroy; -begin - FStream.Free; - inherited; -end; - -function TSkDefaultAnimationCodec.GetDuration: Double; -begin - Result := FAnimationCodec.Duration / 1000; -end; - -function TSkDefaultAnimationCodec.GetFPS: Double; -begin - Result := TSkCustomAnimation.DefaultFrameRate; -end; - -function TSkDefaultAnimationCodec.GetIsStatic: Boolean; -begin - Result := FAnimationCodec.Duration = 0; -end; - -function TSkDefaultAnimationCodec.GetSize: TSizeF; -begin - Result := FAnimationCodec.Dimensions; -end; - -procedure TSkDefaultAnimationCodec.Render(const ACanvas: ISkCanvas; - const ADest: TRectF; const AOpacity: Single); -var - LPaint: ISkPaint; -begin - if SameValue(AOpacity, 1, TEpsilon.Position) then - LPaint := nil - else - begin - LPaint := TSkPaint.Create; - LPaint.AlphaF := AOpacity; - end; - ACanvas.DrawImageRect(FAnimationCodec.Frame, ADest, TSkSamplingOptions.Medium, LPaint); -end; - -procedure TSkDefaultAnimationCodec.SeekFrameTime(const ATime: Double); -begin - FAnimationCodec.Seek(Round(ATime * 1000)); -end; - -class function TSkDefaultAnimationCodec.SupportedFormats: TArray; -begin - SetLength(Result, Ord(High(TImageFormat)) + 1); - Result[Ord(TImageFormat.GIF)] := TSkAnimatedImage.TFormatInfo.Create('GIF', 'GIF image', ['.gif']); - Result[Ord(TImageFormat.WebP)] := TSkAnimatedImage.TFormatInfo.Create('WebP', 'WebP image', ['.webp']); -end; - -class function TSkDefaultAnimationCodec.TryDetectFormat(const ABytes: TBytes; - out AFormat: TSkAnimatedImage.TFormatInfo): Boolean; - - function IsWebP: Boolean; - const - HeaderRiff: array[0..3] of Byte = ($52, $49, $46, $46); - HeaderWebP: array[0..3] of Byte = ($57, $45, $42, $50); - begin - Result := (Length(ABytes) > 12) and - CompareMem(@HeaderRiff[0], ABytes, Length(HeaderRiff)) and - CompareMem(@HeaderWebP[0], @ABytes[8], Length(HeaderWebP)); - end; - -const - GIFSignature: array[0..2] of Byte = (71, 73, 70); -begin - Result := True; - if (Length(ABytes) >= Length(GIFSignature)) and CompareMem(@GIFSignature[0], ABytes, Length(GIFSignature)) then - AFormat := SupportedFormats[Ord(TImageFormat.GIF)] - else if IsWebP then - AFormat := SupportedFormats[Ord(TImageFormat.WebP)] - else - Result := False; -end; - -class function TSkDefaultAnimationCodec.TryMakeFromStream( - const AStream: TStream; out ACodec: TSkAnimatedImage.TAnimationCodec): Boolean; -var - LAnimationCodec: ISkAnimationCodecPlayer; - LStream: TMemoryStream; -begin - Result := False; - LStream := TMemoryStream.Create; - try - LStream.CopyFrom(AStream, 0); - LStream.Position := 0; - LAnimationCodec := TSkAnimationCodecPlayer.MakeFromStream(LStream); - if Assigned(LAnimationCodec) then - begin - ACodec := TSkDefaultAnimationCodec.Create(LAnimationCodec, LStream); - Result := True; - end - else - ACodec := nil; - finally - if not Result then - LStream.Free; - end; -end; - -{ TSkLottieAnimationCodec } - -constructor TSkLottieAnimationCodec.Create(const ASkottie: ISkottieAnimation); -begin - inherited Create; - FSkottie := ASkottie; -end; - -function TSkLottieAnimationCodec.GetDuration: Double; -begin - Result := FSkottie.Duration; -end; - -function TSkLottieAnimationCodec.GetFPS: Double; -begin - Result := FSkottie.FPS; -end; - -function TSkLottieAnimationCodec.GetIsStatic: Boolean; -begin - Result := False; -end; - -function TSkLottieAnimationCodec.GetSize: TSizeF; -begin - Result := FSkottie.Size; -end; - -procedure TSkLottieAnimationCodec.Render(const ACanvas: ISkCanvas; - const ADest: TRectF; const AOpacity: Single); -var - LLottieRect: TRectF; - LNeedSaveLayer: Boolean; -begin - if ADest.IsEmpty then - Exit; - LLottieRect := TRectF.Create(PointF(0, 0), FSkottie.Size).FitInto(ADest); - if LLottieRect.IsEmpty then - Exit; - LNeedSaveLayer := not SameValue(AOpacity, 1, TEpsilon.Position); - if LNeedSaveLayer then - ACanvas.SaveLayerAlpha(Round(AOpacity * 255)); - try - if SameValue(ADest.Width / LLottieRect.Width, ADest.Height / LLottieRect.Height, TEpsilon.Matrix) then - FSkottie.Render(ACanvas, ADest) - else - begin - if not LNeedSaveLayer then - ACanvas.Save; - try - ACanvas.Scale(ADest.Width / LLottieRect.Width, ADest.Height / LLottieRect.Height); - ACanvas.Translate((LLottieRect.Width - ADest.Width) / 2, (LLottieRect.Height - ADest.Height) / 2); - FSkottie.Render(ACanvas, ADest); - finally - if not LNeedSaveLayer then - ACanvas.Restore; - end; - end; - finally - if LNeedSaveLayer then - ACanvas.Restore; - end; -end; - -procedure TSkLottieAnimationCodec.SeekFrameTime(const ATime: Double); -begin - FSkottie.SeekFrameTime(ATime); -end; - -class function TSkLottieAnimationCodec.SupportedFormats: TArray; -begin - SetLength(Result, Ord(High(TAnimationFormat)) + 1); - Result[Ord(TAnimationFormat.Lottie)] := TSkAnimatedImage.TFormatInfo.Create('Lottie', 'Lottie file', ['.json', '.lottie']); - Result[Ord(TAnimationFormat.TGS)] := TSkAnimatedImage.TFormatInfo.Create('TGS', 'Telegram sticker', ['.tgs']); -end; - -class function TSkLottieAnimationCodec.TryDetectFormat(const ABytes: TBytes; - out AFormat: TSkAnimatedImage.TFormatInfo): Boolean; -const - GZipSignature: Word = $8B1F; -begin - Result := False; - if Length(ABytes) > 4 then - begin - if PWord(ABytes)^ = GZipSignature then - begin - AFormat := SupportedFormats[Ord(TAnimationFormat.TGS)]; - Result := True; - end - else if ((ABytes[0] = $7B) and (ABytes[Length(ABytes) - 1] = $7D)) or - ((PWord(ABytes)^ = $7B00) and (PWord(@ABytes[Length(ABytes) - 2])^ = $7D00)) then - begin - AFormat := SupportedFormats[Ord(TAnimationFormat.Lottie)]; - Result := True; - end; - end; -end; - -class function TSkLottieAnimationCodec.TryMakeFromStream(const AStream: TStream; out ACodec: TSkAnimatedImage.TAnimationCodec): Boolean; - - function IsTgs: Boolean; - const - GZipSignature: Word = $8B1F; - var - LSignature: Word; - LSavePosition: Int64; - begin - if AStream.Size < 2 then - Exit(False); - LSavePosition := AStream.Position; - try - Result := (AStream.ReadData(LSignature) = SizeOf(Word)) and (LSignature = GZipSignature); - finally - AStream.Position := LSavePosition; - end; - end; - - function MakeFromTgsStream(const AStream: TStream): ISkottieAnimation; - var - LDecompressionStream: TDecompressionStream; - begin - LDecompressionStream := TDecompressionStream.Create(AStream, 31); - try - Result := TSkottieAnimation.MakeFromStream(LDecompressionStream, TSkDefaultProviders.Resource); - finally - LDecompressionStream.Free; - end; - end; - -var - LSkottie: ISkottieAnimation; -begin - if IsTgs then - LSkottie := MakeFromTgsStream(AStream) - else - LSkottie := TSkottieAnimation.MakeFromStream(AStream, TSkDefaultProviders.Resource); - - Result := Assigned(LSkottie); - if Result then - ACodec := TSkLottieAnimationCodec.Create(LSkottie) - else - ACodec := nil; -end; - -{ TSkFontComponent } - -procedure TSkFontComponent.AssignTo(ADest: TPersistent); -var - LDestFont: TFont absolute ADest; - LStyle: TFontStyles; -begin - if ADest is TFont then - begin - LDestFont.Name := Families; - LDestFont.Size := Round(Size); - LStyle := []; - if Weight >= TSkFontWeight.Medium then - begin - Include(LStyle, fsBold); - end; - if Slant in [TSkFontSlant.Italic, TSkFontSlant.Oblique] then - Include(LStyle, fsItalic); - LDestFont.Style := LStyle; - end - else - inherited; -end; - -constructor TSkFontComponent.Create; -begin - inherited Create; - Assign(nil); -end; - -procedure TSkFontComponent.DoAssign(ASource: TPersistent); -var - LSourceFont: TSkFontComponent absolute ASource; -begin - if ASource = nil then - begin - Families := DefaultFamilies; - Size := DefaultSize; - Slant := DefaultSlant; - Stretch := DefaultStretch; - Weight := DefaultWeight; - end - else if ASource is TSkFontComponent then - begin - Families := LSourceFont.Families; - Size := LSourceFont.Size; - Slant := LSourceFont.Slant; - Stretch := LSourceFont.Stretch; - Weight := LSourceFont.Weight; - end - else if ASource is TFont then - begin - Families := TFont(ASource).Name; - Size := TFont(ASource).Size; - Stretch := TSkFontStretch.Regular; - if TFontStyle.fsItalic in TFont(ASource).Style then - Slant := TSkFontSlant.Oblique - else - Slant := TSkFontSlant.Regular; - if TFontStyle.fsBold in TFont(ASource).Style then - Weight := TSkFontWeight.Bold - else - Weight := TSkFontWeight.Regular; - end - else - inherited; -end; - -function TSkFontComponent.Equals(AObject: TObject): Boolean; -var - LFont: TSkFontComponent absolute AObject; -begin - Result := (AObject is TSkFontComponent) and - (FFamilies = LFont.Families) and - (FSlant = LFont.Slant) and - (FStretch = LFont.Stretch) and - (FWeight = LFont.Weight) and - SameValue(FSize, LFont.Size, TEpsilon.FontSize); -end; - -function TSkFontComponent.IsFamiliesStored: Boolean; -begin - Result := FFamilies <> DefaultFamilies; -end; - -function TSkFontComponent.IsSizeStored: Boolean; -begin - Result := not SameValue(FSize, DefaultSize, TEpsilon.FontSize); -end; - -procedure TSkFontComponent.SetFamilies(const AValue: string); - - function NormalizeFamilies(const AValue: string): string; - var - LSplitted: TArray; - LFamilies: TArray; - I: Integer; - begin - LSplitted := AValue.Split([',', #13, #10], TStringSplitOptions.ExcludeEmpty); - LFamilies := []; - for I := 0 to Length(LSplitted) - 1 do - begin - LSplitted[I] := LSplitted[I].Trim; - if LSplitted[I] <> '' then - LFamilies := LFamilies + [LSplitted[I]]; - end; - if LFamilies = nil then - Exit(''); - Result := string.Join(', ', LFamilies); - end; - -begin - SetValue(FFamilies, NormalizeFamilies(AValue)); -end; - -procedure TSkFontComponent.SetSize(const AValue: Single); -begin - SetValue(FSize, AValue, TEpsilon.FontSize); -end; - -procedure TSkFontComponent.SetSlant(const AValue: TSkFontSlant); -begin - SetValue(FSlant, AValue); -end; - -procedure TSkFontComponent.SetStretch(const AValue: TSkFontStretch); -begin - SetValue(FStretch, AValue); -end; - -procedure TSkFontComponent.SetWeight(const AValue: TSkFontWeight); -begin - SetValue(FWeight, AValue); -end; - -{ TSkTextSettings.TDecorations } - -constructor TSkTextSettings.TDecorations.Create; -begin - inherited Create; - Assign(nil); -end; - -procedure TSkTextSettings.TDecorations.DoAssign(ASource: TPersistent); -var - LSourceDecorations: TDecorations absolute ASource; -begin - if ASource = nil then - begin - Color := DefaultColor; - Decorations := DefaultDecorations; - StrokeColor := DefaultStrokeColor; - Style := DefaultStyle; - Thickness := DefaultThickness; - end - else if ASource is TDecorations then - begin - Color := LSourceDecorations.Color; - Decorations := LSourceDecorations.Decorations; - StrokeColor := LSourceDecorations.StrokeColor; - Style := LSourceDecorations.Style; - Thickness := LSourceDecorations.Thickness; - end - else - inherited; -end; - -function TSkTextSettings.TDecorations.Equals(AObject: TObject): Boolean; -var - LDecorations: TDecorations absolute AObject; -begin - Result := (AObject is TDecorations) and - (Color = LDecorations.Color) and - (Decorations = LDecorations.Decorations) and - (StrokeColor = LDecorations.StrokeColor) and - (Style = LDecorations.Style) and - (Thickness = LDecorations.Thickness); -end; - -function TSkTextSettings.TDecorations.IsThicknessStored: Boolean; -begin - Result := not SameValue(FThickness, DefaultThickness, TEpsilon.Scale); -end; - -procedure TSkTextSettings.TDecorations.SetColor(const AValue: TAlphaColor); -begin - SetValue(FColor, AValue); -end; - -procedure TSkTextSettings.TDecorations.SetDecorations( - const AValue: TSkTextDecorations); -begin - SetValue(FDecorations, AValue); -end; - -procedure TSkTextSettings.TDecorations.SetStrokeColor( - const AValue: TAlphaColor); -begin - SetValue(FStrokeColor, AValue); -end; - -procedure TSkTextSettings.TDecorations.SetStyle( - const AValue: TSkTextDecorationStyle); -begin - SetValue(FStyle, AValue); -end; - -procedure TSkTextSettings.TDecorations.SetThickness( - const AValue: Single); -begin - SetValue(FThickness, AValue); -end; - -{ TSkTextSettings } - -procedure TSkTextSettings.AssignNotStyled(const ATextSettings: TSkTextSettings; - const AStyledSettings: TSkStyledSettings); -var - LTextSettings: TSkTextSettings; -begin - if AStyledSettings <> AllStyledSettings then - begin - if AStyledSettings = [] then - Assign(ATextSettings) - else - begin - if ATextSettings = nil then - LTextSettings := TSkTextSettingsClass(ClassType).Create(Owner) - else - LTextSettings := ATextSettings; - try - BeginUpdate; - try - DoAssignNotStyled(LTextSettings, AStyledSettings); - finally - EndUpdate; - end; - finally - if ATextSettings = nil then - LTextSettings.Free; - end; - end; - end; -end; - -constructor TSkTextSettings.Create(const AOwner: TPersistent); -begin - inherited Create; - FOwner := AOwner; - FFont := TSkFontComponent.Create; - FFont.OnChange := FontChanged; - FDecorations := TDecorations.Create; - FDecorations.OnChange := DecorationsChange; - Assign(nil); -end; - -procedure TSkTextSettings.DecorationsChange(ASender: TObject); -begin - Change; -end; - -destructor TSkTextSettings.Destroy; -begin - FDecorations.Free; - FFont.Free; - inherited; -end; - -procedure TSkTextSettings.DoAssign(ASource: TPersistent); -var - LSourceTextSettings: TSkTextSettings absolute ASource; -begin - if ASource = nil then - begin - Decorations := nil; - Font := nil; - FontColor := DefaultFontColor; - HeightMultiplier := DefaultHeightMultiplier; - HorzAlign := DefaultHorzAlign; - LetterSpacing := DefaultLetterSpacing; - MaxLines := DefaultMaxLines; - Trimming := DefaultTrimming; - VertAlign := DefaultVertAlign; - end - else if ASource is TSkTextSettings then - begin - Decorations := LSourceTextSettings.Decorations; - Font := LSourceTextSettings.Font; - FontColor := LSourceTextSettings.FontColor; - HeightMultiplier := LSourceTextSettings.HeightMultiplier; - HorzAlign := LSourceTextSettings.HorzAlign; - LetterSpacing := LSourceTextSettings.LetterSpacing; - MaxLines := LSourceTextSettings.MaxLines; - Trimming := LSourceTextSettings.Trimming; - VertAlign := LSourceTextSettings.VertAlign; - end - else - inherited; -end; - -procedure TSkTextSettings.DoAssignNotStyled( - const ATextSettings: TSkTextSettings; const AStyledSettings: TSkStyledSettings); -begin - Font.BeginUpdate; - try - if not (TSkStyledSetting.Family in AStyledSettings) then - Font.Families := ATextSettings.Font.Families; - if not (TSkStyledSetting.Size in AStyledSettings) then - Font.Size := ATextSettings.Font.Size; - if not (TSkStyledSetting.Style in AStyledSettings) then - begin - Font.Slant := ATextSettings.Font.Slant; - Font.Stretch := ATextSettings.Font.Stretch; - Font.Weight := ATextSettings.Font.Weight; - end; - finally - Font.EndUpdate; - end; - if not (TSkStyledSetting.FontColor in AStyledSettings) then - FontColor := ATextSettings.FontColor; - if not (TSkStyledSetting.Other in AStyledSettings) then - begin - Decorations := ATextSettings.Decorations; - HeightMultiplier := ATextSettings.HeightMultiplier; - HorzAlign := ATextSettings.HorzAlign; - LetterSpacing := ATextSettings.LetterSpacing; - VertAlign := ATextSettings.VertAlign; - MaxLines := ATextSettings.MaxLines; - Trimming := ATextSettings.Trimming; - end; -end; - -function TSkTextSettings.Equals(AObject: TObject): Boolean; -var - LTextSettings: TSkTextSettings absolute AObject; -begin - Result := (AObject is TSkTextSettings) and - FDecorations.Equals(LTextSettings.Decorations) and - FFont.Equals(LTextSettings.Font) and - (FFontColor = LTextSettings.FontColor) and - (FHeightMultiplier = LTextSettings.HeightMultiplier) and - (FHorzAlign = LTextSettings.HorzAlign) and - (FLetterSpacing = LTextSettings.LetterSpacing) and - (FMaxLines = LTextSettings.MaxLines) and - (FTrimming = LTextSettings.Trimming) and - (FVertAlign = LTextSettings.VertAlign); -end; - -procedure TSkTextSettings.FontChanged(ASender: TObject); -begin - Change; -end; - -function TSkTextSettings.IsHeightMultiplierStored: Boolean; -begin - Result := not SameValue(FHeightMultiplier, DefaultHeightMultiplier, TEpsilon.Position); -end; - -function TSkTextSettings.IsLetterSpacingStored: Boolean; -begin - Result := not SameValue(FLetterSpacing, DefaultLetterSpacing, TEpsilon.Position); -end; - -procedure TSkTextSettings.SetDecorations(const AValue: TDecorations); -begin - FDecorations.Assign(AValue); -end; - -procedure TSkTextSettings.SetFont(const AValue: TSkFontComponent); -begin - FFont.Assign(AValue); -end; - -procedure TSkTextSettings.SetFontColor(const AValue: TAlphaColor); -begin - SetValue(FFontColor, AValue); -end; - -procedure TSkTextSettings.SetHeightMultiplier(const AValue: Single); -begin - SetValue(FHeightMultiplier, AValue, TEpsilon.Position); -end; - -procedure TSkTextSettings.SetHorzAlign(const AValue: TSkTextHorzAlign); -begin - SetValue(FHorzAlign, AValue); -end; - -procedure TSkTextSettings.SetLetterSpacing(const AValue: Single); -begin - SetValue(FLetterSpacing, AValue, TEpsilon.Position); -end; - -procedure TSkTextSettings.SetMaxLines(const AValue: NativeUInt); -begin - SetValue(FMaxLines, AValue); -end; - -procedure TSkTextSettings.SetTrimming(const AValue: TSkTextTrimming); -begin - SetValue(FTrimming, AValue); -end; - -procedure TSkTextSettings.SetVertAlign(const AValue: TSkTextVertAlign); -begin - SetValue(FVertAlign, AValue); -end; - -procedure TSkTextSettings.UpdateStyledSettings(const AOldTextSettings, - ADefaultTextSettings: TSkTextSettings; var AStyledSettings: TSkStyledSettings); -begin - // If the user changed the value of the property, and it differs from the default, - // then delete the corresponding value from AStyledSettings - if (not SameText(AOldTextSettings.Font.Families, Font.Families)) and - (not SameText(ADefaultTextSettings.Font.Families, Font.Families)) then - begin - Exclude(AStyledSettings, TSkStyledSetting.Family); - end; - - if (not SameValue(AOldTextSettings.Font.Size, Font.Size, TEpsilon.FontSize)) and - (not SameValue(ADefaultTextSettings.Font.Size, Font.Size, TEpsilon.FontSize)) then - begin - Exclude(AStyledSettings, TSkStyledSetting.Size); - end; - - if ((AOldTextSettings.Font.Slant <> Font.Slant) or (AOldTextSettings.Font.Stretch <> Font.Stretch) or - (AOldTextSettings.Font.Weight <> Font.Weight)) and - ((ADefaultTextSettings.Font.Slant <> Font.Slant) or (ADefaultTextSettings.Font.Stretch <> Font.Stretch) or - (ADefaultTextSettings.Font.Weight <> Font.Weight)) then - begin - Exclude(AStyledSettings, TSkStyledSetting.Style); - end; - - if ((AOldTextSettings.FontColor <> FontColor) and (ADefaultTextSettings.FontColor <> FontColor)) then - Exclude(AStyledSettings, TSkStyledSetting.FontColor); - - if ((not AOldTextSettings.Decorations.Equals(Decorations)) or - (AOldTextSettings.HeightMultiplier <> HeightMultiplier) or - (AOldTextSettings.HorzAlign <> HorzAlign) or (AOldTextSettings.VertAlign <> VertAlign) or - (AOldTextSettings.LetterSpacing <> LetterSpacing) or - (AOldTextSettings.Trimming <> Trimming) or (AOldTextSettings.MaxLines <> MaxLines)) and - ((not ADefaultTextSettings.Decorations.Equals(Decorations)) or - (ADefaultTextSettings.HeightMultiplier <> HeightMultiplier) or - (ADefaultTextSettings.HorzAlign <> HorzAlign) or (ADefaultTextSettings.VertAlign <> VertAlign) or - (ADefaultTextSettings.LetterSpacing <> LetterSpacing) or - (ADefaultTextSettings.Trimming <> Trimming) or (ADefaultTextSettings.MaxLines <> MaxLines)) then - begin - Exclude(AStyledSettings, TSkStyledSetting.Other); - end; -end; - -{ TSkTextSettingsInfo.TBaseTextSettings } - -constructor TSkTextSettingsInfo.TBaseTextSettings.Create( - const AOwner: TPersistent); -begin - inherited; - if AOwner is TSkTextSettingsInfo then - begin - FInfo := TSkTextSettingsInfo(AOwner); - if FInfo.Owner is TControl then - FControl := TControl(FInfo.Owner); - end; -end; - -{ TSkTextSettingsInfo.TCustomTextSettings } - -constructor TSkTextSettingsInfo.TCustomTextSettings.Create( - const AOwner: TPersistent); -begin - inherited; - MaxLines := 0; -end; - -{ TSkTextSettingsInfo } - -constructor TSkTextSettingsInfo.Create(AOwner: TPersistent; - ATextSettingsClass: TSkTextSettingsInfo.TCustomTextSettingsClass); -var - LClass: TSkTextSettingsInfo.TCustomTextSettingsClass; -begin - if AOwner = nil then - raise ESkTextSettingsInfo.Create(SArgumentNil); - inherited Create; - FOwner := AOwner; - FStyledSettings := DefaultStyledSettings; - if ATextSettingsClass = nil then - LClass := TCustomTextSettings - else - LClass := ATextSettingsClass; - - FDefaultTextSettings := LClass.Create(Self); - FDefaultTextSettings.OnChange := OnDefaultChanged; - FTextSettings := LClass.Create(Self); - FTextSettings.OnChange := OnTextChanged; - FResultingTextSettings := LClass.Create(Self); - FResultingTextSettings.OnChange := OnCalculatedTextSettings; - FOldTextSettings := LClass.Create(Self); - FOldTextSettings.Assign(FTextSettings); -end; - -destructor TSkTextSettingsInfo.Destroy; -begin - FDefaultTextSettings.Free; - FTextSettings.Free; - FResultingTextSettings.Free; - FOldTextSettings.Free; - inherited; -end; - -procedure TSkTextSettingsInfo.DoCalculatedTextSettings; -begin -end; - -procedure TSkTextSettingsInfo.DoDefaultChanged; -begin - RecalculateTextSettings; -end; - -procedure TSkTextSettingsInfo.DoStyledSettingsChanged; -begin - RecalculateTextSettings; - if Assigned(FOnChange) then - FOnChange(Self); -end; - -procedure TSkTextSettingsInfo.DoTextChanged; -var - LDesign: Boolean; -begin - try - LDesign := Design and (not (Owner is TComponent) or - (TComponent(Owner).ComponentState * [csLoading, csDestroying, csReading] = [])); - if LDesign then - TextSettings.UpdateStyledSettings(FOldTextSettings, DefaultTextSettings, FStyledSettings); - RecalculateTextSettings; - finally - if FOldTextSettings <> nil then - FOldTextSettings.Assign(FTextSettings); - end; - if Assigned(FOnChange) then - FOnChange(Self); -end; - -procedure TSkTextSettingsInfo.OnCalculatedTextSettings(ASender: TObject); -begin - DoCalculatedTextSettings; -end; - -procedure TSkTextSettingsInfo.OnDefaultChanged(ASender: TObject); -begin - DoDefaultChanged; -end; - -procedure TSkTextSettingsInfo.OnTextChanged(ASender: TObject); -begin - DoTextChanged; -end; - -procedure TSkTextSettingsInfo.RecalculateTextSettings; -var - TmpResultingTextSettings: TSkTextSettings; -begin - if ResultingTextSettings <> nil then - begin - TmpResultingTextSettings := TSkTextSettingsClass(TextSettings.ClassType).Create(Self); - try - TmpResultingTextSettings.Assign(DefaultTextSettings); - TmpResultingTextSettings.AssignNotStyled(TextSettings, StyledSettings); - ResultingTextSettings.Assign(TmpResultingTextSettings); - finally - TmpResultingTextSettings.Free; - end; - end; -end; - -procedure TSkTextSettingsInfo.SetDefaultTextSettings( - const AValue: TSkTextSettings); -begin - FDefaultTextSettings.Assign(AValue); -end; - -procedure TSkTextSettingsInfo.SetStyledSettings(const AValue: TSkStyledSettings); -begin - if FStyledSettings <> AValue then - begin - FStyledSettings := AValue; - DoStyledSettingsChanged; - end; -end; - -procedure TSkTextSettingsInfo.SetTextSettings(const AValue: TSkTextSettings); -begin - FTextSettings.Assign(AValue); -end; - -{ TSkLabel.TCustomWordsItem } - -procedure TSkLabel.TCustomWordsItem.Assign(ASource: TPersistent); -begin - if ASource <> Self then - begin - BeginUpdate; - try - DoAssign(ASource); - finally - EndUpdate; - end; - end; -end; - -procedure TSkLabel.TCustomWordsItem.BeginUpdate; -begin - Inc(FUpdatingCount); -end; - -procedure TSkLabel.TCustomWordsItem.Change; -begin - if FUpdatingCount > 0 then - FChanged := True - else - begin - FChanged := False; - DoChanged; - end; -end; - -procedure TSkLabel.TCustomWordsItem.CheckName(const AName: string; - AWordsCollection: TWordsCollection); -var - I: Integer; -begin - if AName.Trim.IsEmpty then - raise ESkLabel.CreateFmt(SInvalidName, [AName]); - if AWordsCollection <> nil then - for I := 0 to AWordsCollection.Count - 1 do - if (AWordsCollection.Items[I] <> Self) and (string.Compare(AName, AWordsCollection.Items[I].Name, [TCompareOption.coIgnoreCase]) = 0) then - raise ESkLabel.CreateFmt(SDuplicateName, [AWordsCollection.Items[I].Name]); -end; - -constructor TSkLabel.TCustomWordsItem.Create(ACollection: TCollection); -var - LTextSettingsInfoOwner: TPersistent; -begin - inherited; - if (ACollection is TWordsCollection) and Assigned(TWordsCollection(ACollection).&Label) then - LTextSettingsInfoOwner := TWordsCollection(ACollection).&Label - else - LTextSettingsInfoOwner := Self; - FTextSettingsInfo := TSkTextSettingsInfo.Create(LTextSettingsInfoOwner, nil); - if LTextSettingsInfoOwner is TSkLabel then - FTextSettingsInfo.Design := True; - Assign(nil); - FTextSettingsInfo.OnChange := TextSettingsChange; -end; - -destructor TSkLabel.TCustomWordsItem.Destroy; -begin - FTextSettingsInfo.Free; - inherited; -end; - -procedure TSkLabel.TCustomWordsItem.DoAssign(ASource: TPersistent); -var - LSourceItem: TCustomWordsItem absolute ASource; -begin - if ASource = nil then - begin - BackgroundColor := DefaultBackgroundColor; - Caption := DefaultCaption; - Cursor := DefaultCursor; - Font := nil; - FontColor := DefaultFontColor; - HeightMultiplier := DefaultHeightMultiplier; - LetterSpacing := DefaultLetterSpacing; - Name := UniqueName(DefaultName, Collection); - StyledSettings := DefaultStyledSettings; - OnClick := nil; - end - else if ASource is TCustomWordsItem then - begin - BackgroundColor := LSourceItem.BackgroundColor; - Caption := LSourceItem.Caption; - Cursor := LSourceItem.Cursor; - Font := LSourceItem.Font; - FontColor := LSourceItem.FontColor; - HeightMultiplier := LSourceItem.HeightMultiplier; - LetterSpacing := LSourceItem.LetterSpacing; - Name := UniqueName(LSourceItem.Name, Collection); - StyledSettings := LSourceItem.StyledSettings; - OnClick := LSourceItem.OnClick; - end - else - inherited Assign(ASource); -end; - -procedure TSkLabel.TCustomWordsItem.DoChanged; -begin - Changed(False); -end; - -procedure TSkLabel.TCustomWordsItem.EndUpdate; -begin - EndUpdate(False); -end; - -procedure TSkLabel.TCustomWordsItem.EndUpdate(const AIgnoreAllChanges: Boolean); -var - LCallChange: Boolean; - LIgnoreChanges: Boolean; -begin - LIgnoreChanges := AIgnoreAllChanges or FIgnoringAllChanges; - LCallChange := False; - if FUpdatingCount <= 0 then - raise ESkLabel.Create('The object is not in update state'); - Dec(FUpdatingCount); - if (not LIgnoreChanges) and FChanged then - LCallChange := True - else - FChanged := False; - if FUpdatingCount <= 0 then - FIgnoringAllChanges := False; - if LCallChange and (FUpdatingCount = 0) then - begin - FChanged := False; - DoChanged; - end; -end; - -function TSkLabel.TCustomWordsItem.GetDecorations: TSkTextSettings.TDecorations; -begin - Result := FTextSettingsInfo.TextSettings.Decorations; -end; - -function TSkLabel.TCustomWordsItem.GetDisplayName: string; -begin - Result := Name; -end; - -function TSkLabel.TCustomWordsItem.GetFont: TSkFontComponent; -begin - Result := FTextSettingsInfo.TextSettings.Font; -end; - -function TSkLabel.TCustomWordsItem.GetFontColor: TAlphaColor; -begin - Result := FTextSettingsInfo.TextSettings.FontColor; -end; - -function TSkLabel.TCustomWordsItem.GetHeightMultiplier: Single; -begin - Result := FTextSettingsInfo.TextSettings.HeightMultiplier; -end; - -function TSkLabel.TCustomWordsItem.GetLetterSpacing: Single; -begin - Result := FTextSettingsInfo.TextSettings.LetterSpacing; -end; - -function TSkLabel.TCustomWordsItem.GetStyledSettings: TSkStyledSettings; -begin - Result := FTextSettingsInfo.StyledSettings; -end; - -function TSkLabel.TCustomWordsItem.IsCaptionStored: Boolean; -begin - Result := Caption <> DefaultCaption; -end; - -function TSkLabel.TCustomWordsItem.IsFontColorStored: Boolean; -begin - Result := (FontColor <> DefaultFontColor) or not (TSkStyledSetting.FontColor in StyledSettings); -end; - -function TSkLabel.TCustomWordsItem.IsHeightMultiplierStored: Boolean; -begin - Result := (not SameValue(HeightMultiplier, DefaultHeightMultiplier, TEpsilon.Position)) or not (TSkStyledSetting.Other in StyledSettings); -end; - -function TSkLabel.TCustomWordsItem.IsLetterSpacingStored: Boolean; -begin - Result := (not SameValue(LetterSpacing, DefaultLetterSpacing, TEpsilon.Position)) or not (TSkStyledSetting.Other in StyledSettings); -end; - -function TSkLabel.TCustomWordsItem.IsNameStored: Boolean; -begin - Result := (Assigned(Collection) and (Collection.Count <> 1)) or (Name <> 'Item 0'); -end; - -function TSkLabel.TCustomWordsItem.IsStyledSettingsStored: Boolean; -begin - Result := StyledSettings <> DefaultStyledSettings; -end; - -procedure TSkLabel.TCustomWordsItem.SetBackgroundColor( - const AValue: TAlphaColor); -begin - if FBackgroundColor <> AValue then - begin - FBackgroundColor := AValue; - Change; - end; -end; - -procedure TSkLabel.TCustomWordsItem.SetCaption(const AValue: string); -begin - if FCaption <> AValue then - begin - FCaption := AValue; - Change; - end; -end; - -procedure TSkLabel.TCustomWordsItem.SetCollection(AValue: TCollection); -var - S: string; -begin - if Assigned(AValue) and not (AValue is TWordsCollection) then - raise ESkLabel.Create('You can use only the inheritors of class "TWordsCollection"'); - S := UniqueName(FName, AValue); - if string.Compare(S, FName, [TCompareOption.coIgnoreCase]) <> 0 then - CheckName(S, TWordsCollection(AValue)); - FName := S; - inherited; - FWords := TWordsCollection(Collection); -end; - -procedure TSkLabel.TCustomWordsItem.SetCursor(const AValue: TCursor); -begin - if FCursor <> AValue then - begin - FCursor := AValue; - Change; - end; -end; - -procedure TSkLabel.TCustomWordsItem.SetDecorations( - const AValue: TSkTextSettings.TDecorations); -begin - FTextSettingsInfo.TextSettings.Decorations.Assign(AValue); -end; - -procedure TSkLabel.TCustomWordsItem.SetFont(const AValue: TSkFontComponent); -begin - FTextSettingsInfo.TextSettings.Font.Assign(AValue); -end; - -procedure TSkLabel.TCustomWordsItem.SetFontColor(const AValue: TAlphaColor); -begin - FTextSettingsInfo.TextSettings.FontColor := AValue; -end; - -procedure TSkLabel.TCustomWordsItem.SetHeightMultiplier(const AValue: Single); -begin - FTextSettingsInfo.TextSettings.HeightMultiplier := AValue; -end; - -procedure TSkLabel.TCustomWordsItem.SetLetterSpacing(const AValue: Single); -begin - FTextSettingsInfo.TextSettings.LetterSpacing := AValue; -end; - -procedure TSkLabel.TCustomWordsItem.SetName(const AValue: string); -var - LValue: string; -begin - LValue := AValue.Trim; - if FName <> LValue then - begin - if string.Compare(LValue, FName, [TCompareOption.coIgnoreCase]) <> 0 then - CheckName(LValue, Words); - FName := LValue; - Change; - end; -end; - -procedure TSkLabel.TCustomWordsItem.SetStyledSettings( - const AValue: TSkStyledSettings); -begin - FTextSettingsInfo.StyledSettings := AValue; -end; - -procedure TSkLabel.TCustomWordsItem.TextSettingsChange(ASender: TObject); -begin - Change; -end; - -function TSkLabel.TCustomWordsItem.UniqueName(const AName: string; - const ACollection: TCollection): string; -var - S: string; - I, J, LIndex, LMaxIndex: Integer; - LFound: Boolean; - LOriginalName: string; - - procedure SeparateNameIndex(var S: string; var AIndex: Integer); - var - I, N: integer; - begin - AIndex := -1; - I := S.Length - 1; - N := 0; - while (N <= 9) and (I >= 0) and S.Chars[I].IsDigit do - begin - Dec(I); - Inc(N); - end; - if (I >= 0) and InRange(N, 1, 5) then - begin - AIndex := S.Substring(I + 1).ToInteger; - S := S.Substring(0, I + 1); - end; - end; - -begin - LOriginalName := AName.Trim; - Result := LOriginalName; - if ACollection <> nil then - begin - SeparateNameIndex(Result, LIndex); - LMaxIndex := -1; - LFound := False; - for I := 0 to ACollection.Count - 1 do - if (ACollection.Items[I] <> Self) and (ACollection.Items[I] is TCustomWordsItem) then - begin - S := TCustomWordsItem(ACollection.Items[I]).Name; - SeparateNameIndex(S, J); - if string.Compare(S, Result, [TCompareOption.coIgnoreCase]) = 0 then - begin - LMaxIndex := Max(LMaxIndex, J); - if (LIndex = J) then - LFound := True; - end; - end; - if LFound then - begin - LMaxIndex := Max(LMaxIndex + 1, 1); - Result := Result + LMaxIndex.ToString; - end - else - Result := LOriginalName; - end; -end; - -{ TSkLabel.TWordsCollection } - -function TSkLabel.TWordsCollection.Add: TCustomWordsItem; -begin - Result := TCustomWordsItem(inherited Add); -end; - -function TSkLabel.TWordsCollection.Add(const ACaption: string; - const AColor: TAlphaColor; const AFontSize: Single; - const AFontWeight: TSkFontComponent.TSkFontWeight; - const AFontSlant: TSkFontComponent.TSkFontSlant): TCustomWordsItem; -begin - Result := Add; - Result.BeginUpdate; - try - Result.Caption := ACaption; - Result.Font.BeginUpdate; - try - Result.Font.Size := AFontSize; - Result.Font.Weight := AFontWeight; - Result.Font.Slant := AFontSlant; - finally - Result.Font.EndUpdate; - end; - Result.FontColor := AColor; - finally - Result.EndUpdate; - end; -end; - -function TSkLabel.TWordsCollection.AddOrSet(const AName, ACaption: string; - const AFontColor: TAlphaColor; const AFont: TSkFontComponent; - const AOnClick: TNotifyEvent; const ACursor: TCursor): TCustomWordsItem; -begin - Result := ItemByName[AName]; - if not Assigned(Result) then - Result := Add; - Result.BeginUpdate; - try - if not AName.IsEmpty then - Result.Name := AName; - Result.Caption := ACaption; - Result.Font := AFont; - Result.FontColor := AFontColor; - Result.OnClick := AOnClick; - Result.Cursor := ACursor; - finally - Result.EndUpdate; - end; -end; - -constructor TSkLabel.TWordsCollection.Create(AOwner: TPersistent; - AItemClass: TCustomWordsItemClass); -begin - if not (AOwner is TSkLabel) then - raise ESkLabel.Create('You can use only the inheritors of class "TSkLabel"'); - inherited Create(AOwner, AItemClass); - FLabel := TSkLabel(AOwner); -end; - -function TSkLabel.TWordsCollection.GetItem(AIndex: Integer): TCustomWordsItem; -begin - Result := TCustomWordsItem(inherited GetItem(AIndex)); -end; - -function TSkLabel.TWordsCollection.GetItemByName( - const AName: string): TCustomWordsItem; -var - LIndex: Integer; -begin - LIndex := IndexOf(AName); - if LIndex = -1 then - Result := nil - else - Result := Items[LIndex]; -end; - -function TSkLabel.TWordsCollection.IndexOf(const AName: string): Integer; -var - I: Integer; -begin - Result := -1; - for I := 0 to Count - 1 do - if string.Compare(AName, Items[I].Name, [TCompareOption.coIgnoreCase]) = 0 then - begin - Result := I; - Break; - end; -end; - -function TSkLabel.TWordsCollection.Insert(AIndex: Integer): TCustomWordsItem; -begin - Result := TCustomWordsItem(inherited Insert(AIndex)); -end; - -procedure TSkLabel.TWordsCollection.SetItem(AIndex: Integer; - const AValue: TCustomWordsItem); -begin - inherited SetItem(AIndex, AValue); -end; - -procedure TSkLabel.TWordsCollection.Update(AItem: TCollectionItem); -begin - inherited; - if (FLabel <> nil) and not (csDestroying in FLabel.ComponentState) then - begin - if Assigned(FOnChange) then - FOnChange(Self); - end; -end; - -{ TSkLabel } - -function TSkLabel.CanAutoSize(var ANewWidth, ANewHeight: Integer): Boolean; -var - LNewWidth: Single; - LNewHeight: Single; -begin - if not (csLoading in ComponentState) then - begin - LNewWidth := ANewWidth; - LNewHeight := ANewHeight; - GetFitSize(LNewWidth, LNewHeight); - ANewWidth := Ceil(LNewWidth); - ANewHeight := Ceil(LNewHeight); - end; - Result := True; -end; - -procedure TSkLabel.Click; -var - LClickedItem: TCustomWordsItem; -begin - LClickedItem := GetWordsItemAtPosition(FClickedPosition.X, FClickedPosition.Y); - if Assigned(LClickedItem) and (LClickedItem = GetWordsItemAtPosition(FPressedPosition.X, FPressedPosition.Y)) then - begin - TMessageManager.DefaultManager.SendMessage(Self, TItemClickedMessage.Create(LClickedItem)); - if Assigned(LClickedItem.OnClick) then - LClickedItem.OnClick(FWordsMouseOver) - else - inherited; - end - else - inherited; -end; - -procedure TSkLabel.CMBiDiModeChanged(var AMessage: TMessage); -begin - TextSettingsChanged(nil); - inherited; -end; - -procedure TSkLabel.CMControlChange(var AMessage: TMessage); -begin - inherited; - if Assigned(FTextSettingsInfo) then - FTextSettingsInfo.Design := csDesigning in ComponentState; -end; - -procedure TSkLabel.CMMouseEnter(var AMessage: TMessage); -begin - FIsMouseOver := True; - inherited; -end; - -procedure TSkLabel.CMMouseLeave(var AMessage: TMessage); -begin - FIsMouseOver := False; - inherited; - SetWordsMouseOver(nil); -end; - -procedure TSkLabel.CMParentBiDiModeChanged(var AMessage: TMessage); -begin - TextSettingsChanged(nil); - inherited; -end; - -constructor TSkLabel.Create(AOwner: TComponent); -begin - inherited; - AutoSize := True; - FTextSettingsInfo := TSkTextSettingsInfo.Create(Self, nil); - FTextSettingsInfo.Design := True;//csDesigning in ComponentState; - FTextSettingsInfo.StyledSettings := []; - FTextSettingsInfo.OnChange := TextSettingsChanged; - FWords := TWordsCollection.Create(Self, TWordsItem); - FWords.OnChange := WordsChange; -end; - -procedure TSkLabel.DeleteParagraph; -begin - FParagraph := nil; - FParagraphStroked := nil; - FParagraphBounds := TRectF.Empty; - FParagraphLayoutWidth := 0; -end; - -destructor TSkLabel.Destroy; -begin - FTextSettingsInfo.Free; - FWords.Free; - inherited; -end; - -function TSkLabel.DidExceedMaxLines: Boolean; -var - LParagraph: ISkParagraph; -begin - LParagraph := Paragraph; - Result := Assigned(LParagraph) and (LParagraph.DidExceedMaxLines); -end; - -procedure TSkLabel.Draw(const ACanvas: ISkCanvas; const ADest: TRectF; - const AOpacity: Single); - - function CreateBackgroundPicture(const AParagraph: ISkParagraph): ISkPicture; - var - LPictureRecorder: ISkPictureRecorder; - LCanvas: ISkCanvas; - LPaint: ISkPaint; - I: Integer; - LTextEndIndex: Integer; - LTextBox: TSkTextBox; - LRects: TArray; - LRectsColor: TArray; - LLastRect: TRectF; - LLastColor: TAlphaColor; - begin - LPictureRecorder := TSkPictureRecorder.Create; - LCanvas := LPictureRecorder.BeginRecording(ADest); - LPaint := TSkPaint.Create; - LPaint.AntiAlias := True; - LTextEndIndex := 0; - LRects := nil; - for I := 0 to FWords.Count - 1 do - begin - Inc(LTextEndIndex, FWords[I].Caption.Length); - if TAlphaColorRec(FWords[I].BackgroundColor).A = 0 then - Continue; - for LTextBox in AParagraph.GetRectsForRange(LTextEndIndex - FWords[I].Caption.Length, LTextEndIndex, TSkRectHeightStyle.Tight, TSkRectWidthStyle.Tight) do - begin - if LRects = nil then - begin - LRects := [LTextBox.Rect]; - LRectsColor := [FWords[I].BackgroundColor]; - Continue; - end; - LLastRect := LRects[High(LRects)]; - LLastColor := LRectsColor[High(LRectsColor)]; - if (LLastColor = FWords[I].BackgroundColor) and SameValue(LLastRect.Right, LTextBox.Rect.Left, 1) and - (InRange(LTextBox.Rect.CenterPoint.Y, LLastRect.Top, LLastRect.Bottom) or - InRange(LLastRect.CenterPoint.Y, LTextBox.Rect.Top, LTextBox.Rect.Bottom)) then - begin - LLastRect.Right := LTextBox.Rect.Right; - LLastRect.Top := Min(LLastRect.Top, LTextBox.Rect.Top); - LLastRect.Bottom := Max(LLastRect.Bottom, LTextBox.Rect.Bottom); - LRects[High(LRects)] := LLastRect; - end - else - begin - LRects := LRects + [LTextBox.Rect]; - LRectsColor := LRectsColor + [FWords[I].BackgroundColor]; - end; - end; - end; - for I := 0 to Length(LRects) - 1 do - begin - LPaint.Color := LRectsColor[I]; - LCanvas.DrawRoundRect(TRectF.Create(LRects[I].Round), 2 * ScaleFactor, 2 * ScaleFactor, LPaint); - end; - Result := LPictureRecorder.FinishRecording; - end; - -var - LParagraph: ISkParagraph; - LPositionY: Single; -begin - LParagraph := Paragraph; - if Assigned(LParagraph) then - begin - ParagraphLayout(ADest.Width); - LPositionY := ADest.Top; - case ResultingTextSettings.VertAlign of - TSkTextVertAlign.Center: LPositionY := LPositionY + ((ADest.Height - ParagraphBounds.Height) / 2); - TSkTextVertAlign.Leading: ; - TSkTextVertAlign.Trailing: LPositionY := LPositionY + (ADest.Height - ParagraphBounds.Height); - end; - - if SameValue(AOpacity, 1, TEpsilon.Position) then - ACanvas.Save - else - ACanvas.SaveLayerAlpha(Round(AOpacity * 255)); - try - ACanvas.ClipRect(ADest); - ACanvas.Translate(ADest.Left, LPositionY); - if FHasCustomBackground then - begin - if FBackgroundPicture = nil then - FBackgroundPicture := CreateBackgroundPicture(LParagraph); - ACanvas.DrawPicture(FBackgroundPicture); - end; - LParagraph.Paint(ACanvas, 0, 0); - if Assigned(FParagraphStroked) then - FParagraphStroked.Paint(ACanvas, 0, 0); - finally - ACanvas.Restore; - end; - end; -end; - -function TSkLabel.GetCaption: string; -var - I: Integer; -begin - Result := ''; - if Assigned(FWords) and (FWords.Count > 0) then - for I := 0 to FWords.Count - 1 do - Result := Result + FWords[I].Caption; -end; - -function TSkLabel.GetDefaultTextSettings: TSkTextSettings; -begin - Result := FTextSettingsInfo.DefaultTextSettings; -end; - -procedure TSkLabel.GetFitSize(var AWidth, AHeight: Single); - - function GetFitHeight: Single; - begin - if (akTop in Anchors) and (akBottom in Anchors) then - Result := AHeight - else - Result := Ceil(ParagraphBounds.Height * ScaleFactor); - end; - - function GetFitWidth: Single; - begin - if (akLeft in Anchors) and (akRight in Anchors) then - Result := AWidth - else - Result := Ceil(ParagraphBounds.Width * ScaleFactor); - end; - -var - LParagraph: ISkParagraph; -begin - LParagraph := Paragraph; - if Assigned(LParagraph) then - begin - if (akLeft in Anchors) and (akRight in Anchors) then - ParagraphLayout(AWidth / ScaleFactor) - else - ParagraphLayout(High(Integer)); - end; - try - AWidth := GetFitWidth; - AHeight := GetFitHeight; - finally - if Assigned(LParagraph) then - ParagraphLayout(AWidth / ScaleFactor); - end; -end; - -function TSkLabel.GetLinesCount: Integer; -var - LParagraph: ISkParagraph; -begin - LParagraph := Paragraph; - if Assigned(LParagraph) then - Result := Length(LParagraph.LineMetrics) - else - Result := 0; -end; - -function TSkLabel.GetParagraph: ISkParagraph; -type - TDrawKind = (Fill, Stroke); -const - SkTextAlign: array[TSkTextHorzAlign] of TSkTextAlign = (TSkTextAlign.Center, TSkTextAlign.Start, TSkTextAlign.Terminate, TSkTextAlign.Justify); - SkFontSlant: array[TSkFontComponent.TSkFontSlant] of TSkFontSlant = (TSkFontSlant.Upright, TSkFontSlant.Italic, TSkFontSlant.Oblique); - SkFontWeightValue: array[TSkFontComponent.TSkFontWeight] of Integer = (100, 200, 300, 350, 400, 500, 600, 700, 800, 900, 950); - SkFontWidthValue: array[TSkFontComponent.TSkFontStretch] of Integer = (1, 2, 3, 4, 5, 6, 7, 8, 9); -var - LHasTextStroked: Boolean; - - function GetFontFamilies(const AValue: string): TArray; - begin - Result := AValue.Split([', ', ','], TStringSplitOptions.ExcludeEmpty); - end; - - procedure SetTextStyleDecorations(var ATextStyle: ISkTextStyle; - const ADecorations: TSkTextSettings.TDecorations; - const ADrawKind: TDrawKind); - var - LPaint: ISkPaint; - begin - if ADecorations.Decorations <> [] then - begin - if ADecorations.Color = TAlphaColors.Null then - ATextStyle.DecorationColor := ATextStyle.Color - else - ATextStyle.DecorationColor := ADecorations.Color; - ATextStyle.Decorations := ADecorations.Decorations; - ATextStyle.DecorationStyle := ADecorations.Style; - ATextStyle.DecorationThickness := ADecorations.Thickness; - end; - if ADrawKind = TDrawKind.Stroke then - begin - if (ADecorations.StrokeColor <> TAlphaColors.Null) and not SameValue(ADecorations.Thickness, 0, TEpsilon.Position) then - begin - LPaint := TSkPaint.Create(TSkPaintStyle.Stroke); - LPaint.Color := ADecorations.StrokeColor; - LPaint.StrokeWidth := (ADecorations.Thickness / 2) * (ATextStyle.FontSize / 14); - ATextStyle.SetForegroundColor(LPaint); - end - else - ATextStyle.Color := TAlphaColors.Null; - end - else - LHasTextStroked := LHasTextStroked or - ((ADecorations.StrokeColor <> TAlphaColors.Null) and not SameValue(ADecorations.Thickness, 0, TEpsilon.Position)); - end; - - function CreateTextStyle(const AWordsItem: TCustomWordsItem; - const ADefaultTextStyle: ISkTextStyle; const ADrawKind: TDrawKind): ISkTextStyle; - begin - Result := TSkTextStyle.Create; - if TSkStyledSetting.FontColor in AWordsItem.StyledSettings then - Result.Color := ResultingTextSettings.FontColor - else - Result.Color := AWordsItem.FontColor; - if TSkStyledSetting.Family in AWordsItem.StyledSettings then - Result.FontFamilies := ADefaultTextStyle.FontFamilies - else - Result.FontFamilies := GetFontFamilies(AWordsItem.Font.Families); - if TSkStyledSetting.Size in AWordsItem.StyledSettings then - Result.FontSize := ADefaultTextStyle.FontSize - else - Result.FontSize := AWordsItem.Font.Size; - if TSkStyledSetting.Style in AWordsItem.StyledSettings then - Result.FontStyle := ADefaultTextStyle.FontStyle - else - Result.FontStyle := TSkFontStyle.Create(SkFontWeightValue[AWordsItem.Font.Weight], SkFontWidthValue[AWordsItem.Font.Stretch], SkFontSlant[AWordsItem.Font.Slant]); - if TSkStyledSetting.Other in AWordsItem.StyledSettings then - begin - Result.HeightMultiplier := ADefaultTextStyle.HeightMultiplier; - SetTextStyleDecorations(Result, ResultingTextSettings.Decorations, ADrawKind); - Result.LetterSpacing := ADefaultTextStyle.LetterSpacing; - end - else - begin - Result.HeightMultiplier := AWordsItem.HeightMultiplier; - SetTextStyleDecorations(Result, AWordsItem.Decorations, ADrawKind); - Result.LetterSpacing := AWordsItem.LetterSpacing; - end; - end; - - function CreateDefaultTextStyle(const ADrawKind: TDrawKind): ISkTextStyle; - begin - Result := TSkTextStyle.Create; - Result.Color := ResultingTextSettings.FontColor; - Result.FontFamilies := GetFontFamilies(ResultingTextSettings.Font.Families); - Result.FontSize := ResultingTextSettings.Font.Size; - Result.FontStyle := TSkFontStyle.Create(SkFontWeightValue[ResultingTextSettings.Font.Weight], SkFontWidthValue[ResultingTextSettings.Font.Stretch], SkFontSlant[ResultingTextSettings.Font.Slant]); - Result.HeightMultiplier := ResultingTextSettings.HeightMultiplier; - Result.LetterSpacing := ResultingTextSettings.LetterSpacing; - SetTextStyleDecorations(Result, ResultingTextSettings.Decorations, ADrawKind); - end; - - function CreateParagraphStyle(const ADefaultTextStyle: ISkTextStyle): ISkParagraphStyle; - begin - Result := TSkParagraphStyle.Create; - if UseRightToLeftAlignment then - Result.TextDirection := TSkTextDirection.RightToLeft; - if ResultingTextSettings.Trimming in [TSkTextTrimming.Character, TSkTextTrimming.Word] then - Result.Ellipsis := '...'; - if ResultingTextSettings.MaxLines = 0 then - Result.MaxLines := High(Integer) - else - Result.MaxLines := ResultingTextSettings.MaxLines; - Result.TextAlign := SkTextAlign[ResultingTextSettings.HorzAlign]; - Result.TextStyle := ADefaultTextStyle; - end; - - // Temporary solution to fix an issue with Skia: https://bugs.chromium.org/p/skia/issues/detail?id=13117 - // SkParagraph has several issues with the #13 line break, so the best thing to do is replace it with #10 or a zero-widh character (#8203) - function NormalizeParagraphText(const AText: string): string; - begin - Result := AText.Replace(#13#10, #8203#10).Replace(#13, #10); - end; - - function CreateParagraph(const ADrawKind: TDrawKind): ISkParagraph; - var - LBuilder: ISkParagraphBuilder; - LDefaultTextStyle: ISkTextStyle; - LText: string; - I: Integer; - begin - LDefaultTextStyle := CreateDefaultTextStyle(ADrawKind); - LBuilder := TSkParagraphBuilder.Create(CreateParagraphStyle(LDefaultTextStyle), TSkDefaultProviders.TypefaceFont); - - for I := 0 to FWords.Count- 1 do - begin - if FWords[I].Caption = '' then - Continue; - if FWords[I].StyledSettings = AllStyledSettings then - LBuilder.AddText(FWords[I].Caption) - else - begin - LText := NormalizeParagraphText(FWords[I].Caption); - if not LText.IsEmpty then - begin - LBuilder.PushStyle(CreateTextStyle(FWords[I], LDefaultTextStyle, ADrawKind)); - LBuilder.AddText(LText); - LBuilder.Pop; - end; - end; - FHasCustomBackground := FHasCustomBackground or (FWords[I].BackgroundColor <> TAlphaColors.Null); - end; - Result := LBuilder.Build; - end; - -begin - if (FParagraph = nil) and (Caption <> '') then - begin - FBackgroundPicture := nil; - FHasCustomBackground := False; - LHasTextStroked := False; - FParagraph := CreateParagraph(TDrawKind.Fill); - if LHasTextStroked then - FParagraphStroked := CreateParagraph(TDrawKind.Stroke); - ParagraphLayout(Width / ScaleFactor); - end; - Result := FParagraph; -end; - -function TSkLabel.GetParagraphBounds: TRectF; - - function CalculateParagraphBounds: TRectF; - var - LParagraph: ISkParagraph; - begin - LParagraph := Paragraph; - if Assigned(LParagraph) then - Result := RectF(0, 0, Ceil(LParagraph.MaxIntrinsicWidth), Ceil(LParagraph.Height)) - else - Result := TRectF.Empty; - end; - -begin - if FParagraphBounds.IsEmpty then - FParagraphBounds := CalculateParagraphBounds; - Result := FParagraphBounds; -end; - -function TSkLabel.GetResultingTextSettings: TSkTextSettings; -begin - Result := FTextSettingsInfo.ResultingTextSettings; -end; - -function TSkLabel.GetTextSettings: TSkTextSettings; -begin - Result := FTextSettingsInfo.TextSettings; -end; - -function TSkLabel.GetTextSettingsClass: TSkTextSettingsInfo.TCustomTextSettingsClass; -begin - Result := TSkTextSettingsInfo.TCustomTextSettings; -end; - -function TSkLabel.GetWordsItemAtPosition(const AX, - AY: Integer): TCustomWordsItem; - - // Remove inconsistencies such as area after a line break - function IsInsideValidArea(const AParagraph: ISkParagraph; const ATextArea: TRectF; const APoint: TPointF): Boolean; - var - LGlyphTextBoxes: TArray; - LGlyphPosition: TSkPositionAffinity; - begin - LGlyphPosition := AParagraph.GetGlyphPositionAtCoordinate(APoint.X, APoint.Y); - if LGlyphPosition.Affinity = TSkAffinity.Downstream then - Result := True - else if LGlyphPosition.Position >= 0 then - begin - LGlyphTextBoxes := AParagraph.GetRectsForRange(LGlyphPosition.Position, LGlyphPosition.Position + 1, TSkRectHeightStyle.Max, TSkRectWidthStyle.Tight); - Result := (LGlyphTextBoxes <> nil) and - ((LGlyphTextBoxes[0].Rect.CenterPoint.Distance(APoint) < (LGlyphTextBoxes[0].Rect.Width + LGlyphTextBoxes[0].Rect.Height) / 2) or - ATextArea.Contains(LGlyphTextBoxes[0].Rect.CenterPoint)); - end - else - Result := False; - end; - -var - I, J: Integer; - LTextIndex: Integer; - LTextBoxes: TArray; - LParagraph: ISkParagraph; - LParagraphPoint: TPointF; -begin - Result := nil; - LParagraph := Paragraph; - if Assigned(LParagraph) then - begin - case ResultingTextSettings.VertAlign of - TSkTextVertAlign.Center: LParagraphPoint := PointF(AX, AY - (Height - ParagraphBounds.Height * ScaleFactor) / 2); - TSkTextVertAlign.Trailing: LParagraphPoint := PointF(AX, AY - Height - ParagraphBounds.Height * ScaleFactor); - else - LParagraphPoint := PointF(AX, AY); - end; - LParagraphPoint := LParagraphPoint / ScaleFactor; - LTextIndex := 0; - for I := 0 to FWords.Count - 1 do - begin - if FWords[I].Caption.Length = 0 then - Continue; - LTextBoxes := LParagraph.GetRectsForRange(LTextIndex, LTextIndex + FWords[I].Caption.Length, TSkRectHeightStyle.Max, TSkRectWidthStyle.Tight); - for J := 0 to Length(LTextBoxes) - 1 do - begin - if LTextBoxes[J].Rect.Contains(LParagraphPoint) then - begin - if IsInsideValidArea(LParagraph, LTextBoxes[J].Rect, LParagraphPoint) then - Result := FWords[I]; - Break; - end; - end; - if Assigned(Result) then - Break; - Inc(LTextIndex, FWords[I].Caption.Length); - end; - end; -end; - -function TSkLabel.HasFitSizeChanged: Boolean; -var - LNewWidth: Single; - LNewHeight: Single; -begin - LNewWidth := Width; - LNewHeight := Height; - GetFitSize(LNewWidth, LNewHeight); - Result := (not SameValue(LNewWidth, Width, TEpsilon.Position)) or (not SameValue(LNewHeight, Height, TEpsilon.Position)); -end; - -procedure TSkLabel.Loaded; -begin - inherited; - if AutoSize and HasFitSizeChanged then - SetBounds(Left, Top, Width, Height); -end; - -procedure TSkLabel.MouseDown(AButton: TMouseButton; AShift: TShiftState; AX, - AY: Integer); -begin - if AButton = TMouseButton.mbLeft then - FPressedPosition := Point(AX, AY); - inherited; -end; - -procedure TSkLabel.ParagraphLayout(const AWidth: Single); -var - LParagraph: ISkParagraph; -begin - if not SameValue(FParagraphLayoutWidth, AWidth, TEpsilon.Position) then - begin - LParagraph := Paragraph; - if Assigned(LParagraph) then - begin - LParagraph.Layout(AWidth); - if Assigned(FParagraphStroked) then - FParagraphStroked.Layout(AWidth); - FParagraphLayoutWidth := AWidth; - FParagraphBounds := TRectF.Empty; - FBackgroundPicture := nil; - end; - end; -end; - -procedure TSkLabel.SetCaption(const AValue: string); -begin - if Assigned(FWords) then - begin - FWords.BeginUpdate; - try - if FWords.Count = 1 then - FWords[0].Caption := AValue - else - begin - FWords.Clear; - FWords.Add.Caption := AValue; - end; - finally - FWords.EndUpdate; - end; - end; -end; - -procedure TSkLabel.SetName(const AValue: TComponentName); -var - LChangeCaption: Boolean; -begin - LChangeCaption := not (csLoading in ComponentState) and (Name = Caption) and - ((Owner = nil) or not (csLoading in TComponent(Owner).ComponentState)); - inherited SetName(AValue); - if LChangeCaption then - Caption := AValue; -end; - -procedure TSkLabel.SetTextSettings(const AValue: TSkTextSettings); -begin - FTextSettingsInfo.TextSettings := AValue; -end; - -procedure TSkLabel.SetWords(const AValue: TWordsCollection); -begin - FWords.Assign(AValue); -end; - -procedure TSkLabel.SetWordsMouseOver(const AValue: TCustomWordsItem); -begin - if FWordsMouseOver <> AValue then - begin - FWordsMouseOver := AValue; - if not (csDesigning in ComponentState) and IsMouseOver then - begin - if Assigned(FWordsMouseOver) and (FWordsMouseOver.Cursor <> crDefault) then - Cursor := FWordsMouseOver.Cursor - else - Cursor := crDefault; - end; - end - else if Assigned(FWordsMouseOver) and (FWordsMouseOver.Cursor <> crDefault) then - Cursor := FWordsMouseOver.Cursor - else - Cursor := crDefault; -end; - -procedure TSkLabel.TextSettingsChanged(AValue: TObject); -begin - DeleteParagraph; - if not (csLoading in ComponentState) then - begin - if AutoSize and HasFitSizeChanged then - SetBounds(Left, Top, Width, Height) - else - Redraw; - end; -end; - -type - TControlAccess = class(TControl); - -function TSkLabel.UseRightToLeftAlignment: Boolean; - - function GetParentedBiDiMode: TBiDiMode; - var - LControl: TControl; - begin - LControl := Self; - repeat - Result := LControl.BiDiMode; - if not TControlAccess(LControl).ParentBiDiMode then - Break; - LControl := LControl.Parent; - until LControl = nil; - end; - -begin - Result := SysLocale.MiddleEast and (GetParentedBiDiMode = bdRightToLeft); -end; - -procedure TSkLabel.WMLButtonUp(var AMessage: TWMLButtonUp); -begin - FClickedPosition := Point(AMessage.XPos, AMessage.YPos); - inherited; -end; - -procedure TSkLabel.WMMouseMove(var AMessage: TWMMouseMove); -begin - if FHasCustomCursor then - SetWordsMouseOver(GetWordsItemAtPosition(AMessage.XPos, AMessage.YPos)); - inherited; -end; - -procedure TSkLabel.WordsChange(ASender: TObject); -var - I: Integer; -begin - FHasCustomCursor := False; - for I := 0 to FWords.Count - 1 do - begin - if FWords[I].Cursor <> crDefault then - begin - FHasCustomCursor := True; - Break; - end; - end; - if FWords.Count = 0 then - FWords.Add - else - TextSettingsChanged(nil); -end; - -{ TSkDefaultProviders } - -class constructor TSkDefaultProviders.Create; -begin - FTypefaceFont := TSkTypefaceFontProvider.Create; -end; - -class procedure TSkDefaultProviders.RegisterTypeface(const AFileName: string); -begin - FTypefaceFont.RegisterTypeface(TSkTypeFace.MakeFromFile(AFileName)); -end; - -class procedure TSkDefaultProviders.RegisterTypeface(const AStream: TStream); -begin - FTypefaceFont.RegisterTypeface(TSkTypeFace.MakeFromStream(AStream)); -end; - -{ TSkTypefaceManager } - -class function TSkTypefaceManager.Provider: ISkTypefaceFontProvider; -begin - Result := TSkDefaultProviders.TypefaceFont; -end; - -class procedure TSkTypefaceManager.RegisterTypeface(const AFileName: string); -begin - TSkDefaultProviders.RegisterTypeface(AFileName); -end; - -class procedure TSkTypefaceManager.RegisterTypeface(const AStream: TStream); -begin - TSkDefaultProviders.RegisterTypeface(AStream); -end; - -{ TSkGraphic } - -procedure TSkGraphic.Assign(ASource: TPersistent); -begin - if ASource is TSkGraphic then - begin - if TObject(FImage) <> TObject(TSkGraphic(ASource).FImage) then - begin - FImage := TSkGraphic(ASource).FImage; - Changed(Self); - end; - end - else - inherited; -end; - -{$IF CompilerVersion >= 32} -class function TSkGraphic.CanLoadFromStream(AStream: TStream): Boolean; -const - SupportedFormats = [TSkEncodedImageFormat.WEBP, TSkEncodedImageFormat.WBMP, TSkEncodedImageFormat.DNG]; -var - LCodec: ISkCodec; - LSavedPosition: Int64; -begin - LSavedPosition := AStream.Position; - try - LCodec := TSkCodec.MakeFromStream(AStream); - Result := Assigned(LCodec) and (LCodec.EncodedImageFormat in SupportedFormats); - finally - AStream.Position := LSavedPosition; - end; -end; -{$ENDIF} - -procedure TSkGraphic.Changed(ASender: TObject); -begin - FreeAndNil(FBuffer); - inherited; -end; - -destructor TSkGraphic.Destroy; -begin - FBuffer.Free; - inherited; -end; - -procedure TSkGraphic.Draw(ACanvas: TCanvas; const ARect: TRect); -begin - DrawTransparent(ACanvas, ARect, High(Byte)); -end; - -procedure TSkGraphic.DrawTransparent(ACanvas: TCanvas; const ARect: TRect; - AOpacity: Byte); -var - LBitmap: TBitmap; -begin - LBitmap := GetBuffer(ARect.Size, AOpacity); - if Assigned(LBitmap) then - ACanvas.Draw(ARect.Left, ARect.Top, LBitmap); -end; - -function TSkGraphic.Equals(AGraphic: TGraphic): Boolean; - - function Equals(const ALeft, ARight: ISkPixmap): Boolean; - var - I: Integer; - begin - if ALeft.ImageInfo <> ARight.ImageInfo then - Exit(False); - if (ALeft.RowBytes = ARight.RowBytes) and (ALeft.RowBytes = ALeft.ImageInfo.MinRowBytes) then - Result := CompareMem(ALeft.Pixels, ARight.Pixels, ALeft.RowBytes * NativeUInt(ALeft.Height)) - else - begin - Result := True; - for I := 0 to ALeft.Height - 1 do - if not CompareMem(ALeft.PixelAddr[0, I], ARight.PixelAddr[0, I], ALeft.ImageInfo.BytesPerPixel * ALeft.Width) then - Exit(False); - end; - end; - -var - LPixmap: ISkPixmap; - LPixmap2: ISkPixmap; -begin - if AGraphic is TSkGraphic then - begin - Result := (Empty and AGraphic.Empty) or - (FImage.ReadPixels(LPixmap) and TSkGraphic(AGraphic).FImage.ReadPixels(LPixmap2) and Equals(LPixmap, LPixmap2)); - end - else - Result := inherited; -end; - -function TSkGraphic.GetBuffer(const ASize: TSize; const AOpacity: Byte): TBitmap; -begin - if Empty or (ASize.Width <= 0) or (ASize.Height <= 0) or (AOpacity = 0) then - Exit(nil); - if Assigned(FBuffer) and (ASize.Width = FBuffer.Width) and (ASize.Height = FBuffer.Height) and (AOpacity = FBufferOpacity) then - Exit(FBuffer); - if not Assigned(FBuffer) then - begin - FBuffer := TBitmap.Create; - FBuffer.PixelFormat := TPixelFormat.pf32bit; - FBuffer.AlphaFormat := TAlphaFormat.afPremultiplied; - end; - FBuffer.SetSize(ASize.Width, ASize.Height); - FBuffer.SkiaDraw( - procedure(const ACanvas: ISkCanvas) - var - LPaint: ISkPaint; - begin - if AOpacity = High(AOpacity) then - LPaint := nil - else - begin - LPaint := TSkPaint.Create; - LPaint.Alpha := AOpacity; - end; - if (FBuffer.Width = Width) and (FBuffer.Height = Height) then - ACanvas.DrawImage(FImage, 0, 0, LPaint) - else - begin - ACanvas.Scale(FBuffer.Width / Width, FBuffer.Height / Height); - ACanvas.DrawImage(FImage, 0, 0, TSkSamplingOptions.Medium, LPaint); - end; - end); - FBufferOpacity := AOpacity; - Result := FBuffer; -end; - -function TSkGraphic.GetEmpty: Boolean; -begin - Result := (not Assigned(FImage)) or (FImage.Width <= 0) or (FImage.Height <= 0); -end; - -function TSkGraphic.GetHeight: Integer; -begin - if Assigned(FImage) then - Result := FImage.Height - else - Result := 0; -end; - -function TSkGraphic.GetSupportsPartialTransparency: Boolean; -begin - Result := True; -end; - -function TSkGraphic.GetWidth: Integer; -begin - if Assigned(FImage) then - Result := FImage.Width - else - Result := 0; -end; - -procedure TSkGraphic.LoadFromClipboardFormat(AFormat: Word; AData: THandle; - APalette: HPALETTE); -begin -end; - -procedure TSkGraphic.LoadFromStream(AStream: TStream); -begin - FImage := TSkImage.MakeFromEncodedStream(AStream); - Changed(Self); -end; - -procedure TSkGraphic.SaveToClipboardFormat(var AFormat: Word; - var AData: THandle; var APalette: HPALETTE); -begin -end; - -procedure TSkGraphic.SaveToFile(const AFileName: string); -begin - if AFilename.EndsText(AFileName, '.jpg') or AFilename.EndsText(AFileName, '.jpeg') then - FImage.EncodeToFile(AFileName, TSkEncodedImageFormat.JPEG) - else if AFilename.EndsText(AFileName, '.webp') then - FImage.EncodeToFile(AFileName, TSkEncodedImageFormat.WEBP) - else - FImage.EncodeToFile(AFileName); -end; - -procedure TSkGraphic.SaveToStream(AStream: TStream); -begin - FImage.EncodeToStream(AStream); -end; - -procedure TSkGraphic.SetHeight(AValue: Integer); -begin - SetSize(Width, AValue); -end; - -procedure TSkGraphic.SetSize(AWidth, AHeight: Integer); -var - LSurface: ISkSurface; - LPixmap: ISkPixmap; -begin - if (Width <> AWidth) or (Height <> AHeight) then - begin - if Assigned(FImage) then - begin - FImage.ScalePixels(LPixmap, TSkSamplingOptions.Medium); - FImage := TSkImage.MakeRasterCopy(LPixmap); - end - else - begin - LSurface := TSkSurface.MakeRaster(AWidth, AHeight); - LSurface.Canvas.Clear(TAlphaColors.Null); - FImage := LSurface.MakeImageSnapshot; - end; - Changed(Self); - end; -end; - -procedure TSkGraphic.SetWidth(AValue: Integer); -begin - SetSize(AValue, Height); -end; - -{ TSkSvgGraphic } - -procedure TSkSvgGraphic.Assign(ASource: TPersistent); -begin - if ASource is TSkSvgGraphic then - FSvgBrush.Assign(TSkSvgGraphic(ASource).FSvgBrush) - else - inherited; -end; - -procedure TSkSvgGraphic.Changed(ASender: TObject); -begin - FreeAndNil(FBuffer); - inherited; -end; - -constructor TSkSvgGraphic.Create; -begin - inherited; - FSvgBrush := TSkSvgBrush.Create; - FSvgBrush.WrapMode := TSkSvgWrapMode.Stretch; - FSvgBrush.OnChanged := Changed; -end; - -destructor TSkSvgGraphic.Destroy; -begin - FBuffer.Free; - FSvgBrush.Free; - inherited; -end; - -procedure TSkSvgGraphic.Draw(ACanvas: TCanvas; const ARect: TRect); -begin - DrawTransparent(ACanvas, ARect, High(Byte)); -end; - -procedure TSkSvgGraphic.DrawTransparent(ACanvas: TCanvas; const ARect: TRect; - AOpacity: Byte); -var - LBitmap: TBitmap; -begin - LBitmap := GetBuffer(ARect.Size, AOpacity); - if Assigned(LBitmap) then - ACanvas.Draw(ARect.Left, ARect.Top, LBitmap); -end; - -function TSkSvgGraphic.Equals(AGraphic: TGraphic): Boolean; -begin - Result := (AGraphic is TSkSvgGraphic) and (FSvgBrush.Source = TSkSvgGraphic(AGraphic).FSvgBrush.Source); -end; - -function TSkSvgGraphic.GetBuffer(const ASize: TSize; - const AOpacity: Byte): TBitmap; -begin - if Empty or (ASize.Width <= 0) or (ASize.Height <= 0) or (AOpacity = 0) then - Exit(nil); - if Assigned(FBuffer) and (ASize.Width = FBuffer.Width) and (ASize.Height = FBuffer.Height) and (AOpacity = FBufferOpacity) then - Exit(FBuffer); - if not Assigned(FBuffer) then - begin - FBuffer := TBitmap.Create; - FBuffer.PixelFormat := TPixelFormat.pf32bit; - FBuffer.AlphaFormat := TAlphaFormat.afPremultiplied; - end; - FBuffer.SetSize(ASize.Width, ASize.Height); - FBuffer.SkiaDraw( - procedure(const ACanvas: ISkCanvas) - begin - FSvgBrush.Render(ACanvas, RectF(0, 0, FBuffer.Width, FBuffer.Height), AOpacity / 255); - end); - FBufferOpacity := AOpacity; - Result := FBuffer; -end; - -function TSkSvgGraphic.GetEmpty: Boolean; -begin - Result := FSvgBrush.Source = ''; -end; - -function TSkSvgGraphic.GetHeight: Integer; -begin - Result := Round(FSvgBrush.OriginalSize.Height); -end; - -function TSkSvgGraphic.GetSupportsPartialTransparency: Boolean; -begin - Result := True; -end; - -function TSkSvgGraphic.GetWidth: Integer; -begin - Result := Round(FSvgBrush.OriginalSize.Width); -end; - -procedure TSkSvgGraphic.LoadFromClipboardFormat(AFormat: Word; AData: THandle; - APalette: HPALETTE); -begin -end; - -procedure TSkSvgGraphic.LoadFromStream(AStream: TStream); -var - LBytes: TBytes; -begin - SetLength(LBytes, AStream.Size - AStream.Position); - if Length(LBytes) > 0 then - begin - AStream.ReadBuffer(LBytes, Length(LBytes)); - FSvgBrush.Source := TEncoding.UTF8.GetString(LBytes); - end - else - FSvgBrush.Source := ''; -end; - -procedure TSkSvgGraphic.SaveToClipboardFormat(var AFormat: Word; - var AData: THandle; var APalette: HPALETTE); -begin -end; - -procedure TSkSvgGraphic.SaveToFile(const AFileName: string); -begin - TFile.WriteAllText(AFileName, FSvgBrush.Source); -end; - -procedure TSkSvgGraphic.SaveToStream(AStream: TStream); -var - LBytes: TBytes; -begin - if FSvgBrush.Source <> '' then - begin - LBytes := TEncoding.UTF8.GetBytes(FSvgBrush.Source); - AStream.WriteBuffer(LBytes, Length(LBytes)); - end; -end; - -procedure TSkSvgGraphic.SetHeight(AValue: Integer); -begin -end; - -procedure TSkSvgGraphic.SetWidth(AValue: Integer); -begin -end; - -{ Register } - -procedure Register; -begin - RegisterComponents('Skia', [TSkAnimatedImage, TSkAnimatedPaintBox, TSkLabel, TSkPaintBox, TSkSvg]); -end; - -{$IFDEF MSWINDOWS} - {$HPPEMIT '#ifdef USEPACKAGES'} - {$HPPEMIT ' #pragma link "Skia.Package.VCL.bpi"'} - {$HPPEMIT '#elif defined(__WIN32__)'} - {$HPPEMIT ' #pragma link "Skia.Package.VCL.lib"'} - {$HPPEMIT '#elif defined(_WIN64)'} - {$HPPEMIT ' #pragma link "Skia.Package.VCL.a"'} - {$HPPEMIT '#endif'} -{$ENDIF} - -(*$HPPEMIT 'namespace Skia {'*) -(*$HPPEMIT ' namespace Vcl {'*) -(*$HPPEMIT ' namespace Graphics { using namespace ::Vcl::Graphics; }'*) -(*$HPPEMIT ' namespace Controls { using namespace ::Vcl::Controls; }'*) -(*$HPPEMIT ' namespace Extctrls { using namespace ::Vcl::Extctrls; }'*) -(*$HPPEMIT ' }'*) -(*$HPPEMIT '}'*) - -{$HPPEMIT NOUSINGNAMESPACE} -{$HPPEMIT END '#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_SKIA)'} -{$HPPEMIT END ' using ::Skia::Vcl::_di_ISkTextSettings;'} -{$HPPEMIT END ' using ::Skia::Vcl::_di_TSkAnimationDrawProc;'} -{$HPPEMIT END ' using ::Skia::Vcl::_di_TSkDrawProc;'} -{$HPPEMIT END ' using ::Skia::Vcl::ESkBitmapHelper;'} -{$HPPEMIT END ' using ::Skia::Vcl::ESkLabel;'} -{$HPPEMIT END ' using ::Skia::Vcl::ESkPersistentData;'} -{$HPPEMIT END ' using ::Skia::Vcl::ESkTextSettingsInfo;'} -{$HPPEMIT END ' using ::Skia::Vcl::ESkVcl;'} -{$HPPEMIT END ' using ::Skia::Vcl::ISkTextSettings;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkAnimatedImage;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkAnimatedImageWrapMode;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkAnimatedPaintBox;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkAnimationDrawEvent;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkAnimationDrawProc;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkCustomAnimatedControl;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkCustomAnimation;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkCustomControl;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkCustomWinControl;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkDefaultProviders;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkDrawCacheKind;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkDrawEvent;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkDrawProc;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkFontComponent;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkLabel;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkPaintBox;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkPersistent;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkStyledSetting;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkStyledSettings;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkSvg;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkSvgBrush;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkSvgSource;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkSvgWrapMode;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkTextHorzAlign;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkTextSettings;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkTextSettingsClass;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkTextSettingsInfo;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkTextTrimming;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkTextVertAlign;'} -{$HPPEMIT END ' using ::Skia::Vcl::TSkTypefaceManager;'} -{$HPPEMIT END ' typedef ::Skia::_di_ISkImage (__fastcall *TBitmapToSkImageFunc)(::Vcl::Graphics::TBitmap* const ABitmap);'} -{$HPPEMIT END ' typedef void (__fastcall *TSkiaDrawProc)(::Vcl::Graphics::TBitmap* const ABitmap, const ::Skia::Vcl::_di_TSkDrawProc AProc, const bool AStartClean);'} -{$HPPEMIT END ' typedef ::Vcl::Graphics::TBitmap* (__fastcall *TSkImageToBitmapFunc)(const ::Skia::_di_ISkImage AImage);'} -{$HPPEMIT END ' static TSkStyledSettings& AllStyledSettings = ::Skia::Vcl::AllStyledSettings;'} -{$HPPEMIT END ' static TSkStyledSettings& DefaultStyledSettings = ::Skia::Vcl::DefaultStyledSettings;'} -{$HPPEMIT END ' static const TBitmapToSkImageFunc BitmapToSkImage = ::Skia::Vcl::BitmapToSkImage;'} -{$HPPEMIT END ' static const TSkiaDrawProc SkiaDraw = ::Skia::Vcl::SkiaDraw;'} -{$HPPEMIT END ' static const TSkImageToBitmapFunc SkImageToBitmap = ::Skia::Vcl::SkImageToBitmap;'} -{$HPPEMIT END '#endif'} - -initialization - TSkAnimatedImage.RegisterCodec(TSkLottieAnimationCodec); - TSkAnimatedImage.RegisterCodec(TSkDefaultAnimationCodec); - TPicture.RegisterFileFormat('svg', 'Scalable Vector Graphics', TSkSvgGraphic); - TPicture.RegisterFileFormat('webp', 'WebP Images', TSkGraphic); - TPicture.RegisterFileFormat('wbmp', 'WBMP Images', TSkGraphic); - TSkCustomAnimation.FrameRate := TSkCustomAnimation.DefaultFrameRate; -finalization - TPicture.UnregisterGraphicClass(TSkGraphic); - TPicture.UnregisterGraphicClass(TSkSvgGraphic); -end.