am d345505a: Merge "Add error checks to bitmap uploads. Fix java side calculation for pixel sizes." into honeycomb
* commit 'd345505a32f991ffb74639795451f545141b8890': Add error checks to bitmap uploads. Fix java side calculation for pixel sizes.
This commit is contained in:
@@ -122,6 +122,49 @@ public class Allocation extends BaseObj {
|
||||
mType.getY() != b.getHeight()) {
|
||||
throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch");
|
||||
}
|
||||
Bitmap.Config bc = b.getConfig();
|
||||
switch (bc) {
|
||||
case ALPHA_8:
|
||||
if (mType.getElement().mKind != Element.DataKind.PIXEL_A) {
|
||||
throw new RSIllegalArgumentException("Allocation kind is " +
|
||||
mType.getElement().mKind + ", type " +
|
||||
mType.getElement().mType +
|
||||
" of " + mType.getElement().getSizeBytes() +
|
||||
" bytes, passed bitmap was " + bc);
|
||||
}
|
||||
break;
|
||||
case ARGB_8888:
|
||||
if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) ||
|
||||
(mType.getElement().getSizeBytes() != 4)) {
|
||||
throw new RSIllegalArgumentException("Allocation kind is " +
|
||||
mType.getElement().mKind + ", type " +
|
||||
mType.getElement().mType +
|
||||
" of " + mType.getElement().getSizeBytes() +
|
||||
" bytes, passed bitmap was " + bc);
|
||||
}
|
||||
break;
|
||||
case RGB_565:
|
||||
if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGB) ||
|
||||
(mType.getElement().getSizeBytes() != 2)) {
|
||||
throw new RSIllegalArgumentException("Allocation kind is " +
|
||||
mType.getElement().mKind + ", type " +
|
||||
mType.getElement().mType +
|
||||
" of " + mType.getElement().getSizeBytes() +
|
||||
" bytes, passed bitmap was " + bc);
|
||||
}
|
||||
break;
|
||||
case ARGB_4444:
|
||||
if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) ||
|
||||
(mType.getElement().getSizeBytes() != 2)) {
|
||||
throw new RSIllegalArgumentException("Allocation kind is " +
|
||||
mType.getElement().mKind + ", type " +
|
||||
mType.getElement().mType +
|
||||
" of " + mType.getElement().getSizeBytes() +
|
||||
" bytes, passed bitmap was " + bc);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void copyFrom(int[] d) {
|
||||
|
||||
@@ -425,7 +425,13 @@ public class Element extends BaseObj {
|
||||
|
||||
Element(int id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) {
|
||||
super(id, rs);
|
||||
mSize = dt.mSize * size;
|
||||
if ((dt != DataType.UNSIGNED_5_6_5) &&
|
||||
(dt != DataType.UNSIGNED_4_4_4_4) &&
|
||||
(dt != DataType.UNSIGNED_5_5_5_1)) {
|
||||
mSize = dt.mSize * size;
|
||||
} else {
|
||||
mSize = dt.mSize;
|
||||
}
|
||||
mType = dt;
|
||||
mKind = dk;
|
||||
mNormalized = norm;
|
||||
|
||||
Reference in New Issue
Block a user