Changeset 96454 in webkit
- Timestamp:
- Sep 30, 2011 8:15:10 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r96452 r96454 1 2011-09-30 Adrienne Walker <enne@google.com> 2 3 [chromium] Track separate scroll deltas on the compositor thread 4 https://bugs.webkit.org/show_bug.cgi?id=69034 5 6 Reviewed by James Robinson. 7 8 Test: new tests in CCLayerTreeHostImplTest/CCLayerTreeHostTest 9 10 Track scroll deltas and maximum scrolls on LayerChromium/CCLayerImpl. 11 The CCLayerImpl tree is now able to adjust these scroll deltas 12 independent of the main thread. To push them back to the main thread, 13 CCLayerTreeHostImpl collects them all and then bakes them into the 14 scroll position during a begin frame and commit call. This allows new 15 deltas to be collected while the scroll position containing the old 16 delta and the old scroll position will be overwritten during the next 17 commit. 18 19 Only the main frame is supported right now for pushing this scroll 20 delta back into the authoritative WebKit source to keep both sides in 21 sync. 22 23 Move tilingTransform() to the impl tree because drawTransform() is now 24 updated using scroll deltas and so the results from calculating draw 25 transforms needs to be dynamic so that children are updated properly. 26 27 Also, exposed DebugScopedSetImplThread public because it's used in a 28 few places. 29 30 * platform/graphics/chromium/LayerChromium.cpp: 31 (WebCore::LayerChromium::pushPropertiesTo): 32 * platform/graphics/chromium/LayerChromium.h: 33 (WebCore::LayerChromium::maxScrollPosition): 34 (WebCore::LayerChromium::setMaxScrollPosition): 35 (WebCore::LayerChromium::scrollDelta): 36 (WebCore::LayerChromium::scrollable): 37 * platform/graphics/chromium/NonCompositedContentHost.cpp: 38 (WebCore::NonCompositedContentHost::setViewport): 39 * platform/graphics/chromium/TiledLayerChromium.cpp: 40 (WebCore::TiledLayerChromium::pushPropertiesTo): 41 * platform/graphics/chromium/TiledLayerChromium.h: 42 * platform/graphics/chromium/cc/CCLayerImpl.cpp: 43 (WebCore::CCLayerImpl::scrollBy): 44 * platform/graphics/chromium/cc/CCLayerImpl.h: 45 (WebCore::CCLayerImpl::maxScrollPosition): 46 (WebCore::CCLayerImpl::setMaxScrollPosition): 47 (WebCore::CCLayerImpl::scrollDelta): 48 (WebCore::CCLayerImpl::setScrollDelta): 49 (WebCore::CCLayerImpl::scrollable): 50 * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: 51 (WebCore::CCLayerTreeHost::applyScrollDeltas): 52 * platform/graphics/chromium/cc/CCLayerTreeHost.h: 53 * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp: 54 (WebCore::calculateDrawTransformsAndVisibilityInternal): 55 * platform/graphics/chromium/cc/CCLayerTreeHostCommon.h: 56 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: 57 (WebCore::CCLayerTreeHostImpl::scrollRootLayer): 58 (WebCore::CCLayerTreeHostImpl::processScrollDeltas): 59 * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h: 60 * platform/graphics/chromium/cc/CCProxy.h: 61 * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp: 62 (WebCore::CCSingleThreadProxy::start): 63 (WebCore::CCSingleThreadProxy::context): 64 (WebCore::CCSingleThreadProxy::finishAllRendering): 65 (WebCore::CCSingleThreadProxy::initializeLayerRenderer): 66 (WebCore::CCSingleThreadProxy::setNeedsCommit): 67 (WebCore::CCSingleThreadProxy::stop): 68 (WebCore::CCSingleThreadProxy::recreateContextIfNeeded): 69 (WebCore::CCSingleThreadProxy::commitIfNeeded): 70 (WebCore::CCSingleThreadProxy::doComposite): 71 * platform/graphics/chromium/cc/CCSingleThreadProxy.h: 72 (WebCore::DebugScopedSetImplThread::DebugScopedSetImplThread): 73 (WebCore::DebugScopedSetImplThread::~DebugScopedSetImplThread): 74 * platform/graphics/chromium/cc/CCThreadProxy.cpp: 75 (WebCore::CCThreadProxy::createBeginFrameAndCommitTaskOnCCThread): 76 (WebCore::CCThreadProxy::beginFrameAndCommit): 77 * platform/graphics/chromium/cc/CCThreadProxy.h: 78 * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp: 79 (WebCore::CCTiledLayerImpl::tilingTransform): 80 (WebCore::CCTiledLayerImpl::draw): 81 * platform/graphics/chromium/cc/CCTiledLayerImpl.h: 82 1 83 2011-09-30 David Hyatt <hyatt@apple.com> 2 84 -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
r95901 r96454 289 289 layer->setIsNonCompositedContent(m_isNonCompositedContent); 290 290 layer->setMasksToBounds(m_masksToBounds); 291 layer->setMaxScrollPosition(m_maxScrollPosition); 291 292 layer->setName(m_name); 292 293 layer->setOpacity(m_opacity); … … 296 297 layer->setSublayerTransform(m_sublayerTransform); 297 298 layer->setTransform(m_transform); 298 layer->setVisibleLayerRect(m_visibleLayerRect);299 299 300 300 if (maskLayer()) -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r96186 r96454 131 131 void setScrollPosition(const IntPoint& scrollPosition) { m_scrollPosition = scrollPosition; } 132 132 133 const IntSize& maxScrollPosition() const {return m_maxScrollPosition; } 134 void setMaxScrollPosition(const IntSize& maxScrollPosition) { m_maxScrollPosition = maxScrollPosition; } 135 136 IntSize scrollDelta() const { return IntSize(); } 137 138 bool scrollable() const { return !maxScrollPosition().isZero(); } 139 133 140 bool doubleSided() const { return m_doubleSided; } 134 141 void setDoubleSided(bool doubleSided) { m_doubleSided = doubleSided; setNeedsCommit(); } … … 238 245 IntRect m_visibleLayerRect; 239 246 IntPoint m_scrollPosition; 247 IntSize m_maxScrollPosition; 240 248 FloatPoint m_position; 241 249 FloatPoint m_anchorPoint; -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r96186 r96454 535 535 GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST)); 536 536 537 IntRect visibleLayerRect = CCLayerTreeHostCommon::calculateVisibleLayerRect(targetSurfaceRect, layer->bounds(), layer->contentBounds(), layer->drawTransform()); 538 visibleLayerRect.move(toSize(layer->scrollPosition())); 539 layer->setVisibleLayerRect(visibleLayerRect); 540 537 541 // The layer should not be drawn if (1) it is not double-sided and (2) the back of the layer is facing the screen. 538 542 // This second condition is checked by computing the transformed normal of the layer. -
trunk/Source/WebCore/platform/graphics/chromium/NonCompositedContentHost.cpp
r95901 r96454 66 66 m_viewportSize = viewportSize; 67 67 m_graphicsLayer->platformLayer()->setScrollPosition(scrollPosition); 68 IntSize maxScroll = contentsSize - viewportSize; 69 // The viewport may be larger than the contents in some cases, such as 70 // having a vertical scrollbar but no horizontal overflow. 71 maxScroll.clampNegativeToZero(); 72 73 m_graphicsLayer->platformLayer()->setMaxScrollPosition(maxScroll); 68 74 m_graphicsLayer->setSize(contentsSize); 69 75 … … 107 113 108 114 } // namespace WebCore 109 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
r96186 r96454 221 221 } 222 222 223 TransformationMatrix TiledLayerChromium::tilingTransform() const224 {225 TransformationMatrix transform = drawTransform();226 227 if (contentBounds().isEmpty())228 return transform;229 230 transform.scaleNonUniform(bounds().width() / static_cast<double>(contentBounds().width()),231 bounds().height() / static_cast<double>(contentBounds().height()));232 233 // Tiler draws with a different origin from other layers.234 transform.translate(-contentBounds().width() / 2.0, -contentBounds().height() / 2.0);235 236 transform.translate(-scrollPosition().x(), -scrollPosition().y());237 238 return transform;239 }240 241 223 void TiledLayerChromium::pushPropertiesTo(CCLayerImpl* layer) 242 224 { … … 249 231 } 250 232 251 tiledLayer->setTilingTransform(tilingTransform());252 233 tiledLayer->setSkipsDraw(m_skipsDraw); 253 234 tiledLayer->setTextureOrientation(m_textureOrientation); -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
r96186 r96454 79 79 void createTilerIfNeeded(); 80 80 void setTilingOption(TilingOption); 81 TransformationMatrix tilingTransform() const;82 81 83 82 UpdatableTile* tileAt(int, int) const; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
r96066 r96454 119 119 } 120 120 121 void CCLayerImpl::scrollBy(const IntSize& scroll) 122 { 123 IntSize newDelta = m_scrollDelta + scroll; 124 IntSize minDelta = -toSize(m_scrollPosition); 125 IntSize maxDelta = m_maxScrollPosition - toSize(m_scrollPosition); 126 // Clamp newDelta so that position + delta stays within scroll bounds. 127 m_scrollDelta = newDelta.expandedTo(minDelta).shrunkTo(maxDelta); 128 } 129 121 130 void CCLayerImpl::cleanupResources() 122 131 { -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h
r95901 r96454 146 146 void setScrollPosition(const IntPoint& scrollPosition) { m_scrollPosition = scrollPosition; } 147 147 148 const IntSize& maxScrollPosition() const {return m_maxScrollPosition; } 149 void setMaxScrollPosition(const IntSize& maxScrollPosition) { m_maxScrollPosition = maxScrollPosition; } 150 151 const IntSize& scrollDelta() const { return m_scrollDelta; } 152 void setScrollDelta(const IntSize& scrollDelta) { m_scrollDelta = scrollDelta; } 153 154 void scrollBy(const IntSize& scroll); 155 bool scrollable() const { return !maxScrollPosition().isZero(); } 156 148 157 const IntRect& visibleLayerRect() const { return m_visibleLayerRect; } 149 158 void setVisibleLayerRect(const IntRect& visibleLayerRect) { m_visibleLayerRect = visibleLayerRect; } … … 192 201 IntSize m_contentBounds; 193 202 IntPoint m_scrollPosition; 194 Int Rect m_visibleLayerRect;203 IntSize m_maxScrollPosition; 195 204 196 205 // Whether the "back" of this layer should draw. 197 206 bool m_doubleSided; 198 207 208 IntRect m_visibleLayerRect; 199 209 bool m_masksToBounds; 200 210 float m_opacity; … … 208 218 bool m_drawsContent; 209 219 220 IntSize m_scrollDelta; 221 210 222 // Properties owned exclusively by this CCLayerImpl. 211 223 // Debugging. -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
r96392 r96454 416 416 } 417 417 418 } 418 void CCLayerTreeHost::applyScrollDeltas(const CCScrollUpdateSet& info) 419 { 420 for (size_t i = 0; i < info.size(); ++i) { 421 int layerId = info[i].layerId; 422 IntSize scrollDelta = info[i].scrollDelta; 423 424 // FIXME: pushing scroll offsets to non-root layers not implemented 425 if (rootLayer()->id() == layerId) 426 m_client->applyScrollDelta(scrollDelta); 427 else 428 ASSERT_NOT_REACHED(); 429 } 430 } 431 432 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
r96392 r96454 29 29 #include "IntRect.h" 30 30 #include "TransformationMatrix.h" 31 #include "cc/CCLayerTreeHostCommon.h" 31 32 #include "cc/CCProxy.h" 32 33 … … 51 52 public: 52 53 virtual void animateAndLayout(double frameBeginTime) = 0; 54 virtual void applyScrollDelta(const IntSize&) = 0; 53 55 virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() = 0; 54 56 virtual void didRecreateGraphicsContext(bool success) = 0; … … 151 153 void updateLayers(); 152 154 155 void applyScrollDeltas(const CCScrollUpdateSet&); 153 156 protected: 154 157 CCLayerTreeHost(CCLayerTreeHostClient*, PassRefPtr<LayerChromium> rootLayer, const CCSettings&); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp
r95901 r96454 112 112 IntSize bounds = layer->bounds(); 113 113 FloatPoint anchorPoint = layer->anchorPoint(); 114 FloatPoint position = layer->position() ;114 FloatPoint position = layer->position() - layer->scrollDelta(); 115 115 116 116 // Offset between anchor point and the center of the quad. -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.h
r95901 r96454 26 26 #define CCLayerTreeHostCommon_h 27 27 28 #include "IntSize.h" 28 29 #include <wtf/RefPtr.h> 29 30 #include <wtf/Vector.h> … … 34 35 class CCLayerSorter; 35 36 class IntRect; 36 class IntSize;37 37 class LayerChromium; 38 38 class TransformationMatrix; … … 47 47 static void calculateDrawTransformsAndVisibility(CCLayerImpl*, CCLayerImpl* rootLayer, const TransformationMatrix& parentMatrix, const TransformationMatrix& fullHierarchyMatrix, Vector<RefPtr<CCLayerImpl> >& renderSurfaceLayerList, Vector<RefPtr<CCLayerImpl> >& layerList, CCLayerSorter*, int maxTextureSize); 48 48 49 struct ScrollUpdateInfo { 50 int layerId; 51 IntSize scrollDelta; 52 }; 49 53 }; 54 55 typedef Vector<CCLayerTreeHostCommon::ScrollUpdateInfo> CCScrollUpdateSet; 50 56 51 57 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
r96186 r96454 160 160 } 161 161 162 void CCLayerTreeHostImpl::scrollRootLayer(const IntSize& scrollDelta) 163 { 164 if (!m_rootLayerImpl || !m_rootLayerImpl->scrollable()) 165 return; 166 167 m_rootLayerImpl->scrollBy(scrollDelta); 162 168 } 169 170 PassOwnPtr<CCScrollUpdateSet> CCLayerTreeHostImpl::processScrollDeltas() 171 { 172 OwnPtr<CCScrollUpdateSet> scrollInfo = adoptPtr(new CCScrollUpdateSet()); 173 // FIXME: track scrolls from layers other than the root 174 if (rootLayer() && !rootLayer()->scrollDelta().isZero()) { 175 CCLayerTreeHostCommon::ScrollUpdateInfo info; 176 info.layerId = rootLayer()->id(); 177 info.scrollDelta = rootLayer()->scrollDelta(); 178 scrollInfo->append(info); 179 180 rootLayer()->setScrollPosition(rootLayer()->scrollPosition() + rootLayer()->scrollDelta()); 181 rootLayer()->setScrollDelta(IntSize()); 182 } 183 return scrollInfo.release(); 184 } 185 186 } -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h
r96186 r96454 27 27 28 28 #include "cc/CCLayerTreeHost.h" 29 #include "cc/CCLayerTreeHostCommon.h" 29 30 #include <wtf/RefPtr.h> 30 31 … … 82 83 83 84 const CCSettings& settings() const { return m_settings; } 85 86 void scrollRootLayer(const IntSize&); 87 88 PassOwnPtr<CCScrollUpdateSet> processScrollDeltas(); 89 84 90 protected: 85 91 explicit CCLayerTreeHostImpl(const CCSettings&); -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCProxy.h
r96066 r96454 89 89 protected: 90 90 CCProxy() { } 91 friend class ScopedSetImplThread;91 friend class DebugScopedSetImplThread; 92 92 }; 93 93 -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
r96186 r96454 38 38 namespace WebCore { 39 39 40 class ScopedSetImplThread {41 public:42 ScopedSetImplThread()43 {44 #ifndef NDEBUG45 ASSERT(CCProxy::isMainThread());46 CCProxy::setImplThread(true);47 #endif48 }49 ~ScopedSetImplThread()50 {51 #ifndef NDEBUG52 CCProxy::setImplThread(false);53 #endif54 }55 };56 57 40 PassOwnPtr<CCProxy> CCSingleThreadProxy::create(CCLayerTreeHost* layerTreeHost) 58 41 { … … 72 55 void CCSingleThreadProxy::start() 73 56 { 74 ScopedSetImplThread impl;57 DebugScopedSetImplThread impl; 75 58 m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(); 76 59 } … … 106 89 { 107 90 ASSERT(CCProxy::isMainThread()); 108 ScopedSetImplThread impl;91 DebugScopedSetImplThread impl; 109 92 return m_layerTreeHostImpl->context(); 110 93 } … … 114 97 ASSERT(CCProxy::isMainThread()); 115 98 { 116 ScopedSetImplThread impl;99 DebugScopedSetImplThread impl; 117 100 m_layerTreeHostImpl->finishAllRendering(); 118 101 } … … 134 117 135 118 { 136 ScopedSetImplThread impl;119 DebugScopedSetImplThread impl; 137 120 bool ok = m_layerTreeHostImpl->initializeLayerRenderer(context); 138 121 if (ok) … … 159 142 // Commit immediately 160 143 { 161 ScopedSetImplThread impl;144 DebugScopedSetImplThread impl; 162 145 m_layerTreeHostImpl->beginCommit(); 163 146 m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get()); 164 147 m_layerTreeHostImpl->commitComplete(); 148 149 #if !ASSERT_DISABLED 150 // In the single-threaded case, the scroll deltas should never be 151 // touched on the impl layer tree. 152 OwnPtr<CCScrollUpdateSet> scrollInfo = m_layerTreeHostImpl->processScrollDeltas(); 153 ASSERT(!scrollInfo->size()); 154 #endif 165 155 } 166 156 m_layerTreeHost->commitComplete(); … … 190 180 ASSERT(CCProxy::isMainThread()); 191 181 { 192 ScopedSetImplThread impl;182 DebugScopedSetImplThread impl; 193 183 m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator()); 194 184 m_layerTreeHostImpl.clear(); … … 227 217 bool ok; 228 218 { 229 ScopedSetImplThread impl;219 DebugScopedSetImplThread impl; 230 220 m_layerTreeHost->deleteContentsTexturesOnCCThread(m_layerTreeHostImpl->contentsTextureAllocator()); 231 221 ok = m_layerTreeHostImpl->initializeLayerRenderer(context); … … 263 253 // Commit 264 254 { 265 ScopedSetImplThread impl;255 DebugScopedSetImplThread impl; 266 256 m_layerTreeHostImpl->beginCommit(); 267 257 m_layerTreeHost->commitToOnCCThread(m_layerTreeHostImpl.get()); … … 276 266 277 267 { 278 ScopedSetImplThread impl;268 DebugScopedSetImplThread impl; 279 269 m_layerTreeHostImpl->drawLayers(); 280 270 if (m_layerTreeHostImpl->isContextLost()) { -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
r96066 r96454 77 77 }; 78 78 79 } 79 // For use in the single-threaded case. In debug builds, it pretends that the 80 // code is running on the thread to satisfy assertion checks. 81 class DebugScopedSetImplThread { 82 public: 83 DebugScopedSetImplThread() 84 { 85 #if !ASSERT_DISABLED 86 ASSERT(CCProxy::isMainThread()); 87 CCProxy::setImplThread(true); 88 #endif 89 } 90 ~DebugScopedSetImplThread() 91 { 92 #if !ASSERT_DISABLED 93 CCProxy::setImplThread(false); 94 #endif 95 } 96 }; 97 98 } // namespace WebCore 80 99 81 100 #endif -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
r96392 r96454 280 280 int thisTaskSequenceNumber = m_numBeginFrameAndCommitsIssuedOnCCThread; 281 281 m_numBeginFrameAndCommitsIssuedOnCCThread++; 282 return createMainThreadTask(this, &CCThreadProxy::beginFrameAndCommit, thisTaskSequenceNumber, frameBeginTime); 283 } 284 285 void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTime) 282 OwnPtr<CCScrollUpdateSet> scrollInfo = m_layerTreeHostImpl->processScrollDeltas(); 283 return createMainThreadTask(this, &CCThreadProxy::beginFrameAndCommit, thisTaskSequenceNumber, frameBeginTime, scrollInfo.release()); 284 } 285 286 void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTime, PassOwnPtr<CCScrollUpdateSet> scrollInfo) 286 287 { 287 288 TRACE_EVENT("CCThreadProxy::beginFrameAndCommit", this, 0); … … 289 290 if (!m_layerTreeHost) 290 291 return; 292 293 // Scroll deltas need to be applied even if the commit will be dropped. 294 m_layerTreeHost->applyScrollDeltas(*scrollInfo.get()); 291 295 292 296 // Drop beginFrameAndCommit calls that occur out of sequence. See createBeginFrameAndCommitTaskOnCCThread for -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h
r96392 r96454 63 63 64 64 // Called on CCMainThread 65 void beginFrameAndCommit(int sequenceNumber, double frameBeginTime );65 void beginFrameAndCommit(int sequenceNumber, double frameBeginTime, PassOwnPtr<CCScrollUpdateSet>); 66 66 67 67 // Called on CCThread -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp
r95901 r96454 93 93 } 94 94 95 TransformationMatrix CCTiledLayerImpl::tilingTransform() const 96 { 97 TransformationMatrix transform = drawTransform(); 98 99 if (contentBounds().isEmpty()) 100 return transform; 101 102 transform.scaleNonUniform(bounds().width() / static_cast<double>(contentBounds().width()), 103 bounds().height() / static_cast<double>(contentBounds().height())); 104 105 // Tiler draws with a different origin from other layers. 106 transform.translate(-contentBounds().width() / 2.0, -contentBounds().height() / 2.0); 107 108 transform.translate(-scrollPosition().x(), -scrollPosition().y()); 109 110 return transform; 111 } 112 95 113 void CCTiledLayerImpl::draw(LayerRendererChromium* layerRenderer) 96 114 { -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.h
r95901 r96454 70 70 virtual const char* layerTypeAsString() const { return "ContentLayer"; } 71 71 72 TransformationMatrix tilingTransform() const; 73 72 74 // Draw all tiles that intersect with the content rect. 73 75 void draw(LayerRendererChromium*, const IntRect& contentRect, const TransformationMatrix&, float opacity); -
trunk/Source/WebKit/chromium/ChangeLog
r96450 r96454 1 2011-09-30 Adrienne Walker <enne@google.com> 2 3 [chromium] Track separate scroll deltas on the compositor thread 4 https://bugs.webkit.org/show_bug.cgi?id=69034 5 6 Reviewed by James Robinson. 7 8 Add testing support for scroll deltas on layers. 9 10 * WebKit.gypi: 11 * src/WebViewImpl.cpp: 12 (WebKit::WebViewImpl::applyScrollDelta): 13 * src/WebViewImpl.h: 14 * tests/CCLayerTreeHostImplTest.cpp: Added. 15 (WebCore::CCLayerTreeHostImplTest::CCLayerTreeHostImplTest): 16 (WebCore::CCLayerTreeHostImplTest::expectClearedScrollDeltasRecursive): 17 (WebCore::CCLayerTreeHostImplTest::expectContains): 18 (WebCore::TEST_F): 19 * tests/CCLayerTreeHostTest.cpp: 20 (WTF::TestHooks::applyScrollDelta): 21 (WTF::MockLayerTreeHostClient::applyScrollDelta): 22 (WTF::CCLayerTreeHostTest::runTest): 23 (WTF::CCLayerTreeHostTest::doBeginTest): 24 (WTF::CCLayerTreeHostTestThreadOnly::runTest): 25 (WTF::CCLayerTreeHostTestScrollSimple::CCLayerTreeHostTestScrollSimple): 26 (WTF::CCLayerTreeHostTestScrollSimple::beginTest): 27 (WTF::CCLayerTreeHostTestScrollSimple::beginCommitOnCCThread): 28 (WTF::CCLayerTreeHostTestScrollSimple::drawLayersOnCCThread): 29 (WTF::CCLayerTreeHostTestScrollSimple::applyScrollDelta): 30 (WTF::CCLayerTreeHostTestScrollSimple::afterTest): 31 (WTF::TEST_F): 32 (WTF::CCLayerTreeHostTestScrollMultipleRedraw::CCLayerTreeHostTestScrollMultipleRedraw): 33 (WTF::CCLayerTreeHostTestScrollMultipleRedraw::beginTest): 34 (WTF::CCLayerTreeHostTestScrollMultipleRedraw::beginCommitOnCCThread): 35 (WTF::CCLayerTreeHostTestScrollMultipleRedraw::drawLayersOnCCThread): 36 (WTF::CCLayerTreeHostTestScrollMultipleRedraw::applyScrollDelta): 37 (WTF::CCLayerTreeHostTestScrollMultipleRedraw::afterTest): 38 * tests/TreeSynchronizerTest.cpp: 39 (WebCore::TEST): 40 1 41 2011-09-30 Shawn Singh <shawnsingh@chromium.org> 2 42 -
trunk/Source/WebKit/chromium/WebKit.gypi
r96450 r96454 57 57 'tests/CCLayerSorterTest.cpp', 58 58 'tests/CCLayerTreeHostTest.cpp', 59 'tests/CCLayerTreeHostImplTest.cpp', 59 60 'tests/CCThreadTaskTest.cpp', 60 61 'tests/CCThreadTest.cpp', -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r96392 r96454 2705 2705 } 2706 2706 2707 void WebViewImpl::applyScrollDelta(const IntSize& scrollDelta) 2708 { 2709 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 2710 return; 2711 2712 mainFrameImpl()->frameView()->scrollBy(scrollDelta); 2713 } 2714 2707 2715 void WebViewImpl::didRecreateGraphicsContext(bool success) 2708 2716 { -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r96392 r96454 220 220 // CCLayerTreeHostClient 221 221 virtual void animateAndLayout(double frameBeginTime); 222 virtual void applyScrollDelta(const WebCore::IntSize&); 222 223 virtual PassRefPtr<WebCore::GraphicsContext3D> createLayerTreeHostContext3D(); 223 224 virtual void didRecreateGraphicsContext(bool success); -
trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
r96392 r96454 29 29 #include "cc/CCLayerTreeHost.h" 30 30 31 #include "cc/CCLayerImpl.h" 31 32 #include "cc/CCLayerTreeHostImpl.h" 32 33 #include "cc/CCMainThreadTask.h" 33 34 #include "cc/CCThreadTask.h" 34 #include "CCThreadImpl.h"35 35 #include "GraphicsContext3DPrivate.h" 36 36 #include <gtest/gtest.h> … … 59 59 virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) { } 60 60 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl*) { } 61 virtual void applyScrollDelta(const IntSize&) { } 61 62 }; 62 63 … … 150 151 virtual void animateAndLayout(double frameBeginTime) 151 152 { 153 } 154 155 virtual void applyScrollDelta(const IntSize& scrollDelta) 156 { 157 m_testHooks->applyScrollDelta(scrollDelta); 152 158 } 153 159 … … 251 257 } 252 258 253 v oid runTest()259 virtual void runTest() 254 260 { 255 261 webkit_support::PostDelayedTask(CCLayerTreeHostTest::onBeginTest, static_cast<void*>(this), 0); … … 297 303 m_client = MockLayerTreeHostClient::create(this); 298 304 299 RefPtr<LayerChromium> rootLayer ;305 RefPtr<LayerChromium> rootLayer = LayerChromium::create(0); 300 306 m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings); 301 307 ASSERT(m_layerTreeHost); … … 323 329 } 324 330 331 class CCLayerTreeHostTestThreadOnly : public CCLayerTreeHostTest { 332 public: 333 virtual void runTest() 334 { 335 if (m_settings.enableCompositorThread) 336 CCLayerTreeHostTest::runTest(); 337 } 338 }; 339 325 340 // Shortlived layerTreeHosts shouldn't die. 326 341 class CCLayerTreeHostTestShortlived1 : public CCLayerTreeHostTest { … … 557 572 } 558 573 574 class CCLayerTreeHostTestScrollSimple : public CCLayerTreeHostTestThreadOnly { 575 public: 576 CCLayerTreeHostTestScrollSimple() 577 : m_initialScroll(IntPoint(10, 20)) 578 , m_secondScroll(IntPoint(40, 5)) 579 , m_scrollAmount(2, -1) 580 , m_scrolls(0) 581 { 582 } 583 584 virtual void beginTest() 585 { 586 m_layerTreeHost->rootLayer()->setMaxScrollPosition(IntSize(100, 100)); 587 m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll); 588 postSetNeedsCommitToMainThread(); 589 } 590 591 virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl) 592 { 593 LayerChromium* root = m_layerTreeHost->rootLayer(); 594 if (!m_layerTreeHost->frameNumber()) 595 EXPECT_EQ(root->scrollPosition(), m_initialScroll); 596 else { 597 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount); 598 599 // Pretend like Javascript updated the scroll position itself. 600 root->setScrollPosition(m_secondScroll); 601 } 602 } 603 604 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) 605 { 606 CCLayerImpl* root = impl->rootLayer(); 607 EXPECT_EQ(root->scrollDelta(), IntSize()); 608 609 root->scrollBy(m_scrollAmount); 610 611 if (impl->frameNumber() == 1) { 612 EXPECT_EQ(root->scrollPosition(), m_initialScroll); 613 EXPECT_EQ(root->scrollDelta(), m_scrollAmount); 614 postSetNeedsCommitToMainThread(); 615 } else if (impl->frameNumber() == 2) { 616 EXPECT_EQ(root->scrollPosition(), m_secondScroll); 617 EXPECT_EQ(root->scrollDelta(), m_scrollAmount); 618 endTest(); 619 } 620 } 621 622 virtual void applyScrollDelta(const IntSize& scrollDelta) 623 { 624 IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition(); 625 m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta); 626 m_scrolls++; 627 } 628 629 virtual void afterTest() 630 { 631 EXPECT_EQ(1, m_scrolls); 632 } 633 private: 634 IntPoint m_initialScroll; 635 IntPoint m_secondScroll; 636 IntSize m_scrollAmount; 637 int m_scrolls; 638 }; 639 TEST_F(CCLayerTreeHostTestScrollSimple, run) 640 { 641 runTest(); 642 } 643 644 class CCLayerTreeHostTestScrollMultipleRedraw : public CCLayerTreeHostTestThreadOnly { 645 public: 646 CCLayerTreeHostTestScrollMultipleRedraw() 647 : m_initialScroll(IntPoint(40, 10)) 648 , m_scrollAmount(-3, 17) 649 , m_scrolls(0) 650 { 651 } 652 653 virtual void beginTest() 654 { 655 m_layerTreeHost->rootLayer()->setMaxScrollPosition(IntSize(100, 100)); 656 m_layerTreeHost->rootLayer()->setScrollPosition(m_initialScroll); 657 postSetNeedsCommitToMainThread(); 658 } 659 660 virtual void beginCommitOnCCThread(CCLayerTreeHostImpl* impl) 661 { 662 LayerChromium* root = m_layerTreeHost->rootLayer(); 663 if (!m_layerTreeHost->frameNumber()) 664 EXPECT_EQ(root->scrollPosition(), m_initialScroll); 665 else if (m_layerTreeHost->frameNumber() == 1) 666 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount); 667 else if (m_layerTreeHost->frameNumber() == 2) 668 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount); 669 } 670 671 virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) 672 { 673 CCLayerImpl* root = impl->rootLayer(); 674 675 if (impl->frameNumber() == 1) { 676 EXPECT_EQ(root->scrollDelta(), IntSize()); 677 root->scrollBy(m_scrollAmount); 678 EXPECT_EQ(root->scrollDelta(), m_scrollAmount); 679 680 EXPECT_EQ(root->scrollPosition(), m_initialScroll); 681 postSetNeedsRedrawToMainThread(); 682 } else if (impl->frameNumber() == 2) { 683 EXPECT_EQ(root->scrollDelta(), m_scrollAmount); 684 root->scrollBy(m_scrollAmount); 685 EXPECT_EQ(root->scrollDelta(), m_scrollAmount + m_scrollAmount); 686 687 EXPECT_EQ(root->scrollPosition(), m_initialScroll); 688 postSetNeedsCommitToMainThread(); 689 } else if (impl->frameNumber() == 3) { 690 EXPECT_EQ(root->scrollDelta(), IntSize()); 691 EXPECT_EQ(root->scrollPosition(), m_initialScroll + m_scrollAmount + m_scrollAmount); 692 endTest(); 693 } 694 } 695 696 virtual void applyScrollDelta(const IntSize& scrollDelta) 697 { 698 IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition(); 699 m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta); 700 m_scrolls++; 701 } 702 703 virtual void afterTest() 704 { 705 EXPECT_EQ(1, m_scrolls); 706 } 707 private: 708 IntPoint m_initialScroll; 709 IntSize m_scrollAmount; 710 int m_scrolls; 711 }; 712 TEST_F(CCLayerTreeHostTestScrollMultipleRedraw, run) 713 { 714 runTest(); 715 } 716 559 717 } // namespace 560 718 -
trunk/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp
r96066 r96454 30 30 #include "cc/CCLayerImpl.h" 31 31 #include "cc/CCProxy.h" 32 #include "cc/CCSingleThreadProxy.h" 32 33 #include <gtest/gtest.h> 33 34 … … 35 36 36 37 namespace { 37 38 class ScopedSetImplThread {39 public:40 ScopedSetImplThread()41 {42 #ifndef NDEBUG43 CCProxy::setImplThread(true);44 #endif45 }46 ~ScopedSetImplThread()47 {48 #ifndef NDEBUG49 CCProxy::setImplThread(false);50 #endif51 }52 };53 38 54 39 class MockCCLayerImpl : public CCLayerImpl { … … 134 119 TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty) 135 120 { 136 ScopedSetImplThread impl;121 DebugScopedSetImplThread impl; 137 122 RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create(0); 138 123 layerTreeRoot->addChild(LayerChromium::create(0)); … … 147 132 TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers) 148 133 { 149 ScopedSetImplThread impl;134 DebugScopedSetImplThread impl; 150 135 Vector<int> ccLayerDestructionList; 151 136 … … 173 158 TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties) 174 159 { 175 ScopedSetImplThread impl;160 DebugScopedSetImplThread impl; 176 161 RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create(0); 177 162 layerTreeRoot->addChild(LayerChromium::create(0)); … … 205 190 TEST(TreeSynchronizerTest, reuseCCLayersAfterStructuralChange) 206 191 { 207 ScopedSetImplThread impl;192 DebugScopedSetImplThread impl; 208 193 Vector<int> ccLayerDestructionList; 209 194 … … 252 237 TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy) 253 238 { 254 ScopedSetImplThread impl;239 DebugScopedSetImplThread impl; 255 240 Vector<int> ccLayerDestructionList; 256 241 … … 283 268 TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) 284 269 { 285 ScopedSetImplThread impl;270 DebugScopedSetImplThread impl; 286 271 RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create(0); 287 272 layerTreeRoot->addChild(LayerChromium::create(0));
Note: See TracChangeset
for help on using the changeset viewer.