Changeset 70
- Timestamp:
- May 20, 2001, 5:38:55 PM (24 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/gpih.h
r64 r70 235 235 typedef GPIHICON2BITMAP *PGPIHICON2BITMAP; 236 236 237 /* ****************************************************************** 238 * 239 * XBitmap functions 240 * 241 ********************************************************************/ 242 243 /* 244 *@@ XBITMAP: 245 * representation of an XBitmap, which is created 246 * with gpihCreateXBitmap and destroyed with 247 * gpihDestroyXBitmap. 248 * 249 * An XBitmap is essentially a set of a memory 250 * device context, a memory presentation space, 251 * and a bitmap which is selected into that 252 * HPS. 253 * 254 *@@added V0.9.12 (2001-05-20) [umoeller] 255 */ 256 257 typedef struct _XBITMAP 258 { 259 HDC hdcMem; // memory DC 260 HPS hpsMem; // memory PS 261 HBITMAP hbm; // bitmap handle 262 SIZEL szl; // size of bitmap 263 } XBITMAP, *PXBITMAP; 264 265 PXBITMAP XWPENTRY gpihCreateXBitmap(HAB hab, LONG cx, LONG cy); 266 typedef PXBITMAP XWPENTRY GPIHCREATEXBITMAP(HAB hab, LONG cx, LONG cy); 267 typedef GPIHCREATEXBITMAP *PGPIHCREATEXBITMAP; 268 269 VOID XWPENTRY gpihDestroyXBitmap(PXBITMAP *ppbmp); 270 typedef VOID XWPENTRY GPIHDESTROYXBITMAP(PXBITMAP *ppbmp); 271 typedef GPIHDESTROYXBITMAP *PGPIHDESTROYXBITMAP; 272 237 273 #endif 238 274 -
trunk/include/helpers/threads.h
r49 r70 47 47 ULONG cbStruct; 48 48 void* pThreadFunc; // as passed to thrCreate, really a PTHREADFUNC 49 P BOOL pfRunning; // as passed to thrCreate49 PULONG ptidRunning; // as passed to thrCreate V0.9.12 (2001-05-20) [umoeller] 50 50 const char *pcszThreadName; // as passed to thrCreate 51 51 ULONG flFlags; // as passed to thrCreate … … 58 58 HAB hab; // for PM threads 59 59 HMQ hmq; // for PM threads 60 BOOL fExitComplete; // TRUE if thr_fntGeneric is exiting60 BOOL fExitComplete; 61 61 62 62 // data to be maintained by application -
trunk/src/helpers/gpih.c
r63 r70 1479 1479 bih2.usReserved = 0; 1480 1480 bih2.usRecording = BRA_BOTTOMUP; // scan lines are bottom to top (default) 1481 bih2.usRendering = BRH_NOTHALFTONED; // other algorithms aren't documented anyway s1482 bih2.cSize1 = 0; // parameter for halftoning (undocumented anyway s)1483 bih2.cSize2 = 0; // parameter for halftoning (undocumented anyway s)1481 bih2.usRendering = BRH_NOTHALFTONED; // other algorithms aren't documented anyway 1482 bih2.cSize1 = 0; // parameter for halftoning (undocumented anyway) 1483 bih2.cSize2 = 0; // parameter for halftoning (undocumented anyway) 1484 1484 bih2.ulColorEncoding = BCE_RGB; // only possible value 1485 1485 bih2.ulIdentifier = 0; // application-specific data … … 1545 1545 * which can then be used for WinDrawBitmap and such, or 1546 1546 * NULLHANDLE upon errors. 1547 * 1548 *@@changed V0.9.12 (2001-05-20) [umoeller]: fixed excessive mem PS size 1547 1549 */ 1548 1550 … … 1564 1566 POINTL aptl[3]; 1565 1567 1566 SIZEL szlPage = {0, 0}; 1567 if (gpihCreateMemPS(hab, &szlPage, &hdcMem, &hpsMem)) 1568 SIZEL szlPage = {prcl->xRight - prcl->xLeft, 1569 prcl->yTop - prcl->yBottom}; // fixed V0.9.12 (2001-05-20) [umoeller] 1570 if (gpihCreateMemPS(hab, 1571 &szlPage, 1572 &hdcMem, 1573 &hpsMem)) 1568 1574 { 1569 1575 if ((hbm = gpihCreateBitmap(hpsMem, 1570 prcl->xRight - prcl->xLeft,1571 prcl->yTop - prcl->yBottom)))1576 szlPage.cx, 1577 szlPage.cy))) 1572 1578 { 1573 1579 // Associate the bit map and the memory presentation space. … … 1595 1601 hbm = NULLHANDLE; // for return code 1596 1602 } 1597 } else { 1603 } 1604 else 1605 { 1598 1606 // error selecting bitmap for hpsMem: 1599 1607 GpiDeleteBitmap(hbm); … … 2019 2027 } 2020 2028 2029 /* 2030 *@@category: Helpers\PM helpers\GPI helpers\XBitmaps 2031 * Extended bitmaps. See gpihCreateXBitmap for an introduction. 2032 */ 2033 2034 /* ****************************************************************** 2035 * 2036 * XBitmap functions 2037 * 2038 ********************************************************************/ 2039 2040 /* 2041 *@@ gpihCreateXBitmap: 2042 * creates an XBitmap, which is returned in an 2043 * _XBITMAP structure. 2044 * 2045 * The problem with all the GPI bitmap functions 2046 * is that they are quite complex and it is easy 2047 * to forget one of the "disassociate" and "deselect" 2048 * functions, which then simply leads to enormous 2049 * resource leaks in the application. 2050 * 2051 * This function may relieve this a bit. This 2052 * creates a memory DC, an memory PS, and a bitmap, 2053 * and selects the bitmap into the memory PS. 2054 * You can then use any GPI function on the memory 2055 * PS to draw into the bitmap. Use the fields from 2056 * _XBITMAP for that. 2057 * 2058 * The bitmap is created in RGB mode. 2059 * 2060 * Use gpihDestroyXBitmap to destroy the XBitmap 2061 * again. 2062 * 2063 * Example: 2064 * 2065 + PXBITMAP pbmp = gpihCreateXBitmap(hab, 100, 100); 2066 + if (pbmp) 2067 + { 2068 + GpiMove(pbmp->hpsMem, ...); 2069 + GpiBox(pbmp->hpsMem, ...); 2070 + 2071 + WinDrawBitmap(hpsScreen, 2072 + pbmp->hbm, // bitmap handle 2073 + ...); 2074 + gpihDestroyXBitmap(&pbmp); 2075 + } 2076 * 2077 * Without the gpih* functions, the above would expand 2078 * to more than 100 lines. 2079 * 2080 *@@added V0.9.12 (2001-05-20) [umoeller] 2081 */ 2082 2083 PXBITMAP gpihCreateXBitmap(HAB hab, // in: anchor block 2084 LONG cx, // in: bitmap width 2085 LONG cy) // in: bitmap height 2086 { 2087 BOOL fOK = FALSE; 2088 PXBITMAP pbmp = (PXBITMAP)malloc(sizeof(XBITMAP)); 2089 if (pbmp) 2090 { 2091 memset(pbmp, 0, sizeof(XBITMAP)); 2092 2093 // create memory PS for bitmap 2094 pbmp->szl.cx = cx; 2095 pbmp->szl.cy = cy; 2096 if (gpihCreateMemPS(hab, 2097 &pbmp->szl, 2098 &pbmp->hdcMem, 2099 &pbmp->hpsMem)) 2100 { 2101 gpihSwitchToRGB(pbmp->hpsMem); 2102 if (pbmp->hbm = gpihCreateBitmap(pbmp->hpsMem, 2103 cx, 2104 cy)) 2105 { 2106 if (GpiSetBitmap(pbmp->hpsMem, 2107 pbmp->hbm) 2108 != HBM_ERROR) 2109 fOK = TRUE; 2110 } 2111 } 2112 2113 if (!fOK) 2114 gpihDestroyXBitmap(&pbmp); 2115 } 2116 2117 return (pbmp); 2118 } 2119 2120 /* 2121 *@@ gpihDestroyXBitmap: 2122 * destroys an XBitmap created with gpihCreateXBitmap. 2123 * 2124 * To be on the safe side, this sets the 2125 * bitmap pointer to NULL as well. 2126 * 2127 *@@added V0.9.12 (2001-05-20) [umoeller] 2128 */ 2129 2130 VOID gpihDestroyXBitmap(PXBITMAP *ppbmp) 2131 { 2132 if (ppbmp) 2133 { 2134 PXBITMAP pbmp; 2135 if (pbmp = *ppbmp) 2136 { 2137 if (pbmp->hbm) 2138 { 2139 if (pbmp->hpsMem) 2140 GpiSetBitmap(pbmp->hpsMem, NULLHANDLE); 2141 GpiDeleteBitmap(pbmp->hbm); 2142 } 2143 if (pbmp->hpsMem) 2144 { 2145 GpiAssociate(pbmp->hpsMem, NULLHANDLE); 2146 GpiDestroyPS(pbmp->hpsMem); 2147 } 2148 if (pbmp->hdcMem) 2149 DevCloseDC(pbmp->hdcMem); 2150 2151 free(pbmp); 2152 2153 *ppbmp = NULL; 2154 } 2155 } 2156 } 2157 2158 -
trunk/src/helpers/threads.c
r52 r70 130 130 if (pti) 131 131 { 132 if (pti->pfRunning)133 // set "running" flag134 *(pti->pfRunning) = TRUE;135 136 132 if (pti->flFlags & THRF_WAIT) 137 133 // "Wait" flag set: thrCreate is then … … 174 170 } 175 171 176 // for non-transient threads:set exit flags172 // set exit flags 177 173 // V0.9.7 (2000-12-20) [umoeller] 178 174 pti->fExitComplete = TRUE; 179 175 pti->tid = NULLHANDLE; 180 176 181 if (pti->p fRunning)177 if (pti->ptidRunning) 182 178 // clear "running" flag 183 *(pti->p fRunning) = FALSE;179 *(pti->ptidRunning) = 0; 184 180 185 181 // (2000-12-18) [lafaix] clean up pti if thread is transient. … … 213 209 * The thread's ptiMyself is then a pointer to the 214 210 * THREADINFO structure passed to this function. 215 * ulData may be obtained like this:211 * In your thread function, ulData may be obtained like this: 216 212 * 217 213 + ULONG ulData = ptiMyself->ulData; 218 214 * 219 * The THREADINFO structure passed to this function must 220 * be accessible all the time while the thread is running 221 * because the thr* functions will use it for maintenance. 222 * 223 * This function does NOT check whether a thread is 224 * already running in *pti. Do not use the same THREADINFO 225 * for several threads. 226 * 227 * If you do not want to manage the structure yourself, 228 * you can pass the THRF_TRANSIENT flag (see below). 229 * 230 * thrCreate does not call your thread func directly, 215 * thrCreate does not start your thread func directly, 231 216 * but only through the thr_fntGeneric wrapper to 232 217 * provide additional functionality. As a consequence, … … 235 220 * (cleanup) in thr_fntGeneric. Instead, just fall out of 236 221 * your thread function, or return(). 222 * 223 * The THREADINFO structure passed to this function must 224 * be accessible all the time while the thread is running 225 * because the thr* functions will use it for maintenance. 226 * This function does NOT check whether a thread is 227 * already running in *pti. Do not use the same THREADINFO 228 * for several threads. 229 * 230 * If you do not want to manage the structure yourself, 231 * you can pass the THRF_TRANSIENT flag (see below). 232 * 233 * ptidRunning is an optional parameter and can be NULL. 234 * If non-null, it must point to a ULONG which will contain 235 * the thread's TID while the thread is still running. 236 * Once the thread exits, the ULONG will automatically 237 * be set to zero; this is useful for a quick check whether 238 * the thread is currently busy. 239 * 240 * Note: ptidRunning is only reliable if you set the 241 * THRF_WAIT or THRF_WAIT_EXPLICIT flags. 237 242 * 238 243 * flFlags can be any combination of the following: … … 252 257 * 253 258 * -- THRF_WAIT_EXPLICIT: like THRF_WAIT, but in this case, 254 * your thread function mustpost THREADINFO.hevRunning259 * your thread function _must_ post THREADINFO.hevRunning 255 260 * yourself (thr_fntGeneric will not automatically 256 261 * post it). Useful for waiting until your own thread … … 282 287 *@@changed V0.9.9 (2001-03-07) [umoeller]: added pcszThreadName 283 288 *@@changed V0.9.9 (2001-03-14) [umoeller]: added THRF_WAIT_EXPLICIT 289 *@@changed V0.9.12 (2001-05-20) [umoeller]: changed pfRunning to ptidRunning 284 290 */ 285 291 286 292 ULONG thrCreate(PTHREADINFO pti, // out: THREADINFO data 287 293 PTHREADFUNC pfn, // in: _Optlink thread function 288 P BOOL pfRunning, // out: variable set to TRUEwhile thread is running;294 PULONG ptidRunning, // out: variable set to TID while thread is running; 289 295 // ptr can be NULL 290 296 const char *pcszThreadName, // in: thread name (for identification) … … 307 313 pti->cbStruct = sizeof(THREADINFO); 308 314 pti->pThreadFunc = (PVOID)pfn; 309 pti->p fRunning = pfRunning;315 pti->ptidRunning = ptidRunning; 310 316 pti->pcszThreadName = pcszThreadName; // V0.9.9 (2001-03-07) [umoeller] 311 317 pti->flFlags = flFlags; … … 336 342 pti); // parameter passed to thread 337 343 ulrc = pti->tid; 344 345 if (pti->ptidRunning) 346 // set "running" flag // V0.9.12 (2001-05-20) [umoeller] 347 *(pti->ptidRunning) = pti->tid; 338 348 339 349 if (ulrc)
Note:
See TracChangeset
for help on using the changeset viewer.