0003-Fix-build-without-OpenGL.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. From 4ecb913768ff0806c6efdff4567ef5907f597e4a Mon Sep 17 00:00:00 2001
  2. From: Allan Sandfeld Jensen <allan.jensen@digia.com>
  3. Date: Tue, 6 Jan 2015 16:31:27 +0100
  4. Subject: [PATCH] Fix build without OpenGL
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The accelerated 2D canvas feature broke building without OpenGL due to
  9. missing feature checks.
  10. Task-number: QTBUG-43549
  11. Change-Id: I7e62751d5237e1c600bc784539c70db50bccfa22
  12. Reviewed-by: Ashish Kulkarni <kulkarni.ashish@gmail.com>
  13. Reviewed-by: Michael Brüning <michael.bruning@theqtcompany.com>
  14. ---
  15. Source/WebCore/Target.pri | 4 ++--
  16. Source/WebCore/html/HTMLCanvasElement.cpp | 2 +-
  17. Source/WebCore/platform/graphics/ImageBuffer.h | 4 ++--
  18. .../platform/graphics/qt/ImageBufferDataQt.cpp | 11 +++++------
  19. .../platform/graphics/qt/ImageBufferDataQt.h | 7 ++++++-
  20. .../WebCore/platform/graphics/qt/ImageBufferQt.cpp | 4 ++++
  21. Tools/QtTestBrowser/launcherwindow.cpp | 8 ++++----
  22. Tools/QtTestBrowser/launcherwindow.h | 2 +-
  23. 8 files changed, 25 insertions(+), 17 deletions(-)
  24. diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri
  25. index b9167d1..d1aad9f 100644
  26. --- a/Source/WebCore/Target.pri
  27. +++ b/Source/WebCore/Target.pri
  28. @@ -2232,7 +2232,6 @@ HEADERS += \
  29. platform/graphics/RoundedRect.h \
  30. platform/graphics/qt/FontCustomPlatformData.h \
  31. platform/graphics/qt/NativeImageQt.h \
  32. - platform/graphics/qt/QFramebufferPaintDevice.h \
  33. platform/graphics/qt/StillImageQt.h \
  34. platform/graphics/qt/TransparencyLayer.h \
  35. platform/graphics/SegmentedFontData.h \
  36. @@ -2886,7 +2885,6 @@ SOURCES += \
  37. platform/graphics/qt/IntPointQt.cpp \
  38. platform/graphics/qt/IntRectQt.cpp \
  39. platform/graphics/qt/IntSizeQt.cpp \
  40. - platform/graphics/qt/QFramebufferPaintDevice.cpp \
  41. platform/graphics/qt/PathQt.cpp \
  42. platform/graphics/qt/PatternQt.cpp \
  43. platform/graphics/qt/StillImageQt.cpp \
  44. @@ -4146,6 +4144,7 @@ use?(3D_GRAPHICS) {
  45. platform/graphics/gpu/Texture.h \
  46. platform/graphics/gpu/TilingData.h \
  47. platform/graphics/opengl/Extensions3DOpenGL.h \
  48. + platform/graphics/qt/QFramebufferPaintDevice.h \
  49. platform/graphics/texmap/TextureMapperGL.h \
  50. platform/graphics/texmap/TextureMapperShaderProgram.h \
  51. platform/graphics/texmap/coordinated/AreaAllocator.h \
  52. @@ -4182,6 +4181,7 @@ use?(3D_GRAPHICS) {
  53. platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp \
  54. platform/graphics/opengl/Extensions3DOpenGLCommon.cpp \
  55. platform/graphics/qt/GraphicsContext3DQt.cpp \
  56. + platform/graphics/qt/QFramebufferPaintDevice.cpp \
  57. platform/graphics/texmap/TextureMapperGL.cpp \
  58. platform/graphics/texmap/TextureMapperShaderProgram.cpp \
  59. platform/graphics/texmap/coordinated/AreaAllocator.cpp \
  60. diff --git a/Source/WebCore/html/HTMLCanvasElement.cpp b/Source/WebCore/html/HTMLCanvasElement.cpp
  61. index b856234..ae39959 100644
  62. --- a/Source/WebCore/html/HTMLCanvasElement.cpp
  63. +++ b/Source/WebCore/html/HTMLCanvasElement.cpp
  64. @@ -586,7 +586,7 @@ void HTMLCanvasElement::createImageBuffer() const
  65. return;
  66. RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated : Unaccelerated;
  67. -#if PLATFORM(QT)
  68. +#if PLATFORM(QT) && ENABLE(ACCELERATED_2D_CANVAS)
  69. if (renderingMode == Accelerated) {
  70. QWebPageClient* client = document()->page()->chrome().platformPageClient();
  71. // The WebKit2 Chrome does not have a pageclient.
  72. diff --git a/Source/WebCore/platform/graphics/ImageBuffer.h b/Source/WebCore/platform/graphics/ImageBuffer.h
  73. index 7addde9..a30d052 100644
  74. --- a/Source/WebCore/platform/graphics/ImageBuffer.h
  75. +++ b/Source/WebCore/platform/graphics/ImageBuffer.h
  76. @@ -95,7 +95,7 @@ namespace WebCore {
  77. }
  78. static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, float resolutionScale, ColorSpace, const GraphicsContext*, bool hasAlpha);
  79. -#if PLATFORM(QT)
  80. +#if PLATFORM(QT) && ENABLE(ACCELERATED_2D_CANVAS)
  81. static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, float resolutionScale, ColorSpace, QOpenGLContext*);
  82. #endif
  83. @@ -165,7 +165,7 @@ namespace WebCore {
  84. // This constructor will place its success into the given out-variable
  85. // so that create() knows when it should return failure.
  86. ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, RenderingMode, bool& success);
  87. -#if PLATFORM(QT)
  88. +#if PLATFORM(QT) && ENABLE(ACCELERATED_2D_CANVAS)
  89. ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, QOpenGLContext*, bool& success);
  90. #endif
  91. };
  92. diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp
  93. index 4a16515..1235ce6 100644
  94. --- a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp
  95. +++ b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp
  96. @@ -34,7 +34,6 @@
  97. #include "GraphicsSurface.h"
  98. #include "ImageData.h"
  99. #include "StillImageQt.h"
  100. -#include "QFramebufferPaintDevice.h"
  101. #include <QImage>
  102. #include <QPaintEngine>
  103. @@ -42,6 +41,7 @@
  104. #include <QPixmap>
  105. #if ENABLE(ACCELERATED_2D_CANVAS)
  106. +#include "QFramebufferPaintDevice.h"
  107. #include "TextureMapper.h"
  108. #include "TextureMapperPlatformLayer.h"
  109. #include "TextureMapperGL.h"
  110. @@ -483,16 +483,12 @@ ImageBufferData::ImageBufferData(const IntSize& size)
  111. initPainter();
  112. }
  113. +#if ENABLE(ACCELERATED_2D_CANVAS)
  114. ImageBufferData::ImageBufferData(const IntSize& size, QOpenGLContext* compatibleContext)
  115. {
  116. m_painter = new QPainter;
  117. -#if ENABLE(ACCELERATED_2D_CANVAS)
  118. m_impl = new ImageBufferDataPrivateAccelerated(size, compatibleContext);
  119. -#else
  120. - Q_UNUSED(compatibleContext);
  121. - m_impl = new ImageBufferDataPrivateUnaccelerated(size);
  122. -#endif
  123. if (!m_impl->paintDevice())
  124. return;
  125. @@ -501,11 +497,14 @@ ImageBufferData::ImageBufferData(const IntSize& size, QOpenGLContext* compatible
  126. initPainter();
  127. }
  128. +#endif
  129. ImageBufferData::~ImageBufferData()
  130. {
  131. +#if ENABLE(ACCELERATED_2D_CANVAS)
  132. if (m_impl->isAccelerated())
  133. static_cast<QFramebufferPaintDevice*>(m_impl->paintDevice())->ensureActiveTarget();
  134. +#endif
  135. m_painter->end();
  136. delete m_painter;
  137. delete m_impl;
  138. diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
  139. index 486b0d5..fcad887 100644
  140. --- a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
  141. +++ b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.h
  142. @@ -29,10 +29,13 @@
  143. #include "Image.h"
  144. #include <QImage>
  145. -#include <QOpenGLContext>
  146. #include <QPainter>
  147. #include <QPaintDevice>
  148. +#if ENABLE(ACCELERATED_2D_CANVAS)
  149. +#include <QOpenGLContext>
  150. +#endif
  151. +
  152. #include <wtf/RefPtr.h>
  153. namespace WebCore {
  154. @@ -61,7 +64,9 @@ class ImageBufferData
  155. {
  156. public:
  157. ImageBufferData(const IntSize&);
  158. +#if ENABLE(ACCELERATED_2D_CANVAS)
  159. ImageBufferData(const IntSize&, QOpenGLContext*);
  160. +#endif
  161. ~ImageBufferData();
  162. QPainter* m_painter;
  163. ImageBufferDataPrivate* m_impl;
  164. diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
  165. index 400743d..09c90a6 100644
  166. --- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
  167. +++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
  168. @@ -47,6 +47,7 @@
  169. namespace WebCore {
  170. +#if ENABLE(ACCELERATED_2D_CANVAS)
  171. ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, QOpenGLContext* compatibleContext, bool& success)
  172. : m_data(size, compatibleContext)
  173. , m_size(size)
  174. @@ -58,6 +59,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, Color
  175. m_context = adoptPtr(new GraphicsContext(m_data.m_painter));
  176. }
  177. +#endif
  178. ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode /*renderingMode*/, bool& success)
  179. : m_data(size)
  180. @@ -75,6 +77,7 @@ ImageBuffer::~ImageBuffer()
  181. {
  182. }
  183. +#if ENABLE(ACCELERATED_2D_CANVAS)
  184. PassOwnPtr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const IntSize& size, float resolutionScale, ColorSpace colorSpace, QOpenGLContext* context)
  185. {
  186. bool success = false;
  187. @@ -83,6 +86,7 @@ PassOwnPtr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const IntSize& size,
  188. return nullptr;
  189. return buf.release();
  190. }
  191. +#endif
  192. GraphicsContext* ImageBuffer::context() const
  193. {
  194. diff --git a/Tools/QtTestBrowser/launcherwindow.cpp b/Tools/QtTestBrowser/launcherwindow.cpp
  195. index e2dcef3..d293397 100644
  196. --- a/Tools/QtTestBrowser/launcherwindow.cpp
  197. +++ b/Tools/QtTestBrowser/launcherwindow.cpp
  198. @@ -177,9 +177,9 @@ void LauncherWindow::initializeView()
  199. #ifndef QT_NO_OPENGL
  200. if (!m_windowOptions.useQOpenGLWidgetViewport)
  201. toggleQGLWidgetViewport(m_windowOptions.useQGLWidgetViewport);
  202. -#endif
  203. if (!m_windowOptions.useQGLWidgetViewport)
  204. toggleQOpenGLWidgetViewport(m_windowOptions.useQOpenGLWidgetViewport);
  205. +#endif
  206. view->setPage(page());
  207. connect(view, SIGNAL(currentFPSUpdated(int)), this, SLOT(updateFPS(int)));
  208. @@ -407,7 +407,6 @@ void LauncherWindow::createChrome()
  209. toggleQGLWidgetViewport->setChecked(m_windowOptions.useQGLWidgetViewport);
  210. toggleQGLWidgetViewport->setEnabled(isGraphicsBased());
  211. toggleQGLWidgetViewport->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool)));
  212. -#endif
  213. #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
  214. QAction* toggleQOpenGLWidgetViewport = graphicsViewMenu->addAction("Toggle use of QOpenGLWidget Viewport", this, SLOT(toggleQOpenGLWidgetViewport(bool)));
  215. toggleQOpenGLWidgetViewport->setCheckable(true);
  216. @@ -415,6 +414,7 @@ void LauncherWindow::createChrome()
  217. toggleQOpenGLWidgetViewport->setEnabled(isGraphicsBased());
  218. toggleQOpenGLWidgetViewport->connect(toggleGraphicsView, SIGNAL(toggled(bool)), SLOT(setEnabled(bool)));
  219. #endif
  220. +#endif
  221. QMenu* viewportUpdateMenu = graphicsViewMenu->addMenu("Change Viewport Update Mode");
  222. viewportUpdateMenu->setEnabled(isGraphicsBased());
  223. @@ -802,9 +802,9 @@ void LauncherWindow::screenshot()
  224. #ifndef QT_NO_OPENGL
  225. if (!m_windowOptions.useQOpenGLWidgetViewport)
  226. toggleQGLWidgetViewport(m_windowOptions.useQGLWidgetViewport);
  227. -#endif
  228. if (!m_windowOptions.useQGLWidgetViewport)
  229. toggleQOpenGLWidgetViewport(m_windowOptions.useQOpenGLWidgetViewport);
  230. +#endif
  231. }
  232. void LauncherWindow::setEditable(bool on)
  233. @@ -997,7 +997,6 @@ void LauncherWindow::toggleQGLWidgetViewport(bool enable)
  234. WebViewGraphicsBased* view = static_cast<WebViewGraphicsBased*>(m_view);
  235. view->setViewport(enable ? new QGLWidget() : 0);
  236. }
  237. -#endif
  238. void LauncherWindow::toggleQOpenGLWidgetViewport(bool enable)
  239. {
  240. @@ -1013,6 +1012,7 @@ void LauncherWindow::toggleQOpenGLWidgetViewport(bool enable)
  241. view->setViewport(enable ? new QOpenGLWidget() : 0);
  242. #endif
  243. }
  244. +#endif
  245. void LauncherWindow::changeViewportUpdateMode(int mode)
  246. {
  247. diff --git a/Tools/QtTestBrowser/launcherwindow.h b/Tools/QtTestBrowser/launcherwindow.h
  248. index c470a5a..5cee7e5 100644
  249. --- a/Tools/QtTestBrowser/launcherwindow.h
  250. +++ b/Tools/QtTestBrowser/launcherwindow.h
  251. @@ -180,8 +180,8 @@ protected Q_SLOTS:
  252. #endif
  253. #ifndef QT_NO_OPENGL
  254. void toggleQGLWidgetViewport(bool enable);
  255. -#endif
  256. void toggleQOpenGLWidgetViewport(bool enable);
  257. +#endif
  258. void changeViewportUpdateMode(int mode);
  259. void animatedFlip();
  260. --
  261. 1.7.1