示例#1
0
        private void SKGLView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintGLSurfaceEventArgs e)
        {
            if (_isInitiated)
            {
                e.Surface.Canvas.Clear(SKColors.Black);
                try
                {
                    _oRoot.Render(_rootState);
                }
                catch (Exception ex)
                {
                }

                var dt = _stopwatch.ElapsedMilliseconds - _lastElapsedTime;
                if (dt < 16)
                {
                    Task.Delay((int)(16 - dt)).Wait();
                }
                _lastElapsedTime = _stopwatch.ElapsedMilliseconds;
            }
            else if (!_isInitializing)
            {
                try
                {
                    var deviceHeight = e.Surface.Canvas.DeviceClipBounds.Height;
                    var deviceWidth  = e.Surface.Canvas.DeviceClipBounds.Width;
                    _isInitializing = true;
                    // Init Odin
                    _oRoot.Initialize(deviceWidth, deviceHeight);
                    _oRoot.SetCanvas(e.Surface.Canvas);
                    _stopwatch = new Stopwatch();
                    _stopwatch.Start();
                    _isInitiated = true;
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                    throw;
                }
            }
        }
示例#2
0
        void Handle_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintGLSurfaceEventArgs e)
        {
            SkiaView.GRContext.GetResourceCacheLimits(out _resources, out _resourceBytes);

            SkiaView.GRContext.GetResourceCacheUsage(out _cacheResources, out _cacheResourcesBytes);

            e.Surface.Canvas.SetMatrix(_currentMatrix);
            e.Surface.Canvas.Clear(SKColors.LemonChiffon);
            using (SKPaint p = new SKPaint {
                IsAntialias = true, StrokeWidth = 2, Typeface = SKTypeface.FromFamilyName("default"), TextSize = 70
            })
            {
                p.FilterQuality = _quality;
                foreach (var img in _images)
                {
#if USE_BITMAP
                    e.Surface.Canvas.DrawBitmap(img.Image, img.Destination, p);
#else
                    e.Surface.Canvas.DrawImage(img.Image, img.Destination, p);
#endif
                }
                var c  = _sw.Elapsed;
                var ts = c - _last;
                _last = c;

                var fps       = 1.0 / (ts.TotalSeconds);
                var fpsString = fps.ToString("00.00");
                _lastScale = e.Surface.Canvas.TotalMatrix.ScaleX;
                e.Surface.Canvas.ResetMatrix();
                p.FilterQuality = SKFilterQuality.High;
                //e.Surface.Canvas.DrawText("FPS: " + fpsString, 100, 100, p);
                FPSLabel.Text    = fpsString;
                ScaleLabel.Text  = _currentMatrix.ScaleX.ToString();
                UsageLabel.Text  = _resourceBytes.ToPrettySize(3) + " | " + _cacheResourcesBytes.ToPrettySize(2);
                NumberLabel.Text = _cacheResources.ToString() + " | " + _resources.ToString();

                //e.Surface.Canvas.DrawText("Resource Limits: \t" + nResources + " " + nResourceBytes.ToString("N"), 100, 190, p);
                //e.Surface.Canvas.DrawText("Resource Usages: \t" + nCacheResources + " " + nCacheResourcesBytes.ToString("N"), 100, 280, p);
            }
        }
 private void SKGLView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintGLSurfaceEventArgs e)
 {
     Draw?.Invoke(this, new DrawEventArgs(e.Surface, e.RenderTarget));
     isdrawing = false;
 }
示例#4
0
 private void SKGLView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintGLSurfaceEventArgs e)
 {
     e.Surface.Canvas.Clear(SkiaSharp.SKColors.White);
 }