Changeset 136976 in webkit


Ignore:
Timestamp:
Dec 7, 2012 1:15:07 PM (11 years ago)
Author:
kenneth@webkit.org
Message:

[WK2][EFL][Qt] Pixel alignment is wrong in some cases involving a non-integral content scale
https://webkit.org/b/103519

Reviewed by Noam Rosenthal.

This patch removes the blurriness by pixel aligning the layers. It
does not fully remove the shaking, only minimizes it.

  • UIProcess/API/efl/EwkViewImpl.cpp:

(EwkViewImpl::transformFromScene):
(EwkViewImpl::displayTimerFired):

  • UIProcess/API/efl/EwkViewImpl.h:

(EwkViewImpl::pagePosition):

As the pixel alignment of the main layer is moved to the
PageViewportController, rename discretePagePosition to just
pagePosition. It now returns a FloatPoint but the positions
should still be discrete.

  • UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp:

(WebKit::LayerTreeCoordinatorProxy::setVisibleContentsRect):
(WebKit::LayerTreeCoordinatorProxy::didChangeScrollPosition):

  • UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h:

(LayerTreeCoordinatorProxy):

  • UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in:
  • UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:

(WebKit::LayerTreeRenderer::didChangeScrollPosition):

  • UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:

(LayerTreeRenderer):

  • WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:

(WebKit::LayerTreeCoordinator::visibleContentsRect):
(WebKit::LayerTreeCoordinator::setVisibleContentsRect):

  • WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h:

(LayerTreeCoordinator):

  • WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.messages.in:
  • WebProcess/WebPage/LayerTreeHost.h:

(WebCore):
(WebKit::LayerTreeHost::setVisibleContentsRect):

Change the internal scroll position/visible contents rect
to be represented as float positions. The rounding to integer
values not happens just before setFixesVisibleContentsRect.
This makes it possible to know our exact positions and
calculate proper scroll deltas.

(WebKit::LayerTreeRenderer::setLayerState):

Group anchor point, position and size together.

  • UIProcess/PageViewportController.h:

(PageViewportController):

  • UIProcess/PageViewportController.cpp:

(WebKit::PageViewportController::PageViewportController):
(WebKit::PageViewportController::boundContentsPosition):
(WebKit::PageViewportController::boundContentsPositionAtScale):
(WebKit::PageViewportController::didRenderFrame):
(WebKit::PageViewportController::pageDidRequestScroll):
(WebKit::PageViewportController::didChangeContentsVisibility):
(WebKit::PageViewportController::syncVisibleContents):
(WebKit::PageViewportController::visibleContentsSize):
(WebKit::PageViewportController::applyPositionAfterRenderingContents):

  • UIProcess/qt/PageViewportControllerClientQt.cpp:

(WebKit::PageViewportControllerClientQt::focusEditableArea):
(WebKit::PageViewportControllerClientQt::zoomToAreaGestureEnded):
(WebKit::PageViewportControllerClientQt::nearestValidVisibleContentsRect):

Some renaming as what was called viewportPos was actually the
contents position. Rename clampViewportToContents to
boundContentsPosition and remove scale argument which is has
direct access to.

Make the boundContentsPosition allow one extra pixel in each
orientation to allow for pixel alignment of fixed position layers

(WebKit::isIntegral):
(WebKit):
(WebKit::PageViewportController::pixelAlignedFloatPoint):

Introduce way to pixel align the main contents layer. Only in
use for EFL so far.

  • UIProcess/efl/PageClientLegacyImpl.cpp:

(WebKit::PageClientLegacyImpl::updateViewportSize):

  • UIProcess/efl/PageViewportControllerClientEfl.cpp:

(WebKit::PageViewportControllerClientEfl::setViewportPosition):

  • UIProcess/efl/PageViewportControllerClientEfl.h:

(WebKit::PageViewportControllerClientEfl::contentPosition):
(PageViewportControllerClientEfl):

Store the contents position as a FloatPoint.

  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:

