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