Diff
Modified: trunk/Source/WebCore/ChangeLog (100383 => 100384)
--- trunk/Source/WebCore/ChangeLog 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebCore/ChangeLog 2011-11-16 01:52:24 UTC (rev 100384)
@@ -1,3 +1,35 @@
+2011-11-15 Andy Estes <aes...@apple.com>
+
+ Consolidate the logic that creates run loop observers for flushing layer tree changes to CoreAnimation
+ https://bugs.webkit.org/show_bug.cgi?id=72106
+
+ Reviewed by Anders Carlsson.
+
+ Add a class that encapsulates the logic of scheduling, enabling and
+ invalidating a run loop observer that fires before Core Animation's
+ commit observer. Clients can subclass LayerFlushSchedulerClient and
+ implement flushLayers(), which will be called by the observer.
+
+ * WebCore.exp.in:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/ca/LayerFlushScheduler.cpp: Added.
+ (WebCore::LayerFlushScheduler::suspend): Suspend scheduling by
+ invalidating the run loop observer. Keep a count of calls to suspend()
+ in m_suspendCount.
+ (WebCore::LayerFlushScheduler::resume): Decrement m_suspendCount.
+ Install the run loop observer when it reaches 0.
+ * platform/graphics/ca/LayerFlushSchedulerClient.h: Added.
+ (WebCore::LayerFlushSchedulerClient::~LayerFlushSchedulerClient):
+ * platform/graphics/ca/LayerFlushScheduler.h: Added.
+ * platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp: Added.
+ (LayerFlushScheduler::LayerFlushScheduler):
+ (LayerFlushScheduler::~LayerFlushScheduler):
+ (LayerFlushScheduler::runLoopObserverCallback): Call flushLayers() on
+ the LayerFlushSchedulerClient.
+ (LayerFlushScheduler::schedule): Install the run loop observer.
+ (LayerFlushScheduler::invalidate): Remove the run loop
+ observer if it is installed.
+
2011-11-15 Adam Klein <ad...@chromium.org>
[v8] Use throwError instead of compiling and running script in handleMaxRecursionDepthExceeded
Modified: trunk/Source/WebCore/WebCore.exp.in (100383 => 100384)
--- trunk/Source/WebCore/WebCore.exp.in 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebCore/WebCore.exp.in 2011-11-16 01:52:24 UTC (rev 100384)
@@ -566,6 +566,12 @@
__ZN7WebCore19BackForwardListImpl9goForwardEv
__ZN7WebCore19BackForwardListImplC1EPNS_4PageE
__ZN7WebCore19CSSStyleDeclaration11setPropertyERKN3WTF6StringES4_Ri
+__ZN7WebCore19LayerFlushScheduler10invalidateEv
+__ZN7WebCore19LayerFlushScheduler6resumeEv
+__ZN7WebCore19LayerFlushScheduler7suspendEv
+__ZN7WebCore19LayerFlushScheduler8scheduleEv
+__ZN7WebCore19LayerFlushSchedulerC1EPNS_25LayerFlushSchedulerClientE
+__ZN7WebCore19LayerFlushSchedulerD1Ev
__ZN7WebCore19ResourceRequestBase11setHTTPBodyEN3WTF10PassRefPtrINS_8FormDataEEE
__ZN7WebCore19ResourceRequestBase13setHTTPMethodERKN3WTF6StringE
__ZN7WebCore19ResourceRequestBase18setHTTPHeaderFieldEPKcRKN3WTF6StringE
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (100383 => 100384)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-11-16 01:52:24 UTC (rev 100384)
@@ -669,6 +669,10 @@
2542F4DA1166C25A00E89A86 /* UserGestureIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2542F4D81166C25A00E89A86 /* UserGestureIndicator.cpp */; };
2542F4DB1166C25A00E89A86 /* UserGestureIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2542F4D91166C25A00E89A86 /* UserGestureIndicator.h */; settings = {ATTRIBUTES = (Private, ); }; };
26E98A10130A9FCA008EB7B2 /* TextCodecASCIIFastPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 26E98A0F130A9FCA008EB7B2 /* TextCodecASCIIFastPath.h */; };
+ 2917B5611473496C0052C9D0 /* LayerFlushScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2917B55E1473496C0052C9D0 /* LayerFlushScheduler.cpp */; };
+ 2917B5621473496C0052C9D0 /* LayerFlushScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 2917B55F1473496C0052C9D0 /* LayerFlushScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 2917B5631473496C0052C9D0 /* LayerFlushSchedulerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2917B5601473496C0052C9D0 /* LayerFlushSchedulerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 2917B566147349950052C9D0 /* LayerFlushSchedulerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2917B565147349950052C9D0 /* LayerFlushSchedulerMac.cpp */; };
293EAE1F1356B2FE0067ACF9 /* RuntimeApplicationChecks.h in Headers */ = {isa = PBXBuildFile; fileRef = 293EAE1E1356B2FE0067ACF9 /* RuntimeApplicationChecks.h */; settings = {ATTRIBUTES = (Private, ); }; };
293EAE211356B32E0067ACF9 /* RuntimeApplicationChecks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 293EAE201356B32E0067ACF9 /* RuntimeApplicationChecks.cpp */; };
29489FC712C00F0300D83F0F /* AccessibilityScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 29489FC512C00F0300D83F0F /* AccessibilityScrollView.h */; };
@@ -7750,6 +7754,10 @@
2542F4D81166C25A00E89A86 /* UserGestureIndicator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserGestureIndicator.cpp; sourceTree = "<group>"; };
2542F4D91166C25A00E89A86 /* UserGestureIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserGestureIndicator.h; sourceTree = "<group>"; };
26E98A0F130A9FCA008EB7B2 /* TextCodecASCIIFastPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecASCIIFastPath.h; sourceTree = "<group>"; };
+ 2917B55E1473496C0052C9D0 /* LayerFlushScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LayerFlushScheduler.cpp; path = ca/LayerFlushScheduler.cpp; sourceTree = "<group>"; };
+ 2917B55F1473496C0052C9D0 /* LayerFlushScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LayerFlushScheduler.h; path = ca/LayerFlushScheduler.h; sourceTree = "<group>"; };
+ 2917B5601473496C0052C9D0 /* LayerFlushSchedulerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LayerFlushSchedulerClient.h; path = ca/LayerFlushSchedulerClient.h; sourceTree = "<group>"; };
+ 2917B565147349950052C9D0 /* LayerFlushSchedulerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LayerFlushSchedulerMac.cpp; path = ca/mac/LayerFlushSchedulerMac.cpp; sourceTree = "<group>"; };
293EAE1E1356B2FE0067ACF9 /* RuntimeApplicationChecks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeApplicationChecks.h; sourceTree = "<group>"; };
293EAE201356B32E0067ACF9 /* RuntimeApplicationChecks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeApplicationChecks.cpp; sourceTree = "<group>"; };
29489FC512C00F0300D83F0F /* AccessibilityScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityScrollView.h; sourceTree = "<group>"; };
@@ -14957,6 +14965,7 @@
4958781E12A57DBC007238AC /* mac */ = {
isa = PBXGroup;
children = (
+ 2917B565147349950052C9D0 /* LayerFlushSchedulerMac.cpp */,
4958781F12A57DDF007238AC /* PlatformCAAnimationMac.mm */,
4958782012A57DDF007238AC /* PlatformCALayerMac.mm */,
);
@@ -14993,6 +15002,9 @@
4958781E12A57DBC007238AC /* mac */,
499B3ED4128CD31400E726C2 /* GraphicsLayerCA.cpp */,
499B3ED5128CD31400E726C2 /* GraphicsLayerCA.h */,
+ 2917B55E1473496C0052C9D0 /* LayerFlushScheduler.cpp */,
+ 2917B55F1473496C0052C9D0 /* LayerFlushScheduler.h */,
+ 2917B5601473496C0052C9D0 /* LayerFlushSchedulerClient.h */,
499B3EDC128DB50100E726C2 /* PlatformCAAnimation.h */,
499B3EC3128CCC4700E726C2 /* PlatformCALayer.h */,
493E5E0812D6420500020081 /* PlatformCALayerClient.h */,
@@ -24680,6 +24692,8 @@
29CD61DE146D02890068E82A /* WebKitCSSShaderValue.h in Headers */,
CDF65CC8145B1E7500C4C7AA /* MediaController.h in Headers */,
CDF65CCA145B448800C4C7AA /* MediaControllerInterface.h in Headers */,
+ 2917B5621473496C0052C9D0 /* LayerFlushScheduler.h in Headers */,
+ 2917B5631473496C0052C9D0 /* LayerFlushSchedulerClient.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -27548,6 +27562,8 @@
7134496D146941B300720312 /* SVGLengthContext.cpp in Sources */,
974D2DA4146A535D00D51F8B /* SecurityPolicy.cpp in Sources */,
31313F651443B35F006E2A90 /* FilterEffectRenderer.cpp in Sources */,
+ 2917B5611473496C0052C9D0 /* LayerFlushScheduler.cpp in Sources */,
+ 2917B566147349950052C9D0 /* LayerFlushSchedulerMac.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Added: trunk/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.cpp (0 => 100384)
--- trunk/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.cpp 2011-11-16 01:52:24 UTC (rev 100384)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "LayerFlushScheduler.h"
+
+namespace WebCore {
+
+void LayerFlushScheduler::suspend()
+{
+ if (!m_suspendCount)
+ invalidate();
+
+ ++m_suspendCount;
+}
+
+void LayerFlushScheduler::resume()
+{
+ ASSERT(m_suspendCount);
+ --m_suspendCount;
+
+ if (!m_suspendCount)
+ schedule();
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
Added: trunk/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h (0 => 100384)
--- trunk/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h 2011-11-16 01:52:24 UTC (rev 100384)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LayerFlushScheduler_h
+#define LayerFlushScheduler_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "LayerFlushSchedulerClient.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class LayerFlushScheduler {
+ WTF_MAKE_NONCOPYABLE(LayerFlushScheduler);
+public:
+ LayerFlushScheduler(LayerFlushSchedulerClient*);
+ ~LayerFlushScheduler();
+
+ void schedule();
+ void invalidate();
+
+ void suspend();
+ void resume();
+
+private:
+ unsigned int m_suspendCount;
+ LayerFlushSchedulerClient* m_client;
+
+#if PLATFORM(MAC)
+ RetainPtr<CFRunLoopObserverRef> m_runLoopObserver;
+ static void runLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context);
+#endif
+};
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // LayerFlushScheduler_h
Added: trunk/Source/WebCore/platform/graphics/ca/LayerFlushSchedulerClient.h (0 => 100384)
--- trunk/Source/WebCore/platform/graphics/ca/LayerFlushSchedulerClient.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/LayerFlushSchedulerClient.h 2011-11-16 01:52:24 UTC (rev 100384)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LayerFlushSchedulerClient_h
+#define LayerFlushSchedulerClient_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+namespace WebCore {
+
+class LayerFlushSchedulerClient {
+public:
+ virtual ~LayerFlushSchedulerClient() { }
+ virtual void flushLayers() = 0;
+};
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // LayerFlushSchedulerClient_h
Added: trunk/Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp (0 => 100384)
--- trunk/Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp 2011-11-16 01:52:24 UTC (rev 100384)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "LayerFlushScheduler.h"
+
+namespace WebCore {
+
+static const CFIndex CoreAnimationRunLoopOrder = 2000000;
+static const CFIndex LayerFlushRunLoopOrder = CoreAnimationRunLoopOrder - 1;
+
+LayerFlushScheduler::LayerFlushScheduler(LayerFlushSchedulerClient* client)
+ : m_suspendCount(0)
+ , m_client(client)
+{
+ ASSERT_ARG(client, client);
+}
+
+LayerFlushScheduler::~LayerFlushScheduler()
+{
+ ASSERT(!m_runLoopObserver);
+}
+
+void LayerFlushScheduler::runLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context)
+{
+ LayerFlushScheduler* layerFlushScheduler = static_cast<LayerFlushScheduler*>(context);
+ ASSERT(layerFlushScheduler->m_runLoopObserver);
+ ASSERT(!layerFlushScheduler->m_suspendCount);
+ layerFlushScheduler->m_client->flushLayers();
+}
+
+void LayerFlushScheduler::schedule()
+{
+ if (m_suspendCount)
+ return;
+
+ CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
+
+ // Make sure we wake up the loop or the observer could be delayed until some other source fires.
+ CFRunLoopWakeUp(currentRunLoop);
+
+ if (m_runLoopObserver)
+ return;
+
+ CFRunLoopObserverContext context = { 0, this, 0, 0, 0 };
+ m_runLoopObserver.adoptCF(CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, LayerFlushRunLoopOrder, runLoopObserverCallback, &context));
+
+ CFRunLoopAddObserver(currentRunLoop, m_runLoopObserver.get(), kCFRunLoopCommonModes);
+}
+
+void LayerFlushScheduler::invalidate()
+{
+ if (m_runLoopObserver) {
+ CFRunLoopObserverInvalidate(m_runLoopObserver.get());
+ m_runLoopObserver = nullptr;
+ }
+}
+
+} // namespace WebCore
+
+#endif // USE(ACCELERATED_COMPOSITING)
Modified: trunk/Source/WebKit/mac/ChangeLog (100383 => 100384)
--- trunk/Source/WebKit/mac/ChangeLog 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebKit/mac/ChangeLog 2011-11-16 01:52:24 UTC (rev 100384)
@@ -1,3 +1,28 @@
+2011-11-15 Andy Estes <aes...@apple.com>
+
+ Consolidate the logic that creates run loop observers for flushing layer tree changes to CoreAnimation
+ https://bugs.webkit.org/show_bug.cgi?id=72106
+
+ Reviewed by Anders Carlsson.
+
+ Remove code that schedules layer flushes and use LayerFlushScheduler instead.
+
+ * WebView/WebView.mm:
+ (-[WebView _close]): Invalidate the run loop observer and destroy the
+ LayerFlushController.
+ (LayerFlushController::flushLayers): Perform the work that
+ layerSyncRunLoopObserverCallBack used to do.
+ (-[WebView _scheduleCompositingLayerSync]): If layerFlushController has
+ yet to be created, create it, then schedule a layer flush.
+ * WebView/WebViewData.h:
+ (LayerFlushController::create): Create a LayerFlushController that
+ implements the LayerFlushSchedulerClient interface and contains a
+ LayerFlushScheduler with itself as the client.
+ * WebView/WebViewData.mm:
+ (LayerFlushController::scheduleLayerFlush):
+ (LayerFlushController::invalidateObserver):
+ (LayerFlushController::LayerFlushController):
+
2011-11-15 Jochen Eisinger <joc...@chromium.org>
Rename ReferrerPolicy to clarify its meaning
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (100383 => 100384)
--- trunk/Source/WebKit/mac/WebView/WebView.mm 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm 2011-11-16 01:52:24 UTC (rev 100384)
@@ -394,9 +394,6 @@
+ (void)_preflightSpellChecker;
- (BOOL)_continuousCheckingAllowed;
- (NSResponder *)_responderForResponderOperations;
-#if USE(ACCELERATED_COMPOSITING)
-- (void)_clearLayerSyncLoopObserver;
-#endif
#if ENABLE(GLIB_SUPPORT)
- (void)_clearGlibLoopObserver;
#endif
@@ -1096,7 +1093,10 @@
}
#if USE(ACCELERATED_COMPOSITING)
- [self _clearLayerSyncLoopObserver];
+ if (_private->layerFlushController) {
+ _private->layerFlushController->invalidateObserver();
+ _private->layerFlushController = nullptr;
+ }
#endif
#if ENABLE(GLIB_SUPPORT)
@@ -5859,18 +5859,6 @@
#endif
}
-#if USE(ACCELERATED_COMPOSITING)
-- (void)_clearLayerSyncLoopObserver
-{
- if (!_private->layerSyncRunLoopObserver)
- return;
-
- CFRunLoopObserverInvalidate(_private->layerSyncRunLoopObserver);
- CFRelease(_private->layerSyncRunLoopObserver);
- _private->layerSyncRunLoopObserver = 0;
-}
-#endif
-
#if ENABLE(GLIB_SUPPORT)
- (void)_clearGlibLoopObserver
{
@@ -6076,12 +6064,10 @@
until the time is right (essentially when there are no more pending layouts).
*/
-
-static void layerSyncRunLoopObserverCallBack(CFRunLoopObserverRef, CFRunLoopActivity, void* info)
+void LayerFlushController::flushLayers()
{
- WebView *webView = reinterpret_cast<WebView*>(info);
- NSWindow *window = [webView window];
-
+ NSWindow *window = [m_webView window];
+
// An NSWindow may not display in the next runloop cycle after dirtying due to delayed window display logic,
// in which case this observer can fire first. So if the window is due for a display, don't commit
// layer changes, otherwise they'll show on screen before the view drawing.
@@ -6096,8 +6082,8 @@
if (viewsNeedDisplay)
return;
- if ([webView _syncCompositingChanges]) {
- [webView _clearLayerSyncLoopObserver];
+ if ([m_webView _syncCompositingChanges]) {
+ m_layerFlushScheduler.invalidate();
// AppKit may have disabled screen updates, thinking an upcoming window flush will re-enable them.
// In case setNeedsDisplayInRect() has prevented the window from needing to be flushed, re-enable screen
// updates here.
@@ -6106,34 +6092,15 @@
} else {
// Since the WebView does not need display, -viewWillDraw will not be called. Perform pending layout now,
// so that the layers draw with up-to-date layout.
- [webView _viewWillDrawInternal];
+ [m_webView _viewWillDrawInternal];
}
}
- (void)_scheduleCompositingLayerSync
{
- CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
-
- // Make sure we wake up the loop or the observer could be delayed until some other source fires.
- CFRunLoopWakeUp(currentRunLoop);
-
- if (_private->layerSyncRunLoopObserver)
- return;
-
- // Run after AppKit does its window update. If we do any painting, we'll commit
- // layer changes from FrameView::paintContents(), otherwise we'll commit via
- // _syncCompositingChanges when this observer fires.
- // Also leave a slot for the requestAnimationFrameRunLoopObserver, if it's enabled
- const CFIndex runLoopOrder = NSDisplayWindowRunLoopOrdering + 2;
-
- // The WebView always outlives the observer, so no need to retain/release.
- CFRunLoopObserverContext context = { 0, self, 0, 0, 0 };
-
- _private->layerSyncRunLoopObserver = CFRunLoopObserverCreate(NULL,
- kCFRunLoopBeforeWaiting | kCFRunLoopExit, true /* repeats */,
- runLoopOrder, layerSyncRunLoopObserverCallBack, &context);
-
- CFRunLoopAddObserver(currentRunLoop, _private->layerSyncRunLoopObserver, kCFRunLoopCommonModes);
+ if (!_private->layerFlushController)
+ _private->layerFlushController = LayerFlushController::create(self);
+ _private->layerFlushController->scheduleLayerFlush();
}
#endif
Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (100383 => 100384)
--- trunk/Source/WebKit/mac/WebView/WebViewData.h 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.h 2011-11-16 01:52:24 UTC (rev 100384)
@@ -29,9 +29,12 @@
#import "WebTypesInternal.h"
#import "WebDelegateImplementationCaching.h"
+#import <WebCore/LayerFlushScheduler.h>
+#import <WebCore/LayerFlushSchedulerClient.h>
#import <WebCore/PlatformString.h>
#import <WebCore/WebCoreKeyboardUIMode.h>
#import <wtf/HashMap.h>
+#import <wtf/PassOwnPtr.h>
#import <wtf/RetainPtr.h>
namespace WebCore {
@@ -57,6 +60,27 @@
extern BOOL applicationIsTerminating;
extern int pluginDatabaseClientCount;
+#if USE(ACCELERATED_COMPOSITING)
+class LayerFlushController : public WebCore::LayerFlushSchedulerClient {
+public:
+ static PassOwnPtr<LayerFlushController> create(WebView* webView)
+ {
+ return adoptPtr(new LayerFlushController(webView));
+ }
+
+ virtual void flushLayers();
+
+ void scheduleLayerFlush();
+ void invalidateObserver();
+
+private:
+ LayerFlushController(WebView*);
+
+ WebView* m_webView;
+ WebCore::LayerFlushScheduler m_layerFlushScheduler;
+};
+#endif
+
// FIXME: This should be renamed to WebViewData.
@interface WebViewPrivate : NSObject {
@public
@@ -148,8 +172,7 @@
// so that the NSView drawing is visually synchronized with CALayer updates.
BOOL needsOneShotDrawingSynchronization;
BOOL postsAcceleratedCompositingNotifications;
- // Run loop observer used to implement the compositing equivalent of -viewWillDraw
- CFRunLoopObserverRef layerSyncRunLoopObserver;
+ OwnPtr<LayerFlushController> layerFlushController;
#endif
NSPasteboard *insertionPasteboard;
Modified: trunk/Source/WebKit/mac/WebView/WebViewData.mm (100383 => 100384)
--- trunk/Source/WebKit/mac/WebView/WebViewData.mm 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.mm 2011-11-16 01:52:24 UTC (rev 100384)
@@ -40,6 +40,25 @@
BOOL applicationIsTerminating = NO;
int pluginDatabaseClientCount = 0;
+#if USE(ACCELERATED_COMPOSITING)
+void LayerFlushController::scheduleLayerFlush()
+{
+ m_layerFlushScheduler.schedule();
+}
+
+void LayerFlushController::invalidateObserver()
+{
+ m_layerFlushScheduler.invalidate();
+}
+
+LayerFlushController::LayerFlushController(WebView* webView)
+ : m_webView(webView)
+ , m_layerFlushScheduler(this)
+{
+ ASSERT_ARG(webView, webView);
+}
+#endif
+
@implementation WebViewPrivate
+ (void)initialize
Modified: trunk/Source/WebKit2/ChangeLog (100383 => 100384)
--- trunk/Source/WebKit2/ChangeLog 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebKit2/ChangeLog 2011-11-16 01:52:24 UTC (rev 100384)
@@ -1,3 +1,27 @@
+2011-11-15 Andy Estes <aes...@apple.com>
+
+ Consolidate the logic that creates run loop observers for flushing layer tree changes to CoreAnimation
+ https://bugs.webkit.org/show_bug.cgi?id=72106
+
+ Reviewed by Anders Carlsson.
+
+ Remove code that schedules layer flushes and use LayerFlushScheduler instead.
+
+ * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h: Replace
+ m_flushPendingLayerChangesRunLoopObserver with m_layerFlushScheduler
+ and implement the LayerFlushSchedulerClient interface.
+ * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm:
+ (WebKit::LayerTreeHostCAMac::LayerTreeHostCAMac): Instantiate
+ m_layerFlushScheduler with the LayerTreeHost as the client.
+ (WebKit::LayerTreeHostCAMac::~LayerTreeHostCAMac):
+ (WebKit::LayerTreeHostCAMac::scheduleLayerFlush): Call LayerFlushScheduler::schedule().
+ (WebKit::LayerTreeHostCAMac::setLayerFlushSchedulingEnabled): Call
+ LayerFlushScheduler::suspend() or LayerFlushScheduler::resume().
+ (WebKit::LayerTreeHostCAMac::invalidate): Call LayerFlushScheduler::invalidate().
+ (WebKit::LayerTreeHostCAMac::flushLayers): Do the work that
+ flushPendingLayerChangesRunLoopObserverCallback() used to do.
+ (WebKit::LayerTreeHostCAMac::didPerformScheduledLayerFlush): Call LayerFlushScheduler::invalidate().
+
2011-11-15 Sam Weinig <s...@webkit.org>
Add a connection client to the WKContext, to notify when new connections to the WebProcess are established
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h (100383 => 100384)
--- trunk/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h 2011-11-16 01:52:24 UTC (rev 100384)
@@ -27,15 +27,15 @@
#define LayerTreeHostCAMac_h
#include "LayerTreeHostCA.h"
+#include <WebCore/LayerFlushScheduler.h>
+#include <WebCore/LayerFlushSchedulerClient.h>
#include <wtf/RetainPtr.h>
-#define CoreAnimationRunLoopOrder 2000000
-
typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef;
namespace WebKit {
-class LayerTreeHostCAMac : public LayerTreeHostCA {
+class LayerTreeHostCAMac : public LayerTreeHostCA, public WebCore::LayerFlushSchedulerClient {
public:
static PassRefPtr<LayerTreeHostCAMac> create(WebPage*);
virtual ~LayerTreeHostCAMac();
@@ -55,11 +55,12 @@
// LayerTreeHostCA
virtual void platformInitialize(LayerTreeContext&);
virtual void didPerformScheduledLayerFlush();
+
+ // LayerFlushSchedulerClient
+ virtual void flushLayers();
- static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*);
-
RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient;
- RetainPtr<CFRunLoopObserverRef> m_flushPendingLayerChangesRunLoopObserver;
+ WebCore::LayerFlushScheduler m_layerFlushScheduler;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm (100383 => 100384)
--- trunk/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm 2011-11-16 01:51:17 UTC (rev 100383)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm 2011-11-16 01:52:24 UTC (rev 100384)
@@ -48,12 +48,12 @@
LayerTreeHostCAMac::LayerTreeHostCAMac(WebPage* webPage)
: LayerTreeHostCA(webPage)
+ , m_layerFlushScheduler(this)
{
}
LayerTreeHostCAMac::~LayerTreeHostCAMac()
{
- ASSERT(!m_flushPendingLayerChangesRunLoopObserver);
ASSERT(!m_remoteLayerClient);
}
@@ -69,50 +69,20 @@
void LayerTreeHostCAMac::scheduleLayerFlush()
{
- if (!m_layerFlushSchedulingEnabled)
- return;
-
- CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
-
- // Make sure we wake up the loop or the observer could be delayed until some other source fires.
- CFRunLoopWakeUp(currentRunLoop);
-
- if (m_flushPendingLayerChangesRunLoopObserver)
- return;
-
- // Run before the Core Animation commit observer.
- const CFIndex runLoopOrder = CoreAnimationRunLoopOrder - 1;
- CFRunLoopObserverContext context = { 0, this, 0, 0, 0 };
- m_flushPendingLayerChangesRunLoopObserver.adoptCF(CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, runLoopOrder, flushPendingLayerChangesRunLoopObserverCallback, &context));
-
- CFRunLoopAddObserver(currentRunLoop, m_flushPendingLayerChangesRunLoopObserver.get(), kCFRunLoopCommonModes);
+ m_layerFlushScheduler.schedule();
}
void LayerTreeHostCAMac::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
{
- if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)
- return;
-
- m_layerFlushSchedulingEnabled = layerFlushingEnabled;
-
- if (m_layerFlushSchedulingEnabled) {
- scheduleLayerFlush();
- return;
- }
-
- if (!m_flushPendingLayerChangesRunLoopObserver)
- return;
-
- CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
- m_flushPendingLayerChangesRunLoopObserver = nullptr;
+ if (layerFlushingEnabled)
+ m_layerFlushScheduler.resume();
+ else
+ m_layerFlushScheduler.suspend();
}
void LayerTreeHostCAMac::invalidate()
{
- if (m_flushPendingLayerChangesRunLoopObserver) {
- CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
- m_flushPendingLayerChangesRunLoopObserver = nullptr;
- }
+ m_layerFlushScheduler.invalidate();
WKCARemoteLayerClientInvalidate(m_remoteLayerClient.get());
m_remoteLayerClient = nullptr;
@@ -148,24 +118,18 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidResumeNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:root forKey:@"layer"]];
}
-void LayerTreeHostCAMac::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context)
+void LayerTreeHostCAMac::flushLayers()
{
- LayerTreeHostCAMac* layerTreeHost = static_cast<LayerTreeHostCAMac*>(context);
-
- ASSERT(layerTreeHost->m_layerFlushSchedulingEnabled);
-
// This gets called outside of the normal event loop so wrap in an autorelease pool
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- layerTreeHost->performScheduledLayerFlush();
+ performScheduledLayerFlush();
[pool drain];
}
void LayerTreeHostCAMac::didPerformScheduledLayerFlush()
{
// We successfully flushed the pending layer changes, remove the run loop observer.
- ASSERT(m_flushPendingLayerChangesRunLoopObserver);
- CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
- m_flushPendingLayerChangesRunLoopObserver = 0;
+ m_layerFlushScheduler.invalidate();
LayerTreeHostCA::didPerformScheduledLayerFlush();
}