2 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef DrawingAreaImpl_h
27 #define DrawingAreaImpl_h
29 #include "DrawingArea.h"
30 #include "LayerTreeHost.h"
31 #include <WebCore/Region.h>
32 #include <WebCore/RunLoop.h>
35 class GraphicsContext;
40 class ShareableBitmap;
43 class DrawingAreaImpl : public DrawingArea {
45 static PassOwnPtr<DrawingAreaImpl> create(WebPage*, const WebPageCreationParameters&);
46 virtual ~DrawingAreaImpl();
48 void layerHostDidFlushLayers();
51 DrawingAreaImpl(WebPage*, const WebPageCreationParameters&);
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();
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;
67 virtual void setPaintingEnabled(bool);
69 virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
70 virtual void scheduleCompositingLayerSync();
72 #if ENABLE(TIZEN_ONESHOT_DRAWING_SYNCHRONIZATION)
73 virtual void setNeedsOneShotDrawingSynchronization();
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);
82 virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&);
86 virtual void setLayerHostingMode(uint32_t) OVERRIDE;
89 #if USE(UI_SIDE_COMPOSITING)
90 virtual void didReceiveLayerTreeCoordinatorMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
93 #if ENABLE(TIZEN_LAYER_FLUSH_THROTTLING)
94 void didStartProgress();
95 void didFinishProgress();
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();
104 virtual void pageCustomRepresentationChanged();
106 void sendDidUpdateBackingStoreState();
108 void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
109 void exitAcceleratedCompositingModeSoon();
110 bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); }
111 void exitAcceleratedCompositingMode();
113 void scheduleDisplay();
114 void displayTimerFired();
116 void display(UpdateInfo&);
117 PassOwnPtr<WebCore::GraphicsContext> createGraphicsContext(ShareableBitmap*);
119 uint64_t m_backingStoreStateID;
121 WebCore::Region m_dirtyRegion;
122 WebCore::IntRect m_scrollRect;
123 WebCore::IntSize m_scrollOffset;
125 // Whether painting is enabled. If painting is disabled, any calls to setNeedsDisplay and scroll are ignored.
126 bool m_isPaintingEnabled;
128 // Whether we're currently processing an UpdateBackingStoreState message.
129 bool m_inUpdateBackingStoreState;
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;
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;
139 // True between sending the 'enter compositing' messages, and the 'exit compositing' message.
140 bool m_compositingAccordingToProxyMessages;
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;
146 // True when we were asked to exit accelerated compositing mode but couldn't because layer tree
148 bool m_wantsToExitAcceleratedCompositingMode;
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;
156 bool m_alwaysUseCompositing;
158 WebCore::RunLoop::Timer<DrawingAreaImpl> m_displayTimer;
159 WebCore::RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer;
161 // The layer tree host that handles accelerated compositing.
162 RefPtr<LayerTreeHost> m_layerTreeHost;
165 } // namespace WebKit
167 #endif // DrawingAreaImpl_h