Merge "Use EwkView's variables instead of drawingScaleFactor and drawingScrollPositio...
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / DrawingAreaProxyImpl.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 DrawingAreaProxyImpl_h
27 #define DrawingAreaProxyImpl_h
28
29 #include "BackingStore.h"
30 #include "DrawingAreaProxy.h"
31 #include "LayerTreeContext.h"
32 #include <WebCore/RunLoop.h>
33 #include <wtf/OwnPtr.h>
34 #include <wtf/PassOwnPtr.h>
35
36 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
37 #include <Evas_GL.h>
38 #endif
39
40 namespace WebCore {
41 class Region;
42 }
43
44 namespace WebKit {
45
46 class LayerTreeCoordinatorProxy;
47
48 class DrawingAreaProxyImpl : public DrawingAreaProxy {
49 public:
50     static PassOwnPtr<DrawingAreaProxyImpl> create(WebPageProxy*);
51     virtual ~DrawingAreaProxyImpl();
52
53     void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, WebCore::Region& unpaintedRegion);
54
55 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
56 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
57     virtual void setAngle(int);
58 #endif
59     virtual void didSuspendPainting();
60 #endif
61
62 private:
63     explicit DrawingAreaProxyImpl(WebPageProxy*);
64
65     // DrawingAreaProxy
66     virtual void sizeDidChange();
67     virtual void deviceScaleFactorDidChange();
68     virtual void layerHostingModeDidChange() OVERRIDE;
69
70     virtual void visibilityDidChange();
71     virtual void setBackingStoreIsDiscardable(bool);
72     virtual void waitForBackingStoreUpdateOnNextPaint();
73
74     // CoreIPC message handlers
75     virtual void update(uint64_t backingStoreStateID, const UpdateInfo&);
76     virtual void didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo&, const LayerTreeContext&);
77     virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&);
78     virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&);
79     virtual void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&);
80
81     void incorporateUpdate(const UpdateInfo&);
82
83     enum RespondImmediatelyOrNot { DoNotRespondImmediately, RespondImmediately };
84     void backingStoreStateDidChange(RespondImmediatelyOrNot);
85     void sendUpdateBackingStoreState(RespondImmediatelyOrNot);
86     void waitForAndDispatchDidUpdateBackingStoreState();
87
88 #if USE(ACCELERATED_COMPOSITING)
89     void enterAcceleratedCompositingMode(const LayerTreeContext&);
90     void exitAcceleratedCompositingMode();
91     void updateAcceleratedCompositingMode(const LayerTreeContext&);
92
93     bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
94
95 #if USE(UI_SIDE_COMPOSITING)
96     virtual void setVisibleContentsRect(const WebCore::IntRect& visibleContentsRect, float scale, const WebCore::FloatPoint& trajectory, const WebCore::FloatPoint& accurateVisibleContentsPosition = WebCore::FloatPoint());
97     void didReceiveLayerTreeCoordinatorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
98 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
99     virtual void setVisibleContentsRectForScrollingContentsLayers(const WebCore::IntRect&);
100 #endif
101 #endif
102 #else
103     bool isInAcceleratedCompositingMode() const { return false; }
104 #endif
105
106     virtual void pageCustomRepresentationChanged();
107
108     void discardBackingStoreSoon();
109     void discardBackingStore();
110
111     // The state ID corresponding to our current backing store. Updated whenever we allocate
112     // a new backing store. Any messages received that correspond to an earlier state are ignored,
113     // as they don't apply to our current backing store.
114     uint64_t m_currentBackingStoreStateID;
115
116     // The next backing store state ID we will request the web process update to. Incremented
117     // whenever our state changes in a way that will require a new backing store to be allocated.
118     uint64_t m_nextBackingStoreStateID;
119
120 #if USE(ACCELERATED_COMPOSITING)
121     // The current layer tree context.
122     LayerTreeContext m_layerTreeContext;
123 #endif
124
125     // Whether we've sent a UpdateBackingStoreState message and are now waiting for a DidUpdateBackingStoreState message.
126     // Used to throttle UpdateBackingStoreState messages so we don't send them faster than the Web process can handle.
127     bool m_isWaitingForDidUpdateBackingStoreState;
128     
129     // For a new Drawing Area don't draw anything until the WebProcess has sent over the first content.
130     bool m_hasReceivedFirstUpdate;
131
132     bool m_isBackingStoreDiscardable;
133     OwnPtr<BackingStore> m_backingStore;
134
135     WebCore::RunLoop::Timer<DrawingAreaProxyImpl> m_discardBackingStoreTimer;
136 };
137
138 } // namespace WebKit
139
140 #endif // DrawingAreaProxyImpl_h