Skip to content

Commit 0e2c701

Browse files
Alex SakhartchoukAndroid (Google) Code Review
authored andcommitted
Merge "Unhiding J API's for Renderscript."
2 parents 6c19be4 + 918e840 commit 0e2c701

12 files changed

Lines changed: 141 additions & 112 deletions

File tree

api/current.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17993,15 +17993,24 @@ package android.renderscript {
1799317993
method public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type, int);
1799417994
method public static android.renderscript.Allocation createTyped(android.renderscript.RenderScript, android.renderscript.Type);
1799517995
method public void generateMipmaps();
17996+
method public int getBytesSize();
17997+
method public android.renderscript.Element getElement();
17998+
method public android.view.Surface getSurface();
1799617999
method public android.renderscript.Type getType();
18000+
method public int getUsage();
18001+
method public void ioReceive();
18002+
method public void ioSend();
1799718003
method public synchronized void resize(int);
1799818004
method public void setFromFieldPacker(int, android.renderscript.FieldPacker);
1799918005
method public void setFromFieldPacker(int, int, android.renderscript.FieldPacker);
18006+
method public void setSurface(android.view.Surface);
1800018007
method public void syncAll(int);
1800118008
field public static final int USAGE_GRAPHICS_CONSTANTS = 8; // 0x8
1800218009
field public static final int USAGE_GRAPHICS_RENDER_TARGET = 16; // 0x10
1800318010
field public static final int USAGE_GRAPHICS_TEXTURE = 2; // 0x2
1800418011
field public static final int USAGE_GRAPHICS_VERTEX = 4; // 0x4
18012+
field public static final int USAGE_IO_INPUT = 32; // 0x20
18013+
field public static final int USAGE_IO_OUTPUT = 64; // 0x40
1800518014
field public static final int USAGE_SCRIPT = 1; // 0x1
1800618015
}
1800718016

