public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); if (fsurface == null) { return; } var size = ConvertSizeToBacking(Bounds.Size); renderTarget.Width = (int)size.Width; renderTarget.Height = (int)size.Height; Gles.glClear(Gles.GL_STENCIL_BUFFER_BIT); using (var surface = SKSurface.Create(context, renderTarget)) { fsurface.UpdateSurface(surface); // draw on the surface DrawInSurface(surface, renderTarget); surface.Canvas.Flush(); } // flush the SkiaSharp contents to GL context.Flush(); OpenGLContext.FlushBuffer(); }
public virtual void SwapBuffers() { AssertValid(); AssertContext(); // basically SwapBuffers is the same as FlushBuffer on OSX OpenGLContext.FlushBuffer(); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); var size = ConvertSizeToBacking(Bounds.Size); renderTarget.Width = (int)size.Width; renderTarget.Height = (int)size.Height; Gles.glClear(Gles.GL_STENCIL_BUFFER_BIT); using (var surface = SKSurface.Create(context, renderTarget)) { if (PaintSurface != null) { PaintSurface.Invoke(surface); } surface.Canvas.Flush(); } // flush the SkiaSharp contents to GL context.Flush(); OpenGLContext.FlushBuffer(); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); Gles.glClear(Gles.GL_COLOR_BUFFER_BIT | Gles.GL_DEPTH_BUFFER_BIT | Gles.GL_STENCIL_BUFFER_BIT); // create the render target if (renderTarget == null || lastSize != newSize || !renderTarget.IsValid) { // create or update the dimensions lastSize = newSize; // read the info from the buffer Gles.glGetIntegerv(Gles.GL_FRAMEBUFFER_BINDING, out var framebuffer); Gles.glGetIntegerv(Gles.GL_STENCIL_BITS, out var stencil); Gles.glGetIntegerv(Gles.GL_SAMPLES, out var samples); var maxSamples = context.GetMaxSurfaceSampleCount(colorType); if (samples > maxSamples) { samples = maxSamples; } glInfo = new GRGlFramebufferInfo((uint)framebuffer, colorType.ToGlSizedFormat()); // destroy the old surface surface?.Dispose(); surface = null; canvas = null; // re-create the render target renderTarget?.Dispose(); renderTarget = new GRBackendRenderTarget(newSize.Width, newSize.Height, samples, stencil, glInfo); } // create the surface if (surface == null) { surface = SKSurface.Create(context, renderTarget, surfaceOrigin, colorType); canvas = surface.Canvas; } using (new SKAutoCanvasRestore(canvas, true)) { // start drawing var e = new SKPaintGLSurfaceEventArgs(surface, renderTarget, surfaceOrigin, colorType, glInfo); #pragma warning disable CS0618 // Type or member is obsolete DrawInSurface(e.Surface, e.RenderTarget); #pragma warning restore CS0618 // Type or member is obsolete OnPaintSurface(e); } // flush the SkiaSharp contents to GL canvas.Flush(); context.Flush(); OpenGLContext.FlushBuffer(); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); Gles.glClear(Gles.GL_COLOR_BUFFER_BIT | Gles.GL_DEPTH_BUFFER_BIT | Gles.GL_STENCIL_BUFFER_BIT); // manage the drawing surface var size = ConvertSizeToBacking(Bounds.Size); if (renderTarget == null || surface == null || renderTarget.Width != size.Width || renderTarget.Height != size.Height) { // create or update the dimensions renderTarget?.Dispose(); Gles.glGetIntegerv(Gles.GL_FRAMEBUFFER_BINDING, out var framebuffer); Gles.glGetIntegerv(Gles.GL_STENCIL_BITS, out var stencil); Gles.glGetIntegerv(Gles.GL_SAMPLES, out var samples); var maxSamples = context.GetMaxSurfaceSampleCount(colorType); if (samples > maxSamples) { samples = maxSamples; } var glInfo = new GRGlFramebufferInfo((uint)framebuffer, colorType.ToGlSizedFormat()); renderTarget = new GRBackendRenderTarget((int)size.Width, (int)size.Height, samples, stencil, glInfo); // create the surface surface?.Dispose(); surface = SKSurface.Create(context, renderTarget, surfaceOrigin, colorType); } using (new SKAutoCanvasRestore(surface.Canvas, true)) { // start drawing var e = new SKPaintGLSurfaceEventArgs(surface, renderTarget, surfaceOrigin, colorType); #pragma warning disable CS0618 // Type or member is obsolete DrawInSurface(e.Surface, e.RenderTarget); #pragma warning restore CS0618 // Type or member is obsolete OnPaintSurface(e); } // flush the SkiaSharp contents to GL surface.Canvas.Flush(); context.Flush(); OpenGLContext.FlushBuffer(); }
public override void DrawRect(CGRect dirtyRect) { base.DrawRect(dirtyRect); Gles.glClear(Gles.GL_COLOR_BUFFER_BIT | Gles.GL_DEPTH_BUFFER_BIT | Gles.GL_STENCIL_BUFFER_BIT); // manage the drawing surface var size = ConvertSizeToBacking(Bounds.Size); if (renderTarget == null || surface == null || renderTarget.Width != size.Width || renderTarget.Height != size.Height) { // create or update the dimensions renderTarget?.Dispose(); renderTarget = SKGLDrawable.CreateRenderTarget((int)size.Width, (int)size.Height); // create the surface surface?.Dispose(); surface = SKSurface.Create(context, renderTarget, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888); } using (new SKAutoCanvasRestore(surface.Canvas, true)) { // start drawing var e = new SKPaintGLSurfaceEventArgs(surface, renderTarget, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888); #pragma warning disable CS0618 // Type or member is obsolete DrawInSurface(e.Surface, e.RenderTarget); #pragma warning restore CS0618 // Type or member is obsolete OnPaintSurface(e); } // flush the SkiaSharp contents to GL surface.Canvas.Flush(); context.Flush(); OpenGLContext.FlushBuffer(); }