Exemple #1
0
 /// <summary>
 /// Clears the Target
 /// </summary>
 protected abstract void ClearInternal(RenderTarget target, Clear flags, Color color, float depth, int stencil, RectInt viewport);
Exemple #2
0
        public void GetPixels(Memory <Color> dest, Point2 destPosition, Point2 destSize, RectInt sourceRect)
        {
            var src = new Span <Color>(Pixels);
            var dst = dest.Span;

            // can't be outside of the source image
            if (sourceRect.Left < 0)
            {
                sourceRect.Left = 0;
            }
            if (sourceRect.Top < 0)
            {
                sourceRect.Top = 0;
            }
            if (sourceRect.Right > Width)
            {
                sourceRect.Right = Width;
            }
            if (sourceRect.Bottom > Height)
            {
                sourceRect.Bottom = Height;
            }

            // can't be larger than our destination
            if (sourceRect.Width > destSize.X - destPosition.X)
            {
                sourceRect.Width = destSize.X - destPosition.X;
            }
            if (sourceRect.Height > destSize.Y - destPosition.Y)
            {
                sourceRect.Height = destSize.Y - destPosition.Y;
            }

            for (int y = 0; y < sourceRect.Height; y++)
            {
                var from = src.Slice(sourceRect.X + (sourceRect.Y + y) * Width, sourceRect.Width);
                var to   = dst.Slice(destPosition.X + (destPosition.Y + y) * destSize.X, sourceRect.Width);

                from.CopyTo(to);
            }
        }
Exemple #3
0
        /// <summary>
        /// Clears the Target
        /// </summary>
        public void Clear(RenderTarget target, Clear flags, Color color, float depth, int stencil, RectInt viewport)
        {
            if (!target.Renderable)
            {
                throw new Exception("Render Target cannot currently be drawn to");
            }

            var bounds  = new RectInt(0, 0, target.RenderWidth, target.RenderHeight);
            var clamped = viewport.OverlapRect(bounds);

            ClearInternal(target, flags, color, depth, stencil, clamped);
        }