|
|
@@ -32,21 +32,23 @@ namespace Avalonia.Gtk3
|
|
|
Height = height;
|
|
|
Address = Native.CairoImageSurfaceGetData(_surface);
|
|
|
RowBytes = Native.CairoImageSurfaceGetStride(_surface);
|
|
|
- Native.CairoSurfaceSetDeviceScale(_surface, factor, factor);
|
|
|
Native.CairoSurfaceFlush(_surface);
|
|
|
}
|
|
|
|
|
|
- static void Draw(IntPtr context, CairoSurface surface)
|
|
|
+ static void Draw(IntPtr context, CairoSurface surface, double factor)
|
|
|
{
|
|
|
+
|
|
|
Native.CairoSurfaceMarkDirty(surface);
|
|
|
+ Native.CairoScale(context, 1d / factor, 1d / factor);
|
|
|
Native.CairoSetSourceSurface(context, surface, 0, 0);
|
|
|
Native.CairoPaint(context);
|
|
|
+
|
|
|
}
|
|
|
/*
|
|
|
static Stopwatch St =Stopwatch.StartNew();
|
|
|
private static int _frames;
|
|
|
private static int _fps;*/
|
|
|
- static void DrawToWidget(GtkWidget widget, CairoSurface surface, int width, int height)
|
|
|
+ static void DrawToWidget(GtkWidget widget, CairoSurface surface, int width, int height, double factor)
|
|
|
{
|
|
|
if(surface == null || widget.IsClosed)
|
|
|
return;
|
|
|
@@ -56,7 +58,7 @@ namespace Avalonia.Gtk3
|
|
|
var rc = new GdkRectangle {Width = width, Height = height};
|
|
|
Native.GdkWindowBeginPaintRect(window, ref rc);
|
|
|
var context = Native.GdkCairoCreate(window);
|
|
|
- Draw(context, surface);
|
|
|
+ Draw(context, surface, factor);
|
|
|
/*
|
|
|
_frames++;
|
|
|
var el = St.Elapsed;
|
|
|
@@ -82,13 +84,15 @@ namespace Avalonia.Gtk3
|
|
|
{
|
|
|
private readonly GtkWidget _widget;
|
|
|
private CairoSurface _surface;
|
|
|
+ private readonly double _factor;
|
|
|
private readonly int _width;
|
|
|
private readonly int _height;
|
|
|
|
|
|
- public RenderOp(GtkWidget widget, CairoSurface _surface, int width, int height)
|
|
|
+ public RenderOp(GtkWidget widget, CairoSurface _surface, double factor, int width, int height)
|
|
|
{
|
|
|
_widget = widget;
|
|
|
this._surface = _surface;
|
|
|
+ _factor = factor;
|
|
|
_width = width;
|
|
|
_height = height;
|
|
|
}
|
|
|
@@ -101,7 +105,7 @@ namespace Avalonia.Gtk3
|
|
|
|
|
|
public void RenderNow()
|
|
|
{
|
|
|
- DrawToWidget(_widget, _surface, _width, _height);
|
|
|
+ DrawToWidget(_widget, _surface, _width, _height, _factor);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -112,13 +116,13 @@ namespace Avalonia.Gtk3
|
|
|
if (Dispatcher.UIThread.CheckAccess())
|
|
|
{
|
|
|
if (_impl.CurrentCairoContext != IntPtr.Zero)
|
|
|
- Draw(_impl.CurrentCairoContext, _surface);
|
|
|
+ Draw(_impl.CurrentCairoContext, _surface, _factor);
|
|
|
else
|
|
|
- DrawToWidget(_widget, _surface, Width, Height);
|
|
|
+ DrawToWidget(_widget, _surface, Width, Height, _factor);
|
|
|
_surface.Dispose();
|
|
|
}
|
|
|
else
|
|
|
- _impl.SetNextRenderOperation(new RenderOp(_widget, _surface, Width, Height));
|
|
|
+ _impl.SetNextRenderOperation(new RenderOp(_widget, _surface, _factor, Width, Height));
|
|
|
_surface = null;
|
|
|
}
|
|
|
}
|