Changeset 146906 in webkit


Ignore:
Timestamp:
Mar 26, 2013 10:44:19 AM (11 years ago)
Author:
anilsson@rim.com
Message:

[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):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r146905 r146906  
     12013-03-26  Arvid Nilsson  <anilsson@rim.com>
     2
     3        [BlackBerry] WebOverlay::pixelViewportRect() should return pixel viewport coordinates
     4        https://bugs.webkit.org/show_bug.cgi?id=113263
     5
     6        Reviewed by Rob Buis.
     7
     8        PR 312404
     9
     10        Fix WebOverlay::pixelViewportRect() to return the pixel viewport rect
     11        instead of the window rect. These are different if the web page is
     12        rendered starting at a window coordinate other than 0,0. The clip rect
     13        encodes the position we're rendered at, and can be used to translate
     14        the rect expressed in window coordinates to the pixel viewport
     15        coordinate system.
     16
     17        Also perform some cleanup of related code.
     18
     19        Only manually testable.
     20
     21        * platform/graphics/blackberry/LayerCompositingThread.cpp:
     22        (WebCore::LayerCompositingThread::getTransformedHolePunchRect):
     23        (WebCore::LayerCompositingThread::drawTextures):
     24        * platform/graphics/blackberry/LayerRenderer.cpp:
     25        (WebCore::toPixelCoordinates):
     26        (WebCore):
     27        (WebCore::LayerRenderer::toWindowCoordinates):
     28        (WebCore::LayerRenderer::toPixelViewportCoordinates):
     29        (WebCore::LayerRenderer::toDocumentViewportCoordinates):
     30        (WebCore::LayerRenderer::updateLayersRecursive):
     31        * platform/graphics/blackberry/LayerRenderer.h:
     32        (LayerRenderer):
     33
    1342013-03-26  Sheriff Bot  <webkit.review.bot@gmail.com>
    235
  • trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp

    r146343 r146906  
    183183    // In order to clip we need to determine the current position of this layer, which
    184184    // is encoded in the m_drawTransform value, which was used to initialize m_drawRect.
    185     IntRect drawRect = m_layerRenderer->toWebKitDocumentCoordinates(m_drawRect);
     185    IntRect drawRect = m_layerRenderer->toDocumentViewportCoordinates(m_drawRect);
    186186
    187187    // Assert that in this case, where the hole punch rectangle equals the size of the layer,
     
    253253                    -m_transformedBounds.p1().y() * vrh2 + vrh2 + visibleRect.y());
    254254                paintRect = IntRect(roundedIntPoint(p), m_bounds);
    255             } else {
    256                 FloatRect r = m_layerRenderer->toWebKitWindowCoordinates(m_drawRect);
    257                 paintRect = enclosingIntRect(r);
    258             }
     255            } else
     256                paintRect = m_layerRenderer->toWindowCoordinates(m_drawRect);
     257
    259258            m_mediaPlayer->paint(0, paintRect);
    260259            MediaPlayerPrivate* mpp = static_cast<MediaPlayerPrivate*>(m_mediaPlayer->platformMedia().media.qnxMediaPlayer);
  • trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.cpp

    r146366 r146906  
    546546}
    547547
     548static FloatRect toPixelCoordinates(const FloatRect& rect, const IntRect& viewport, int surfaceHeight)
     549{
     550    float vw2 = viewport.width() / 2.0;
     551    float vh2 = viewport.height() / 2.0;
     552    float ox = viewport.x() + vw2;
     553    float oy = surfaceHeight - (viewport.y() + vh2);
     554    return FloatRect(rect.x() * vw2 + ox, -(rect.y() + rect.height()) * vh2 + oy, rect.width() * vw2, rect.height() * vh2);
     555}
     556
    548557// Transform normalized device coordinates to window coordinates as WebKit understands them.
    549558//
     
    551560// have origin in bottom left while WebKit window coordinates origin is in top left.
    552561// The viewport is setup to cover the upper portion of the larger OpenGL surface.
    553 IntRect LayerRenderer::toWebKitWindowCoordinates(const FloatRect& r) const
    554 {
    555     float vw2 = m_viewport.width() / 2.0;
    556     float vh2 = m_viewport.height() / 2.0;
    557     float ox = m_viewport.x() + vw2;
    558     float oy = m_client->context()->surfaceSize().height() - (m_viewport.y() + vh2);
    559     return enclosingIntRect(FloatRect(r.x() * vw2 + ox, -(r.y()+r.height()) * vh2 + oy, r.width() * vw2, r.height() * vh2));
    560 }
    561 
    562 // Similar to toWebKitWindowCoordinates except that this also takes any zoom into account.
    563 IntRect LayerRenderer::toWebKitDocumentCoordinates(const FloatRect& r) const
    564 {
    565     // The zoom is the ratio between visibleRect (or layoutRect) and dstRect parameters which are passed to drawLayers
    566     float zoom = m_visibleRect.width() / m_viewport.width();
    567     // Could assert here that it doesn't matter whether we choose width or height in the above statement:
    568     // because both rectangles should have very similar shapes (subject only to pixel rounding error).
    569 
    570     IntRect result = toWebKitWindowCoordinates(r);
    571     result.scale(zoom);
    572     return result;
     562IntRect LayerRenderer::toWindowCoordinates(const FloatRect& rect) const
     563{
     564    return enclosingIntRect(toPixelCoordinates(rect, m_viewport, m_client->context()->surfaceSize().height()));
     565}
     566
     567IntRect LayerRenderer::toPixelViewportCoordinates(const FloatRect& rect) const
     568{
     569    // The clip rect defines the web page's pixel viewport (to use ViewportAccessor terminology),
     570    // not to be confused with the GL viewport. So translate from window coordinates to pixel
     571    // viewport coordinates.
     572    int surfaceHeight = m_client->context()->surfaceSize().height();
     573    FloatRect pixelViewport = toPixelCoordinates(m_clipRect, m_viewport, surfaceHeight);
     574    FloatRect result = toPixelCoordinates(rect, m_viewport, surfaceHeight);
     575    result.move(-pixelViewport.x(), -pixelViewport.y());
     576    return enclosingIntRect(result);
     577}
     578
     579IntRect LayerRenderer::toDocumentViewportCoordinates(const FloatRect& rect) const
     580{
     581    // Similar to toPixelViewportCoordinates except that this also takes any zoom into account.
     582    FloatRect result = toPixelViewportCoordinates(rect);
     583    result.scale(1 / m_scale);
     584    return enclosingIntRect(result);
    573585}
    574586
     
    800812
    801813    if (layer->needsTexture() && layerVisible) {
    802         IntRect dirtyRect = toWebKitWindowCoordinates(intersection(layer->getDrawRect(), clipRect));
     814        IntRect dirtyRect = toWindowCoordinates(intersection(layer->getDrawRect(), clipRect));
    803815        m_lastRenderingResults.addDirtyRect(dirtyRect);
    804816    }
  • trunk/Source/WebCore/platform/graphics/blackberry/LayerRenderer.h

    r145953 r146906  
    127127    void setNeedsCommit() { m_needsCommit = true; }
    128128
    129     IntRect toWebKitWindowCoordinates(const FloatRect&) const;
    130     IntRect toWebKitDocumentCoordinates(const FloatRect&) const;
     129    IntRect toWindowCoordinates(const FloatRect&) const;
     130    IntRect toPixelViewportCoordinates(const FloatRect&) const;
     131    IntRect toDocumentViewportCoordinates(const FloatRect&) const;
    131132
    132133    // If the layer has already been drawed on a surface.
  • trunk/Source/WebKit/blackberry/Api/WebOverlay.cpp

    r146058 r146906  
    627627{
    628628    if (LayerRenderer* renderer = m_layerCompositingThread->layerRenderer())
    629         return renderer->toWebKitWindowCoordinates(m_layerCompositingThread->getDrawRect());
     629        return renderer->toPixelViewportCoordinates(m_layerCompositingThread->getDrawRect());
    630630
    631631    return Platform::IntRect();
  • trunk/Source/WebKit/blackberry/ChangeLog

    r146865 r146906  
     12013-03-26  Arvid Nilsson  <anilsson@rim.com>
     2
     3        [BlackBerry] WebOverlay::pixelViewportRect() should return pixel viewport coordinates
     4        https://bugs.webkit.org/show_bug.cgi?id=113263
     5
     6        Reviewed by Rob Buis.
     7
     8        PR 312404
     9
     10        Fixed by returning pixel viewport coordinates instead of window
     11        coordinates.
     12
     13        * Api/WebOverlay.cpp:
     14        (BlackBerry::WebKit::WebOverlayPrivateCompositingThread::pixelViewportRect):
     15
    1162013-03-26  Xiaobo Wang  <xbwang@torchmobile.com.cn>
    217
Note: See TracChangeset for help on using the changeset viewer.