Browse Source

Fix GL context issues when using ImageAboutWindow

Signed-off-by: falkTX <falktx@falktx.com>
pull/409/head
falkTX 3 years ago
parent
commit
241845f387
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 46 additions and 9 deletions
  1. +10
    -1
      dgl/StandaloneWindow.hpp
  2. +5
    -1
      dgl/Window.hpp
  3. +10
    -3
      dgl/src/ImageBaseWidgets.cpp
  4. +21
    -4
      dgl/src/Window.cpp

+ 10
- 1
dgl/StandaloneWindow.hpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -53,6 +53,15 @@ public:
sgc.done();
}

/**
Get a graphics context back again.
Called when a valid graphics context is needed outside the constructor.
*/
void reinit()
{
sgc.reinit();
}

/**
Overloaded functions to ensure they apply to the Window class.
*/


+ 5
- 1
dgl/Window.hpp View File

@@ -105,13 +105,17 @@ public:
/** Early context clearing, useful for standalone windows not created by you. */
void done();

/** Get a valid context back again. */
void reinit();

DISTRHO_DECLARE_NON_COPYABLE(ScopedGraphicsContext)
DISTRHO_PREVENT_HEAP_ALLOCATION

private:
Window& window;
Window::PrivateData* ppData;
Window::PrivateData* const ppData;
bool active;
bool reenter;
};

/**


+ 10
- 3
dgl/src/ImageBaseWidgets.cpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -61,13 +61,20 @@ void ImageBaseAboutWindow<ImageType>::setImage(const ImageType& image)
if (img == image)
return;

img = image;

if (image.isInvalid())
{
img = image;
return;
}

reinit();

img = image;

setSize(image.getSize());
setGeometryConstraints(image.getWidth(), image.getHeight(), true, true);

done();
}

template <class ImageType>


+ 21
- 4
dgl/src/Window.cpp View File

@@ -27,12 +27,16 @@ START_NAMESPACE_DGL
Window::ScopedGraphicsContext::ScopedGraphicsContext(Window& win)
: window(win),
ppData(nullptr),
active(puglBackendEnter(window.pData->view)) {}
active(puglBackendEnter(window.pData->view)),
reenter(false)
{
}

Window::ScopedGraphicsContext::ScopedGraphicsContext(Window& win, Window& transientWin)
: window(win),
ppData(transientWin.pData),
active(false)
active(false),
reenter(true)
{
puglBackendLeave(ppData->view);
active = puglBackendEnter(window.pData->view);
@@ -51,13 +55,26 @@ void Window::ScopedGraphicsContext::done()
active = false;
}

if (ppData != nullptr)
if (reenter)
{
reenter = false;
DISTRHO_SAFE_ASSERT_RETURN(ppData != nullptr,);

puglBackendEnter(ppData->view);
ppData = nullptr;
}
}

void Window::ScopedGraphicsContext::reinit()
{
DISTRHO_SAFE_ASSERT_RETURN(!active,);
DISTRHO_SAFE_ASSERT_RETURN(!reenter,);
DISTRHO_SAFE_ASSERT_RETURN(ppData != nullptr,);

reenter = true;
puglBackendLeave(ppData->view);
active = puglBackendEnter(window.pData->view);
}

// -----------------------------------------------------------------------
// Window



Loading…
Cancel
Save