High DPI Support in Windows Vista Aero
A good amount of ink has been spilled on this blog talking about all the
cost, nuance, impact, and techniques we go through to get a composited desktop.
Less ink is spilled on the benefits of the composited desktop. Those were
most broadly covered in
this initial post. I'd like to expand on one such benefit here -- High
DPI Support (or High Resolution Support).
Monitor resolutions are going up while prices are going down. In
general, pixel density is going up as well. Both on laptops that are
regularly 120 DPI and 144 DPI these days (as opposed to the typical desktop
experience of 96 DPI), and on desktops that are getting bigger and denser
monitors. This can make for crisper, less jagged display of content.
However, in order for this to work, applications typically need to do work to
deal with different display resolutions. (This is not always true... for
instance, Windows Presentation Foundation applications are natively
resolution-aware, and the application developer needn't worry about it.)
When applications aren't written to adapt to different resolutions, they just
start to look smaller and smaller on higher and higher resolution monitors.
The seminal article for how to write your GDI/GDI+ applications to be DPI
aware was written way back in 2001 by my colleague
Nick Kramer, and can be found
here. This is ultimately the best approach an application can take.
However, not all applications do this, and yet users of course use these
applications while they're running in a higher DPI environment. This is
where the composited desktop re-enters the picture. As you recall, when
the DWM is running, applications render to an offscreen bitmap. When the
DWM recognizes that an app is not DPI aware and just rendering as it always
does, but that the desktop is set to a non-standard DPI, then the DWM goes ahead
and renders the window at a larger size.
This "rendering at a larger size" results in the app being somewhat fuzzier
and not as crisp as if it were being rendered natively at the correct
resolution. However, it's the "correct" size for everything else on the
desktop, and typically represents the much better option between rendering at
the right size somewhat fuzzily; or crisply but at a size much too small.
For the purposes of this blog, there are some interesting tidbits about the
High DPI rendering that are worth discussing:
As
this earlier post describes, the client area of the window is just a
bitmap. Because of the way the DWM works and how it sits atop WPF
technology and thus atop DirectX, scaling the client area is really just a
matter of modifying a scale transform on the appropriate node of the "visual
tree" that describes the desktop. This notion was describedhere.
When that transform scaling is performed on the visual tree, ultimately
in DirectX, this results in performing a texturing operation with the same
sized texture but a larger mesh (the target client area), resulting in
stretching the client area bitmap.The Non-Client Area (the window frame) is not scaled uniformly with the
client area. As in non-DPI scaled situations, it's "painted"
separately. It's not simply subjected to bitmap scaling because for
the frame, we can natively scale it, and choose elements appropriate
for the target resolution, render caption text appropriate for the target
resolution, etc.While one can imagine any scale factor coming about as a function of the
target DPI resulting in windows that land off of pixel boundaries and
represent fractional pixel contribution. However, we avoid this and
clamp our scaling so that we always remain on pixel boundaries and remain as
crisp as possible, within the confines of the graphical filtering algorithm
in place.
More details for the app developer:
- The preferred mechanism by which an application will be able to declare
itself High DPI aware under Windows Vista will be via the manifest.
Look for upcoming MSDN documentation discussing how to do this. In the
event where a manifest isn't appropriate/available (for instance, when
writing a library or framework), the the library should ensure that the "SetProcessDPIAware"
API is called before creating any UI. - Nick writes a bit more about High DPI in the context of USER and GDI
compatability.
Comments
Anonymous
August 07, 2006
Thanks Greg,
How is ClearType affected by this? The pixel boundary scaling would need to be careful about this is the app was using ClearType. I could imagine some strange discoloration would be visible.Anonymous
August 07, 2006
The comment has been removedAnonymous
August 07, 2006
With old (plex days) concept zoom was really cool. With DCE and vector interface concepts it gived really advanced and useful possibilities. DPI-scaling much more bad.Anonymous
August 07, 2006
Greg, I'd also like to know about font scaling. So are you saying that text is simply scaled as part of the total client area bitmap? The scaling algorithms and hints of the OpenType font program will be ignored?Anonymous
August 08, 2006
The comment has been removedAnonymous
August 23, 2006
okAnonymous
September 13, 2006
The comment has been removedAnonymous
December 10, 2006
PingBack from http://www.istartedsomething.com/20061211/vista-dpi-scaling/Anonymous
January 29, 2007
PingBack from http://itsvista.com/2007/01/itsvista-tip-29-use-vistas-dpi-support-to-scale-your-user-interface/Anonymous
May 06, 2007
PingBack from http://www.errorforum.com/microsoft-windows-vista-error/19340-use-vistas-dpi-support-scale-your-user-interface.html#post24356Anonymous
October 27, 2007
PingBack from http://www.vicente-navarro.com/blog/index.php/2007/10/27/los-dpi-en-pantalla-en-windows-y-linux/Anonymous
September 13, 2008
The comment has been removedAnonymous
September 15, 2008
PingBack from http://windows-7.com.ua/2008/09/15/developing/33Anonymous
October 28, 2008
PingBack from http://www.istartedsomething.com/20081029/windows-7-dpi-scaling-my-7-is-bigger-than-your-7/Anonymous
October 28, 2008
PingBack from http://www.istartedsomething.com/20081029/windows-7-dpi-scaling-my-7-is-bigger-than-your-7/Anonymous
December 16, 2008
PingBack from http://www.hotlink.asia/computer/windows-7-dpi-scaling-my-7-is-bigger-than-your-7/Anonymous
December 16, 2008
PingBack from http://www.TechInfo.com.my/windows-7-dpi-scaling-my-7-is-bigger-than-your-7/Anonymous
January 08, 2009
이 블로그의 좋은 점 중에 하나는 댓글이나 메일에서, 주제에 대한 세부 사항정보와 데이터에 대해 좀 더 깊이 있게 이야기할 수 있는 점입니다. 여러분의 질문이나 의견에 대해 보다 깊이Anonymous
January 20, 2009
PingBack from http://www.hilpers.com/271433-bildschirm-unabhaengig-programmieren-fuer-1024-a/2Anonymous
March 17, 2009
The comment has been removedAnonymous
June 19, 2009
PingBack from http://mydebtconsolidator.info/story.php?id=22234