Beispiel #1
0
 public GradientBenchmark(string name, Surface surface, GradientRenderer renderer, int iterations)
     : base(name)
 {
     Surface    = surface;
     Renderer   = renderer;
     Iterations = iterations;
 }
Beispiel #2
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     //
     // RichEditToolbar
     //
     this.Name = "RichEditToolbar";
     Renderer  = new GradientRenderer(SystemColors.ControlLightLight, SystemColors.Control);
 }
Beispiel #3
0
        private void RenderGradient(Surface surface, PdnRegion clipRegion, CompositingMode compositingMode,
                                    PointF startPointF, ColorBgra startColor, PointF endPointF, ColorBgra endColor)
        {
            GradientRenderer gr = AppEnvironment.GradientInfo.CreateGradientRenderer();

            gr.StartColor    = startColor;
            gr.EndColor      = endColor;
            gr.StartPoint    = startPointF;
            gr.EndPoint      = endPointF;
            gr.AlphaBlending = (compositingMode == CompositingMode.SourceOver);
            gr.BeforeRender();

            Rectangle[] oldRois = clipRegion.GetRegionScansReadOnlyInt();
            Rectangle[] newRois;

            if (oldRois.Length == 1)
            {
                newRois = new Rectangle[Processor.LogicalCpuCount];
                Utility.SplitRectangle(oldRois[0], newRois);
            }
            else
            {
                newRois = oldRois;
            }

            RenderContext rc = new RenderContext();

            rc.surface  = surface;
            rc.rois     = newRois;
            rc.renderer = gr;

            WaitCallback wc = new WaitCallback(rc.Render);

            for (int i = 0; i < Processor.LogicalCpuCount; ++i)
            {
                if (i == Processor.LogicalCpuCount - 1)
                {
                    wc(BoxedConstants.GetInt32(i));
                }
                else
                {
                    PaintDotNet.Threading.ThreadPool.Global.QueueUserWorkItem(wc, BoxedConstants.GetInt32(i));
                }
            }

            PaintDotNet.Threading.ThreadPool.Global.Drain();
        }
Beispiel #4
0
        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            if (tracking)
            {
                GradientRenderer gr = CreateGradientRenderer();

                if (button == 3)                        // Right-click
                {
                    gr.StartColor = PintaCore.Palette.SecondaryColor.ToColorBgra();
                    gr.EndColor   = PintaCore.Palette.PrimaryColor.ToColorBgra();
                }
                else                                    //1 Left-click
                {
                    gr.StartColor = PintaCore.Palette.PrimaryColor.ToColorBgra();
                    gr.EndColor   = PintaCore.Palette.SecondaryColor.ToColorBgra();
                }

                gr.StartPoint    = startpoint;
                gr.EndPoint      = point;
                gr.AlphaBlending = UseAlphaBlending;

                gr.BeforeRender();

                Gdk.Rectangle selection_bounds = doc.GetSelectedBounds(true);
                ImageSurface  scratch_layer    = doc.ToolLayer.Surface;

                gr.Render(scratch_layer, new Gdk.Rectangle[] { selection_bounds });

                using (var g = doc.CreateClippedContext()) {
                    g.SetSource(scratch_layer);
                    g.Paint();
                }

                doc.ToolLayer.Clear();

                selection_bounds.Inflate(5, 5);
                doc.Workspace.Invalidate(selection_bounds);
            }
        }