From 1b1359995ecb44cd64ba2429fa14317e651f0ec7 Mon Sep 17 00:00:00 2001 From: JimBobSquarePants Date: Wed, 6 Sep 2017 12:39:54 +1000 Subject: [PATCH] Remove Parent property --- src/ImageSharp/Image/IImageFrame.cs | 5 --- src/ImageSharp/Image/ImageFrameCollection.cs | 40 +++++-------------- src/ImageSharp/Image/Image{TPixel}.cs | 3 -- src/ImageSharp/Image/PixelAccessor{TPixel}.cs | 26 +++--------- 4 files changed, 15 insertions(+), 59 deletions(-) diff --git a/src/ImageSharp/Image/IImageFrame.cs b/src/ImageSharp/Image/IImageFrame.cs index 244a60a89..803f8a869 100644 --- a/src/ImageSharp/Image/IImageFrame.cs +++ b/src/ImageSharp/Image/IImageFrame.cs @@ -16,11 +16,6 @@ namespace SixLabors.ImageSharp internal interface IImageFrame : IImageFrame where TPixel : struct, IPixel { - /// - /// Gets the parent. - /// - Image Parent { get; } - /// /// Gets the pixel buffer. /// diff --git a/src/ImageSharp/Image/ImageFrameCollection.cs b/src/ImageSharp/Image/ImageFrameCollection.cs index 92e068ec8..65f52f922 100644 --- a/src/ImageSharp/Image/ImageFrameCollection.cs +++ b/src/ImageSharp/Image/ImageFrameCollection.cs @@ -4,16 +4,8 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Numerics; -using System.Text; -using System.Threading.Tasks; -using SixLabors.ImageSharp.Formats; -using SixLabors.ImageSharp.MetaData; + using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using SixLabors.Primitives; namespace SixLabors.ImageSharp { @@ -24,34 +16,25 @@ namespace SixLabors.ImageSharp public sealed class ImageFrameCollection : IEnumerable> where TPixel : struct, IPixel { - private IList> frames = new List>(); - private readonly Image parent; + private readonly IList> frames = new List>(); + private readonly int parentWidth; + private readonly int parentHeight; internal ImageFrameCollection(Image parent) { - this.parent = parent; + this.parentWidth = parent.Width; + this.parentHeight = parent.Height; } /// /// Gets the count. /// - public int Count { get => this.frames.Count; } + public int Count => this.frames.Count; /// /// Gets the root frame. /// - public ImageFrame RootFrame - { - get - { - if (this.frames.Count > 0) - { - return this.frames[0]; - } - - return null; - } - } + public ImageFrame RootFrame => this.frames.Count > 0 ? this.frames[0] : null; /// /// Gets or sets the at the specified index. @@ -63,10 +46,7 @@ namespace SixLabors.ImageSharp /// The at the specified index. public ImageFrame this[int index] { - get - { - return this.frames[index]; - } + get => this.frames[index]; set { @@ -123,7 +103,7 @@ namespace SixLabors.ImageSharp { if (this.Count != 0) { - if (this.parent.Width != frame.Width || this.parent.Height != frame.Height) + if (this.parentWidth != frame.Width || this.parentHeight != frame.Height) { throw new ArgumentException("Frame must have the same dimensions as the image", nameof(frame)); } diff --git a/src/ImageSharp/Image/Image{TPixel}.cs b/src/ImageSharp/Image/Image{TPixel}.cs index cfd28f05d..7d8a48598 100644 --- a/src/ImageSharp/Image/Image{TPixel}.cs +++ b/src/ImageSharp/Image/Image{TPixel}.cs @@ -136,9 +136,6 @@ namespace SixLabors.ImageSharp /// ImageFrameMetaData IImageFrame.MetaData => this.RootFrame.MetaData; - /// - Image IImageFrame.Parent => this.RootFrame.Parent; - /// /// Gets or sets the pixel at the specified position. /// diff --git a/src/ImageSharp/Image/PixelAccessor{TPixel}.cs b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs index bb5f427df..0de76cbd1 100644 --- a/src/ImageSharp/Image/PixelAccessor{TPixel}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TPixel}.cs @@ -4,8 +4,7 @@ using System; using System.Diagnostics; using System.Runtime.CompilerServices; -using System.Threading.Tasks; -using SixLabors.ImageSharp.Advanced; + using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using Unsafe = System.Runtime.CompilerServices.Unsafe; @@ -49,8 +48,6 @@ namespace SixLabors.ImageSharp Guard.MustBeGreaterThan(image.Height, 0, "image height"); this.SetPixelBufferUnsafe(image.PixelBuffer, false); - Configuration config = image.Parent.Configuration(); - this.ParallelOptions = config.ParallelOptions; } /// @@ -77,8 +74,6 @@ namespace SixLabors.ImageSharp Guard.MustBeGreaterThan(height, 0, nameof(height)); this.SetPixelBufferUnsafe(pixels, ownedBuffer); - - this.ParallelOptions = Configuration.Default.ParallelOptions; } /// @@ -104,21 +99,12 @@ namespace SixLabors.ImageSharp /// public int RowStride { get; private set; } - /// - /// Gets the width of the image. - /// + /// public int Width { get; private set; } - /// - /// Gets the height of the image. - /// + /// public int Height { get; private set; } - /// - /// Gets the global parallel options for processing tasks in parallel. - /// - public ParallelOptions ParallelOptions { get; } - /// Span IBuffer2D.Span => this.PixelBuffer; @@ -147,9 +133,7 @@ namespace SixLabors.ImageSharp } } - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// + /// public void Dispose() { if (this.isDisposed || !this.ownedBuffer) @@ -245,7 +229,7 @@ namespace SixLabors.ImageSharp /// If is true then caller is responsible for ensuring is called. internal Buffer2D SwapBufferOwnership(Buffer2D pixels) { - var oldPixels = this.PixelBuffer; + Buffer2D oldPixels = this.PixelBuffer; this.SetPixelBufferUnsafe(pixels, this.ownedBuffer); return oldPixels; }