• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 LayerTreeHost_h
27 #define LayerTreeHost_h
28 
29 #include <wtf/PassRefPtr.h>
30 #include <wtf/RefCounted.h>
31 
32 namespace WebCore {
33     class IntRect;
34     class IntSize;
35     class GraphicsLayer;
36 }
37 
38 namespace WebKit {
39 
40 class LayerTreeContext;
41 class UpdateInfo;
42 class WebPage;
43 
44 class LayerTreeHost : public RefCounted<LayerTreeHost> {
45 public:
46     static PassRefPtr<LayerTreeHost> create(WebPage*);
47     virtual ~LayerTreeHost();
48 
49     static bool supportsAcceleratedCompositing();
50 
51     virtual const LayerTreeContext& layerTreeContext() = 0;
52     virtual void scheduleLayerFlush() = 0;
53     virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool) = 0;
54     virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0;
55     virtual void invalidate() = 0;
56 
57     virtual void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&) = 0;
58     virtual void scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) = 0;
59     virtual void forceRepaint() = 0;
60     virtual void sizeDidChange(const WebCore::IntSize& newSize) = 0;
61 
62     virtual void didInstallPageOverlay() = 0;
63     virtual void didUninstallPageOverlay() = 0;
64     virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&) = 0;
65 
pauseRendering()66     virtual void pauseRendering() { }
resumeRendering()67     virtual void resumeRendering() { }
68 
69     // If a derived class overrides this function to return true, the derived class must also
70     // override the functions beneath it.
participatesInDisplay()71     virtual bool participatesInDisplay() { return false; }
needsDisplay()72     virtual bool needsDisplay() { ASSERT_NOT_REACHED(); return false; }
timeUntilNextDisplay()73     virtual double timeUntilNextDisplay() { ASSERT_NOT_REACHED(); return 0; }
display(UpdateInfo &)74     virtual void display(UpdateInfo&) { ASSERT_NOT_REACHED(); }
75 
76 protected:
77     explicit LayerTreeHost(WebPage*);
78 
79     WebPage* m_webPage;
80 };
81 
82 #if !PLATFORM(WIN)
supportsAcceleratedCompositing()83 inline bool LayerTreeHost::supportsAcceleratedCompositing()
84 {
85     return true;
86 }
87 #endif
88 
89 } // namespace WebKit
90 
91 #endif // LayerTreeHost_h
92