Commit 302250bc authored by anilsson@rim.com's avatar anilsson@rim.com
Browse files

[BlackBerry] WebOverlay::pixelViewportRect() should return pixel viewport coordinates

https://bugs.webkit.org/show_bug.cgi?id=113263

Reviewed by Rob Buis.

PR 312404

Source/WebCore:

Fix WebOverlay::pixelViewportRect() to return the pixel viewport rect
instead of the window rect. These are different if the web page is
rendered starting at a window coordinate other than 0,0. The clip rect
encodes the position we're rendered at, and can be used to translate
the rect expressed in window coordinates to the pixel viewport
coordinate system.

Also perform some cleanup of related code.

Only manually testable.

* platform/graphics/blackberry/LayerCompositingThread.cpp:
(WebCore::LayerCompositingThread::getTransformedHolePunchRect):
(WebCore::LayerCompositingThread::drawTextures):
* platform/graphics/blackberry/LayerRenderer.cpp:
(WebCore::toPixelCoordinates):
(WebCore):
(WebCore::LayerRenderer::toWindowCoordinates):
(WebCore::LayerRenderer::toPixelViewportCoordinates):
(WebCore::LayerRenderer::toDocumentViewportCoordinates):
(WebCore::LayerRenderer::updateLayersRecursive):
* platform/graphics/blackberry/LayerRenderer.h:
(LayerRenderer):

Source/WebKit/blackberry:

Fixed by returning pixel viewport coordinates instead of window
coordinates.

* Api/WebOverlay.cpp:
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::pixelViewportRect):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146906 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 72190cac
2013-03-26 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] WebOverlay::pixelViewportRect() should return pixel viewport coordinates
https://bugs.webkit.org/show_bug.cgi?id=113263
Reviewed by Rob Buis.
PR 312404
Fix WebOverlay::pixelViewportRect() to return the pixel viewport rect
instead of the window rect. These are different if the web page is
rendered starting at a window coordinate other than 0,0. The clip rect
encodes the position we're rendered at, and can be used to translate
the rect expressed in window coordinates to the pixel viewport
coordinate system.
Also perform some cleanup of related code.
Only manually testable.
* platform/graphics/blackberry/LayerCompositingThread.cpp:
(WebCore::LayerCompositingThread::getTransformedHolePunchRect):
(WebCore::LayerCompositingThread::drawTextures):
* platform/graphics/blackberry/LayerRenderer.cpp:
(WebCore::toPixelCoordinates):
(WebCore):
(WebCore::LayerRenderer::toWindowCoordinates):
(WebCore::LayerRenderer::toPixelViewportCoordinates):
(WebCore::LayerRenderer::toDocumentViewportCoordinates):
(WebCore::LayerRenderer::updateLayersRecursive):
* platform/graphics/blackberry/LayerRenderer.h:
(LayerRenderer):
2013-03-26 Sheriff Bot <webkit.review.bot@gmail.com>
 
