summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2011-08-31 14:46:17 -0700
committerTeng-Hui Zhu <ztenghui@google.com>2011-08-31 15:33:29 -0700
commit078f4452393311da6165131451fcf86e04e04f25 (patch)
tree4d5410e33b547c0fb727fa5fb82e7d3d432ea198 /Source/WebCore/platform/graphics
parentf735537049e4e7b11d2da9549b8fe5ba15e05e93 (diff)
downloadexternal_webkit-078f4452393311da6165131451fcf86e04e04f25.zip
external_webkit-078f4452393311da6165131451fcf86e04e04f25.tar.gz
external_webkit-078f4452393311da6165131451fcf86e04e04f25.tar.bz2
WebView animation support
bug:4982054 Change-Id: I6f4fe313d242f728a515c485a2531611d7166198
Diffstat (limited to 'Source/WebCore/platform/graphics')
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.cpp36
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.h6
3 files changed, 39 insertions, 5 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index e07c86f..bc07925 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -473,7 +473,7 @@ double GLWebViewState::setupDrawing(IntRect& viewRect, SkRect& visibleRect,
glUseProgram(shader->program());
glUniform1i(shader->textureSampler(), 0);
shader->setViewRect(viewRect);
- shader->setViewport(visibleRect);
+ shader->setViewport(visibleRect, scale);
shader->setWebViewRect(webViewRect);
shader->setTitleBarHeight(titleBarHeight);
shader->setScreenClip(screenClip);
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
index bf5f760..536d228 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -235,6 +235,8 @@ void ShaderProgram::init()
glBufferData(GL_ARRAY_BUFFER, 2 * 4 * sizeof(GLfloat), coord, GL_STATIC_DRAW);
GLUtils::checkGlError("init");
+
+ memset(m_webViewMatrix, 0, sizeof(m_webViewMatrix));
}
void ShaderProgram::resetBlending()
@@ -262,13 +264,14 @@ void ShaderProgram::setBlendingState(bool enableBlending)
// Drawing
/////////////////////////////////////////////////////////////////////////////////////////
-void ShaderProgram::setViewport(SkRect& viewport)
+void ShaderProgram::setViewport(SkRect& viewport, float scale)
{
TransformationMatrix ortho;
GLUtils::setOrthographicMatrix(ortho, viewport.fLeft, viewport.fTop,
viewport.fRight, viewport.fBottom, -1000, 1000);
m_projectionMatrix = ortho;
m_viewport = viewport;
+ m_currentScale = scale;
}
void ShaderProgram::setProjectionMatrix(SkRect& geometry, GLint projectionMatrixHandle)
@@ -277,8 +280,29 @@ void ShaderProgram::setProjectionMatrix(SkRect& geometry, GLint projectionMatrix
translate.translate3d(geometry.fLeft, geometry.fTop, 0.0);
TransformationMatrix scale;
scale.scale3d(geometry.width(), geometry.height(), 1.0);
-
- TransformationMatrix total = m_projectionMatrix * translate * scale;
+ // Translate float* to TransformationMatrix
+ TransformationMatrix webViewTransformMatrix(
+ m_webViewMatrix[0], m_webViewMatrix[1], m_webViewMatrix[2], m_webViewMatrix[3],
+ m_webViewMatrix[4], m_webViewMatrix[5], m_webViewMatrix[6], m_webViewMatrix[7],
+ m_webViewMatrix[8], m_webViewMatrix[9], m_webViewMatrix[10], m_webViewMatrix[11],
+ m_webViewMatrix[12], m_webViewMatrix[13], m_webViewMatrix[14], m_webViewMatrix[15] );
+
+
+ TransformationMatrix reposition;
+ // After the webViewTranform, we need to reposition the rect to match our viewport.
+ reposition.translate3d(-m_webViewRect.x(), -m_webViewRect.y() - m_titleBarHeight, 0);
+ reposition.translate3d(m_viewport.fLeft * m_currentScale, m_viewport.fTop * m_currentScale, 0);
+
+ // Basically, the webViewTransformMatrix should apply on the screen resolution.
+ // So we start by doing the scale and translate to get each tile into screen coordinates.
+ // After applying the webViewTransformMatrix, b/c the way it currently set up
+ // for scroll and titlebar, we need to offset both of them.
+ // Finally, map everything back to (-1, 1) by using the m_projectionMatrix.
+ // TODO: Given that webViewTransformMatrix contains most of the tranformation
+ // information, we should be able to get rid of some parameter we got from
+ // Java side and simplify our code.
+ TransformationMatrix total =
+ m_projectionMatrix * reposition * webViewTransformMatrix * translate * scale;
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, total);
@@ -573,6 +597,12 @@ void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
+void ShaderProgram::setWebViewMatrix(float* matrix)
+{
+ if (matrix)
+ memcpy(m_webViewMatrix, matrix, sizeof(m_webViewMatrix));
+}
+
} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.h b/Source/WebCore/platform/graphics/android/ShaderProgram.h
index d8447bf..f31eb91 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.h
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.h
@@ -39,7 +39,7 @@ public:
int program() { return m_program; }
// Drawing
- void setViewport(SkRect& viewport);
+ void setViewport(SkRect& viewport, float scale);
float zValue(const TransformationMatrix& drawMatrix, float w, float h);
// For drawQuad and drawLayerQuad, they can handle 3 cases for now:
@@ -88,6 +88,7 @@ public:
contrast = MAX_CONTRAST;
m_contrast = contrast;
}
+ void setWebViewMatrix(float* matrix);
private:
GLuint loadShader(GLenum shaderType, const char* pSource);
@@ -149,6 +150,9 @@ private:
// attribs
GLint m_hPosition;
GLint m_hVideoPosition;
+
+ float m_webViewMatrix[16];
+ float m_currentScale;
};
} // namespace WebCore