Esempio n. 1
0
        protected override bool OnDamageEvent(Gdk.EventExpose evnt)
        {
            if (canvas_child == null || !canvas_child.Visible || !Visible || !IsMapped)
            {
                return(true);
            }

            Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window);
            context.Context = cr;

            for (int i = 0; i < evnt.Region.NumRectangles; i++)
            {
                var damage = evnt.Region.GetRectangle(i);
                cr.Rectangle(damage.X, damage.Y, damage.Width, damage.Height);
                cr.Clip();

                cr.Translate(Allocation.X, Allocation.Y);
                canvas_child.Render(context);
                cr.Translate(-Allocation.X, -Allocation.Y);

                if (Debug)
                {
                    cr.LineWidth = 1.0;
                    cr.SetSourceColor(CairoExtensions.RgbToColor(
                                          (uint)(rand = rand ?? new Random()).Next(0, 0xffffff)));
                    cr.Rectangle(damage.X + 0.5, damage.Y + 0.5, damage.Width - 1, damage.Height - 1);
                    cr.Stroke();
                }

                cr.ResetClip();
            }

            CairoExtensions.DisposeContext(cr);

            if (fps.Update())
            {
                // Console.WriteLine ("FPS: {0}", fps.FramesPerSecond);
            }

            return(true);
        }
Esempio n. 2
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (canvas_child == null || !canvas_child.Visible || !Visible || !IsMapped)
            {
                return(true);
            }

            foreach (Gdk.Rectangle damage in evnt.Region.GetRectangles())
            {
                cr.Rectangle(damage.X, damage.Y, damage.Width, damage.Height);
                cr.Clip();

                cr.Translate(Allocation.X, Allocation.Y);
                canvas_child.Render(cr);
                cr.Translate(-Allocation.X, -Allocation.Y);

                if (Debug)
                {
                    cr.LineWidth = 1.0;
                    cr.Color     = CairoExtensions.RgbToColor(
                        (uint)(rand = rand ?? new Random()).Next(0, 0xffffff));
                    cr.Rectangle(damage.X + 0.5, damage.Y + 0.5, damage.Width - 1, damage.Height - 1);
                    cr.Stroke();
                }

                cr.ResetClip();
            }

            CairoExtensions.DisposeContext(cr);

            if (fps.Update())
            {
                // Console.WriteLine ("FPS: {0}", fps.FramesPerSecond);
            }

            return(true);
        }