示例#1
0
        internal void BeginIteration([NotNull] CalculationState state)
        {
            var trans = state.Transform;

            state.Input  = trans.Matrix.Multiply(state.Input).Copy(c: state.Input.C * trans.CmapCorners[0] + trans.CmapCorners[1]);
            state.Output = new Vertex(0, 0, state.Input.C);
        }
示例#2
0
        private void NextTransform(CalculationState calculationState)
        {
            calculationState.TransformIndex = _selector.NextIndex(this);
            calculationState.Transform      = _transforms[calculationState.TransformIndex];

            Statistics.SetTransform(calculationState.TransformIndex);
        }
示例#3
0
        protected override IResult Initialize()
        {
            using (_context.PerformanceCounter.EnterMeasureScope("Thread overhead"))
            {
                _state = _context.CreateThreadState();
            }

            return(Result.Success);
        }
示例#4
0
        internal void EndIteration([NotNull] CalculationState state)
        {
            NextTransform(state);

            Statistics.Update(state);

            state.Input = state.Output.ResetNaNs();
            state.IterationNumber++;

            PerformanceCounter.Count();
        }
示例#5
0
        internal CalculationState CreateThreadState()
        {
            var calculationState = new CalculationState(this);

            calculationState.Input = new Vertex(
                Random() * 2 - 1,
                Random() * 2 - 1,
                Random() * 2 - 1);

            NextTransform(calculationState);

            return(calculationState);
        }
示例#6
0
        internal void Update([NotNull] CalculationState state)
        {
            if (!IsEnabled)
            {
                return;
            }

            if (double.IsNaN(state.Output.X) || double.IsNaN(state.Output.Y))
            {
                return;
            }

            lock (_stLock)
            {
                _min = new Vertex(double.IsNaN(_min.X) ? state.Output.X : Math.Min(state.Output.X, _min.X), double.IsNaN(_min.Y) ? state.Output.Y : Math.Min(state.Output.Y, _min.Y));
                _max = new Vertex(double.IsNaN(_max.X) ? state.Output.X : Math.Max(state.Output.X, _max.X), double.IsNaN(_max.Y) ? state.Output.Y : Math.Max(state.Output.Y, _max.Y));
            }
        }
示例#7
0
        internal void Plot([NotNull] CalculationState state)
        {
            var pixelX = (int)((1 + state.Output.X) * _backBuffer.Width * 0.5f);
            var pixelY = (int)((2 - (1 + state.Output.Y)) * _backBuffer.Height * 0.5f);

            if (pixelX >= 0 && pixelY >= 0 && pixelX < _backBuffer.Width && pixelY < _backBuffer.Height)
            {
                var caddr = (int)Math.Max(0, Math.Min(state.Output.C * (_colors.Length - 1), _colors.Length - 1));
                var addr  = _backBuffer.Width * pixelY + pixelX;
                var col   = _colors[caddr];

                lock (_histogramLock)
                {
                    var p = Histogram[addr];

                    p.Red   += col.R;
                    p.Green += col.G;
                    p.Blue  += col.B;
                    p.Count++;

                    Histogram[addr] = p;
                }
            }
        }
示例#8
0
 public abstract void Calculate([NotNull] CalculationState calculationState);
示例#9
0
 protected override void Cleanup(bool wasCancelled)
 {
     _state = null;
 }