| Differences between
and this patch
- a/Source/WebCore/ChangeLog +32 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2011-11-14  Andy Estes  <aestes@apple.com>
2
3
        Consolidate the logic that creates run loop observers for flushing layer tree changes to CoreAnimation
4
        https://bugs.webkit.org/show_bug.cgi?id=72106
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Add a class that encapsulates the logic of scheduling, enabling and
9
        invalidating a run loop observer that fires before Core Animation's
10
        commit observer. Clients can subclass LayerFlushSchedulerClient and
11
        implement flushLayers(), which will be called by the observer.
12
13
        * WebCore.exp.in:
14
        * WebCore.xcodeproj/project.pbxproj:
15
        * platform/graphics/ca/LayerFlushScheduler.cpp: Added.
16
        (WebCore::LayerFlushScheduler::suspend): Suspend scheduling by
17
        invalidating the run loop observer. Keep a count of calls to suspend()
18
        in m_suspendCount.
19
        (WebCore::LayerFlushScheduler::resume): Decrement m_suspendCount.
20
        Install the run loop observer when it reaches 0.
21
        * platform/graphics/ca/LayerFlushSchedulerClient.h: Added.
22
        (WebCore::LayerFlushSchedulerClient::~LayerFlushSchedulerClient):
23
        * platform/graphics/ca/LayerFlushScheduler.h: Added.
24
        * platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp: Added.
25
        (LayerFlushScheduler::LayerFlushScheduler):
26
        (LayerFlushScheduler::~LayerFlushScheduler):
27
        (LayerFlushScheduler::runLoopObserverCallback): Call flushLayers() on
28
        the LayerFlushSchedulerClient.
29
        (LayerFlushScheduler::schedule): Install the run loop observer.
30
        (LayerFlushScheduler::invalidate): Remove the run loop
31
        observer if it is installed.
32
1
2011-11-10  Andy Estes  <aestes@apple.com>
33
2011-11-10  Andy Estes  <aestes@apple.com>
2
34
3
        WebKitCSSShaderValue.h is not a member of the WebCore target
35
        WebKitCSSShaderValue.h is not a member of the WebCore target
- a/Source/WebKit/mac/ChangeLog +25 lines
Lines 1-3 a/Source/WebKit/mac/ChangeLog_sec1
1
2011-11-11  Andy Estes  <aestes@apple.com>
2
3
        Consolidate the logic that creates run loop observers for flushing layer tree changes to CoreAnimation
4
        https://bugs.webkit.org/show_bug.cgi?id=72106
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Remove code that schedules layer flushes and use LayerFlushScheduler instead.
9
10
        * WebView/WebView.mm:
11
        (-[WebView _close]): Invalidate the run loop observer and destroy the
12
        LayerFlushController.
13
        (LayerFlushController::flushLayers): Perform the work that
14
        layerSyncRunLoopObserverCallBack used to do.
15
        (-[WebView _scheduleCompositingLayerSync]): If layerFlushController has
16
        yet to be created, create it, then schedule a layer flush.
17
        * WebView/WebViewData.h:
18
        (LayerFlushController::create): Create a LayerFlushController that
19
        implements the LayerFlushSchedulerClient interface and contains a
20
        LayerFlushScheduler with itself as the client.
21
        * WebView/WebViewData.mm:
22
        (LayerFlushController::scheduleLayerFlush):
23
        (LayerFlushController::invalidateObserver):
24
        (LayerFlushController::LayerFlushController):
25
1
2011-11-07  Adam Barth  <abarth@webkit.org>
26
2011-11-07  Adam Barth  <abarth@webkit.org>
2
27
3
        Move static "policy" state from SecurityOrigin.cpp to SecurityPolicy.cpp
28
        Move static "policy" state from SecurityOrigin.cpp to SecurityPolicy.cpp
- a/Source/WebKit2/ChangeLog +24 lines
Lines 1-3 a/Source/WebKit2/ChangeLog_sec1
1
2011-11-14  Andy Estes  <aestes@apple.com>
2
3
        Consolidate the logic that creates run loop observers for flushing layer tree changes to CoreAnimation
4
        https://bugs.webkit.org/show_bug.cgi?id=72106
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Remove code that schedules layer flushes and use LayerFlushScheduler instead.
9
10
        * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h: Replace
11
        m_flushPendingLayerChangesRunLoopObserver with m_layerFlushScheduler
12
        and implement the LayerFlushSchedulerClient interface.
13
        * WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm:
14
        (WebKit::LayerTreeHostCAMac::LayerTreeHostCAMac): Instantiate
15
        m_layerFlushScheduler with the LayerTreeHost as the client.
16
        (WebKit::LayerTreeHostCAMac::~LayerTreeHostCAMac):
17
        (WebKit::LayerTreeHostCAMac::scheduleLayerFlush): Call LayerFlushScheduler::schedule().
18
        (WebKit::LayerTreeHostCAMac::setLayerFlushSchedulingEnabled): Call
19
        LayerFlushScheduler::suspend() or LayerFlushScheduler::resume().
20
        (WebKit::LayerTreeHostCAMac::invalidate): Call LayerFlushScheduler::invalidate().
21
        (WebKit::LayerTreeHostCAMac::flushLayers): Do the work that
22
        flushPendingLayerChangesRunLoopObserverCallback() used to do.
