Skip to content

Commit

Permalink
Unhiding J API's for Renderscript.
Browse files Browse the repository at this point in the history
Change-Id: I8c2d43ccca94549bc6ca1a914106567ccc125503
  • Loading branch information
Alex Sakhartchouk committed Apr 11, 2012
1 parent 5713c9c commit 918e840
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 112 deletions.
43 changes: 43 additions & 0 deletions api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17994,15 +17994,24 @@ package android.renderscript {
method public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type, int);
method public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type);
method public void generateMipmaps();
method public int getBytesSize();
method public android.renderscript.Element getElement();
method public android.view.Surface getSurface();
method public android.renderscript.Type getType();
method public int getUsage();
method public void ioReceive();
method public void ioSend();
method public synchronized void resize(int);
method public void setFromFieldPacker(int, android.renderscript.FieldPacker);
method public void setFromFieldPacker(int, int, android.renderscript.FieldPacker);
method public void setSurface(android.view.Surface);
method public void syncAll(int);
field public static final int USAGE_GRAPHICS_CONSTANTS = 8; // 0x8
field public static final int USAGE_GRAPHICS_RENDER_TARGET = 16; // 0x10
field public static final int USAGE_GRAPHICS_TEXTURE = 2; // 0x2
field public static final int USAGE_GRAPHICS_VERTEX = 4; // 0x4
field public static final int USAGE_IO_INPUT = 32; // 0x20
field public static final int USAGE_IO_OUTPUT = 64; // 0x40
field public static final int USAGE_SCRIPT = 1; // 0x1
}

