Fix use of zero sized allocation. Add check to make sure the read object has not become null while waiting for the message to arrive.

This commit is contained in:
Jason Sams
2009-09-27 17:51:44 -07:00
parent 05de32aec2
commit 0a8dc2cd98
+25 -19
View File
@@ -338,7 +338,10 @@ public class AllAppsView extends RSSurfaceView
Handler mReadZoom = new Handler() { Handler mReadZoom = new Handler() {
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
mRollo.mReadback.read(); if(mRollo != null && mRollo.mReadback != null) {
// FIXME: These checks may indicate other problems.
mRollo.mReadback.read();
}
} }
}; };
@@ -490,7 +493,9 @@ public class AllAppsView extends RSSurfaceView
} }
void read() { void read() {
mAlloc.read(this); if(mAlloc != null) {
mAlloc.read(this);
}
} }
} }
@@ -571,16 +576,14 @@ public class AllAppsView extends RSSurfaceView
mRS.contextBindProgramVertex(mPV); mRS.contextBindProgramVertex(mPV);
mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1]; mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1];
mAllocTouchXBorders = Allocation.createSized(mRS, Element.USER_I32, mAllocTouchXBorders = Allocation.createSized(mRS, Element.USER_I32(mRS),
mTouchXBorders.length); mTouchXBorders.length);
mAllocTouchXBorders.data(mTouchXBorders); mAllocTouchXBorders.data(mTouchXBorders);
mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1]; mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1];
mAllocTouchYBorders = Allocation.createSized(mRS, Element.USER_I32, mAllocTouchYBorders = Allocation.createSized(mRS, Element.USER_I32(mRS),
mTouchYBorders.length); mTouchYBorders.length);
mAllocTouchYBorders.data(mTouchYBorders); mAllocTouchYBorders.data(mTouchYBorders);
Log.e("rs", "Done loading named");
} }
private void initData() { private void initData() {
@@ -596,7 +599,7 @@ public class AllAppsView extends RSSurfaceView
mParams.bubbleBitmapHeight = bubble.getBitmapHeight(); mParams.bubbleBitmapHeight = bubble.getBitmapHeight();
mScrollHandle = Allocation.createFromBitmapResource(mRS, mRes, mScrollHandle = Allocation.createFromBitmapResource(mRS, mRes,
R.drawable.all_apps_button_pow2, Element.RGBA_8888, false); R.drawable.all_apps_button_pow2, Element.RGBA_8888(mRS), false);
mScrollHandle.uploadToTexture(0); mScrollHandle.uploadToTexture(0);
mParams.scrollHandleId = mScrollHandle.getID(); mParams.scrollHandleId = mScrollHandle.getID();
Log.d(TAG, "mParams.scrollHandleId=" + mParams.scrollHandleId); Log.d(TAG, "mParams.scrollHandleId=" + mParams.scrollHandleId);
@@ -644,15 +647,20 @@ public class AllAppsView extends RSSurfaceView
private void setApps(ArrayList<ApplicationInfo> list) { private void setApps(ArrayList<ApplicationInfo> list) {
final int count = list != null ? list.size() : 0; final int count = list != null ? list.size() : 0;
int allocCount = count;
if(allocCount < 1) {
allocCount = 1;
}
mIcons = new Allocation[count]; mIcons = new Allocation[count];
mIconIds = new int[count]; mIconIds = new int[allocCount];
mAllocIconID = Allocation.createSized(mRS, Element.USER_I32, count); mAllocIconID = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
mLabels = new Allocation[count]; mLabels = new Allocation[count];
mLabelIds = new int[count]; mLabelIds = new int[allocCount];
mAllocLabelID = Allocation.createSized(mRS, Element.USER_I32, count); mAllocLabelID = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount);
Element ie8888 = Element.RGBA_8888; Element ie8888 = Element.RGBA_8888(mRS);
Utilities.BubbleText bubble = new Utilities.BubbleText(getContext()); Utilities.BubbleText bubble = new Utilities.BubbleText(getContext());
@@ -660,9 +668,9 @@ public class AllAppsView extends RSSurfaceView
final ApplicationInfo item = list.get(i); final ApplicationInfo item = list.get(i);
mIcons[i] = Allocation.createFromBitmap(mRS, item.iconBitmap, mIcons[i] = Allocation.createFromBitmap(mRS, item.iconBitmap,
Element.RGBA_8888, false); Element.RGBA_8888(mRS), false);
mLabels[i] = Allocation.createFromBitmap(mRS, item.titleBitmap, mLabels[i] = Allocation.createFromBitmap(mRS, item.titleBitmap,
Element.RGBA_8888, false); Element.RGBA_8888(mRS), false);
mIcons[i].uploadToTexture(0); mIcons[i].uploadToTexture(0);
mLabels[i].uploadToTexture(0); mLabels[i].uploadToTexture(0);
@@ -671,10 +679,8 @@ public class AllAppsView extends RSSurfaceView
mLabelIds[i] = mLabels[i].getID(); mLabelIds[i] = mLabels[i].getID();
} }
if(count > 0) { mAllocIconID.data(mIconIds);
mAllocIconID.data(mIconIds); mAllocLabelID.data(mLabelIds);
mAllocLabelID.data(mLabelIds);
}
mState.iconCount = count; mState.iconCount = count;
@@ -769,7 +775,7 @@ public class AllAppsView extends RSSurfaceView
mAllAppsList.get(index).iconBitmap); mAllAppsList.get(index).iconBitmap);
mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap, mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap,
Element.RGBA_8888, false); Element.RGBA_8888(mRS), false);
mSelectedIcon.uploadToTexture(0); mSelectedIcon.uploadToTexture(0);
mState.selectedIconTexture = mSelectedIcon.getID(); mState.selectedIconTexture = mSelectedIcon.getID();
} }