Browse Source

Got OS X compiling/running again. Fixed Render update issues on iOS, including accounting for iOS Status Bar at the top. Input works again!

pull/506/head
Jason Jarvis 10 years ago
parent
commit
1a791a02b3
  1. 2
      src/Skia/Perspex.Skia.iOS.TestApp/Perspex.Skia.iOS.TestApp.csproj
  2. 8
      src/Skia/Perspex.Skia.iOS/Perspex.Skia.iOS.csproj
  3. 6
      src/Skia/Perspex.Skia.iOS/SkiaView.cs
  4. 26
      src/Skia/Perspex.Skia/RenderTarget.cs
  5. 13
      src/Windows/Perspex.Win32/SystemDialogImpl.cs
  6. 3
      src/iOS/Perspex.iOS/PerspexView.cs
  7. 36
      src/iOS/Perspex.iOSTestApplication/AppDelegate.cs
  8. 2
      src/iOS/Perspex.iOSTestApplication/Perspex.iOSTestApplication.csproj

2
src/Skia/Perspex.Skia.iOS.TestApp/Perspex.Skia.iOS.TestApp.csproj

@ -20,7 +20,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchArch>i386</MtouchArch>
<MtouchLink>None</MtouchLink>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchDebug>true</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">

8
src/Skia/Perspex.Skia.iOS/Perspex.Skia.iOS.csproj

@ -2,7 +2,7 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{47BE08A7-5985-410B-9FFC-2264B8EA595F}</ProjectGuid>
@ -36,15 +36,9 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="iOSMethodTable.cs" />
<Compile Include="SkiaView.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\native\iOS\libperspesk_standalone.a">
<Link>libperspesk_standalone.a</Link>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Reference Include="SkiaSharp, Version=1.49.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SkiaSharp.1.49.2.0-beta\lib\XamariniOS\SkiaSharp.dll</HintPath>

6
src/Skia/Perspex.Skia.iOS/SkiaView.cs

