Browse Source

Trying to create a cairo renderer.

Not working. Nothing is drawn...
pull/10/head
Steven Kirk 12 years ago
parent
commit
7167f26c93
  1. 67
      Cairo/Perspex.Cairo/CairoPlatform.cs
  2. 151
      Cairo/Perspex.Cairo/Media/DrawingContext.cs
  3. 37
      Cairo/Perspex.Cairo/Media/Imaging/BitmapImpl.cs
  4. 40
      Cairo/Perspex.Cairo/Media/TextService.cs
  5. 110
      Cairo/Perspex.Cairo/Perspex.Cairo.csproj
  6. 36
      Cairo/Perspex.Cairo/Properties/AssemblyInfo.cs
  7. 104
      Cairo/Perspex.Cairo/Renderer.cs
  8. BIN
      Cairo/Perspex.Cairo/libcairo-2.dll
  9. BIN
      Cairo/Perspex.Cairo/libfontconfig-1.dll
  10. BIN
      Cairo/Perspex.Cairo/libfreetype-6.dll
  11. BIN
      Cairo/Perspex.Cairo/libiconv-2.dll
  12. BIN
      Cairo/Perspex.Cairo/liblzma-5.dll
  13. BIN
      Cairo/Perspex.Cairo/libpixman-1-0.dll
  14. BIN
      Cairo/Perspex.Cairo/libpng15-15.dll
  15. BIN
      Cairo/Perspex.Cairo/libxml2-2.dll
  16. 6
      Cairo/Perspex.Cairo/packages.config
  17. BIN
      Dependencies/Mono.Cairo.dll
  18. 13
      Perspex.sln
  19. 5
      TestApplication/App.cs
  20. 9
      TestApplication/TestApplication.csproj
  21. 2
      Windows/Perspex.Direct2D1/Direct2D1Platform.cs
  22. 3
      Windows/Perspex.Direct2D1/Renderer.cs
  23. 15
      Windows/Perspex.Win32/Interop/UnmanagedMethods.cs

67
Cairo/Perspex.Cairo/CairoPlatform.cs

@ -0,0 +1,67 @@
// -----------------------------------------------------------------------
// <copyright file="CairoPlatform.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Cairo
{
using System;
using global::Cairo;
using Perspex.Cairo.Media;
using Perspex.Cairo.Media.Imaging;
using Perspex.Platform;
using Perspex.Threading;
using Splat;
public class CairoPlatform : IPlatformRenderInterface
{
private static CairoPlatform instance = new CairoPlatform();
private static TextService textService = new TextService();
public static void Initialize()
{
var locator = Locator.CurrentMutable;
locator.Register(() => instance, typeof(IPlatformRenderInterface));
locator.Register(() => textService, typeof(ITextService));
//locator.Register(() => d2d1Factory, typeof(SharpDX.Direct2D1.Factory));
//locator.Register(() => dwFactory, typeof(SharpDX.DirectWrite.Factory));
//locator.Register(() => imagingFactory, typeof(SharpDX.WIC.ImagingFactory));
}
public ITextService TextService
{
get { /*return textService;*/ throw new NotImplementedException(); }
}
public IBitmapImpl CreateBitmap(int width, int height)
{
throw new NotImplementedException();
//return new BitmapImpl(imagingFactory, width, height);
}
public IRenderer CreateRenderer(IntPtr handle, double width, double height)
{
return new Renderer(handle, width, height);
}
public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height)
{
throw new NotImplementedException();
//return new RenderTargetBitmapImpl(imagingFactory, d2d1Factory, width, height);
}
public IStreamGeometryImpl CreateStreamGeometry()
{
throw new NotImplementedException();
//return new StreamGeometryImpl();
}
public IBitmapImpl LoadBitmap(string fileName)
{
ImageSurface result = new ImageSurface(fileName);
return new BitmapImpl(result);
}
}
}

151
Cairo/Perspex.Cairo/Media/DrawingContext.cs

