diff options
Diffstat (limited to 'WebCore/platform/graphics/android')
-rw-r--r-- | WebCore/platform/graphics/android/GLUtils.cpp | 11 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/ShaderProgram.cpp | 31 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/ShaderProgram.h | 2 |
3 files changed, 34 insertions, 10 deletions
diff --git a/WebCore/platform/graphics/android/GLUtils.cpp b/WebCore/platform/graphics/android/GLUtils.cpp index 1c84fe2..0923c54 100644 --- a/WebCore/platform/graphics/android/GLUtils.cpp +++ b/WebCore/platform/graphics/android/GLUtils.cpp @@ -67,16 +67,17 @@ void GLUtils::toGLMatrix(GLfloat* flattened, const TransformationMatrix& m) { void GLUtils::setOrthographicMatrix(TransformationMatrix& ortho, float left, float top, float right, float bottom, float nearZ, float farZ) { float deltaX = right - left; - float deltaY = bottom - top; + float deltaY = top - bottom; float deltaZ = farZ - nearZ; + if (!deltaX || !deltaY || !deltaZ) + return; ortho.setM11(2.0f / deltaX); - ortho.setM22(2.0 / deltaY); - ortho.setM33(2.0f / deltaZ); ortho.setM41(-(right + left) / deltaX); + ortho.setM22(2.0f / deltaY); ortho.setM42(-(top + bottom) / deltaY); - ortho.setM43(-(farZ + nearZ) / deltaZ); - ortho.setM44(1); + ortho.setM33(-2.0f / deltaZ); + ortho.setM43(-(nearZ + farZ) / deltaZ); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/WebCore/platform/graphics/android/ShaderProgram.cpp b/WebCore/platform/graphics/android/ShaderProgram.cpp index aa41a48..2195bd4 100644 --- a/WebCore/platform/graphics/android/ShaderProgram.cpp +++ b/WebCore/platform/graphics/android/ShaderProgram.cpp @@ -149,11 +149,7 @@ void ShaderProgram::setViewport(SkRect& viewport) { TransformationMatrix ortho; GLUtils::setOrthographicMatrix(ortho, viewport.fLeft, viewport.fTop, viewport.fRight, viewport.fBottom, -1000, 1000); - TransformationMatrix invert; - invert.scale3d(1.0, -1.0, 1.0); - TransformationMatrix total = invert; - total.multLeft(ortho); - m_projectionMatrix = total; + m_projectionMatrix = ortho; } void ShaderProgram::setProjectionMatrix(SkRect& geometry) { @@ -184,6 +180,31 @@ void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity) { glUniform1f(alpha(), opacity); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + GLUtils::checkGlError("drawQuad"); +} + +void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix, + SkRect& geometry, int textureId, float opacity) { + + TransformationMatrix renderMatrix = drawMatrix; + renderMatrix.scale3d(geometry.width(), geometry.height(), 1); + renderMatrix.multiply(m_projectionMatrix); + + GLfloat projectionMatrix[16]; + GLUtils::toGLMatrix(projectionMatrix, renderMatrix); + glUniformMatrix4fv(m_hProjectionMatrix, 1, GL_FALSE, projectionMatrix); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, textureId); + + glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]); + glEnableVertexAttribArray(1); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0); + glBindAttribLocation(program(), 1, "vPosition"); + glUniform1f(alpha(), opacity); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } } // namespace WebCore diff --git a/WebCore/platform/graphics/android/ShaderProgram.h b/WebCore/platform/graphics/android/ShaderProgram.h index 4a8e96e..93a6d4c 100644 --- a/WebCore/platform/graphics/android/ShaderProgram.h +++ b/WebCore/platform/graphics/android/ShaderProgram.h @@ -36,6 +36,8 @@ class ShaderProgram { // Drawing void setViewport(SkRect& viewport); void drawQuad(SkRect& geometry, int textureId, float opacity); + void drawLayerQuad(const TransformationMatrix& drawMatrix, + SkRect& geometry, int textureId, float opacity); private: GLuint loadShader(GLenum shaderType, const char* pSource); |