Implement initial simplified render loop
このコミットが含まれているのは:
1 親
f84bbdc20a
コミット
081aacd4fd
1ファイル変更
+50
-2
@@ -1,7 +1,15 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using ComputeSharp.D2D1.Uwp;
|
||||
using ComputeSharp.SwapChain.D2D1.CoreWindow.Extensions;
|
||||
using ComputeSharp.SwapChain.Shaders.D2D1;
|
||||
using Microsoft.Graphics.Canvas;
|
||||
using Microsoft.Graphics.Canvas.Effects;
|
||||
using Windows.ApplicationModel.Core;
|
||||
|
||||
#pragma warning disable IDE0052
|
||||
using Windows.Graphics.Display;
|
||||
using Windows.UI;
|
||||
using Windows.UI.ViewManagement;
|
||||
|
||||
namespace ComputeSharp.SwapChain.D2D1.CoreWindow;
|
||||
|
||||
@@ -12,7 +20,14 @@ using Windows.UI.Core;
|
||||
/// </summary>
|
||||
public sealed partial class App : IFrameworkViewSource, IFrameworkView
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="CoreApplicationView"/> for the current app instance.
|
||||
/// </summary>
|
||||
private CoreApplicationView? applicationView;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="CoreWindow"/> used to display the app content.
|
||||
/// </summary>
|
||||
private CoreWindow? window;
|
||||
|
||||
/// <summary>
|
||||
@@ -51,6 +66,39 @@ public sealed partial class App : IFrameworkViewSource, IFrameworkView
|
||||
/// <inheritdoc/>
|
||||
public void Run()
|
||||
{
|
||||
this.applicationView!.TitleBar.ExtendViewIntoTitleBar = true;
|
||||
|
||||
ApplicationView.GetForCurrentView().TitleBar.StyleTitleBarForExtendedIntoViewMode();
|
||||
|
||||
CanvasSwapChain swapChain = CanvasSwapChain.CreateForCoreWindow(
|
||||
CanvasDevice.GetSharedDevice(),
|
||||
this.window,
|
||||
DisplayInformation.GetForCurrentView().LogicalDpi);
|
||||
|
||||
int2 sizeInPixels = new((int)swapChain.SizeInPixels.Width, (int)swapChain.SizeInPixels.Height);
|
||||
CancellationTokenSource cancellationTokenSource = new();
|
||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
|
||||
Thread thread = new(() =>
|
||||
{
|
||||
PixelShaderEffect<ColorfulInfinity> shader = new();
|
||||
PremultiplyEffect premultiply = new() { Source = shader };
|
||||
|
||||
while (!cancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
using (CanvasDrawingSession session = swapChain.CreateDrawingSession(Colors.Transparent))
|
||||
{
|
||||
shader.ConstantBuffer = new ColorfulInfinity((float)stopwatch.Elapsed.TotalSeconds, sizeInPixels);
|
||||
|
||||
session.DrawImage(premultiply);
|
||||
}
|
||||
|
||||
swapChain.Present(syncInterval: 1);
|
||||
}
|
||||
});
|
||||
|
||||
thread.Start();
|
||||
|
||||
this.window!.Activate();
|
||||
|
||||
this.window.Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessUntilQuit);
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする