Pinta.ImageManipulation.UnaryPixelOp.ApplyLoop C# (CSharp) Method

ApplyLoop() protected method

protected ApplyLoop ( ISurface src, ISurface dst, Rectangle roi, CancellationToken token, IRenderProgress progress ) : void
src ISurface
dst ISurface
roi Rectangle
token System.Threading.CancellationToken
progress IRenderProgress
return void
		protected void ApplyLoop (ISurface src, ISurface dst, Rectangle roi, CancellationToken token, IRenderProgress progress)
		{
			src.BeginUpdate ();
			dst.BeginUpdate ();

			var completed_lines = new bool[roi.Height];
			var last_completed_index = 0;

			if (Settings.SingleThreaded || roi.Height <= 1) {
				for (var y = roi.Y; y <= roi.Bottom; ++y) {
					if (token.IsCancellationRequested)
						return;

					var dstPtr = dst.GetPointAddress (roi.X, y);
					var srcPtr = src.GetPointAddress (roi.X, y);
					Apply (srcPtr, dstPtr, roi.Width);

					completed_lines[y - roi.Top] = true;

					if (progress != null) {
						var last_y = FindLastCompletedLine (completed_lines, last_completed_index);
						last_completed_index = last_y;
						progress.CompletedRoi = new Rectangle (roi.X, roi.Y, roi.Width, last_y);
						progress.PercentComplete = (float)last_y / (float)roi.Height;
					}
				}
			} else {
				ParallelExtensions.OrderedFor (roi.Y, roi.Bottom + 1, token, (y) => {
					var dstPtr = dst.GetPointAddress (roi.X, y);
					var srcPtr = src.GetPointAddress (roi.X, y);
					Apply (srcPtr, dstPtr, roi.Width);

					completed_lines[y - roi.Top] = true;

					if (progress != null) {
						var last_y = FindLastCompletedLine (completed_lines, last_completed_index);
						last_completed_index = last_y;
						progress.CompletedRoi = new Rectangle (roi.X, roi.Y, roi.Width, last_y);
						progress.PercentComplete = (float)last_y / (float)roi.Height;
					}
				});
			}

			src.EndUpdate ();
			dst.EndUpdate ();
		}

Same methods

UnaryPixelOp::ApplyLoop ( ISurface src, Rectangle roi, CancellationToken token, IRenderProgress progress ) : void