Expand Down Expand Up @@ -18141,6 +18150,15 @@ package android.renderscript {
method public static android.renderscript.Element U8_4(android.renderscript.RenderScript);
method public static android.renderscript.Element createPixel(android.renderscript.RenderScript, android.renderscript.Element.DataType, android.renderscript.Element.DataKind);
method public static android.renderscript.Element createVector(android.renderscript.RenderScript, android.renderscript.Element.DataType, int);
method public int getBytesSize();
method public android.renderscript.Element.DataKind getDataKind();
method public android.renderscript.Element.DataType getDataType();
method public android.renderscript.Element getSubElement(int);
method public int getSubElementArraySize(int);
method public int getSubElementCount();
method public java.lang.String getSubElementName(int);
method public int getSubElementOffsetBytes(int);
method public int getVectorSize();
method public boolean isCompatible(android.renderscript.Element);
method public boolean isComplex();
}
Expand Down Expand Up @@ -18173,6 +18191,7 @@ package android.renderscript {
enum_constant public static final android.renderscript.Element.DataType MATRIX_2X2;
enum_constant public static final android.renderscript.Element.DataType MATRIX_3X3;
enum_constant public static final android.renderscript.Element.DataType MATRIX_4X4;
enum_constant public static final android.renderscript.Element.DataType NONE;
enum_constant public static final android.renderscript.Element.DataType RS_ALLOCATION;
enum_constant public static final android.renderscript.Element.DataType RS_ELEMENT;
enum_constant public static final android.renderscript.Element.DataType RS_MESH;
Expand Down Expand Up @@ -18487,12 +18506,18 @@ package android.renderscript {
method public void bindConstants(android.renderscript.Allocation, int);
method public void bindSampler(android.renderscript.Sampler, int) throws java.lang.IllegalArgumentException;
method public void bindTexture(android.renderscript.Allocation, int) throws java.lang.IllegalArgumentException;
method public android.renderscript.Type getConstant(int);
method public int getConstantCount();
method public int getTextureCount();
method public java.lang.String getTextureName(int);
method public android.renderscript.Program.TextureType getTextureType(int);
}

public static class Program.BaseProgramBuilder {
ctor protected Program.BaseProgramBuilder(android.renderscript.RenderScript);
method public android.renderscript.Program.BaseProgramBuilder addConstant(android.renderscript.Type) throws java.lang.IllegalStateException;
method public android.renderscript.Program.BaseProgramBuilder addTexture(android.renderscript.Program.TextureType) throws java.lang.IllegalArgumentException;
method public android.renderscript.Program.BaseProgramBuilder addTexture(android.renderscript.Program.TextureType, java.lang.String) throws java.lang.IllegalArgumentException;
method public int getCurrentConstantIndex();
method public int getCurrentTextureIndex();
method protected void initProgram(android.renderscript.Program);
Expand Down Expand Up @@ -18548,6 +18573,8 @@ package android.renderscript {
method public static android.renderscript.ProgramRaster CULL_BACK(android.renderscript.RenderScript);
method public static android.renderscript.ProgramRaster CULL_FRONT(android.renderscript.RenderScript);
method public static android.renderscript.ProgramRaster CULL_NONE(android.renderscript.RenderScript);
method public android.renderscript.ProgramRaster.CullMode getCullMode();
method public boolean isPointSpriteEnabled();
}

public static class ProgramRaster.Builder {
Expand All @@ -18570,6 +18597,15 @@ package android.renderscript {
method public static android.renderscript.ProgramStore BLEND_ALPHA_DEPTH_TEST(android.renderscript.RenderScript);
method public static android.renderscript.ProgramStore BLEND_NONE_DEPTH_NONE(android.renderscript.RenderScript);
method public static android.renderscript.ProgramStore BLEND_NONE_DEPTH_TEST(android.renderscript.RenderScript);
method public android.renderscript.ProgramStore.BlendDstFunc getBlendDstFunc();
method public android.renderscript.ProgramStore.BlendSrcFunc getBlendSrcFunc();
method public android.renderscript.ProgramStore.DepthFunc getDepthFunc();
method public boolean isColorMaskAlphaEnabled();
method public boolean isColorMaskBlueEnabled();
method public boolean isColorMaskGreenEnabled();
method public boolean isColorMaskRedEnabled();
method public boolean isDepthMaskEnabled();
method public boolean isDitherEnabled();
}

public static final class ProgramStore.BlendDstFunc extends java.lang.Enum {
Expand Down Expand Up @@ -18622,6 +18658,8 @@ package android.renderscript {
}

public class ProgramVertex extends android.renderscript.Program {
method public android.renderscript.Element getInput(int);
method public int getInputCount();
}

public static class ProgramVertex.Builder extends android.renderscript.Program.BaseProgramBuilder {
Expand Down Expand Up @@ -18759,6 +18797,11 @@ package android.renderscript {
method public static android.renderscript.Sampler WRAP_LINEAR(android.renderscript.RenderScript);
method public static android.renderscript.Sampler WRAP_LINEAR_MIP_LINEAR(android.renderscript.RenderScript);
method public static android.renderscript.Sampler WRAP_NEAREST(android.renderscript.RenderScript);
method public float getAnisotropy();
method public android.renderscript.Sampler.Value getMagnification();
method public android.renderscript.Sampler.Value getMinification();
method public android.renderscript.Sampler.Value getWrapS();
method public android.renderscript.Sampler.Value getWrapT();
}

public static class Sampler.Builder {
Expand Down
80 changes: 27 additions & 53 deletions graphics/java/android/renderscript/Allocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public class Allocation extends BaseObj {
* consumer. This usage will cause the allocation to be created
* read only.
*
* @hide
*/
public static final int USAGE_IO_INPUT = 0x0020;

Expand All @@ -145,7 +144,6 @@ public class Allocation extends BaseObj {
* SurfaceTexture producer. The dimensions and format of the
* SurfaceTexture will be forced to those of the allocation.
*
* @hide
*/
public static final int USAGE_IO_OUTPUT = 0x0040;

Expand Down Expand Up @@ -193,8 +191,8 @@ private int getIDSafe() {
/**
* Get the element of the type of the Allocation.
*
* @hide
* @return Element
* @return Element that describes the structure of data in the
* allocation
*
*/
public Element getElement() {
Expand All @@ -204,8 +202,8 @@ public Element getElement() {
/**
* Get the usage flags of the Allocation.
*
* @hide
* @return usage
* @return usage flags associated with the allocation. e.g.
* script, texture, etc.
*
*/
public int getUsage() {
Expand All @@ -215,12 +213,11 @@ public int getUsage() {
/**
* Get the size of the Allocation in bytes.
*
* @hide
* @return sizeInBytes
* @return size of the Allocation in bytes.
*
*/
public int getSizeBytes() {
return mType.getCount() * mType.getElement().getSizeBytes();
public int getBytesSize() {
return mType.getCount() * mType.getElement().getBytesSize();
}

private void updateCacheInfo(Type t) {
Expand Down Expand Up @@ -362,8 +359,6 @@ public void syncAll(int srcLocation) {
* Send a buffer to the output stream. The contents of the
* Allocation will be undefined after this operation.
*
* @hide
*
*/
public void ioSend() {
if ((mUsage & USAGE_IO_OUTPUT) == 0) {
Expand All @@ -385,8 +380,6 @@ public void ioSendOutput() {
/**
* Receive the latest input into the Allocation.
*
* @hide
*
*/
public void ioReceive() {
if ((mUsage & USAGE_IO_INPUT) == 0) {
Expand Down Expand Up @@ -424,37 +417,37 @@ private void validateBitmapFormat(Bitmap b) {
throw new RSIllegalArgumentException("Allocation kind is " +
mType.getElement().mKind + ", type " +
mType.getElement().mType +
" of " + mType.getElement().getSizeBytes() +
" of " + mType.getElement().getBytesSize() +
" bytes, passed bitmap was " + bc);
}
break;
case ARGB_8888:
if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) ||
(mType.getElement().getSizeBytes() != 4)) {
(mType.getElement().getBytesSize() != 4)) {
throw new RSIllegalArgumentException("Allocation kind is " +
mType.getElement().mKind + ", type " +
mType.getElement().mType +
" of " + mType.getElement().getSizeBytes() +
" of " + mType.getElement().getBytesSize() +
" bytes, passed bitmap was " + bc);
}
break;
case RGB_565:
if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGB) ||
(mType.getElement().getSizeBytes() != 2)) {
(mType.getElement().getBytesSize() != 2)) {
throw new RSIllegalArgumentException("Allocation kind is " +
mType.getElement().mKind + ", type " +
mType.getElement().mType +
" of " + mType.getElement().getSizeBytes() +
" of " + mType.getElement().getBytesSize() +
" bytes, passed bitmap was " + bc);
}
break;
case ARGB_4444:
if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) ||
(mType.getElement().getSizeBytes() != 2)) {
(mType.getElement().getBytesSize() != 2)) {
throw new RSIllegalArgumentException("Allocation kind is " +
mType.getElement().mKind + ", type " +
mType.getElement().mType +
" of " + mType.getElement().getSizeBytes() +
" of " + mType.getElement().getBytesSize() +
" bytes, passed bitmap was " + bc);
}
break;
Expand Down Expand Up @@ -583,7 +576,7 @@ public void copyFrom(Bitmap b) {
*/
public void setFromFieldPacker(int xoff, FieldPacker fp) {
mRS.validate();
int eSize = mType.mElement.getSizeBytes();
int eSize = mType.mElement.getBytesSize();
final byte[] data = fp.getData();

int count = data.length / eSize;
Expand Down Expand Up @@ -612,7 +605,7 @@ public void setFromFieldPacker(int xoff, int component_number, FieldPacker fp) {
}

final byte[] data = fp.getData();
int eSize = mType.mElement.mElements[component_number].getSizeBytes();
int eSize = mType.mElement.mElements[component_number].getBytesSize();
eSize *= mType.mElement.mArraySizes[component_number];

if (data.length != eSize) {
Expand Down Expand Up @@ -665,7 +658,7 @@ public void generateMipmaps() {
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, int[] d) {
int dataSize = mType.mElement.getSizeBytes() * count;
int dataSize = mType.mElement.getBytesSize() * count;
data1DChecks(off, count, d.length * 4, dataSize);
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
}
Expand All @@ -679,7 +672,7 @@ public void copy1DRangeFromUnchecked(int off, int count, int[] d) {
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, short[] d) {
int dataSize = mType.mElement.getSizeBytes() * count;
int dataSize = mType.mElement.getBytesSize() * count;
data1DChecks(off, count, d.length * 2, dataSize);
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
}
Expand All @@ -693,7 +686,7 @@ public void copy1DRangeFromUnchecked(int off, int count, short[] d) {
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, byte[] d) {
int dataSize = mType.mElement.getSizeBytes() * count;
int dataSize = mType.mElement.getBytesSize() * count;
data1DChecks(off, count, d.length, dataSize);
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
}
Expand All @@ -707,7 +700,7 @@ public void copy1DRangeFromUnchecked(int off, int count, byte[] d) {
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, float[] d) {
int dataSize = mType.mElement.getSizeBytes() * count;
int dataSize = mType.mElement.getBytesSize() * count;
data1DChecks(off, count, d.length * 4, dataSize);
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
}
Expand Down Expand Up @@ -1029,30 +1022,6 @@ static public Allocation createTyped(RenderScript rs, Type type, MipmapControl m
return new Allocation(id, rs, type, usage);
}

/**
* @hide
* This API is hidden and only intended to be used for
* transitional purposes.
*
* @param type renderscript type describing data layout
* @param mips specifies desired mipmap behaviour for the
* allocation
* @param usage bit field specifying how the allocation is
* utilized
*/
static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips,
int usage, int pointer) {
rs.validate();
if (type.getID(rs) == 0) {
throw new RSInvalidStateException("Bad Type");
}
int id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, pointer);
if (id == 0) {
throw new RSRuntimeException("Allocation creation failed.");
}
return new Allocation(id, rs, type, usage);
}

/**
* Creates a renderscript allocation with the size specified by
* the type and no mipmaps generated by default
Expand Down Expand Up @@ -1194,16 +1163,21 @@ public SurfaceTexture getSurfaceTexture() {
}

/**
* For allocations used with io operations, returns the handle
* onto a raw buffer that is being managed by the screen
* compositor.
*
* @hide
* @return Surface object associated with allocation
*
*/
public Surface getSurface() {
return new Surface(getSurfaceTexture());
}

/**
* @hide
* Associate a surface for io output with this allocation
*
* @param sur Surface to associate with allocation
*/
public void setSurface(Surface sur) {
mRS.validate();
Expand Down
Loading

0 comments on commit 918e840

Please sign in to comment.