• Home
Name Date Size #Lines LOC

..--

gradle/wrapper/03-May-2024-76

renderscript-toolkit/03-May-2024-19,00213,256

test-app/03-May-2024-4,3623,304

.gitignoreD03-May-2024101 1110

Android.bpD03-May-20241.7 KiB5752

CONTRIBUTING.mdD03-May-20241.1 KiB2920

LICENSED03-May-202411.1 KiB203169

METADATAD03-May-2024719 2219

MODULE_LICENSE_APACHE2D03-May-20240

NOTICED03-May-202411.1 KiB203169

OWNERSD03-May-202465 32

README.mdD03-May-20243.5 KiB7754

build.gradleD03-May-2024653 2723

gradle.propertiesD03-May-20241.1 KiB1919

gradlewD03-May-20245.2 KiB173128

gradlew.batD03-May-20242.2 KiB8561

settings.gradleD03-May-2024117 43

README.md

1# RenderScript Intrinsics Replacement Toolkit - v0.8 BETA
2
3This Toolkit provides a collection of high-performance image manipulation functions
4like blur, blend, and resize. It can be used as a stand-alone replacement for most
5of the deprecated RenderScript Intrinsics functions.
6
7The Toolkit provides ten image manipulation functions:
8* blend,
9* blur,
10* color matrix,
11* convolve,
12* histogram and histogramDot,
13* LUT (lookup table) and LUT 3D,
14* resize, and
15* YUV to RGB.
16
17The Toolkit provides a C++ and a Java/Kotlin interface. It is packaged as an Android
18library that you can add to your project.
19
20These functions execute multithreaded on the CPU. They take advantage of Neon/AdvSimd
21on Arm processors and SSE on Intel's.
22
23Compared to the RenderScript Intrinsics, this Toolkit is simpler to use and twice as fast
24when executing on the CPU. However RenderScript Intrinsics allow more flexibility for
25the type of allocations supported. This toolkit does not support allocations of floats;
26most the functions support ByteArrays and Bitmaps.
27
28You should instantiate the Toolkit once and reuse it throughout your application.
29On instantiation, the Toolkit creates a thread pool that's used for processing all the functions.
30You can limit the number of poolThreads used by the Toolkit via the constructor. The poolThreads
31are destroyed once the Toolkit is destroyed, after any pending work is done.
32
33This library is thread safe. You can call methods from different poolThreads. The functions will
34execute sequentially.
35
36
37## Future improvement ideas:
38
39* Turn the Java version of the Toolkit into a singleton, to reduce the chance that someone inadventarly
40create multiple threadpools.
41
42* Support ByteBuffer. It should be straightforward to use GetDirectBufferAddress in JniEntryPoints.cpp.
43See https://developer.android.com/training/articles/perf-jni and jni_helper.h.
44
45* The RenderScript Intrinsics support floats for colorMatrix, convolve, and resize. The Toolkit does not.
46
47* Allow in place update of buffers, or writing to an existing byte array.
48
49* For Blur, we could have a version that accepts a mask. This is commonly used for background
50blurring. We should allow the mask to be smaller than the original, since neural networks models
51that do segmentation are downscaled.
52
53* Allow yuvToRgb to have a Restriction.
54
55* Add support for YUV_420_888, the YUV format favored by Camera2. Allow various strides to be specified.
56
57* When passing a Restriction, it would be nice to say "Create a smaller output".
58The original RenderScript does not allow that. It's not that useful when outputing new buffers as
59our Java library does.
60
61* For Resize, Restriction working on input buffer would be more useful but that's not RenderScript.
62
63* Integrate and test with imageprocessing_jb. Do the same for [github/renderscript-samples/](https://github.com/android/renderscript-samples/tree/main/RenderScriptIntrinsic)
64
65* Allow Bitmaps with rowSize != width * vectorSize. We could do this also for ByteArray.
66
67- In TaskProcessor.cpp, the code below is fine and clean, but probably a bit inefficient.
68When this wakes up another thread, it may have to immediately go back to sleep, since we still hold the lock.
69It could instead set a need_to_notify flag and test that after releasing the lock (both places).
70That might avoid some context switches.
71```cpp
72if (mTilesInProcess == 0 && mTilesNotYetStarted == 0) {
73    mWorkIsFinished.notify_one();
74```
75
76* When compiled as part of Android, librenderscript_toolkit.so is 101,456 bytes. When compiled by Android Studio as part of an .aar, it's 387K. Figure out why and slim it down.
77