Gpuimage is now the most mainstream open source framework for iOS filters. The author Bradlarson the image processing unit based on OpenGL to provide the Gpuimagefilter base class, with shader, common filters are not the problem. There are several concepts in Gpuimage:
? Output, source
? Intput, input source
? Filter, Filter
So a complete filter processing flow is: output+x+input , X is the group of filters (1+ filters). Gpuimage for convenience, the new version provides Gpuimagefilterpipeline, which allows users to use multiple filter combinations without worrying about the chain logic before and after.
gpuimage separates the image filter processing from the live filter, and the dynamic filter is based on the process above, but the picture processing is (output+filter) *x + Input this logic. If the effect of processing a picture requires multiple combinations of filters, a filter is used to generate a picture output, and then passed to the next filter processing, the process if the filter overlay more times, or the filter effect is called multiple times, so that the memory consumption is particularly large, The exported image output after each filter processing is in memory, and if the original is particularly large, the memory is estimated to explode.
Output+x+input This mode to handle, so the code logic is single, high efficiency, eat less memory. Read the source know output +x+ input, when X is multiple, last filter n processed texture, there is GPU memory, the GPU directly passes this texture to n+1 as its output, so that the entire filter process down, only one texture memory occupied.
< Span class= "token p" style= "color: #5a5a5a; font-family: ' Microsoft Yahei '; font-size:18px; line-height:29px; White-space:pre-wrap; Outline:none!important; " > with this line to go, the process of basic no problem encountered, but the code structure design and packaging time-consuming. Project, found that the filter module after the call, memory went down, repeated checks, all gpuimage related elements have been released. Later thought of the video memory, ARC environment, only responsible for recycling OC object memory, video memory naturally need to gpuimage users to recycle, so it is easy, turn Gpuimage API, know
There is a framebuffercache in Gpuimagecontext:
[[Gpuimagecontextsharedimageprocessingcontext]. Framebuffercachepurgeallunassignedframebuffers].
iOS third-party make filters the most mainstream open source framework Gpuimage