Clean up ahead of PR.

pull/2/head
Matthew Chen 6 years ago
parent 922f787ff6
commit 331a013f8d

@ -8,15 +8,6 @@ import XCTest
class ImageEditorModelTest: SignalBaseTest { class ImageEditorModelTest: SignalBaseTest {
// override func setUp() {
// super.setUp()
// }
//
// override func tearDown() {
// // Put teardown code here. This method is called after the invocation of each test method in the class.
// super.tearDown()
// }
func testImageEditorTransform0() { func testImageEditorTransform0() {
let imageSizePixels = CGSize(width: 200, height: 300) let imageSizePixels = CGSize(width: 200, height: 300)
let outputSizePixels = CGSize(width: 200, height: 300) let outputSizePixels = CGSize(width: 200, height: 300)

@ -43,9 +43,13 @@ public class ImageEditorCanvasView: UIView {
// MARK: - Views // MARK: - Views
// TODO: Audit all usage of this view. // contentView is used to host the layers used to render the content.
//
// The transform for the content is applied to it.
public let contentView = OWSLayerView() public let contentView = OWSLayerView()
// clipView is used to clip the content. It reflects the actual
// visible bounds of the content.
private let clipView = OWSLayerView() private let clipView = OWSLayerView()
private var contentViewConstraints = [NSLayoutConstraint]() private var contentViewConstraints = [NSLayoutConstraint]()
@ -157,8 +161,6 @@ public class ImageEditorCanvasView: UIView {
internal func updateAllContent() { internal func updateAllContent() {
AssertIsOnMainThread() AssertIsOnMainThread()
Logger.verbose("")
// Don't animate changes. // Don't animate changes.
CATransaction.begin() CATransaction.begin()
CATransaction.setDisableActions(true) CATransaction.setDisableActions(true)
@ -200,8 +202,6 @@ public class ImageEditorCanvasView: UIView {
internal func updateContent(changedItemIds: [String]) { internal func updateContent(changedItemIds: [String]) {
AssertIsOnMainThread() AssertIsOnMainThread()
Logger.verbose("")
// Don't animate changes. // Don't animate changes.
CATransaction.begin() CATransaction.begin()
CATransaction.setDisableActions(true) CATransaction.setDisableActions(true)
@ -245,8 +245,6 @@ public class ImageEditorCanvasView: UIView {
} }
private func applyTransform() { private func applyTransform() {
Logger.verbose("")
let viewSize = clipView.bounds.size let viewSize = clipView.bounds.size
contentView.layer.setAffineTransform(model.currentTransform().affineTransform(viewSize: viewSize)) contentView.layer.setAffineTransform(model.currentTransform().affineTransform(viewSize: viewSize))
} }
@ -295,7 +293,6 @@ public class ImageEditorCanvasView: UIView {
width: width, width: width,
height: height) height: height)
Logger.verbose("viewSize: \(viewSize), imageFrame: \(imageFrame), ")
return imageFrame return imageFrame
} }
@ -364,7 +361,7 @@ public class ImageEditorCanvasView: UIView {
y: viewSize.height * unitSample.y) y: viewSize.height * unitSample.y)
} }
// TODO: Use bezier curves to smooth stroke. // Use bezier curves to smooth stroke.
let bezierPath = UIBezierPath() let bezierPath = UIBezierPath()
let points = applySmoothing(to: unitSamples.map { (unitSample) in let points = applySmoothing(to: unitSamples.map { (unitSample) in
@ -474,7 +471,6 @@ public class ImageEditorCanvasView: UIView {
.font: item.font.withSize(fontSize) .font: item.font.withSize(fontSize)
], ],
context: nil) context: nil)
Logger.verbose("---- maxWidth: \(maxWidth), viewSize: \(viewSize), item.unitWidth: \(item.unitWidth), textBounds: \(textBounds)")
let center = CGPoint(x: viewSize.width * item.unitCenter.x, let center = CGPoint(x: viewSize.width * item.unitCenter.x,
y: viewSize.height * item.unitCenter.y) y: viewSize.height * item.unitCenter.y)
let layerSize = CGSizeCeil(textBounds.size) let layerSize = CGSizeCeil(textBounds.size)
@ -570,7 +566,6 @@ public class ImageEditorCanvasView: UIView {
// Render output at same size as source image. // Render output at same size as source image.
let dstSizePixels = transform.outputSizePixels let dstSizePixels = transform.outputSizePixels
let dstScale: CGFloat = 1.0 // The size is specified in pixels, not in points. let dstScale: CGFloat = 1.0 // The size is specified in pixels, not in points.
// TODO: Reflect crop rectangle.
let viewSize = dstSizePixels let viewSize = dstSizePixels
let hasAlpha = NSData.hasAlpha(forValidImageFilePath: model.srcImagePath) let hasAlpha = NSData.hasAlpha(forValidImageFilePath: model.srcImagePath)
@ -602,7 +597,6 @@ public class ImageEditorCanvasView: UIView {
owsFailDebug("Could not load src image.") owsFailDebug("Could not load src image.")
return nil return nil
} }
// TODO:
imageLayer.contentsScale = dstScale * transform.scaling imageLayer.contentsScale = dstScale * transform.scaling
contentView.layer.addSublayer(imageLayer) contentView.layer.addSublayer(imageLayer)
@ -613,7 +607,6 @@ public class ImageEditorCanvasView: UIView {
Logger.error("Couldn't create layer for item.") Logger.error("Couldn't create layer for item.")
continue continue
} }
// TODO: Should we do this for all layers?
layer.contentsScale = dstScale * transform.scaling * item.outputScale() layer.contentsScale = dstScale * transform.scaling * item.outputScale()
contentView.layer.addSublayer(layer) contentView.layer.addSublayer(layer)
} }

Loading…
Cancel
Save