BradLarson / GPUImage2

GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.
BSD 3-Clause "New" or "Revised" License
4.85k stars 605 forks source link

Changed Framebuffer Caching to work under ARC by using Framebuffer.Core class and removed unnecessary methods and properties #208

Closed purpleblues closed 6 years ago

purpleblues commented 6 years ago

I modified Framebuffer to support caching mechanism under ARC(Automatic Reference Counting) by using hidden core framebuffer class (Framebuffer.Core in Framebuffer.swift).

The way this works is that FramebufferCache caches only the Framebuffer.Core object and returns the wrapped Framebuffer object.

Framebuffer object has deinit() methods that returns the internal Framebuffer.Core object to cache if it exists. This way the framebuffer is safely returned to the cache when it is not referenced without worrying about locking/unlocking.

Framebuffer class redirects all the methods and variable properties to the internal Framebuffer.Core object and has same constant properties with it.

lock(), unlock(), resetRetainCount(), framebufferRetainCount are removed accordingly.