|
@@ -131,7 +131,7 @@ public class PQGPUImagePlayerView: UIView {
|
|
|
|
|
|
FilterLog(message: "设置线程为: \(Thread.current) \(OperationQueue.current?.underlyingQueue?.label as Any)")
|
|
FilterLog(message: "设置线程为: \(Thread.current) \(OperationQueue.current?.underlyingQueue?.label as Any)")
|
|
|
|
|
|
- configCache()
|
|
|
|
|
|
+ configCache(beginTime: mStickers?.first?.timelineIn ?? 0)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -406,7 +406,7 @@ public class PQGPUImagePlayerView: UIView {
|
|
guard let strongSelf = self else { return }
|
|
guard let strongSelf = self else { return }
|
|
//缓存已经用完,重新初始化缓存
|
|
//缓存已经用完,重新初始化缓存
|
|
if(strongSelf.filters.count == 0){
|
|
if(strongSelf.filters.count == 0){
|
|
- strongSelf.configCache()
|
|
|
|
|
|
+ strongSelf.configCache(beginTime: strongSelf.mStickers?.first?.timelineIn ?? 0)
|
|
}
|
|
}
|
|
|
|
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
@@ -421,8 +421,9 @@ public class PQGPUImagePlayerView: UIView {
|
|
applyFilters()
|
|
applyFilters()
|
|
}
|
|
}
|
|
|
|
|
|
- // 初始化缓存,默认选创建 cacheFiltersMaxCount 个缓存 filterrs
|
|
|
|
- func configCache() {
|
|
|
|
|
|
+ /// 初始化缓存,默认选创建 cacheFiltersMaxCount 个缓存 filterrs
|
|
|
|
+ /// - Parameter beginTime: 开始缓存的开始时间,用在 seek操作时 老的缓存已经无效不能在使用了
|
|
|
|
+ func configCache(beginTime: Float64 ) {
|
|
cacheFilters.removeAll()
|
|
cacheFilters.removeAll()
|
|
FilterLog(message: "原素材 总数:\(mStickers?.count ?? 0) ")
|
|
FilterLog(message: "原素材 总数:\(mStickers?.count ?? 0) ")
|
|
|
|
|
|
@@ -435,9 +436,13 @@ public class PQGPUImagePlayerView: UIView {
|
|
|
|
|
|
for (index, currentSticker) in mStickers!.enumerated() {
|
|
for (index, currentSticker) in mStickers!.enumerated() {
|
|
//到达最大缓存数退出
|
|
//到达最大缓存数退出
|
|
- if index == cacheFiltersMaxCount {
|
|
|
|
|
|
+ if cacheFilters.count == cacheFiltersMaxCount {
|
|
break
|
|
break
|
|
}
|
|
}
|
|
|
|
+ //小于缓存的开始时间继续查找
|
|
|
|
+ if(currentSticker.timelineOut < beginTime){
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
var showFitler: PQBaseFilter?
|
|
var showFitler: PQBaseFilter?
|
|
if currentSticker.type == StickerType.VIDEO.rawValue {
|
|
if currentSticker.type == StickerType.VIDEO.rawValue {
|
|
showFitler = PQMovieFilter(movieSticker: currentSticker)
|
|
showFitler = PQMovieFilter(movieSticker: currentSticker)
|