Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DxBrush "reuse"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    DxBrush "reuse"

    I created indicator that uses many brushes from UI. There is a big probability that many of the brushes would be same color. It is possible/safe to "reroute" the brushes so that when they are the same, the second one is not created in OnRenderTargetChanged() and instead the first one is assignet to it? Something like this:

    Code:
    try{ 
    
        brush_1Dx = brush_1.ToDxBrush(RenderTarget);
    
         if (brush_2 == brush_1)
         {
              brush_2Dx = brush_1Dx;
         }
        else
         {
             brush_2Dx = brush_2ToDxBrush(RenderTarget);
         }
    
    }

    Second question: What is more "expensive" when I dont need to expose brush to the UI?

    brushDx = brush.ToDxBrush(RenderTarget);
    OR
    brushDx = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.Black);

    #2
    Hello Marty125,

    You could possibly make something like that however you would have to come up with a mechanism to know when two brushes are the same. You could possibly use a C# Dictionary for that type of use. I would likely suggest for simplicity to just create the brushes because you are already doing it the most efficient way if you are using OnRenderTargetChanged.

    Regarding the brush creation, I would suggest using the built in method ToDxBrush to make sure your brush is using the settings that the platform intended.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    553 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    100 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    543 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    546 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X