Merge "[Release] Webkit2-efl-123997_0.11.75" into tizen_2.2
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebPage / DrawingAreaImpl.h
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. 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 #ifndef DrawingAreaImpl_h
27 #define DrawingAreaImpl_h
28
29 #include "DrawingArea.h"
30 #include "LayerTreeHost.h"
31 #include <WebCore/Region.h>
32 #include <WebCore/RunLoop.h>
33
34 namespace WebCore {
35     class GraphicsContext;
36 }
37
38 namespace WebKit {
39
40 class ShareableBitmap;
41 class UpdateInfo;
42
43 class DrawingAreaImpl : public DrawingArea {
44 public:
45     static PassOwnPtr<DrawingAreaImpl> create(WebPage*, const WebPageCreationParameters&);
46     virtual ~DrawingAreaImpl();
47
48     void layerHostDidFlushLayers();
49
50 private:
51     DrawingAreaImpl(WebPage*, const WebPageCreationParameters&);
52
53     // DrawingArea
54     virtual void setNeedsDisplay(const WebCore::IntRect&);
55     virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
56     virtual void setLayerTreeStateIsFrozen(bool);
57     virtual bool layerTreeStateIsFrozen() const { return m_layerTreeStateIsFrozen; }
58     virtual LayerTreeHost* layerTreeHost() const { return m_layerTreeHost.get(); }
59     virtual void forceRepaint();
60
61     virtual void didInstallPageOverlay();
62     virtual void didUninstallPageOverlay();
63     virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&);
64     virtual void setPageOverlayOpacity(float);
65     virtual bool pageOverlayShouldApplyFadeWhenPainting() const;
66
67     virtual void setPaintingEnabled(bool);
68
69     virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
70     virtual void scheduleCompositingLayerSync();
71
72 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
73     virtual void setNeedsOneShotDrawingSynchronization();
74 #endif
75
76 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
77     virtual void addOrUpdateScrollingLayer(WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer, const WebCore::IntSize& scrollSize);
78     virtual void removeScrollingLayer(WebCore::GraphicsLayer* scrollingLayer, WebCore::GraphicsLayer* contentsLayer);
79 #endif
80
81 #if PLATFORM(WIN)
82     virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&);
83 #endif
84
85 #if PLATFORM(MAC)
86     virtual void setLayerHostingMode(uint32_t) OVERRIDE;
87 #endif
88
89 #if USE(UI_SIDE_COMPOSITING)
90     virtual void didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
91 #endif
92
93 #if ENABLE(TIZEN_LAYER_FLUSH_THROTTLING)
94     void didStartProgress();
95     void didFinishProgress();
96 #endif
97
98     // CoreIPC message handlers.
99     virtual void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset);
100     virtual void didUpdate();
101     virtual void suspendPainting();
102     virtual void resumePainting();
103     
104     virtual void pageCustomRepresentationChanged();
105
106     void sendDidUpdateBackingStoreState();
107
108     void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
109     void exitAcceleratedCompositingModeSoon();
110     bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); }
111     void exitAcceleratedCompositingMode();
112
113     void scheduleDisplay();
114     void displayTimerFired();
115     void display();
116     void display(UpdateInfo&);
117     PassOwnPtr<WebCore::GraphicsContext> createGraphicsContext(ShareableBitmap*);
118
119     uint64_t m_backingStoreStateID;
120
121     WebCore::Region m_dirtyRegion;
122     WebCore::IntRect m_scrollRect;
123     WebCore::IntSize m_scrollOffset;
124
125     // Whether painting is enabled. If painting is disabled, any calls to setNeedsDisplay and scroll are ignored.
126     bool m_isPaintingEnabled;
127
128     // Whether we're currently processing an UpdateBackingStoreState message.
129     bool m_inUpdateBackingStoreState;
130
131     // When true, we should send an UpdateBackingStoreState message instead of any other messages
132     // we normally send to the UI process.
133     bool m_shouldSendDidUpdateBackingStoreState;
134
135     // Whether we're waiting for a DidUpdate message. Used for throttling paints so that the 
136     // web process won't paint more frequent than the UI process can handle.
137     bool m_isWaitingForDidUpdate;
138     
139     // True between sending the 'enter compositing' messages, and the 'exit compositing' message.
140     bool m_compositingAccordingToProxyMessages;
141
142     // When true, we maintain the layer tree in its current state by not leaving accelerated compositing mode
143     // and not scheduling layer flushes.
144     bool m_layerTreeStateIsFrozen;
145
146     // True when we were asked to exit accelerated compositing mode but couldn't because layer tree
147     // state was frozen.
148     bool m_wantsToExitAcceleratedCompositingMode;
149
150     // Whether painting is suspended. We'll still keep track of the dirty region but we 
151     // won't paint until painting has resumed again.
152     bool m_isPaintingSuspended;
153 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
154     int m_paintingSuspendCount;
155 #endif
156     bool m_alwaysUseCompositing;
157
158     WebCore::RunLoop::Timer<DrawingAreaImpl> m_displayTimer;
159     WebCore::RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer;
160
161     // The layer tree host that handles accelerated compositing.
162     RefPtr<LayerTreeHost> m_layerTreeHost;
163 };
164
165 } // namespace WebKit
166
167 #endif // DrawingAreaImpl_h