Loading api/current.xml +55 −1 Original line number Diff line number Diff line Loading @@ -166391,6 +166391,60 @@ <parameter name="b" type="android.graphics.Bitmap"> </parameter> </method> <method name="createCubemapFromCubeFaces" return="android.renderscript.Allocation" abstract="false" native="false" synchronized="false" static="true" final="false" deprecated="not deprecated" visibility="public" > <parameter name="rs" type="android.renderscript.RenderScript"> </parameter> <parameter name="xpos" type="android.graphics.Bitmap"> </parameter> <parameter name="xneg" type="android.graphics.Bitmap"> </parameter> <parameter name="ypos" type="android.graphics.Bitmap"> </parameter> <parameter name="yneg" type="android.graphics.Bitmap"> </parameter> <parameter name="zpos" type="android.graphics.Bitmap"> </parameter> <parameter name="zneg" type="android.graphics.Bitmap"> </parameter> <parameter name="mips" type="android.renderscript.Allocation.MipmapControl"> </parameter> <parameter name="usage" type="int"> </parameter> </method> <method name="createCubemapFromCubeFaces" return="android.renderscript.Allocation" abstract="false" native="false" synchronized="false" static="true" final="false" deprecated="not deprecated" visibility="public" > <parameter name="rs" type="android.renderscript.RenderScript"> </parameter> <parameter name="xpos" type="android.graphics.Bitmap"> </parameter> <parameter name="xneg" type="android.graphics.Bitmap"> </parameter> <parameter name="ypos" type="android.graphics.Bitmap"> </parameter> <parameter name="yneg" type="android.graphics.Bitmap"> </parameter> <parameter name="zpos" type="android.graphics.Bitmap"> </parameter> <parameter name="zneg" type="android.graphics.Bitmap"> </parameter> </method> <method name="createFromBitmap" return="android.renderscript.Allocation" abstract="false" Loading Loading @@ -258064,7 +258118,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="t" type="T"> <parameter name="arg0" type="T"> </parameter> </method> </interface> graphics/java/android/renderscript/Allocation.java +64 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.renderscript; import java.io.IOException; import java.io.InputStream; import android.content.res.Resources; import android.content.res.AssetManager; import android.graphics.Bitmap; Loading Loading @@ -470,7 +469,7 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Cubemap height must be multiple of 6"); } if (width / 6 != height) { throw new RSIllegalArgumentException("Only square cobe map faces supported"); throw new RSIllegalArgumentException("Only square cube map faces supported"); } boolean isPow2 = (height & (height - 1)) == 0; if (!isPow2) { Loading @@ -492,11 +491,73 @@ public class Allocation extends BaseObj { return new Allocation(id, rs, t, usage); } static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b) { static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b) { return createCubemapFromBitmap(rs, b, MipmapControl.MIPMAP_NONE, USAGE_GRAPHICS_TEXTURE); } static public Allocation createCubemapFromCubeFaces(RenderScript rs, Bitmap xpos, Bitmap xneg, Bitmap ypos, Bitmap yneg, Bitmap zpos, Bitmap zneg, MipmapControl mips, int usage) { int height = xpos.getHeight(); if (xpos.getWidth() != height || xneg.getWidth() != height || xneg.getHeight() != height || ypos.getWidth() != height || ypos.getHeight() != height || yneg.getWidth() != height || yneg.getHeight() != height || zpos.getWidth() != height || zpos.getHeight() != height || zneg.getWidth() != height || zneg.getHeight() != height) { throw new RSIllegalArgumentException("Only square cube map faces supported"); } boolean isPow2 = (height & (height - 1)) == 0; if (!isPow2) { throw new RSIllegalArgumentException("Only power of 2 cube faces supported"); } Element e = elementFromBitmap(rs, xpos); Type.Builder tb = new Type.Builder(rs, e); tb.setX(height); tb.setY(height); tb.setFaces(true); tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL); Type t = tb.create(); Allocation cubemap = Allocation.createTyped(rs, t, mips, usage); AllocationAdapter adapter = AllocationAdapter.create2D(rs, cubemap); adapter.setFace(Type.CubemapFace.POSITVE_X); adapter.copyFrom(xpos); adapter.setFace(Type.CubemapFace.NEGATIVE_X); adapter.copyFrom(xneg); adapter.setFace(Type.CubemapFace.POSITVE_Y); adapter.copyFrom(ypos); adapter.setFace(Type.CubemapFace.NEGATIVE_Y); adapter.copyFrom(yneg); adapter.setFace(Type.CubemapFace.POSITVE_Z); adapter.copyFrom(zpos); adapter.setFace(Type.CubemapFace.NEGATIVE_Z); adapter.copyFrom(zneg); return cubemap; } static public Allocation createCubemapFromCubeFaces(RenderScript rs, Bitmap xpos, Bitmap xneg, Bitmap ypos, Bitmap yneg, Bitmap zpos, Bitmap zneg) { return createCubemapFromCubeFaces(rs, xpos, xneg, ypos, yneg, zpos, zneg, MipmapControl.MIPMAP_NONE, USAGE_GRAPHICS_TEXTURE); } static public Allocation createFromBitmapResource(RenderScript rs, Resources res, int id, Loading libs/rs/rsAllocation.cpp +24 −25 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ #include "utils/StopWatch.h" static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va); using namespace android; using namespace android::renderscript; Loading Loading @@ -699,13 +701,7 @@ void rsi_AllocationCopyFromBitmap(Context *rsc, RsAllocation va, const void *dat if (texAlloc->getIsScript()) { memcpy(texAlloc->getPtr(), data, s); if (genMips) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { adapt.setLOD(lod); adapt2.setLOD(lod + 1); mip(adapt2, adapt); } rsaAllocationGenerateScriptMips(rsc, texAlloc); } } else { texAlloc->upload2DTexture(false, data); Loading Loading @@ -770,6 +766,23 @@ void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32 } } static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va) { Context *rsc = static_cast<Context *>(con); Allocation *texAlloc = static_cast<Allocation *>(va); uint32_t numFaces = texAlloc->getType()->getDimFaces() ? 6 : 1; for (uint32_t face = 0; face < numFaces; face ++) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); adapt.setFace(face); adapt2.setFace(face); for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { adapt.setLOD(lod); adapt2.setLOD(lod + 1); mip(adapt2, adapt); } } } const void * rsaAllocationGetType(RsContext con, RsAllocation va) { Allocation *a = static_cast<Allocation *>(va); a->getType()->incUserRef(); Loading Loading @@ -802,13 +815,7 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, memcpy(texAlloc->getPtr(), data, t->getDimX() * t->getDimY() * t->getElementSizeBytes()); if (mips == RS_ALLOCATION_MIPMAP_FULL) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { adapt.setLOD(lod); adapt2.setLOD(lod + 1); mip(adapt2, adapt); } rsaAllocationGenerateScriptMips(rsc, texAlloc); } texAlloc->deferedUploadToTexture(rsc); Loading Loading @@ -846,18 +853,10 @@ RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, // Move the data pointer to the next cube face sourcePtr += copySize; } if (mips == RS_ALLOCATION_MIPMAP_FULL) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); adapt.setFace(face); adapt2.setFace(face); for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { adapt.setLOD(lod); adapt2.setLOD(lod + 1); mip(adapt2, adapt); } } rsaAllocationGenerateScriptMips(rsc, texAlloc); } texAlloc->deferedUploadToTexture(rsc); Loading Loading
api/current.xml +55 −1 Original line number Diff line number Diff line Loading @@ -166391,6 +166391,60 @@ <parameter name="b" type="android.graphics.Bitmap"> </parameter> </method> <method name="createCubemapFromCubeFaces" return="android.renderscript.Allocation" abstract="false" native="false" synchronized="false" static="true" final="false" deprecated="not deprecated" visibility="public" > <parameter name="rs" type="android.renderscript.RenderScript"> </parameter> <parameter name="xpos" type="android.graphics.Bitmap"> </parameter> <parameter name="xneg" type="android.graphics.Bitmap"> </parameter> <parameter name="ypos" type="android.graphics.Bitmap"> </parameter> <parameter name="yneg" type="android.graphics.Bitmap"> </parameter> <parameter name="zpos" type="android.graphics.Bitmap"> </parameter> <parameter name="zneg" type="android.graphics.Bitmap"> </parameter> <parameter name="mips" type="android.renderscript.Allocation.MipmapControl"> </parameter> <parameter name="usage" type="int"> </parameter> </method> <method name="createCubemapFromCubeFaces" return="android.renderscript.Allocation" abstract="false" native="false" synchronized="false" static="true" final="false" deprecated="not deprecated" visibility="public" > <parameter name="rs" type="android.renderscript.RenderScript"> </parameter> <parameter name="xpos" type="android.graphics.Bitmap"> </parameter> <parameter name="xneg" type="android.graphics.Bitmap"> </parameter> <parameter name="ypos" type="android.graphics.Bitmap"> </parameter> <parameter name="yneg" type="android.graphics.Bitmap"> </parameter> <parameter name="zpos" type="android.graphics.Bitmap"> </parameter> <parameter name="zneg" type="android.graphics.Bitmap"> </parameter> </method> <method name="createFromBitmap" return="android.renderscript.Allocation" abstract="false" Loading Loading @@ -258064,7 +258118,7 @@ deprecated="not deprecated" visibility="public" > <parameter name="t" type="T"> <parameter name="arg0" type="T"> </parameter> </method> </interface>
graphics/java/android/renderscript/Allocation.java +64 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.renderscript; import java.io.IOException; import java.io.InputStream; import android.content.res.Resources; import android.content.res.AssetManager; import android.graphics.Bitmap; Loading Loading @@ -470,7 +469,7 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Cubemap height must be multiple of 6"); } if (width / 6 != height) { throw new RSIllegalArgumentException("Only square cobe map faces supported"); throw new RSIllegalArgumentException("Only square cube map faces supported"); } boolean isPow2 = (height & (height - 1)) == 0; if (!isPow2) { Loading @@ -492,11 +491,73 @@ public class Allocation extends BaseObj { return new Allocation(id, rs, t, usage); } static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b) { static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b) { return createCubemapFromBitmap(rs, b, MipmapControl.MIPMAP_NONE, USAGE_GRAPHICS_TEXTURE); } static public Allocation createCubemapFromCubeFaces(RenderScript rs, Bitmap xpos, Bitmap xneg, Bitmap ypos, Bitmap yneg, Bitmap zpos, Bitmap zneg, MipmapControl mips, int usage) { int height = xpos.getHeight(); if (xpos.getWidth() != height || xneg.getWidth() != height || xneg.getHeight() != height || ypos.getWidth() != height || ypos.getHeight() != height || yneg.getWidth() != height || yneg.getHeight() != height || zpos.getWidth() != height || zpos.getHeight() != height || zneg.getWidth() != height || zneg.getHeight() != height) { throw new RSIllegalArgumentException("Only square cube map faces supported"); } boolean isPow2 = (height & (height - 1)) == 0; if (!isPow2) { throw new RSIllegalArgumentException("Only power of 2 cube faces supported"); } Element e = elementFromBitmap(rs, xpos); Type.Builder tb = new Type.Builder(rs, e); tb.setX(height); tb.setY(height); tb.setFaces(true); tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL); Type t = tb.create(); Allocation cubemap = Allocation.createTyped(rs, t, mips, usage); AllocationAdapter adapter = AllocationAdapter.create2D(rs, cubemap); adapter.setFace(Type.CubemapFace.POSITVE_X); adapter.copyFrom(xpos); adapter.setFace(Type.CubemapFace.NEGATIVE_X); adapter.copyFrom(xneg); adapter.setFace(Type.CubemapFace.POSITVE_Y); adapter.copyFrom(ypos); adapter.setFace(Type.CubemapFace.NEGATIVE_Y); adapter.copyFrom(yneg); adapter.setFace(Type.CubemapFace.POSITVE_Z); adapter.copyFrom(zpos); adapter.setFace(Type.CubemapFace.NEGATIVE_Z); adapter.copyFrom(zneg); return cubemap; } static public Allocation createCubemapFromCubeFaces(RenderScript rs, Bitmap xpos, Bitmap xneg, Bitmap ypos, Bitmap yneg, Bitmap zpos, Bitmap zneg) { return createCubemapFromCubeFaces(rs, xpos, xneg, ypos, yneg, zpos, zneg, MipmapControl.MIPMAP_NONE, USAGE_GRAPHICS_TEXTURE); } static public Allocation createFromBitmapResource(RenderScript rs, Resources res, int id, Loading
libs/rs/rsAllocation.cpp +24 −25 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ #include "utils/StopWatch.h" static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va); using namespace android; using namespace android::renderscript; Loading Loading @@ -699,13 +701,7 @@ void rsi_AllocationCopyFromBitmap(Context *rsc, RsAllocation va, const void *dat if (texAlloc->getIsScript()) { memcpy(texAlloc->getPtr(), data, s); if (genMips) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { adapt.setLOD(lod); adapt2.setLOD(lod + 1); mip(adapt2, adapt); } rsaAllocationGenerateScriptMips(rsc, texAlloc); } } else { texAlloc->upload2DTexture(false, data); Loading Loading @@ -770,6 +766,23 @@ void rsi_AllocationResize2D(Context *rsc, RsAllocation va, uint32_t dimX, uint32 } } static void rsaAllocationGenerateScriptMips(RsContext con, RsAllocation va) { Context *rsc = static_cast<Context *>(con); Allocation *texAlloc = static_cast<Allocation *>(va); uint32_t numFaces = texAlloc->getType()->getDimFaces() ? 6 : 1; for (uint32_t face = 0; face < numFaces; face ++) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); adapt.setFace(face); adapt2.setFace(face); for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { adapt.setLOD(lod); adapt2.setLOD(lod + 1); mip(adapt2, adapt); } } } const void * rsaAllocationGetType(RsContext con, RsAllocation va) { Allocation *a = static_cast<Allocation *>(va); a->getType()->incUserRef(); Loading Loading @@ -802,13 +815,7 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, memcpy(texAlloc->getPtr(), data, t->getDimX() * t->getDimY() * t->getElementSizeBytes()); if (mips == RS_ALLOCATION_MIPMAP_FULL) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { adapt.setLOD(lod); adapt2.setLOD(lod + 1); mip(adapt2, adapt); } rsaAllocationGenerateScriptMips(rsc, texAlloc); } texAlloc->deferedUploadToTexture(rsc); Loading Loading @@ -846,18 +853,10 @@ RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, // Move the data pointer to the next cube face sourcePtr += copySize; } if (mips == RS_ALLOCATION_MIPMAP_FULL) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); adapt.setFace(face); adapt2.setFace(face); for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { adapt.setLOD(lod); adapt2.setLOD(lod + 1); mip(adapt2, adapt); } } rsaAllocationGenerateScriptMips(rsc, texAlloc); } texAlloc->deferedUploadToTexture(rsc); Loading