Browse Source

Merge branch 'master' into screen-updates

pull/9133/head
Max Katz 4 years ago
committed by GitHub
parent
commit
af449e8b7b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      samples/ControlCatalog.Web/ControlCatalog.Web.csproj
  2. 1
      samples/ControlCatalog.Web/Roots.xml
  3. 4
      src/Avalonia.Base/Media/PathMarkupParser.cs
  4. 35
      src/Web/Avalonia.Web/webapp/modules/avalonia/canvas.ts
  5. 6
      src/Web/Avalonia.Web/webapp/modules/avalonia/input.ts
  6. 5
      src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs

5
samples/ControlCatalog.Web/ControlCatalog.Web.csproj

@ -16,9 +16,8 @@
<TrimMode>full</TrimMode> <TrimMode>full</TrimMode>
<WasmBuildNative>true</WasmBuildNative> <WasmBuildNative>true</WasmBuildNative>
<InvariantGlobalization>true</InvariantGlobalization> <InvariantGlobalization>true</InvariantGlobalization>
<WasmEnableSIMD>true</WasmEnableSIMD> <EmccCompileOptimizationFlag>-O2</EmccCompileOptimizationFlag>
<EmccCompileOptimizationFlag>-O3</EmccCompileOptimizationFlag> <EmccLinkOptimizationFlag>-O2</EmccLinkOptimizationFlag>
<EmccLinkOptimizationFlag>-O3</EmccLinkOptimizationFlag>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

1
samples/ControlCatalog.Web/Roots.xml

@ -3,4 +3,5 @@
<assembly fullname="ControlCatalog.Web" preserve="All" /> <assembly fullname="ControlCatalog.Web" preserve="All" />
<assembly fullname="Avalonia.Themes.Fluent" preserve="All" /> <assembly fullname="Avalonia.Themes.Fluent" preserve="All" />
<assembly fullname="Avalonia.Themes.Simple" preserve="All" /> <assembly fullname="Avalonia.Themes.Simple" preserve="All" />
<assembly fullname="Avalonia.Controls.ColorPicker" preserve="All" />
</linker> </linker>

4
src/Avalonia.Base/Media/PathMarkupParser.cs

@ -188,7 +188,7 @@ namespace Avalonia.Media
_isOpen = true; _isOpen = true;
} }
private void SetFillRule(ref ReadOnlySpan<char> span) private void SetFillRule(scoped ref ReadOnlySpan<char> span)
{ {
ThrowIfDisposed(); ThrowIfDisposed();
@ -452,7 +452,7 @@ namespace Avalonia.Media
return !span.IsEmpty && (span[0] == ',' || span[0] == '-' || span[0] == '.' || char.IsDigit(span[0])); return !span.IsEmpty && (span[0] == ',' || span[0] == '-' || span[0] == '.' || char.IsDigit(span[0]));
} }
private static bool ReadArgument(ref ReadOnlySpan<char> remaining, out ReadOnlySpan<char> argument) private static bool ReadArgument(scoped ref ReadOnlySpan<char> remaining, out ReadOnlySpan<char> argument)
{ {
remaining = SkipWhitespace(remaining); remaining = SkipWhitespace(remaining);
if (remaining.IsEmpty) if (remaining.IsEmpty)

35
src/Web/Avalonia.Web/webapp/modules/avalonia/canvas.ts

@ -106,12 +106,6 @@ export class Canvas {
// add the draw to the next frame // add the draw to the next frame
this.renderLoopRequest = window.requestAnimationFrame(() => { this.renderLoopRequest = window.requestAnimationFrame(() => {
if (this.glInfo) {
const GL = (globalThis as any).AvaloniaGL;
// make current
GL.makeContextCurrent(this.glInfo.context);
}
if (this.htmlCanvas.width !== this.newWidth) { if (this.htmlCanvas.width !== this.newWidth) {
this.htmlCanvas.width = this.newWidth ?? 0; this.htmlCanvas.width = this.newWidth ?? 0;
} }
@ -131,6 +125,11 @@ export class Canvas {
} }
public setCanvasSize(width: number, height: number): void { public setCanvasSize(width: number, height: number): void {
if (this.renderLoopRequest !== 0) {
window.cancelAnimationFrame(this.renderLoopRequest);
this.renderLoopRequest = 0;
}
this.newWidth = width; this.newWidth = width;
this.newHeight = height; this.newHeight = height;
@ -142,11 +141,7 @@ export class Canvas {
this.htmlCanvas.height = this.newHeight; this.htmlCanvas.height = this.newHeight;
} }
if (this.glInfo) { this.requestAnimationFrame();
const GL = (globalThis as any).AvaloniaGL;
// make current
GL.makeContextCurrent(this.glInfo.context);
}
} }
public static setCanvasSize(element: HTMLCanvasElement, width: number, height: number): void { public static setCanvasSize(element: HTMLCanvasElement, width: number, height: number): void {
@ -210,23 +205,25 @@ interface SizeWatcherInstance {
export class SizeWatcher { export class SizeWatcher {
static observer: ResizeObserver; static observer: ResizeObserver;
static elements: Map<string, HTMLElement>; static elements: Map<string, HTMLElement>;
private static lastMove: number;
public static observe(element: HTMLElement, elementId: string | undefined, callback: (width: number, height: number) => void): void { public static observe(element: HTMLElement, elementId: string | undefined, callback: (width: number, height: number) => void): void {
if (!element || !callback) { if (!element || !callback) {
return; return;
} }
SizeWatcher.init(); SizeWatcher.lastMove = Date.now();
const watcherElement = element as SizeWatcherElement; callback(element.clientWidth, element.clientHeight);
watcherElement.SizeWatcher = {
callback
};
SizeWatcher.elements.set(elementId ?? element.id, element); const handleResize = (args: UIEvent) => {
SizeWatcher.observer.observe(element); if (Date.now() - SizeWatcher.lastMove > 33) {
callback(element.clientWidth, element.clientHeight);
SizeWatcher.lastMove = Date.now();
}
};
SizeWatcher.invoke(element); window.addEventListener("resize", handleResize);
} }
public static unobserve(elementId: string): void { public static unobserve(elementId: string): void {

6
src/Web/Avalonia.Web/webapp/modules/avalonia/input.ts

@ -159,7 +159,11 @@ export class InputHelper {
} }
public static setCursor(inputElement: HTMLInputElement, kind: string) { public static setCursor(inputElement: HTMLInputElement, kind: string) {
inputElement.style.cursor = kind; if (kind === "pointer") {
inputElement.style.removeProperty("cursor");
} else {
inputElement.style.cursor = kind;
}
} }
public static setBounds(inputElement: HTMLInputElement, x: number, y: number, caretWidth: number, caretHeight: number, caret: number) { public static setBounds(inputElement: HTMLInputElement, x: number, y: number, caretWidth: number, caretHeight: number, caret: number) {

5
src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs

@ -1878,7 +1878,10 @@ namespace Avalonia.Win32.Interop
public static uint LGID(IntPtr HKL) public static uint LGID(IntPtr HKL)
{ {
return (uint)(HKL.ToInt32() & 0xffff); unchecked
{
return (uint)((ulong)HKL & 0xffff);
}
} }
public const int SORT_DEFAULT = 0; public const int SORT_DEFAULT = 0;

Loading…
Cancel
Save