Changeset 106565 in webkit
- Timestamp:
- Feb 2, 2012 9:44:16 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106563 r106565 1 2012-02-02 Anders Carlsson <andersca@apple.com> 2 3 Move ScrollingThread to its own file 4 https://bugs.webkit.org/show_bug.cgi?id=77652 5 6 Reviewed by Sam Weinig. 7 8 This just shuffles some classes around and makes ScrollingCoordinator call into ScrollingThread. 9 Hopefully we'll be able to make ScrollingThread use the new WebCore::RunLoop class eventually. 10 11 * WebCore.xcodeproj/project.pbxproj: 12 * page/scrolling/ScrollingCoordinator.cpp: 13 (WebCore::ScrollingCoordinator::handleWheelEvent): 14 * page/scrolling/ScrollingCoordinator.h: 15 (ScrollingCoordinator): 16 * page/scrolling/ScrollingThread.cpp: Added. 17 (WebCore): 18 (WebCore::ScrollingThread::ScrollingThread): 19 (WebCore::ScrollingThread::isCurrentThread): 20 (WebCore::ScrollingThread::dispatch): 21 (WebCore::ScrollingThread::shared): 22 (WebCore::ScrollingThread::createThreadIfNeeded): 23 (WebCore::ScrollingThread::threadCallback): 24 (WebCore::ScrollingThread::threadBody): 25 (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): 26 * page/scrolling/ScrollingThread.h: Added. 27 (WebCore): 28 (ScrollingThread): 29 * page/scrolling/mac/ScrollingCoordinatorMac.mm: 30 (WebCore::ScrollingCoordinator::scrollByOnScrollingThread): 31 (WebCore::ScrollingCoordinator::updateMainFrameScrollLayerPositionOnScrollingThread): 32 * page/scrolling/mac/ScrollingThreadMac.mm: Added. 33 (WebCore): 34 (WebCore::ScrollingThread::initializeRunLoop): 35 (WebCore::ScrollingThread::wakeUpRunLoop): 36 (WebCore::ScrollingThread::threadRunLoopSourceCallback): 37 1 38 2012-02-02 Sheriff Bot <webkit.review.bot@gmail.com> 2 39 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r106523 r106565 588 588 1AF62EE714DA22A70041556C /* ScrollingCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF62EE414DA22A70041556C /* ScrollingCoordinator.cpp */; }; 589 589 1AF62EE814DA22A70041556C /* ScrollingCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF62EE514DA22A70041556C /* ScrollingCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; }; 590 1AF62F2414DAFE910041556C /* ScrollingThreadMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AF62F2314DAFE910041556C /* ScrollingThreadMac.mm */; }; 591 1AF62F2514DAFE9E0041556C /* ScrollingThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF62F2014DAFE790041556C /* ScrollingThread.cpp */; }; 592 1AF62F2614DAFEA10041556C /* ScrollingThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF62F2114DAFE790041556C /* ScrollingThread.h */; }; 590 593 1AF8E11A1256592600230FF7 /* ProxyServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF8E1191256592600230FF7 /* ProxyServer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 591 594 1AF8E13312565A4400230FF7 /* ProxyServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF8E13212565A4400230FF7 /* ProxyServer.cpp */; }; … … 7324 7327 1AF62EE414DA22A70041556C /* ScrollingCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingCoordinator.cpp; sourceTree = "<group>"; }; 7325 7328 1AF62EE514DA22A70041556C /* ScrollingCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingCoordinator.h; sourceTree = "<group>"; }; 7329 1AF62F2014DAFE790041556C /* ScrollingThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingThread.cpp; sourceTree = "<group>"; }; 7330 1AF62F2114DAFE790041556C /* ScrollingThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingThread.h; sourceTree = "<group>"; }; 7331 1AF62F2314DAFE910041556C /* ScrollingThreadMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingThreadMac.mm; sourceTree = "<group>"; }; 7326 7332 1AF8E1191256592600230FF7 /* ProxyServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyServer.h; sourceTree = "<group>"; }; 7327 7333 1AF8E13212565A4400230FF7 /* ProxyServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProxyServer.cpp; sourceTree = "<group>"; }; … … 13912 13918 1AF62EE414DA22A70041556C /* ScrollingCoordinator.cpp */, 13913 13919 1AF62EE514DA22A70041556C /* ScrollingCoordinator.h */, 13920 1AF62F2014DAFE790041556C /* ScrollingThread.cpp */, 13921 1AF62F2114DAFE790041556C /* ScrollingThread.h */, 13914 13922 ); 13915 13923 path = scrolling; … … 13920 13928 children = ( 13921 13929 1AF62EE314DA22A70041556C /* ScrollingCoordinatorMac.mm */, 13930 1AF62F2314DAFE910041556C /* ScrollingThreadMac.mm */, 13922 13931 ); 13923 13932 path = mac; … … 24089 24098 2CF6878A14D32EFF00340F39 /* ElementAttributeData.h in Headers */, 24090 24099 1AF62EE814DA22A70041556C /* ScrollingCoordinator.h in Headers */, 24100 1AF62F2614DAFEA10041556C /* ScrollingThread.h in Headers */, 24091 24101 ); 24092 24102 runOnlyForDeploymentPostprocessing = 0; … … 27015 27025 1AF62EE614DA22A70041556C /* ScrollingCoordinatorMac.mm in Sources */, 27016 27026 1AF62EE714DA22A70041556C /* ScrollingCoordinator.cpp in Sources */, 27027 1AF62F2414DAFE910041556C /* ScrollingThreadMac.mm in Sources */, 27028 1AF62F2514DAFE9E0041556C /* ScrollingThread.cpp in Sources */, 27017 27029 ); 27018 27030 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
r106523 r106565 36 36 #include "PlatformWheelEvent.h" 37 37 #include "ScrollAnimator.h" 38 #include "ScrollingThread.h" 38 39 #include <wtf/Functional.h> 39 40 #include <wtf/MainThread.h> … … 114 115 115 116 IntSize scrollOffset = IntSize(-deltaX, -deltaY); 116 dispatchOnScrollingThread(bind(&ScrollingCoordinator::scrollByOnScrollingThread, this, scrollOffset));117 ScrollingThread::dispatch(bind(&ScrollingCoordinator::scrollByOnScrollingThread, this, scrollOffset)); 117 118 return true; 118 119 } -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h
r106523 r106565 86 86 explicit ScrollingCoordinator(Page*); 87 87 88 // FIXME: Once we have a proper thread/run loop abstraction we should get rid of these89 // functions and just use something like scrollingRunLoop()->dispatch(function);90 static bool isScrollingThread();91 static void dispatchOnScrollingThread(const Function<void()>&);92 93 88 // The following functions can only be called from the main thread. 94 89 void didUpdateMainFrameScrollPosition(); -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
r106523 r106565 32 32 #import "FrameView.h" 33 33 #import "Page.h" 34 #import "ScrollingThread.h" 34 35 #import <QuartzCore/QuartzCore.h> 35 36 #import <wtf/Functional.h> … … 40 41 41 42 namespace WebCore { 42 43 class ScrollingThread {44 public:45 ScrollingThread()46 : m_threadIdentifier(0)47 {48 }49 50 bool isCurrentThread() const;51 void dispatch(const Function<void()>&);52 53 private:54 void createThreadIfNeeded();55 56 static void* threadCallback(void* scrollingThread);57 void threadBody();58 59 static void threadRunLoopSourceCallback(void* scrollingThread);60 void threadRunLoopSourceCallback();61 62 ThreadIdentifier m_threadIdentifier;63 64 ThreadCondition m_initializeRunLoopCondition;65 Mutex m_initializeRunLoopConditionMutex;66 67 RetainPtr<CFRunLoopRef> m_threadRunLoop;68 RetainPtr<CFRunLoopSourceRef> m_threadRunLoopSource;69 70 Mutex m_functionsMutex;71 Vector<Function<void()> > m_functions;72 };73 74 bool ScrollingThread::isCurrentThread() const75 {76 if (!m_threadIdentifier)77 return false;78 79 return currentThread() == m_threadIdentifier;80 }81 82 void ScrollingThread::createThreadIfNeeded()83 {84 if (m_threadIdentifier)85 return;86 87 m_threadIdentifier = createThread(threadCallback, this, "WebCore: Scrolling");88 89 // Wait for the thread to initialize the run loop.90 {91 MutexLocker locker(m_initializeRunLoopConditionMutex);92 93 while (!m_threadRunLoop)94 m_initializeRunLoopCondition.wait(m_initializeRunLoopConditionMutex);95 }96 }97 98 void* ScrollingThread::threadCallback(void* scrollingThread)99 {100 static_cast<ScrollingThread*>(scrollingThread)->threadBody();101 102 return 0;103 }104 105 void ScrollingThread::threadBody()106 {107 ASSERT(isCurrentThread());108 109 // Initialize the run loop.110 {111 MutexLocker locker(m_initializeRunLoopConditionMutex);112 113 m_threadRunLoop = CFRunLoopGetCurrent();114 115 CFRunLoopSourceContext context = { 0, this, 0, 0, 0, 0, 0, 0, 0, threadRunLoopSourceCallback };116 m_threadRunLoopSource = adoptCF(CFRunLoopSourceCreate(0, 0, &context));117 CFRunLoopAddSource(CFRunLoopGetCurrent(), m_threadRunLoopSource.get(), kCFRunLoopDefaultMode);118 119 m_initializeRunLoopCondition.broadcast();120 }121 122 CFRunLoopRun();123 }124 125 void ScrollingThread::threadRunLoopSourceCallback(void* scrollingThread)126 {127 static_cast<ScrollingThread*>(scrollingThread)->threadRunLoopSourceCallback();128 }129 130 void ScrollingThread::threadRunLoopSourceCallback()131 {132 ASSERT(isCurrentThread());133 134 Vector<Function<void ()> > functions;135 136 {137 MutexLocker locker(m_functionsMutex);138 m_functions.swap(functions);139 }140 141 for (size_t i = 0; i < functions.size(); ++i)142 functions[i]();143 }144 145 void ScrollingThread::dispatch(const Function<void()>& function)146 {147 createThreadIfNeeded();148 149 {150 MutexLocker locker(m_functionsMutex);151 m_functions.append(function);152 }153 154 CFRunLoopSourceSignal(m_threadRunLoopSource.get());155 CFRunLoopWakeUp(m_threadRunLoop.get());156 }157 158 static ScrollingThread& scrollingThread()159 {160 DEFINE_STATIC_LOCAL(ScrollingThread, scrollingThread, ());161 return scrollingThread;162 }163 43 164 44 void ScrollingCoordinator::frameViewHorizontalScrollbarLayerDidChange(FrameView* frameView, GraphicsLayer*) … … 198 78 } 199 79 200 bool ScrollingCoordinator::isScrollingThread()201 {202 return scrollingThread().isCurrentThread();203 }204 205 void ScrollingCoordinator::dispatchOnScrollingThread(const Function<void()>& function)206 {207 return scrollingThread().dispatch(function);208 }209 210 80 void ScrollingCoordinator::scrollByOnScrollingThread(const IntSize& offset) 211 81 { 212 ASSERT( isScrollingThread());82 ASSERT(ScrollingThread::isCurrentThread()); 213 83 214 84 MutexLocker locker(m_mainFrameGeometryMutex); … … 235 105 void ScrollingCoordinator::updateMainFrameScrollLayerPositionOnScrollingThread(const FloatPoint& scrollLayerPosition) 236 106 { 237 ASSERT( isScrollingThread());107 ASSERT(ScrollingThread::isCurrentThread()); 238 108 ASSERT(!m_mainFrameGeometryMutex.tryLock()); 239 109
Note: See TracChangeset
for help on using the changeset viewer.