         var image = image
         
         if let clip = current_layer.state.clip {
-            image = image.applyingFilter("CIBlendWithMask", parameters: [kCIInputBackgroundImageKey: GPContext.clear, kCIInputMaskImageKey: clip])
+            image = image.applyingFilter("CIBlendWithMask", parameters: [kCIInputBackgroundImageKey: CIImage.empty(), kCIInputMaskImageKey: clip])
         }
         
         guard let blended = blendKernel.apply(foreground: image, background: current_layer._image) else { return }
             
         current_layer._image = blended
+        current_layer.state.isDirty = true
     }
     
     private func draw_layer(_ image: CIImage) {

    
    public let height: Int
    
    private var _image: CIImage {
        didSet {
            _image = _image.clamped(to: extent)
            state.isDirty = true
        }
    }
    
    fileprivate var state: GPContextState = GPContextState()
    

    }
    
    public var image: CIImage {
        return _image.clamped(to: extent).cropped(to: extent)
    }
}

