Browse Source

Picked some style nits.

pull/861/head
Steven Kirk 10 years ago
parent
commit
8f3e56963a
  1. 6
      src/Android/Avalonia.Android/Platform/SkiaPlatform/WindowImpl.cs
  2. 9
      src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs
  3. 4
      src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs
  4. 2
      src/Gtk/Avalonia.Cairo/CairoPlatform.cs
  5. 5
      src/Gtk/Avalonia.Gtk/FramebufferManager.cs
  6. 13
      src/Gtk/Avalonia.Gtk/WindowImplBase.cs
  7. 2
      src/Skia/Avalonia.Skia/PlatformRenderInterface.cs
  8. 71
      src/Windows/Avalonia.Win32/WindowFramebuffer.cs
  9. 11
      src/Windows/Avalonia.Win32/WindowImpl.cs
  10. 5
      src/iOS/Avalonia.iOS/AvaloniaView.cs

6
src/Android/Avalonia.Android/Platform/SkiaPlatform/WindowImpl.cs

@ -96,6 +96,8 @@ namespace Avalonia.Android.Platform.SkiaPlatform
IPlatformHandle ITopLevelImpl.Handle => this; IPlatformHandle ITopLevelImpl.Handle => this;
public IEnumerable<object> Surfaces => new object[] { this };
public void Activate() public void Activate()
{ {
} }
@ -194,7 +196,5 @@ namespace Avalonia.Android.Platform.SkiaPlatform
{ {
// No window icons for mobile platforms // No window icons for mobile platforms
} }
}
public IEnumerable<object> Surfaces => new object[] {this};
}
} }

9
src/Avalonia.Controls/Platform/Surfaces/ILockedFramebuffer.cs

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Controls.Platform.Surfaces namespace Avalonia.Controls.Platform.Surfaces
{ {
@ -12,22 +8,27 @@ namespace Avalonia.Controls.Platform.Surfaces
/// Address of the first pixel /// Address of the first pixel
/// </summary> /// </summary>
IntPtr Address { get; } IntPtr Address { get; }
/// <summary> /// <summary>
/// Framebuffer width /// Framebuffer width
/// </summary> /// </summary>
int Width { get; } int Width { get; }
/// <summary> /// <summary>
/// Framebuffer height /// Framebuffer height
/// </summary> /// </summary>
int Height { get; } int Height { get; }
/// <summary> /// <summary>
/// Number of bytes per row /// Number of bytes per row
/// </summary> /// </summary>
int RowBytes { get; } int RowBytes { get; }
/// <summary> /// <summary>
/// DPI of underling screen /// DPI of underling screen
/// </summary> /// </summary>
Size Dpi { get; } Size Dpi { get; }
/// <summary> /// <summary>
/// Pixel format /// Pixel format
/// </summary> /// </summary>

4
src/Avalonia.Visuals/Platform/IPlatformRenderInterface.cs

@ -41,7 +41,9 @@ namespace Avalonia.Platform
/// <summary> /// <summary>
/// Creates a renderer. /// Creates a renderer.
/// </summary> /// </summary>
/// <param name="surfaces">The list of native platform's surfaces that can be used for output.</param> /// <param name="surfaces">
/// The list of native platform surfaces that can be used for output.
/// </param>
/// <returns>An <see cref="IRenderTarget"/>.</returns> /// <returns>An <see cref="IRenderTarget"/>.</returns>
IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces); IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces);

2
src/Gtk/Avalonia.Cairo/CairoPlatform.cs

@ -59,7 +59,7 @@ namespace Avalonia.Cairo
return new RenderTarget(accessor); return new RenderTarget(accessor);
throw new NotSupportedException(string.Format( throw new NotSupportedException(string.Format(
"Don't know how to create a Cairo renderer from any of provided surfaces")); "Don't know how to create a Cairo renderer from any of the provided surfaces."));
} }
public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height) public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height)