23
        (WebKit::LayerTreeHostCAMac::didPerformScheduledLayerFlush): Call LayerFlushScheduler::invalidate().
24
1
2011-11-10  Beth Dakin  <bdakin@apple.com>
25
2011-11-10  Beth Dakin  <bdakin@apple.com>
2
26
3
        Once more for the QT build.
27
        Once more for the QT build.
- a/Source/WebCore/WebCore.exp.in +6 lines
Lines 566-571 __ZN7WebCore19BackForwardListImpl8capacityEv a/Source/WebCore/WebCore.exp.in_sec1
566
__ZN7WebCore19BackForwardListImpl9goForwardEv
566
__ZN7WebCore19BackForwardListImpl9goForwardEv
567
__ZN7WebCore19BackForwardListImplC1EPNS_4PageE
567
__ZN7WebCore19BackForwardListImplC1EPNS_4PageE
568
__ZN7WebCore19CSSStyleDeclaration11setPropertyERKN3WTF6StringES4_Ri
568
__ZN7WebCore19CSSStyleDeclaration11setPropertyERKN3WTF6StringES4_Ri
569
__ZN7WebCore19LayerFlushScheduler10invalidateEv
570
__ZN7WebCore19LayerFlushScheduler6resumeEv
571
__ZN7WebCore19LayerFlushScheduler7suspendEv
572
__ZN7WebCore19LayerFlushScheduler8scheduleEv
573
__ZN7WebCore19LayerFlushSchedulerC1EPNS_25LayerFlushSchedulerClientE
574
__ZN7WebCore19LayerFlushSchedulerD1Ev
569
__ZN7WebCore19ResourceRequestBase11setHTTPBodyEN3WTF10PassRefPtrINS_8FormDataEEE
575
__ZN7WebCore19ResourceRequestBase11setHTTPBodyEN3WTF10PassRefPtrINS_8FormDataEEE
570
__ZN7WebCore19ResourceRequestBase13setHTTPMethodERKN3WTF6StringE
576
__ZN7WebCore19ResourceRequestBase13setHTTPMethodERKN3WTF6StringE
571
__ZN7WebCore19ResourceRequestBase18setHTTPHeaderFieldEPKcRKN3WTF6StringE
577
__ZN7WebCore19ResourceRequestBase18setHTTPHeaderFieldEPKcRKN3WTF6StringE
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +16 lines
Lines 689-696 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
689
		29ACB212143E7128006BCA5F /* AccessibilityMockObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 29ACB211143E7128006BCA5F /* AccessibilityMockObject.h */; };
689
		29ACB212143E7128006BCA5F /* AccessibilityMockObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 29ACB211143E7128006BCA5F /* AccessibilityMockObject.h */; };
690
		29ACB214143E7498006BCA5F /* AccessibilityMockObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29ACB213143E7498006BCA5F /* AccessibilityMockObject.cpp */; };
690
		29ACB214143E7498006BCA5F /* AccessibilityMockObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29ACB213143E7498006BCA5F /* AccessibilityMockObject.cpp */; };
691
		29CD61DE146D02890068E82A /* WebKitCSSShaderValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 50B42157146976960087E604 /* WebKitCSSShaderValue.h */; };
691
		29CD61DE146D02890068E82A /* WebKitCSSShaderValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 50B42157146976960087E604 /* WebKitCSSShaderValue.h */; };
692
		29CD61E8146D07360068E82A /* LayerFlushScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CD61E7146D07360068E82A /* LayerFlushScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
693
		29CD61EB146D074F0068E82A /* LayerFlushSchedulerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CD61EA146D074F0068E82A /* LayerFlushSchedulerMac.cpp */; };
692
		29D7BCF61444AF580070619C /* AccessibilitySpinButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29D7BCF51444AF580070619C /* AccessibilitySpinButton.cpp */; };
694
		29D7BCF61444AF580070619C /* AccessibilitySpinButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29D7BCF51444AF580070619C /* AccessibilitySpinButton.cpp */; };
693
		29D7BCFA1444AF7D0070619C /* AccessibilitySpinButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 29D7BCF91444AF7D0070619C /* AccessibilitySpinButton.h */; };
695
		29D7BCFA1444AF7D0070619C /* AccessibilitySpinButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 29D7BCF91444AF7D0070619C /* AccessibilitySpinButton.h */; };
696
		29EA95C7147240D2000DA41A /* LayerFlushScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29EA95C6147240D2000DA41A /* LayerFlushScheduler.cpp */; };
697
		29EA95C9147240FB000DA41A /* LayerFlushSchedulerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 29EA95C8147240FB000DA41A /* LayerFlushSchedulerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
694
		2BE8E2C712A589EC00FAD550 /* HTMLMetaCharsetParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */; };
698
		2BE8E2C712A589EC00FAD550 /* HTMLMetaCharsetParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */; };
695
		2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */; };
699
		2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */; };
696
		2D3A0E3613A7D76100E85AF0 /* SVGParsingError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */; settings = {ATTRIBUTES = (Private, ); }; };
