diff options
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 49 | 
1 files changed, 25 insertions, 24 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 6e2f1c37ef56..fcac053be110 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -199,13 +199,13 @@ void OpenGLRenderer::interrupt() {          }      }      mCaches.unbindMeshBuffer(); +    mCaches.resetVertexPointers();  }  void OpenGLRenderer::resume() {      sp<Snapshot> snapshot = (mSnapshot != NULL) ? mSnapshot : mFirstSnapshot;      glViewport(0, 0, snapshot->viewport.getWidth(), snapshot->viewport.getHeight()); -      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);      glEnable(GL_SCISSOR_TEST); @@ -1201,16 +1201,15 @@ void OpenGLRenderer::setupDrawColorFilterUniforms() {  }  void OpenGLRenderer::setupDrawSimpleMesh() { -    mCaches.bindMeshBuffer(); -    glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE, -            gMeshStride, 0); +    bool force = mCaches.bindMeshBuffer(); +    mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position, 0);  }  void OpenGLRenderer::setupDrawTexture(GLuint texture) {      bindTexture(texture);      glUniform1i(mCaches.currentProgram->getUniform("sampler"), mTextureUnit++); -    mTexCoordsSlot = mCaches.currentProgram->getAttrib("texCoords"); +    mTexCoordsSlot = mCaches.currentProgram->texCoords;      glEnableVertexAttribArray(mTexCoordsSlot);  } @@ -1218,7 +1217,7 @@ void OpenGLRenderer::setupDrawExternalTexture(GLuint texture) {      bindExternalTexture(texture);      glUniform1i(mCaches.currentProgram->getUniform("sampler"), mTextureUnit++); -    mTexCoordsSlot = mCaches.currentProgram->getAttrib("texCoords"); +    mTexCoordsSlot = mCaches.currentProgram->texCoords;      glEnableVertexAttribArray(mTexCoordsSlot);  } @@ -1232,23 +1231,23 @@ void OpenGLRenderer::setupDrawTextureTransformUniforms(mat4& transform) {  }  void OpenGLRenderer::setupDrawMesh(GLvoid* vertices, GLvoid* texCoords, GLuint vbo) { +    bool force = false;      if (!vertices) { -        mCaches.bindMeshBuffer(vbo == 0 ? mCaches.meshBuffer : vbo); +        force = mCaches.bindMeshBuffer(vbo == 0 ? mCaches.meshBuffer : vbo);      } else { -        mCaches.unbindMeshBuffer(); +        force = mCaches.unbindMeshBuffer();      } -    glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE, -            gMeshStride, vertices); +    mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position, vertices);      if (mTexCoordsSlot >= 0) { -        glVertexAttribPointer(mTexCoordsSlot, 2, GL_FLOAT, GL_FALSE, gMeshStride, texCoords); +        mCaches.bindTexCoordsVertexPointer(force, mTexCoordsSlot, texCoords);      }  }  void OpenGLRenderer::setupDrawVertices(GLvoid* vertices) { -    mCaches.unbindMeshBuffer(); -    glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE, -            gVertexStride, vertices); +    bool force = mCaches.unbindMeshBuffer(); +    mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position, +            vertices, gVertexStride);  }  /** @@ -1264,10 +1263,10 @@ void OpenGLRenderer::setupDrawVertices(GLvoid* vertices) {   */  void OpenGLRenderer::setupDrawAALine(GLvoid* vertices, GLvoid* widthCoords,          GLvoid* lengthCoords, float boundaryWidthProportion) { -    mCaches.unbindMeshBuffer(); - -    glVertexAttribPointer(mCaches.currentProgram->position, 2, GL_FLOAT, GL_FALSE, -            gAAVertexStride, vertices); +    bool force = mCaches.unbindMeshBuffer(); +    mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position, +            vertices, gAAVertexStride); +    mCaches.resetTexCoordsVertexPointer();      int widthSlot = mCaches.currentProgram->getAttrib("vtxWidth");      glEnableVertexAttribArray(widthSlot); @@ -2186,12 +2185,14 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,  #else      bool hasActiveLayer = false;  #endif -    mCaches.unbindMeshBuffer(); -    // Tell font renderer the locations of position and texture coord -    // attributes so it can bind its data properly -    int positionSlot = mCaches.currentProgram->position; -    fontRenderer.setAttributeBindingSlots(positionSlot, mTexCoordsSlot); +    float* buffer = fontRenderer.getMeshBuffer(); +    int offset = fontRenderer.getMeshTexCoordsOffset(); + +    bool force = mCaches.unbindMeshBuffer(); +    mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position, buffer); +    mCaches.bindTexCoordsVertexPointer(force, mTexCoordsSlot, buffer + offset); +      if (fontRenderer.renderText(paint, clip, text, 0, bytesCount, count, x, y,              hasActiveLayer ? &bounds : NULL)) {  #if RENDER_LAYERS_AS_REGIONS @@ -2205,7 +2206,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,      }      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -    glDisableVertexAttribArray(mCaches.currentProgram->getAttrib("texCoords")); +    glDisableVertexAttribArray(mCaches.currentProgram->texCoords);      drawTextDecorations(text, bytesCount, length, oldX, oldY, paint);  }  |