2 * Copyright (C) 2010 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 LayerBackedDrawingArea_h
27 #define LayerBackedDrawingArea_h
29 #if USE(ACCELERATED_COMPOSITING)
31 #include "DrawingArea.h"
33 #include <WebCore/IntPoint.h>
34 #include <WebCore/GraphicsLayerClient.h>
37 #include <wtf/RetainPtr.h>
38 OBJC_CLASS NSPopUpButtonCell;
40 typedef struct __WKCARemoteLayerClientRef *WKCARemoteLayerClientRef;
44 class GraphicsContext;
50 class LayerBackedDrawingArea : public DrawingArea, private WebCore::GraphicsLayerClient {
52 LayerBackedDrawingArea(DrawingAreaInfo::Identifier identifier, WebPage*);
53 virtual ~LayerBackedDrawingArea();
55 virtual void setNeedsDisplay(const WebCore::IntRect&);
56 virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
57 virtual void display();
59 virtual void pageBackgroundTransparencyChanged();
61 virtual void attachCompositingContext();
62 virtual void detachCompositingContext();
63 virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
64 virtual void scheduleCompositingLayerSync();
65 virtual void syncCompositingLayers();
67 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
71 // GraphicsLayerClient
72 virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double /*time*/) { }
73 virtual void notifySyncRequired(const WebCore::GraphicsLayer*) { }
75 virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
77 virtual bool showDebugBorders() const;
78 virtual bool showRepaintCounter() const;
81 virtual void onPageClose();
84 void scheduleDisplay();
86 // CoreIPC message handlers.
87 void setSize(const WebCore::IntSize& viewSize);
88 void suspendPainting();
89 void resumePainting();
96 void setUpUpdateLayoutRunLoopObserver();
97 void scheduleUpdateLayoutRunLoopObserver();
98 void removeUpdateLayoutRunLoopObserver();
100 static void updateLayoutRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*);
101 void updateLayoutRunLoopObserverFired();
104 RunLoop::Timer<LayerBackedDrawingArea> m_syncTimer;
106 OwnPtr<WebCore::GraphicsLayer> m_hostingLayer;
107 OwnPtr<WebCore::GraphicsLayer> m_backingLayer;
109 #if HAVE(HOSTED_CORE_ANIMATION)
110 RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerRef;
112 RetainPtr<CFRunLoopObserverRef> m_updateLayoutRunLoopObserver;
119 } // namespace WebKit
121 #endif // USE(ACCELERATED_COMPOSITING)
123 #endif // LayerBackedDrawingArea_h