MCPcopy Create free account
hub / github.com/DISTRHO/DPF / display

Method display

dgl/src/OpenGL.cpp:160–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158// --------------------------------------------------------------------------------------------------------------------
159
160void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor)
161{
162 if (skipDrawing)
163 return;
164
165 bool needsDisableScissor = false;
166
167 if (needsViewportScaling)
168 {
169 // limit viewport to widget bounds
170 const int x = absolutePos.getX();
171 const int w = static_cast<int>(self->getWidth());
172 const int h = static_cast<int>(self->getHeight());
173
174 if (d_isNotZero(viewportScaleFactor) && d_isNotEqual(viewportScaleFactor, 1.0))
175 {
176 glViewport(x,
177 -d_roundToIntPositive(height * viewportScaleFactor - height + absolutePos.getY()),
178 d_roundToIntPositive(width * viewportScaleFactor),
179 d_roundToIntPositive(height * viewportScaleFactor));
180 }
181 else
182 {
183 const int y = static_cast<int>(height - self->getHeight()) - absolutePos.getY();
184 glViewport(x, y, w, h);
185 }
186 }
187 else if (needsFullViewportForDrawing || (absolutePos.isZero() && self->getSize() == Size<uint>(width, height)))
188 {
189 // full viewport size
190 glViewport(0, 0, static_cast<int>(width), static_cast<int>(height));
191 }
192 else
193 {
194 // set viewport pos
195 glViewport(d_roundToIntPositive(absolutePos.getX() * autoScaleFactor),
196 -d_roundToIntPositive(absolutePos.getY() * autoScaleFactor),
197 static_cast<int>(width),
198 static_cast<int>(height));
199
200 // then cut the outer bounds
201 glScissor(d_roundToIntPositive(absolutePos.getX() * autoScaleFactor),
202 d_roundToIntPositive(height - (static_cast<int>(self->getHeight()) + absolutePos.getY()) * autoScaleFactor),
203 d_roundToIntPositive(self->getWidth() * autoScaleFactor),
204 d_roundToIntPositive(self->getHeight() * autoScaleFactor));
205
206 glEnable(GL_SCISSOR_TEST);
207 needsDisableScissor = true;
208 }
209
210 // display widget
211 self->onDisplay();
212
213 if (needsDisableScissor)
214 glDisable(GL_SCISSOR_TEST);
215
216 selfw->pData->displaySubWidgets(width, height, autoScaleFactor);
217}

Callers

nothing calls this directly

Calls 9

d_isNotZeroFunction · 0.85
d_isNotEqualFunction · 0.85
d_roundToIntPositiveFunction · 0.85
isZeroMethod · 0.80
displaySubWidgetsMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45
getSizeMethod · 0.45
onDisplayMethod · 0.45

Tested by

no test coverage detected