Exemple #1
0
        public void PushLayer(GDILayerParameters layerParameters, GDILayer layer)
        {
            layerStack.AddFirst(layer);
            paramStack.AddFirst(layerParameters);

            float w = (float)Math.Round(layerParameters.ContentBounds.Width);
            float h = (float)Math.Round(layerParameters.ContentBounds.Height);

            Bitmap bitmap = new Bitmap((int)w, (int)h);

            gdiGraph = layer.CreateGraphics(bitmap);
        }
Exemple #2
0
        public GDILayer PushLayer(GDIGraphics g, ScDrawNode node)
        {
            ScLayer  sclayer  = node.layer;
            GDILayer gdiLayer = new GDILayer(g);

            GDILayerParameters layerParameters = new GDILayerParameters();

            layerParameters.ContentBounds     = sclayer.DrawBox;
            layerParameters.MaskAntialiasMode = GDIAntialiasMode.PerPrimitive;
            layerParameters.Opacity           = sclayer.Opacity;

            layerParameters.ClipRect = new RectangleF(
                (int)(node.clipRect.X - sclayer.DrawBox.X - 1), (int)(node.clipRect.Y - sclayer.DrawBox.Y - 1),
                (int)(node.clipRect.Width + 2), (int)(node.clipRect.Height + 2));


            Matrix m = new Matrix();

            m.Translate(-sclayer.DrawBox.X, -sclayer.DrawBox.Y);
            m.Multiply(sclayer.GlobalMatrix);
            node.m         = m;
            node.rootLayer = node.layer;

            if (!sclayer.Parent.IsComputedStraight)
            {
                m = new Matrix();
                m.Translate(-sclayer.Parent.DrawBox.X, -sclayer.Parent.DrawBox.Y);
                m.Multiply(sclayer.GlobalMatrix);

                layerParameters.GeometricMask = sclayer.CreateTransLastHitGeometryForGDI(m);
                m.Dispose();
            }
            else
            {
                layerParameters.GeometricMask  = sclayer.TransLastHitGraphicsPath;
                layerParameters.parentClipRect = node.clipRect;
            }

            node.clipRect = layerParameters.ClipRect;

            layerParameters.sclayer = sclayer;

            g.PushLayer(layerParameters, gdiLayer);
            return(gdiLayer);
        }
Exemple #3
0
        public void PopLayer()
        {
            GDILayer           layer           = layerStack.First();
            GDILayerParameters layerParameters = paramStack.First();
            RectangleF         parentContentBound;
            RectangleF         clipRect;
            ScLayer            sclayer = layerParameters.sclayer;

            layerStack.RemoveFirst();
            paramStack.RemoveFirst();

            if (layerStack.Count > 0)
            {
                gdiGraph           = layerStack.First().graph;
                parentContentBound = paramStack.First().ContentBounds;
                clipRect           = paramStack.First().ClipRect;
            }
            else
            {
                gdiGraph           = rootGdiGraph;
                parentContentBound = new RectangleF(0, 0, w, h);
                clipRect           = layerParameters.parentClipRect;
            }


            float x = (float)Math.Round(layerParameters.ContentBounds.X - parentContentBound.X);
            float y = (float)Math.Round(layerParameters.ContentBounds.Y - parentContentBound.Y);

            Bitmap effectbmp = layer.bitmap;


            //后处理效果
            if (sclayer.UsePosttreatmentEffect)
            {
                effectbmp = sclayer.ScPostTreatmentEffectGDI(layer.bitmap);
            }

            //
            TextureBrush br = new TextureBrush(effectbmp, WrapMode.Clamp);

            br.TranslateTransform((int)x, (int)y);

            switch (layerParameters.MaskAntialiasMode)
            {
            case GDIAntialiasMode.PerPrimitive:
                gdiGraph.SmoothingMode = SmoothingMode.AntiAlias;
                break;

            case GDIAntialiasMode.Aliased:
                gdiGraph.SmoothingMode = SmoothingMode.None;
                break;
            }

            gdiGraph.Transform = new Matrix();

            gdiGraph.SetClip(clipRect);
            gdiGraph.FillPath(br, layerParameters.GeometricMask);
            gdiGraph.ResetClip();

            //后处理效果释放
            if (sclayer.UsePosttreatmentEffect)
            {
                sclayer.ScReleasePostTreatmentEffectGDI(effectbmp);
            }

            br.Dispose();
        }