|
@@ -17,6 +17,8 @@ open class PQImageFilter: PQBaseFilter {
|
|
|
var imageVertexBuffer: GLuint = 0
|
|
|
var mSticker: PQEditVisionTrackMaterialsModel?
|
|
|
var newImage: UIImage?
|
|
|
+ //临时方案,是否是卡点模式
|
|
|
+ public var isPointModel:Bool = false
|
|
|
deinit {
|
|
|
FilterLog(1, message: "image filter deinit 析构掉~")
|
|
|
newImage = nil
|
|
@@ -135,8 +137,9 @@ open class PQImageFilter: PQBaseFilter {
|
|
|
}
|
|
|
|
|
|
FilterLog(2, message: " image filter 当前时间: \(currTime) \(newImage!.size)")
|
|
|
-
|
|
|
- if currTime >= mSticker!.timelineIn && currTime <= mSticker!.timelineOut {
|
|
|
+
|
|
|
+ if(isPointModel){
|
|
|
+
|
|
|
FilterLog(2, message: " 显示图片当前时间: \(currTime) 开始时间:\(mSticker!.timelineIn) 结束时间:\(mSticker!.timelineOut) \(String(describing: newImage?.size))")
|
|
|
// 取纹理坐标
|
|
|
var textureCoordinates = PQGPUImageTools.getTextureCoordinates(sticker: mSticker!, textureSize: newImage!.size, cannvasSize: inputSize)
|
|
@@ -184,6 +187,58 @@ open class PQImageFilter: PQBaseFilter {
|
|
|
PQGPUImageTools.deleteVBO(imageVertexBuffer)
|
|
|
imageVertexBuffer = 0
|
|
|
}
|
|
|
+ }else{
|
|
|
+ if currTime >= mSticker!.timelineIn && currTime <= mSticker!.timelineOut {
|
|
|
+ FilterLog(2, message: " 显示图片当前时间: \(currTime) 开始时间:\(mSticker!.timelineIn) 结束时间:\(mSticker!.timelineOut) \(String(describing: newImage?.size))")
|
|
|
+ // 取纹理坐标
|
|
|
+ var textureCoordinates = PQGPUImageTools.getTextureCoordinates(sticker: mSticker!, textureSize: newImage!.size, cannvasSize: inputSize)
|
|
|
+
|
|
|
+ FilterLog(2, message: "textureCoordinates is \(textureCoordinates) image size :\(newImage!.size) cannvasSize:\(inputSize) files path is \(mSticker?.locationPath)")
|
|
|
+
|
|
|
+ // imageTexture 有可能被析构导致黑屏
|
|
|
+ if imageTexture == 0 && newImage?.cgImage != nil {
|
|
|
+ FilterLog(2, message: "imageTexture is error !!!!!重新创建")
|
|
|
+ imageTexture = PQGPUImageTools.setupTexture(image: newImage!.cgImage!)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果设置过大小位置,使用设置值,比如水印
|
|
|
+ if stickerInfo?.materialPosition?.width != 0 {
|
|
|
+ textureCoordinates = [
|
|
|
+ 0.0, 0.0, // 1 bottom left
|
|
|
+ 1.0, 0.0, // 2 bottom right
|
|
|
+ 0.0, 1.0, // 3 top left
|
|
|
+ 1.0, 1.0, // 4 top right
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
+ let texturePropertiesimagetwo = InputTextureProperties(textureCoordinates: textureCoordinates, texture: imageTexture)
|
|
|
+
|
|
|
+ var verticesPoint: [GLfloat] = PQGPUImageTools.getVerticesPoint(sticker: mSticker!, textureSize: newImage!.size, cannvasSize: inputSize)
|
|
|
+
|
|
|
+ // 如果设置过大小位置,使用设置值,比如水印
|
|
|
+ if stickerInfo?.materialPosition?.width != 0 {
|
|
|
+ verticesPoint = PQGPUImageTools.computeVertices(viewSize: CGSize(width: CGFloat(inputSize.width), height: CGFloat(inputSize.height)), _bounds: CGRect(x: stickerInfo?.materialPosition?.x ?? 0, y: stickerInfo?.materialPosition?.y ?? 0, width: stickerInfo?.materialPosition?.width ?? 0, height: stickerInfo?.materialPosition?.height ?? 0))
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置融合模式支持 alpha
|
|
|
+ glEnable(GLenum(GL_DEPTH_TEST))
|
|
|
+ glEnable(GLenum(GL_BLEND))
|
|
|
+ glBlendFunc(GLenum(GL_SRC_ALPHA), GLenum(GL_ONE_MINUS_SRC_ALPHA))
|
|
|
+
|
|
|
+ imageVertexBuffer = PQGPUImageTools.NXGenerateVBO(for: verticesPoint)
|
|
|
+
|
|
|
+ renderQuadWithShader(shader,
|
|
|
+ uniformSettings: uniformSettings,
|
|
|
+ vertexBufferObject: imageVertexBuffer, inputTextures: [texturePropertiesimagetwo])
|
|
|
+ releaseIncomingFramebuffers()
|
|
|
+
|
|
|
+ if imageVertexBuffer != 0 {
|
|
|
+ PQGPUImageTools.deleteVBO(imageVertexBuffer)
|
|
|
+ imageVertexBuffer = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|