Esempio n. 1
0
        /// <summary>
        /// This method is called just after the Piccolo scene graph is painted.
        /// </summary>
        /// <param name="paintContext">The paint context used to paint the scene graph.</param>
        public static void EndProcessingOutput(PPaintContext paintContext)
        {
            processOutputTime += (PUtil.CurrentTimeMillis - startProcessingOutputTime);
            framesProcessed++;

            if (PDebug.debugPrintFrameRate)
            {
                if (framesProcessed % printResultsFrameRate == 0)
                {
                    System.Console.WriteLine("Process output frame rate: " + OutputFPS + " fps");
                    System.Console.WriteLine("Process input frame rate: " + InputFPS + " fps");
                    System.Console.WriteLine("Total frame rate: " + TotalFPS + " fps");
                    System.Console.WriteLine();
                    ResetFPSTiming();
                }
            }

            if (PDebug.debugPrintUsedMemory)
            {
                if (framesProcessed % printResultsFrameRate == 0)
                {
                    System.Console.WriteLine("Approximate used memory: " + ApproximateUsedMemory / 1024 + " k");
                }
            }

            if (PDebug.debugRegionManagement)
            {
                paintContext.PaintClipRegion(DebugPaintColor);
            }

            processingOutput = false;
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs a new PPaintContext.
        /// </summary>
        /// <param name="graphics">
        /// The graphics context to associate with this paint context.
        /// </param>
        /// <param name="canvas">The canvas that the paint context will render on.</param>
        public PPaintContext(XnaGraphics graphics, PCanvas canvas)
        {
            this.graphics         = graphics;
            this.canvas           = canvas;
            clipStack             = new Stack();
            localClipStack        = new Stack();
            cameraStack           = new Stack();
            transformStack        = new Stack();
            RenderQuality         = RenderQuality.HighQuality;
            CURRENT_PAINT_CONTEXT = this;

            InitializeStacks();
        }
Esempio n. 3
0
        //****************************************************************
        // Painting - Methods for painting a PText.
        //****************************************************************

        /// <summary>
        /// Overridden.  See <see cref="PNode.Paint">PNode.Paint</see>.
        /// </summary>
        protected override void Paint(XnaPiccolo.Util.PPaintContext paintContext)
        {
            //Font font = new Font("Arial", 12);
            //XnaGraphics gg = paintContext.Graphics;
            //gg.DrawString("Before BasePaint", font, Brushes.Red, new PointF(10, 50));
            //gg.Flush();

            base.Paint(paintContext);

            if (text != null && textBrush != null && font != null)
            {
                XnaGraphics g = paintContext.Graphics;

                float renderedFontSize = font.MeasureString(text).Y * 1.0f;
                //float renderedFontSize = font.SizeInPoints * paintContext.Scale;
                if (renderedFontSize < PUtil.GreekThreshold)
                {
                    // .NET bug: DrawString throws a generic gdi+ exception when
                    // the scaled font size is very small.  So, we will render
                    // the text as a simple rectangle for small fonts
                    g.FillRectangle(textBrush, Bounds);
                }
                else if (renderedFontSize < PUtil.MaxFontSize)
                {
                    SpriteFont renderFont = font;

                    // The font needs to be adjusted for printing.
                    if (g.DpiY != GRAPHICS.DpiY)
                    {
                        float fPrintedFontRatio = GRAPHICS.DpiY / 100;
                        //renderFont = new Font(font.Name, font.Size * fPrintedFontRatio,
                        //	font.Style, font.Unit);
                    }

                    g.DrawString(text, renderFont, textBrush, Bounds, stringFormat);
                }
            }
        }