private void RenderDropShadow(IRenderFrame frame) { char shadowChar; switch (BorderStyle) { case BorderStyle.DropShadowLight: shadowChar = '░'; break; case BorderStyle.DropShadowMedium: shadowChar = '▒'; break; case BorderStyle.DropShadowStrong: shadowChar = '▓'; break; default: throw new NotImplementedException($"BoarderStyle {BorderStyle} is not a shadow."); } frame[frame.Width - 1, 0] = new ColoredKey(' ', Foreground, Background); frame[0, frame.Height - 1] = new ColoredKey(' ', Foreground, Background); for (int y = 1; y < frame.Height - 1; y++) { frame[frame.Width - 1, y] = new ColoredKey(shadowChar, Foreground, Background); } for (int x = 1; x < frame.Width; x++) { frame[x, frame.Height - 1] = new ColoredKey(shadowChar, Foreground, Background); } }
void IRenderOwner.render(IRenderFrame destination, long time, Rectangle r) { // var state = this.Renderer.StartRender(destination, r); var c = (test++ % 25) / 25f; var cc = new Xwt.Drawing.Color(c, c, c, 255); GL.ClearColor((float)cc.Red, (float)cc.Green, (float)cc.Blue, (float)cc.Alpha); GL.Clear(ClearBufferMask.ColorBufferBit /*ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/); // We're not using stencil buffer so why bother with clearing? this.verticestex.Apply(this.shadertex); if (frame != null) { GL.BindTexture(TextureTarget.Texture2D, (frame.Buffer as IOpenGLFrame).Textures[0]); // this.vertices.Apply(this.shader); GL.DrawArrays(BeginMode.Triangles, 0, 6); // Starting from vertex 0; 3 vertices total -> 2 triangle GL.DisableVertexAttribArray(0); frame.Dispose(); frame = null; } // this.Renderer.EndRender(state); this.Renderer.Present(destination, r, IntPtr.Zero); }
private void RenderBorder(IRenderFrame frame) { RectPen borderPen; switch (BorderStyle) { case BorderStyle.None: return; case BorderStyle.DropShadowLight: case BorderStyle.DropShadowMedium: case BorderStyle.DropShadowStrong: RenderDropShadow(frame); return; case BorderStyle.SingelLined: borderPen = Pen.SingelLine; break; case BorderStyle.DoubleLined: borderPen = Pen.DoubleLine; break; case BorderStyle.Block: borderPen = Pen.BlockLine; break; default: throw new NotImplementedException($"BoarderStyle {BorderStyle} not implemented."); } frame.DrawRect(0, 0, frame.Width, frame.Height, IsDisabled ?ForegroundDisabled: Foreground, IsDisabled ?BackgroundDisabled: Background, borderPen); }
public void Render(IRenderFrame frame) { try { RenderInProgress = true; RootWindow.RequestDraw(); this.lastFrame = frame; if (frame != null && frame.Clip != Rect.Empty) { RootWindow.UnRegisterRenderDirty(this); RenderCore(frame); } else { var queue = new Queue <UIElement>(); queue.Enqueue(this); while (queue.Count > 0) { var e = queue.Dequeue(); RootWindow.UnRegisterRenderDirty(e); foreach (var child in e.VisualChildrean) { queue.Enqueue(child); } } } } finally { RenderInProgress = false; } Rendered(); }
public static void DrawRect(this IRenderFrame buffer, int xPos, int yPos, int width, int height, ConsoleColor forground, ConsoleColor background, RectPen p) { // Draw corners buffer[xPos, 0] = new ColoredKey(p.topLeft, forground, background); buffer[xPos, yPos + height - 1] = new ColoredKey(p.bottomLeft, forground, background); buffer[xPos + width - 1, yPos] = new ColoredKey(p.topRight, forground, background); buffer[xPos + width - 1, yPos + height - 1] = new ColoredKey(p.bottemRight, forground, background); //Draw top Line for (int x = xPos + 1; x < xPos + width - 1; x++) { buffer[x, yPos] = new ColoredKey(p.top, forground, background); } //Draw bottom Line for (int x = xPos + 1; x < xPos + width - 1; x++) { buffer[x, yPos + height - 1] = new ColoredKey(p.bottom, forground, background); } //Draw left Line for (int y = yPos + 1; y < yPos + height - 1; y++) { buffer[xPos, y] = new ColoredKey(p.left, forground, background); } //Draw right Line for (int y = yPos + 1; y < yPos + height - 1; y++) { buffer[xPos + width - 1, y] = new ColoredKey(p.right, forground, background); } }
public override void Render(IRenderFrame frame, long videotime) { var c = (test++ % 25) / 25f; var cc = new Xwt.Drawing.Color(c, c, c, 255); // render var state = this.Display.Renderer.StartRender(frame, new rectangle(0, 0, frame.Width, frame.Height)); GL.ClearColor((float)cc.Red, (float)cc.Green, (float)cc.Blue, (float)cc.Alpha); GL.Clear(ClearBufferMask.ColorBufferBit /*ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/); // We're not using stencil buffer so why bother with clearing? GL.Disable(EnableCap.DepthTest); // GL.Disable(EnableCap.Lighting); // ES30.GL.Enable(OpenTK.Graphics.ES30.EnableCap.DepthTest); // ES30.GL.Enable(ES30.EnableCap.Blend); // ES30.GL.BlendFunc(ES30.BlendingFactorSrc.SrcAlpha, ES30.BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.StencilTest); /* GL.UseProgram(shaderProgram); * GL.BindBuffer(BufferTarget.ArrayBuffer, buf_vertices); * * GL.DrawArrays(PrimitiveType.Triangles, 0, 3);*/ this.vertices.Apply(this.shader); GL.DrawArrays(BeginMode.Triangles, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle GL.DisableVertexAttribArray(0); // return destination; this.Display.Renderer.EndRender(state); }
object IRenderer.StartRender(IRenderFrame destination, rectangle r) { var oldframebuffer = (uint)GL.GetInteger(GetPName.FramebufferBinding); try { if (destination == null) { GL.Viewport(r.x, r.y, r.width, r.height);// new Rectangle(this.window.Location,this.window.ClientSize)); } else { var frame = (RenderFrame)destination; GL.BindFramebuffer(FramebufferTarget.Framebuffer, frame.framebuffer); GL.Viewport(0, 0, frame.Width, frame.Height);// new Rectangle(this.window.Location,this.window.ClientSize)); } } catch (Exception e) { // Log.LogException(e); } return(oldframebuffer);// destination; }
void IRenderOwner.render(IRenderFrame destination, long time, rectangle r) { // using (var lck = this.Renderer.GetDrawLock()) { // var state = this.Renderer.StartRender(destination, r); // GL.MatrixMode(MatrixMode.Projection); // GL.LoadIdentity(); // this.xwt.StartRender(renderer, this); var c = (test++ % 25) / 25f; var cc = new Xwt.Drawing.Color(c, c, c, 255); GL.ClearColor((float)cc.Red, (float)cc.Green, (float)cc.Blue, (float)cc.Alpha); GL.Clear(ClearBufferMask.ColorBufferBit /*ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/); // We're not using stencil buffer so why bother with clearing? this.vertices.Apply(this.shader); GL.DrawArrays(BeginMode.Triangles, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle GL.DisableVertexAttribArray(0); // this.Renderer.EndRender(state); this.Renderer.Present(destination, r, IntPtr.Zero); } }
internal void Deinterlace(IVideoFrame frame, IRenderFrame destination, DeinterlaceModes mode) { try { using (var ll = this.GetDrawLock()) { // Lock(); GL.BindFramebuffer(FramebufferTarget.Framebuffer, (destination as RenderFrame).framebuffer); var err = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer); GL.Viewport(0, 0, destination.Width, destination.Height);// new Rectangle(this.window.Location,this.window.ClientSize)); GL.ClearColor(1, 1, 0, 1); GL.Clear(ClearBufferMask.ColorBufferBit /*| ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/); // We're not using stencil buffer so why bother with clearing? GL.Disable(EnableCap.DepthTest); GL.Disable(EnableCap.StencilTest); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, (frame as IOpenGLFrame).Textures[0]); shader pp; switch (mode) { default: throw new NotImplementedException(); case DeinterlaceModes.Blend: pp = deinterlaceblendshader; break; case DeinterlaceModes.Split: pp = deinterlacesplitshader; break; } pp.Bind(vertices2); var locvpheight = GL.GetUniformLocation(pp, "vpHeight"); GL.Uniform1(locvpheight, destination.Height); GL.DrawArrays(PrimitiveType.Quads, 0, 4); GL.DisableVertexAttribArray(0); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, 0); GL.UseProgram(0); // vertices3.Bind(); GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); } } catch (Exception e) { // Log.LogException(e); } }
protected override void RenderOverride(IRenderFrame frame) { if (Content != null) { var horizontalScrollPosition = MathEx.Clamp(0, HorizontalScrollMaximum, HorizontalScrollPosition); var verticalScrollPosition = MathEx.Clamp(0, VerticalScrollMaximum, VerticalScrollPosition); Content.Render(frame.GetGraphicsBuffer(new Rect(-horizontalScrollPosition, -verticalScrollPosition, Content.ArrangedPosition.Width, Content.ArrangedPosition.Height), new Rect(0, 0, frame.Width, frame.Height))); } }
protected sealed override void RenderOverride(IRenderFrame frame) { if (DisplayContent == null) { DisplayContent = GetControlTemplatedInstance(); } DisplayContent.Render(frame); }
public static void FillRect(this IRenderFrame buffer, int xPos, int yPos, int width, int height, ConsoleColor forground, ConsoleColor background, char c) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { buffer[x + xPos, y + yPos] = new ColoredKey((char)c, forground, background); } } }
protected override void RenderOverride(IRenderFrame frame) { if (Panel != null) { Panel.Render(frame); } else { base.RenderOverride(frame); } }
internal void Deinterlace(IVideoFrame frame, IRenderFrame destination, DeinterlaceModes mode) { if (this.device != null) { switch (mode) { default: throw new NotImplementedException(); case DeinterlaceModes.Blend: case DeinterlaceModes.Split: { var state = this.StartRender(destination, rectangle.Zero); try { /* var dstrec = new System.Drawing.Rectangle(0, 0, destination.Width, destination.Height); * var effect = this.effect2; * var m = Matrix.Scaling(dstrec.Width, dstrec.Height, 1) * Matrix.Translation(dstrec.Left, dstrec.Top, 0); * var worldViewProj = m * this.CreateViewMatrix(destination.Width, destination.Height); * int n; * switch (mode) * { * case DeinterlaceModes.Blend: * { * effect.SetValue("worldViewProj", worldViewProj); * effect.SetTexture("texture0", (frame as IDirectXFrame).Textures[0]); * effect.SetValue("vpHeight", frame.Height); * n = 1; * } * break; * case DeinterlaceModes.Split: * { * effect.SetValue("worldViewProj", worldViewProj); * effect.SetTexture("texture0", (frame as IDirectXFrame).Textures[0]); * effect.SetValue("vpHeight", frame.Height); * n = 0; * } * break; * default: * throw new NotImplementedException(); * } * this.Paint( * new System.Drawing.Rectangle(0, 0, destination.Width, destination.Height), * effect, n);*/ } finally { this.EndRender(state); } } break; } } }
protected override void RenderOverride(IRenderFrame frame) { var clip = frame.Clip; for (int y = (int)clip.Top; y < clip.Bottom; y++) { for (int x = (int)clip.Left; x < clip.Right; x++) { frame[x, y] = new ColoredKey(y < this.renderLines.Length && x < this.renderLines[y].Length ? this.renderLines[y][x] : ' ', Foreground, Background); } } }
protected override void RenderOverride(IRenderFrame frame) { frame.FillRect(0, 0, frame.Width, frame.Height, Foreground, Background, (char)SpecialChars.Fill); for (int i = 0; i < Children.Count; i++) { var location = GetLocation(Children[i]); Children[i].Render(frame.GetGraphicsBuffer(location)); } base.RenderOverride(frame); }
protected override void RenderOverride(IRenderFrame frame) { RenderBorder(frame); if (Child != null) { var borderThikness = BorderThikness; var borderWith = borderThikness.Left + borderThikness.Right; var borderHeight = borderThikness.Top + borderThikness.Bottom; Child.Render(frame.GetGraphicsBuffer(new Rect(borderThikness.Left, borderThikness.Top, frame.Width - borderWith, frame.Height - borderHeight), frame.Clip)); } else { var borderThikness = BorderThikness; var borderWith = borderThikness.Left + borderThikness.Right; var borderHeight = borderThikness.Top + borderThikness.Bottom; frame.FillRect(borderThikness.Left, borderThikness.Top, frame.Width - borderWith, frame.Height - borderHeight, IsDisabled ? ForegroundDisabled : Foreground, IsDisabled ? BackgroundDisabled : Background, (char)SpecialChars.Fill); } }
protected override void RenderOverride(IRenderFrame frame) { switch (Orientation) { case Orientation.Vertical: RenderVertical(frame); break; case Orientation.Horizontal: break; default: throw new NotSupportedException($"The value {Orientation} is not expected in {typeof(Orientation).FullName}"); } }
protected override sealed void RenderCore(IRenderFrame frame) { frame.FillRect(0, 0, Padding.Left, Padding.Top, Foreground, Background, (char)SpecialChars.Fill); frame.FillRect(frame.Width - Padding.Right - Padding.Left, 0, Padding.Right, Padding.Top, Foreground, Background, (char)SpecialChars.Fill); frame.FillRect(0, frame.Height - Padding.Top - Padding.Bottom, Padding.Left, Padding.Bottom, Foreground, Background, (char)SpecialChars.Fill); frame.FillRect(frame.Width - Padding.Right - Padding.Left, frame.Height - Padding.Top - Padding.Bottom, Padding.Right, Padding.Bottom, Foreground, Background, (char)SpecialChars.Fill); frame.FillRect(Padding.Left, 0, frame.Width - Padding.Left - Padding.Right, Padding.Top, Foreground, Background, (char)SpecialChars.Fill); frame.FillRect(0, Padding.Top, Padding.Left, frame.Height - Padding.Top - Padding.Bottom, Foreground, Background, (char)SpecialChars.Fill); frame.FillRect(Padding.Left, frame.Height - Padding.Bottom, frame.Width - Padding.Left - Padding.Right, Padding.Bottom, Foreground, Background, (char)SpecialChars.Fill); frame.FillRect(frame.Width - Padding.Right, Padding.Top, Padding.Right, frame.Height - Padding.Bottom - Padding.Top, Foreground, Background, (char)SpecialChars.Fill); if (Padding.Left + Padding.Right >= frame.Width || Padding.Top + Padding.Bottom >= frame.Height) { return; // Not enough Place to draw content. } RenderOverride(frame.GetGraphicsBuffer(new Rect(Padding.Left, Padding.Top, frame.Width - Padding.Right - Padding.Left, frame.Height - Padding.Bottom - Padding.Top))); }
public object StartRender(IRenderFrame destination, rectangle r) { // Monitor.Enter(this); if (destination == null) // render direct { if (this.renderframe == null || this.renderframe.Width != this.videosize.width || this.renderframe.Height != this.videosize.height) { this.renderframe?.Dispose(); this.renderframe = this.opentk.GetRenderFrame(1); this.renderframe.Set(this.opentk.AlphaFormat); this.renderframe.Set(0, this.videosize.width, this.videosize.height, 0); } this.gllock = this.opentk.GetDrawLock(); return(new object[] { this.opentk.StartRender(this.renderframe, new rectangle(point.Zero, this.videosize)) }); } else { return(this.opentk.StartRender(destination, r)); } /* RenderFrame frame = destination as RenderFrame; * * var oldtargets = new Surface[destination.Levels]; * * for (int nit = 0; nit < 1; nit++) * { * try * { * oldtargets[nit] = this.device.GetRenderTarget(nit); * } * catch { } * } * for (int nit = 0; nit < destination.Levels; nit++) * { * this.device.SetRenderTarget(nit, (destination as RenderFrame).rendertarget[nit]); * } * this.device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, new global::SharpDX.Mathematics.Interop.RawColorBGRA((byte)(color.Red * 255), (byte)(color.Green * 255), (byte)(color.Blue * 255), (byte)(color.Alpha * 255)), 0, 0); * * this.device.BeginScene(); * * return oldtargets;*/ }
protected override void RenderOverride(IRenderFrame frame) { for (int i = 0; i < Children.Count; i++) { var location = GetLocation(Children[i]); if (!location.IntersectsWith(frame.Clip)) { Children[i].Render(null); continue; } Children[i].Render(frame.GetGraphicsBuffer(location)); if (location.Left > 0) { frame.FillRect(0, (int)location.Top, (int)location.Left, (int)location.Height, Foreground, Background, (char)SpecialChars.Fill); } if (frame.Width - location.Right > 0) { frame.FillRect((int)location.Right, (int)location.Top, (int)(frame.Width - location.Right), (int)location.Height, Foreground, Background, (char)SpecialChars.Fill); } } }
public BufferWraper(IRenderFrame parent, Rect?translation = default, Rect?clip = default) { this.parent = parent; this.translation = translation ?? new Rect(0, 0, parent.Width, parent.Height); Clip = clip ?? parent.Clip.Translate(new Size(-this.translation.Location.X, -this.translation.Location.Y)); Clip = new Rect( x: MathEx.Clamp(0, this.translation.Width, Clip.X), y: MathEx.Clamp(0, this.translation.Height, Clip.Y), width: MathEx.Clamp(0, this.translation.Width - MathEx.Clamp(0, this.translation.Width, Clip.X), Clip.Width), height: MathEx.Clamp(0, this.translation.Height - MathEx.Clamp(0, this.translation.Height, Clip.Y), Clip.Height)); if (Clip.Width == 0 || Clip.Height == 0) { Clip = Rect.Empty; } var test = clip?.Translate((Size)this.translation.Location) ?? this.translation; if (test.Right > parent.Width || test.Bottom > parent.Height || test.Left < 0 || test.Top < 0) { throw new ArgumentOutOfRangeException(nameof(translation), $"Translation must be insied the width and height of the parent. Width={parent.Width},Height={parent.Height}. Translation={this.translation}"); } }
public virtual void render(IRenderFrame destination, long time, rectangle r) { this.impl.Render(destination, time, r, this.renderdata); this.Renderer.Present(destination, r, IntPtr.Zero); }
public virtual bool preparerender(IRenderFrame destination, long time, bool dowait) { return(this.impl.StartRender(time, dowait, out this.renderdata)); }
protected virtual void RenderCore(IRenderFrame frame) { }
bool IRenderOwner.preparerender(IRenderFrame destination, long time, bool dowait) { return(true); }
protected virtual void RenderOverride(IRenderFrame frame) { }
public void Deinterlace(IRenderFrame deinterlace, DeinterlaceModes mode) { owner.Deinterlace(this, deinterlace, mode); }
bool IRenderOwner.preparerender(IRenderFrame destination, long time, bool dowait) { this.frame = this.MoviePlayer?.GetFrame(time, 0); return(frame != null); }
protected override void RenderOverride(IRenderFrame frame) => DisplayContent?.Render(frame);