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 DrawingAreaProxyImpl_h
27 #define DrawingAreaProxyImpl_h
29 #include "BackingStore.h"
30 #include "DrawingAreaProxy.h"
31 #include "LayerTreeContext.h"
33 #include <wtf/OwnPtr.h>
34 #include <wtf/PassOwnPtr.h>
36 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
46 class LayerTreeHostProxy;
48 class DrawingAreaProxyImpl : public DrawingAreaProxy {
50 static PassOwnPtr<DrawingAreaProxyImpl> create(WebPageProxy*);
51 virtual ~DrawingAreaProxyImpl();
53 void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, WebCore::Region& unpaintedRegion);
55 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
56 virtual void setVisibleContentsRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale);
57 virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&);
58 virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity);
59 void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
63 explicit DrawingAreaProxyImpl(WebPageProxy*);
66 virtual void sizeDidChange();
67 virtual void deviceScaleFactorDidChange();
68 virtual void visibilityDidChange();
69 virtual void setBackingStoreIsDiscardable(bool);
70 virtual void waitForBackingStoreUpdateOnNextPaint();
72 // CoreIPC message handlers
73 virtual void update(uint64_t backingStoreStateID, const UpdateInfo&);
74 virtual void didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo&, const LayerTreeContext&);
75 virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&);
76 virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&);
78 void incorporateUpdate(const UpdateInfo&);
80 enum RespondImmediatelyOrNot { DoNotRespondImmediately, RespondImmediately };
81 void backingStoreStateDidChange(RespondImmediatelyOrNot);
82 void sendUpdateBackingStoreState(RespondImmediatelyOrNot);
83 void waitForAndDispatchDidUpdateBackingStoreState();
85 #if USE(ACCELERATED_COMPOSITING)
86 void enterAcceleratedCompositingMode(const LayerTreeContext&);
87 void exitAcceleratedCompositingMode();
89 bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
91 bool isInAcceleratedCompositingMode() const { return false; }
94 virtual void pageCustomRepresentationChanged();
96 void discardBackingStoreSoon();
97 void discardBackingStore();
99 // The state ID corresponding to our current backing store. Updated whenever we allocate
100 // a new backing store. Any messages received that correspond to an earlier state are ignored,
101 // as they don't apply to our current backing store.
102 uint64_t m_currentBackingStoreStateID;
104 // The next backing store state ID we will request the web process update to. Incremented
105 // whenever our state changes in a way that will require a new backing store to be allocated.
106 uint64_t m_nextBackingStoreStateID;
108 #if USE(ACCELERATED_COMPOSITING)
109 // The current layer tree context.
110 LayerTreeContext m_layerTreeContext;
113 // Whether we've sent a UpdateBackingStoreState message and are now waiting for a DidUpdateBackingStoreState message.
114 // Used to throttle UpdateBackingStoreState messages so we don't send them faster than the Web process can handle.
115 bool m_isWaitingForDidUpdateBackingStoreState;
117 // For a new Drawing Area don't draw anything until the WebProcess has sent over the first content.
118 bool m_hasReceivedFirstUpdate;
120 bool m_isBackingStoreDiscardable;
121 OwnPtr<BackingStore> m_backingStore;
123 RunLoop::Timer<DrawingAreaProxyImpl> m_discardBackingStoreTimer;
126 } // namespace WebKit
128 #endif // DrawingAreaProxyImpl_h