Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PixelCopy for surface, main-thread bugfix, Optimized stack for API-31 instead of renderScript (from other pull-request by KaustubhsPatangnse) #120

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

arberg
Copy link

@arberg arberg commented Mar 11, 2022

From the new readme:

On API-26 and newer, Blurry uses PixelCopy to copy directly from the surface of the window,
and can thus obtain a bitmap that contains a GoogleMap. Blurry automatically use PixelCopy when using
Blurry.with(activity) instead of the deprecated Blurry.with(context).

Bugfix:
The old code of applied the Blur.of work inside main-thread, which completely negated the intention of the task. I move the blur-job out-side main.

I did some performance tests on the optimized stack (se by branch performance-test), executed on Samsung S20 FE, running API-31 = Android-12.

Performance test with 200 executions and with sampling factor 1: 
Runtime Original Stack average: 123ms
Runtime RS average: 33ms
Runtime optimized SingleThreaded average: 58ms when split into 0 jobs
Runtime optimized MultiThreaded average: 61ms when split into 8 jobs (bad image)
Runtime optimized MultiThreaded2 average: 43ms when split into 40 jobs (bad image)
Runtime optimized MultiThreaded3 average: 45ms when split into 80 jobs (bad image)

The code by KaustubhsPatangnse did not go multi-threaded. I implemented that but then the image contained errors. So the code I have pushed does not use the multi-threaded, but I left the code in, in case someone will fix it. So for the above runtimes we should ignore multithreaded. For singleThreaded its clearly faster than the original stack implementation and slower than RS on this hardware accelerated device. But the hardware acceleration is said to vanish on future devices.

…failed, for instance because surface not ready. Extracted PixelCopy listener variable, so the try-catch is easier to read.
…sed internally in Blurry and does not live longer than the executing method
@arberg
Copy link
Author

arberg commented Jul 25, 2022

I've updated the code today, fixing a bug where the activity surface wasn't ready yet, and also cleaning up the new code a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants