DrawingAreaImpl.h revision 81bc750723a18f21cd17d1b173cd2a4dda9cea6e
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 DrawingAreaImpl_h 27#define DrawingAreaImpl_h 28 29#include "DrawingArea.h" 30#include "LayerTreeHost.h" 31#include "Region.h" 32#include "RunLoop.h" 33 34namespace WebKit { 35 36class UpdateInfo; 37 38class DrawingAreaImpl : public DrawingArea { 39public: 40 static PassOwnPtr<DrawingAreaImpl> create(WebPage*, const WebPageCreationParameters&); 41 virtual ~DrawingAreaImpl(); 42 43 void layerHostDidFlushLayers(); 44 45private: 46 DrawingAreaImpl(WebPage*, const WebPageCreationParameters&); 47 48 // DrawingArea 49 virtual void setNeedsDisplay(const WebCore::IntRect&); 50 virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset); 51 virtual void forceRepaint(); 52 53 virtual void didInstallPageOverlay(); 54 virtual void didUninstallPageOverlay(); 55 virtual void setPageOverlayNeedsDisplay(const WebCore::IntRect&); 56 57 virtual void setRootCompositingLayer(WebCore::GraphicsLayer*); 58 virtual void scheduleCompositingLayerSync(); 59 virtual void syncCompositingLayers(); 60 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 61 62 // CoreIPC message handlers. 63 virtual void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset); 64 virtual void didUpdate(); 65 virtual void suspendPainting(); 66 virtual void resumePainting(); 67 68 void sendDidUpdateBackingStoreState(); 69 70 void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*); 71 void exitAcceleratedCompositingModeSoon(); 72 void exitAcceleratedCompositingMode(); 73 74 void scheduleDisplay(); 75 void display(); 76 void display(UpdateInfo&); 77 78 uint64_t m_backingStoreStateID; 79 80 Region m_dirtyRegion; 81 WebCore::IntRect m_scrollRect; 82 WebCore::IntSize m_scrollOffset; 83 84 // Whether we're currently processing an UpdateBackingStoreState message. 85 bool m_inUpdateBackingStoreState; 86 87 // When true, we should send an UpdateBackingStoreState message instead of any other messages 88 // we normally send to the UI process. 89 bool m_shouldSendDidUpdateBackingStoreState; 90 91 // Whether we're waiting for a DidUpdate message. Used for throttling paints so that the 92 // web process won't paint more frequent than the UI process can handle. 93 bool m_isWaitingForDidUpdate; 94 95 // Whether painting is suspended. We'll still keep track of the dirty region but we 96 // won't paint until painting has resumed again. 97 bool m_isPaintingSuspended; 98 bool m_alwaysUseCompositing; 99 100 RunLoop::Timer<DrawingAreaImpl> m_displayTimer; 101 RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer; 102 103 // The layer tree host that handles accelerated compositing. 104 RefPtr<LayerTreeHost> m_layerTreeHost; 105}; 106 107} // namespace WebKit 108 109#endif // DrawingAreaImpl_h 110