summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-01-31 16:27:02 -0500
committerDerek Sollenberger <djsollen@google.com>2011-01-31 17:34:33 -0500
commit9b4518afdef9240b40c293834fab99b312d41d57 (patch)
tree8b9ed378ebce0a37fcc4b7d756a88c901560196c /WebCore/platform
parent25207148f6b10a10f544078777187966591eabb1 (diff)
downloadexternal_webkit-9b4518afdef9240b40c293834fab99b312d41d57.zip
external_webkit-9b4518afdef9240b40c293834fab99b312d41d57.tar.gz
external_webkit-9b4518afdef9240b40c293834fab99b312d41d57.tar.bz2
Add new vertex shader to support video transforms.
bug: 3072603 Change-Id: I59e52cc9672c653760351b835c63d0496e6ff6ff
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/graphics/android/MediaTexture.cpp7
-rw-r--r--WebCore/platform/graphics/android/ShaderProgram.cpp17
-rw-r--r--WebCore/platform/graphics/android/ShaderProgram.h3
3 files changed, 23 insertions, 4 deletions
diff --git a/WebCore/platform/graphics/android/MediaTexture.cpp b/WebCore/platform/graphics/android/MediaTexture.cpp
index cf6f5b3..8481a20 100644
--- a/WebCore/platform/graphics/android/MediaTexture.cpp
+++ b/WebCore/platform/graphics/android/MediaTexture.cpp
@@ -86,7 +86,12 @@ void VideoTexture::drawVideo(const TransformationMatrix& matrix)
return;
m_surfaceTexture->updateTexImage();
- TilesManager::instance()->shader()->drawVideoLayerQuad(matrix, m_dimensions, m_textureId);
+
+ float surfaceMatrix[16];
+ m_surfaceTexture->getTransformMatrix(surfaceMatrix);
+
+ TilesManager::instance()->shader()->drawVideoLayerQuad(matrix, surfaceMatrix,
+ m_dimensions, m_textureId);
}
ANativeWindow* VideoTexture::requestNewWindow()
diff --git a/WebCore/platform/graphics/android/ShaderProgram.cpp b/WebCore/platform/graphics/android/ShaderProgram.cpp
index 0237f03..8da6855 100644
--- a/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -59,6 +59,16 @@ static const char gFragmentShader[] =
" gl_FragColor *= alpha; "
"}\n";
+static const char gVideoVertexShader[] =
+ "attribute vec4 vPosition;\n"
+ "uniform mat4 textureMatrix;\n"
+ "uniform mat4 projectionMatrix;\n"
+ "varying vec2 v_texCoord;\n"
+ "void main() {\n"
+ " gl_Position = projectionMatrix * vPosition;\n"
+ " v_texCoord = vec2(textureMatrix * vec4(vPosition.x, 1.0 - vPosition.y, 0.0, 1.0));\n"
+ "}\n";
+
static const char gVideoFragmentShader[] =
"#extension GL_OES_EGL_image_external : require\n"
"precision mediump float;\n"
@@ -145,13 +155,14 @@ ShaderProgram::ShaderProgram()
void ShaderProgram::init()
{
m_program = createProgram(gVertexShader, gFragmentShader);
- m_videoProgram = createProgram(gVertexShader, gVideoFragmentShader);
+ m_videoProgram = createProgram(gVideoVertexShader, gVideoFragmentShader);
m_hProjectionMatrix = glGetUniformLocation(m_program, "projectionMatrix");
m_hAlpha = glGetUniformLocation(m_program, "alpha");
m_hTexSampler = glGetUniformLocation(m_program, "s_texture");
m_hVideoProjectionMatrix = glGetUniformLocation(m_videoProgram, "projectionMatrix");
+ m_hVideoTextureMatrix = glGetUniformLocation(m_videoProgram, "textureMatrix");
m_hVideoTexSampler = glGetUniformLocation(m_videoProgram, "s_yuvTexture");
const GLfloat coord[] = {
@@ -288,7 +299,8 @@ void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
}
void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
- SkRect& geometry, int textureId)
+ float* textureMatrix, SkRect& geometry,
+ int textureId)
{
// switch to our custom yuv video rendering program
glUseProgram(m_videoProgram);
@@ -301,6 +313,7 @@ void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, renderMatrix);
glUniformMatrix4fv(m_hVideoProjectionMatrix, 1, GL_FALSE, projectionMatrix);
+ glUniformMatrix4fv(m_hVideoTextureMatrix, 1, GL_FALSE, textureMatrix);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, textureId);
diff --git a/WebCore/platform/graphics/android/ShaderProgram.h b/WebCore/platform/graphics/android/ShaderProgram.h
index fcb093b..1f94290 100644
--- a/WebCore/platform/graphics/android/ShaderProgram.h
+++ b/WebCore/platform/graphics/android/ShaderProgram.h
@@ -42,7 +42,7 @@ class ShaderProgram {
void drawLayerQuad(const TransformationMatrix& drawMatrix,
SkRect& geometry, int textureId, float opacity);
void drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
- SkRect& geometry, int textureId);
+ float* textureMatrix, SkRect& geometry, int textureId);
void setViewRect(const IntRect& viewRect);
FloatRect clipRectInScreenCoord(const TransformationMatrix& drawMatrix,
const IntSize& size);
@@ -70,6 +70,7 @@ class ShaderProgram {
int m_hAlpha;
int m_hTexSampler;
int m_hVideoProjectionMatrix;
+ int m_hVideoTextureMatrix;
int m_hVideoTexSampler;
};