Commit 354c09da authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

add ability to use offscreen buffers for screen capture

This is a temporary fix for #18446. To make vtkSMViewProxy use offscreen
buffers for screen capture, we now support an environment variable
`PV_USE_OFFSCREEN_BUFFERS_FOR_IMAGE_CAPTURE`.
parent 3f5893af
......@@ -41,7 +41,8 @@
#include "vtkSmartPointer.h"
#include "vtkWindowToImageFilter.h"
#include <assert.h>
#include <cassert>
#include <cstdlib>
namespace vtkSMViewProxyNS
{
......@@ -122,6 +123,15 @@ private:
vtkStandardNewMacro(WindowToImageFilter);
};
namespace
{
static bool GetUseOffScreenBuffersEnvironmentFlag()
{
static bool flag = (getenv("PV_USE_OFFSCREEN_BUFFERS_FOR_IMAGE_CAPTURE") != nullptr);
return flag;
}
}
bool vtkSMViewProxy::TransparentBackground = false;
vtkStandardNewMacro(vtkSMViewProxy);
......@@ -596,6 +606,14 @@ vtkImageData* vtkSMViewProxy::CaptureWindowInternal(int magX, int magY)
int swapBuffers = renWin->GetSwapBuffers();
renWin->SwapBuffersOff();
const bool prevOB = renWin->GetUseOffScreenBuffers();
static bool use_offscreen_buffers_flag = ::GetUseOffScreenBuffersEnvironmentFlag();
if (use_offscreen_buffers_flag)
{
// see #18446 for why we need UseOffScreenBuffers.
renWin->SetUseOffScreenBuffers(true);
}
// this is needed to ensure that view gets setup correctly before go ahead to
// capture the image.
this->RenderForImageCapture();
......@@ -614,6 +632,10 @@ vtkImageData* vtkSMViewProxy::CaptureWindowInternal(int magX, int magY)
w2i->Update();
renWin->SetSwapBuffers(swapBuffers);
if (use_offscreen_buffers_flag)
{
renWin->SetUseOffScreenBuffers(prevOB);
}
vtkImageData* capture = vtkImageData::New();
capture->ShallowCopy(w2i->GetOutput());
......
......@@ -20,3 +20,4 @@ PV_PLUGIN_DEBUG | Prints debugging information when loading plugins into ParaVie
PV_PLUGIN_PATH | Directories containing plugins to be loaded on startup.
PV_SETTINGS_DEBUG | When set, debugging text will be printed out to assist developers debug settings.
QT_MAC_NO_NATIVE_MENUBAR | Qt flag to force the Qt menu bar rather than the native mac menu bar.
PV_USE_OFFSCREEN_BUFFERS_FOR_IMAGE_CAPTURE | A temporary environment variable which defined causes ParaView to use offscreen frame buffer when capturing images (see #18446). This may be removed in future without notice.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment