From 69c03d902dc9385270e70d6282651f5e738d64b6 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Wed, 29 Jan 2020 15:34:03 -0700 Subject: [PATCH] Fix deadlock in rendering --- vtkm/rendering/TextRenderer.cxx | 54 +++++++++++++++++---------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/vtkm/rendering/TextRenderer.cxx b/vtkm/rendering/TextRenderer.cxx index 6eb1fb7c5..4e6742e03 100644 --- a/vtkm/rendering/TextRenderer.cxx +++ b/vtkm/rendering/TextRenderer.cxx @@ -230,33 +230,35 @@ void TextRenderer::RenderText(const vtkm::Matrix& transform using TextureCoordsArrayHandle = internal::RenderBitmapFontExecutor::TextureCoordsArrayHandle; ScreenCoordsArrayHandle screenCoords; TextureCoordsArrayHandle textureCoords; - screenCoords.Allocate(static_cast(text.length())); - textureCoords.Allocate(static_cast(text.length())); - ScreenCoordsArrayHandle::WritePortalType screenCoordsPortal = screenCoords.WritePortal(); - TextureCoordsArrayHandle::WritePortalType textureCoordsPortal = textureCoords.WritePortal(); - vtkm::Vec4f_32 charVertices, charUVs, charCoords; - for (std::size_t i = 0; i < text.length(); ++i) { - char c = text[i]; - char nextchar = (i < text.length() - 1) ? text[i + 1] : 0; - Font.GetCharPolygon(c, - fx, - fy, - charVertices[0], - charVertices[2], - charVertices[3], - charVertices[1], - charUVs[0], - charUVs[2], - charUVs[3], - charUVs[1], - nextchar); - charVertices = charVertices * scale; - vtkm::Id2 p0 = Canvas->GetScreenPoint(charVertices[0], charVertices[3], fz, transform); - vtkm::Id2 p1 = Canvas->GetScreenPoint(charVertices[2], charVertices[1], fz, transform); - charCoords = vtkm::Id4(p0[0], p1[1], p1[0], p0[1]); - screenCoordsPortal.Set(static_cast(i), charCoords); - textureCoordsPortal.Set(static_cast(i), charUVs); + screenCoords.Allocate(static_cast(text.length())); + textureCoords.Allocate(static_cast(text.length())); + ScreenCoordsArrayHandle::WritePortalType screenCoordsPortal = screenCoords.WritePortal(); + TextureCoordsArrayHandle::WritePortalType textureCoordsPortal = textureCoords.WritePortal(); + vtkm::Vec4f_32 charVertices, charUVs, charCoords; + for (std::size_t i = 0; i < text.length(); ++i) + { + char c = text[i]; + char nextchar = (i < text.length() - 1) ? text[i + 1] : 0; + Font.GetCharPolygon(c, + fx, + fy, + charVertices[0], + charVertices[2], + charVertices[3], + charVertices[1], + charUVs[0], + charUVs[2], + charUVs[3], + charUVs[1], + nextchar); + charVertices = charVertices * scale; + vtkm::Id2 p0 = Canvas->GetScreenPoint(charVertices[0], charVertices[3], fz, transform); + vtkm::Id2 p1 = Canvas->GetScreenPoint(charVertices[2], charVertices[1], fz, transform); + charCoords = vtkm::Id4(p0[0], p1[1], p1[0], p0[1]); + screenCoordsPortal.Set(static_cast(i), charCoords); + textureCoordsPortal.Set(static_cast(i), charUVs); + } } vtkm::cont::TryExecute(internal::RenderBitmapFontExecutor(screenCoords,