@ -21,7 +21,7 @@ namespace Perspex.Skia.iOS
//static extern IntPtr GetPerspexEAGLContext();
bool _drawQueued;
CADisplayLink _link;
//CADisplayLink _link;
static EAGLContext GetContext()
{
/* No longer needed with SkiaSharp
@ -43,7 +43,7 @@ namespace Perspex.Skia.iOS
protected SkiaView() : base(UIScreen.MainScreen.ApplicationFrame) //, GetContext())
{
(_link = CADisplayLink.Create(() => OnFrame())).AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
//(_link = CADisplayLink.Create(() => OnFrame())).AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
}
protected void OnFrame()
@ -54,6 +54,8 @@ namespace Perspex.Skia.iOS
// GLKView
//Display();
this.SetNeedsDisplay();
}
}

26
src/Skia/Perspex.Skia/RenderTarget.cs

@ -50,6 +50,25 @@ namespace Perspex.Skia
FixSize();
}
#if __IOS__
private CGRect GetApplicationFrame()
{
// if we are excluding Status Bar then we use ApplicationFrame
// otherwise we use full screen bounds. Note that this must also match
// the Skia/PerspexView!!!
//
bool excludeStatusArea = false; // TODO: make this configurable later
if (excludeStatusArea)
{
return UIScreen.MainScreen.ApplicationFrame;
}
else
{
return UIScreen.MainScreen.Bounds;
}
}
#endif
void FixSize()
{
int width, height;
@ -83,7 +102,7 @@ namespace Perspex.Skia
void GetPlatformWindowSize(IntPtr hwnd, out int w, out int h)
{
#if __IOS__
var bounds = UIScreen.MainScreen.ApplicationFrame;
var bounds = GetApplicationFrame();
w = (int) bounds.Width;
h = (int)bounds.Height;
@ -126,7 +145,8 @@ namespace Perspex.Skia
#if __IOS__
const int bitmapInfo = ((int)CGBitmapFlags.ByteOrder32Big) | ((int)CGImageAlphaInfo.PremultipliedLast);
var bounds = UIScreen.MainScreen.ApplicationFrame;
var bounds = GetApplicationFrame();
var statusBarOffset = UIScreen.MainScreen.Bounds.Height - bounds.Height;
using (var colorSpace = CGColorSpace.CreateDeviceRGB())
using (var bContext = new CGBitmapContext(pixels, _bitmap.Width, _bitmap.Height, 8, _bitmap.Width * 4, colorSpace, (CGImageAlphaInfo)bitmapInfo))
@ -134,7 +154,7 @@ namespace Perspex.Skia
using (var context = UIGraphics.GetCurrentContext())
{
// flip the image for CGContext.DrawImage
context.TranslateCTM(0, bounds.Height); // Frame.Height);
context.TranslateCTM(0, bounds.Height + statusBarOffset);
context.ScaleCTM(1, -1);
context.DrawImage(bounds, image);
}

13
src/Windows/Perspex.Win32/SystemDialogImpl.cs

@ -40,17 +40,20 @@ namespace Perspex.Win32
var filterBuffer = new char[filters.Length];
filters.CopyTo(0, filterBuffer, 0, filterBuffer.Length);
var defExt = (dialog as SaveFileDialog)?.DefaultExtension;
var defExt = (dialog as SaveFileDialog)?.DefaultExtension.ToArray();
var fileBuffer = new char[256];
dialog.InitialFileName?.CopyTo(0, fileBuffer, 0, dialog.InitialFileName.Length);
string userSelectedExt = null;
fixed (char* pFileBuffer = fileBuffer)
var title = dialog.Title.ToArray();
var initialDir = dialog.InitialDirectory.ToArray();
fixed (char* pFileBuffer = fileBuffer)
fixed (char* pFilterBuffer = filterBuffer)
fixed (char* pDefExt = defExt)
fixed (char* pInitDir = dialog.InitialDirectory)
fixed (char* pTitle = dialog.Title)
fixed (char* pInitDir = initialDir)
fixed (char* pTitle = title)
{
var ofn = new UnmanagedMethods.OpenFileName()
{

3
src/iOS/Perspex.iOS/PerspexView.cs

@ -57,7 +57,8 @@ namespace Perspex.iOS
(_controller.InterfaceOrientation == UIInterfaceOrientation.LandscapeLeft
|| _controller.InterfaceOrientation == UIInterfaceOrientation.LandscapeRight);
var frame = UIScreen.MainScreen.Bounds;
// Bounds here (if top level) needs to correspond with the rendertarget
var frame = UIScreen.MainScreen.Bounds;
if (needFlip)
Frame = new CGRect(frame.Y, frame.X, frame.Height, frame.Width);
else

36
src/iOS/Perspex.iOSTestApplication/AppDelegate.cs

@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Foundation;
using Perspex.Controls;
using Perspex.iOS;
using Perspex.Media;
using Perspex.Threading;
using TestApplication;
using UIKit;
@ -29,12 +31,42 @@ namespace Perspex.iOSTestApplication
var app = new App();
MainWindow.RootNamespace = "Perspex.iOSTestApplication";
var window = MainWindow.Create();
MainWindow.RootNamespace = "Perspex.iOSTestApplication";
var window = MainWindow.Create();
window.Show();
app.Run(window);
return true;
}
// This provides a simple UI tree for testing input handling
public static Window Create()
{
Window window = new Window
{
Title = "Perspex Test Application",
//Width = 900,
//Height = 480,
Background = Brushes.Red,
Content = new Grid
{
Margin = new Thickness(100),
Background = Brushes.Yellow,
Children = new Controls.Controls
{
new Button
{
Content = "Hello World!",
Width = 200,
Height = 200
}
}
}
};
return window;
}
}
}

2
src/iOS/Perspex.iOSTestApplication/Perspex.iOSTestApplication.csproj

@ -20,7 +20,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchArch>i386</MtouchArch>
<MtouchLink>None</MtouchLink>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchDebug>true</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">

Loading…
Cancel
Save