Browse Source

Fix fullviewport-drawing auto-scaling for Cairo

Signed-off-by: falkTX <falktx@falktx.com>
pull/309/head
falkTX 4 years ago
parent
commit
2e508c73e9
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 23 additions and 6 deletions
  1. +20
    -3
      dgl/src/Cairo.cpp
  2. +3
    -3
      dgl/src/OpenGL.cpp

+ 20
- 3
dgl/src/Cairo.cpp View File

@@ -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);
}


+ 3
- 3
dgl/src/OpenGL.cpp View File

@@ -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
{


Loading…
Cancel
Save