Inheritance: IVertexSource
Exemplo n.º 1
0
 public override void Render(IVertexSource vertexSource, int pathIndexToRender, RGBA_Bytes colorBytes)
 {
     m_Rasterizer.reset();
     Affine transform = GetTransform();
     if (!transform.IsIdentity())
     {
         vertexSource = new conv_transform(vertexSource, transform);
     }
     m_Rasterizer.add_path(vertexSource, pathIndexToRender);
     Renderer.RenderSolid(m_DestImage, m_Rasterizer, m_ScanlineCache, colorBytes);
 }
Exemplo n.º 2
0
        void DrawImage(IImage sourceImage,
            double DestX, double DestY,
            double HotspotOffsetX, double HotspotOffsetY,
            double ScaleX, double ScaleY,
            double AngleRad,
            RGBA_Bytes Color32,
            ref RectangleD pFinalBlitBounds,
            bool doDrawing,
            bool oneMinusSourceAlphaOne)
        {
            Affine destRectTransform = Affine.NewIdentity();

            if (HotspotOffsetX != 0.0f || HotspotOffsetY != 0.0f)
            {
                destRectTransform *= Affine.NewTranslation(-HotspotOffsetX, -HotspotOffsetY);
            }

            if (ScaleX != 1 || ScaleY != 1)
            {
                destRectTransform *= Affine.NewScaling(ScaleX, ScaleY);
            }

            if (AngleRad != 0)
            {
                destRectTransform *= Affine.NewRotation(AngleRad);
            }

            if (DestX != 0 || DestY != 0)
            {
                destRectTransform *= Affine.NewTranslation(DestX, DestY);
            }

            int SourceBufferWidth = (int)sourceImage.Width();
            int SourceBufferHeight = (int)sourceImage.Height();

            RectPath.Clear();

            RectPath.MoveTo(0, 0);
            RectPath.LineTo(SourceBufferWidth, 0);
            RectPath.LineTo(SourceBufferWidth, SourceBufferHeight);
            RectPath.LineTo(0, SourceBufferHeight);
            RectPath.ClosePolygon();


            // Calculate the bounds. LBB [10/5/2004]
            const int ERROR_ADD = 0;
            double BoundXDouble, BoundYDouble;
            BoundXDouble = 0; BoundYDouble = 0;
            destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble);
            double BoundX = (double)BoundXDouble;
            double BoundY = (double)BoundYDouble;

            pFinalBlitBounds.Left = Math.Floor(BoundX - ERROR_ADD);
            pFinalBlitBounds.Right = Math.Ceiling(BoundX + ERROR_ADD);
            pFinalBlitBounds.Top = Math.Floor(BoundY - ERROR_ADD);
            pFinalBlitBounds.Bottom = Math.Ceiling(BoundY + ERROR_ADD);

            BoundXDouble = SourceBufferWidth; BoundYDouble = 0;
            destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble);
            BoundX = (double)BoundXDouble;
            BoundY = (double)BoundYDouble;
            pFinalBlitBounds.Left = Math.Min((long)Math.Floor(BoundX - ERROR_ADD), pFinalBlitBounds.Left);
            pFinalBlitBounds.Right = Math.Max((long)Math.Ceiling(BoundX + ERROR_ADD), pFinalBlitBounds.Right);
            pFinalBlitBounds.Top = Math.Min((long)Math.Floor(BoundY - ERROR_ADD), pFinalBlitBounds.Top);
            pFinalBlitBounds.Bottom = Math.Max((long)Math.Ceiling(BoundY + ERROR_ADD), pFinalBlitBounds.Bottom);

            BoundXDouble = SourceBufferWidth; BoundYDouble = SourceBufferHeight;
            destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble);
            BoundX = (double)BoundXDouble;
            BoundY = (double)BoundYDouble;
            pFinalBlitBounds.Left = Math.Min((long)Math.Floor(BoundX - ERROR_ADD), pFinalBlitBounds.Left);
            pFinalBlitBounds.Right = Math.Max((long)Math.Ceiling(BoundX + ERROR_ADD), pFinalBlitBounds.Right);
            pFinalBlitBounds.Top = Math.Min((long)Math.Floor(BoundY - ERROR_ADD), pFinalBlitBounds.Top);
            pFinalBlitBounds.Bottom = Math.Max((long)Math.Ceiling(BoundY + ERROR_ADD), pFinalBlitBounds.Bottom);

            BoundXDouble = 0; BoundYDouble = SourceBufferHeight;
            destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble);
            BoundX = (double)BoundXDouble;
            BoundY = (double)BoundYDouble;
            pFinalBlitBounds.Left = Math.Min((long)Math.Floor(BoundX - ERROR_ADD), pFinalBlitBounds.Left);
            pFinalBlitBounds.Right = Math.Max((long)Math.Ceiling(BoundX + ERROR_ADD), pFinalBlitBounds.Right);
            pFinalBlitBounds.Top = Math.Min((long)Math.Floor(BoundY - ERROR_ADD), pFinalBlitBounds.Top);
            pFinalBlitBounds.Bottom = Math.Max((long)Math.Ceiling(BoundY + ERROR_ADD), pFinalBlitBounds.Bottom);

            if (!doDrawing)
            {
                return;
            }

            if (m_DestImage.OriginOffset.x != 0 || m_DestImage.OriginOffset.y != 0)
            {
                destRectTransform *= Affine.NewTranslation(-m_DestImage.OriginOffset.x, -m_DestImage.OriginOffset.y);
            }

            Affine sourceRectTransform = new Affine(destRectTransform);
            // We invert it because it is the transform to make the image go to the same position as the polygon. LBB [2/24/2004]
            sourceRectTransform.Invert();

            span_allocator spanAllocator = new span_allocator();

            span_interpolator_linear interpolator = new span_interpolator_linear(sourceRectTransform);

            ImageBuffer sourceImageWithBlender = (ImageBuffer)sourceImage;// new ImageBuffer(sourceImage, new BlenderBGRA());

            span_image_filter_rgba_bilinear_clip spanImageFilter;
            ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImageWithBlender, RGBA_Doubles.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes());
            spanImageFilter = new span_image_filter_rgba_bilinear_clip(source, RGBA_Doubles.rgba_pre(0, 0, 0, 0), interpolator);

            rasterizer_scanline_aa rasterizer = new rasterizer_scanline_aa();
            rasterizer.SetVectorClipBox(0, 0, m_DestImage.Width(), m_DestImage.Height());
            scanline_packed_8 scanlineCache = new scanline_packed_8();
            //scanline_unpacked_8 scanlineCache = new scanline_unpacked_8();

            conv_transform transfromedRect = new conv_transform(RectPath, destRectTransform);
            rasterizer.add_path(transfromedRect);
#if false
	        bool HighQualityFilter = (BlitXParams.m_OptionalFlags & CBlitXParams::BlitHighQualityFilter) != 0
		        && (BlitXParams.m_OptionalFlags & CBlitXParams::RenderOneMinusScrAlpha_One) == 0;
	        if (HighQualityFilter)
	        {