QOpenGLWidget: Do not recurse when calling grabFramebuffer() from paintGL()
Task-number: QTBUG-48450 Change-Id: I14b1ff40727f705d8b89371b4d3bb5d6adc139fe Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
This commit is contained in:
parent
e7ab9a1fb9
commit
e82e075e51
@ -559,7 +559,8 @@ public:
|
|||||||
flushPending(false),
|
flushPending(false),
|
||||||
paintDevice(0),
|
paintDevice(0),
|
||||||
updateBehavior(QOpenGLWidget::NoPartialUpdate),
|
updateBehavior(QOpenGLWidget::NoPartialUpdate),
|
||||||
requestedSamples(0)
|
requestedSamples(0),
|
||||||
|
inPaintGL(false)
|
||||||
{
|
{
|
||||||
requestedFormat = QSurfaceFormat::defaultFormat();
|
requestedFormat = QSurfaceFormat::defaultFormat();
|
||||||
}
|
}
|
||||||
@ -602,6 +603,7 @@ public:
|
|||||||
QSurfaceFormat requestedFormat;
|
QSurfaceFormat requestedFormat;
|
||||||
QOpenGLWidget::UpdateBehavior updateBehavior;
|
QOpenGLWidget::UpdateBehavior updateBehavior;
|
||||||
int requestedSamples;
|
int requestedSamples;
|
||||||
|
bool inPaintGL;
|
||||||
};
|
};
|
||||||
|
|
||||||
void QOpenGLWidgetPaintDevicePrivate::beginPaint()
|
void QOpenGLWidgetPaintDevicePrivate::beginPaint()
|
||||||
@ -823,7 +825,9 @@ void QOpenGLWidgetPrivate::invokeUserPaint()
|
|||||||
QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle();
|
QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle();
|
||||||
|
|
||||||
f->glViewport(0, 0, q->width() * q->devicePixelRatioF(), q->height() * q->devicePixelRatioF());
|
f->glViewport(0, 0, q->width() * q->devicePixelRatioF(), q->height() * q->devicePixelRatioF());
|
||||||
|
inPaintGL = true;
|
||||||
q->paintGL();
|
q->paintGL();
|
||||||
|
inPaintGL = false;
|
||||||
flushPending = true;
|
flushPending = true;
|
||||||
|
|
||||||
QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0;
|
QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0;
|
||||||
@ -870,7 +874,9 @@ QImage QOpenGLWidgetPrivate::grabFramebuffer()
|
|||||||
if (!initialized)
|
if (!initialized)
|
||||||
return QImage();
|
return QImage();
|
||||||
|
|
||||||
|
if (!inPaintGL)
|
||||||
render();
|
render();
|
||||||
|
|
||||||
resolveSamples();
|
resolveSamples();
|
||||||
q->makeCurrent();
|
q->makeCurrent();
|
||||||
QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), false, false);
|
QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), false, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user