|
1 /* |
|
2 * Copyright (C) 2010 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. AND ITS CONTRIBUTORS ``AS IS'' |
|
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
|
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
|
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|
23 * THE POSSIBILITY OF SUCH DAMAGE. |
|
24 */ |
|
25 |
|
26 #include "LayerBackedDrawingAreaProxy.h" |
|
27 |
|
28 #include "DrawingAreaMessageKinds.h" |
|
29 #include "DrawingAreaProxyMessageKinds.h" |
|
30 #include <QuartzCore/QuartzCore.h> |
|
31 #include "WKAPICast.h" |
|
32 #include "WKView.h" |
|
33 #include "WKViewInternal.h" |
|
34 #include "WebKitSystemInterface.h" |
|
35 #include "WebPageProxy.h" |
|
36 |
|
37 using namespace WebCore; |
|
38 |
|
39 namespace WebKit { |
|
40 |
|
41 WebPageProxy* LayerBackedDrawingAreaProxy::page() |
|
42 { |
|
43 return toWK([m_webView pageRef]); |
|
44 } |
|
45 |
|
46 void LayerBackedDrawingAreaProxy::platformSetSize() |
|
47 { |
|
48 [m_compositingRootLayer.get() setBounds:CGRectMake(0, 0, m_viewSize.width(), m_viewSize.height())]; |
|
49 } |
|
50 |
|
51 void LayerBackedDrawingAreaProxy::attachCompositingContext(uint32_t contextID) |
|
52 { |
|
53 #if HAVE(HOSTED_CORE_ANIMATION) |
|
54 m_compositingRootLayer = WKMakeRenderLayer(contextID); |
|
55 |
|
56 // Turn off default animations. |
|
57 NSNull *nullValue = [NSNull null]; |
|
58 NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys: |
|
59 nullValue, @"anchorPoint", |
|
60 nullValue, @"bounds", |
|
61 nullValue, @"contents", |
|
62 nullValue, @"contentsRect", |
|
63 nullValue, @"opacity", |
|
64 nullValue, @"position", |
|
65 nullValue, @"sublayerTransform", |
|
66 nullValue, @"sublayers", |
|
67 nullValue, @"transform", |
|
68 nil]; |
|
69 [m_compositingRootLayer.get() setStyle:[NSDictionary dictionaryWithObject:actions forKey:@"actions"]]; |
|
70 |
|
71 [m_compositingRootLayer.get() setAnchorPoint:CGPointZero]; |
|
72 [m_compositingRootLayer.get() setBounds:CGRectMake(0, 0, m_viewSize.width(), m_viewSize.height())]; |
|
73 |
|
74 // FIXME: this fixes the layer jiggle when resizing the window, but breaks layer flipping because |
|
75 // CA doesn't propagate the kCALayerFlagFlippedAbove through the remote layer. |
|
76 // [m_compositingRootLayer.get() setGeometryFlipped:YES]; |
|
77 |
|
78 #ifndef NDEBUG |
|
79 [m_compositingRootLayer.get() setName:@"Compositing root layer"]; |
|
80 #endif |
|
81 |
|
82 [m_webView _startAcceleratedCompositing:m_compositingRootLayer.get()]; |
|
83 #endif |
|
84 } |
|
85 |
|
86 void LayerBackedDrawingAreaProxy::detachCompositingContext() |
|
87 { |
|
88 [m_webView _stopAcceleratedCompositing]; |
|
89 m_compositingRootLayer = 0; |
|
90 } |
|
91 |
|
92 } // namespace WebKit |