DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 2e508c73e95ef50947e3ed6e941b67b1f6b5bed4
parent d70805175194e38dcec75503e4836fb105a5f695
Author: falkTX <falktx@falktx.com>
Date:   Sat, 14 Aug 2021 13:34:06 +0100

Fix fullviewport-drawing auto-scaling for Cairo

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdgl/src/Cairo.cpp | 23++++++++++++++++++++---
Mdgl/src/OpenGL.cpp | 6+++---
2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/dgl/src/Cairo.cpp b/dgl/src/Cairo.cpp @@ -735,9 +735,7 @@ void SubWidget::PrivateData::display(const uint width, const uint height, const { // full viewport size cairo_translate(handle, 0, 0); - - // no scaling - cairo_scale(handle, 1.0, 1.0); + cairo_scale(handle, autoScaleFactor, autoScaleFactor); } else { @@ -776,15 +774,34 @@ void TopLevelWidget::PrivateData::display() if (! selfw->pData->visible) return; + cairo_t* const handle = static_cast<const CairoGraphicsContext&>(self->getGraphicsContext()).handle; + const Size<uint> size(window.getSize()); const uint width = size.getWidth(); const uint height = size.getHeight(); const double autoScaleFactor = window.pData->autoScaleFactor; + cairo_matrix_t matrix; + cairo_get_matrix(handle, &matrix); + + // full viewport size + if (window.pData->autoScaling) + { + cairo_translate(handle, 0, 0); + cairo_scale(handle, autoScaleFactor, autoScaleFactor); + } + else + { + cairo_translate(handle, 0, 0); + cairo_scale(handle, 1.0, 1.0); + } + // main widget drawing self->onDisplay(); + cairo_set_matrix(handle, &matrix); + // now draw subwidgets if there are any selfw->pData->displaySubWidgets(width, height, autoScaleFactor); } diff --git a/dgl/src/OpenGL.cpp b/dgl/src/OpenGL.cpp @@ -649,9 +649,9 @@ void TopLevelWidget::PrivateData::display() if (window.pData->autoScaling) { glViewport(0, - -static_cast<int>(height * autoScaleFactor - height), - static_cast<int>(width * autoScaleFactor), - static_cast<int>(height * autoScaleFactor)); + -static_cast<int>(height * autoScaleFactor - height + 0.5), + static_cast<int>(width * autoScaleFactor + 0.5), + static_cast<int>(height * autoScaleFactor + 0.5)); } else {