QueryPerformanceCounter() private method

private QueryPerformanceCounter ( long &var ) : short
var long
return short
Beispiel #1
0
        /// <summary>
        /// Perform a layout of the view.
        /// </summary>
        /// <param name="context">View context for layout operation.</param>
        public virtual void Layout(ViewLayoutContext context)
        {
            if (KryptonToolkitSettings.DisableLayout)
            {
                return;
            }

            Debug.Assert(context != null);
            Debug.Assert(context.Renderer != null);
            Debug.Assert(Root != null);

            // Do nothing if the control is disposed
            if (!context.Control.IsDisposed)
            {
                if (_outputDebug)
                {
                    PI.QueryPerformanceCounter(ref _outputStart);
                }

                // Validate incoming references
                if (context.Renderer == null)
                {
                    throw new ArgumentNullException("renderer");
                }

                // If someone is interested, tell them the layout cycle to beginning
                if (LayoutBefore != null)
                {
                    LayoutBefore(this, EventArgs.Empty);
                }

                // Ask the view to perform a layout
                Root.Layout(context);

                // If someone is interested, tell them the layout cycle has finished
                if (LayoutAfter != null)
                {
                    LayoutAfter(this, EventArgs.Empty);
                }

                if (_outputDebug)
                {
                    long outputEnd = 0;
                    PI.QueryPerformanceCounter(ref outputEnd);
                    long outputDiff = outputEnd - _outputStart;

                    Console.WriteLine("Id:{0} Layout Type:{1} Elapsed:{2} Rect:{3}",
                                      Id,
                                      context.Control.GetType().ToString(),
                                      outputDiff.ToString(),
                                      context.DisplayRectangle);
                }

                // Maintain internal counters for measuring perf
                _layoutCounter++;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Perform a paint of the view.
        /// </summary>
        /// <param name="context">Renderer context.</param>
        public virtual void Paint(RenderContext context)
        {
            Debug.Assert(context != null);
            Debug.Assert(Root != null);

            // Validate incoming reference
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            // Do nothing if the control is disposed or inside a layout call
            if (!_control.IsDisposed)
            {
#if DEBUG
                PI.QueryPerformanceCounter(ref _outputStart);
#endif
                //if (_outputDebug)
                //    PI.QueryPerformanceCounter(ref _outputStart);

                // Ask the view to paint itself
                Root.Render(context);

#if DEBUG
                long outputEnd = 0;
                PI.QueryPerformanceCounter(ref outputEnd);
                long outputDiff = outputEnd - _outputStart;

                Console.WriteLine("Root.Render(context) :: Id:{0} | Control:{3} | PaintType:{1} | Elapsed: {2}",
                                  Id,
                                  _control.GetType().ToString(),
                                  outputDiff.ToString(),
                                  _control.ToString());
#endif

                //if (_outputDebug)
                //{
                //    long outputEnd = 0;
                //    PI.QueryPerformanceCounter(ref outputEnd);
                //    long outputDiff = outputEnd - _outputStart;

                //    Console.WriteLine("Id:{0} Paint Type:{1} Elapsed: {2}",
                //        Id,
                //        _control.GetType().ToString(),
                //        outputDiff.ToString());
                //}
            }

            // Maintain internal counters for measuring perf
            _paintCounter++;
        }