(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
(WebCore::CoordinatedGraphicsLayer::setMaskLayer):
(WebCore::CoordinatedGraphicsLayer::syncLayerState):
(WebCore::CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect):
(WebCore::isIntegral):
(WebCore):
(WebCore::CoordinatedGraphicsLayer::computePositionRelativeToBase):
(WebCore::CoordinatedGraphicsLayer::computePixelAlignment):
(WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):

  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:

(CoordinatedGraphicsLayerClient):
(CoordinatedGraphicsLayer):

Pixel align layers when the effective scale is not an integer
value. This code is based on code from GraphicsLayerCA.

Location:
trunk/Source/WebKit2
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r136973 r136976  
     12012-12-07  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        [WK2][EFL][Qt] Pixel alignment is wrong in some cases involving a non-integral content scale
     4        https://webkit.org/b/103519
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        This patch removes the blurriness by pixel aligning the layers. It
     9        does not fully remove the shaking, only minimizes it.
     10
     11        * UIProcess/API/efl/EwkViewImpl.cpp:
     12        (EwkViewImpl::transformFromScene):
     13        (EwkViewImpl::displayTimerFired):
     14        * UIProcess/API/efl/EwkViewImpl.h:
     15        (EwkViewImpl::pagePosition):
     16
     17            As the pixel alignment of the main layer is moved to the
     18            PageViewportController, rename discretePagePosition to just
     19            pagePosition. It now returns a FloatPoint but the positions
     20            should still be discrete.
     21
     22        * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp:
     23        (WebKit::LayerTreeCoordinatorProxy::setVisibleContentsRect):
     24        (WebKit::LayerTreeCoordinatorProxy::didChangeScrollPosition):
     25        * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h:
     26        (LayerTreeCoordinatorProxy):
     27        * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in:
     28        * UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
     29        (WebKit::LayerTreeRenderer::didChangeScrollPosition):
     30        * UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:
     31        (LayerTreeRenderer):
     32        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
     33        (WebKit::LayerTreeCoordinator::visibleContentsRect):
     34        (WebKit::LayerTreeCoordinator::setVisibleContentsRect):
     35        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h:
     36        (LayerTreeCoordinator):
     37        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.messages.in:
     38        * WebProcess/WebPage/LayerTreeHost.h:
     39        (WebCore):
     40        (WebKit::LayerTreeHost::setVisibleContentsRect):
     41
     42            Change the internal scroll position/visible contents rect
     43            to be represented as float positions. The rounding to integer
     44            values not happens just before setFixesVisibleContentsRect.
     45            This makes it possible to know our exact positions and
     46            calculate proper scroll deltas.
     47
     48        (WebKit::LayerTreeRenderer::setLayerState):
     49
     50            Group anchor point, position and size together.
     51
     52        * UIProcess/PageViewportController.h:
     53        (PageViewportController):
     54        * UIProcess/PageViewportController.cpp:
     55        (WebKit::PageViewportController::PageViewportController):
     56        (WebKit::PageViewportController::boundContentsPosition):
     57        (WebKit::PageViewportController::boundContentsPositionAtScale):
     58        (WebKit::PageViewportController::didRenderFrame):
     59        (WebKit::PageViewportController::pageDidRequestScroll):
     60        (WebKit::PageViewportController::didChangeContentsVisibility):
     61        (WebKit::PageViewportController::syncVisibleContents):
     62        (WebKit::PageViewportController::visibleContentsSize):
     63        (WebKit::PageViewportController::applyPositionAfterRenderingContents):
     64        * UIProcess/qt/PageViewportControllerClientQt.cpp:
     65        (WebKit::PageViewportControllerClientQt::focusEditableArea):
     66        (WebKit::PageViewportControllerClientQt::zoomToAreaGestureEnded):
     67        (WebKit::PageViewportControllerClientQt::nearestValidVisibleContentsRect):
     68
     69            Some renaming as what was called viewportPos was actually the
     70            contents position. Rename clampViewportToContents to
     71            boundContentsPosition and remove scale argument which is has
     72            direct access to.
     73
     74            Make the boundContentsPosition allow one extra pixel in each
     75            orientation to allow for pixel alignment of fixed position layers
     76
     77        (WebKit::isIntegral):
     78        (WebKit):
     79        (WebKit::PageViewportController::pixelAlignedFloatPoint):
     80
     81            Introduce way to pixel align the main contents layer. Only in
     82            use for EFL so far.
     83
     84        * UIProcess/efl/PageClientLegacyImpl.cpp:
     85        (WebKit::PageClientLegacyImpl::updateViewportSize):
     86        * UIProcess/efl/PageViewportControllerClientEfl.cpp:
     87        (WebKit::PageViewportControllerClientEfl::setViewportPosition):
     88        * UIProcess/efl/PageViewportControllerClientEfl.h:
     89        (WebKit::PageViewportControllerClientEfl::contentPosition):
     90        (PageViewportControllerClientEfl):
     91
     92            Store the contents position as a FloatPoint.
     93
     94        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp:
     95        (WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
     96        (WebCore::CoordinatedGraphicsLayer::setMaskLayer):
     97        (WebCore::CoordinatedGraphicsLayer::syncLayerState):
     98        (WebCore::CoordinatedGraphicsLayer::tiledBackingStoreVisibleRect):
     99        (WebCore::isIntegral):
     100        (WebCore):
     101        (WebCore::CoordinatedGraphicsLayer::computePositionRelativeToBase):
     102        (WebCore::CoordinatedGraphicsLayer::computePixelAlignment):
     103        (WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):
     104        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h:
     105        (CoordinatedGraphicsLayerClient):
     106        (CoordinatedGraphicsLayer):
     107
     108            Pixel align layers when the effective scale is not an integer
     109            value. This code is based on code from GraphicsLayerCA.
     110
    11112012-12-07  Alexey Proskuryakov  <ap@apple.com>
    2112
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp

    r136485 r136976  
    296296#if USE(TILED_BACKING_STORE)
    297297    transform.scale(1 / m_scaleFactor);
    298     transform.translate(discretePagePosition().x(), discretePagePosition().y());
     298    transform.translate(pagePosition().x(), pagePosition().y());
    299299#endif
    300300
     
    392392
    393393        RefPtr<cairo_t> graphicsContext = adoptRef(cairo_create(surface.get()));
    394         cairo_translate(graphicsContext.get(), - discretePagePosition().x(), - discretePagePosition().y());
     394        cairo_translate(graphicsContext.get(), - pagePosition().x(), - pagePosition().y());
    395395        cairo_scale(graphicsContext.get(), m_scaleFactor, m_scaleFactor);
    396396        renderer->paintToGraphicsContext(graphicsContext.get());
  • trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h

    r136402 r136976  
    203203
    204204    void setPagePosition(const WebCore::FloatPoint& position) { m_pagePosition = position; }
    205     const WebCore::IntPoint discretePagePosition() const { return roundedIntPoint(m_pagePosition); }
     205    const WebCore::FloatPoint pagePosition() const { return m_pagePosition; }
    206206#endif
    207207
  • trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp

    r136912 r136976  
    182182    dispatchUpdate(bind(&LayerTreeRenderer::setVisibleContentsRect, m_renderer.get(), rect));
    183183
    184     // Round the rect instead of enclosing it to make sure that its size stays the same while panning. This can have nasty effects on layout.
    185     IntRect roundedRect = roundedIntRect(rect);
    186     if (roundedRect == m_lastSentVisibleRect && scale == m_lastSentScale && trajectoryVector == m_lastSentTrajectoryVector)
     184    if (rect == m_lastSentVisibleRect && scale == m_lastSentScale && trajectoryVector == m_lastSentTrajectoryVector)
    187185        return;
    188186
    189     m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::SetVisibleContentsRect(roundedRect, scale, trajectoryVector), m_drawingAreaProxy->page()->pageID());
    190     m_lastSentVisibleRect = roundedRect;
     187    m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::SetVisibleContentsRect(rect, scale, trajectoryVector), m_drawingAreaProxy->page()->pageID());
     188    m_lastSentVisibleRect = rect;
    191189    m_lastSentScale = scale;
    192190    m_lastSentTrajectoryVector = trajectoryVector;
     
    211209#endif
    212210
    213 void LayerTreeCoordinatorProxy::didChangeScrollPosition(const IntPoint& position)
     211void LayerTreeCoordinatorProxy::didChangeScrollPosition(const FloatPoint& position)
    214212{
    215213    dispatchUpdate(bind(&LayerTreeRenderer::didChangeScrollPosition, m_renderer.get(), position));
  • trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h

    r136912 r136976  
    7979    void updateViewport();
    8080    void renderNextFrame();
    81     void didChangeScrollPosition(const WebCore::IntPoint& position);
     81    void didChangeScrollPosition(const WebCore::FloatPoint& position);
    8282#if USE(GRAPHICS_SURFACE)
    8383    void createCanvas(CoordinatedLayerID, const WebCore::IntSize&, const WebCore::GraphicsSurfaceToken&);
     
    100100    DrawingAreaProxy* m_drawingAreaProxy;
    101101    RefPtr<LayerTreeRenderer> m_renderer;
    102     WebCore::IntRect m_lastSentVisibleRect;
     102    WebCore::FloatRect m_lastSentVisibleRect;
    103103    float m_lastSentScale;
    104104    WebCore::FloatPoint m_lastSentTrajectoryVector;
  • trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in

    r136912 r136976  
    4141    RemoveImageBacking(uint64_t imageID)
    4242    DidRenderFrame(WebCore::IntSize contentsSize, WebCore::IntRect coveredRect)
    43     DidChangeScrollPosition(WebCore::IntPoint position)
     43    DidChangeScrollPosition(WebCore::FloatPoint position)
    4444    SetLayerAnimations(uint32_t id, WebCore::GraphicsLayerAnimations animations)
    4545    SetAnimationsLocked(bool locked)
  • trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp

    r136912 r136976  
    222222}
    223223
    224 void LayerTreeRenderer::didChangeScrollPosition(const IntPoint& position)
     224void LayerTreeRenderer::didChangeScrollPosition(const FloatPoint& position)
    225225{
    226226    m_pendingRenderedContentsScrollPosition = position;
     
    334334    layer->setMaskLayer(layerByID(layerInfo.mask));
    335335
     336    layer->setAnchorPoint(layerInfo.anchorPoint);
    336337    layer->setPosition(layerInfo.pos);
    337338    layer->setSize(layerInfo.size);
     339
    338340    layer->setTransform(layerInfo.transform);
    339     layer->setAnchorPoint(layerInfo.anchorPoint);
    340341    layer->setChildrenTransform(layerInfo.childrenTransform);
    341342    layer->setBackfaceVisibility(layerInfo.backfaceVisible);
     
    451452
    452453    RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create());
     454
    453455    backingStore->setSize(graphicsLayer->size());
    454456    ASSERT(!m_pendingSyncBackingStores.contains(layer));
  • trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h

    r136912 r136976  
    7373    void setContentsSize(const WebCore::FloatSize&);
    7474    void setVisibleContentsRect(const WebCore::FloatRect&);
    75     void didChangeScrollPosition(const WebCore::IntPoint& position);
     75    void didChangeScrollPosition(const WebCore::FloatPoint& position);
    7676#if USE(GRAPHICS_SURFACE)
    7777    void createCanvas(CoordinatedLayerID, const WebCore::IntSize&, PassRefPtr<WebCore::GraphicsSurface>);
     
    186186    LayerRawPtrMap m_fixedLayers;
    187187    CoordinatedLayerID m_rootLayerID;
    188     WebCore::IntPoint m_renderedContentsScrollPosition;
    189     WebCore::IntPoint m_pendingRenderedContentsScrollPosition;
     188    WebCore::FloatPoint m_renderedContentsScrollPosition;
     189    WebCore::FloatPoint m_pendingRenderedContentsScrollPosition;
    190190    bool m_animationsLocked;
    191191#if ENABLE(REQUEST_ANIMATION_FRAME)
  • trunk/Source/WebKit2/UIProcess/PageViewportController.cpp

    r136668 r136976  
    4949    , m_hadUserInteraction(false)
    5050    , m_effectiveScale(1)
    51     , m_viewportPosIsLocked(false)
     51    , m_contentsPositionIsLocked(false)
    5252    , m_effectiveScaleIsLocked(false)
    5353{
     
    8888}
    8989
    90 FloatPoint PageViewportController::clampViewportToContents(const WebCore::FloatPoint& viewportPos, float viewportScale)
    91 {
    92     const float horizontalRange = std::max(0.f, m_contentsSize.width() - m_viewportSize.width() / viewportScale);
    93     const float verticalRange = std::max(0.f, m_contentsSize.height() - m_viewportSize.height() / viewportScale);
    94 
    95     return FloatPoint(clampTo(viewportPos.x(), 0.f, horizontalRange), clampTo(viewportPos.y(), 0.f, verticalRange));
     90static inline bool isIntegral(float value)
     91{
     92    return static_cast<int>(value) == value;
     93}
     94
     95FloatPoint PageViewportController::pixelAlignedFloatPoint(const FloatPoint& framePosition)
     96{
     97#if PLATFORM(EFL)
     98    if (!isIntegral(m_effectiveScale)) {
     99        // To avoid blurryness, modify the position so that it maps into a discrete device position.
     100        FloatPoint scaledPos(framePosition);
     101
     102        // Scale by the effective scale factor to compute the screen-relative position.
     103        scaledPos.scale(m_effectiveScale, m_effectiveScale);
     104
     105        // Round to integer boundaries.
     106        FloatPoint alignedPos = roundedIntPoint(scaledPos);
     107
     108        // Convert back to CSS coordinates.
     109        alignedPos.scale(1 / m_effectiveScale, 1 / m_effectiveScale);
     110
     111        return alignedPos;
     112    }
     113#endif
     114
     115    return framePosition;
     116}
     117
     118FloatPoint PageViewportController::boundContentsPositionAtScale(const WebCore::FloatPoint& framePosition, float scale)
     119{
     120    // We need to floor the viewport here as to allow aligning the content in device units. If not,
     121    // it might not be possible to scroll the last pixel and that affects fixed position elements.
     122    FloatRect bounds;
     123    bounds.setWidth(std::max(0.f, m_contentsSize.width() - floorf(m_viewportSize.width() / scale)));
     124    bounds.setHeight(std::max(0.f, m_contentsSize.height() - floorf(m_viewportSize.height() / scale)));
     125
     126    FloatPoint position;
     127    // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
     128    position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
     129    position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
     130
     131    return position;
     132}
     133
     134FloatPoint PageViewportController::boundContentsPosition(const WebCore::FloatPoint& framePosition)
     135{
     136    return boundContentsPositionAtScale(framePosition, m_effectiveScale);
    96137}
    97138
     
    147188        m_effectiveScaleIsLocked = false;
    148189    }
    149     if (m_viewportPosIsLocked) {
    150         FloatPoint clampedPos = clampViewportToContents(m_viewportPos, m_effectiveScale);
     190    if (m_contentsPositionIsLocked) {
     191        FloatPoint contentsPos = boundContentsPosition(m_contentsPosition);
    151192        // There might be rendered frames not covering our requested position yet, wait for it.
    152         if (FloatRect(clampedPos, viewportSizeInContentsCoordinates()).intersects(coveredRect)) {
    153             m_client->setViewportPosition(clampedPos);
    154             m_viewportPosIsLocked = false;
     193        if (FloatRect(contentsPos, visibleContentsSize()).intersects(coveredRect)) {
     194            m_client->setViewportPosition(contentsPos);
     195            m_contentsPositionIsLocked = false;
    155196        }
    156197    }
     
    178219        return;
    179220
    180     FloatRect endVisibleContentRect(clampViewportToContents(cssPosition, m_effectiveScale), viewportSizeInContentsCoordinates());
     221    FloatPoint position = pixelAlignedFloatPoint(FloatPoint(cssPosition));
     222    FloatPoint boundPosition = boundContentsPosition(position);
     223
     224    FloatRect endVisibleContentRect(boundPosition, visibleContentsSize());
     225
    181226    if (m_lastFrameCoveredRect.intersects(endVisibleContentRect))
    182         m_client->setViewportPosition(endVisibleContentRect.location());
    183     else
    184         // Keep the unclamped position in case the contents size is changed later on.
    185         applyPositionAfterRenderingContents(cssPosition);
     227        m_client->setViewportPosition(boundPosition);
     228    else {
     229        // Keep the unbound position in case the contents size is changed later on.
     230        applyPositionAfterRenderingContents(position);
     231    }
    186232}
    187233
     
    198244}
    199245
    200 void PageViewportController::didChangeContentsVisibility(const FloatPoint& viewportPos, float viewportScale, const FloatPoint& trajectoryVector)
    201 {
    202     if (!m_viewportPosIsLocked)
    203         m_viewportPos = viewportPos;
     246void PageViewportController::didChangeContentsVisibility(const FloatPoint& position, float scale, const FloatPoint& trajectoryVector)
     247{
     248    if (!m_contentsPositionIsLocked)
     249        m_contentsPosition = position;
    204250    if (!m_effectiveScaleIsLocked)
    205         m_effectiveScale = viewportScale;
     251        m_effectiveScale = scale;
    206252
    207253    syncVisibleContents(trajectoryVector);
     
    214260        return;
    215261
    216     FloatRect visibleContentsRect(clampViewportToContents(m_viewportPos, m_effectiveScale), viewportSizeInContentsCoordinates());
     262    FloatRect visibleContentsRect(boundContentsPosition(m_contentsPosition), visibleContentsSize());
    217263    visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize));
    218264    drawingArea->setVisibleContentsRect(visibleContentsRect, m_effectiveScale, trajectoryVector);
     
    237283}
    238284
    239 WebCore::FloatSize PageViewportController::viewportSizeInContentsCoordinates() const
    240 {
    241     return WebCore::FloatSize(m_viewportSize.width() / m_effectiveScale, m_viewportSize.height() / m_effectiveScale);
     285FloatSize PageViewportController::visibleContentsSize() const
     286{
     287    return FloatSize(m_viewportSize.width() / m_effectiveScale, m_viewportSize.height() / m_effectiveScale);
    242288}
    243289
     
    271317void PageViewportController::applyPositionAfterRenderingContents(const FloatPoint& pos)
    272318{
    273     m_viewportPos = pos;
    274     m_viewportPosIsLocked = true;
     319    m_contentsPosition = pos;
     320    m_contentsPositionIsLocked = true;
    275321    syncVisibleContents();
    276322}
  • trunk/Source/WebKit2/UIProcess/PageViewportController.h

    r136129 r136976  
    5353    float innerBoundedViewportScale(float) const;
    5454    float outerBoundedViewportScale(float) const;
    55     WebCore::FloatPoint clampViewportToContents(const WebCore::FloatPoint& viewportPos, float viewportScale);
     55
     56    WebCore::FloatPoint pixelAlignedFloatPoint(const WebCore::FloatPoint&);
     57
     58    WebCore::FloatPoint boundContentsPosition(const WebCore::FloatPoint&);
     59    WebCore::FloatPoint boundContentsPositionAtScale(const WebCore::FloatPoint&, float scale);
     60
     61    WebCore::FloatSize visibleContentsSize() const;
    5662
    5763    bool hasSuspendedContent() const { return m_hasSuspendedContent; }
     
    6975    // Notifications from the viewport.
    7076    void didChangeViewportSize(const WebCore::FloatSize& newSize);
    71     void didChangeContentsVisibility(const WebCore::FloatPoint& viewportPos, float viewportScale, const WebCore::FloatPoint& trajectoryVector = WebCore::FloatPoint::zero());
     77    void didChangeContentsVisibility(const WebCore::FloatPoint&, float scale, const WebCore::FloatPoint& trajectoryVector = WebCore::FloatPoint::zero());
    7278
    7379    // Notifications from the WebProcess.
     
    8692    void applyPositionAfterRenderingContents(const WebCore::FloatPoint& pos);
    8793    bool updateMinimumScaleToFit(bool userInitiatedUpdate);
    88     WebCore::FloatSize viewportSizeInContentsCoordinates() const;
    8994
    9095    WebPageProxy* const m_webPageProxy;
     
    100105    bool m_hadUserInteraction;
    101106
    102     WebCore::FloatPoint m_viewportPos;
     107    WebCore::FloatPoint m_contentsPosition;
     108    WebCore::FloatSize m_contentsSize;
    103109    WebCore::FloatSize m_viewportSize;
    104     WebCore::FloatSize m_contentsSize;
    105110    WebCore::IntSize m_clientContentsSize;
    106111    float m_effectiveScale; // Should always be cssScale * devicePixelRatio.
    107112
    108     bool m_viewportPosIsLocked;
     113    bool m_contentsPositionIsLocked;
    109114    bool m_effectiveScaleIsLocked;
    110115    WebCore::FloatRect m_lastFrameCoveredRect;
  • trunk/Source/WebKit2/UIProcess/efl/PageClientLegacyImpl.cpp

    r136402 r136976  
    5151{
    5252#if USE(TILED_BACKING_STORE)
    53     m_viewImpl->page()->drawingArea()->setVisibleContentsRect(IntRect(m_viewImpl->discretePagePosition(), size), m_viewImpl->scaleFactor(), FloatPoint());
     53    m_viewImpl->page()->drawingArea()->setVisibleContentsRect(IntRect(roundedIntPoint(m_viewImpl->pagePosition()), size), m_viewImpl->scaleFactor(), FloatPoint());
    5454#else
    5555    UNUSED_PARAM(size);
  • trunk/Source/WebKit2/UIProcess/efl/PageViewportControllerClientEfl.cpp

    r136000 r136976  
    7676void PageViewportControllerClientEfl::setViewportPosition(const WebCore::FloatPoint& contentsPoint)
    7777{
    78     m_contentPosition = roundedIntPoint(contentsPoint);
     78    m_contentPosition = contentsPoint;
    7979
    8080    FloatPoint pos(contentsPoint);
  • trunk/Source/WebKit2/UIProcess/efl/PageViewportControllerClientEfl.h

    r136000 r136976  
    4747    WebCore::IntSize viewSize() { return m_viewportSize; }
    4848    float scaleFactor() const { return m_viewImpl->scaleFactor(); }
    49     WebCore::IntPoint contentPosition() const { return m_contentPosition; }
     49    WebCore::FloatPoint contentPosition() const { return m_contentPosition; }
    5050
    5151    void updateViewportSize(const WebCore::IntSize& viewportSize);
     
    6767    EwkViewImpl* m_viewImpl;
    6868    WebCore::IntSize m_viewportSize;
    69     WebCore::IntPoint m_contentPosition;
     69    WebCore::FloatPoint m_contentPosition;
    7070    PageViewportController* m_controller;
    7171};
  • trunk/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp

    r136859 r136976  
    205205
    206206    QPointF endPosition = hotspot - viewportHotspot / targetScale;
    207     endPosition = m_controller->clampViewportToContents(endPosition, targetScale);
     207    endPosition = m_controller->boundContentsPositionAtScale(endPosition, targetScale);
    208208    QRectF endVisibleContentRect(endPosition, viewportRect.size() / targetScale);
    209209
     
    239239
    240240    QPointF endPosition = hotspot - viewportHotspot / targetScale;
    241     endPosition = m_controller->clampViewportToContents(endPosition, targetScale);
     241    endPosition = m_controller->boundContentsPositionAtScale(endPosition, targetScale);
    242242    QRectF endVisibleContentRect(endPosition, viewportRect.size() / targetScale);
    243243
     
    280280            endPosition.setX(lastScale.xPosition);
    281281        }
    282         endPosition = m_controller->clampViewportToContents(endPosition, targetScale);
     282        endPosition = m_controller->boundContentsPositionAtScale(endPosition, targetScale);
    283283        endVisibleContentRect = QRectF(endPosition, viewportRect.size() / targetScale);
    284284        break;
     
    312312    QPointF endPosition = m_viewportItem->mapToWebContent(viewportHotspot) - viewportHotspot / targetScale;
    313313
    314     endPosition = m_controller->clampViewportToContents(endPosition, targetScale);
     314    endPosition = m_controller->boundContentsPositionAtScale(endPosition, targetScale);
    315315    return QRectF(endPosition, viewportRect.size() / targetScale);
    316316}
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp

    r136912 r136976  
    11/*
    22 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
     3 Copyright (C) 2010 Apple Inc. All rights reserved.
    34 Copyright (C) 2012 Company 100, Inc.
     5 Copyright (C) 2012 Intel Corporation. All rights reserved.
    46
    57 This library is free software; you can redistribute it and/or
     
    406408    CoordinatedGraphicsLayer->didChangeLayerState();
    407409    didChangeLayerState();
    408 
    409410}
    410411
     
    525526    m_layerInfo.fixedToViewport = fixedToViewport();
    526527
    527     m_layerInfo.anchorPoint = anchorPoint();
    528528    m_layerInfo.backfaceVisible = backfaceVisibility();
    529529    m_layerInfo.childrenTransform = childrenTransform();
     
    535535    m_layerInfo.masksToBounds = masksToBounds();
    536536    m_layerInfo.opacity = opacity();
    537     m_layerInfo.pos = position();
    538537    m_layerInfo.preserves3D = preserves3D();
    539538    m_layerInfo.replica = toCoordinatedLayerID(replicaLayer());
    540     m_layerInfo.size = size();
    541539    m_layerInfo.transform = transform();
     540
     541    m_layerInfo.anchorPoint = m_adjustedAnchorPoint;
     542    m_layerInfo.pos = m_adjustedPosition;
     543    m_layerInfo.size = m_adjustedSize;
     544
    542545    m_coordinator->syncLayerState(m_id, m_layerInfo);
    543546}
     
    593596void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
    594597{
     598    // Sets the values.
     599    computePixelAlignment(m_adjustedPosition, m_adjustedSize, m_adjustedAnchorPoint, m_pixelAlignmentOffset);
     600
    595601    syncImageBacking();
    596602    syncLayerState();
     
    720726    // so it might spread further than the real visible area (and then even more amplified by the cover rect multiplier).
    721727    ASSERT(m_cachedInverseTransform == m_layerTransform.combined().inverse());
    722     FloatRect rect = m_cachedInverseTransform.clampedBoundsOfProjectedQuad(FloatQuad(FloatRect(m_coordinator->visibleContentsRect())));
     728    FloatRect rect = m_cachedInverseTransform.clampedBoundsOfProjectedQuad(FloatQuad(m_coordinator->visibleContentsRect()));
    723729    clampToContentsRectIfRectIsInfinite(rect, tiledBackingStoreContentsRect());
    724730    return enclosingIntRect(rect);
     
    816822}
    817823
     824static inline bool isIntegral(float value)
     825{
     826    return static_cast<int>(value) == value;
     827}
     828
     829FloatPoint CoordinatedGraphicsLayer::computePositionRelativeToBase()
     830{
     831    FloatPoint offset;
     832    for (const GraphicsLayer* currLayer = this; currLayer; currLayer = currLayer->parent())
     833        offset += currLayer->position();
     834
     835    return offset;
     836}
     837
     838void CoordinatedGraphicsLayer::computePixelAlignment(FloatPoint& position, FloatSize& size, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset)
     839{
     840    if (isIntegral(effectiveContentsScale())) {
     841        position = m_position;
     842        size = m_size;
     843        anchorPoint = m_anchorPoint;
     844        alignmentOffset = FloatSize();
     845        return;
     846    }
     847
     848    FloatPoint positionRelativeToBase = computePositionRelativeToBase();
     849
     850    FloatRect baseRelativeBounds(positionRelativeToBase, m_size);
     851    FloatRect scaledBounds = baseRelativeBounds;
     852
     853    // Scale by the effective scale factor to compute the screen-relative bounds.
     854    scaledBounds.scale(effectiveContentsScale());
     855
     856    // Round to integer boundaries.
     857    // NOTE: When using enclosingIntRect (as mac) it will have different sizes depending on position.
     858    FloatRect alignedBounds = roundedIntRect(scaledBounds);
     859
     860    // Convert back to layer coordinates.
     861    alignedBounds.scale(1 / effectiveContentsScale());
     862
     863    // Convert back to layer coordinates.
     864    alignmentOffset = baseRelativeBounds.location() - alignedBounds.location();
     865
     866    position = m_position - alignmentOffset;
     867    size = alignedBounds.size();
     868
     869    // Now we have to compute a new anchor point which compensates for rounding.
     870    float anchorPointX = m_anchorPoint.x();
     871    float anchorPointY = m_anchorPoint.y();
     872
     873    if (alignedBounds.width())
     874        anchorPointX = (baseRelativeBounds.width() * anchorPointX + alignmentOffset.width()) / alignedBounds.width();
     875
     876    if (alignedBounds.height())
     877        anchorPointY = (baseRelativeBounds.height() * anchorPointY + alignmentOffset.height()) / alignedBounds.height();
     878
     879    anchorPoint = FloatPoint3D(anchorPointX, anchorPointY, m_anchorPoint.z() * effectiveContentsScale());
     880}
     881
    818882void CoordinatedGraphicsLayer::computeTransformedVisibleRect()
    819883{
     
    828892        client()->getCurrentTransform(this, currentTransform);
    829893    m_layerTransform.setLocalTransform(currentTransform);
    830     m_layerTransform.setPosition(position());
    831     m_layerTransform.setAnchorPoint(anchorPoint());
    832     m_layerTransform.setSize(size());
     894
     895    m_layerTransform.setAnchorPoint(m_adjustedAnchorPoint);
     896    m_layerTransform.setPosition(m_adjustedPosition);
     897    m_layerTransform.setSize(m_adjustedSize);
     898
    833899    m_layerTransform.setFlattening(!preserves3D());
    834900    m_layerTransform.setChildrenTransform(childrenTransform());
    835901    m_layerTransform.combineTransforms(parent() ? toCoordinatedGraphicsLayer(parent())->m_layerTransform.combinedForChildren() : TransformationMatrix());
     902
    836903    m_cachedInverseTransform = m_layerTransform.combined().inverse();
    837904
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h

    r136912 r136976  
    5858    virtual void removeTile(CoordinatedLayerID, uint32_t tileID) = 0;
    5959
    60     virtual WebCore::IntRect visibleContentsRect() const = 0;
     60    virtual WebCore::FloatRect visibleContentsRect() const = 0;
    6161    virtual bool layerTreeTileUpdatesAllowed() const = 0;
    6262    virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) = 0;
     
    130130    virtual void suspendAnimations(double time) OVERRIDE;
    131131    virtual void resumeAnimations() OVERRIDE;
    132    
     132
     133    FloatPoint computePositionRelativeToBase();
     134    void computePixelAlignment(FloatPoint& position, FloatSize&, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset);
     135
    133136    void setContentsScale(float);
    134137    void setVisibleContentRectTrajectoryVector(const FloatPoint&);
     
    211214    GraphicsLayerTransform m_layerTransform;
    212215    TransformationMatrix m_cachedInverseTransform;
     216    FloatSize m_pixelAlignmentOffset;
     217    FloatSize m_adjustedSize;
     218    FloatPoint m_adjustedPosition;
     219    FloatPoint3D m_adjustedAnchorPoint;
     220
    213221    bool m_inUpdateMode : 1;
    214222    bool m_shouldUpdateVisibleRect: 1;
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp

    r136912 r136976  
    672672}
    673673
    674 WebCore::IntRect LayerTreeCoordinator::visibleContentsRect() const
     674WebCore::FloatRect LayerTreeCoordinator::visibleContentsRect() const
    675675{
    676676    return m_visibleContentsRect;
     
    696696}
    697697
    698 void LayerTreeCoordinator::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector)
     698void LayerTreeCoordinator::setVisibleContentsRect(const FloatRect& rect, float scale, const FloatPoint& trajectoryVector)
    699699{
    700700    bool contentsRectDidChange = rect != m_visibleContentsRect;
     
    718718
    719719    scheduleLayerFlush();
    720     if (m_webPage->useFixedLayout())
    721         m_webPage->setFixedVisibleContentRect(rect);
     720    if (m_webPage->useFixedLayout()) {
     721        // Round the rect instead of enclosing it to make sure that its size stays
     722        // the same while panning. This can have nasty effects on layout.
     723        m_webPage->setFixedVisibleContentRect(roundedIntRect(rect));
     724    }
     725
    722726    if (contentsRectDidChange)
    723727        m_shouldSendScrollPositionUpdate = true;
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h

    r136912 r136976  
    8282    virtual void updateTile(CoordinatedLayerID, uint32_t tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&);
    8383    virtual void removeTile(CoordinatedLayerID, uint32_t tileID);
    84     virtual WebCore::IntRect visibleContentsRect() const;
     84    virtual WebCore::FloatRect visibleContentsRect() const;
    8585    virtual void renderNextFrame();
    8686    virtual void purgeBackingStores();
    8787    virtual bool layerTreeTileUpdatesAllowed() const;
    88     virtual void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint&);
     88    virtual void setVisibleContentsRect(const WebCore::FloatRect&, float scale, const WebCore::FloatPoint&);
    8989    virtual void didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
    9090    virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
     
    188188    bool m_waitingForUIProcess;
    189189    bool m_isSuspended;
    190     WebCore::IntRect m_visibleContentsRect;
     190    WebCore::FloatRect m_visibleContentsRect;
    191191    float m_contentsScale;
    192192    bool m_shouldSendScrollPositionUpdate;
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.messages.in

    r132742 r136976  
    11#
    22#    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
     3#    Copyright (C) 2012 Intel Corporation. All rights reserved.
    34#
    45#    This library is free software; you can redistribute it and/or
     
    2122#if USE(COORDINATED_GRAPHICS)
    2223messages -> LayerTreeCoordinator {
    23     SetVisibleContentsRect(WebCore::IntRect visibleContentsRect, float scale, WebCore::FloatPoint trajectoryVectory)
     24    SetVisibleContentsRect(WebCore::FloatRect visibleContentsRect, float scale, WebCore::FloatPoint trajectoryVectory)
    2425    RenderNextFrame()
    2526    PurgeBackingStores()
  • trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h

    r134953 r136976  
    4040namespace WebCore {
    4141class FloatPoint;
     42class FloatRect;
    4243class IntRect;
    4344class IntSize;
     
    9394
    9495#if USE(COORDINATED_GRAPHICS)
    95     virtual void setVisibleContentsRect(const WebCore::IntRect&, float /* scale */, const WebCore::FloatPoint&) { }
    96     virtual void setVisibleContentsRectForLayer(int /* layerID */, const WebCore::IntRect&) { }
     96    virtual void setVisibleContentsRect(const WebCore::FloatRect&, float /* scale */, const WebCore::FloatPoint&) { }
    9797    virtual void renderNextFrame() { }
    9898    virtual void purgeBackingStores() { }
Note: See TracChangeset for help on using the changeset viewer.