diff options
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 52 | 
1 files changed, 29 insertions, 23 deletions
| diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index fcac053be110..59d3fcc2b0f6 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -144,6 +144,7 @@ void OpenGLRenderer::setViewport(int width, int height) {      glDisable(GL_DITHER);      glEnable(GL_SCISSOR_TEST);      glClearColor(0.0f, 0.0f, 0.0f, 0.0f); +      glEnableVertexAttribArray(Program::kBindingPosition);  } @@ -199,7 +200,9 @@ void OpenGLRenderer::interrupt() {          }      }      mCaches.unbindMeshBuffer(); +    mCaches.unbindIndicesBuffer();      mCaches.resetVertexPointers(); +    mCaches.disbaleTexCoordsVertexArray();  }  void OpenGLRenderer::resume() { @@ -212,7 +215,6 @@ void OpenGLRenderer::resume() {      dirtyClip();      glBindFramebuffer(GL_FRAMEBUFFER, snapshot->fbo); -    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);      mCaches.blend = true;      glEnable(GL_BLEND); @@ -771,7 +773,7 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {              layer->setFilter(GL_LINEAR);              setupDrawModelViewTranslate(rect.left, rect.top, rect.right, rect.bottom);          } -        setupDrawMesh(&mesh[0].position[0], &mesh[0].texture[0]); +        setupDrawMeshIndices(&mesh[0].position[0], &mesh[0].texture[0]);          for (size_t i = 0; i < count; i++) {              const android::Rect* r = &rects[i]; @@ -800,7 +802,6 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {              glDrawElements(GL_TRIANGLES, numQuads * 6, GL_UNSIGNED_SHORT, NULL);          } -        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);          finishDrawTexture();  #if DEBUG_LAYERS_AS_REGIONS @@ -1015,7 +1016,6 @@ void OpenGLRenderer::setupDraw(bool clear) {      mColorA = mColorR = mColorG = mColorB = 0.0f;      mTextureUnit = 0;      mTrackDirtyRegions = true; -    mTexCoordsSlot = -1;  }  void OpenGLRenderer::setupDrawWithTexture(bool isAlpha8) { @@ -1027,6 +1027,10 @@ void OpenGLRenderer::setupDrawWithExternalTexture() {      mDescription.hasExternalTexture = true;  } +void OpenGLRenderer::setupDrawNoTexture() { +    mCaches.disbaleTexCoordsVertexArray(); +} +  void OpenGLRenderer::setupDrawAALine() {      mDescription.isAA = true;  } @@ -1203,22 +1207,19 @@ void OpenGLRenderer::setupDrawColorFilterUniforms() {  void OpenGLRenderer::setupDrawSimpleMesh() {      bool force = mCaches.bindMeshBuffer();      mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position, 0); +    mCaches.unbindIndicesBuffer();  }  void OpenGLRenderer::setupDrawTexture(GLuint texture) {      bindTexture(texture);      glUniform1i(mCaches.currentProgram->getUniform("sampler"), mTextureUnit++); - -    mTexCoordsSlot = mCaches.currentProgram->texCoords; -    glEnableVertexAttribArray(mTexCoordsSlot); +    mCaches.enableTexCoordsVertexArray();  }  void OpenGLRenderer::setupDrawExternalTexture(GLuint texture) {      bindExternalTexture(texture);      glUniform1i(mCaches.currentProgram->getUniform("sampler"), mTextureUnit++); - -    mTexCoordsSlot = mCaches.currentProgram->texCoords; -    glEnableVertexAttribArray(mTexCoordsSlot); +    mCaches.enableTexCoordsVertexArray();  }  void OpenGLRenderer::setupDrawTextureTransform() { @@ -1239,8 +1240,18 @@ void OpenGLRenderer::setupDrawMesh(GLvoid* vertices, GLvoid* texCoords, GLuint v      }      mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position, vertices); -    if (mTexCoordsSlot >= 0) { -        mCaches.bindTexCoordsVertexPointer(force, mTexCoordsSlot, texCoords); +    if (mCaches.currentProgram->texCoords >= 0) { +        mCaches.bindTexCoordsVertexPointer(force, mCaches.currentProgram->texCoords, texCoords); +    } + +    mCaches.unbindIndicesBuffer(); +} + +void OpenGLRenderer::setupDrawMeshIndices(GLvoid* vertices, GLvoid* texCoords) { +    bool force = mCaches.unbindMeshBuffer(); +    mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position, vertices); +    if (mCaches.currentProgram->texCoords >= 0) { +        mCaches.bindTexCoordsVertexPointer(force, mCaches.currentProgram->texCoords, texCoords);      }  } @@ -1248,6 +1259,7 @@ void OpenGLRenderer::setupDrawVertices(GLvoid* vertices) {      bool force = mCaches.unbindMeshBuffer();      mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position,              vertices, gVertexStride); +    mCaches.unbindIndicesBuffer();  }  /** @@ -1267,6 +1279,7 @@ void OpenGLRenderer::setupDrawAALine(GLvoid* vertices, GLvoid* widthCoords,      mCaches.bindPositionVertexPointer(force, mCaches.currentProgram->position,              vertices, gAAVertexStride);      mCaches.resetTexCoordsVertexPointer(); +    mCaches.unbindIndicesBuffer();      int widthSlot = mCaches.currentProgram->getAttrib("vtxWidth");      glEnableVertexAttribArray(widthSlot); @@ -1285,7 +1298,6 @@ void OpenGLRenderer::setupDrawAALine(GLvoid* vertices, GLvoid* widthCoords,  }  void OpenGLRenderer::finishDrawTexture() { -    glDisableVertexAttribArray(mTexCoordsSlot);  }  /////////////////////////////////////////////////////////////////////////////// @@ -1624,6 +1636,7 @@ void OpenGLRenderer::drawAARect(float left, float top, float right, float bottom      }      setupDraw(); +    setupDrawNoTexture();      setupDrawAALine();      setupDrawColor(color);      setupDrawColorFilter(); @@ -1734,6 +1747,7 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {      getAlphaAndMode(paint, &alpha, &mode);      setupDraw(); +    setupDrawNoTexture();      if (isAA) {          setupDrawAALine();      } @@ -1943,6 +1957,7 @@ void OpenGLRenderer::drawPoints(float* points, int count, SkPaint* paint) {      TextureVertex* vertex = &pointsData[0];      setupDraw(); +    setupDrawNoTexture();      setupDrawPoint(strokeWidth);      setupDrawColor(paint->getColor(), alpha);      setupDrawColorFilter(); @@ -2186,13 +2201,6 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,      bool hasActiveLayer = false;  #endif -    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,9 +2213,6 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,  #endif      } -    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -    glDisableVertexAttribArray(mCaches.currentProgram->texCoords); -      drawTextDecorations(text, bytesCount, length, oldX, oldY, paint);  } @@ -2437,6 +2442,7 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot      }      setupDraw(); +    setupDrawNoTexture();      setupDrawColor(color);      setupDrawShader();      setupDrawColorFilter(); |