Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

GPUImagePicture: don't redraw using CoreGraphics unless you have to #1267

Merged
merged 2 commits into from Nov 4, 2013

Conversation

Projects
None yet
2 participants
Contributor

karlvr commented Oct 17, 2013

There was support for this but it appeared to have been disabled. I've tested this in my project and it seems to still work as expected, and significantly reduces memory usage by not needing to redraw these graphics. I think was just a typo.

@karlvr karlvr GPUImagePicture: don't redraw using CoreGraphics unless you have to
There was support for this but it appeared to have been disabled.
08d1521
Owner

BradLarson commented Oct 17, 2013

I disabled that for a while, because it was actually slower in my benchmarks (and produced no memory reduction), while potentially being more fragile (it's possible that input images won't align to the image properties that I specify there).

I've since heard that this is more performant and may avoid issues with premultiplied alpha, but I'm still concerned about the possibility that this will break with certain images. See Tyler's comment for a little background on this: http://stackoverflow.com/questions/448125/how-to-get-pixel-data-from-a-uiimage-cocoa-touch-or-cgimage-core-graphics/1247963#comment3435194_1247963

If I was sure that this would work with all images, I'd accept this.

Contributor

karlvr commented Oct 17, 2013

Right, interesting. It does use memory - you can see it more easily now with Instruments in Xcode 5 in the anonymous vm section.

Can we check the bitmap properties of the supplied CGImage to see if it's compatible, I wonder? We could then consider that a fast-pass that is activated sometimes?

Can you point me to the GL requirements for the image? I will write and test that code if you think it is possible!

Sent from my iPhone

On 17/10/2013, at 10:20 am, Brad Larson notifications@github.com wrote:

I disabled that for a while, because it was actually slower in my benchmarks (and produced no memory reduction), while potentially being more fragile (it's possible that input images won't align to the image properties that I specify there).

I've since heard that this is more performant and may avoid issues with premultiplied alpha, but I'm still concerned about the possibility that this will break with certain images. See Tyler's comment for a little background on this: http://stackoverflow.com/questions/448125/how-to-get-pixel-data-from-a-uiimage-cocoa-touch-or-cgimage-core-graphics/1247963#comment3435194_1247963

If I was sure that this would work with all images, I'd accept this.


Reply to this email directly or view it on GitHub.

Owner

BradLarson commented Oct 18, 2013

It sounds like byte order (BGRA vs. RGBA) and the presence or absence of an alpha channel are the big ones. The texture format that the image was uploaded into could be adjusted based on these parameters, if we could determine what they were. I'm pretty sure there's a way to extract that, but I don't have it in front of me now.

Contributor

karlvr commented Oct 19, 2013

Cool, no problem. I know how to do that and I have started playing around with it. It looks like the most important to support will be RGBA and perhaps RGBX.

On 18/10/2013, at 2:28 pm, Brad Larson notifications@github.com wrote:

It sounds like byte order (BGRA vs. RGBA) and the presence or absence of an alpha channel are the big ones. The texture format that the image was uploaded into could be adjusted based on these parameters, if we could determine what they were. I'm pretty sure there's a way to extract that, but I don't have it in front of me now.


Reply to this email directly or view it on GitHub.

@karlvr karlvr GPUImagePicture: only access image bytes directly if the bitmap byte …
…order and format is compatible with GL

This correct non-redrawing for JPGs from my previous commit, as they are big endian.
62c8311
Contributor

karlvr commented Oct 20, 2013

Please see the latest commit. I have tested this particularly with JPG files supplied to GPUImagePicture and this works great.

@BradLarson BradLarson added a commit that referenced this pull request Nov 4, 2013

@BradLarson BradLarson Merge pull request #1267 from karlvr/gpuimagepicture-redraw
GPUImagePicture: don't redraw using CoreGraphics unless you have to
b662c2e

@BradLarson BradLarson merged commit b662c2e into BradLarson:master Nov 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment