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 LayerTreeHostCA_h 27 #define LayerTreeHostCA_h 28 29 #include "LayerTreeContext.h" 30 #include "LayerTreeHost.h" 31 #include <WebCore/GraphicsLayerClient.h> 32 #include <wtf/OwnPtr.h> 33 34 namespace WebKit { 35 36 class LayerTreeHostCA : public LayerTreeHost, WebCore::GraphicsLayerClient { 37 public: 38 virtual ~LayerTreeHostCA(); 39 40 protected: 41 explicit LayerTreeHostCA(WebPage*); 42 43 WebCore::GraphicsLayer* rootLayer() const { return m_rootLayer.get(); } 44 45 void initialize(); 46 void performScheduledLayerFlush(); 47 48 // LayerTreeHost. 49 virtual void invalidate(); 50 virtual void sizeDidChange(const WebCore::IntSize& newSize); 51 virtual void forceRepaint(); 52 53 // LayerTreeHostCA 54 virtual void didPerformScheduledLayerFlush(); 55 56 private: 57 // LayerTreeHost. 58 virtual const LayerTreeContext& layerTreeContext(); 59 virtual void setShouldNotifyAfterNextScheduledLayerFlush(bool); 60 virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); 61 62 virtual void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&); 63 virtual void scrollNonCompositedContents(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); 64 65 virtual void didInstallPageOverlay(); 66 virtual void didUninstallPageOverlay(); 67 virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&); 68 69 // GraphicsLayerClient 70 virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time); 71 virtual void notifySyncRequired(const WebCore::GraphicsLayer*); 72 virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); 73 virtual bool showDebugBorders() const; 74 virtual bool showRepaintCounter() const; 75 76 // LayerTreeHostCA 77 virtual void platformInitialize(LayerTreeContext&) = 0; 78 79 bool flushPendingLayerChanges(); 80 81 void createPageOverlayLayer(); 82 void destroyPageOverlayLayer(); 83 84 // The context for this layer tree. 85 LayerTreeContext m_layerTreeContext; 86 87 // Whether the layer tree host is valid or not. 88 bool m_isValid; 89 90 // Whether we should let the drawing area know the next time we've flushed 91 // layer tree changes. 92 bool m_notifyAfterScheduledLayerFlush; 93 94 // The root layer. 95 OwnPtr<WebCore::GraphicsLayer> m_rootLayer; 96 97 // The layer which contains all non-composited content. 98 OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer; 99 100 // The page overlay layer. Will be null if there's no page overlay. 101 OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer; 102 }; 103 104 } // namespace WebKit 105 106 #endif // LayerTreeHostCA_h 107