1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2021 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 
17 #include "../Vulkan.hpp"
18 #include "../Color.hpp"
19 
20 #include "SubWidgetPrivateData.hpp"
21 #include "TopLevelWidgetPrivateData.hpp"
22 #include "WidgetPrivateData.hpp"
23 #include "WindowPrivateData.hpp"
24 
25 START_NAMESPACE_DGL
26 
27 // -----------------------------------------------------------------------
28 
notImplemented(const char * const name)29 static void notImplemented(const char* const name)
30 {
31     d_stderr2("vulkan function not implemented: %s", name);
32 }
33 
34 // -----------------------------------------------------------------------
35 // Color
36 
setFor(const GraphicsContext &,bool)37 void Color::setFor(const GraphicsContext&, bool)
38 {
39     notImplemented("Color::setFor");
40 }
41 
42 // -----------------------------------------------------------------------
43 // Line
44 
45 template<typename T>
draw(const GraphicsContext &,T)46 void Line<T>::draw(const GraphicsContext&, T)
47 {
48     notImplemented("Line::draw");
49 }
50 
51 template<typename T>
draw()52 void Line<T>::draw()
53 {
54     notImplemented("Line::draw");
55 }
56 
57 template class Line<double>;
58 template class Line<float>;
59 template class Line<int>;
60 template class Line<uint>;
61 template class Line<short>;
62 template class Line<ushort>;
63 
64 // -----------------------------------------------------------------------
65 // Circle
66 
67 template<typename T>
draw(const GraphicsContext &)68 void Circle<T>::draw(const GraphicsContext&)
69 {
70     notImplemented("Circle::draw");
71 }
72 
73 template<typename T>
drawOutline(const GraphicsContext &,T)74 void Circle<T>::drawOutline(const GraphicsContext&, T)
75 {
76     notImplemented("Circle::drawOutline");
77 }
78 
79 template<typename T>
draw()80 void Circle<T>::draw()
81 {
82     notImplemented("Circle::draw");
83 }
84 
85 template<typename T>
drawOutline()86 void Circle<T>::drawOutline()
87 {
88     notImplemented("Circle::drawOutline");
89 }
90 
91 template class Circle<double>;
92 template class Circle<float>;
93 template class Circle<int>;
94 template class Circle<uint>;
95 template class Circle<short>;
96 template class Circle<ushort>;
97 
98 // -----------------------------------------------------------------------
99 // Triangle
100 
101 template<typename T>
draw(const GraphicsContext &)102 void Triangle<T>::draw(const GraphicsContext&)
103 {
104     notImplemented("Triangle::draw");
105 }
106 
107 template<typename T>
drawOutline(const GraphicsContext &,T)108 void Triangle<T>::drawOutline(const GraphicsContext&, T)
109 {
110     notImplemented("Triangle::drawOutline");
111 }
112 
113 template<typename T>
draw()114 void Triangle<T>::draw()
115 {
116     notImplemented("Triangle::draw");
117 }
118 
119 template<typename T>
drawOutline()120 void Triangle<T>::drawOutline()
121 {
122     notImplemented("Triangle::drawOutline");
123 }
124 
125 template class Triangle<double>;
126 template class Triangle<float>;
127 template class Triangle<int>;
128 template class Triangle<uint>;
129 template class Triangle<short>;
130 template class Triangle<ushort>;
131 
132 
133 // -----------------------------------------------------------------------
134 // Rectangle
135 
136 template<typename T>
draw(const GraphicsContext &)137 void Rectangle<T>::draw(const GraphicsContext&)
138 {
139     notImplemented("Rectangle::draw");
140 }
141 
142 template<typename T>
drawOutline(const GraphicsContext &,T)143 void Rectangle<T>::drawOutline(const GraphicsContext&, T)
144 {
145     notImplemented("Rectangle::drawOutline");
146 }
147 
148 template<typename T>
draw()149 void Rectangle<T>::draw()
150 {
151     notImplemented("Rectangle::draw");
152 }
153 
154 template<typename T>
drawOutline()155 void Rectangle<T>::drawOutline()
156 {
157     notImplemented("Rectangle::drawOutline");
158 }
159 
160 template class Rectangle<double>;
161 template class Rectangle<float>;
162 template class Rectangle<int>;
163 template class Rectangle<uint>;
164 template class Rectangle<short>;
165 template class Rectangle<ushort>;
166 
167 // -----------------------------------------------------------------------
168 // VulkanImage
169 
VulkanImage()170 VulkanImage::VulkanImage()
171     : ImageBase() {}
172 
VulkanImage(const char * const rdata,const uint w,const uint h,const ImageFormat fmt)173 VulkanImage::VulkanImage(const char* const rdata, const uint w, const uint h, const ImageFormat fmt)
174     : ImageBase(rdata, w, h, fmt) {}
175 
VulkanImage(const char * const rdata,const Size<uint> & s,const ImageFormat fmt)176 VulkanImage::VulkanImage(const char* const rdata, const Size<uint>& s, const ImageFormat fmt)
177     : ImageBase(rdata, s, fmt) {}
178 
VulkanImage(const VulkanImage & image)179 VulkanImage::VulkanImage(const VulkanImage& image)
180     : ImageBase(image.rawData, image.size, image.format) {}
181 
~VulkanImage()182 VulkanImage::~VulkanImage() {}
183 
loadFromMemory(const char * const rdata,const Size<uint> & s,const ImageFormat fmt)184 void VulkanImage::loadFromMemory(const char* const rdata, const Size<uint>& s, const ImageFormat fmt) noexcept
185 {
186     ImageBase::loadFromMemory(rdata, s, fmt);
187 }
188 
drawAt(const GraphicsContext &,const Point<int> &)189 void VulkanImage::drawAt(const GraphicsContext&, const Point<int>&)
190 {
191 }
192 
operator =(const VulkanImage & image)193 VulkanImage& VulkanImage::operator=(const VulkanImage& image) noexcept
194 {
195     rawData = image.rawData;
196     size    = image.size;
197     format  = image.format;
198     return *this;
199 }
200 
201 // -----------------------------------------------------------------------
202 
display(const uint width,const uint height,const double autoScaleFactor)203 void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor)
204 {
205     // TODO
206 
207     selfw->pData->displaySubWidgets(width, height, autoScaleFactor);
208 }
209 
210 // -----------------------------------------------------------------------
211 
display()212 void TopLevelWidget::PrivateData::display()
213 {
214     if (! selfw->pData->visible)
215         return;
216 
217     const Size<uint> size(window.getSize());
218     const uint width  = size.getWidth();
219     const uint height = size.getHeight();
220 
221     const double autoScaleFactor = window.pData->autoScaleFactor;
222 
223     // TODO
224 
225     // main widget drawing
226     self->onDisplay();
227 
228     // now draw subwidgets if there are any
229     selfw->pData->displaySubWidgets(width, height, autoScaleFactor);
230 }
231 
232 // -----------------------------------------------------------------------
233 
getGraphicsContext() const234 const GraphicsContext& Window::PrivateData::getGraphicsContext() const noexcept
235 {
236     return (const GraphicsContext&)graphicsContext;
237 }
238 
239 // -----------------------------------------------------------------------
240 
241 END_NAMESPACE_DGL
242 
243 // -----------------------------------------------------------------------
244