DrawingAreaImpl.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. #ifndef DrawingAreaImpl_h
  26. #define DrawingAreaImpl_h
  27. #include "DrawingArea.h"
  28. #include "LayerTreeHost.h"
  29. #include <WebCore/Region.h>
  30. #include <WebCore/RunLoop.h>
  31. namespace WebCore {
  32. class GraphicsContext;
  33. }
  34. namespace WebKit {
  35. class ShareableBitmap;
  36. class UpdateInfo;
  37. class DrawingAreaImpl : public DrawingArea {
  38. public:
  39. static PassOwnPtr<DrawingAreaImpl> create(WebPage*, const WebPageCreationParameters&);
  40. virtual ~DrawingAreaImpl();
  41. void layerHostDidFlushLayers();
  42. private:
  43. DrawingAreaImpl(WebPage*, const WebPageCreationParameters&);
  44. // DrawingArea
  45. virtual void setNeedsDisplay() OVERRIDE;
  46. virtual void setNeedsDisplayInRect(const WebCore::IntRect&) OVERRIDE;
  47. virtual void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta);
  48. virtual void pageBackgroundTransparencyChanged() OVERRIDE;
  49. virtual void setLayerTreeStateIsFrozen(bool);
  50. virtual bool layerTreeStateIsFrozen() const { return m_layerTreeStateIsFrozen; }
  51. virtual LayerTreeHost* layerTreeHost() const { return m_layerTreeHost.get(); }
  52. virtual void forceRepaint();
  53. virtual bool forceRepaintAsync(uint64_t callbackID);
  54. virtual void didInstallPageOverlay(PageOverlay*);
  55. virtual void didUninstallPageOverlay(PageOverlay*);
  56. virtual void setPageOverlayNeedsDisplay(PageOverlay*, const WebCore::IntRect&);
  57. virtual void setPageOverlayOpacity(PageOverlay*, float);
  58. virtual bool pageOverlayShouldApplyFadeWhenPainting() const;
  59. virtual void setPaintingEnabled(bool);
  60. virtual void updatePreferences(const WebPreferencesStore&) OVERRIDE;
  61. #if USE(ACCELERATED_COMPOSITING)
  62. virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
  63. virtual void setRootCompositingLayer(WebCore::GraphicsLayer*) OVERRIDE;
  64. virtual void scheduleCompositingLayerFlush() OVERRIDE;
  65. #endif
  66. #if PLATFORM(MAC)
  67. virtual void setLayerHostingMode(uint32_t) OVERRIDE;
  68. #endif
  69. #if USE(COORDINATED_GRAPHICS)
  70. virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
  71. #endif
  72. // CoreIPC message handlers.
  73. virtual void updateBackingStoreState(uint64_t backingStoreStateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize&, const WebCore::IntSize& scrollOffset);
  74. virtual void didUpdate();
  75. virtual void suspendPainting();
  76. virtual void resumePainting();
  77. virtual void pageCustomRepresentationChanged();
  78. void sendDidUpdateBackingStoreState();
  79. void enterAcceleratedCompositingMode(WebCore::GraphicsLayer*);
  80. void exitAcceleratedCompositingModeSoon();
  81. bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); }
  82. void exitAcceleratedCompositingMode();
  83. #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MANX)
  84. virtual void updateAcceleratedCompositingMode();
  85. #endif
  86. void scheduleDisplay();
  87. void displayTimerFired();
  88. void display();
  89. void display(UpdateInfo&);
  90. uint64_t m_backingStoreStateID;
  91. WebCore::Region m_dirtyRegion;
  92. WebCore::IntRect m_scrollRect;
  93. WebCore::IntSize m_scrollOffset;
  94. // Whether painting is enabled. If painting is disabled, any calls to setNeedsDisplay and scroll are ignored.
  95. bool m_isPaintingEnabled;
  96. // Whether we're currently processing an UpdateBackingStoreState message.
  97. bool m_inUpdateBackingStoreState;
  98. // When true, we should send an UpdateBackingStoreState message instead of any other messages
  99. // we normally send to the UI process.
  100. bool m_shouldSendDidUpdateBackingStoreState;
  101. // Whether we're waiting for a DidUpdate message. Used for throttling paints so that the
  102. // web process won't paint more frequent than the UI process can handle.
  103. bool m_isWaitingForDidUpdate;
  104. // True between sending the 'enter compositing' messages, and the 'exit compositing' message.
  105. bool m_compositingAccordingToProxyMessages;
  106. // When true, we maintain the layer tree in its current state by not leaving accelerated compositing mode
  107. // and not scheduling layer flushes.
  108. bool m_layerTreeStateIsFrozen;
  109. // True when we were asked to exit accelerated compositing mode but couldn't because layer tree
  110. // state was frozen.
  111. bool m_wantsToExitAcceleratedCompositingMode;
  112. // Whether painting is suspended. We'll still keep track of the dirty region but we
  113. // won't paint until painting has resumed again.
  114. bool m_isPaintingSuspended;
  115. bool m_alwaysUseCompositing;
  116. WebCore::RunLoop::Timer<DrawingAreaImpl> m_displayTimer;
  117. WebCore::RunLoop::Timer<DrawingAreaImpl> m_exitCompositingTimer;
  118. // The layer tree host that handles accelerated compositing.
  119. RefPtr<LayerTreeHost> m_layerTreeHost;
  120. };
  121. } // namespace WebKit
  122. #endif // DrawingAreaImpl_h