Wiley.Symbian.OS.Internals.Real.time.Kernel.Programming.Dec.2005.eBook-DDU (779891), страница 98
Текст из файла (страница 98)
If the current systemscreen size mode differs from the screen device’s screen size mode, thenWSERV will make all of the group windows and their children invisible.11.9.3 Properties of client windowsClient windows have two screen modes and many different areas orregions.11.9.3.1 Screen modesThe two screen modes (or color depths) are both associated with thescreen mode that the client requests. One of these is the drawing mode,which specifies which set of colors can be drawn to the window. Theother mode is the hardware mode, which is the minimum mode that thehardware needs to be switched into so that this window can be displayedcorrectly.
A window can request its own drawing mode, but by defaultWSERV will give it the mode that is specified in the WSINI.INI file usingthe keyword WINDOWMODE. WSERV calculates the actual drawingmode that a window will get using the requested mode and the modesavailable on the hardware. In Symbian OS, color modes are specifiedusing the enum TDisplayMode. These have a naming convention,depending on whether they are gray scale or color, and the number ofcolors they contain. So, for example, EColor64K is a mode with 65536PROPERTIES OF WINDOWSRequestmodeDrawingmode465HardwaremodeEGray16EGray16EColor4KEColor256EColor256EColor4KEColor64KEColor64KEColor64KEColor16MEColor64KEColor64Knon-gray colors. Here are some examples of how the modes get assignedto windows for hardware that supports EColor4K and EColor64K:The drawing mode is changed to the one requested, unless it requiresmore colors than the hardware supports.11.9.3.2 RegionsWindows have many different regions associated with them.
I will nowdiscuss some of these. In Symbian OS, we provide a base class, TRegion,which has several derived classes. These classes store a list of disjointrectangles and can be used to describe a two-dimensional area. There aremany manipulation functions for these classes, including functions to addand intersect regions. WSERV makes extensive use of these classes – thisis why we recommend that you machine code these classes when portingSymbian OS to new hardware.Calculating the regions is a time-consuming business. Because of this,WSERV caches the regions after it has first calculated it.
Then the nexttime it needs it, it uses the cached value. This of course means that whenan operation takes place that might have changed one of the cachedregions, WSERV must discard them all.Base areaThis is the area that the client specifies using the function RWindowBase::SetShape(). However, the more rectangles that there are inthe region describing the area, the greater the processing required whenthese windows are visible.
Thus circular or triangular windows will beparticularly inefficient.By default, windows are rectangular and the same size as their parent.This means that they are full screen if their parent is a group window.Their size can be changed by using the SetSize() function (definedin RWindow or RBlankWindow) or by the SetSizeErr() function(defined in RWindowBase).466THE WINDOW SERVERVisible areaThis is an area that WSERV calculates for each window. It is the area ofthe window that is not obscured by any other window.Invalid areaThis is the area of a window that is waiting for a redraw.
Areas may needredrawing after any of the following:• They become visible when another window is destroyed or madeinvisible• Their window is made visible• Their window is positioned so it is partly outside the screen and thenmoved back onto the screen• Part of their window loses its shadow• Their window becomes unfaded• The client calls Invalidate() on the window.Only instantiations of RWindow can have invalid areas, since WSERVknows how to draw other window types (see latter section on drawing ofwindows). The invalid area must be contained in the visible area.When a window has invalid areas, then WSERV will send it a redrawevent. The client can discover the invalid area using the GetInvalidRegion() function.Drawing areaThis is the area that WSERV clips drawing to. It is calculated differently,depending on whether the window is being redrawn or not.
If it’s notbeing redrawn, then the drawing area is just the visible area less theinvalid area. If the window is being redrawn, then the drawing area is thearea being redrawn (that is, the area validated by the redraw) less anyarea that has become invalid since the redraw started.Shadow areaThis is the area of the window that is currently in shadow. When WSERVdraws to a window, it actually does the drawing twice. First it draws tothe part of the drawing region that is not in shadow, and then it draws tothe part that is in shadow. The shadow flag is set for the second drawing.11.10Drawing to windowsIn this section, I will discuss the different ways to draw to a window andthe mechanisms in WSERV to support them.DRAWING TO WINDOWS46711.10.1 Drawing of blank windowsWSERV handles the drawing of all blank windows (RBlankWindow) forthe client. The client can specify a color for WSERV using the function SetColor(TRgb aColor).
When drawing the window, WSERVmust take account of the fact that this window could be faded (by callingthe RWindowTreeNode::SetFaded() or RWindowBase::FadeBehind() functions) and that the window could have shadows caston it. This means that when drawing a blank window, WSERV can useany of four different colors.11.10.2 Drawing of backup content windowsA client requiring this kind of window must instantiate the class RBackupWindow. These windows could also be called bitmap backup windows, because WSERV keeps the content of the window in a bitmap,so that when the window would otherwise become invalid, WSERV candraw it from the bitmap without needing any co-operation from theowner. WSERV creates a bitmap that is the same size and color depth asthe window, and uses this bitmap to mirror the content of the window.Because of the existence of the bitmap, the client must specify the window’s color depth when it creates the window.
If the client subsequentlywants to change the window’s size, then the operation may fail if there isnot enough memory to change the size of the bitmap.There are two ways in which the bitmap can be used. When thewindow is created, the bitmap will store all the parts of the window thatare not fully represented on the screen. Situations in which the window’scontent is not fully represented on the screen include:• Parts of the window are behind other windows or outside thescreen’s area• Parts of the window that have shadow cast upon them• The window is faded• There is not enough memory to calculate the area that is fullyrepresented.However, if the window owner calls the function MaintainBackup()on its window object, then all of the content will also be stored in thebitmap as it changes. The disadvantage of doing this is that most pixels ofthe window will be drawn twice, to the screen and to the bitmap.There are two ways in which the two drawings can differ slightly.Firstly, if you are using the DrawBitmap() function, which scales thingsdepending on the twips size of the relevant objects, then the scalingonscreen and in the backup bitmap can be different.
This is because468THE WINDOW SERVERthe screen and backup bitmap will have slightly different twips to pixelmappings. (This is because the only way to guarantee the same mappingwould be to create a backup bitmap the same size as the screen, andof course this would be a waste of memory if the window was small.In any case, the differences are small, being due to rounding errors.)Secondly, the exact color shade can change when copying the contentfrom the screen to the bitmap and back again. If the window is EColor4Kthen the bitmap will also be EColor4K.
However, the screen may beEColor64K because another window that requires this mode is alsovisible. Even though EColor64K has a much richer set of colors, they arenot a superset of the colors in EColor4K, and sometimes the mappingsfrom one to the other won’t be the most ideal.11.10.3 Drawing to redraw windowsA client requiring this kind of window must instantiate the class RWindow.Unlike the windows described in the previous section, WSERV requiresco-operation from the client to keep the content of these windows correct.It does this by sending redraw messages to the client telling it that thewindow content needs redrawing.
This happens in the circumstanceslisted in Section 11.9.3.2, under the title ‘‘Invalid area’’.A redraw window is either in redraw mode, or not. The mode changeshow drawing takes place – the main difference being the drawing areaused. This is described in Section 11.9.3.2.Drawing outside of a redraw is rare in Symbian OS, because of theway that Cone deals with drawing. Cone is a component that makesuse of WSERV APIs and provides a framework for the controls usedin applications. When a client calls the DrawNow() function on aCCoeControl, the control invalidates the whole of the control’s areaand then draws it all again in a redraw.However, there is nothing to stop a particular application bypassingthis mechanism to draw outside of a redraw.