700
		2D3A0E3613A7D76100E85AF0 /* SVGParsingError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 7783-7790 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
7783
		29A812470FBB9CA900510293 /* AXObjectCacheMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AXObjectCacheMac.mm; sourceTree = "<group>"; };
7787
		29A812470FBB9CA900510293 /* AXObjectCacheMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AXObjectCacheMac.mm; sourceTree = "<group>"; };
7784
		29ACB211143E7128006BCA5F /* AccessibilityMockObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityMockObject.h; sourceTree = "<group>"; };
7788
		29ACB211143E7128006BCA5F /* AccessibilityMockObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityMockObject.h; sourceTree = "<group>"; };
7785
		29ACB213143E7498006BCA5F /* AccessibilityMockObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityMockObject.cpp; sourceTree = "<group>"; };
7789
		29ACB213143E7498006BCA5F /* AccessibilityMockObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityMockObject.cpp; sourceTree = "<group>"; };
7790
		29CD61E7146D07360068E82A /* LayerFlushScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LayerFlushScheduler.h; path = ca/LayerFlushScheduler.h; sourceTree = "<group>"; };
7791
		29CD61EA146D074F0068E82A /* LayerFlushSchedulerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LayerFlushSchedulerMac.cpp; path = ca/mac/LayerFlushSchedulerMac.cpp; sourceTree = "<group>"; };
7786
		29D7BCF51444AF580070619C /* AccessibilitySpinButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AccessibilitySpinButton.cpp; path = accessibility/AccessibilitySpinButton.cpp; sourceTree = SOURCE_ROOT; };
7792
		29D7BCF51444AF580070619C /* AccessibilitySpinButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AccessibilitySpinButton.cpp; path = accessibility/AccessibilitySpinButton.cpp; sourceTree = SOURCE_ROOT; };
7787
		29D7BCF91444AF7D0070619C /* AccessibilitySpinButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySpinButton.h; sourceTree = "<group>"; };
7793
		29D7BCF91444AF7D0070619C /* AccessibilitySpinButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySpinButton.h; sourceTree = "<group>"; };
7794
		29EA95C6147240D2000DA41A /* LayerFlushScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LayerFlushScheduler.cpp; path = ca/LayerFlushScheduler.cpp; sourceTree = "<group>"; };
7795
		29EA95C8147240FB000DA41A /* LayerFlushSchedulerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LayerFlushSchedulerClient.h; path = ca/LayerFlushSchedulerClient.h; sourceTree = "<group>"; };
7788
		2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLMetaCharsetParser.h; path = parser/HTMLMetaCharsetParser.h; sourceTree = "<group>"; };
7796
		2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLMetaCharsetParser.h; path = parser/HTMLMetaCharsetParser.h; sourceTree = "<group>"; };
7789
		2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLMetaCharsetParser.cpp; path = parser/HTMLMetaCharsetParser.cpp; sourceTree = "<group>"; };
7797
		2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLMetaCharsetParser.cpp; path = parser/HTMLMetaCharsetParser.cpp; sourceTree = "<group>"; };
7790
		2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGParsingError.h; sourceTree = "<group>"; };
7798
		2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGParsingError.h; sourceTree = "<group>"; };
Lines 14942-14947 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
14942
		4958781E12A57DBC007238AC /* mac */ = {
14950
		4958781E12A57DBC007238AC /* mac */ = {
14943
			isa = PBXGroup;
14951
			isa = PBXGroup;
14944
			children = (
14952
			children = (
14953
				29CD61EA146D074F0068E82A /* LayerFlushSchedulerMac.cpp */,
14945
				4958781F12A57DDF007238AC /* PlatformCAAnimationMac.mm */,
14954
				4958781F12A57DDF007238AC /* PlatformCAAnimationMac.mm */,
14946
				4958782012A57DDF007238AC /* PlatformCALayerMac.mm */,
14955
				4958782012A57DDF007238AC /* PlatformCALayerMac.mm */,
14947
			);
14956
			);
Lines 14978-14983 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
14978
				4958781E12A57DBC007238AC /* mac */,
14987
				4958781E12A57DBC007238AC /* mac */,
14979
				499B3ED4128CD31400E726C2 /* GraphicsLayerCA.cpp */,
14988
				499B3ED4128CD31400E726C2 /* GraphicsLayerCA.cpp */,
14980
				499B3ED5128CD31400E726C2 /* GraphicsLayerCA.h */,
14989
				499B3ED5128CD31400E726C2 /* GraphicsLayerCA.h */,
14990
				29EA95C6147240D2000DA41A /* LayerFlushScheduler.cpp */,
14991
				29CD61E7146D07360068E82A /* LayerFlushScheduler.h */,
14992
				29EA95C8147240FB000DA41A /* LayerFlushSchedulerClient.h */,
14981
				499B3EDC128DB50100E726C2 /* PlatformCAAnimation.h */,
14993
				499B3EDC128DB50100E726C2 /* PlatformCAAnimation.h */,
14982
				499B3EC3128CCC4700E726C2 /* PlatformCALayer.h */,
14994
				499B3EC3128CCC4700E726C2 /* PlatformCALayer.h */,
14983
				493E5E0812D6420500020081 /* PlatformCALayerClient.h */,
14995
				493E5E0812D6420500020081 /* PlatformCALayerClient.h */,
Lines 24654-24659 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
24654
				71537A01146BD9D7008BD615 /* SVGPathData.h in Headers */,
24666
				71537A01146BD9D7008BD615 /* SVGPathData.h in Headers */,
24655
				31313F661443B35F006E2A90 /* FilterEffectRenderer.h in Headers */,
24667
				31313F661443B35F006E2A90 /* FilterEffectRenderer.h in Headers */,
24656
				29CD61DE146D02890068E82A /* WebKitCSSShaderValue.h in Headers */,
24668
				29CD61DE146D02890068E82A /* WebKitCSSShaderValue.h in Headers */,
24669
				29CD61E8146D07360068E82A /* LayerFlushScheduler.h in Headers */,
24670
				29EA95C9147240FB000DA41A /* LayerFlushSchedulerClient.h in Headers */,
24657
			);
24671
			);
