From 0bc8a6f1de48da432733e2bd21c5c793b7a0393d Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Tue, 31 May 2011 15:24:42 -0700 Subject: Support the screen shot while the video is paused. Basically, the GL textures generated for the surface texture will be used for showing the screenshot. Surface texture will be recycled every time a new video starts. But GL textures will be recycled either when running out of memory bound, or when the mediaplayer is deleted. 1. Add the VideoLayerManager as a static instance to manage the info of textures allocated for the screenshot. The basic info will be added into the manager while the video is played and prepared. During the draw time, the matirx info will be updated, too. 2. When there are too many screenshots are created, then we will discard the oldest one and just show the grey static rectangle to replace the screenshot. The corresponding framework change is 112501. Change-Id: Ifea60c96532500f9c93062cc97f7c4ef978046b0 --- .../graphics/android/VideoLayerAndroid.cpp | 37 ++++++++++++++-------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp') diff --git a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp index 32e518d..aee5ae0 100644 --- a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp @@ -75,9 +75,7 @@ void VideoLayerAndroid::init() { // m_surfaceTexture is only useful on UI thread, no need to copy. // And it will be set at setBaseLayer timeframe - m_playerState = INITIALIZED; - m_textureId = 0; } // We can use this function to set the Layer to point to surface texture. @@ -85,9 +83,8 @@ void VideoLayerAndroid::setSurfaceTexture(sp texture, int textureName, PlayerState playerState) { m_surfaceTexture = texture; - m_textureId = textureName; - m_playerState = playerState; + TilesManager::instance()->videoLayerManager()->registerTexture(uniqueId(), textureName); } GLuint VideoLayerAndroid::createSpinnerInnerTexture() @@ -199,18 +196,32 @@ bool VideoLayerAndroid::drawGL(GLWebViewState* glWebViewState, SkMatrix& matrix) // Show the real video. m_surfaceTexture->updateTexImage(); m_surfaceTexture->getTransformMatrix(surfaceMatrix); + GLuint textureId = + TilesManager::instance()->videoLayerManager()->getTextureId(uniqueId()); TilesManager::instance()->shader()->drawVideoLayerQuad(drawTransform(), surfaceMatrix, - rect, m_textureId); + rect, textureId); + TilesManager::instance()->videoLayerManager()->updateMatrix(uniqueId(), + surfaceMatrix); } else { - // Show the poster - TilesManager::instance()->shader()->drawLayerQuad(drawTransform(), rect, - m_backgroundTextureId, - 0.5, true); - - TilesManager::instance()->shader()->drawLayerQuad(drawTransform(), innerRect, - m_posterTextureId, - 1, true); + GLuint textureId = + TilesManager::instance()->videoLayerManager()->getTextureId(uniqueId()); + GLfloat* matrix = + TilesManager::instance()->videoLayerManager()->getMatrix(uniqueId()); + if (textureId && matrix) { + // Show the screen shot for each video. + TilesManager::instance()->shader()->drawVideoLayerQuad(drawTransform(), + matrix, + rect, textureId); + } else { + // Show the static poster b/c there is no screen shot available. + TilesManager::instance()->shader()->drawLayerQuad(drawTransform(), rect, + m_backgroundTextureId, + 0.5, true); + TilesManager::instance()->shader()->drawLayerQuad(drawTransform(), innerRect, + m_posterTextureId, + 1, true); + } } return drawChildrenGL(glWebViewState, matrix); -- cgit v1.1