Windows runtime Windows应用商店应用程序-SwapChainPanel抽绳性能
我正在使用XAML/C#开发一个Windows应用商店应用程序。该应用程序还有一个Windows运行时组件,用于使用DirectX显示图表输出 我使用SwapChainPanel方法绘制线条(x轴、y轴和波形) 我从下面的MSDN示例中选择了这种方法(请参阅场景3-D2DPanel) 这是我的问题,, 我的波形包含大量数据(从1000到20000个点)。在每次渲染函数调用期间,我会连续调用DrawLine以获取所有这些点 该控件还提供平移和缩放,但不管缩放级别如何,都会保持笔划宽度恒定,因此可见区域(渲染目标)可能比我正在绘制的线小得多 为即将脱离屏幕的区域调用抽绳是否会导致性能问题? 我尝试了PathGeometry和GeometryRealization,但无法在不同的缩放级别控制笔划宽度Windows runtime Windows应用商店应用程序-SwapChainPanel抽绳性能,windows-runtime,windows-store-apps,direct2d,Windows Runtime,Windows Store Apps,Direct2d,我正在使用XAML/C#开发一个Windows应用商店应用程序。该应用程序还有一个Windows运行时组件,用于使用DirectX显示图表输出 我使用SwapChainPanel方法绘制线条(x轴、y轴和波形) 我从下面的MSDN示例中选择了这种方法(请参阅场景3-D2DPanel) 这是我的问题,, 我的波形包含大量数据(从1000到20000个点)。在每次渲染函数调用期间,我会连续调用DrawLine以获取所有这些点 该控件还提供平移和缩放,但不管缩放级别如何,都会保持笔划宽度恒定,因此可
m_d2dContext->SetTransform(m_worldMatrix);
float lineThickness = 2.0f / m_zoom;
for (unsigned int i = 0; i < points->Size; i += 2)
{
double wavex1 = points->GetAt(i);
double wavey1 = points->GetAt(i + 1);
if (i != 0)
{
m_d2dContext->DrawLine(Point2F(prevX, prevY), Point2F(wavex1, wavey1), brush, lineThickness);
}
prevX = wavex1;
prevY = wavey1;
}
我的渲染方法通常类似于下面的代码片段。无论缩放级别如何,线宽都被控制为相同
m_d2dContext->SetTransform(m_worldMatrix);
float lineThickness = 2.0f / m_zoom;
for (unsigned int i = 0; i < points->Size; i += 2)
{
double wavex1 = points->GetAt(i);
double wavey1 = points->GetAt(i + 1);
if (i != 0)
{
m_d2dContext->DrawLine(Point2F(prevX, prevY), Point2F(wavex1, wavey1), brush, lineThickness);
}
prevX = wavex1;
prevY = wavey1;
}
m_d2dContext->SetTransform(m_worldMatrix);
浮动线厚度=2.0f/m\u缩放;
对于(无符号整数i=0;iSize;i+=2)
{
双波X1=点->到达(i);
双波1=点->到达(i+1);
如果(i!=0)
{
m_d2dContext->绘图线(点2F(上一个,上一个),点2F(波X1,波Y1),画笔,线条厚度);
}
prevX=wavex1;
prevY=波1;
}
我对DirectX有点新,但对C++没有。有什么想法吗?简短的回答:可能会。在绘图前推一个夹子是一个很好的做法。例如,在本例中,您需要使用图形曲面的边界调用。这将确保没有图形调用尝试在曲面边界之外绘制
详细回答:实际上,这取决于几个因素,包括但不限于设备上下文所指向的目标、显示硬件和显示驱动程序。例如,如果您正在绘制一个由CPU支持的ID2D1Bitmap
,那么可以公平地假设不会有太大差异
但是,如果您直接绘制到某个硬件支持的表面(GPU位图,或从IDXGISurface
创建的位图),它可能会有点毛茸茸的。例如,从AN中考虑此注释。这里,代码将要清除的位置是从IDXGISurface
创建的ID2D1Bitmap
:
// The Clear call must follow and not precede the PushAxisAlignedClip call.
// Placing the Clear call before the clip is set violates the contract of the
// virtual surface image source in that the application draws outside the
// designated portion of the surface the image source hands over to it. This
// violation won't actually cause the content to spill outside the designated
// area because the image source will safeguard it. But this extra protection
// has a runtime cost associated with it, and in some drivers this cost can be
// very expensive. So the best performance strategy here is to never create a
// situation where this protection is required. Not drawing outside the appropriate
// clip does that the right way.