5
src/Gtk/Avalonia.Gtk/FramebufferManager.cs

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls.Platform.Surfaces; using Avalonia.Controls.Platform.Surfaces;
namespace Avalonia.Gtk namespace Avalonia.Gtk
@ -11,6 +7,7 @@ namespace Avalonia.Gtk
{ {
private readonly WindowImplBase _window; private readonly WindowImplBase _window;
private PixbufFramebuffer _fb; private PixbufFramebuffer _fb;
public FramebufferManager(WindowImplBase window) public FramebufferManager(WindowImplBase window)
{ {
_window = window; _window = window;

13
src/Gtk/Avalonia.Gtk/WindowImplBase.cs

@ -3,15 +3,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reactive.Disposables; using Avalonia.Input;
using System.Runtime.InteropServices;
using Gdk;
using Avalonia.Controls;
using Avalonia.Controls.Platform.Surfaces;
using Avalonia.Input.Raw; using Avalonia.Input.Raw;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Input; using Gdk;
using Avalonia.Threading;
using Action = System.Action; using Action = System.Action;
using WindowEdge = Avalonia.Controls.WindowEdge; using WindowEdge = Avalonia.Controls.WindowEdge;
@ -23,8 +18,6 @@ namespace Avalonia.Gtk
{ {
private IInputRoot _inputRoot; private IInputRoot _inputRoot;
protected Gtk.Widget _window; protected Gtk.Widget _window;
public Gtk.Widget Widget => _window;
public Gdk.Drawable CurrentDrawable { get; private set; }
private FramebufferManager _framebuffer; private FramebufferManager _framebuffer;
private Gtk.IMContext _imContext; private Gtk.IMContext _imContext;
@ -60,6 +53,8 @@ namespace Avalonia.Gtk
} }
public IPlatformHandle Handle { get; private set; } public IPlatformHandle Handle { get; private set; }
public Gtk.Widget Widget => _window;
public Gdk.Drawable CurrentDrawable { get; private set; }
void OnRealized (object sender, EventArgs eventArgs) void OnRealized (object sender, EventArgs eventArgs)
{ {

2
src/Skia/Avalonia.Skia/PlatformRenderInterface.cs

@ -55,8 +55,6 @@ namespace Avalonia.Skia
return new Renderer(root, renderLoop); return new Renderer(root, renderLoop);
} }
public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height) public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height)
{ {
if (width < 1) if (width < 1)

71
src/Windows/Avalonia.Win32/WindowFramebuffer.cs

@ -18,8 +18,7 @@ namespace Avalonia.Win32
{ {
private readonly IntPtr _handle; private readonly IntPtr _handle;
private IntPtr _pBitmap; private IntPtr _pBitmap;
UnmanagedMethods.BITMAPINFOHEADER _bmpInfo; private UnmanagedMethods.BITMAPINFOHEADER _bmpInfo;
public WindowFramebuffer(IntPtr handle, int width, int height) public WindowFramebuffer(IntPtr handle, int width, int height)
{ {
@ -38,7 +37,38 @@ namespace Avalonia.Win32
_pBitmap = Marshal.AllocHGlobal(width * height * 4); _pBitmap = Marshal.AllocHGlobal(width * height * 4);
} }
~WindowFramebuffer()
{
Deallocate();
}
public IntPtr Address => _pBitmap;
public int RowBytes => Width * 4;
public PixelFormat Format => PixelFormat.Bgra8888;
public Size Dpi
{
get
{
if (UnmanagedMethods.ShCoreAvailable)
{
uint dpix, dpiy;
var monitor = UnmanagedMethods.MonitorFromWindow(_handle,
UnmanagedMethods.MONITOR.MONITOR_DEFAULTTONEAREST);
if (UnmanagedMethods.GetDpiForMonitor(
monitor,
UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI,
out dpix,
out dpiy) == 0)
{
return new Size(dpix, dpiy);
}
}
return new Size(96, 96);
}
}
public int Width => _bmpInfo.biWidth; public int Width => _bmpInfo.biWidth;
@ -73,11 +103,9 @@ namespace Avalonia.Win32
return true; return true;
} }
public void Dispose() public void Dispose()
{ {
//It's not an *actual* dispose. This call meand "We are done drawing" //It's not an *actual* dispose. This call means "We are done drawing"
DrawToWindow(_handle); DrawToWindow(_handle);
} }
@ -89,38 +117,5 @@ namespace Avalonia.Win32
_pBitmap = IntPtr.Zero; _pBitmap = IntPtr.Zero;
} }
} }
~WindowFramebuffer()
{
Deallocate();
}
public IntPtr Address => _pBitmap;
public int RowBytes => Width * 4;
public PixelFormat Format => PixelFormat.Bgra8888;
public Size Dpi
{
get
{
if (UnmanagedMethods.ShCoreAvailable)
{
uint dpix, dpiy;
var monitor = UnmanagedMethods.MonitorFromWindow(_handle,
UnmanagedMethods.MONITOR.MONITOR_DEFAULTTONEAREST);
if (UnmanagedMethods.GetDpiForMonitor(
monitor,
UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI,
out dpix,
out dpiy) == 0)
{
return new Size(dpix, dpiy);
}
}
return new Size(96, 96);
}
}
} }
} }

11
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -38,6 +38,7 @@ namespace Avalonia.Win32
private double _scaling = 1; private double _scaling = 1;
private WindowState _showWindowState; private WindowState _showWindowState;
private FramebufferManager _framebuffer; private FramebufferManager _framebuffer;
public WindowImpl() public WindowImpl()
{ {
CreateWindow(); CreateWindow();
@ -164,6 +165,11 @@ namespace Avalonia.Win32
} }
} }
public IEnumerable<object> Surfaces => new object[]
{
Handle, _framebuffer
};
public void Activate() public void Activate()
{ {
UnmanagedMethods.SetActiveWindow(_hwnd); UnmanagedMethods.SetActiveWindow(_hwnd);
@ -764,10 +770,5 @@ namespace Avalonia.Win32
ShowWindow(WindowState.Maximized); ShowWindow(WindowState.Maximized);
} }
} }
public IEnumerable<object> Surfaces => new object[]
{
Handle, _framebuffer
};
} }
} }

5
src/iOS/Avalonia.iOS/AvaloniaView.cs

@ -149,6 +149,9 @@ namespace Avalonia.iOS
} }
public Size MaxClientSize => Bounds.Size.ToAvalonia(); public Size MaxClientSize => Bounds.Size.ToAvalonia();
public IEnumerable<object> Surfaces => new object[] { this };
public void SetTitle(string title) public void SetTitle(string title)
{ {
//Not supported //Not supported
@ -232,8 +235,6 @@ namespace Avalonia.iOS
public void SetIcon(IWindowIconImpl icon) public void SetIcon(IWindowIconImpl icon)
{ {
} }
public IEnumerable<object> Surfaces => new object[]{this};
} }
class AvaloniaViewController : UIViewController class AvaloniaViewController : UIViewController

Loading…
Cancel
Save