xref: /haiku/docs/develop/servers/app_server/DisplayDriver.rst (revision a5061ecec55353a5f394759473f1fd6df04890da)
1*a5061eceSAdrien DestuguesDisplayDriver class
2*a5061eceSAdrien Destugues###################
3*a5061eceSAdrien Destugues
4*a5061eceSAdrien DestuguesThe DisplayDriver class is not a useful class unto itself. It is to
5*a5061eceSAdrien Destuguesprovide a consistent interface for the rest of the app_server to
6*a5061eceSAdrien Destugueswhatever rendering context it is utilizing, whether it be a remote
7*a5061eceSAdrien Destuguesscreen, a ServerBitmap, installed graphics hardware, or whatever.
8*a5061eceSAdrien DestuguesDocumentation below will describe the role of each function.
9*a5061eceSAdrien Destugues
10*a5061eceSAdrien DestuguesMember Functions
11*a5061eceSAdrien Destugues================
12*a5061eceSAdrien Destugues
13*a5061eceSAdrien DestuguesDisplayDriver(void)
14*a5061eceSAdrien Destugues-------------------
15*a5061eceSAdrien Destugues
16*a5061eceSAdrien Destugues~DisplayDriver(void)
17*a5061eceSAdrien Destugues--------------------
18*a5061eceSAdrien Destugues
19*a5061eceSAdrien Destuguesbool Initialize(void)
20*a5061eceSAdrien Destugues---------------------
21*a5061eceSAdrien Destugues
22*a5061eceSAdrien Destuguesvoid Shutdown(void)
23*a5061eceSAdrien Destugues-------------------
24*a5061eceSAdrien Destugues
25*a5061eceSAdrien DestuguesThese four are for general start and stop procedures. The constructor
26*a5061eceSAdrien Destuguesand destructor concern themselves with the internal members common to
27*a5061eceSAdrien Destuguesall drivers, such as the current cursor and the access semaphore.
28*a5061eceSAdrien DestuguesSubclasses will probably end up using these to handle memory
29*a5061eceSAdrien Destuguesallocation-related issues, but likely not much else. Initialize() and
30*a5061eceSAdrien DestuguesShutdown() are for general setup internal to the module. Note that if
31*a5061eceSAdrien DestuguesInitialize() returns false, the server will not use the module, call
32*a5061eceSAdrien DestuguesShutdown(), and then delete it as accordingly.
33*a5061eceSAdrien Destugues
34*a5061eceSAdrien Destuguesvoid CopyBits(BRect src, BRect dest)
35*a5061eceSAdrien Destugues------------------------------------
36*a5061eceSAdrien Destugues
37*a5061eceSAdrien Destuguesvoid InvertRect(BRect r)
38*a5061eceSAdrien Destugues------------------------
39*a5061eceSAdrien Destugues
40*a5061eceSAdrien Destuguesvoid DrawBitmap(ServerBitmap \*bmp, BRect src, BRect dest, render_mode mode)
41*a5061eceSAdrien Destugues----------------------------------------------------------------------------
42*a5061eceSAdrien Destugues
43*a5061eceSAdrien Destuguesvoid DrawPicture(SPicture \*pic, BPoint pt)
44*a5061eceSAdrien Destugues-------------------------------------------
45*a5061eceSAdrien Destugues
46*a5061eceSAdrien Destuguesvoid DrawChar(char c, BPoint pt)
47*a5061eceSAdrien Destugues--------------------------------
48*a5061eceSAdrien Destugues
49*a5061eceSAdrien Destuguesvoid DrawString(const char \*string, int32 length, BPoint pt, escapement_delta \*delta=NULL)
50*a5061eceSAdrien Destugues--------------------------------------------------------------------------------------------
51*a5061eceSAdrien Destugues
52*a5061eceSAdrien Destuguesvoid StrokeArc(BRect r, float angle, float span, layerdata \*d, int8 \*pattern)
53*a5061eceSAdrien Destugues-------------------------------------------------------------------------------
54*a5061eceSAdrien Destugues
55*a5061eceSAdrien Destuguesvoid FillArc(BRect r, float angle, float span, layerdata \*d, int8 \*pattern)
56*a5061eceSAdrien Destugues-----------------------------------------------------------------------------
57*a5061eceSAdrien Destugues
58*a5061eceSAdrien Destuguesvoid StrokeBezier(BPoint \*pts, layerdata \*d, int8 \*pat)
59*a5061eceSAdrien Destugues----------------------------------------------------------
60*a5061eceSAdrien Destugues
61*a5061eceSAdrien Destuguesvoid FillBezier(BPoint \*pts, layerdata \*d, int8 \*pat)
62*a5061eceSAdrien Destugues--------------------------------------------------------
63*a5061eceSAdrien Destugues
64*a5061eceSAdrien Destuguesvoid StrokeEllipse(BRect r, layerdata \*d, int8 \*pattern)
65*a5061eceSAdrien Destugues----------------------------------------------------------
66*a5061eceSAdrien Destugues
67*a5061eceSAdrien Destuguesvoid FillEllipse(BRect r, layerdata \*d, int8 \*pattern)
68*a5061eceSAdrien Destugues--------------------------------------------------------
69*a5061eceSAdrien Destugues
70*a5061eceSAdrien Destuguesvoid StrokeLine(BPoint start, BPoint end, layerdata \*d, int8 \*pattern)
71*a5061eceSAdrien Destugues------------------------------------------------------------------------
72*a5061eceSAdrien Destugues
73*a5061eceSAdrien Destuguesvoid StrokeLineArray(BPoint \*pts, int32 numlines, rgb_color \*colors, layerdata \*d)
74*a5061eceSAdrien Destugues-------------------------------------------------------------------------------------
75*a5061eceSAdrien Destugues
76*a5061eceSAdrien Destuguesvoid StrokePolygon(BPoint \*ptlist, int32 numpts, BRect rect, layerdata \*d, int8 \*pattern, bool is_closed=true)
77*a5061eceSAdrien Destugues-----------------------------------------------------------------------------------------------------------------
78*a5061eceSAdrien Destugues
79*a5061eceSAdrien Destuguesvoid FillPolygon(BPoint \*ptlist, int32 numpts, BRect rect, layerdata \*d, int8 \*pattern)
80*a5061eceSAdrien Destugues------------------------------------------------------------------------------------------
81*a5061eceSAdrien Destugues
82*a5061eceSAdrien Destuguesvoid StrokeRect(BRect r, layerdata \*d, int8 \*pattern)
83*a5061eceSAdrien Destugues-------------------------------------------------------
84*a5061eceSAdrien Destugues
85*a5061eceSAdrien Destuguesvoid FillRect(BRect r, layerdata \*d, int8 \*pattern)
86*a5061eceSAdrien Destugues-----------------------------------------------------
87*a5061eceSAdrien Destugues
88*a5061eceSAdrien Destuguesvoid StrokeRoundRect(BRect r, float xrad, float yrad, layerdata \*d, int8 \*pattern)
89*a5061eceSAdrien Destugues------------------------------------------------------------------------------------
90*a5061eceSAdrien Destugues
91*a5061eceSAdrien Destuguesvoid FillRoundRect(BRect r, float xrad, float yrad, layerdata \*d, int8 \*pattern)
92*a5061eceSAdrien Destugues----------------------------------------------------------------------------------
93*a5061eceSAdrien Destugues
94*a5061eceSAdrien Destuguesvoid StrokeShape(SShape \*sh, layerdata \*d, int8 \*pattern)
95*a5061eceSAdrien Destugues------------------------------------------------------------
96*a5061eceSAdrien Destugues
97*a5061eceSAdrien Destuguesvoid FillShape(SShape \*sh, layerdata \*d, int8 \*pattern)
98*a5061eceSAdrien Destugues----------------------------------------------------------
99*a5061eceSAdrien Destugues
100*a5061eceSAdrien Destuguesvoid StrokeTriangle(BPoints \*pts, BRect r, layerdata \*d, int8 \*pattern)
101*a5061eceSAdrien Destugues--------------------------------------------------------------------------
102*a5061eceSAdrien Destugues
103*a5061eceSAdrien Destuguesvoid FillTriangle(BPoints \*pts, BRect r, layerdata \*d, int8 \*pattern)
104*a5061eceSAdrien Destugues------------------------------------------------------------------------
105*a5061eceSAdrien Destugues
106*a5061eceSAdrien Destuguesvoid ShowCursor(void)
107*a5061eceSAdrien Destugues---------------------
108*a5061eceSAdrien Destugues
109*a5061eceSAdrien Destuguesvoid HideCursor(void)
110*a5061eceSAdrien Destugues---------------------
111*a5061eceSAdrien Destugues
112*a5061eceSAdrien Destuguesvoid ObscureCursor(void)
113*a5061eceSAdrien Destugues------------------------
114*a5061eceSAdrien Destugues
115*a5061eceSAdrien Destuguesbool IsCursorHidden(void)
116*a5061eceSAdrien Destugues-------------------------
117*a5061eceSAdrien Destugues
118*a5061eceSAdrien Destuguesvoid SetCursor(ServerCursor \*csr)
119*a5061eceSAdrien Destugues----------------------------------
120*a5061eceSAdrien Destugues
121*a5061eceSAdrien Destuguesfloat StringWidth(const char \*string, int32 length, LayerData \*d)
122*a5061eceSAdrien Destugues-------------------------------------------------------------------
123*a5061eceSAdrien Destugues
124*a5061eceSAdrien Destuguesfloat StringHeight(const char \*string, int32 length, LayerData \*d)
125*a5061eceSAdrien Destugues--------------------------------------------------------------------
126*a5061eceSAdrien Destugues
127*a5061eceSAdrien Destugues
128*a5061eceSAdrien DestuguesThese drawing functions are the meat and potatoes of the graphics
129*a5061eceSAdrien Destuguesmodule. Defining any or all of them is completely optional. However,
130*a5061eceSAdrien Destuguesthe default versions of these functions will do nothing. Thus,
131*a5061eceSAdrien Destuguesimplementing them is likely a good idea, even if not required.
132*a5061eceSAdrien Destugues
133*a5061eceSAdrien Destugues
134*a5061eceSAdrien Destugues
135*a5061eceSAdrien DestuguesProtected Functions
136*a5061eceSAdrien Destugues===================
137*a5061eceSAdrien Destugues
138*a5061eceSAdrien Destuguesuint8 GetDepth(void)
139*a5061eceSAdrien Destugues--------------------
140*a5061eceSAdrien Destugues
141*a5061eceSAdrien Destuguesuint16 GetHeight(void)
142*a5061eceSAdrien Destugues----------------------
143*a5061eceSAdrien Destugues
144*a5061eceSAdrien Destuguesuint16 GetWidth(void)
145*a5061eceSAdrien Destugues---------------------
146*a5061eceSAdrien Destugues
147*a5061eceSAdrien Destuguesscreen_mode GetMode(void)
148*a5061eceSAdrien Destugues-------------------------
149*a5061eceSAdrien Destugues
150*a5061eceSAdrien Destuguesvoid SetMode(screen_mode mode)
151*a5061eceSAdrien Destugues------------------------------
152*a5061eceSAdrien Destugues
153*a5061eceSAdrien Destugues
154*a5061eceSAdrien DestuguesThese five functions are called internally in order to get information
155*a5061eceSAdrien Destuguesabout the current state of the buffer in the module. GetDepth should
156*a5061eceSAdrien Destuguesreturn 8, 16, or 32, in any event because the server handles RGB color
157*a5061eceSAdrien Destuguesspaces of these depths only.
158*a5061eceSAdrien Destugues
159*a5061eceSAdrien Destugues
160*a5061eceSAdrien Destuguesbool DumpToFile(const char \*path)
161*a5061eceSAdrien Destugues----------------------------------
162*a5061eceSAdrien Destugues
163*a5061eceSAdrien DestuguesDumpToFile is completely optional, providing a hook which allows
164*a5061eceSAdrien Destuguesscreenshots to be taken. The default version does nothing but return
165*a5061eceSAdrien Destuguesfalse. If a screenshot is successful, return true.
166*a5061eceSAdrien Destugues
167*a5061eceSAdrien Destugues
168*a5061eceSAdrien Destuguesvoid Lock(void)
169*a5061eceSAdrien Destugues---------------
170*a5061eceSAdrien Destugues
171*a5061eceSAdrien Destuguesvoid Unlock(void)
172*a5061eceSAdrien Destugues-----------------
173*a5061eceSAdrien Destugues
174*a5061eceSAdrien Destugues
175*a5061eceSAdrien DestuguesThese two functions provide a locking scheme for the driver in order
176*a5061eceSAdrien Destuguesto easily make it thread safe. Note that it is not publicly callable.
177*a5061eceSAdrien Destugues
178*a5061eceSAdrien Destugues
179*a5061eceSAdrien Destuguesvoid SetDepthInternal(uint8 d)
180*a5061eceSAdrien Destugues------------------------------
181*a5061eceSAdrien Destugues
182*a5061eceSAdrien Destuguesvoid SetHeightInternal(uint16 h)
183*a5061eceSAdrien Destugues--------------------------------
184*a5061eceSAdrien Destugues
185*a5061eceSAdrien Destuguesvoid SetWidthInternal(uint16 w)
186*a5061eceSAdrien Destugues-------------------------------
187*a5061eceSAdrien Destugues
188*a5061eceSAdrien Destuguesvoid SetModeInternal(int32 m)
189*a5061eceSAdrien Destugues-----------------------------
190*a5061eceSAdrien Destugues
191*a5061eceSAdrien Destugues
192*a5061eceSAdrien DestuguesThese four functions set the internal state variables for height,
193*a5061eceSAdrien Destugueswidth, etc. If the driver reimplements the public members SetDepth(),
194*a5061eceSAdrien Destuguesetc, be sure to call the respective internal call so that calls to
195*a5061eceSAdrien DestuguesGetDepth(), etc. return the proper values.
196*a5061eceSAdrien Destugues
197*a5061eceSAdrien Destugues
198*a5061eceSAdrien Destuguesvoid SetCursorHidden(bool state)
199*a5061eceSAdrien Destugues--------------------------------
200*a5061eceSAdrien Destugues
201*a5061eceSAdrien Destuguesvoid SetCursorObscured(bool state)
202*a5061eceSAdrien Destugues----------------------------------
203*a5061eceSAdrien Destugues
204*a5061eceSAdrien Destuguesbool IsCursorObscured(void)
205*a5061eceSAdrien Destugues---------------------------
206*a5061eceSAdrien Destugues
207*a5061eceSAdrien Destugues
208*a5061eceSAdrien DestuguesThese calls handle internal state tracking so that subclasses don't
209*a5061eceSAdrien Destugueshave to.
210*a5061eceSAdrien Destugues
211