DrawingArea.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. #ifndef DrawingArea_h
  26. #define DrawingArea_h
  27. #include "DrawingAreaInfo.h"
  28. #include <WebCore/FloatPoint.h>
  29. #include <WebCore/IntRect.h>
  30. #include <wtf/Forward.h>
  31. #include <wtf/Noncopyable.h>
  32. #include <wtf/PassOwnPtr.h>
  33. namespace CoreIPC {
  34. class Connection;
  35. class MessageDecoder;
  36. }
  37. namespace WebCore {
  38. class GraphicsLayer;
  39. class GraphicsLayerFactory;
  40. }
  41. namespace WebKit {
  42. struct ColorSpaceData;
  43. class LayerTreeHost;
  44. class PageOverlay;
  45. class WebPage;
  46. struct WebPageCreationParameters;
  47. struct WebPreferencesStore;
  48. class DrawingArea {
  49. WTF_MAKE_NONCOPYABLE(DrawingArea);
  50. public:
  51. static PassOwnPtr<DrawingArea> create(WebPage*, const WebPageCreationParameters&);
  52. virtual ~DrawingArea();
  53. void didReceiveDrawingAreaMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
  54. virtual void setNeedsDisplay() = 0;
  55. virtual void setNeedsDisplayInRect(const WebCore::IntRect&) = 0;
  56. virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) = 0;
  57. // FIXME: These should be pure virtual.
  58. virtual void pageBackgroundTransparencyChanged() { }
  59. virtual void forceRepaint() { }
  60. virtual bool forceRepaintAsync(uint64_t /*callbackID*/) { return false; }
  61. virtual void setLayerTreeStateIsFrozen(bool) { }
  62. virtual bool layerTreeStateIsFrozen() const { return false; }
  63. virtual LayerTreeHost* layerTreeHost() const { return 0; }
  64. virtual void didInstallPageOverlay(PageOverlay*) { }
  65. virtual void didUninstallPageOverlay(PageOverlay*) { }
  66. virtual void setPageOverlayNeedsDisplay(PageOverlay*, const WebCore::IntRect&) { }
  67. virtual void setPageOverlayOpacity(PageOverlay*, float) { }
  68. // If this function returns false, PageOverlay should apply opacity when painting.
  69. virtual bool pageOverlayShouldApplyFadeWhenPainting() const { return true; }
  70. virtual void pageCustomRepresentationChanged() { }
  71. virtual void setPaintingEnabled(bool) { }
  72. virtual void updatePreferences(const WebPreferencesStore&) { }
  73. virtual void mainFrameContentSizeChanged(const WebCore::IntSize&) { }
  74. virtual void setExposedRect(const WebCore::FloatRect&) { }
  75. virtual void setClipsToExposedRect(bool) { }
  76. virtual void mainFrameScrollabilityChanged(bool) { }
  77. virtual void didChangeScrollOffsetForAnyFrame() { }
  78. #if USE(ACCELERATED_COMPOSITING)
  79. virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() { return 0; }
  80. virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) = 0;
  81. virtual void scheduleCompositingLayerFlush() = 0;
  82. #if PLATFORM(MANX)
  83. virtual void updateAcceleratedCompositingMode() { }
  84. #endif
  85. #endif
  86. #if USE(COORDINATED_GRAPHICS)
  87. virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) = 0;
  88. #endif
  89. virtual void dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>&);
  90. protected:
  91. DrawingArea(DrawingAreaType, WebPage*);
  92. DrawingAreaType m_type;
  93. WebPage* m_webPage;
  94. private:
  95. // CoreIPC message handlers.
  96. // FIXME: These should be pure virtual.
  97. virtual void updateBackingStoreState(uint64_t /*backingStoreStateID*/, bool /*respondImmediately*/, float /*deviceScaleFactor*/, const WebCore::IntSize& /*size*/,
  98. const WebCore::IntSize& /*scrollOffset*/) { }
  99. virtual void didUpdate() { }
  100. virtual void suspendPainting() { }
  101. virtual void resumePainting() { }
  102. virtual void setLayerHostingMode(uint32_t) { }
  103. #if PLATFORM(MAC)
  104. // Used by TiledCoreAnimationDrawingArea.
  105. virtual void updateGeometry(const WebCore::IntSize& viewSize, const WebCore::IntSize& layerPosition) { }
  106. virtual void setDeviceScaleFactor(float) { }
  107. virtual void setColorSpace(const ColorSpaceData&) { }
  108. #endif
  109. };
  110. } // namespace WebKit
  111. #endif // DrawingArea_h