question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why the Visual.VisualOffset is double type but run the compositor in floats?

See original GitHub issue

We will use Visual.VisualOffset to set the visual offset. The Visual.VisualOffset is in managed code. And the type of VisualOffset is Vector which is contained the double X and the double Y.

https://github.com/dotnet/wpf/blob/7e0195803bf0144daba4e5fd2d8be93774d043ef/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Visual.cs#L3523-L3550

But we will use CMilVisual::ProcessSetOffset to set it in the MIL code. It will cast the double X and double Y to the float type. Just as the code says, The packet contains doubles. Should they be floats? Why are we using doubles in managed but run the compositor in floats?

https://github.com/dotnet/wpf/blob/7e0195803bf0144daba4e5fd2d8be93774d043ef/src/Microsoft.DotNet.Wpf/src/WpfGfx/core/resources/node.cpp#L425-L439

Can I know the reason?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
miloushcommented, Oct 14, 2021

My guess is because there is no Vector struct that holds floats, and all computations and math functions use doubles anyway. GPUs on the other hand can do much faster calculations with floats. Changing either side seems unreasonable, and changing the managed type to use floats - apart from compatibility issues - would move the burden of conversion on the developer (and from native to managed performance).

1reaction
vishalmsftcommented, Sep 29, 2021

@batzen The question exists in the code as comments. At some point of time, we may circle back to this one as code-review. This issue is practically a duplicate of issue already reported in code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using the Visual Layer with WPF - Windows apps
In this tutorial, you create a simple WPF app UI and add animated Composition elements to it. Both the WPF and Composition components...
Read more >
Composition - Ratish Philip's Blog
TKey can be of types – int , float , double or string . TValue should be an object deriving from CompositionObject ....
Read more >
MS-RDPCR2-Diff - Composited Remoting V2
Remote Desktop Protocol: Composited Remoting V2 ... Resource Types . ... associated with windows, but they can also be free-floating.
Read more >
Composition | Mike Taulty | Page 2
I'm unsure how to get hold of such a mask for arbitrary content but, from the recipes post, a new method has been...
Read more >
dotnet 读WPF 源代码笔记布局时Arrange 如何影响元素渲染 ...
我在GitHub 上尝试去问问大佬们,这个是否有特别的原因,请看Why the Visual.VisualOffset is double type but run the compositor in floats?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found