I have an efficiency/performance question regarding reusing DX brushes during calls to OnRender().
I understand that it is not efficient to recreate brushes during each call to OnRender(). This leaves me with two options:
Option A:
Inside OnRender() I can set
SharpDX.Direct2D1.Brush areaBrushDX = areaBrush.ToDxBrush(RenderTarget); SharpDX.Direct2D1.Brush textBrushDX = textBrush.ToDxBrush(RenderTarget);
Alternatively, I can have
Option B:
Inside OnRenderTargetChanged() I can set
public override void OnRenderTargetChanged()
{
if (areaBrushDx != null)
areaBrushDx.Dispose();
if (textBrushDx != null)
textBrushDx.Dispose();
if (RenderTarget != null)
{
try
{
areaBrushDx = areaBrush.ToDxBrush(RenderTarget);
textBrushDx = textBrush.ToDxBrush(RenderTarget);
}
catch (Exception e) { }
}
}
1. Which option is most efficient in terms of resources and performance?
2. Which option should be used if you have a lot of brushes you need to use?
Thank you.

Comment