Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Metal APIs from main branch #1598

Merged
merged 28 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f3f0d44
Add Metal
mattleibow Jul 10, 2020
2115f62
Update externals
mattleibow Jul 10, 2020
c5eb1c6
Changes
mattleibow Jul 11, 2020
a0e2c59
undos
mattleibow Jul 11, 2020
ded3586
dsfgdsf 
mattleibow Jul 11, 2020
488cbde
Merge branch 'master' into dev/metal
mattleibow Jul 19, 2020
e14b92b
Merge branch 'master' into dev/metal
mattleibow Jul 19, 2020
cba19ad
Merge branch 'master' into dev/metal
mattleibow Jul 21, 2020
a1a7b18
regen
mattleibow Jul 21, 2020
96f4a26
sdfasdf
mattleibow Jul 21, 2020
6d7d0d9
SKMetalView
mattleibow Jul 21, 2020
719368a
Merge master into dev/metal
mattleibow Oct 10, 2020
1fd0a1d
Update PR
mattleibow Feb 1, 2021
951333d
Merge branch 'master' into dev/metal
mattleibow Feb 1, 2021
753d395
Merge branch 'dev/skia-update' into dev/metal-update
mattleibow Feb 1, 2021
6b6213f
Some fixes
mattleibow Feb 1, 2021
daf2657
Fixing things up
mattleibow Feb 1, 2021
fc244e3
Fix changed enums
mattleibow Feb 1, 2021
7d087c9
Remove the externals/harfbuzz submodule (#1599)
mattleibow Feb 1, 2021
2a87a0d
Add Metal APIs for macOS and iOS (#1394)
mattleibow Feb 2, 2021
112025b
Revert "Add Metal APIs for macOS and iOS (#1394)"
mattleibow Feb 2, 2021
29e8f26
Add Metal APIs for macOS and iOS (#1394)
mattleibow Feb 2, 2021
d966ef2
docs: Add unoplatform references (#1602)
jeromelaban Feb 2, 2021
97efda8
Merge branch 'dev/skia-update' into dev/metal-update
mattleibow Feb 2, 2021
fa6fbbe
Merge branch 'master' into dev/metal-update
mattleibow Feb 2, 2021
abc73fe
Merge branch 'master' into dev/metal-update
mattleibow Feb 2, 2021
e3a2414
Add a symlink for a "missing" file
mattleibow Feb 2, 2021
f66ea3b
Merge branch 'master' into dev/metal-update
mattleibow Feb 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changes
  • Loading branch information
mattleibow committed Jul 11, 2020
commit c5eb1c683714c28a0827330a3980bc3e9522e2b5
4 changes: 4 additions & 0 deletions cake/native-shared.cake
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ void GnNinja(DirectoryPath outDir, string target, string skiaArgs)
skiaArgs += $" win_vc='{win_vc}' ";
}

skiaArgs +=
$" skia_enable_tools=false " +
$" is_official_build={CONFIGURATION.ToLower() == "release"} ".ToLower();

// generate native skia build files
RunProcess(GN_EXE, new ProcessSettings {
Arguments = $"gen out/{outDir} --script-executable={quote}{PYTHON_EXE}{quote} --args={quote}{skiaArgs.Replace("'", innerQuote)}{quote}",
Expand Down
2 changes: 1 addition & 1 deletion externals/skia
Submodule skia updated 1 files
+4 −2 src/c/sk_types_priv.h
2 changes: 0 additions & 2 deletions native/android/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ Task("libSkiaSharp")
GnNinja($"android/{arch}", "SkiaSharp",
$"target_cpu='{skiaArch}' " +
$"target_os='android' " +
$"is_official_build=true " +
$"skia_enable_tools=false " +
$"skia_use_icu=false " +
$"skia_use_piex=true " +
$"skia_use_sfntly=false " +
Expand Down
2 changes: 0 additions & 2 deletions native/ios/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Task("libSkiaSharp")
GnNinja($"ios/{arch}", "skia",
$"target_cpu='{skiaArch}' " +
$"target_os='ios' " +
$"is_official_build=false " +
$"skia_enable_tools=false " +
$"skia_use_icu=false " +
$"skia_use_metal=true " +
$"skia_use_piex=true " +
Expand Down
3 changes: 0 additions & 3 deletions native/linux/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ Task("libSkiaSharp")
GnNinja($"{VARIANT}/{arch}", "SkiaSharp",
$"target_os='linux' " +
$"target_cpu='{arch}' " +
$"is_official_build=true " +
$"skia_enable_gpu={(SUPPORT_GPU ? "true" : "false")} " +
$"skia_enable_tools=false " +
$"skia_use_icu=false " +
$"skia_use_piex=true " +
$"skia_use_sfntly=false " +
Expand Down Expand Up @@ -92,7 +90,6 @@ Task("libHarfBuzzSharp")
GnNinja($"{VARIANT}/{arch}", "HarfBuzzSharp",
$"target_os='linux' " +
$"target_cpu='{arch}' " +
$"is_official_build=true " +
$"visibility_hidden=false " +
$"extra_asmflags=[] " +
$"extra_cflags=[] " +
Expand Down
2 changes: 0 additions & 2 deletions native/macos/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ Task("libSkiaSharp")
GnNinja($"macos/{arch}", "skia",
$"target_os='mac' " +
$"target_cpu='{skiaArch}' " +
$"is_official_build=true " +
$"skia_enable_tools=false " +
$"skia_use_icu=false " +
$"skia_use_metal=true " +
$"skia_use_piex=true " +
Expand Down
2 changes: 0 additions & 2 deletions native/tizen/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ Task("libSkiaSharp")
GnNinja($"tizen/{arch}", "skia",
$"target_os='tizen' " +
$"target_cpu='{skiaArch}' " +
$"is_official_build=true " +
$"skia_enable_gpu=true " +
$"skia_enable_tools=false " +
$"skia_use_icu=false " +
$"skia_use_piex=true " +
$"skia_use_sfntly=false " +
Expand Down
2 changes: 0 additions & 2 deletions native/tvos/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Task("libSkiaSharp")
GnNinja($"tvos/{arch}", "skia",
$"target_os='tvos' " +
$"target_cpu='{skiaArch}' " +
$"is_official_build=true " +
$"skia_enable_tools=false " +
$"skia_use_icu=false " +
$"skia_use_piex=true " +
$"skia_use_sfntly=false " +
Expand Down
2 changes: 0 additions & 2 deletions native/uwp/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ Task("libSkiaSharp")
GnNinja($"uwp/{arch}", "SkiaSharp",
$"target_os='winrt' " +
$"target_cpu='{skiaArch}' " +
$"is_official_build=true " +
$"skia_enable_fontmgr_win_gdi=false " +
$"skia_enable_tools=false " +
$"skia_use_icu=false " +
$"skia_use_piex=true " +
$"skia_use_sfntly=false " +
Expand Down
2 changes: 0 additions & 2 deletions native/wasm/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Task("libSkiaSharp")
GnNinja($"wasm", "SkiaSharp",
$"target_os='linux' " +
$"target_cpu='wasm' " +
$"is_official_build=true " +
$"is_static_skiasharp=true " +
$"skia_enable_ccpr=false " +
$"skia_enable_fontmgr_custom_empty=false " +
Expand All @@ -29,7 +28,6 @@ Task("libSkiaSharp")
(SUPPORT_GPU ? "skia_gl_standard='webgl'" : "") +
$"skia_enable_nvpr=false " +
$"skia_enable_pdf=false " +
$"skia_enable_tools=false " +
$"skia_use_dng_sdk=false " +
$"skia_use_egl=true " +
$"skia_use_fontconfig=false " +
Expand Down
2 changes: 0 additions & 2 deletions native/watchos/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ Task("libSkiaSharp")
GnNinja($"watchos/{arch}", "skia",
$"target_os='watchos' " +
$"target_cpu='{skiaArch}' " +
$"is_official_build=true " +
$"skia_enable_gpu=false " +
$"skia_enable_tools=false " +
$"skia_use_icu=false " +
$"skia_use_piex=true " +
$"skia_use_sfntly=false " +
Expand Down
2 changes: 0 additions & 2 deletions native/windows/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ Task("libSkiaSharp")
GnNinja($"{VARIANT}/{arch}", "SkiaSharp",
$"target_os='win'" +
$"target_cpu='{skiaArch}' " +
$"is_official_build=true " +
$"skia_enable_fontmgr_win_gdi=false " +
$"skia_enable_tools=false " +
$"skia_use_dng_sdk=true " +
$"skia_use_icu=false " +
$"skia_use_piex=true " +
Expand Down
78 changes: 20 additions & 58 deletions samples/Basic/iOS/SkiaSharpSample/ViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ public override void ViewDidLoad()
mtkView.Delegate = this;
}

public void DrawableSizeWillChange(MTKView view, CGSize size)
{
}

private SKSurface SkMtkViewToSurface(MTKView mtkView)
public void Draw(MTKView view)
{
if (mtkView?.CurrentDrawable?.Texture == null || grContext == null)
return null;
if (grContext == null || view == null)
return;

var colorType = SKColorType.Bgra8888;
var origin = GRSurfaceOrigin.TopLeft;
Expand All @@ -67,75 +70,34 @@ private SKSurface SkMtkViewToSurface(MTKView mtkView)

var fbInfo = new GRMetalTextureInfo(mtkView.CurrentDrawable.Texture);

if (sampleCount == 1)
using (var backendRT = new GRBackendRenderTarget(width, height, 1, fbInfo))
using (var surface = SKSurface.Create(grContext, backendRT, origin, colorType))
{
var backendRT = new GRBackendRenderTarget(width, height, 1, fbInfo);
return SKSurface.Create(grContext, backendRT, origin, colorType);
}
else
{
var backendTexture = new GRBackendTexture(width, height, false, fbInfo);
return SKSurface.Create(grContext, backendTexture, origin, sampleCount, colorType);
}
}

public void DrawableSizeWillChange(MTKView view, CGSize size)
{
}
if (surface == null)
{
Console.WriteLine("Unable to create SKSurface.");
return;
}

public void Draw(MTKView view)
{
if (grContext == null || view == null)
return;

//// Do as much as possible before creating surface.
//config_paint(&fPaint);
//float rotation = (float)(180 * 1e-9 * SkTime::GetNSecs());
OnPaintSurface(mtkView, new SKPaintGLSurfaceEventArgs(surface, backendRT));

// Create surface:
var surface = SkMtkViewToSurface(view);
if (surface == null)
{
Console.WriteLine("Unable to create SKSurface.");
return;
// Must flush *and* present for this to work!
surface.Flush();
}

//draw_example(surface.get(), fPaint, rotation);

// Must flush *and* present for this to work!
surface.Flush();
surface = null;

var commandBuffer = metalQueue.CommandBuffer();
commandBuffer.PresentDrawable(view.CurrentDrawable);
commandBuffer.Commit();
}

private void OnPaintSurface(object sender, SKPaintSurfaceEventArgs e)
private void OnPaintSurface(object sender, SKPaintGLSurfaceEventArgs e)
{
// the the canvas and properties
var canvas = e.Surface.Canvas;

// get the screen density for scaling
var scale = (float)mtkView.ContentScaleFactor;
canvas.Clear(SKColors.Red);
canvas.DrawRect(SKRect.Create(100, 400, 400, 100), new SKPaint { Color = SKColors.Violet });
canvas.DrawText("This is METAL! " + DateTime.Now.ToString("mm:ss.fff"), 50, 550, new SKPaint { TextSize = 50 });

// handle the device screen density
canvas.Scale(scale);

// make sure the canvas is blank
canvas.Clear(SKColors.White);

// draw some text
var paint = new SKPaint
{
Color = SKColors.Black,
IsAntialias = true,
Style = SKPaintStyle.Fill,
TextAlign = SKTextAlign.Center,
TextSize = 24
};
var coord = new SKPoint((float)mtkView.Bounds.Width / 2, ((float)mtkView.Bounds.Height + paint.TextSize) / 2);
canvas.DrawText("SkiaSharp", coord, paint);
}
}
}