OSDN Git Service

Merge WebKit at r78450: Initial merge by git.
[android-x86/external-webkit.git] / Source / WebKit2 / WebProcess / WebPage / LayerBackedDrawingArea.h
1 /*
2  * Copyright (C) 2010 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 LayerBackedDrawingArea_h
27 #define LayerBackedDrawingArea_h
28
29 #if USE(ACCELERATED_COMPOSITING)
30
31 #include "DrawingArea.h"
32 #include "RunLoop.h"
33 #include <WebCore/IntPoint.h>
34 #include <WebCore/GraphicsLayerClient.h>
35
36 #if PLATFORM(MAC)
37 #include <wtf/RetainPtr.h>
38 OBJC_CLASS NSPopUpButtonCell;
39 OBJC_CLASS WKView;
40 typedef struct __WKCARemoteLayerClientRef *WKCARemoteLayerClientRef;
41 #endif
42
43 namespace WebCore {
44     class GraphicsContext;
45     class GraphicsLayer;
46 }
47
48 namespace WebKit {
49
50 class LayerBackedDrawingArea : public DrawingArea, private WebCore::GraphicsLayerClient {
51 public:
52     LayerBackedDrawingArea(DrawingAreaInfo::Identifier identifier, WebPage*);
53     virtual ~LayerBackedDrawingArea();
54
55     virtual void setNeedsDisplay(const WebCore::IntRect&);
56     virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
57     virtual void display();
58
59     virtual void pageBackgroundTransparencyChanged();
60
61     virtual void attachCompositingContext();
62     virtual void detachCompositingContext();
63     virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
64     virtual void scheduleCompositingLayerSync();
65     virtual void syncCompositingLayers();
66
67     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
68
69 private:
70
71     // GraphicsLayerClient
72     virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double /*time*/) { }
73     virtual void notifySyncRequired(const WebCore::GraphicsLayer*) { }
74 public:
75     virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
76 private:
77     virtual bool showDebugBorders() const;
78     virtual bool showRepaintCounter() const;
79
80 #if PLATFORM(MAC)
81     virtual void onPageClose();
82 #endif
83
84     void scheduleDisplay();
85     
86     // CoreIPC message handlers.
87     void setSize(const WebCore::IntSize& viewSize);
88     void suspendPainting();
89     void resumePainting();
90     void didUpdate();
91     
92     void platformInit();
93     void platformClear();
94
95 #if PLATFORM(MAC)
96     void setUpUpdateLayoutRunLoopObserver();
97     void scheduleUpdateLayoutRunLoopObserver();
98     void removeUpdateLayoutRunLoopObserver();
99
100     static void updateLayoutRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*);
101     void updateLayoutRunLoopObserverFired();
102 #endif
103
104     RunLoop::Timer<LayerBackedDrawingArea> m_syncTimer;
105
106     OwnPtr<WebCore::GraphicsLayer> m_hostingLayer;
107     OwnPtr<WebCore::GraphicsLayer> m_backingLayer;
108 #if PLATFORM(MAC)
109 #if HAVE(HOSTED_CORE_ANIMATION)
110     RetainPtr<WKCARemoteLayerClientRef> m_remoteLayerRef;
111 #endif
112     RetainPtr<CFRunLoopObserverRef> m_updateLayoutRunLoopObserver;
113 #endif
114
115     bool m_attached;
116     bool m_shouldPaint;
117 };
118
119 } // namespace WebKit
120
121 #endif // USE(ACCELERATED_COMPOSITING)
122
123 #endif // LayerBackedDrawingArea_h