<commit_before>﻿// -----------------------------------------------------------------------
// <copyright file="Renderer.cs" company="<NAME>">
// 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)
        {<commit_msg>Now at least draws something.<commit_after>﻿// -----------------------------------------------------------------------
// <copyright file="Renderer.cs" company="<NAME>">
// 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 handle of the window to draw to.
        /// </summary>
        private IntPtr hwnd;

        /// <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)
        {
            this.hwnd = hwnd;
        }

        /// <summary>
        /// Renders the specified visual.
        /// </summary>
        /// <param name="visual">The visual to render.</param>
        public void Render(IVisual visual)
        {
            using (var surface = new Win32Surface(GetDC(this.hwnd)))
            using (DrawingContext context = new DrawingContext(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)
        {
        }

        [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)
        {
{'fraction_non_alphanumeric': 0.18703241895261846, 'fraction_numerical': 0.0033250207813798837, 'mean_word_length': 1.5172594142259415, 'pattern_counts': {'":': 0, '<': 68, '<?xml version=': 0, '>': 68, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '497102', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1207, 'n_words': 340}