Home | History | Annotate | Download | only in UIProcess
      1 /*
      2  * Copyright (C) 2010 Apple Inc. All rights reserved.
      3  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  *
     14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
     18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     24  * THE POSSIBILITY OF SUCH DAMAGE.
     25  */
     26 
     27 #ifndef DrawingAreaProxy_h
     28 #define DrawingAreaProxy_h
     29 
     30 #include "DrawingAreaInfo.h"
     31 #include <stdint.h>
     32 #include <WebCore/IntSize.h>
     33 #include <wtf/Noncopyable.h>
     34 
     35 #if PLATFORM(QT)
     36 class QPainter;
     37 #elif PLATFORM(GTK)
     38 typedef struct _cairo cairo_t;
     39 #endif
     40 
     41 namespace CoreIPC {
     42     class ArgumentDecoder;
     43     class Connection;
     44     class MessageID;
     45 }
     46 
     47 namespace WebCore {
     48     class IntRect;
     49 }
     50 
     51 namespace WebKit {
     52 
     53 class LayerTreeContext;
     54 class UpdateInfo;
     55 class WebPageProxy;
     56 
     57 #if PLATFORM(MAC)
     58 typedef CGContextRef PlatformDrawingContext;
     59 #elif PLATFORM(WIN)
     60 typedef HDC PlatformDrawingContext;
     61 #elif PLATFORM(QT)
     62 typedef QPainter* PlatformDrawingContext;
     63 #elif PLATFORM(GTK)
     64 typedef cairo_t* PlatformDrawingContext;
     65 #endif
     66 
     67 class DrawingAreaProxy {
     68     WTF_MAKE_NONCOPYABLE(DrawingAreaProxy);
     69 
     70 public:
     71     virtual ~DrawingAreaProxy();
     72 
     73     DrawingAreaType type() const { return m_type; }
     74 
     75 #if PLATFORM(MAC) || PLATFORM(WIN)
     76     void didReceiveDrawingAreaProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
     77 #endif
     78 
     79     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) = 0;
     80 
     81     // Returns true if painting was successful, false otherwise.
     82     virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext) = 0;
     83 
     84     virtual void sizeDidChange() = 0;
     85 
     86     // FIXME: These should be pure virtual.
     87     virtual void visibilityDidChange() { }
     88     virtual void setBackingStoreIsDiscardable(bool) { }
     89 
     90     virtual void setPageIsVisible(bool isVisible) = 0;
     91 
     92     const WebCore::IntSize& size() const { return m_size; }
     93     void setSize(const WebCore::IntSize&, const WebCore::IntSize& scrollOffset);
     94 
     95 protected:
     96     explicit DrawingAreaProxy(DrawingAreaType, WebPageProxy*);
     97 
     98     DrawingAreaType m_type;
     99     WebPageProxy* m_webPageProxy;
    100 
    101     WebCore::IntSize m_size;
    102     WebCore::IntSize m_scrollOffset;
    103 
    104 private:
    105     // CoreIPC message handlers.
    106     // FIXME: These should be pure virtual.
    107     virtual void update(uint64_t backingStoreStateID, const UpdateInfo&) { }
    108     virtual void didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo&, const LayerTreeContext&) { }
    109 #if USE(ACCELERATED_COMPOSITING)
    110     virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) { }
    111     virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) { }
    112 #endif
    113 };
    114 
    115 } // namespace WebKit
    116 
    117 #endif // DrawingAreaProxy_h
    118