@ -0,0 +1,151 @@
// -----------------------------------------------------------------------
// <copyright file="DrawingContext.cs" company="Steven Kirk">
// Copyright 2013 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Cairo.Media
{
using System;
using System.Reactive.Disposables;
using global::Cairo;
using Perspex.Media;
using IBitmap = Perspex.Media.Imaging.IBitmap;
using Matrix = Perspex.Matrix;
/// <summary>
/// Draws using Direct2D1.
/// </summary>
public class DrawingContext : IDrawingContext, IDisposable
{
/// <summary>
/// The cairo context.
/// </summary>
private Context context;
/// <summary>
/// Initializes a new instance of the <see cref="DrawingContext"/> class.
/// </summary>
/// <param name="surface">The target surface.</param>
public DrawingContext(Surface surface)
{
this.context = new Context(surface);
}
public Matrix CurrentTransform
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
/// <summary>
/// Ends a draw operation.
/// </summary>
public void Dispose()
{
this.context.Dispose();
}
public void DrawImage(IBitmap bitmap, double opacity, Rect sourceRect, Rect destRect)
{
throw new NotImplementedException();
}
/// <summary>
/// Draws a line.
/// </summary>
/// <param name="pen">The stroke pen.</param>
/// <param name="p1">The first point of the line.</param>
/// <param name="p1">The second point of the line.</param>
public void DrawLine(Pen pen, Perspex.Point p1, Perspex.Point p2)
{
throw new NotImplementedException();
}
/// <summary>
/// Draws a geometry.
/// </summary>
/// <param name="brush">The fill brush.</param>
/// <param name="pen">The stroke pen.</param>
/// <param name="geometry">The geometry.</param>
public void DrawGeometry(Perspex.Media.Brush brush, Perspex.Media.Pen pen, Perspex.Media.Geometry geometry)
{
throw new NotImplementedException();
}
/// <summary>
/// Draws the outline of a rectangle.
/// </summary>
/// <param name="pen">The pen.</param>
/// <param name="rect">The rectangle bounds.</param>
public void DrawRectange(Pen pen, Rect rect)
{
this.SetPen(pen);
this.context.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
this.context.Stroke();
}
/// <summary>
/// Draws text.
/// </summary>
/// <param name="foreground">The foreground brush.</param>
/// <param name="rect">The output rectangle.</param>
/// <param name="text">The text.</param>
public void DrawText(Perspex.Media.Brush foreground, Rect rect, FormattedText text)
{
// TODO: Implement
}
/// <summary>
/// Draws a filled rectangle.
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="rect">The rectangle bounds.</param>
public void FillRectange(Perspex.Media.Brush brush, Rect rect)
{
this.SetBrush(brush);
this.context.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
this.context.Fill();
}
/// <summary>
/// Pushes a clip rectange.
/// </summary>
/// <param name="clip">The clip rectangle.</param>
/// <returns>A disposable used to undo the clip rectangle.</returns>
public IDisposable PushClip(Rect clip)
{
return Disposable.Empty;
}
/// <summary>
/// Pushes a matrix transformation.
/// </summary>
/// <param name="matrix">The matrix</param>
/// <returns>A disposable used to undo the transformation.</returns>
public IDisposable PushTransform(Matrix matrix)
{
return Disposable.Empty;
}
private void SetBrush(Brush brush)
{
var solid = brush as SolidColorBrush;
if (solid != null)
{
this.context.SetSourceRGBA(
solid.Color.R / 255.0,
solid.Color.G / 255.0,
solid.Color.B / 255.0,
solid.Color.A / 255.0);
}
}
private void SetPen(Pen pen)
{
this.SetBrush(pen.Brush);
this.context.LineWidth = pen.Thickness;
}
}
}

37
Cairo/Perspex.Cairo/Media/Imaging/BitmapImpl.cs

@ -0,0 +1,37 @@
// -----------------------------------------------------------------------
// <copyright file="BitmapImpl.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Cairo.Media.Imaging
{
using System;
using global::Cairo;
using Perspex.Platform;
public class BitmapImpl : IBitmapImpl
{
private ImageSurface surface;
public BitmapImpl(ImageSurface surface)
{
this.surface = surface;
}
public int PixelWidth
{
get { return this.surface.Width; }
}
public int PixelHeight
{
get { return this.surface.Height; }
}
public void Save(string fileName)
{
throw new NotImplementedException();
}
}
}

40
Cairo/Perspex.Cairo/Media/TextService.cs

@ -0,0 +1,40 @@
// -----------------------------------------------------------------------
// <copyright file="TextService.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Cairo.Media
{
using System;
using System.Linq;
using Perspex.Media;
using Perspex.Platform;
public class TextService : ITextService
{
public TextService()
{
}
public int GetCaretIndex(FormattedText text, Point point, Size constraint)
{
throw new NotImplementedException();
}
public Point GetCaretPosition(FormattedText text, int caretIndex, Size constraint)
{
throw new NotImplementedException();
}
public double[] GetLineHeights(FormattedText text, Size constraint)
{
throw new NotImplementedException();
}
public Size Measure(FormattedText text, Size constraint)
{
return new Size(100, 30);
}
}
}

