Exemplo n.º 1
0
 /// <inheritdoc/>
 protected internal override void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
 {
     if (Shader.IsValid && Shader.IsLoaded)
     {
         DrawRenderTargetAtVisualBounds(dc, element, target, Shader);
     }
 }
Exemplo n.º 2
0
 /// <inheritdoc/>
 protected internal override void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
 {
     if (Shader.IsValid && Shader.IsLoaded)
     {
         DrawRenderTargetAtVisualBounds(dc, element, target, Shader);
     }
 }
Exemplo n.º 3
0
        /// <inheritdoc/>
        protected internal override void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var state = dc.GetCurrentState();

            var position        = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);

            dc.End();

            dc.Begin(SpriteSortMode.Immediate, null, Matrix.Identity);
            dc.Draw(target.Next.Next.ColorBuffer, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            dc.End();

            dc.Begin(state);
        }
Exemplo n.º 4
0
        /// <inheritdoc/>
        protected internal override void DrawRenderTargets(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var blurTarget = target.Next.RenderTarget;

            var gfx = dc.Ultraviolet.GetGraphics();
            gfx.SetRenderTarget(blurTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius = GetRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Horizontal;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, Color.White);
            dc.End();
        }
Exemplo n.º 5
0
        /// <inheritdoc/>
        protected internal override void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var state = dc.GetCurrentState();
            
            var position = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);

            dc.End();

            effect.Value.Radius = GetRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Vertical;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);

            var shadowTexture = target.Next.ColorBuffer;
            dc.Draw(shadowTexture, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            
            dc.End();
            dc.Begin(state);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Draws the specified render target at its desired visual bounds.
        /// </summary>
        /// <param name="dc">The current drawing context.</param>
        /// <param name="element">The element being drawn.</param>
        /// <param name="target">The render target that contains the element's graphics.</param>
        /// <param name="effect">The shader effect to apply to the render target, if any.</param>
        public static void DrawRenderTargetAtVisualBounds(DrawingContext dc, UIElement element, OutOfBandRenderTarget target, GraphicsEffect effect = null)
        {
            Contract.Require(dc, "dc");
            Contract.Require(element, "element");
            Contract.Require(target, "rtarget");

            if (element.View == null)
                return;

            var state = dc.GetCurrentState();

            dc.End();
            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);

            var position = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);
            dc.Draw(target.ColorBuffer, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);

            dc.End();
            dc.Begin(state);
        }
Exemplo n.º 7
0
        /// <inheritdoc/>
        protected internal override void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var state = dc.GetCurrentState();

            var position        = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);

            dc.End();

            effect.Value.Radius    = GetRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Vertical;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);

            var shadowTexture = target.Next.ColorBuffer;

            dc.RawDraw(shadowTexture, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);

            dc.End();
            dc.Begin(state);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Draws the specified element using an out-of-band render target.
        /// </summary>
        /// <param name="dc">The current drawing context.</param>
        /// <param name="element">The element being drawn.</param>
        /// <param name="target">The render target that contains the element's graphics.</param>
        protected internal virtual void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {

        }
