Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with a LayerVisual and a DropShadow with SourcePolicy set as InheritFromVisualContent #81

Open
smourier opened this issue Feb 8, 2021 · 1 comment

Comments

@smourier
Copy link

smourier commented Feb 8, 2021

Hi,

I use the CPP Hello Composition sample. Just change AddElement method in CompositionHost.cpp by this:

void CompositionHost::AddElement(float size, float x, float y)
{
	if (m_target.Root())
	{
		auto visuals = m_target.Root().as<ContainerVisual>().Children();

		// create a layer
		auto layer = m_compositor.CreateLayerVisual();
		layer.Size({ size, size });
		layer.Offset({ x, y, 0.0f, });

		// add a shadow
		auto shadow = m_compositor.CreateDropShadow();
		shadow.BlurRadius(10);
		shadow.Color({ 255, 100, 100, 100});
		shadow.SourcePolicy(CompositionDropShadowSourcePolicy::InheritFromVisualContent);
		layer.Shadow(shadow);

		// add a child element
		auto element = m_compositor.CreateSpriteVisual();
		uint8_t r = rand() % 255;
		uint8_t g = rand() % 255;
		uint8_t b = rand() % 255;
		element.Brush(m_compositor.CreateColorBrush({ 255, r, g, b }));
		element.Size({ size, size });

		// insert layer
		layer.Children().InsertAtTop(element);
		visuals.InsertAtTop(layer);
	}
}

When you run the sample and add elements, it doesn't look good. What's worse is if you open another window (for example you open Notepad) and move this new window around and over the sample window with elements, it creates very strange artifacts on drawn elements that look like a bug in the composition engine.

If I remove the shadow.SourcePolicy line or remove the shadow completely, it seems to work as expected.
Is there anything that can be done to fix this? any workaround?

I've not found a way to capture the screen because the system updates the surface properly as soon as we change focus, or capture the screen (print screen, etc.).

I'm using Windows 10 20H2 19042.789 (latest non insider) and compiled using Visual Studio 2019, x64.

@duncanmacmichael
Copy link
Member

Hi @smourier, thanks for your thorough explanation of the issue. We are currently aware of this problem and are tracking it in an internal bug work item. Unfortunately we don't have a current fix or workaround, nor do we have an estimate on when the fix might be available. When we do address it we'll circle back to this thread, but in the meantime I just wanted to set the right expectation that this might take a while and it's unclear when that will be. Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants