次の方法で共有


Always think in terms of the current screen orientation

Today I am going to write a short development note on a GPE-based display driver for Windows CE as we noticed that this stuff is not clearly documented online and have confused many people including those who are writing display drivers for new platforms at MS. Hopefully this entry might save a few strands of hairs of some people out there somewhere.

The topic is about the screen resolutions and orientations supported by the display driver. It is really a simple thing, but there are a set of rules that driver writers must know to get it right. When it is not correctly followed, your device might still boot, but you may start noticing weird glitches here and there.

A GPE-based display driver has to override a function called GetModeInfo() which is a pure virtual function defined by the GPE base class. What it does is very simple; It just returns the screen resolution (and some extra information such as bit depth) supported by the device at the given index. It is used in a combination with NumModes() which gives the number of modes that the GetModeInfo() supports. What is important here is that the display driver framework requires that the GetModeInfo() returns the screen resolution relative to the current screen orientation. Not the native screen orientation. Not the boot-time screen orientation. It is always the current screen orientation.

The screen can take four possible orientations; 0 degree, 90 degrees, 180 degrees, and 270 degrees. Unless you are only dealing with square displays, then depending on the angle, the width and height have to be swapped. For example, if your screen resolution is 800 x 600 at the 0 degree and that is how your GetModeInfo() reports, then it has to return 600 x 800 when the current orientation is at 90 or 270 degrees. Many GWES components that deal with screen resolutions and orientations are dependent upon this behavior, but this doesn't become a problem until you actually try to rotate the screen. So, initially it may look like it is working perfectly, but once you try to rotate it, then you start seeing some issues.

As far as I can think of off the top of my head, most APIs (if not all) that deal with resolutions such as ChangeDisplaySettingsEx() and SetDisplayMode() all expect resolution parameters to be relative to the current screen orientation. So, the rule of the thumb appears to be this: Always think in terms of the current screen orientation.

Comments

  • Anonymous
    July 10, 2008
    PingBack from http://www.basketballs-sports.info/better-basketball/?p=1253

  • Anonymous
    December 07, 2009
    I can't understand exactly in MGDI layer in CE 6 It's different from CE5 In CE6, MGDI implements MatchDisplayModes, and use it in FInit and SetRotateParms What I want to kwow is how I can set the boot-time rotation. With CE5 and Mobile, I haved used GDIrotationAngle But in CE6. It does not work. I think some initialization code cache the Display Mode from GetModeInfo, then use it in MatchDisplayModes, But it does not change SOMETHING resolution information in the shell or GDI. In CE5, FInit and SetRotateParms just called GetModes. and In WM, there is more SetMode Call. In CE6. There is no SetMode call when I rotate screen.