2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
4 * Copyright (C) 2016 Igalia S.L.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25 * THE POSSIBILITY OF SUCH DAMAGE.
30 #include "DrawingAreaProxy.h"
31 #include "LayerTreeContext.h"
35 class CoordinatedLayerTreeHostProxy;
37 class AcceleratedDrawingAreaProxy : public DrawingAreaProxy {
39 explicit AcceleratedDrawingAreaProxy(WebPageProxy&);
40 virtual ~AcceleratedDrawingAreaProxy();
42 bool isInAcceleratedCompositingMode() const { return alwaysUseCompositing() || !m_layerTreeContext.isEmpty(); }
43 void visibilityDidChange();
45 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
46 CoordinatedLayerTreeHostProxy& coordinatedLayerTreeHostProxy() const { return *m_coordinatedLayerTreeHostProxy.get(); }
49 #if USE(TEXTURE_MAPPER_GL) && PLATFORM(GTK) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
50 void setNativeSurfaceHandleForCompositing(uint64_t);
51 void destroyNativeSurfaceHandleForCompositing();
54 void dispatchAfterEnsuringDrawing(std::function<void(CallbackBase::Error)>) override;
58 void sizeDidChange() override;
59 void deviceScaleFactorDidChange() override;
60 void waitForBackingStoreUpdateOnNextPaint() override;
62 // IPC message handlers
63 void didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo&, const LayerTreeContext&) override;
64 void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
65 void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) override;
66 void updateAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) override;
68 enum RespondImmediatelyOrNot { DoNotRespondImmediately, RespondImmediately };
69 void backingStoreStateDidChange(RespondImmediatelyOrNot);
70 void sendUpdateBackingStoreState(RespondImmediatelyOrNot);
71 void waitForAndDispatchDidUpdateBackingStoreState();
73 virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
74 void exitAcceleratedCompositingMode();
75 void updateAcceleratedCompositingMode(const LayerTreeContext&);
77 bool alwaysUseCompositing() const;
79 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
80 std::unique_ptr<CoordinatedLayerTreeHostProxy> m_coordinatedLayerTreeHostProxy;
83 // The state ID corresponding to our current backing store. Updated whenever we allocate
84 // a new backing store. Any messages received that correspond to an earlier state are ignored,
85 // as they don't apply to our current backing store.
86 uint64_t m_currentBackingStoreStateID { 0 };
88 // The next backing store state ID we will request the web process update to. Incremented
89 // whenever our state changes in a way that will require a new backing store to be allocated.
90 uint64_t m_nextBackingStoreStateID { 0 };
92 // The current layer tree context.
93 LayerTreeContext m_layerTreeContext;
95 // Whether we've sent a UpdateBackingStoreState message and are now waiting for a DidUpdateBackingStoreState message.
96 // Used to throttle UpdateBackingStoreState messages so we don't send them faster than the Web process can handle.
97 bool m_isWaitingForDidUpdateBackingStoreState { false };
99 // For a new Drawing Area don't draw anything until the WebProcess has sent over the first content.
100 bool m_hasReceivedFirstUpdate { false };
102 #if USE(TEXTURE_MAPPER_GL) && PLATFORM(GTK) && PLATFORM(X11) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
103 uint64_t m_pendingNativeSurfaceHandleForCompositing { 0 };
107 } // namespace WebKit