WebPageCompositor_p.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (C) 2010, 2011, 2012, 2013 Research In Motion Limited. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef WebPageCompositor_p_h
  19. #define WebPageCompositor_p_h
  20. #if USE(ACCELERATED_COMPOSITING)
  21. #include "LayerCompositingThread.h"
  22. #include "LayerRenderer.h"
  23. #include "LayerRendererClient.h"
  24. #include "WebPageCompositor.h"
  25. #include <BlackBerryPlatformAnimationFrameRateController.h>
  26. #include <BlackBerryPlatformGLES2Context.h>
  27. #include <wtf/OwnPtr.h>
  28. #include <wtf/RefCounted.h>
  29. #include <wtf/RefPtr.h>
  30. namespace WebCore {
  31. class LayerWebKitThread;
  32. };
  33. namespace BlackBerry {
  34. namespace WebKit {
  35. class WebPageCompositorClient;
  36. class WebPagePrivate;
  37. // This class may only be used on the compositing thread. So it does not need to be threadsaferefcounted.
  38. class WebPageCompositorPrivate
  39. : public RefCounted<WebPageCompositorPrivate>
  40. , public WebCore::LayerRendererClient
  41. , public Platform::AnimationFrameRateClient {
  42. public:
  43. static PassRefPtr<WebPageCompositorPrivate> create(WebPagePrivate* page, WebPageCompositorClient* client)
  44. {
  45. return adoptRef(new WebPageCompositorPrivate(page, client));
  46. }
  47. ~WebPageCompositorPrivate();
  48. // Public API
  49. void setChildWindowPlacement(WebPageCompositor::ChildWindowPlacement placement) { m_childWindowPlacement = placement; }
  50. void prepareFrame(double animationTime);
  51. void render(const WebCore::IntRect& targetRect, const WebCore::IntRect& clipRect, const WebCore::TransformationMatrix&, const WebCore::FloatRect& documentSrcRect);
  52. Platform::Graphics::GLES2Context* context() const { return m_context; }
  53. void setContext(Platform::Graphics::GLES2Context*);
  54. WebCore::LayerCompositingThread* rootLayer() const { return m_rootLayer.get(); }
  55. void setRootLayer(WebCore::LayerCompositingThread*);
  56. WebCore::LayerCompositingThread* overlayLayer() const { return m_overlayLayer.get(); }
  57. void setOverlayLayer(WebCore::LayerCompositingThread*);
  58. WebCore::LayerCompositingThread* compositingThreadOverlayLayer() const { return m_compositingThreadOverlayLayer.get(); }
  59. bool drawsRootLayer() const;
  60. void setDrawsRootLayer(bool drawsRootLayer) { m_drawsRootLayer = drawsRootLayer; }
  61. // Render everything but the root layer, or everything if drawsRootLayer() is true.
  62. bool drawLayers(const WebCore::IntRect& dstRect, const WebCore::FloatRect& contents);
  63. WebCore::IntRect layoutRect() const { return m_layoutRect; }
  64. void setLayoutRect(const WebCore::IntRect& rect) { m_layoutRect = rect; }
  65. WebCore::IntRect documentRect() const { return m_documentRect; }
  66. void setDocumentRect(const WebCore::IntRect& rect) { m_documentRect = rect; }
  67. WebCore::LayerRenderingResults lastCompositingResults() const { return m_lastCompositingResults; }
  68. void setLastCompositingResults(const WebCore::LayerRenderingResults& results) { m_lastCompositingResults = results; }
  69. WebCore::Color backgroundColor() const { return m_backgroundColor; }
  70. void setBackgroundColor(const WebCore::Color&);
  71. void releaseLayerResources();
  72. WebPagePrivate* page() const { return m_webPage; }
  73. void setPage(WebPagePrivate*);
  74. void detach();
  75. WebPageCompositorClient* client() const { return m_client; }
  76. void compositorDestroyed();
  77. void addOverlay(WebCore::LayerCompositingThread*);
  78. void removeOverlay(WebCore::LayerCompositingThread*);
  79. void findFixedElementRect(WebCore::LayerCompositingThread*, WebCore::IntRect&);
  80. protected:
  81. WebPageCompositorPrivate(WebPagePrivate*, WebPageCompositorClient*);
  82. private:
  83. void compositeLayers(const WebCore::TransformationMatrix&);
  84. void attachOverlays() { attachOverlays(m_compositingThreadOverlayLayer.get(), m_webPage); }
  85. void detachOverlays() { attachOverlays(m_compositingThreadOverlayLayer.get(), 0); }
  86. static void attachOverlays(WebCore::LayerCompositingThread* overlayRoot, WebPagePrivate*);
  87. // LayerRendererClient
  88. virtual bool shouldChildWindowsUseDocumentCoordinates();
  89. // AnimationFrameRateClient
  90. virtual void animationFrameChanged();
  91. WebPageCompositorClient* m_client;
  92. WebPagePrivate* m_webPage;
  93. Platform::Graphics::GLES2Context* m_context;
  94. OwnPtr<WebCore::LayerRenderer> m_layerRenderer;
  95. RefPtr<WebCore::LayerCompositingThread> m_rootLayer;
  96. RefPtr<WebCore::LayerCompositingThread> m_overlayLayer;
  97. RefPtr<WebCore::LayerCompositingThread> m_compositingThreadOverlayLayer;
  98. WebCore::IntRect m_layoutRect;
  99. WebCore::IntRect m_documentRect;
  100. WebCore::LayerRenderingResults m_lastCompositingResults;
  101. WebCore::Color m_backgroundColor;
  102. bool m_drawsRootLayer;
  103. WebPageCompositor::ChildWindowPlacement m_childWindowPlacement;
  104. };
  105. } // namespace WebKit
  106. } // namespace BlackBerry
  107. #endif // USE(ACCELERATED_COMPOSITING)
  108. #endif // WebPageCompositor_p_h