Unreviewed, rolling out r146901.
......@@ -182,7 +182,7 @@ FloatQuad LayerCompositingThread::getTransformedHolePunchRect() const
// In order to clip we need to determine the current position of this layer, which
// is encoded in the m_drawTransform value, which was used to initialize m_drawRect.
IntRect drawRect = m_layerRenderer->toWebKitDocumentCoordinates(m_drawRect);
IntRect drawRect = m_layerRenderer->toDocumentViewportCoordinates(m_drawRect);
// Assert that in this case, where the hole punch rectangle equals the size of the layer,
// the drawRect has the same size as the hole punch.
......@@ -252,10 +252,9 @@ void LayerCompositingThread::drawTextures(double scale, const GLES2Program& prog
FloatPoint p(m_transformedBounds.p1().x() * vrw2 + vrw2 + visibleRect.x(),
-m_transformedBounds.p1().y() * vrh2 + vrh2 + visibleRect.y());
paintRect = IntRect(roundedIntPoint(p), m_bounds);
} else {
FloatRect r = m_layerRenderer->toWebKitWindowCoordinates(m_drawRect);
paintRect = enclosingIntRect(r);
}
} else
paintRect = m_layerRenderer->toWindowCoordinates(m_drawRect);
m_mediaPlayer->paint(0, paintRect);
MediaPlayerPrivate* mpp = static_cast<MediaPlayerPrivate*>(m_mediaPlayer->platformMedia().media.qnxMediaPlayer);
mpp->drawBufferingAnimation(m_drawTransform, program);
......
......@@ -545,31 +545,43 @@ IntRect LayerRenderer::toOpenGLWindowCoordinates(const FloatRect& r) const
return IntRect(glRound(r.x() * vw2 + ox), glRound(r.y() * vh2 + oy), glRound(r.width() * vw2), glRound(r.height() * vh2));
}
static FloatRect toPixelCoordinates(const FloatRect& rect, const IntRect& viewport, int surfaceHeight)
{
float vw2 = viewport.width() / 2.0;
float vh2 = viewport.height() / 2.0;
float ox = viewport.x() + vw2;
float oy = surfaceHeight - (viewport.y() + vh2);
return FloatRect(rect.x() * vw2 + ox, -(rect.y() + rect.height()) * vh2 + oy, rect.width() * vw2, rect.height() * vh2);
}
// Transform normalized device coordinates to window coordinates as WebKit understands them.
//
// The OpenGL surface may be larger than the WebKit window, and OpenGL window coordinates
// have origin in bottom left while WebKit window coordinates origin is in top left.
// The viewport is setup to cover the upper portion of the larger OpenGL surface.
IntRect LayerRenderer::toWebKitWindowCoordinates(const FloatRect& r) const
IntRect LayerRenderer::toWindowCoordinates(const FloatRect& rect) const
{
float vw2 = m_viewport.width() / 2.0;
float vh2 = m_viewport.height() / 2.0;
float ox = m_viewport.x() + vw2;
float oy = m_client->context()->surfaceSize().height() - (m_viewport.y() + vh2);
return enclosingIntRect(FloatRect(r.x() * vw2 + ox, -(r.y()+r.height()) * vh2 + oy, r.width() * vw2, r.height() * vh2));
return enclosingIntRect(toPixelCoordinates(rect, m_viewport, m_client->context()->surfaceSize().height()));
}
IntRect LayerRenderer::toPixelViewportCoordinates(const FloatRect& rect) const
{
// The clip rect defines the web page's pixel viewport (to use ViewportAccessor terminology),
// not to be confused with the GL viewport. So translate from window coordinates to pixel
// viewport coordinates.
int surfaceHeight = m_client->context()->surfaceSize().height();
FloatRect pixelViewport = toPixelCoordinates(m_clipRect, m_viewport, surfaceHeight);
FloatRect result = toPixelCoordinates(rect, m_viewport, surfaceHeight);
result.move(-pixelViewport.x(), -pixelViewport.y());
return enclosingIntRect(result);
}
// Similar to toWebKitWindowCoordinates except that this also takes any zoom into account.
IntRect LayerRenderer::toWebKitDocumentCoordinates(const FloatRect& r) const
IntRect LayerRenderer::toDocumentViewportCoordinates(const FloatRect& rect) const
{
// The zoom is the ratio between visibleRect (or layoutRect) and dstRect parameters which are passed to drawLayers
float zoom = m_visibleRect.width() / m_viewport.width();
// Could assert here that it doesn't matter whether we choose width or height in the above statement:
// because both rectangles should have very similar shapes (subject only to pixel rounding error).
IntRect result = toWebKitWindowCoordinates(r);
result.scale(zoom);
return result;
// Similar to toPixelViewportCoordinates except that this also takes any zoom into account.
FloatRect result = toPixelViewportCoordinates(rect);
result.scale(1 / m_scale);
return enclosingIntRect(result);
}
// Draws a debug border around the layer's bounds.
......@@ -799,7 +811,7 @@ void LayerRenderer::updateLayersRecursive(LayerCompositingThread* layer, const T
#endif
if (layer->needsTexture() && layerVisible) {
IntRect dirtyRect = toWebKitWindowCoordinates(intersection(layer->getDrawRect(), clipRect));
IntRect dirtyRect = toWindowCoordinates(intersection(layer->getDrawRect(), clipRect));
m_lastRenderingResults.addDirtyRect(dirtyRect);
}
......
......@@ -126,8 +126,9 @@ public:
// Used when a layer discovers during rendering that it needs a commit.
void setNeedsCommit() { m_needsCommit = true; }
IntRect toWebKitWindowCoordinates(const FloatRect&) const;
IntRect toWebKitDocumentCoordinates(const FloatRect&) const;
IntRect toWindowCoordinates(const FloatRect&) const;
IntRect toPixelViewportCoordinates(const FloatRect&) const;
IntRect toDocumentViewportCoordinates(const FloatRect&) const;
// If the layer has already been drawed on a surface.
bool layerAlreadyOnSurface(LayerCompositingThread*) const;
......
......@@ -626,7 +626,7 @@ void WebOverlayPrivateCompositingThread::removeAnimation(const String& name)
Platform::IntRect WebOverlayPrivateCompositingThread::pixelViewportRect() const
{
if (LayerRenderer* renderer = m_layerCompositingThread->layerRenderer())
return renderer->toWebKitWindowCoordinates(m_layerCompositingThread->getDrawRect());
return renderer->toPixelViewportCoordinates(m_layerCompositingThread->getDrawRect());
return Platform::IntRect();
}
......
2013-03-26 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] WebOverlay::pixelViewportRect() should return pixel viewport coordinates
https://bugs.webkit.org/show_bug.cgi?id=113263
Reviewed by Rob Buis.
PR 312404
Fixed by returning pixel viewport coordinates instead of window
coordinates.
* Api/WebOverlay.cpp:
(BlackBerry::WebKit::WebOverlayPrivateCompositingThread::pixelViewportRect):
2013-03-26 Xiaobo Wang <xbwang@torchmobile.com.cn>
 
[BlackBerry] Memory leak in UserMediaClientImpl
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment