Clean up CGRect and CGSize usage, remove some debug prints
This commit is contained in:
parent
e457a4b3c4
commit
78e9be6e1d
1 changed files with 17 additions and 10 deletions
|
@ -41,6 +41,18 @@ struct SilicaDocument {
|
|||
var height: Int = 0
|
||||
|
||||
var layers: [SilicaLayer] = []
|
||||
|
||||
lazy var nsSize = {
|
||||
return NSSize(width: width, height: height)
|
||||
}()
|
||||
|
||||
lazy var cgSize = {
|
||||
return CGSize(width: width, height: height)
|
||||
}()
|
||||
|
||||
lazy var cgRect = {
|
||||
return CGRect(origin: .zero, size: cgSize)
|
||||
}()
|
||||
}
|
||||
|
||||
func objectRefGetValue2(_ objectRef: CFTypeRef) -> UInt32 {
|
||||
|
@ -136,8 +148,6 @@ class Document: NSDocument {
|
|||
if getDocumentClassName(dict: dict) == LayerClassName {
|
||||
var layer = SilicaLayer()
|
||||
|
||||
//dump(dict, indent: 5)
|
||||
|
||||
if let val = dict["name"] {
|
||||
let NameClassID = getClassID(id: val)
|
||||
let NameClass = objectsArray[NameClassID] as! NSString
|
||||
|
@ -389,11 +399,10 @@ class Document: NSDocument {
|
|||
let ccgContext = CGContext(data: nil, width: info.width, height: info.height, bitsPerComponent: 8, bytesPerRow: info.width * 4, space: info.colorSpace, bitmapInfo: bitmapInfo.rawValue)
|
||||
|
||||
ccgContext?.setFillColor(info.backgroundColor)
|
||||
ccgContext?.fill(CGRect(origin: .zero, size: CGSize(width: info.width, height: info.height)))
|
||||
ccgContext?.fill(info.cgRect)
|
||||
|
||||
var masterImage = ccgContext?.makeImage()
|
||||
let context = CIContext()
|
||||
let size = CGRect(x: 0, y: 0, width: info.width, height: info.height)
|
||||
|
||||
var previousImage: CGImage?
|
||||
|
||||
|
@ -407,7 +416,7 @@ class Document: NSDocument {
|
|||
let maskContext = CGContext(data: nil, width: info.width, height: info.height, bitsPerComponent: 16, bytesPerRow: 0, space: grayColorSpace, bitmapInfo: maskBitmapInfo.rawValue)
|
||||
|
||||
maskContext?.setFillColor(.white)
|
||||
maskContext?.fill(CGRect(origin: .zero, size: CGSize(width: info.width, height: info.height)))
|
||||
maskContext?.fill(info.cgRect)
|
||||
|
||||
var kernel: CIBlendKernel? = .sourceOver
|
||||
if layer.data.blendMode == 1 {
|
||||
|
@ -493,8 +502,6 @@ class Document: NSDocument {
|
|||
kernel = .luminosity
|
||||
}
|
||||
|
||||
Swift.print(layer.name + " is " + kernel!.name)
|
||||
|
||||
if layer.mask != nil {
|
||||
for chunk in layer.mask!.chunks {
|
||||
let x = chunk.x
|
||||
|
@ -557,10 +564,10 @@ class Document: NSDocument {
|
|||
let ciImage = CIImage(cgImage: (masterImage)!)
|
||||
let newCiImage = kernel!.apply(foreground: CIImage(cgImage: previousImage!), background: ciImage, colorSpace: info.colorSpace)
|
||||
|
||||
masterImage = context.createCGImage(newCiImage!, from: size, format: .RGBA8, colorSpace: info.colorSpace)!
|
||||
masterImage = context.createCGImage(newCiImage!, from: info.cgRect, format: .RGBA8, colorSpace: info.colorSpace)!
|
||||
}
|
||||
|
||||
var image = NSImage(cgImage: masterImage!, size: NSSize(width: info.width, height: info.height))
|
||||
var image = NSImage(cgImage: masterImage!, size: info.nsSize)
|
||||
|
||||
if info.orientation == 3 {
|
||||
image = image.imageRotatedByDegreess(degrees: 90)
|
||||
|
|
Reference in a new issue