diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2011-09-20 14:27:34 -0700 |
---|---|---|
committer | Teng-Hui Zhu <ztenghui@google.com> | 2011-09-20 14:41:09 -0700 |
commit | 2bed0484fa3b4cac5cad82dc69affc5c49113fc4 (patch) | |
tree | 8518fbb7a28086ef5688005fb526a9b7cdc3922c /Source/WebCore/platform/graphics/android | |
parent | b94237ebf14cf9e894b24cfcc613960625b30494 (diff) | |
download | external_webkit-2bed0484fa3b4cac5cad82dc69affc5c49113fc4.zip external_webkit-2bed0484fa3b4cac5cad82dc69affc5c49113fc4.tar.gz external_webkit-2bed0484fa3b4cac5cad82dc69affc5c49113fc4.tar.bz2 |
Support drawing the quad in GL_NEAREST mode.
This can save the draw call perf up to about 20-40% for each quad.
We should make more draw calls using NEAREST mode when it is 1 to 1 mapping.
bug:5347539
Change-Id: I1ae206716f2b1352775e0079e25e54f46bc18578
Diffstat (limited to 'Source/WebCore/platform/graphics/android')
3 files changed, 10 insertions, 7 deletions
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp index bf5f760..3f265fc 100644 --- a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp +++ b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp @@ -294,6 +294,7 @@ void ShaderProgram::drawQuadInternal(SkRect& geometry, GLenum textureTarget, GLint position, GLint alpha, + GLint texFilter, GLint contrast) { glUseProgram(program); @@ -330,26 +331,26 @@ void ShaderProgram::drawQuadInternal(SkRect& geometry, } void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity, - GLenum textureTarget) + GLenum textureTarget, GLint texFilter) { if (textureTarget == GL_TEXTURE_2D) { drawQuadInternal(geometry, textureId, opacity, m_program, m_hProjectionMatrix, m_hTexSampler, GL_TEXTURE_2D, - m_hPosition, alpha()); + m_hPosition, alpha(), texFilter); } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES && !TilesManager::instance()->invertedScreen()) { drawQuadInternal(geometry, textureId, opacity, m_surfTexOESProgram, m_hSTOESProjectionMatrix, m_hSTOESTexSampler, GL_TEXTURE_EXTERNAL_OES, - m_hSTOESPosition, m_hSTOESAlpha); + m_hSTOESPosition, m_hSTOESAlpha, texFilter); } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES && TilesManager::instance()->invertedScreen()) { drawQuadInternal(geometry, textureId, opacity, m_surfTexOESProgramInverted, m_hSTOESProjectionMatrixInverted, m_hSTOESTexSamplerInverted, GL_TEXTURE_EXTERNAL_OES, m_hSTOESPositionInverted, m_hSTOESAlphaInverted, - m_hSTOESContrastInverted); + texFilter, m_hSTOESContrastInverted); } GLUtils::checkGlError("drawQuad"); } diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.h b/Source/WebCore/platform/graphics/android/ShaderProgram.h index d8447bf..5f5ce9f 100644 --- a/Source/WebCore/platform/graphics/android/ShaderProgram.h +++ b/Source/WebCore/platform/graphics/android/ShaderProgram.h @@ -54,7 +54,8 @@ public: // support Surface texture in GL_TEXTURE_EXTERNAL_OES target on all // platforms. void drawQuad(SkRect& geometry, int textureId, float opacity, - GLenum textureTarget = GL_TEXTURE_2D); + GLenum textureTarget = GL_TEXTURE_2D, + GLint texFilter = GL_LINEAR); void drawLayerQuad(const TransformationMatrix& drawMatrix, SkRect& geometry, int textureId, float opacity, bool forceBlending = false, @@ -99,7 +100,8 @@ private: void drawQuadInternal(SkRect& geometry, GLint textureId, float opacity, GLint program, GLint projectionMatrixHandle, GLint texSampler, GLenum textureTarget, - GLint position, GLint alpha, GLint contrast = -1); + GLint position, GLint alpha, + GLint texFilter, GLint contrast = -1); void drawLayerQuadInternal(const GLfloat* projectionMatrix, int textureId, float opacity, GLenum textureTarget, GLint program, diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp index 26b20dc..a8451a6 100644 --- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp +++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp @@ -154,7 +154,7 @@ void TransferQueue::blitTileFromQueue(GLuint fboID, BaseTileTexture* destTex, // Use empty rect to set up the special matrix to draw. SkRect rect = SkRect::MakeEmpty(); TilesManager::instance()->shader()->drawQuad(rect, srcTexId, 1.0, - srcTexTarget); + srcTexTarget, GL_NEAREST); // To workaround a sync issue on some platforms, we should insert the sync // here while in the current FBO. |