Fix clipRect interpretation in composited backingstores
Empty clipRect means "clip away completely", not "no clipping". Task-number: QTBUG-50719 Change-Id: I6a9dd66130716a921fe9fc245582274e3c9718fe Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
This commit is contained in:
parent
758b7b0d88
commit
920472c85f
src
tests/manual/qopenglwidget/openglwidget
@ -263,12 +263,14 @@ static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
|
||||
static void blitTextureForWidget(const QPlatformTextureList *textures, int idx, QWindow *window, const QRect &deviceWindowRect,
|
||||
QOpenGLTextureBlitter *blitter, const QPoint &offset)
|
||||
{
|
||||
const QRect clipRect = textures->clipRect(idx);
|
||||
if (clipRect.isEmpty())
|
||||
return;
|
||||
|
||||
QRect rectInWindow = textures->geometry(idx);
|
||||
// relative to the TLW, not necessarily our window (if the flush is for a native child widget), have to adjust
|
||||
rectInWindow.translate(-offset);
|
||||
QRect clipRect = textures->clipRect(idx);
|
||||
if (clipRect.isEmpty())
|
||||
clipRect = QRect(QPoint(0, 0), rectInWindow.size());
|
||||
|
||||
const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
|
||||
const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
|
||||
|
||||
|
@ -177,11 +177,11 @@ static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
|
||||
|
||||
static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRect &targetWindowRect, QOpenGLTextureBlitter *blitter)
|
||||
{
|
||||
const QRect rectInWindow = textures->geometry(idx);
|
||||
QRect clipRect = textures->clipRect(idx);
|
||||
const QRect clipRect = textures->clipRect(idx);
|
||||
if (clipRect.isEmpty())
|
||||
clipRect = QRect(QPoint(0, 0), rectInWindow.size());
|
||||
return;
|
||||
|
||||
const QRect rectInWindow = textures->geometry(idx);
|
||||
const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
|
||||
const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
|
||||
|
||||
|
@ -181,6 +181,13 @@ int main(int argc, char *argv[])
|
||||
glw3->setObjectName("GL widget in scroll area (possibly native)");
|
||||
glw3->setFormat(format);
|
||||
glw3->setFixedSize(600, 600);
|
||||
OpenGLWidget *glw3child = new OpenGLWidget(0);
|
||||
const float glw3ClearColor[] = { 0.5f, 0.2f, 0.8f };
|
||||
glw3child->setClearColor(glw3ClearColor);
|
||||
glw3child->setObjectName("Child widget of GL Widget in scroll area");
|
||||
glw3child->setFormat(format);
|
||||
glw3child->setParent(glw3);
|
||||
glw3child->setGeometry(500, 500, 100, 100); // lower right corner of parent
|
||||
QScrollArea *sa = new QScrollArea;
|
||||
sa->setWidget(glw3);
|
||||
sa->setMinimumSize(100, 100);
|
||||
|
@ -78,6 +78,8 @@ public:
|
||||
|
||||
int m_interval;
|
||||
QVector3D m_rotAxis;
|
||||
|
||||
float clearColor[3];
|
||||
};
|
||||
|
||||
|
||||
@ -85,6 +87,7 @@ OpenGLWidget::OpenGLWidget(int interval, const QVector3D &rotAxis, QWidget *pare
|
||||
: QOpenGLWidget(parent)
|
||||
{
|
||||
d.reset(new OpenGLWidgetPrivate(this));
|
||||
d->clearColor[0] = d->clearColor[1] = d->clearColor[2] = 0.0f;
|
||||
d->m_interval = interval;
|
||||
d->m_rotAxis = rotAxis;
|
||||
if (interval > 0) {
|
||||
@ -151,7 +154,7 @@ void OpenGLWidgetPrivate::render()
|
||||
const qreal retinaScale = q->devicePixelRatio();
|
||||
glViewport(0, 0, width() * retinaScale, height() * retinaScale);
|
||||
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClearColor(clearColor[0], clearColor[1], clearColor[2], 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
m_program->bind();
|
||||
@ -194,3 +197,10 @@ void OpenGLWidgetPrivate::render()
|
||||
if (m_interval <= 0)
|
||||
q->update();
|
||||
}
|
||||
|
||||
void OpenGLWidget::setClearColor(const float *c)
|
||||
{
|
||||
d->clearColor[0] = c[0];
|
||||
d->clearColor[1] = c[1];
|
||||
d->clearColor[2] = c[2];
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
void resizeGL(int w, int h);
|
||||
void paintGL();
|
||||
|
||||
void setClearColor(const float *c);
|
||||
|
||||
private:
|
||||
QScopedPointer<OpenGLWidgetPrivate> d;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user