DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

325 lines
8.2KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2026 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifdef _MSC_VER
  17. // instantiated template classes whose methods are defined elsewhere
  18. # pragma warning(disable:4661)
  19. #endif
  20. #include "../Vulkan.hpp"
  21. #include "../Color.hpp"
  22. #include "../ImageBaseWidgets.hpp"
  23. #include "SubWidgetPrivateData.hpp"
  24. #include "TopLevelWidgetPrivateData.hpp"
  25. #include "WidgetPrivateData.hpp"
  26. #include "WindowPrivateData.hpp"
  27. START_NAMESPACE_DGL
  28. // --------------------------------------------------------------------------------------------------------------------
  29. // Check for correct build config
  30. #ifndef DGL_VULKAN
  31. # error Build config error, Vulkan was NOT requested while building Vulkan code
  32. #endif
  33. #ifdef DGL_CAIRO
  34. # error Build config error, Cairo requested while building Vulkan code
  35. #endif
  36. #ifdef DGL_OPENGL
  37. # error Build config error, OpenGL requested while building Vulkan code
  38. #endif
  39. #ifdef DGL_USE_GLES2
  40. # error Build config error, GLESv2 requested while building Vulkan code
  41. #endif
  42. #ifdef DGL_USE_GLES3
  43. # error Build config error, GLESv3 requested while building Vulkan code
  44. #endif
  45. #ifdef DGL_USE_OPENGL3
  46. # error Build config error, OpenGL3 requested while building Vulkan code
  47. #endif
  48. // --------------------------------------------------------------------------------------------------------------------
  49. static void notImplemented(const char* const name)
  50. {
  51. d_stderr2("Vulkan function not implemented: %s", name);
  52. }
  53. // --------------------------------------------------------------------------------------------------------------------
  54. // Color
  55. void Color::setFor(const GraphicsContext&, bool)
  56. {
  57. notImplemented("Color::setFor");
  58. }
  59. // -----------------------------------------------------------------------
  60. // Line
  61. template<typename T>
  62. void Line<T>::draw(const GraphicsContext&, T)
  63. {
  64. notImplemented("Line::draw");
  65. }
  66. #if DGL_ALLOW_DEPRECATED_METHODS
  67. template<typename T>
  68. void Line<T>::draw()
  69. {
  70. notImplemented("Line::draw");
  71. }
  72. #endif
  73. template class Line<double>;
  74. template class Line<float>;
  75. template class Line<int>;
  76. template class Line<uint>;
  77. template class Line<short>;
  78. template class Line<ushort>;
  79. // -----------------------------------------------------------------------
  80. // Circle
  81. template<typename T>
  82. void Circle<T>::draw(const GraphicsContext&)
  83. {
  84. notImplemented("Circle::draw");
  85. }
  86. template<typename T>
  87. void Circle<T>::drawOutline(const GraphicsContext&, T)
  88. {
  89. notImplemented("Circle::drawOutline");
  90. }
  91. #if DGL_ALLOW_DEPRECATED_METHODS
  92. template<typename T>
  93. void Circle<T>::draw()
  94. {
  95. notImplemented("Circle::draw");
  96. }
  97. template<typename T>
  98. void Circle<T>::drawOutline()
  99. {
  100. notImplemented("Circle::drawOutline");
  101. }
  102. #endif
  103. template class Circle<double>;
  104. template class Circle<float>;
  105. template class Circle<int>;
  106. template class Circle<uint>;
  107. template class Circle<short>;
  108. template class Circle<ushort>;
  109. // -----------------------------------------------------------------------
  110. // Triangle
  111. template<typename T>
  112. void Triangle<T>::draw(const GraphicsContext&)
  113. {
  114. notImplemented("Triangle::draw");
  115. }
  116. template<typename T>
  117. void Triangle<T>::drawOutline(const GraphicsContext&, T)
  118. {
  119. notImplemented("Triangle::drawOutline");
  120. }
  121. #if DGL_ALLOW_DEPRECATED_METHODS
  122. template<typename T>
  123. void Triangle<T>::draw()
  124. {
  125. notImplemented("Triangle::draw");
  126. }
  127. template<typename T>
  128. void Triangle<T>::drawOutline()
  129. {
  130. notImplemented("Triangle::drawOutline");
  131. }
  132. #endif
  133. template class Triangle<double>;
  134. template class Triangle<float>;
  135. template class Triangle<int>;
  136. template class Triangle<uint>;
  137. template class Triangle<short>;
  138. template class Triangle<ushort>;
  139. // -----------------------------------------------------------------------
  140. // Rectangle
  141. template<typename T>
  142. void Rectangle<T>::draw(const GraphicsContext&)
  143. {
  144. notImplemented("Rectangle::draw");
  145. }
  146. template<typename T>
  147. void Rectangle<T>::drawOutline(const GraphicsContext&, T)
  148. {
  149. notImplemented("Rectangle::drawOutline");
  150. }
  151. #if DGL_ALLOW_DEPRECATED_METHODS
  152. template<typename T>
  153. void Rectangle<T>::draw()
  154. {
  155. notImplemented("Rectangle::draw");
  156. }
  157. #endif
  158. template<typename T>
  159. void Rectangle<T>::drawOutline()
  160. {
  161. notImplemented("Rectangle::drawOutline");
  162. }
  163. template class Rectangle<double>;
  164. template class Rectangle<float>;
  165. template class Rectangle<int>;
  166. template class Rectangle<uint>;
  167. template class Rectangle<short>;
  168. template class Rectangle<ushort>;
  169. // -----------------------------------------------------------------------
  170. // VulkanImage
  171. VulkanImage::VulkanImage()
  172. : ImageBase() {}
  173. VulkanImage::VulkanImage(const char* const rdata, const uint w, const uint h, const ImageFormat fmt)
  174. : ImageBase(rdata, w, h, fmt) {}
  175. VulkanImage::VulkanImage(const char* const rdata, const Size<uint>& s, const ImageFormat fmt)
  176. : ImageBase(rdata, s, fmt) {}
  177. VulkanImage::VulkanImage(const VulkanImage& image)
  178. : ImageBase(image.rawData, image.size, image.format) {}
  179. VulkanImage::~VulkanImage() {}
  180. void VulkanImage::loadFromMemory(const char* const rdata, const Size<uint>& s, const ImageFormat fmt) noexcept
  181. {
  182. ImageBase::loadFromMemory(rdata, s, fmt);
  183. }
  184. void VulkanImage::drawAt(const GraphicsContext&, const Point<int>&)
  185. {
  186. }
  187. VulkanImage& VulkanImage::operator=(const VulkanImage& image) noexcept
  188. {
  189. rawData = image.rawData;
  190. size = image.size;
  191. format = image.format;
  192. return *this;
  193. }
  194. // -----------------------------------------------------------------------
  195. void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor)
  196. {
  197. // TODO
  198. selfw->pData->displaySubWidgets(width, height, autoScaleFactor);
  199. }
  200. // -----------------------------------------------------------------------
  201. void TopLevelWidget::PrivateData::display()
  202. {
  203. if (! selfw->pData->visible)
  204. return;
  205. const Size<uint> size(window.getSize());
  206. const uint width = size.getWidth();
  207. const uint height = size.getHeight();
  208. // TODO
  209. // main widget drawing
  210. self->onDisplay();
  211. // now draw subwidgets if there are any
  212. selfw->pData->displaySubWidgets(width, height, window.pData->autoScaleFactor);
  213. }
  214. // -----------------------------------------------------------------------
  215. void Window::PrivateData::renderToPicture(const char*, const GraphicsContext&, uint, uint)
  216. {
  217. notImplemented("Window::PrivateData::renderToPicture");
  218. }
  219. // -----------------------------------------------------------------------
  220. void Window::PrivateData::createContextIfNeeded()
  221. {
  222. }
  223. void Window::PrivateData::destroyContext()
  224. {
  225. }
  226. void Window::PrivateData::startContext()
  227. {
  228. }
  229. void Window::PrivateData::endContext()
  230. {
  231. }
  232. // --------------------------------------------------------------------------------------------------------------------
  233. #ifndef DGL_GEOMETRY_CPP_INCLUDED
  234. template class Line<double>;
  235. template class Line<float>;
  236. template class Line<int>;
  237. template class Line<uint>;
  238. template class Line<short>;
  239. template class Line<ushort>;
  240. template class Circle<double>;
  241. template class Circle<float>;
  242. template class Circle<int>;
  243. template class Circle<uint>;
  244. template class Circle<short>;
  245. template class Circle<ushort>;
  246. template class Triangle<double>;
  247. template class Triangle<float>;
  248. template class Triangle<int>;
  249. template class Triangle<uint>;
  250. template class Triangle<short>;
  251. template class Triangle<ushort>;
  252. template class Rectangle<double>;
  253. template class Rectangle<float>;
  254. template class Rectangle<int>;
  255. template class Rectangle<uint>;
  256. template class Rectangle<short>;
  257. template class Rectangle<ushort>;
  258. #endif
  259. // --------------------------------------------------------------------------------------------------------------------
  260. END_NAMESPACE_DGL