QA for #20620 - Make renderGrid handle changing position and dimensions
Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 2 files). Show all
Unified · Split
| @@ -392,7 +392,6 @@ void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, in · 391 unmodified lines | |||
| 392 | gpu::GLBackend::renderBatch(batch); | 392 | gpu::GLBackend::renderBatch(batch); |
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | // TODO: properly handle the x,y,w,h changing for an ID | ||
| 396 | // TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that?? | 395 | // TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that?? |
| 397 | void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { | 396 | void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { |
| 398 | #ifdef WANT_DEBUG | 397 | #ifdef WANT_DEBUG |
| @@ -410,8 +409,23 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h · 11 unmodified lines | |||
| 410 | Vec3Pair colorKey(glm::vec3(color.x, color.y, rows), glm::vec3(color.z, color.y, cols)); | 409 | Vec3Pair colorKey(glm::vec3(color.x, color.y, rows), glm::vec3(color.z, color.y, cols)); |
| 411 | 410 | ||
| 412 | int vertices = (cols + 1 + rows + 1) * 2; | 411 | int vertices = (cols + 1 + rows + 1) * 2; |
| 413 | if ((registered && !_registeredAlternateGridBuffers.contains(id)) || (!registered && !_alternateGridBuffers.contains(key))) { | 412 | if ((registered && (!_registeredAlternateGridBuffers.contains(id) || _lastRegisteredAlternateGridBuffers[id] != key)) |
| 413 | || (!registered && !_alternateGridBuffers.contains(key))) { | ||
| 414 | |||
| 415 | if (registered && _registeredAlternateGridBuffers.contains(id)) { | ||
| 416 | _registeredAlternateGridBuffers[id].reset(); | ||
| 417 | #ifdef WANT_DEBUG | ||
| 418 | qCDebug(renderutils) << "renderGrid()... RELEASING REGISTERED VERTICES BUFFER"; | ||
| 419 | #endif | ||
| 420 | } | ||
| 421 | |||
| 414 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 422 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); |
| 423 | if (registered) { | ||
| 424 | _registeredAlternateGridBuffers[id] = verticesBuffer; | ||
| 425 | _lastRegisteredAlternateGridBuffers[id] = key; | ||
| 426 | } else { | ||
| 427 | _alternateGridBuffers[key] = verticesBuffer; | ||
| 428 | } | ||
| 415 | 429 | ||
| 416 | GLfloat* vertexData = new GLfloat[vertices * 2]; | 430 | GLfloat* vertexData = new GLfloat[vertices * 2]; |
| 417 | GLfloat* vertex = vertexData; | 431 | GLfloat* vertex = vertexData; |
| @@ -445,12 +459,6 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h · 27 unmodified lines | |||
| 445 | 459 | ||
| 446 | verticesBuffer->append(sizeof(GLfloat) * vertices * 2, (gpu::Byte*) vertexData); | 460 | verticesBuffer->append(sizeof(GLfloat) * vertices * 2, (gpu::Byte*) vertexData); |
| 447 | delete[] vertexData; | 461 | delete[] vertexData; |
| 448 | |||
| 449 | if (registered) { | ||
| 450 | _registeredAlternateGridBuffers[id] = verticesBuffer; | ||
| 451 | } else { | ||
| 452 | _alternateGridBuffers[key] = verticesBuffer; | ||
| 453 | } | ||
| 454 | } | 462 | } |
| 455 | 463 | ||
| 456 | if (!_gridColors.contains(colorKey)) { | 464 | if (!_gridColors.contains(colorKey)) { |