diff options
Diffstat (limited to 'WebCore/platform')
7 files changed, 50 insertions, 22 deletions
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index c602d63..2446cb1 100644 --- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -121,8 +121,6 @@ void BaseLayerAndroid::drawCanvas(SkCanvas* canvas) #if USE(ACCELERATED_COMPOSITING) bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale) { - if (m_content.isEmpty()) - return false; if (!m_glWebViewState) return false; @@ -269,9 +267,6 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect, XLOG("drawBasePicture drawGL() viewRect: %d, %d, %d, %d", left, top, width, height); - glEnable(GL_SCISSOR_TEST); - - glScissor(left, top, width, height); glClearColor((float)m_color.red() / 255.0, (float)m_color.green() / 255.0, (float)m_color.blue() / 255.0, 1); @@ -340,7 +335,6 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect, } else { TilesManager::instance()->cleanupLayersTextures(0); } - glDisable(GL_SCISSOR_TEST); glBindBuffer(GL_ARRAY_BUFFER, 0); m_previousVisible = visibleRect; diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index ab0e0ea..e887964 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -768,9 +768,25 @@ void GraphicsLayerAndroid::setContentsToMedia(PlatformLayer* mediaLayer) // Only fullscreen video on Android, so media doesn't get it's own layer. // We might still have other layers though. if (m_contentLayer != mediaLayer && mediaLayer) { + + // TODO add a copy method to LayerAndroid to sync everything + // copy data from the original content layer to the new one + mediaLayer->setPosition(m_contentLayer->getPosition().fX, + m_contentLayer->getPosition().fY); + mediaLayer->setSize(m_contentLayer->getWidth(), m_contentLayer->getHeight()); + mediaLayer->setDrawTransform(m_contentLayer->drawTransform()); + m_contentLayer->unref(); m_contentLayer = mediaLayer; m_contentLayer->ref(); + + // If the parent exists then notify it to re-sync it's children + if (m_parent) { + GraphicsLayerAndroid* parent = static_cast<GraphicsLayerAndroid*>(m_parent); + parent->m_needsSyncChildren = true; + } + m_needsSyncChildren = true; + setNeedsDisplay(); askForSync(); } diff --git a/WebCore/platform/graphics/android/MediaLayer.cpp b/WebCore/platform/graphics/android/MediaLayer.cpp index 3ec21a4..fac94f5 100644 --- a/WebCore/platform/graphics/android/MediaLayer.cpp +++ b/WebCore/platform/graphics/android/MediaLayer.cpp @@ -73,24 +73,23 @@ MediaLayer::~MediaLayer() bool MediaLayer::drawGL(SkMatrix& matrix) { - - TransformationMatrix m = drawTransform(); - // the layer's shader draws the content inverted so we must undo - // that change in the transformation matrix - if (!m_isContentInverted) { - m.flipY(); - m.translate(0, -getSize().height()); - } - // check to see if we need to create a video texture m_videoTexture->initNativeWindowIfNeeded(); // draw any video content if present - m_videoTexture->drawVideo(m); + m_videoTexture->drawVideo(drawTransform()); // draw the primary content if (m_bufferedTexture) { TextureInfo* textureInfo = m_bufferedTexture->consumerLock(); if (textureInfo) { + // the layer's shader draws the content inverted so we must undo + // that change in the transformation matrix + TransformationMatrix m = drawTransform(); + if (!m_isContentInverted) { + m.flipY(); + m.translate(0, -getSize().height()); + } + SkRect rect; rect.set(0, 0, getSize().width(), getSize().height()); TilesManager::instance()->shader()->drawLayerQuad(m, rect, diff --git a/WebCore/platform/graphics/android/MediaTexture.cpp b/WebCore/platform/graphics/android/MediaTexture.cpp index 22fabc3..8481a20 100644 --- a/WebCore/platform/graphics/android/MediaTexture.cpp +++ b/WebCore/platform/graphics/android/MediaTexture.cpp @@ -78,7 +78,7 @@ void VideoTexture::initNativeWindowIfNeeded() m_newVideoRequestCond.signal(); } -void VideoTexture::drawVideo(TransformationMatrix matrix) +void VideoTexture::drawVideo(const TransformationMatrix& matrix) { android::Mutex::Autolock lock(m_videoLock); @@ -86,7 +86,12 @@ void VideoTexture::drawVideo(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/MediaTexture.h b/WebCore/platform/graphics/android/MediaTexture.h index abb8081..156a67f 100644 --- a/WebCore/platform/graphics/android/MediaTexture.h +++ b/WebCore/platform/graphics/android/MediaTexture.h @@ -44,7 +44,7 @@ public: ~VideoTexture(); void initNativeWindowIfNeeded(); - void drawVideo(TransformationMatrix matrix); + void drawVideo(const TransformationMatrix& matrix); ANativeWindow* requestNewWindow(); ANativeWindow* getNativeWindow(); 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; }; |