简体   繁体   中英

How to use RenderScript with SurfaceView/View

Latest Android SDK (R22) has removed android.renderscript.RSSurfaceView and android.renderscript.RenderScriptGL classes. How can we use RenderScript dirrectly on SurfaceView or regular Android View?

Short answer: It's complicated.

Long answer: https://github.com/googlesamples/android-HdrViewfinder

They seem to make an RGBA allocation:

    Type.Builder rgbTypeBuilder = new Type.Builder(rs, Element.RGBA_8888(rs));
    rgbTypeBuilder.setX(dimensions.getWidth());
    rgbTypeBuilder.setY(dimensions.getHeight());
    mOutputAllocation = Allocation.createTyped(rs, rgbTypeBuilder.create(),
            Allocation.USAGE_IO_OUTPUT | Allocation.USAGE_SCRIPT);

Then get a surface from a SurfaceView holder to pass to the allocation. Then they run some rs on it, and then call:

mOutputAllocation.ioSend();

for each frame... Check the code, seems there are some pitfalls there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM