Browse Source

inputbuffer保护

huzhiqiang 3 năm trước cách đây
mục cha
commit
fba759e813

+ 7 - 1
BFFramework/Classes/PQGPUImage/Source/BasicOperation.swift

@@ -134,7 +134,13 @@ open class BasicOperation: ImageProcessingOperation {
             internalRenderFunction(inputFramebuffers[0]!, textureProperties: textureProperties)
             disableStencil()
         } else {
-            internalRenderFunction(inputFramebuffers[0]!, textureProperties: textureProperties)
+            do {
+                let imageFramebuffer = try Framebuffer(context: sharedImageProcessingContext, orientation: .portrait, size: GLSize(width: 0, height: 0), textureOnly: true)
+                internalRenderFunction(inputFramebuffers[0] ?? imageFramebuffer, textureProperties: textureProperties)
+            } catch {
+                fatalError("Could not create a framebuffer  error: \(error)")
+            }
+            
         }
     }
 

+ 6 - 0
BFFramework/Classes/PQGPUImage/Source/TwoStageOperation.swift

@@ -6,6 +6,12 @@ open class TwoStageOperation: BasicOperation {
     var downsamplingFactor: Float?
 
     override func internalRenderFunction(_ inputFramebuffer: Framebuffer, textureProperties: [InputTextureProperties]) {
+        
+        if inputFramebuffer.size.width == 0 && inputFramebuffer.size.height == 0 {
+            HHZPrint("frame buffer data error")
+            return
+        }
+    
         let outputRotation = overriddenOutputRotation ?? inputFramebuffer.orientation.rotationNeededForOrientation(.portrait)
 
         // Downsample