Merge "1.1 Translator: fix drawing of GL_POINT_SIZE_ARRAY"

This commit is contained in:
David Turner
2011-07-03 05:05:55 -07:00
committed by Android Code Review
2 changed files with 49 additions and 44 deletions

View File

@@ -136,31 +136,6 @@ void GLEScmContext::setupArraysPointers(GLESConversionArrays& cArrs,GLint first,
s_glDispatch.glClientActiveTexture(activeTexture);
}
void GLEScmContext::drawPoints(PointSizeIndices* points) {
GLushort* indices = NULL;
int last_size = 0;
//drawing each group of vertices by the points size
for(PointSizeIndices::iterator it = points->begin();it != points->end(); it++) {
int count = (*it).second.size();
int pointSize = (*it).first;
std::vector<int>& arr = (*it).second;
if(count > last_size) {
if(indices) delete [] indices;
indices = new GLushort[count];
}
int i = 0 ;
for(std::vector<int>::iterator it2 = arr.begin();it2 != arr.end();it2++) {
indices[i++] = (*it2);
}
s_glDispatch.glPointSize(pointSize);
s_glDispatch.glDrawElements(GL_POINTS,count,GL_UNSIGNED_SHORT,indices);
}
if(indices) delete [] indices;
}
void GLEScmContext::drawPointsData(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices_in,bool isElemsDraw) {
const char *pointsArr = NULL;
int stride = 0;
@@ -179,23 +154,52 @@ void GLEScmContext::drawPointsData(GLESConversionArrays& cArrs,GLint first,GLsi
stride = sizeof(GLfloat);
}
//filling arrays before sorting them
PointSizeIndices points;
if(isElemsDraw) {
for(int i=0; i< count; i++) {
GLushort index = (type == GL_UNSIGNED_SHORT?
static_cast<const GLushort*>(indices_in)[i]:
static_cast<const GLubyte*>(indices_in)[i]);
GLfloat pSize = *((GLfloat*)(pointsArr+(index*stride)));
points[pSize].push_back(index);
int tSize = type == GL_UNSIGNED_SHORT ? 2 : 1;
int i = 0;
while(i<count)
{
int sStart = i;
int sCount = 1;
#define INDEX \
(type == GL_UNSIGNED_SHORT ? \
static_cast<const GLushort*>(indices_in)[i]: \
static_cast<const GLubyte*>(indices_in)[i])
GLfloat pSize = *((GLfloat*)(pointsArr+(INDEX*stride)));
i++;
while(i < count && pSize == *((GLfloat*)(pointsArr+(INDEX*stride))))
{
sCount++;
i++;
}
s_glDispatch.glPointSize(pSize);
s_glDispatch.glDrawElements(GL_POINTS, sCount, type, (char*)indices_in+sStart*tSize);
}
} else {
for(int i=0; i< count; i++) {
GLfloat pSize = *((GLfloat*)(pointsArr+(first+i*stride)));
points[pSize].push_back(i+first);
int i = 0;
while(i<count)
{
int sStart = i;
int sCount = 1;
GLfloat pSize = *((GLfloat*)(pointsArr+((first+i)*stride)));
i++;
while(i < count && pSize == *((GLfloat*)(pointsArr+((first+i)*stride))))
{
sCount++;
i++;
}
s_glDispatch.glPointSize(pSize);
s_glDispatch.glDrawArrays(GL_POINTS, first+sStart, sCount);
}
}
drawPoints(&points);
}
void GLEScmContext::drawPointsArrs(GLESConversionArrays& arrs,GLint first,GLsizei count) {

View File

@@ -555,12 +555,13 @@ GL_API void GL_APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count)
GLESConversionArrays tmpArrs;
ctx->setupArraysPointers(tmpArrs,first,count,0,NULL,true);
if(mode != GL_POINTS || !ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){
ctx->dispatcher().glDrawArrays(mode,first,count);
}
else{
if(mode == GL_POINTS && ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){
ctx->drawPointsArrs(tmpArrs,first,count);
}
else
{
ctx->dispatcher().glDrawArrays(mode,first,count);
}
}
GL_API void GL_APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *elementsIndices) {
@@ -577,11 +578,11 @@ GL_API void GL_APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type
}
ctx->setupArraysPointers(tmpArrs,0,count,type,indices,false);
if(mode != GL_POINTS || !ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){
ctx->dispatcher().glDrawElements(mode,count,type,indices);
if(mode == GL_POINTS && ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){
ctx->drawPointsElems(tmpArrs,count,type,indices);
}
else{
ctx->drawPointsElems(tmpArrs,count,type,indices);
ctx->dispatcher().glDrawElements(mode,count,type,indices);
}
}