简体   繁体   English

如何在SurfaceView / View中使用RenderScript

[英]How to use RenderScript with SurfaceView/View

Latest Android SDK (R22) has removed android.renderscript.RSSurfaceView and android.renderscript.RenderScriptGL classes. 最新的Android SDK(R22)已删除android.renderscript.RSSurfaceViewandroid.renderscript.RenderScriptGL类。 How can we use RenderScript dirrectly on SurfaceView or regular Android View? 我们如何在SurfaceView或常规Android View上直接使用RenderScript?

Short answer: It's complicated. 简短回答:这很复杂。

Long answer: https://github.com/googlesamples/android-HdrViewfinder 答案很长: https//github.com/googlesamples/android-HdrViewfinder

They seem to make an RGBA allocation: 他们似乎做了一个RGBA分配:

    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. 然后从SurfaceView持有者获取一个曲面以传递给分配。 Then they run some rs on it, and then call: 然后他们在上面运行一些rs,然后调用:

mOutputAllocation.ioSend();

for each frame... Check the code, seems there are some pitfalls there. 对于每一帧...检查代码,似乎有一些陷阱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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