110
Cairo/Perspex.Cairo/Perspex.Cairo.csproj

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FB05AC90-89BA-4F2F-A924-F37875FB547C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Perspex.Cairo</RootNamespace>
<AssemblyName>Perspex.Cairo</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Cairo">
<HintPath>..\..\Dependencies\Mono.Cairo.dll</HintPath>
</Reference>
<Reference Include="Splat">
<HintPath>..\..\packages\Splat.1.5.1\lib\Net45\Splat.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Interfaces, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CairoPlatform.cs" />
<Compile Include="Media\DrawingContext.cs" />
<Compile Include="Media\Imaging\BitmapImpl.cs" />
<Compile Include="Media\TextService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Renderer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Perspex.Base\Perspex.Base.csproj">
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
<Name>Perspex.Base</Name>
</ProjectReference>
<ProjectReference Include="..\..\Perspex.SceneGraph\Perspex.SceneGraph.csproj">
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project>
<Name>Perspex.SceneGraph</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="libcairo-2.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libfontconfig-1.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libfreetype-6.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libiconv-2.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="liblzma-5.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libpixman-1-0.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libpng15-15.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libxml2-2.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

36
Cairo/Perspex.Cairo/Properties/AssemblyInfo.cs

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Perspex.Cairo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Perspex.Cairo")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f999ba8b-64e7-40cc-98a4-003f1852d2a3")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

104
Cairo/Perspex.Cairo/Renderer.cs

@ -0,0 +1,104 @@
// -----------------------------------------------------------------------
// <copyright file="Renderer.cs" company="Steven Kirk">
// Copyright 2013 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Cairo
{
using System;
using Perspex.Platform;
using Splat;
using global::Cairo;
using System.Runtime.InteropServices;
using Perspex.Cairo.Media;
using Matrix = Perspex.Matrix;
public class Renderer : IRenderer
{
/// <summary>
/// The target cairo surface.
/// </summary>
private Surface surface;
/// <summary>
/// Initializes a new instance of the <see cref="Renderer"/> class.
/// </summary>
/// <param name="hwnd">The window handle.</param>
/// <param name="width">The width of the window.</param>
/// <param name="height">The height of the window.</param>
public Renderer(IntPtr hwnd, double width, double height)
{
surface = new Win32Surface(GetDC(hwnd));
}
/// <summary>
/// Initializes a new instance of the <see cref="Renderer"/> class.
/// </summary>
/// <param name="surface">The target surface.</param>
public Renderer(Surface surface)
{
this.surface = surface;
}
/// <summary>
/// Renders the specified visual.
/// </summary>
/// <param name="visual">The visual to render.</param>
public void Render(IVisual visual)
{
using (DrawingContext context = new DrawingContext(this.surface))
{
this.Render(visual, context);
}
}
/// <summary>
/// Resizes the renderer.
/// </summary>
/// <param name="width">The new width.</param>
/// <param name="height">The new height.</param>
public void Resize(int width, int height)
{
var s = this.surface.CreateSimilar(Content.ColorAlpha, width, height);
this.surface.Dispose();
this.surface = s;
}
[DllImport("user32.dll")]
private static extern IntPtr GetDC(IntPtr hWnd);
/// <summary>
/// Renders the specified visual.
/// </summary>
/// <param name="visual">The visual to render.</param>
/// <param name="context">The drawing context.</param>
private void Render(IVisual visual, DrawingContext context)
{
if (visual.IsVisible && visual.Opacity > 0)
{
Matrix transform = Matrix.Identity;
if (visual.RenderTransform != null)
{
Matrix current = context.CurrentTransform;
Matrix offset = Matrix.Translation(visual.TransformOrigin.ToPixels(visual.Bounds.Size));
transform = -current * -offset * visual.RenderTransform.Value * offset * current;
}
transform *= Matrix.Translation(visual.Bounds.Position);
using (context.PushClip(visual.Bounds))
using (context.PushTransform(transform))
{
visual.Render(context);
foreach (var child in visual.VisualChildren)
{
this.Render(child, context);
}
}
}
}
}
}

BIN
Cairo/Perspex.Cairo/libcairo-2.dll

Binary file not shown.

BIN
Cairo/Perspex.Cairo/libfontconfig-1.dll

Binary file not shown.

BIN
Cairo/Perspex.Cairo/libfreetype-6.dll

Binary file not shown.

BIN
Cairo/Perspex.Cairo/libiconv-2.dll

Binary file not shown.

BIN
Cairo/Perspex.Cairo/liblzma-5.dll

Binary file not shown.

BIN
Cairo/Perspex.Cairo/libpixman-1-0.dll

Binary file not shown.

BIN
Cairo/Perspex.Cairo/libpng15-15.dll

Binary file not shown.

BIN
Cairo/Perspex.Cairo/libxml2-2.dll

Binary file not shown.

6
Cairo/Perspex.Cairo/packages.config

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Rx-Core" version="2.2.5" targetFramework="net45" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
<package id="Splat" version="1.5.1" targetFramework="net45" />
</packages>

BIN
Dependencies/Mono.Cairo.dll

Binary file not shown.

13
Perspex.sln

@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Windows", "Windows\Perspex.Win32\Perspex.Win32.csproj", "{811A76CF-1CF6-440F-963B-BBE31BD72A82}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Win32", "Windows\Perspex.Win32\Perspex.Win32.csproj", "{811A76CF-1CF6-440F-963B-BBE31BD72A82}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication", "TestApplication\TestApplication.csproj", "{E3A1060B-50D0-44E8-88B6-F44EF2E5BD72}"
EndProject
@ -41,6 +41,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Application", "Pers
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Diagnostics", "Perspex.Diagnostics\Perspex.Diagnostics.csproj", "{7062AE20-5DCC-4442-9645-8195BDECE63E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cairo", "Cairo", "{1D577B69-F23B-4C4F-8605-97704DAC75A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Cairo", "Cairo\Perspex.Cairo\Perspex.Cairo.csproj", "{FB05AC90-89BA-4F2F-A924-F37875FB547C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -119,6 +123,10 @@ Global
{7062AE20-5DCC-4442-9645-8195BDECE63E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7062AE20-5DCC-4442-9645-8195BDECE63E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7062AE20-5DCC-4442-9645-8195BDECE63E}.Release|Any CPU.Build.0 = Release|Any CPU
{FB05AC90-89BA-4F2F-A924-F37875FB547C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB05AC90-89BA-4F2F-A924-F37875FB547C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB05AC90-89BA-4F2F-A924-F37875FB547C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB05AC90-89BA-4F2F-A924-F37875FB547C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -128,5 +136,6 @@ Global
{E3A1060B-50D0-44E8-88B6-F44EF2E5BD72} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
{3E908F67-5543-4879-A1DC-08EACE79B3CD} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
{DABFD304-D6A4-4752-8123-C2CCF7AC7831} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
{FB05AC90-89BA-4F2F-A924-F37875FB547C} = {1D577B69-F23B-4C4F-8605-97704DAC75A9}
EndGlobalSection
EndGlobal

5
TestApplication/App.cs

@ -1,6 +1,7 @@
namespace TestApplication
{
using Perspex;
using Perspex.Cairo;
using Perspex.Direct2D1;
using Perspex.Themes.Default;
using Perspex.Win32;
@ -11,7 +12,11 @@
: base(new DefaultTheme())
{
this.RegisterServices();
#if PERSPEX_CAIRO
CairoPlatform.Initialize();
#else
Direct2D1Platform.Initialize();
#endif
Win32Platform.Initialize();
}
}

9
TestApplication/TestApplication.csproj

@ -19,9 +19,10 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;PERSPEX_CAIRO</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -96,6 +97,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cairo\Perspex.Cairo\Perspex.Cairo.csproj">
<Project>{fb05ac90-89ba-4f2f-a924-f37875fb547c}</Project>
<Name>Perspex.Cairo</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Application\Perspex.Application.csproj">
<Project>{799a7bb5-3c2c-48b6-85a7-406a12c420da}</Project>
<Name>Perspex.Application</Name>
@ -142,7 +147,7 @@
</ProjectReference>
<ProjectReference Include="..\Windows\Perspex.Win32\Perspex.Win32.csproj">
<Project>{811a76cf-1cf6-440f-963b-bbe31bd72a82}</Project>
<Name>Perspex.Windows</Name>
<Name>Perspex.Win32</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>

2
Windows/Perspex.Direct2D1/Direct2D1Platform.cs

@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
// <copyright file="Direct2D1Initialize.cs" company="Steven Kirk">
// <copyright file="Direct2D1Platform.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------

3
Windows/Perspex.Direct2D1/Renderer.cs

@ -18,9 +18,6 @@ namespace Perspex.Direct2D1
using Matrix = Perspex.Matrix;
using Point = Perspex.Point;
/// <summary>
/// Renders a <see cref="Canvas"/>.
/// </summary>
public class Renderer : IRenderer
{
/// <summary>

15
Windows/Perspex.Win32/Interop/UnmanagedMethods.cs

@ -42,6 +42,18 @@ namespace Perspex.Win32.Interop
IDC_HELP = 32651
}
[StructLayout(LayoutKind.Sequential)]
public struct PAINTSTRUCT
{
public IntPtr hdc;
public bool fErase;
public RECT rcPaint;
public bool fRestore;
public bool fIncUpdate;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] rgbReserved;
}
[Flags]
public enum SetWindowPosFlags : uint
{
@ -350,6 +362,9 @@ namespace Perspex.Win32.Interop
WM_DISPATCH_WORK_ITEM = WM_USER,
}
[DllImport("user32.dll")]
public static extern IntPtr BeginPaint(IntPtr hwnd, out PAINTSTRUCT lpPaint);
[DllImport("user32.dll")]
public static extern bool ClientToScreen(IntPtr hWnd, ref POINT lpPoint);

Loading…
Cancel
Save