summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-03-03 15:13:18 -0500
committerDerek Sollenberger <djsollen@google.com>2011-03-03 16:51:31 -0500
commit68a3ee86577b9e75d6bd88c49c86989a5c3e83cb (patch)
tree85a1db984d5c400fd1b755597dbda212090a3a17
parenta9f4668988e6d40d01ad07acb702d6fe71d4a5f5 (diff)
downloadexternal_webkit-68a3ee86577b9e75d6bd88c49c86989a5c3e83cb.zip
external_webkit-68a3ee86577b9e75d6bd88c49c86989a5c3e83cb.tar.gz
external_webkit-68a3ee86577b9e75d6bd88c49c86989a5c3e83cb.tar.bz2
ensure plugins draw correctly even when they have been given focus.
The initial attempt at fixing this bug was to modify the clip, but this was not correct and only fixed cases where the plugin was on the left edge of the screen. This CL properly adjusts the plugin's boundaries to make sure the content is drawn in the appropriate position. bug: 3477581 Change-Id: I5958228a93fa5600cd7e24ed9e7e1e26f6b241bc
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp15
-rw-r--r--WebCore/platform/graphics/android/MediaLayer.cpp52
-rw-r--r--WebCore/platform/graphics/android/MediaTexture.cpp13
-rw-r--r--WebCore/platform/graphics/android/MediaTexture.h2
-rw-r--r--WebCore/platform/graphics/android/ShaderProgram.cpp2
5 files changed, 42 insertions, 42 deletions
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 3706d20..f7e3f43 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -879,26 +879,19 @@ static inline bool compareLayerZ(const LayerAndroid* a, const LayerAndroid* b)
bool LayerAndroid::drawGL(SkMatrix& matrix)
{
- SkRect rect;
- rect.set(0, 0, getSize().width(), getSize().height());
-
TilesManager::instance()->shader()->clip(m_clippingRect);
if (prepareContext() && m_drawingTexture) {
TextureInfo* textureInfo = m_drawingTexture->consumerLock();
if (textureInfo) {
SkRect bounds;
- IntRect textureRect = m_drawingTexture->rect();
- bounds.set(0, 0, textureRect.width(), textureRect.height());
- // move the drawing depending on where the texture is on the layer
- TransformationMatrix m = drawTransform();
- m.translate(textureRect.x(), textureRect.y());
+ bounds.set(m_drawingTexture->rect());
XLOG("LayerAndroid %d %x (%.2f, %.2f) drawGL (texture %x, %d, %d, %d, %d)",
uniqueId(), this, getWidth(), getHeight(),
- m_drawingTexture, textureRect.x(), textureRect.y(),
- textureRect.width(), textureRect.height());
+ m_drawingTexture, bounds.x(), bounds.y(),
+ bounds.width(), bounds.height());
//TODO determine when drawing if the alpha value is used.
- TilesManager::instance()->shader()->drawLayerQuad(m, bounds,
+ TilesManager::instance()->shader()->drawLayerQuad(drawTransform(), bounds,
textureInfo->m_textureId,
m_drawOpacity, true);
}
diff --git a/WebCore/platform/graphics/android/MediaLayer.cpp b/WebCore/platform/graphics/android/MediaLayer.cpp
index 3d95211..2443a5e 100644
--- a/WebCore/platform/graphics/android/MediaLayer.cpp
+++ b/WebCore/platform/graphics/android/MediaLayer.cpp
@@ -75,43 +75,39 @@ MediaLayer::~MediaLayer()
bool MediaLayer::drawGL(SkMatrix& matrix)
{
- // when the plugin gains focus webkit applies an outline to the widget,
- // which causes the layer to expand to accommodate the outline. Therefore,
- // we shrink the clip by the outline's dimensions to ensure the plugin does
- // not draw outside of its bounds.
- FloatRect clip = drawClip();
- clip.inflate(-m_outlineSize);
- TilesManager::instance()->shader()->clip(clip);
+ TilesManager::instance()->shader()->clip(drawClip());
+
+ // when the plugin gains focus webkit applies an outline to the
+ // widget, which causes the layer to expand to accommodate the
+ // outline. Therefore, we shrink the rect by the outline's dimensions
+ // to ensure the plugin does not draw outside of its bounds.
+ SkRect mediaBounds;
+ mediaBounds.set(0, 0, getSize().width(), getSize().height());
+ mediaBounds.inset(m_outlineSize, m_outlineSize);
// check to see if we need to create a video texture
m_videoTexture->initNativeWindowIfNeeded();
// draw any video content if present
- m_videoTexture->drawVideo(drawTransform());
+ m_videoTexture->drawVideo(drawTransform(), mediaBounds);
// draw the primary content
if (m_bufferedTexture) {
TextureInfo* textureInfo = m_bufferedTexture->consumerLock();
- if (textureInfo) {
-
- SkRect rect;
- rect.set(0, 0, getSize().width(), getSize().height());
-
- if (textureInfo->m_width != 0 && textureInfo->m_height != 0) {
- // 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());
- }
-
- bool forceBlending = textureInfo->m_internalFormat == GL_RGBA ||
- textureInfo->m_internalFormat == GL_BGRA_EXT ||
- textureInfo->m_internalFormat == GL_ALPHA;
- TilesManager::instance()->shader()->drawLayerQuad(m, rect,
- textureInfo->m_textureId,
- 1.0f, forceBlending);
+ if (textureInfo && textureInfo->m_width != 0 && textureInfo->m_height != 0) {
+ // 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());
}
+
+ bool forceBlending = textureInfo->m_internalFormat == GL_RGBA ||
+ textureInfo->m_internalFormat == GL_BGRA_EXT ||
+ textureInfo->m_internalFormat == GL_ALPHA;
+ TilesManager::instance()->shader()->drawLayerQuad(m, mediaBounds,
+ textureInfo->m_textureId,
+ 1.0f, forceBlending);
}
m_bufferedTexture->consumerRelease();
}
diff --git a/WebCore/platform/graphics/android/MediaTexture.cpp b/WebCore/platform/graphics/android/MediaTexture.cpp
index 4ec50d8..9836a01 100644
--- a/WebCore/platform/graphics/android/MediaTexture.cpp
+++ b/WebCore/platform/graphics/android/MediaTexture.cpp
@@ -94,7 +94,7 @@ void VideoTexture::initNativeWindowIfNeeded()
m_newVideoRequestCond.signal();
}
-void VideoTexture::drawVideo(const TransformationMatrix& matrix)
+void VideoTexture::drawVideo(const TransformationMatrix& matrix, const SkRect& parentBounds)
{
android::Mutex::Autolock lock(m_videoLock);
@@ -107,8 +107,17 @@ void VideoTexture::drawVideo(const TransformationMatrix& matrix)
float surfaceMatrix[16];
m_surfaceTexture->getTransformMatrix(surfaceMatrix);
+ SkRect dimensions = m_dimensions;
+ dimensions.offset(parentBounds.fLeft, parentBounds.fTop);
+
+#ifdef DEBUG
+ if (!parentBounds.contains(dimensions)) {
+ XLOG("The video exceeds is parent's bounds.");
+ }
+#endif // DEBUG
+
TilesManager::instance()->shader()->drawVideoLayerQuad(matrix, surfaceMatrix,
- m_dimensions, m_textureId);
+ dimensions, m_textureId);
}
ANativeWindow* VideoTexture::requestNewWindow()
diff --git a/WebCore/platform/graphics/android/MediaTexture.h b/WebCore/platform/graphics/android/MediaTexture.h
index b3e1d07..b0c04a6 100644
--- a/WebCore/platform/graphics/android/MediaTexture.h
+++ b/WebCore/platform/graphics/android/MediaTexture.h
@@ -47,7 +47,7 @@ public:
~VideoTexture();
void initNativeWindowIfNeeded();
- void drawVideo(const TransformationMatrix& matrix);
+ void drawVideo(const TransformationMatrix& matrix, const SkRect& parentBounds);
ANativeWindow* requestNewWindow();
ANativeWindow* getNativeWindow();
diff --git a/WebCore/platform/graphics/android/ShaderProgram.cpp b/WebCore/platform/graphics/android/ShaderProgram.cpp
index 828cc37..ba32d5d 100644
--- a/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -306,6 +306,8 @@ void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
{
TransformationMatrix renderMatrix = drawMatrix;
+ // move the drawing depending on where the texture is on the layer
+ renderMatrix.translate(geometry.fLeft, geometry.fTop);
renderMatrix.scale3d(geometry.width(), geometry.height(), 1);
renderMatrix.multiply(m_projectionMatrix);