Changeset 136976 in webkit
- Timestamp:
- Dec 7, 2012 1:15:07 PM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r136973 r136976 1 2012-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 1 111 2012-12-07 Alexey Proskuryakov <ap@apple.com> 2 112 -
trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp
r136485 r136976 296 296 #if USE(TILED_BACKING_STORE) 297 297 transform.scale(1 / m_scaleFactor); 298 transform.translate( discretePagePosition().x(), discretePagePosition().y());298 transform.translate(pagePosition().x(), pagePosition().y()); 299 299 #endif 300 300 … … 392 392 393 393 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()); 395 395 cairo_scale(graphicsContext.get(), m_scaleFactor, m_scaleFactor); 396 396 renderer->paintToGraphicsContext(graphicsContext.get()); -
trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h
r136402 r136976 203 203 204 204 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; } 206 206 #endif 207 207 -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp
r136912 r136976 182 182 dispatchUpdate(bind(&LayerTreeRenderer::setVisibleContentsRect, m_renderer.get(), rect)); 183 183 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) 187 185 return; 188 186 189 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::SetVisibleContentsRect(r oundedRect, scale, trajectoryVector), m_drawingAreaProxy->page()->pageID());190 m_lastSentVisibleRect = r oundedRect;187 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::SetVisibleContentsRect(rect, scale, trajectoryVector), m_drawingAreaProxy->page()->pageID()); 188 m_lastSentVisibleRect = rect; 191 189 m_lastSentScale = scale; 192 190 m_lastSentTrajectoryVector = trajectoryVector; … … 211 209 #endif 212 210 213 void LayerTreeCoordinatorProxy::didChangeScrollPosition(const IntPoint& position)211 void LayerTreeCoordinatorProxy::didChangeScrollPosition(const FloatPoint& position) 214 212 { 215 213 dispatchUpdate(bind(&LayerTreeRenderer::didChangeScrollPosition, m_renderer.get(), position)); -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h
r136912 r136976 79 79 void updateViewport(); 80 80 void renderNextFrame(); 81 void didChangeScrollPosition(const WebCore:: IntPoint& position);81 void didChangeScrollPosition(const WebCore::FloatPoint& position); 82 82 #if USE(GRAPHICS_SURFACE) 83 83 void createCanvas(CoordinatedLayerID, const WebCore::IntSize&, const WebCore::GraphicsSurfaceToken&); … … 100 100 DrawingAreaProxy* m_drawingAreaProxy; 101 101 RefPtr<LayerTreeRenderer> m_renderer; 102 WebCore:: IntRect m_lastSentVisibleRect;102 WebCore::FloatRect m_lastSentVisibleRect; 103 103 float m_lastSentScale; 104 104 WebCore::FloatPoint m_lastSentTrajectoryVector; -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in
r136912 r136976 41 41 RemoveImageBacking(uint64_t imageID) 42 42 DidRenderFrame(WebCore::IntSize contentsSize, WebCore::IntRect coveredRect) 43 DidChangeScrollPosition(WebCore:: IntPoint position)43 DidChangeScrollPosition(WebCore::FloatPoint position) 44 44 SetLayerAnimations(uint32_t id, WebCore::GraphicsLayerAnimations animations) 45 45 SetAnimationsLocked(bool locked) -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp
r136912 r136976 222 222 } 223 223 224 void LayerTreeRenderer::didChangeScrollPosition(const IntPoint& position)224 void LayerTreeRenderer::didChangeScrollPosition(const FloatPoint& position) 225 225 { 226 226 m_pendingRenderedContentsScrollPosition = position; … … 334 334 layer->setMaskLayer(layerByID(layerInfo.mask)); 335 335 336 layer->setAnchorPoint(layerInfo.anchorPoint); 336 337 layer->setPosition(layerInfo.pos); 337 338 layer->setSize(layerInfo.size); 339 338 340 layer->setTransform(layerInfo.transform); 339 layer->setAnchorPoint(layerInfo.anchorPoint);340 341 layer->setChildrenTransform(layerInfo.childrenTransform); 341 342 layer->setBackfaceVisibility(layerInfo.backfaceVisible); … … 451 452 452 453 RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create()); 454 453 455 backingStore->setSize(graphicsLayer->size()); 454 456 ASSERT(!m_pendingSyncBackingStores.contains(layer)); -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h
r136912 r136976 73 73 void setContentsSize(const WebCore::FloatSize&); 74 74 void setVisibleContentsRect(const WebCore::FloatRect&); 75 void didChangeScrollPosition(const WebCore:: IntPoint& position);75 void didChangeScrollPosition(const WebCore::FloatPoint& position); 76 76 #if USE(GRAPHICS_SURFACE) 77 77 void createCanvas(CoordinatedLayerID, const WebCore::IntSize&, PassRefPtr<WebCore::GraphicsSurface>); … … 186 186 LayerRawPtrMap m_fixedLayers; 187 187 CoordinatedLayerID m_rootLayerID; 188 WebCore:: IntPoint m_renderedContentsScrollPosition;189 WebCore:: IntPoint m_pendingRenderedContentsScrollPosition;188 WebCore::FloatPoint m_renderedContentsScrollPosition; 189 WebCore::FloatPoint m_pendingRenderedContentsScrollPosition; 190 190 bool m_animationsLocked; 191 191 #if ENABLE(REQUEST_ANIMATION_FRAME) -
trunk/Source/WebKit2/UIProcess/PageViewportController.cpp
r136668 r136976 49 49 , m_hadUserInteraction(false) 50 50 , m_effectiveScale(1) 51 , m_ viewportPosIsLocked(false)51 , m_contentsPositionIsLocked(false) 52 52 , m_effectiveScaleIsLocked(false) 53 53 { … … 88 88 } 89 89 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)); 90 static inline bool isIntegral(float value) 91 { 92 return static_cast<int>(value) == value; 93 } 94 95 FloatPoint 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 118 FloatPoint 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 134 FloatPoint PageViewportController::boundContentsPosition(const WebCore::FloatPoint& framePosition) 135 { 136 return boundContentsPositionAtScale(framePosition, m_effectiveScale); 96 137 } 97 138 … … 147 188 m_effectiveScaleIsLocked = false; 148 189 } 149 if (m_ viewportPosIsLocked) {150 FloatPoint c lampedPos = clampViewportToContents(m_viewportPos, m_effectiveScale);190 if (m_contentsPositionIsLocked) { 191 FloatPoint contentsPos = boundContentsPosition(m_contentsPosition); 151 192 // There might be rendered frames not covering our requested position yet, wait for it. 152 if (FloatRect(c lampedPos, viewportSizeInContentsCoordinates()).intersects(coveredRect)) {153 m_client->setViewportPosition(c lampedPos);154 m_ viewportPosIsLocked = false;193 if (FloatRect(contentsPos, visibleContentsSize()).intersects(coveredRect)) { 194 m_client->setViewportPosition(contentsPos); 195 m_contentsPositionIsLocked = false; 155 196 } 156 197 } … … 178 219 return; 179 220 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 181 226 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 } 186 232 } 187 233 … … 198 244 } 199 245 200 void PageViewportController::didChangeContentsVisibility(const FloatPoint& viewportPos, float viewportScale, const FloatPoint& trajectoryVector)201 { 202 if (!m_ viewportPosIsLocked)203 m_ viewportPos = viewportPos;246 void PageViewportController::didChangeContentsVisibility(const FloatPoint& position, float scale, const FloatPoint& trajectoryVector) 247 { 248 if (!m_contentsPositionIsLocked) 249 m_contentsPosition = position; 204 250 if (!m_effectiveScaleIsLocked) 205 m_effectiveScale = viewportScale;251 m_effectiveScale = scale; 206 252 207 253 syncVisibleContents(trajectoryVector); … … 214 260 return; 215 261 216 FloatRect visibleContentsRect( clampViewportToContents(m_viewportPos, m_effectiveScale), viewportSizeInContentsCoordinates());262 FloatRect visibleContentsRect(boundContentsPosition(m_contentsPosition), visibleContentsSize()); 217 263 visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize)); 218 264 drawingArea->setVisibleContentsRect(visibleContentsRect, m_effectiveScale, trajectoryVector); … … 237 283 } 238 284 239 WebCore::FloatSize PageViewportController::viewportSizeInContentsCoordinates() const240 { 241 return WebCore::FloatSize(m_viewportSize.width() / m_effectiveScale, m_viewportSize.height() / m_effectiveScale);285 FloatSize PageViewportController::visibleContentsSize() const 286 { 287 return FloatSize(m_viewportSize.width() / m_effectiveScale, m_viewportSize.height() / m_effectiveScale); 242 288 } 243 289 … … 271 317 void PageViewportController::applyPositionAfterRenderingContents(const FloatPoint& pos) 272 318 { 273 m_ viewportPos= pos;274 m_ viewportPosIsLocked = true;319 m_contentsPosition = pos; 320 m_contentsPositionIsLocked = true; 275 321 syncVisibleContents(); 276 322 } -
trunk/Source/WebKit2/UIProcess/PageViewportController.h
r136129 r136976 53 53 float innerBoundedViewportScale(float) const; 54 54 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; 56 62 57 63 bool hasSuspendedContent() const { return m_hasSuspendedContent; } … … 69 75 // Notifications from the viewport. 70 76 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()); 72 78 73 79 // Notifications from the WebProcess. … … 86 92 void applyPositionAfterRenderingContents(const WebCore::FloatPoint& pos); 87 93 bool updateMinimumScaleToFit(bool userInitiatedUpdate); 88 WebCore::FloatSize viewportSizeInContentsCoordinates() const;89 94 90 95 WebPageProxy* const m_webPageProxy; … … 100 105 bool m_hadUserInteraction; 101 106 102 WebCore::FloatPoint m_viewportPos; 107 WebCore::FloatPoint m_contentsPosition; 108 WebCore::FloatSize m_contentsSize; 103 109 WebCore::FloatSize m_viewportSize; 104 WebCore::FloatSize m_contentsSize;105 110 WebCore::IntSize m_clientContentsSize; 106 111 float m_effectiveScale; // Should always be cssScale * devicePixelRatio. 107 112 108 bool m_ viewportPosIsLocked;113 bool m_contentsPositionIsLocked; 109 114 bool m_effectiveScaleIsLocked; 110 115 WebCore::FloatRect m_lastFrameCoveredRect; -
trunk/Source/WebKit2/UIProcess/efl/PageClientLegacyImpl.cpp
r136402 r136976 51 51 { 52 52 #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()); 54 54 #else 55 55 UNUSED_PARAM(size); -
trunk/Source/WebKit2/UIProcess/efl/PageViewportControllerClientEfl.cpp
r136000 r136976 76 76 void PageViewportControllerClientEfl::setViewportPosition(const WebCore::FloatPoint& contentsPoint) 77 77 { 78 m_contentPosition = roundedIntPoint(contentsPoint);78 m_contentPosition = contentsPoint; 79 79 80 80 FloatPoint pos(contentsPoint); -
trunk/Source/WebKit2/UIProcess/efl/PageViewportControllerClientEfl.h
r136000 r136976 47 47 WebCore::IntSize viewSize() { return m_viewportSize; } 48 48 float scaleFactor() const { return m_viewImpl->scaleFactor(); } 49 WebCore:: IntPoint contentPosition() const { return m_contentPosition; }49 WebCore::FloatPoint contentPosition() const { return m_contentPosition; } 50 50 51 51 void updateViewportSize(const WebCore::IntSize& viewportSize); … … 67 67 EwkViewImpl* m_viewImpl; 68 68 WebCore::IntSize m_viewportSize; 69 WebCore:: IntPoint m_contentPosition;69 WebCore::FloatPoint m_contentPosition; 70 70 PageViewportController* m_controller; 71 71 }; -
trunk/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp
r136859 r136976 205 205 206 206 QPointF endPosition = hotspot - viewportHotspot / targetScale; 207 endPosition = m_controller-> clampViewportToContents(endPosition, targetScale);207 endPosition = m_controller->boundContentsPositionAtScale(endPosition, targetScale); 208 208 QRectF endVisibleContentRect(endPosition, viewportRect.size() / targetScale); 209 209 … … 239 239 240 240 QPointF endPosition = hotspot - viewportHotspot / targetScale; 241 endPosition = m_controller-> clampViewportToContents(endPosition, targetScale);241 endPosition = m_controller->boundContentsPositionAtScale(endPosition, targetScale); 242 242 QRectF endVisibleContentRect(endPosition, viewportRect.size() / targetScale); 243 243 … … 280 280 endPosition.setX(lastScale.xPosition); 281 281 } 282 endPosition = m_controller-> clampViewportToContents(endPosition, targetScale);282 endPosition = m_controller->boundContentsPositionAtScale(endPosition, targetScale); 283 283 endVisibleContentRect = QRectF(endPosition, viewportRect.size() / targetScale); 284 284 break; … … 312 312 QPointF endPosition = m_viewportItem->mapToWebContent(viewportHotspot) - viewportHotspot / targetScale; 313 313 314 endPosition = m_controller-> clampViewportToContents(endPosition, targetScale);314 endPosition = m_controller->boundContentsPositionAtScale(endPosition, targetScale); 315 315 return QRectF(endPosition, viewportRect.size() / targetScale); 316 316 } -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp
r136912 r136976 1 1 /* 2 2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 Copyright (C) 2010 Apple Inc. All rights reserved. 3 4 Copyright (C) 2012 Company 100, Inc. 5 Copyright (C) 2012 Intel Corporation. All rights reserved. 4 6 5 7 This library is free software; you can redistribute it and/or … … 406 408 CoordinatedGraphicsLayer->didChangeLayerState(); 407 409 didChangeLayerState(); 408 409 410 } 410 411 … … 525 526 m_layerInfo.fixedToViewport = fixedToViewport(); 526 527 527 m_layerInfo.anchorPoint = anchorPoint();528 528 m_layerInfo.backfaceVisible = backfaceVisibility(); 529 529 m_layerInfo.childrenTransform = childrenTransform(); … … 535 535 m_layerInfo.masksToBounds = masksToBounds(); 536 536 m_layerInfo.opacity = opacity(); 537 m_layerInfo.pos = position();538 537 m_layerInfo.preserves3D = preserves3D(); 539 538 m_layerInfo.replica = toCoordinatedLayerID(replicaLayer()); 540 m_layerInfo.size = size();541 539 m_layerInfo.transform = transform(); 540 541 m_layerInfo.anchorPoint = m_adjustedAnchorPoint; 542 m_layerInfo.pos = m_adjustedPosition; 543 m_layerInfo.size = m_adjustedSize; 544 542 545 m_coordinator->syncLayerState(m_id, m_layerInfo); 543 546 } … … 593 596 void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() 594 597 { 598 // Sets the values. 599 computePixelAlignment(m_adjustedPosition, m_adjustedSize, m_adjustedAnchorPoint, m_pixelAlignmentOffset); 600 595 601 syncImageBacking(); 596 602 syncLayerState(); … … 720 726 // so it might spread further than the real visible area (and then even more amplified by the cover rect multiplier). 721 727 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())); 723 729 clampToContentsRectIfRectIsInfinite(rect, tiledBackingStoreContentsRect()); 724 730 return enclosingIntRect(rect); … … 816 822 } 817 823 824 static inline bool isIntegral(float value) 825 { 826 return static_cast<int>(value) == value; 827 } 828 829 FloatPoint 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 838 void 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 818 882 void CoordinatedGraphicsLayer::computeTransformedVisibleRect() 819 883 { … … 828 892 client()->getCurrentTransform(this, currentTransform); 829 893 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 833 899 m_layerTransform.setFlattening(!preserves3D()); 834 900 m_layerTransform.setChildrenTransform(childrenTransform()); 835 901 m_layerTransform.combineTransforms(parent() ? toCoordinatedGraphicsLayer(parent())->m_layerTransform.combinedForChildren() : TransformationMatrix()); 902 836 903 m_cachedInverseTransform = m_layerTransform.combined().inverse(); 837 904 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h
r136912 r136976 58 58 virtual void removeTile(CoordinatedLayerID, uint32_t tileID) = 0; 59 59 60 virtual WebCore:: IntRect visibleContentsRect() const = 0;60 virtual WebCore::FloatRect visibleContentsRect() const = 0; 61 61 virtual bool layerTreeTileUpdatesAllowed() const = 0; 62 62 virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) = 0; … … 130 130 virtual void suspendAnimations(double time) OVERRIDE; 131 131 virtual void resumeAnimations() OVERRIDE; 132 132 133 FloatPoint computePositionRelativeToBase(); 134 void computePixelAlignment(FloatPoint& position, FloatSize&, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset); 135 133 136 void setContentsScale(float); 134 137 void setVisibleContentRectTrajectoryVector(const FloatPoint&); … … 211 214 GraphicsLayerTransform m_layerTransform; 212 215 TransformationMatrix m_cachedInverseTransform; 216 FloatSize m_pixelAlignmentOffset; 217 FloatSize m_adjustedSize; 218 FloatPoint m_adjustedPosition; 219 FloatPoint3D m_adjustedAnchorPoint; 220 213 221 bool m_inUpdateMode : 1; 214 222 bool m_shouldUpdateVisibleRect: 1; -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp
r136912 r136976 672 672 } 673 673 674 WebCore:: IntRect LayerTreeCoordinator::visibleContentsRect() const674 WebCore::FloatRect LayerTreeCoordinator::visibleContentsRect() const 675 675 { 676 676 return m_visibleContentsRect; … … 696 696 } 697 697 698 void LayerTreeCoordinator::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector)698 void LayerTreeCoordinator::setVisibleContentsRect(const FloatRect& rect, float scale, const FloatPoint& trajectoryVector) 699 699 { 700 700 bool contentsRectDidChange = rect != m_visibleContentsRect; … … 718 718 719 719 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 722 726 if (contentsRectDidChange) 723 727 m_shouldSendScrollPositionUpdate = true; -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h
r136912 r136976 82 82 virtual void updateTile(CoordinatedLayerID, uint32_t tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&); 83 83 virtual void removeTile(CoordinatedLayerID, uint32_t tileID); 84 virtual WebCore:: IntRect visibleContentsRect() const;84 virtual WebCore::FloatRect visibleContentsRect() const; 85 85 virtual void renderNextFrame(); 86 86 virtual void purgeBackingStores(); 87 87 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&); 89 89 virtual void didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&); 90 90 virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE; … … 188 188 bool m_waitingForUIProcess; 189 189 bool m_isSuspended; 190 WebCore:: IntRect m_visibleContentsRect;190 WebCore::FloatRect m_visibleContentsRect; 191 191 float m_contentsScale; 192 192 bool m_shouldSendScrollPositionUpdate; -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.messages.in
r132742 r136976 1 1 # 2 2 # Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) 3 # Copyright (C) 2012 Intel Corporation. All rights reserved. 3 4 # 4 5 # This library is free software; you can redistribute it and/or … … 21 22 #if USE(COORDINATED_GRAPHICS) 22 23 messages -> LayerTreeCoordinator { 23 SetVisibleContentsRect(WebCore:: IntRect visibleContentsRect, float scale, WebCore::FloatPoint trajectoryVectory)24 SetVisibleContentsRect(WebCore::FloatRect visibleContentsRect, float scale, WebCore::FloatPoint trajectoryVectory) 24 25 RenderNextFrame() 25 26 PurgeBackingStores() -
trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
r134953 r136976 40 40 namespace WebCore { 41 41 class FloatPoint; 42 class FloatRect; 42 43 class IntRect; 43 44 class IntSize; … … 93 94 94 95 #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&) { } 97 97 virtual void renderNextFrame() { } 98 98 virtual void purgeBackingStores() { }
Note: See TracChangeset
for help on using the changeset viewer.