Merge "Add shortcut to avoid potential divide by zero in some case"

This commit is contained in:
Jean-Baptiste Queru
2012-08-08 13:17:25 -07:00
committed by android code review

View File

@ -946,6 +946,11 @@ void FontRenderer::appendRotatedMeshQuad(float x1, float y1, float u1, float v1,
uint32_t FontRenderer::getRemainingCacheCapacity() {
uint32_t remainingCapacity = 0;
float totalPixels = 0;
//avoid divide by zero if the size is 0
if (mCacheLines.size() == 0) {
return 0;
}
for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
remainingCapacity += (mCacheLines[i]->mMaxWidth - mCacheLines[i]->mCurrentCol);
totalPixels += mCacheLines[i]->mMaxWidth;