WebKit2/WebProcess/WebPage/LayerBackedDrawingArea.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 #ifdef __OBJC__
       
    39 @class CALayer;
       
    40 #else
       
    41 class CALayer;
       
    42 #endif
       
    43 typedef struct __WKCARemoteLayerClientRef *WKCARemoteLayerClientRef;
       
    44 #endif
       
    45 
       
    46 namespace WebCore {
       
    47     class GraphicsContext;
       
    48     class GraphicsLayer;
       
    49     class IntRect;
       
    50 }
       
    51 
       
    52 namespace WebKit {
       
    53 
       
    54 class LayerBackedDrawingArea : public DrawingArea, private WebCore::GraphicsLayerClient {
       
    55 public:
       
    56     LayerBackedDrawingArea(WebPage*);
       
    57     virtual ~LayerBackedDrawingArea();
       
    58 
       
    59     virtual void invalidateWindow(const WebCore::IntRect& rect, bool immediate);
       
    60     virtual void invalidateContentsAndWindow(const WebCore::IntRect& rect, bool immediate);
       
    61     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect& rect, bool immediate);
       
    62     virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect);
       
    63     virtual void setNeedsDisplay(const WebCore::IntRect&);
       
    64     virtual void display();
       
    65 
       
    66     virtual void attachCompositingContext();
       
    67     virtual void detachCompositingContext();
       
    68     virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
       
    69     virtual void scheduleCompositingLayerSync();
       
    70     virtual void syncCompositingLayers();
       
    71 
       
    72     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder&);
       
    73 
       
    74 private:
       
    75 
       
    76     // GraphicsLayerClient
       
    77     virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double /*time*/) { }
       
    78     virtual void notifySyncRequired(const WebCore::GraphicsLayer*) { }
       
    79 public:
       
    80     virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& inClip);
       
    81 private:
       
    82     virtual bool showDebugBorders() const;
       
    83     virtual bool showRepaintCounter() const;
       
    84 
       
    85     void scheduleDisplay();
       
    86     
       
    87     // CoreIPC message handlers.
       
    88     void setSize(const WebCore::IntSize& viewSize);
       
    89     void suspendPainting();
       
    90     void resumePainting();
       
    91     void didUpdate();
       
    92     
       
    93     void platformInit();
       
    94     void platformClear();
       
    95 
       
    96 #if PLATFORM(MAC)
       
    97     void setUpUpdateLayoutRunLoopObserver();
       
    98     void scheduleUpdateLayoutRunLoopObserver();
       
    99     void removeUpdateLayoutRunLoopObserver();
       
   100 
       
   101     static void updateLayoutRunLoopObserverCallback(CFRunLoopObserverRef, CFRunLoopActivity, void*);
       
   102     void updateLayoutRunLoopObserverFired();
       
   103 #endif
       
   104 
       
   105     RunLoop::Timer<LayerBackedDrawingArea> m_syncTimer;
       
   106 
       
   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