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

Use device scale factor to support higher DPI on WPF #842

Merged
merged 4 commits into from
Feb 27, 2015

Conversation

bjarteskogoy
Copy link

@amaitland
Copy link
Member

Is it possible to remove the ScaleTransform now?

@@ -811,6 +812,12 @@ public BitmapInfo CreateBitmapInfo(bool isPopup)
return BitmapFactory.CreateBitmap(isPopup);
}

float _deviceScaleFactor = 1.0F;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Underscores only in c++ code - consistency.
Variables should also be declared in the one place for consistency.

@amaitland
Copy link
Member

Additional info on scaling in this thread https://code.google.com/p/chromiumembedded/issues/detail?id=946#c6

- move variable declaration
@bjarteskogoy
Copy link
Author

Actually it's the combination of the ScaleTransform and device scale factor that makes it work properly. Without the transform and the device scale factor the wpf browser content would be the correct size on screen. WPF will upscale the image to comply with the current DPI setting, but this would just be an upscaling of the bitmap image -> very blurry. The scale transform keeps the pixel size from cef, which leads to a too small image when you have a higher DPI than 100%. The device scale factor "zooms" the rendered content from cef up to the correct size on screen.

@amaitland
Copy link
Member

That's based on the transformed dimensions. I still think there's some investigation required.

@amaitland
Copy link
Member

@bjarteskogoy
Copy link
Author

The NotifyScreenInfoChanged should then probably be triggered in this method: https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Wpf/ChromiumWebBrowser.cs#L647

That would also mean that the scale transform needs to be updated at the same time, I believe.

- update the scaletransform when presentation source is changed
@amaitland amaitland merged commit ebf8b88 into cefsharp:master Feb 27, 2015
@amaitland
Copy link
Member

I've merged this though I still think further research is needed. The fact that it works is definitely an improvement, though I'm not convinced what we have is the correct solution.

Currently, all sizes passed in and out of the API for both CEF and Chromium, are in view units (meaning virtual pixels or unscaled pixels) by design

It's my understanding that WPF also uses device independent pixels and as such I'm wondering if the ScaleTransform is required because we provide transformed Width/Height. I don't have a high dpi device, so can't really toy with this easily.

amaitland added a commit that referenced this pull request Mar 2, 2015
… can be conducted - need to look more info how scale factor works and if the ScaleTransform we have is required.
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

Successfully merging this pull request may close these issues.

2 participants