Exemplo n.º 9
0
        /// <inheritdoc/>
        protected internal override void DrawRenderTargets(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var gfx = dc.Ultraviolet.GetGraphics();

            // Calculate the shadow's offset from the element
            var cumulativeTransform = target.VisualTransform;

            var shadowVectorStart = new Vector2(0, 0);

            Vector2.Transform(ref shadowVectorStart, ref cumulativeTransform, out shadowVectorStart);

            var shadowVectorEnd = Vector2.Transform(new Vector2(1, 0), Matrix.CreateRotationZ(Radians.FromDegrees(-Direction)));

            Vector2.Transform(ref shadowVectorEnd, ref cumulativeTransform, out shadowVectorEnd);

            var shadowDepth  = (Int32)element.View.Display.DipsToPixels(ShadowDepth);
            var shadowVector = Vector2.Normalize(shadowVectorEnd - shadowVectorStart) * shadowDepth;

            // Draw the horizontal blur pass
            var pass1Target = target.Next;

            gfx.SetRenderTarget(pass1Target.RenderTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius    = GetBlurRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Horizontal;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, Color);
            dc.End();

            // Draw the vertical blur pass
            var pass2Target = target.Next.Next;

            gfx.SetRenderTarget(pass2Target.RenderTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius    = GetBlurRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Vertical;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(pass1Target.ColorBuffer, shadowVector, null, Color, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            dc.End();

            // Draw the element on top of the shadow
            dc.Begin(SpriteSortMode.Immediate, null, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            dc.End();
        }
Exemplo n.º 10
0
        /// <inheritdoc/>
        protected internal override void DrawRenderTargets(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var blurTarget = target.Next.RenderTarget;

            var gfx = dc.Ultraviolet.GetGraphics();

            gfx.SetRenderTarget(blurTarget, Color.Transparent);

            effect.Value.Radius    = GetRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Horizontal;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.RawDraw(target.ColorBuffer, Vector2.Zero, Color.White);
            dc.End();
        }
Exemplo n.º 11
0
        /// <inheritdoc/>
        protected internal override void DrawRenderTargets(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
        {
            var gfx = dc.Ultraviolet.GetGraphics();
            
            // Calculate the shadow's offset from the element
            var cumulativeTransform = target.VisualTransform;

            var shadowVectorStart = new Vector2(0, 0);
            Vector2.Transform(ref shadowVectorStart, ref cumulativeTransform, out shadowVectorStart);

            var shadowVectorEnd = Vector2.Transform(new Vector2(1, 0), Matrix.CreateRotationZ(Radians.FromDegrees(-Direction)));
            Vector2.Transform(ref shadowVectorEnd, ref cumulativeTransform, out shadowVectorEnd);

            var shadowDepth = (Int32)element.View.Display.DipsToPixels(ShadowDepth);
            var shadowVector = Vector2.Normalize(shadowVectorEnd - shadowVectorStart) * shadowDepth;

            // Draw the horizontal blur pass
            var pass1Target = target.Next;
            gfx.SetRenderTarget(pass1Target.RenderTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius = GetBlurRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Horizontal;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, Color);
            dc.End();

            // Draw the vertical blur pass
            var pass2Target = target.Next.Next;
            gfx.SetRenderTarget(pass2Target.RenderTarget);
            gfx.Clear(Color.Transparent);

            effect.Value.Radius = GetBlurRadiusInPixels(element);
            effect.Value.Direction = BlurDirection.Vertical;

            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
            dc.Draw(pass1Target.ColorBuffer, shadowVector, null, Color, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            dc.End();

            // Draw the element on top of the shadow
            dc.Begin(SpriteSortMode.Immediate, null, Matrix.Identity);
            dc.Draw(target.ColorBuffer, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            dc.End();
        }
Exemplo n.º 12
0
 /// <summary>
 /// Draws the specified element using an out-of-band render target.
 /// </summary>
 /// <param name="dc">The current drawing context.</param>
 /// <param name="element">The element being drawn.</param>
 /// <param name="target">The render target that contains the element's graphics.</param>
 protected internal virtual void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
 {
 }
Exemplo n.º 13
0
        /// <summary>
        /// Draws the specified render target at its desired visual bounds.
        /// </summary>
        /// <param name="dc">The current drawing context.</param>
        /// <param name="element">The element being drawn.</param>
        /// <param name="target">The render target that contains the element's graphics.</param>
        /// <param name="effect">The shader effect to apply to the render target, if any.</param>
        public static void DrawRenderTargetAtVisualBounds(DrawingContext dc, UIElement element, OutOfBandRenderTarget target, GraphicsEffect effect = null)
        {
            Contract.Require(dc, nameof(dc));
            Contract.Require(element, nameof(element));
            Contract.Require(target, nameof(target));

            if (element.View == null)
            {
                return;
            }

            var state = dc.GetCurrentState();

            dc.End();
            dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);

            var position        = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
            var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);

            dc.RawDraw(target.ColorBuffer, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);

            dc.End();
            dc.Begin(state);
        }