24658
			runOnlyForDeploymentPostprocessing = 0;
24672
			runOnlyForDeploymentPostprocessing = 0;
24659
		};
24673
		};
Lines 27515-27520 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec6
27515
				7134496D146941B300720312 /* SVGLengthContext.cpp in Sources */,
27529
				7134496D146941B300720312 /* SVGLengthContext.cpp in Sources */,
27516
				974D2DA4146A535D00D51F8B /* SecurityPolicy.cpp in Sources */,
27530
				974D2DA4146A535D00D51F8B /* SecurityPolicy.cpp in Sources */,
27517
				31313F651443B35F006E2A90 /* FilterEffectRenderer.cpp in Sources */,
27531
				31313F651443B35F006E2A90 /* FilterEffectRenderer.cpp in Sources */,
27532
				29CD61EB146D074F0068E82A /* LayerFlushSchedulerMac.cpp in Sources */,
27533
				29EA95C7147240D2000DA41A /* LayerFlushScheduler.cpp in Sources */,
27518
			);
27534
			);
27519
			runOnlyForDeploymentPostprocessing = 0;
27535
			runOnlyForDeploymentPostprocessing = 0;
27520
		};
27536
		};
- a/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.cpp +54 lines
Line 0 a/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
28
#if USE(ACCELERATED_COMPOSITING)
29
30
#include "LayerFlushScheduler.h"
31
32
namespace WebCore {
33
    
34
void LayerFlushScheduler::suspend()
35
{
36
    if (!m_suspendCount)
37
        invalidate();
38
    
39
    ++m_suspendCount;
40
    ASSERT(m_suspendCount);
41
}
42
    
43
void LayerFlushScheduler::resume()
44
{
45
    --m_suspendCount;
46
    ASSERT(m_suspendCount > -1);
47
    
48
    if (!m_suspendCount)
49
        schedule();
50
}
51
52
} // namespace WebCore
53
54
#endif // USE(ACCELERATED_COMPOSITING)
- a/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h +64 lines
Line 0 a/Source/WebCore/platform/graphics/ca/LayerFlushScheduler.h_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#ifndef LayerFlushScheduler_h
27
#define LayerFlushScheduler_h
28
29
#if USE(ACCELERATED_COMPOSITING)
30
31
#include "LayerFlushSchedulerClient.h"
32
#include <wtf/Noncopyable.h>
33
#include <wtf/PassOwnPtr.h>
34
#include <wtf/RetainPtr.h>
35
36
namespace WebCore {
37
    
38
class LayerFlushScheduler {
39
    WTF_MAKE_NONCOPYABLE(LayerFlushScheduler);
40
public:
41
    LayerFlushScheduler(LayerFlushSchedulerClient*);
42
    ~LayerFlushScheduler();
43
44
    void schedule();
45
    void invalidate();
46
47
    void suspend();
48
    void resume();
49
50
private:
51
    int m_suspendCount;
52
    LayerFlushSchedulerClient* m_client;
53
    
54
#if PLATFORM(MAC)
55
    RetainPtr<CFRunLoopObserverRef> m_runLoopObserver;
56
    static void runLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context);
57
#endif
58
};
59
60
} // namespace WebCore
61
62
#endif // USE(ACCELERATED_COMPOSITING)
63
64
#endif // LayerFlushScheduler_h
- a/Source/WebCore/platform/graphics/ca/LayerFlushSchedulerClient.h +43 lines
Line 0 a/Source/WebCore/platform/graphics/ca/LayerFlushSchedulerClient.h_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#ifndef LayerFlushSchedulerClient_h
27
#define LayerFlushSchedulerClient_h
28
29
#if USE(ACCELERATED_COMPOSITING)
30
31
namespace WebCore {
32
33
class LayerFlushSchedulerClient {
34
public:
35
    virtual ~LayerFlushSchedulerClient() { }
36
    virtual void flushLayers() = 0;
37
};
38
39
} // namespace WebCore
40
41
#endif // USE(ACCELERATED_COMPOSITING)
42
43
#endif // LayerFlushSchedulerClient_h
- a/Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp +86 lines
Line 0 a/Source/WebCore/platform/graphics/ca/mac/LayerFlushSchedulerMac.cpp_sec1
1
/*
2
 * Copyright (C) 2011 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
28
#if USE(ACCELERATED_COMPOSITING)
29
30
#include "LayerFlushScheduler.h"
31
32
namespace WebCore {
33
34
static const CFIndex CoreAnimationRunLoopOrder = 2000000;
35
static const CFIndex LayerFlushRunLoopOrder = CoreAnimationRunLoopOrder - 1;
36
37
LayerFlushScheduler::LayerFlushScheduler(LayerFlushSchedulerClient* client)
38
    : m_suspendCount(0)
39
    , m_client(client)
40
{
41
    ASSERT_ARG(client, client);
42
}
43
44
LayerFlushScheduler::~LayerFlushScheduler()
45
{
46
    ASSERT(!m_runLoopObserver);
47
}
48
49
void LayerFlushScheduler::runLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context)
50
{
51
    LayerFlushScheduler* layerFlushScheduler = static_cast<LayerFlushScheduler*>(context);
52
    ASSERT(layerFlushScheduler->m_runLoopObserver);
53
    ASSERT(!layerFlushScheduler->m_suspendCount);
54
    layerFlushScheduler->m_client->flushLayers();
55
}
56
57
void LayerFlushScheduler::schedule()
58
{
59
    if (m_suspendCount)
60
        return;
61
62
    CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
63
64
    // Make sure we wake up the loop or the observer could be delayed until some other source fires.
65
    CFRunLoopWakeUp(currentRunLoop);
66
67
    if (m_runLoopObserver)
68
        return;
69
70
    CFRunLoopObserverContext context = { 0, this, 0, 0, 0 };
71
    m_runLoopObserver.adoptCF(CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, LayerFlushRunLoopOrder, runLoopObserverCallback, &context));
72
73
    CFRunLoopAddObserver(currentRunLoop, m_runLoopObserver.get(), kCFRunLoopCommonModes);
74
}
75
76
void LayerFlushScheduler::invalidate()
77
{
78
    if (m_runLoopObserver) {
79
        CFRunLoopObserverInvalidate(m_runLoopObserver.get());
80
        m_runLoopObserver = nullptr;   
81
    }
82
}
83
    
84
} // namespace WebCore
85
86
#endif // USE(ACCELERATED_COMPOSITING)
- a/Source/WebKit/mac/WebView/WebView.mm -46 / +13 lines
Lines 394-402 FindOptions coreOptions(WebFindOptions options) a/Source/WebKit/mac/WebView/WebView.mm_sec1
394
+ (void)_preflightSpellChecker;
394
+ (void)_preflightSpellChecker;
395
- (BOOL)_continuousCheckingAllowed;
395
- (BOOL)_continuousCheckingAllowed;
396
- (NSResponder *)_responderForResponderOperations;
396
- (NSResponder *)_responderForResponderOperations;
397
#if USE(ACCELERATED_COMPOSITING)
398
- (void)_clearLayerSyncLoopObserver;
399
#endif
400
#if ENABLE(GLIB_SUPPORT)
397
#if ENABLE(GLIB_SUPPORT)
401
- (void)_clearGlibLoopObserver;
398
- (void)_clearGlibLoopObserver;
402
#endif
399
#endif
Lines 1096-1102 static bool fastDocumentTeardownEnabled() a/Source/WebKit/mac/WebView/WebView.mm_sec2
1096
    }
1093
    }
1097
1094
1098
#if USE(ACCELERATED_COMPOSITING)
1095
#if USE(ACCELERATED_COMPOSITING)
1099
    [self _clearLayerSyncLoopObserver];
1096
    if (_private->layerFlushController) {
1097
        _private->layerFlushController->invalidateObserver();
1098
        _private->layerFlushController = nullptr;
1099
    }
1100
#endif
1100
#endif
1101
    
1101
    
1102
#if ENABLE(GLIB_SUPPORT)
1102
#if ENABLE(GLIB_SUPPORT)
Lines 5859-5876 static inline uint64_t roundUpToPowerOf2(uint64_t num) a/Source/WebKit/mac/WebView/WebView.mm_sec3
5859
#endif
5859
#endif
5860
}
5860
}
5861
5861
5862
#if USE(ACCELERATED_COMPOSITING)
5863
- (void)_clearLayerSyncLoopObserver
5864
{
5865
    if (!_private->layerSyncRunLoopObserver)
5866
        return;
5867
5868
    CFRunLoopObserverInvalidate(_private->layerSyncRunLoopObserver);
5869
    CFRelease(_private->layerSyncRunLoopObserver);
5870
    _private->layerSyncRunLoopObserver = 0;
5871
}
5872
#endif
5873
5874
#if ENABLE(GLIB_SUPPORT)
5862
#if ENABLE(GLIB_SUPPORT)
5875
- (void)_clearGlibLoopObserver
5863
- (void)_clearGlibLoopObserver
5876
{
5864
{
Lines 6076-6087 static inline uint64_t roundUpToPowerOf2(uint64_t num) a/Source/WebKit/mac/WebView/WebView.mm_sec4
6076
       until the time is right (essentially when there are no more pending layouts).
6064
       until the time is right (essentially when there are no more pending layouts).
6077
    
6065
    
6078
*/
6066
*/
6079
6067
void LayerFlushController::flushLayers()
6080
static void layerSyncRunLoopObserverCallBack(CFRunLoopObserverRef, CFRunLoopActivity, void* info)
6081
{
6068
{
6082
    WebView *webView = reinterpret_cast<WebView*>(info);
6069
    NSWindow *window = [m_webView window];
6083
    NSWindow *window = [webView window];
6070
    
6084
6085
    // An NSWindow may not display in the next runloop cycle after dirtying due to delayed window display logic,
6071
    // An NSWindow may not display in the next runloop cycle after dirtying due to delayed window display logic,
6086
    // in which case this observer can fire first. So if the window is due for a display, don't commit
6072
    // in which case this observer can fire first. So if the window is due for a display, don't commit
6087
    // layer changes, otherwise they'll show on screen before the view drawing.
6073
    // layer changes, otherwise they'll show on screen before the view drawing.
Lines 6096-6103 static void layerSyncRunLoopObserverCallBack(CFRunLoopObserverRef, CFRunLoopActi a/Source/WebKit/mac/WebView/WebView.mm_sec5
6096
    if (viewsNeedDisplay)
6082
    if (viewsNeedDisplay)
6097
        return;
6083
        return;
6098
6084
6099
    if ([webView _syncCompositingChanges]) {
6085
    if ([m_webView _syncCompositingChanges]) {
6100
        [webView _clearLayerSyncLoopObserver];
6086
        m_layerFlushScheduler.invalidate();
6101
        // AppKit may have disabled screen updates, thinking an upcoming window flush will re-enable them.
6087
        // AppKit may have disabled screen updates, thinking an upcoming window flush will re-enable them.
6102
        // In case setNeedsDisplayInRect() has prevented the window from needing to be flushed, re-enable screen
6088
        // In case setNeedsDisplayInRect() has prevented the window from needing to be flushed, re-enable screen
6103
        // updates here.
6089
        // updates here.
Lines 6106-6139 static void layerSyncRunLoopObserverCallBack(CFRunLoopObserverRef, CFRunLoopActi a/Source/WebKit/mac/WebView/WebView.mm_sec6
6106
    } else {
6092
    } else {
6107
        // Since the WebView does not need display, -viewWillDraw will not be called. Perform pending layout now,
6093
        // Since the WebView does not need display, -viewWillDraw will not be called. Perform pending layout now,
6108
        // so that the layers draw with up-to-date layout. 
6094
        // so that the layers draw with up-to-date layout. 
6109
        [webView _viewWillDrawInternal];
6095
        [m_webView _viewWillDrawInternal];
6110
    }
6096
    }
6111
}
6097
}
6112
6098
6113
- (void)_scheduleCompositingLayerSync
6099
- (void)_scheduleCompositingLayerSync
6114
{
6100
{
6115
    CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
6101
    if (!_private->layerFlushController)
6116
6102
        _private->layerFlushController = LayerFlushController::create(self);
6117
    // Make sure we wake up the loop or the observer could be delayed until some other source fires.
6103
    _private->layerFlushController->scheduleLayerFlush();
6118
    CFRunLoopWakeUp(currentRunLoop);
6119
6120
    if (_private->layerSyncRunLoopObserver)
6121
        return;
6122
6123
    // Run after AppKit does its window update. If we do any painting, we'll commit
6124
    // layer changes from FrameView::paintContents(), otherwise we'll commit via
6125
    // _syncCompositingChanges when this observer fires.
6126
    // Also leave a slot for the requestAnimationFrameRunLoopObserver, if it's enabled
6127
    const CFIndex runLoopOrder = NSDisplayWindowRunLoopOrdering + 2;
6128
6129
    // The WebView always outlives the observer, so no need to retain/release.
6130
    CFRunLoopObserverContext context = { 0, self, 0, 0, 0 };
6131
6132
    _private->layerSyncRunLoopObserver = CFRunLoopObserverCreate(NULL,
6133
        kCFRunLoopBeforeWaiting | kCFRunLoopExit, true /* repeats */,
6134
        runLoopOrder, layerSyncRunLoopObserverCallBack, &context);
6135
6136
    CFRunLoopAddObserver(currentRunLoop, _private->layerSyncRunLoopObserver, kCFRunLoopCommonModes);
6137
}
6104
}
6138
6105
6139
#endif
6106
#endif
- a/Source/WebKit/mac/WebView/WebViewData.h -2 / +24 lines
Lines 29-34 a/Source/WebKit/mac/WebView/WebViewData.h_sec1
29
29
30
#import "WebTypesInternal.h"
30
#import "WebTypesInternal.h"
31
#import "WebDelegateImplementationCaching.h"
31
#import "WebDelegateImplementationCaching.h"
32
#import <WebCore/LayerFlushScheduler.h>
33
#import <WebCore/LayerFlushSchedulerClient.h>
32
#import <WebCore/PlatformString.h>
34
#import <WebCore/PlatformString.h>
33
#import <WebCore/WebCoreKeyboardUIMode.h>
35
#import <WebCore/WebCoreKeyboardUIMode.h>
34
#import <wtf/HashMap.h>
36
#import <wtf/HashMap.h>
Lines 57-62 namespace WebCore { a/Source/WebKit/mac/WebView/WebViewData.h_sec2
57
extern BOOL applicationIsTerminating;
59
extern BOOL applicationIsTerminating;
58
extern int pluginDatabaseClientCount;
60
extern int pluginDatabaseClientCount;
59
61
62
#if USE(ACCELERATED_COMPOSITING)
63
class LayerFlushController : public WebCore::LayerFlushSchedulerClient {
64
public:
65
    static PassOwnPtr<LayerFlushController> create(WebView* webView)
66
    {
67
        return adoptPtr(new LayerFlushController(webView));
68
    }
69
    
70
    virtual void flushLayers();
71
    
72
    void scheduleLayerFlush();
73
    void invalidateObserver();
74
    
75
private:
76
    LayerFlushController(WebView*);
77
    
78
    WebView* m_webView;
79
    WebCore::LayerFlushScheduler m_layerFlushScheduler;
80
};
81
#endif
82
60
// FIXME: This should be renamed to WebViewData.
83
// FIXME: This should be renamed to WebViewData.
61
@interface WebViewPrivate : NSObject {
84
@interface WebViewPrivate : NSObject {
62
@public
85
@public
Lines 148-155 extern int pluginDatabaseClientCount; a/Source/WebKit/mac/WebView/WebViewData.h_sec3
148
    // so that the NSView drawing is visually synchronized with CALayer updates.
171
    // so that the NSView drawing is visually synchronized with CALayer updates.
149
    BOOL needsOneShotDrawingSynchronization;
172
    BOOL needsOneShotDrawingSynchronization;
150
    BOOL postsAcceleratedCompositingNotifications;
173
    BOOL postsAcceleratedCompositingNotifications;
151
    // Run loop observer used to implement the compositing equivalent of -viewWillDraw
174
    OwnPtr<LayerFlushController> layerFlushController;
152
    CFRunLoopObserverRef layerSyncRunLoopObserver;
153
#endif
175
#endif
154
176
155
    NSPasteboard *insertionPasteboard;
177
    NSPasteboard *insertionPasteboard;
- a/Source/WebKit/mac/WebView/WebViewData.mm +19 lines
Lines 40-45 a/Source/WebKit/mac/WebView/WebViewData.mm_sec1
40
BOOL applicationIsTerminating = NO;
40
BOOL applicationIsTerminating = NO;
41
int pluginDatabaseClientCount = 0;
41
int pluginDatabaseClientCount = 0;
42
42
43
#if USE(ACCELERATED_COMPOSITING)
44
void LayerFlushController::scheduleLayerFlush()
45
{
46
    m_layerFlushScheduler.schedule();
47
}
48
49
void LayerFlushController::invalidateObserver()
50
{
51
    m_layerFlushScheduler.invalidate();
52
}
53
54
LayerFlushController::LayerFlushController(WebView* webView)
55
    : m_webView(webView)
56
    , m_layerFlushScheduler(this)
57
{
58
    ASSERT_ARG(webView, webView);
59
}
60
#endif
61
43
@implementation WebViewPrivate
62
@implementation WebViewPrivate
44
63
45
+ (void)initialize
64
+ (void)initialize
- a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h -6 / +7 lines
Lines 27-41 a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h_sec1
27
#define LayerTreeHostCAMac_h
27
#define LayerTreeHostCAMac_h
28
28
29
#include "LayerTreeHostCA.h"
29
#include "LayerTreeHostCA.h"
30
#include <WebCore/LayerFlushScheduler.h>
31
#include <WebCore/LayerFlushSchedulerClient.h>
30
#include <wtf/RetainPtr.h>
32
#include <wtf/RetainPtr.h>
31
33
32
#define CoreAnimationRunLoopOrder 2000000
33
34
typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef;
34
typedef struct __WKCARemoteLayerClientRef* WKCARemoteLayerClientRef;
35
35
36
namespace WebKit {
36
namespace WebKit {
37
37
38
class LayerTreeHostCAMac : public LayerTreeHostCA {
38
class LayerTreeHostCAMac : public LayerTreeHostCA, public WebCore::LayerFlushSchedulerClient {
39
public:
39
public:
40
    static PassRefPtr<LayerTreeHostCAMac> create(WebPage*);
40
    static PassRefPtr<LayerTreeHostCAMac> create(WebPage*);
41
    virtual ~LayerTreeHostCAMac();
41
    virtual ~LayerTreeHostCAMac();
Lines 55-65 private: a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.h_sec2
55
    // LayerTreeHostCA
55
    // LayerTreeHostCA
56
    virtual void platformInitialize(LayerTreeContext&);
56
    virtual void platformInitialize(LayerTreeContext&);
57
    virtual void didPerformScheduledLayerFlush();
57
    virtual void didPerformScheduledLayerFlush();
58
58
    
59
    static void flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*);
59
    // LayerFlushSchedulerClient
60
    virtual void flushLayers();
60
61
61
    RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient;
62
    RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerClient;
62
    RetainPtr<CFRunLoopObserverRef> m_flushPendingLayerChangesRunLoopObserver;
63
    WebCore::LayerFlushScheduler m_layerFlushScheduler;
63
};
64
};
64
65
65
} // namespace WebKit
66
} // namespace WebKit
- a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm -46 / +10 lines
Lines 48-59 PassRefPtr<LayerTreeHostCAMac> LayerTreeHostCAMac::create(WebPage* webPage) a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm_sec1
48
48
49
LayerTreeHostCAMac::LayerTreeHostCAMac(WebPage* webPage)
49
LayerTreeHostCAMac::LayerTreeHostCAMac(WebPage* webPage)
50
    : LayerTreeHostCA(webPage)
50
    : LayerTreeHostCA(webPage)
51
    , m_layerFlushScheduler(this)
51
{
52
{
52
}
53
}
53
54
54
LayerTreeHostCAMac::~LayerTreeHostCAMac()
55
LayerTreeHostCAMac::~LayerTreeHostCAMac()
55
{
56
{
56
    ASSERT(!m_flushPendingLayerChangesRunLoopObserver);
57
    ASSERT(!m_remoteLayerClient);
57
    ASSERT(!m_remoteLayerClient);
58
}
58
}
59
59
Lines 69-118 void LayerTreeHostCAMac::platformInitialize(LayerTreeContext& layerTreeContext) a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm_sec2
69
69
70
void LayerTreeHostCAMac::scheduleLayerFlush()
70
void LayerTreeHostCAMac::scheduleLayerFlush()
71
{
71
{
72
    if (!m_layerFlushSchedulingEnabled)
72
    m_layerFlushScheduler.schedule();
73
        return;
74
75
    CFRunLoopRef currentRunLoop = CFRunLoopGetCurrent();
76
    
77
    // Make sure we wake up the loop or the observer could be delayed until some other source fires.
78
    CFRunLoopWakeUp(currentRunLoop);
79
80
    if (m_flushPendingLayerChangesRunLoopObserver)
81
        return;
82
83
    // Run before the Core Animation commit observer.
84
    const CFIndex runLoopOrder = CoreAnimationRunLoopOrder - 1;
85
    CFRunLoopObserverContext context = { 0, this, 0, 0, 0 };
86
    m_flushPendingLayerChangesRunLoopObserver.adoptCF(CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting | kCFRunLoopExit, true, runLoopOrder, flushPendingLayerChangesRunLoopObserverCallback, &context));
87
88
    CFRunLoopAddObserver(currentRunLoop, m_flushPendingLayerChangesRunLoopObserver.get(), kCFRunLoopCommonModes);
89
}
73
}
90
74
91
void LayerTreeHostCAMac::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
75
void LayerTreeHostCAMac::setLayerFlushSchedulingEnabled(bool layerFlushingEnabled)
92
{
76
{
93
    if (m_layerFlushSchedulingEnabled == layerFlushingEnabled)
77
    if (layerFlushingEnabled)
94
        return;
78
        m_layerFlushScheduler.resume();
95
79
    else
96
    m_layerFlushSchedulingEnabled = layerFlushingEnabled;
80
        m_layerFlushScheduler.suspend();
97
98
    if (m_layerFlushSchedulingEnabled) {
99
        scheduleLayerFlush();
100
        return;
101
    }
102
103
    if (!m_flushPendingLayerChangesRunLoopObserver)
104
        return;
105
106
    CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
107
    m_flushPendingLayerChangesRunLoopObserver = nullptr;
108
}
81
}
109
82
110
void LayerTreeHostCAMac::invalidate()
83
void LayerTreeHostCAMac::invalidate()
111
{
84
{
112
    if (m_flushPendingLayerChangesRunLoopObserver) {
85
    m_layerFlushScheduler.invalidate();
113
        CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
114
        m_flushPendingLayerChangesRunLoopObserver = nullptr;
115
    }
116
86
117
    WKCARemoteLayerClientInvalidate(m_remoteLayerClient.get());
87
    WKCARemoteLayerClientInvalidate(m_remoteLayerClient.get());
118
    m_remoteLayerClient = nullptr;
88
    m_remoteLayerClient = nullptr;
Lines 148-171 void LayerTreeHostCAMac::resumeRendering() a/Source/WebKit2/WebProcess/WebPage/ca/mac/LayerTreeHostCAMac.mm_sec3
148
    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidResumeNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:root forKey:@"layer"]];
118
    [[NSNotificationCenter defaultCenter] postNotificationName:@"NSCAViewRenderDidResumeNotification" object:nil userInfo:[NSDictionary dictionaryWithObject:root forKey:@"layer"]];
149
}
119
}
150
120
151
void LayerTreeHostCAMac::flushPendingLayerChangesRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void* context)
121
void LayerTreeHostCAMac::flushLayers()
152
{
122
{
153
    LayerTreeHostCAMac* layerTreeHost = static_cast<LayerTreeHostCAMac*>(context);
154
155
    ASSERT(layerTreeHost->m_layerFlushSchedulingEnabled);
156
157
    // This gets called outside of the normal event loop so wrap in an autorelease pool
123
    // This gets called outside of the normal event loop so wrap in an autorelease pool
158
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
124
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
159
    layerTreeHost->performScheduledLayerFlush();
125
    performScheduledLayerFlush();
160
    [pool drain];
126
    [pool drain];
161
}
127
}
162
128
163
void LayerTreeHostCAMac::didPerformScheduledLayerFlush()
129
void LayerTreeHostCAMac::didPerformScheduledLayerFlush()
164
{
130
{
165
    // We successfully flushed the pending layer changes, remove the run loop observer.
131
    // We successfully flushed the pending layer changes, remove the run loop observer.
166
    ASSERT(m_flushPendingLayerChangesRunLoopObserver);
132
    m_layerFlushScheduler.invalidate();
167
    CFRunLoopObserverInvalidate(m_flushPendingLayerChangesRunLoopObserver.get());
168
    m_flushPendingLayerChangesRunLoopObserver = 0;
169
133
170
    LayerTreeHostCA::didPerformScheduledLayerFlush();
134
    LayerTreeHostCA::didPerformScheduledLayerFlush();
171
}
135
}

Return to Bug 72106