Commit 94b42da8 authored by Ulf Hermann's avatar Ulf Hermann

Timeline: Make 0-width events visible again.

Events with duration == 0 were erroneously filtered out by the items
render pass. Also, we have to give them a very small width in order for
the "stretching" mechanism in the vertex shader to work.

Change-Id: Icb76168f0831547a3ca55ab79df7161736ed4dc4
Task-number: QTCREATORBUG-14446
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent 59da3a2b
......@@ -48,7 +48,7 @@ void main()
// Make very narrow events somewhat wider so that they don't collapse into 0 pixels
float scaledWidth = scale.x * rectSize.x;
float shift = sign(scaledWidth) * max(0.0, 3.0 - abs(scaledWidth)) * 0.0005;
float shift = sign(rectSize.x) * max(0.0, 3.0 - abs(scaledWidth)) * 0.0005;
gl_Position.x += shift;
// Ditto for events with very small height
......
......@@ -202,7 +202,7 @@ static void updateNodes(int from, int to, const TimelineModel *model,
for (int i = from; i < to; ++i) {
qint64 start = qMax(parentState->start(), model->startTime(i));
qint64 end = qMin(parentState->end(), model->startTime(i) + model->duration(i));
if (start >= end)
if (start > end)
continue;
float itemTop = (1.0 - model->relativeHeight(i)) * defaultRowHeight;
......@@ -230,7 +230,7 @@ static void updateNodes(int from, int to, const TimelineModel *model,
for (int i = from; i < to; ++i) {
qint64 start = qMax(parentState->start(), model->startTime(i));
qint64 end = qMin(parentState->end(), model->startTime(i) + model->duration(i));
if (start >= end)
if (start > end)
continue;
QColor color = model->color(i);
......@@ -238,7 +238,8 @@ static void updateNodes(int from, int to, const TimelineModel *model,
uchar green = color.green();
uchar blue = color.blue();
float itemWidth = (end - start) * parentState->scale();
float itemWidth = end > start ? (end - start) * parentState->scale() :
std::numeric_limits<float>::min();
float itemLeft = (start - parentState->start()) * parentState->scale();
// This has to be the exact same expression as above, to guarantee determinism.
......
......@@ -105,6 +105,8 @@ void DummyModel::loadData()
{
for (int i = 0; i < 10; ++i)
insert(i, 1, 1);
insert(5, 0, 10);
}
float DummyModel::relativeHeight(int index) const
......@@ -139,7 +141,7 @@ void tst_TimelineItemsRenderPass::update()
result = inst->update(&renderer, &parentState, 0, 0, 0, true, 1);
QCOMPARE(result, nullState);
result = inst->update(&renderer, &parentState, 0, 2, 8, true, 1);
result = inst->update(&renderer, &parentState, 0, 2, 9, true, 1);
QVERIFY(result != nullState);
QCOMPARE(result->expandedOverlay(), nullNode);
QCOMPARE(result->expandedOverlay(), nullNode);
......@@ -150,10 +152,10 @@ void tst_TimelineItemsRenderPass::update()
QSGGeometryNode *node = static_cast<QSGGeometryNode *>(result->expandedRows()[0]->firstChild());
QSGMaterial *material1 = node->material();
QVERIFY(material1 != 0);
QCOMPARE(node->geometry()->vertexCount(), 26);
QCOMPARE(node->geometry()->vertexCount(), 30);
node = static_cast<QSGGeometryNode *>(result->collapsedRows()[0]->firstChild());
QSGMaterial *material2 = node->material();
QCOMPARE(node->geometry()->vertexCount(), 26);
QCOMPARE(node->geometry()->vertexCount(), 30);
QVERIFY(material2 != 0);
QCOMPARE(material1->type(), material2->type());
QSGMaterialShader *shader1 = material1->createShader();
......@@ -165,17 +167,20 @@ void tst_TimelineItemsRenderPass::update()
delete shader1;
delete shader2;
result = inst->update(&renderer, &parentState, result, 0, 10, true, 1);
result = inst->update(&renderer, &parentState, result, 0, 11, true, 1);
QVERIFY(result != nullState);
QCOMPARE(result->expandedOverlay(), nullNode);
QCOMPARE(result->expandedOverlay(), nullNode);
QCOMPARE(result->expandedRows().count(), 1);
QCOMPARE(result->collapsedRows().count(), 1);
QCOMPARE(result->expandedRows()[0]->childCount(), 2);
QCOMPARE(result->collapsedRows()[0]->childCount(), 2);
node = static_cast<QSGGeometryNode *>(result->expandedRows()[0]->lastChild());
// 0-sized node starting at 8 may also be added. We don't test for this one.
QVERIFY(result->expandedRows()[0]->childCount() > 1);
QVERIFY(result->collapsedRows()[0]->childCount() > 1);
node = static_cast<QSGGeometryNode *>(result->expandedRows()[0]->childAtIndex(1));
QCOMPARE(node->geometry()->vertexCount(), 8);
node = static_cast<QSGGeometryNode *>(result->collapsedRows()[0]->lastChild());
node = static_cast<QSGGeometryNode *>(result->collapsedRows()[0]->childAtIndex(1));
QCOMPARE(node->geometry()->vertexCount(), 8);
model.setExpanded(true);
......
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