@@ -18140,6 +18149,15 @@ package android.renderscript {
1814018149
method public static android.renderscript.Element U8_4(android.renderscript.RenderScript);
1814118150
method public static android.renderscript.Element createPixel(android.renderscript.RenderScript, android.renderscript.Element.DataType, android.renderscript.Element.DataKind);
1814218151
method public static android.renderscript.Element createVector(android.renderscript.RenderScript, android.renderscript.Element.DataType, int);
18152+
method public int getBytesSize();
18153+
method public android.renderscript.Element.DataKind getDataKind();
18154+
method public android.renderscript.Element.DataType getDataType();
18155+
method public android.renderscript.Element getSubElement(int);
18156+
method public int getSubElementArraySize(int);
18157+
method public int getSubElementCount();
18158+
method public java.lang.String getSubElementName(int);
18159+
method public int getSubElementOffsetBytes(int);
18160+
method public int getVectorSize();
1814318161
method public boolean isCompatible(android.renderscript.Element);
1814418162
method public boolean isComplex();
1814518163
}
@@ -18172,6 +18190,7 @@ package android.renderscript {
1817218190
enum_constant public static final android.renderscript.Element.DataType MATRIX_2X2;
1817318191
enum_constant public static final android.renderscript.Element.DataType MATRIX_3X3;
1817418192
enum_constant public static final android.renderscript.Element.DataType MATRIX_4X4;
18193+
enum_constant public static final android.renderscript.Element.DataType NONE;
1817518194
enum_constant public static final android.renderscript.Element.DataType RS_ALLOCATION;
1817618195
enum_constant public static final android.renderscript.Element.DataType RS_ELEMENT;
1817718196
enum_constant public static final android.renderscript.Element.DataType RS_MESH;
@@ -18486,12 +18505,18 @@ package android.renderscript {
1848618505
method public void bindConstants(android.renderscript.Allocation, int);
1848718506
method public void bindSampler(android.renderscript.Sampler, int) throws java.lang.IllegalArgumentException;
1848818507
method public void bindTexture(android.renderscript.Allocation, int) throws java.lang.IllegalArgumentException;
18508+
method public android.renderscript.Type getConstant(int);
18509+
method public int getConstantCount();
18510+
method public int getTextureCount();
18511+
method public java.lang.String getTextureName(int);
18512+
method public android.renderscript.Program.TextureType getTextureType(int);
1848918513
}
1849018514

1849118515
public static class Program.BaseProgramBuilder {
1849218516
ctor protected Program.BaseProgramBuilder(android.renderscript.RenderScript);
1849318517
method public android.renderscript.Program.BaseProgramBuilder addConstant(android.renderscript.Type) throws java.lang.IllegalStateException;
1849418518
method public android.renderscript.Program.BaseProgramBuilder addTexture(android.renderscript.Program.TextureType) throws java.lang.IllegalArgumentException;
18519+
method public android.renderscript.Program.BaseProgramBuilder addTexture(android.renderscript.Program.TextureType, java.lang.String) throws java.lang.IllegalArgumentException;
1849518520
method public int getCurrentConstantIndex();
1849618521
method public int getCurrentTextureIndex();
1849718522
method protected void initProgram(android.renderscript.Program);
@@ -18547,6 +18572,8 @@ package android.renderscript {
1854718572
method public static android.renderscript.ProgramRaster CULL_BACK(android.renderscript.RenderScript);
1854818573
method public static android.renderscript.ProgramRaster CULL_FRONT(android.renderscript.RenderScript);
1854918574
method public static android.renderscript.ProgramRaster CULL_NONE(android.renderscript.RenderScript);
18575+
method public android.renderscript.ProgramRaster.CullMode getCullMode();
18576+
method public boolean isPointSpriteEnabled();
1855018577
}
1855118578

1855218579
public static class ProgramRaster.Builder {
@@ -18569,6 +18596,15 @@ package android.renderscript {
1856918596
method public static android.renderscript.ProgramStore BLEND_ALPHA_DEPTH_TEST(android.renderscript.RenderScript);
1857018597
method public static android.renderscript.ProgramStore BLEND_NONE_DEPTH_NONE(android.renderscript.RenderScript);
1857118598
method public static android.renderscript.ProgramStore BLEND_NONE_DEPTH_TEST(android.renderscript.RenderScript);
18599+
method public android.renderscript.ProgramStore.BlendDstFunc getBlendDstFunc();
18600+
method public android.renderscript.ProgramStore.BlendSrcFunc getBlendSrcFunc();
18601+
method public android.renderscript.ProgramStore.DepthFunc getDepthFunc();
18602+
method public boolean isColorMaskAlphaEnabled();
18603+
method public boolean isColorMaskBlueEnabled();
18604+
method public boolean isColorMaskGreenEnabled();
18605+
method public boolean isColorMaskRedEnabled();
18606+
method public boolean isDepthMaskEnabled();
18607+
method public boolean isDitherEnabled();
1857218608
}
1857318609

1857418610
public static final class ProgramStore.BlendDstFunc extends java.lang.Enum {
@@ -18621,6 +18657,8 @@ package android.renderscript {
1862118657
}
1862218658

1862318659
public class ProgramVertex extends android.renderscript.Program {
18660+
method public android.renderscript.Element getInput(int);
18661+
method public int getInputCount();
1862418662
}
1862518663

1862618664
public static class ProgramVertex.Builder extends android.renderscript.Program.BaseProgramBuilder {
@@ -18758,6 +18796,11 @@ package android.renderscript {
1875818796
method public static android.renderscript.Sampler WRAP_LINEAR(android.renderscript.RenderScript);
1875918797
method public static android.renderscript.Sampler WRAP_LINEAR_MIP_LINEAR(android.renderscript.RenderScript);
1876018798
method public static android.renderscript.Sampler WRAP_NEAREST(android.renderscript.RenderScript);
18799+
method public float getAnisotropy();
18800+
method public android.renderscript.Sampler.Value getMagnification();
18801+
method public android.renderscript.Sampler.Value getMinification();
18802+
method public android.renderscript.Sampler.Value getWrapS();
18803+
method public android.renderscript.Sampler.Value getWrapT();
1876118804
}
1876218805

1876318806
public static class Sampler.Builder {

graphics/java/android/renderscript/Allocation.java

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ public class Allocation extends BaseObj {
136136
* consumer. This usage will cause the allocation to be created
137137
* read only.
138138
*
139-
* @hide
140139
*/
141140
public static final int USAGE_IO_INPUT = 0x0020;
142141

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

@@ -193,8 +191,8 @@ private int getIDSafe() {
193191
/**
194192
* Get the element of the type of the Allocation.
195193
*
196-
* @hide
197-
* @return Element
194+
* @return Element that describes the structure of data in the
195+
* allocation
198196
*
199197
*/
200198
public Element getElement() {
@@ -204,8 +202,8 @@ public Element getElement() {
204202
/**
205203
* Get the usage flags of the Allocation.
206204
*
207-
* @hide
208-
* @return usage
205+
* @return usage flags associated with the allocation. e.g.
206+
* script, texture, etc.
209207
*
210208
*/
211209
public int getUsage() {
@@ -215,12 +213,11 @@ public int getUsage() {
215213
/**
216214
* Get the size of the Allocation in bytes.
217215
*
218-
* @hide
219-
* @return sizeInBytes
216+
* @return size of the Allocation in bytes.
220217
*
221218
*/
222-
public int getSizeBytes() {
223-
return mType.getCount() * mType.getElement().getSizeBytes();
219+
public int getBytesSize() {
220+
return mType.getCount() * mType.getElement().getBytesSize();
224221
}
225222

226223
private void updateCacheInfo(Type t) {
@@ -362,8 +359,6 @@ public void syncAll(int srcLocation) {
362359
* Send a buffer to the output stream. The contents of the
363360
* Allocation will be undefined after this operation.
364361
*
365-
* @hide
366-
*
367362
*/
368363
public void ioSend() {
369364
if ((mUsage & USAGE_IO_OUTPUT) == 0) {
@@ -385,8 +380,6 @@ public void ioSendOutput() {
385380
/**
386381
* Receive the latest input into the Allocation.
387382
*
388-
* @hide
389-
*
390383
*/
391384
public void ioReceive() {
392385
if ((mUsage & USAGE_IO_INPUT) == 0) {
@@ -424,37 +417,37 @@ private void validateBitmapFormat(Bitmap b) {
424417
throw new RSIllegalArgumentException("Allocation kind is " +
425418
mType.getElement().mKind + ", type " +
426419
mType.getElement().mType +
427-
" of " + mType.getElement().getSizeBytes() +
420+
" of " + mType.getElement().getBytesSize() +
428421
" bytes, passed bitmap was " + bc);
429422
}
430423
break;
431424
case ARGB_8888:
432425
if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) ||
433-
(mType.getElement().getSizeBytes() != 4)) {
426+
(mType.getElement().getBytesSize() != 4)) {
434427
throw new RSIllegalArgumentException("Allocation kind is " +
435428
mType.getElement().mKind + ", type " +
436429
mType.getElement().mType +
437-
" of " + mType.getElement().getSizeBytes() +
430+
" of " + mType.getElement().getBytesSize() +
438431
" bytes, passed bitmap was " + bc);
439432
}
440433
break;
441434
case RGB_565:
442435
if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGB) ||
443-
(mType.getElement().getSizeBytes() != 2)) {
436+
(mType.getElement().getBytesSize() != 2)) {
444437
throw new RSIllegalArgumentException("Allocation kind is " +
445438
mType.getElement().mKind + ", type " +
446439
mType.getElement().mType +
447-
" of " + mType.getElement().getSizeBytes() +
440+
" of " + mType.getElement().getBytesSize() +
448441
" bytes, passed bitmap was " + bc);
449442
}
450443
break;
451444
case ARGB_4444:
452445
if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) ||
453-
(mType.getElement().getSizeBytes() != 2)) {
446+
(mType.getElement().getBytesSize() != 2)) {
454447
throw new RSIllegalArgumentException("Allocation kind is " +
455448
mType.getElement().mKind + ", type " +
456449
mType.getElement().mType +
457-
" of " + mType.getElement().getSizeBytes() +
450+
" of " + mType.getElement().getBytesSize() +
458451
" bytes, passed bitmap was " + bc);
459452
}
460453
break;
@@ -583,7 +576,7 @@ public void copyFrom(Bitmap b) {
583576
*/
584577
public void setFromFieldPacker(int xoff, FieldPacker fp) {
585578
mRS.validate();
586-
int eSize = mType.mElement.getSizeBytes();
579+
int eSize = mType.mElement.getBytesSize();
587580
final byte[] data = fp.getData();
588581

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

614607
final byte[] data = fp.getData();
615-
int eSize = mType.mElement.mElements[component_number].getSizeBytes();
608+
int eSize = mType.mElement.mElements[component_number].getBytesSize();
616609
eSize *= mType.mElement.mArraySizes[component_number];
617610

618611
if (data.length != eSize) {
@@ -665,7 +658,7 @@ public void generateMipmaps() {
665658
* @param d the source data array
666659
*/
667660
public void copy1DRangeFromUnchecked(int off, int count, int[] d) {
668-
int dataSize = mType.mElement.getSizeBytes() * count;
661+
int dataSize = mType.mElement.getBytesSize() * count;
669662
data1DChecks(off, count, d.length * 4, dataSize);
670663
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
671664
}
@@ -679,7 +672,7 @@ public void copy1DRangeFromUnchecked(int off, int count, int[] d) {
679672
* @param d the source data array
680673
*/
681674
public void copy1DRangeFromUnchecked(int off, int count, short[] d) {
682-
int dataSize = mType.mElement.getSizeBytes() * count;
675+
int dataSize = mType.mElement.getBytesSize() * count;
683676
data1DChecks(off, count, d.length * 2, dataSize);
684677
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
685678
}
@@ -693,7 +686,7 @@ public void copy1DRangeFromUnchecked(int off, int count, short[] d) {
693686
* @param d the source data array
694687
*/
695688
public void copy1DRangeFromUnchecked(int off, int count, byte[] d) {
696-
int dataSize = mType.mElement.getSizeBytes() * count;
689+
int dataSize = mType.mElement.getBytesSize() * count;
697690
data1DChecks(off, count, d.length, dataSize);
698691
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
699692
}
@@ -707,7 +700,7 @@ public void copy1DRangeFromUnchecked(int off, int count, byte[] d) {
707700
* @param d the source data array
708701
*/
709702
public void copy1DRangeFromUnchecked(int off, int count, float[] d) {
710-
int dataSize = mType.mElement.getSizeBytes() * count;
703+
int dataSize = mType.mElement.getBytesSize() * count;
711704
data1DChecks(off, count, d.length * 4, dataSize);
712705
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
713706
}
@@ -1029,30 +1022,6 @@ static public Allocation createTyped(RenderScript rs, Type type, MipmapControl m
10291022
return new Allocation(id, rs, type, usage);
10301023
}
10311024

1032-
/**
1033-
* @hide
1034-
* This API is hidden and only intended to be used for
1035-
* transitional purposes.
1036-
*
1037-
* @param type renderscript type describing data layout
1038-
* @param mips specifies desired mipmap behaviour for the
1039-
* allocation
1040-
* @param usage bit field specifying how the allocation is
1041-
* utilized
1042-
*/
1043-
static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips,
1044-
int usage, int pointer) {
1045-
rs.validate();
1046-
if (type.getID(rs) == 0) {
1047-
throw new RSInvalidStateException("Bad Type");
1048-
}
1049-
int id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, pointer);
1050-
if (id == 0) {
1051-
throw new RSRuntimeException("Allocation creation failed.");
1052-
}
1053-
return new Allocation(id, rs, type, usage);
1054-
}
1055-
10561025
/**
10571026
* Creates a renderscript allocation with the size specified by
10581027
* the type and no mipmaps generated by default
@@ -1194,16 +1163,21 @@ public SurfaceTexture getSurfaceTexture() {
11941163
}
11951164

11961165
/**
1166+
* For allocations used with io operations, returns the handle
1167+
* onto a raw buffer that is being managed by the screen
1168+
* compositor.
11971169
*
1198-
* @hide
1170+
* @return Surface object associated with allocation
11991171
*
12001172
*/
12011173
public Surface getSurface() {
12021174
return new Surface(getSurfaceTexture());
12031175
}
12041176

12051177
/**
1206-
* @hide
1178+
* Associate a surface for io output with this allocation
1179+
*
1180+
* @param sur Surface to associate with allocation
12071181
*/
12081182
public void setSurface(Surface sur) {
12091183
mRS.validate();

0 commit comments

Comments
 (0)