设为首页 加入收藏

TOP

GPUImage API文档之GPUImageFramebufferCache类(四)
2017-10-11 16:34:47 】 浏览:10170
Tags:GPUImage API 文档 GPUImageFramebufferCache
alloc] initWithSize:framebufferSize textureOptions:textureOptions onlyTexture:onlyTexture]; }
else { // Something found, pull the old framebuffer and decrement the count NSInteger currentTextureID = (numberOfMatchingTextures - 1); while ((framebufferFromCache == nil) && (currentTextureID >= 0)) { NSString *textureHash = [NSString stringWithFormat:@"%@-%ld", lookupHash, (long)currentTextureID]; framebufferFromCache = [framebufferCache objectForKey:textureHash]; // Test the values in the cache first, to see if they got invalidated behind our back if (framebufferFromCache != nil) { // Withdraw this from the cache while it's in use [framebufferCache removeObjectForKey:textureHash]; } currentTextureID--; } currentTextureID++; [framebufferTypeCounts setObject:[NSNumber numberWithInteger:currentTextureID] forKey:lookupHash]; if (framebufferFromCache == nil) { framebufferFromCache = [[GPUImageFramebuffer alloc] initWithSize:framebufferSize textureOptions:textureOptions onlyTexture:onlyTexture]; } } }); [framebufferFromCache lock]; return framebufferFromCache; } - (GPUImageFramebuffer *)fetchFramebufferForSize:(CGSize)framebufferSize onlyTexture:(BOOL)onlyTexture; { GPUTextureOptions defaultTextureOptions; defaultTextureOptions.minFilter = GL_LINEAR; defaultTextureOptions.magFilter = GL_LINEAR; defaultTextureOptions.wrapS = GL_CLAMP_TO_EDGE; defaultTextureOptions.wrapT = GL_CLAMP_TO_EDGE; defaultTextureOptions.internalFormat = GL_RGBA; defaultTextureOptions.format = GL_BGRA; defaultTextureOptions.type = GL_UNSIGNED_BYTE; return [self fetchFramebufferForSize:framebufferSize textureOptions:defaultTextureOptions onlyTexture:onlyTexture]; } - (void)returnFramebufferToCache:(GPUImageFramebuffer *)framebuffer; { [framebuffer clearAllLocks]; // dispatch_async(framebufferCacheQueue, ^{ runAsynchronouslyOnVideoProcessingQueue(^{ CGSize framebufferSize = framebuffer.size; GPUTextureOptions framebufferTextureOptions = framebuffer.textureOptions; NSString *lookupHash = [self hashForSize:framebufferSize textureOptions:framebufferTextureOptions onlyTexture:framebuffer.missingFramebuffer]; NSNumber *numberOfMatchingTexturesInCache = [framebufferTypeCounts objectForKey:lookupHash]; NSInteger numberOfMatchingTextures = [numberOfMatchingTexturesInCache integerValue]; NSString *textureHash = [NSString stringWithFormat:@"%@-%ld", lookupHash, (long)numberOfMatchingTextures]; // [framebufferCache setObject:framebuffer forKey:textureHash cost:round(framebufferSize.width * framebufferSize.height * 4.0)]; [framebufferCache setObject:framebuffer forKey:textureHash]; [framebufferTypeCounts setObject:[NSNumber numberWithInteger:(numberOfMatchingTextures + 1)] forKey:lookupHash]; }); } - (void)purgeAllUnassignedFramebuffers; { runAsynchronouslyOnVideoProcessingQueue(^{ // dispatch_async(framebufferCacheQueue, ^{ [framebufferCache removeAllObjects]; [framebufferTypeCounts removeAllObjects]; #if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE CVOpenGLESTextureCacheFlush([[GPUImageContext sharedImageProcessingContext] coreVideo
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇iOS支付宝集成详细流程 下一篇iOS应用发布中的一些细节

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目