 		let bounds = self.bounds
 		if bounds.size != lastLayoutedSize {
 			lastLayoutedSize = bounds.size
-			needsUpdateContents = true
-
 			sourceSessionConfigurationIsValid = false
 		}
 

				return
			}

			if image != nil && scaling != .FitIgnoringAspectRatio {
				setNeedsUpdateContents()
			}

			invalidateConfiguration()
		}

	}


	private func computeImageLayerFrame() -> CGRect {
		guard let image = image else {
			return .zero
		}

		let imageSize = image.size
		let maximumImageLayerFrame = CGRect(size: bounds.size).insetBy(padding)

		guard imageSize.isPositive && maximumImageLayerFrame.size.isPositive else {
			return .zero
		}

		let gravity = self.gravity
		let scaling = self.scaling

		var imageLayerFrame = CGRect()

		switch scaling {
		case .FitIgnoringAspectRatio:
			imageLayerFrame.size = maximumImageLayerFrame.size

		case .FitInside, .FitOutside:
			let horizontalScale = maximumImageLayerFrame.width / imageSize.width
			let verticalScale = maximumImageLayerFrame.height / imageSize.height
			let scale = (scaling == .FitInside ? min : max)(horizontalScale, verticalScale)

			imageLayerFrame.size = imageSize.scaleBy(scale)

		case .FitHorizontally:
			imageLayerFrame.width = maximumImageLayerFrame.width
			imageLayerFrame.height = imageSize.height * (imageLayerFrame.width / imageSize.width)

		case .FitHorizontallyIgnoringAspectRatio:
			imageLayerFrame.width = maximumImageLayerFrame.width
			imageLayerFrame.height = imageSize.height

		case .FitVertically:
			imageLayerFrame.height = maximumImageLayerFrame.height
			imageLayerFrame.width = imageSize.width * (imageLayerFrame.height / imageSize.height)

		case .FitVerticallyIgnoringAspectRatio:
			imageLayerFrame.height = maximumImageLayerFrame.height
			imageLayerFrame.width = imageSize.width

		case .None:
			imageLayerFrame.size = imageSize
		}

		switch gravity.horizontal {
		case .Left:
			imageLayerFrame.left = maximumImageLayerFrame.left

		case .Center:
			imageLayerFrame.horizontalCenter = maximumImageLayerFrame.horizontalCenter

		case .Right:
			imageLayerFrame.right = maximumImageLayerFrame.right
		}

		switch gravity.vertical {
		case .Top:
			imageLayerFrame.top = maximumImageLayerFrame.top

		case .Center:
			imageLayerFrame.verticalCenter = maximumImageLayerFrame.verticalCenter

		case .Bottom:
			imageLayerFrame.bottom = maximumImageLayerFrame.bottom
		}

		switch image.imageOrientation {
		case .Left, .LeftMirrored, .Right, .RightMirrored:
			let center = imageLayerFrame.center
			swap(&imageLayerFrame.width, &imageLayerFrame.height)
			imageLayerFrame.center = center

		case .Down, .DownMirrored, .Up, .UpMirrored:
			break
		}

		imageLayerFrame = alignToGrid(imageLayerFrame)

		return imageLayerFrame
	}


	private func computeImageLayerTransform() -> CGAffineTransform {
		guard let image = image else {
			return CGAffineTransformIdentity
		}

		// TODO support mirrored variants
		let transform: CGAffineTransform
		switch image.imageOrientation {
		case .Down:          transform = CGAffineTransformMakeRotation(.Pi)
		case .DownMirrored:  transform = CGAffineTransformMakeRotation(.Pi)
		case .Left:          transform = CGAffineTransformMakeRotation(-.Pi / 2)
		case .LeftMirrored:  transform = CGAffineTransformMakeRotation(-.Pi / 2)
		case .Right:         transform = CGAffineTransformMakeRotation(.Pi / 2)
		case .RightMirrored: transform = CGAffineTransformMakeRotation(.Pi / 2)
		case .Up:            transform = CGAffineTransformIdentity
		case .UpMirrored:    transform = CGAffineTransformIdentity
		}

		return transform
	}


	@available(*, unavailable, message="Use .gravity and .scaling instead.")
	public final override var contentMode: UIViewContentMode {
		get { return super.contentMode }
		set { super.contentMode = newValue }
