7 Nokia Corporation - initial contribution. |
7 Nokia Corporation - initial contribution. |
8 Contributors: |
8 Contributors: |
9 --> |
9 --> |
10 <!DOCTYPE concept |
10 <!DOCTYPE concept |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
12 <concept id="GUID-667E7F90-D6C2-55CE-AE60-6C938072FB9C" xml:lang="en"><title>Graphics |
12 <concept id="GUID-667E7F90-D6C2-55CE-AE60-6C938072FB9C" xml:lang="en"><title>Graphics and Drawing Overview</title><shortdesc>This topic provides an introduction to drawing graphics |
13 and Drawing Overview</title><shortdesc>This topic provides an introduction to drawing graphics to the |
13 to the screen. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
14 screen. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
15 <p> <b>Variant</b>: Both (ScreenPlay and non-ScreenPlay). <b>Target |
14 <p> <b>Variant</b>: Both (ScreenPlay and non-ScreenPlay). <b>Target |
16 audience</b>: Application developers. </p> |
15 audience</b>: Application developers. </p> |
17 <p>Applications can draw to any <codeph>RDrawableWindow</codeph> —such as |
16 <p>Applications can draw to any <codeph>RDrawableWindow</codeph> —such |
18 an <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita"><apiname>RWindow</apiname></xref> —via a graphics device, of type <xref href="GUID-30479BE3-296E-3B4D-914D-B080ABD733E4.dita"><apiname>CWsScreenDevice</apiname></xref>, |
17 as an <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita"><apiname>RWindow</apiname></xref> —via a graphics device, of type <xref href="GUID-30479BE3-296E-3B4D-914D-B080ABD733E4.dita"><apiname>CWsScreenDevice</apiname></xref>, and a graphics context, of type <xref href="GUID-0AEE5955-C530-35F1-A904-69183331B294.dita"><apiname>CWindowGc</apiname></xref>. These classes are derived from the <xref href="GUID-B6D4AEE9-5C17-51D9-BBDE-7CCB5218279D.dita">GDI component</xref> classes <xref href="GUID-500FC564-35E9-3B66-A0C2-1269371A2EA0.dita"><apiname>CGraphicsDevice</apiname></xref> and <xref href="GUID-DAD09DCF-3123-38B4-99E9-91FB24B92138.dita"><apiname>CGraphicsContext</apiname></xref>, respectively. This means that general drawing functions can be |
19 and a graphics context, of type <xref href="GUID-0AEE5955-C530-35F1-A904-69183331B294.dita"><apiname>CWindowGc</apiname></xref>. These classes |
18 used for drawing to windows, as well as to other graphics devices. |
20 are derived from the <xref href="GUID-B6D4AEE9-5C17-51D9-BBDE-7CCB5218279D.dita">GDI |
19 The Window Server itself does not provide the facilities to draw graphics |
21 component</xref> classes <xref href="GUID-500FC564-35E9-3B66-A0C2-1269371A2EA0.dita"><apiname>CGraphicsDevice</apiname></xref> and <xref href="GUID-DAD09DCF-3123-38B4-99E9-91FB24B92138.dita"><apiname>CGraphicsContext</apiname></xref>, |
20 to a physical device. <codeph>CWindowGc</codeph> functions are not |
22 respectively. This means that general drawing functions can be used for drawing |
21 passed to the Window Server directly. Rather, they are stored in a |
23 to windows, as well as to other graphics devices. The Window Server itself |
22 buffer maintained by the Window Server Client API. This buffer is |
24 does not provide the facilities to draw graphics to a physical device. <codeph>CWindowGc</codeph> functions |
23 flushed to the Window Server only rarely. By this means the context |
25 are not passed to the Window Server directly. Rather, they are stored in a |
24 switching involved in drawing is minimised, and system performance |
26 buffer maintained by the Window Server Client API. This buffer is flushed |
25 significantly enhanced. </p> |
27 to the Window Server only rarely. By this means the context switching involved |
|
28 in drawing is minimised, and system performance significantly enhanced. </p> |
|
29 <p> <codeph>CWsScreenDeviceminimized</codeph> encapsulates the device-dependent |
26 <p> <codeph>CWsScreenDeviceminimized</codeph> encapsulates the device-dependent |
30 aspects of graphics operations. Graphics functions are not carried out directly |
27 aspects of graphics operations. Graphics functions are not carried |
31 via a <codeph>CWsScreenDevice</codeph>, however, but via a graphics context |
28 out directly via a <codeph>CWsScreenDevice</codeph>, however, but |
32 with which it is associated. The graphics context class, <codeph>CWindowGc</codeph>, |
29 via a graphics context with which it is associated. The graphics context |
33 provides a rich set of drawing functions, including functions to draw lines, |
30 class, <codeph>CWindowGc</codeph>, provides a rich set of drawing |
34 arcs, polygons, text and bitmaps. </p> |
31 functions, including functions to draw lines, arcs, polygons, text |
35 <p>A graphics context contains a collection of configurable parameters concerned |
32 and bitmaps. </p> |
36 with graphics, such as pen width, pen color, brush color. It is stored in |
33 <p>A graphics context contains a collection of configurable parameters |
37 the server, thus reducing the amount of information that has to be sent with |
34 concerned with graphics, such as pen width, pen color, brush color. |
38 each graphics call. The graphics call simply specifies the graphics context |
35 It is stored in the server, thus reducing the amount of information |
39 it wishes to use, and a single graphics context can be shared between multiple |
36 that has to be sent with each graphics call. The graphics call simply |
40 windows. </p> |
37 specifies the graphics context it wishes to use, and a single graphics |
41 <p>To draw to a graphics context it must be associated with a window. Typically |
38 context can be shared between multiple windows. </p> |
42 a graphics context is created when a session is constructed, and that graphics |
39 <p>To draw to a graphics context it must be associated with a window. |
43 context is shared between several windows in the application. When the window |
40 Typically a graphics context is created when a session is constructed, |
44 needs to use the graphics context it calls <xref href="GUID-0AEE5955-C530-35F1-A904-69183331B294.dita#GUID-0AEE5955-C530-35F1-A904-69183331B294/GUID-1C0F9DF6-23C2-3707-8F2B-0A738467FF0A"><apiname>CWindowGc::Activate()</apiname></xref>. |
41 and that graphics context is shared between several windows in the |
45 If necessary it can change the graphics context's settings. <xref href="GUID-0AEE5955-C530-35F1-A904-69183331B294.dita#GUID-0AEE5955-C530-35F1-A904-69183331B294/GUID-E977DBB2-8547-3AB7-99E3-9D246DA6CF58"><apiname>CWindowGc::Deactivate()</apiname></xref> should |
42 application. When the window needs to use the graphics context it |
46 be called first if the graphics context is currently active upon another window. </p> |
43 calls <xref href="GUID-0AEE5955-C530-35F1-A904-69183331B294.dita#GUID-0AEE5955-C530-35F1-A904-69183331B294/GUID-1C0F9DF6-23C2-3707-8F2B-0A738467FF0A"><apiname>CWindowGc::Activate()</apiname></xref>. If necessary it can |
|
44 change the graphics context's settings. <xref href="GUID-0AEE5955-C530-35F1-A904-69183331B294.dita#GUID-0AEE5955-C530-35F1-A904-69183331B294/GUID-E977DBB2-8547-3AB7-99E3-9D246DA6CF58"><apiname>CWindowGc::Deactivate()</apiname></xref> should be called first if the graphics context is currently active |
|
45 upon another window. </p> |
47 <p>Several optimizations are used by the Window Server to obtain high-performance |
46 <p>Several optimizations are used by the Window Server to obtain high-performance |
48 graphics: </p> |
47 graphics: </p> |
49 <ul> |
48 <ul> |
50 <li id="GUID-C8AC84D6-AF17-5975-88B8-CC93C499DFA0"><p>Each window is associated |
49 <li id="GUID-C8AC84D6-AF17-5975-88B8-CC93C499DFA0"><p>Each window |
51 with an <codeph>RWsSession</codeph> which is in turn associated with a client-side |
50 is associated with an <codeph>RWsSession</codeph> which is in turn |
52 buffer. Instead of implementing graphics operations by a direct client-server |
51 associated with a client-side buffer. Instead of implementing graphics |
53 call, which involves expensive context switching, all graphics operations |
52 operations by a direct client-server call, which involves expensive |
54 are stored as opcodes in the buffer, and the buffer is only flushed in certain |
53 context switching, all graphics operations are stored as opcodes in |
55 circumstances. </p> </li> |
54 the buffer, and the buffer is only flushed in certain circumstances. </p> </li> |
56 <li id="GUID-00B3FC8E-25DE-542F-BF67-0F71CF22526A"><p>The <codeph>CFbsBitmap</codeph> class |
55 <li id="GUID-00B3FC8E-25DE-542F-BF67-0F71CF22526A"><p>The <codeph>CFbsBitmap</codeph> class allows a bitmap to be shared between all |
57 allows a bitmap to be shared between all threads in the system, including |
56 threads in the system, including the client and the Window Server. |
58 the client and the Window Server. This sharing is mediated by the <xref href="GUID-A03FB1BF-F67B-519D-A904-74CA3F8375D9.dita">Font |
57 This sharing is mediated by the <xref href="GUID-A03FB1BF-F67B-519D-A904-74CA3F8375D9.dita">Font and Bitmap server</xref>. The <xref href="GUID-17150D76-BB82-3A4B-8B1A-8BA93CB1A9EF.dita"><apiname>CWsBitmap</apiname></xref> class eliminates further context |
59 and Bitmap server</xref>. The <xref href="GUID-17150D76-BB82-3A4B-8B1A-8BA93CB1A9EF.dita"><apiname>CWsBitmap</apiname></xref> class eliminates |
58 switches by taking ownership of the handle of the bitmap. Applications |
60 further context switches by taking ownership of the handle of the bitmap. |
59 can use this class to more efficiently open, blit-to-screen, and close |
61 Applications can use this class to more efficiently open, blit-to-screen, |
60 a series of bitmaps. Use functions that take a <codeph>CWsBitmap</codeph> in preference to those that take a <codeph>CFbsBitmap</codeph>, |
62 and close a series of bitmaps. Use functions that take a <codeph>CWsBitmap</codeph> in |
61 because they are faster. </p> </li> |
63 preference to those that take a <codeph>CFbsBitmap</codeph>, because they |
62 <li id="GUID-550D1374-C166-54C6-A055-0CA040691654"><p>A single graphics |
64 are faster. </p> </li> |
63 context may be used for drawing to many windows—it is not necessary |
65 <li id="GUID-550D1374-C166-54C6-A055-0CA040691654"><p>A single graphics context |
64 to have one per window. The <codeph>Activate()</codeph> function associates |
66 may be used for drawing to many windows—it is not necessary to have one per |
65 a <codeph>CWindowGc</codeph> with a particular window. </p> </li> |
67 window. The <codeph>Activate()</codeph> function associates a <codeph>CWindowGc</codeph> with |
66 <li id="GUID-91AFC884-0BB2-5A73-B757-94EF1B2328A7"><p>Provided drawing |
68 a particular window. </p> </li> |
67 operations to an <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita"><apiname>RWindow</apiname></xref> are performed as <xref href="GUID-8DB1C618-597C-560C-95A2-C0AB2CEBB027.dita">redraw drawing</xref>, the Window Server stores the sequence of drawing commands that |
69 <li id="GUID-91AFC884-0BB2-5A73-B757-94EF1B2328A7"><p>Provided drawing operations |
68 represent the window contents in redraw stores. Then when the Window |
70 to an <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita"><apiname>RWindow</apiname></xref> are performed as <xref href="GUID-8DB1C618-597C-560C-95A2-C0AB2CEBB027.dita">redraw |
69 Server needs to repaint the window (because, for example, a dialog |
71 drawing</xref>, the Window Server stores the sequence of drawing commands |
70 box popped up over it and has now closed) it simply replays the sequence |
72 that represent the window contents in redraw stores. Then when the Window |
71 of stored commands, rather than sending a redraw request to the client. |
73 Server needs to repaint the window (because, for example, a dialog box popped |
72 This minimizes the number of client-server transactions and means |
74 up over it and has now closed) it simply replays the sequence of stored commands, |
73 that windows are repainted as soon as the Window Server detects that |
75 rather than sending a redraw request to the client. This minimizes the number |
74 they are needed. </p> <p>This means that all <xref href="GUID-0AEE5955-C530-35F1-A904-69183331B294.dita"><apiname>CWindowGc</apiname></xref> drawing should now be redraw drawing, which means that it takes |
76 of client-server transactions and means that windows are repainted as soon |
75 place between <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-9337538E-7A53-3153-A330-968B5E4F2FF2"><apiname>RWindow::BeginRedraw()</apiname></xref> and <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-3DE16607-AD3B-3946-BEB3-88512EAAB9CE"><apiname>RWindow::EndRedraw()</apiname></xref> calls. If you use the <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-D5458F8C-E199-37DD-B821-050B749122C6"><apiname>CCoeControl::DrawNow()</apiname></xref> and <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-9FB682AC-0209-302A-83F3-7BCB1162B998"><apiname>CCoeControl::DrawDeferred()</apiname></xref> methods, the |
77 as the Window Server detects that they are needed. </p> <p>This means that |
76 UI Control Framework (CONE) takes care of this for you. See <xref href="GUID-8DB1C618-597C-560C-95A2-C0AB2CEBB027.dita">Redraw Drawing</xref> for more information. </p> </li> |
78 all <xref href="GUID-0AEE5955-C530-35F1-A904-69183331B294.dita"><apiname>CWindowGc</apiname></xref> drawing should now be redraw drawing, which |
|
79 means that it takes place between <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-9337538E-7A53-3153-A330-968B5E4F2FF2"><apiname>RWindow::BeginRedraw()</apiname></xref> and <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-3DE16607-AD3B-3946-BEB3-88512EAAB9CE"><apiname>RWindow::EndRedraw()</apiname></xref> calls. |
|
80 If you use the <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-D5458F8C-E199-37DD-B821-050B749122C6"><apiname>CCoeControl::DrawNow()</apiname></xref> and <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-9FB682AC-0209-302A-83F3-7BCB1162B998"><apiname>CCoeControl::DrawDeferred()</apiname></xref> methods, |
|
81 the UI Control Framework (CONE) takes care of this for you. See <xref href="GUID-8DB1C618-597C-560C-95A2-C0AB2CEBB027.dita">Redraw |
|
82 Drawing</xref> for more information. </p> </li> |
|
83 </ul> |
77 </ul> |
84 </conbody><related-links> |
78 </conbody><related-links> |
85 <link href="GUID-484B51EC-2209-5492-8E9C-9D792AB0DF35.dita"><linktext>Graphics |
79 <link href="GUID-484B51EC-2209-5492-8E9C-9D792AB0DF35.dita"><linktext>Graphics |
86 and Drawing </linktext></link> |
80 and Drawing </linktext></link> |
87 <link href="GUID-6C16417B-5B37-5310-B59A-750D971AA6D4.dita"><linktext>The UI Control |
81 <link href="GUID-6C16417B-5B37-5310-B59A-750D971AA6D4.dita"><linktext>The UI Control Framework |
88 Framework (CONE)</linktext></link> |
82 (CONE)</linktext></link> |
89 </related-links></concept> |
83 </related-links></concept> |