Re: How to optimize performance using DrawingContext to draw 10000 lines?
MeshGeometry is being used on our Window.cpp implementation (the Application Framework of the C++ SDK).
In the XAML, you need something like this:
You assign the MeshGeometry with something like this:
The geometry is filled this way in our code:
In the XAML, you need something like this:
Code: Select all
<Path x:Name="histCPU" Fill="{StaticResource Brush.CPU}" Stretch="None"/>
Code: Select all
Path* pathHistCPU = xaml->FindName<Path>("histCPU");
Ptr<MeshGeometry> geoHistCPU = *new MeshGeometry();
pathHistCPU->SetData(geoHistCPU);
Code: Select all
void Window::UpdateHistogram(uint16_t* data, float maxF, MeshGeometry* geometry) const
{
geometry->SetBounds(Rect(mHistSize));
float stepX = mHistSize.width / (NS_COUNTOF(mHistogramCPU) - 1);
float baseH = mHistSize.height;
float minH = baseH - 1.0f;
geometry->SetNumVertices(2 * NS_COUNTOF(mHistogramCPU));
Point* vertices = geometry->GetVertices();
for (uint32_t i = 0; i < NS_COUNTOF(mHistogramCPU); i++)
{
float x = i * stepX;
uint16_t f = data[(mHistPos + i) % NS_COUNTOF(mHistogramCPU)];
float h = minH - (f * minH / maxF);
vertices[2 * i] = Point(x, baseH);
vertices[2 * i + 1] = Point(x, h);
}
geometry->SetNumIndices(6 * (NS_COUNTOF(mHistogramCPU) - 1));
uint16_t* indices = geometry->GetIndices();
for (uint16_t i = 0; i < NS_COUNTOF(mHistogramCPU) - 1; i++)
{
indices[6 * i] = 2 * i;
indices[6 * i + 1] = 2 * i + 1;
indices[6 * i + 2] = 2 * i + 2;
indices[6 * i + 3] = 2 * i + 2;
indices[6 * i + 4] = 2 * i + 1;
indices[6 * i + 5] = 2 * i + 3;
}
geometry->Update();
}
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Hi,
Using meshGeometry with Path, we want to just draw the edge lines, if we set Path attributes as bellow there will draw nothing.
If we set Fill="Black", it will draw a black region on the screen.
And there is a DYNAMIC_VB_SIZE vertex bytes limit.
Using meshGeometry with Path, we want to just draw the edge lines, if we set Path attributes as bellow there will draw nothing.
Code: Select all
<Path Fill="Transparent" Stretch="None" Stroke="Black" StrokeThickness="1"/>
And there is a DYNAMIC_VB_SIZE vertex bytes limit.
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Yes, with MeshGeometry you need to build a mesh (vertices + indices) yourself. Stroke won't work. That's why I said it was too low-level.
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Is that said every line we should draw 2 triangles?
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Yes with MeshGeometry
Re: How to optimize performance using DrawingContext to draw 10000 lines?
Does MeshGeometry support 3 dimensions point?
Re: How to optimize performance using DrawingContext to draw 10000 lines?
No, just 2D points ant 16-bit indices.
Who is online
Users browsing this forum: Google [Bot] and 10 guests