1*a5061eceSAdrien DestuguesBitmapManager class 2*a5061eceSAdrien Destugues################### 3*a5061eceSAdrien Destugues 4*a5061eceSAdrien DestuguesThe BitmapManager object handles all ServerBitmap allocation and 5*a5061eceSAdrien Destuguesdeallocation. The rest of the server uses CreateBitmap and DeleteBitmap 6*a5061eceSAdrien Destuguesinstead of new and delete. 7*a5061eceSAdrien Destugues 8*a5061eceSAdrien DestuguesMember Functions 9*a5061eceSAdrien Destugues================ 10*a5061eceSAdrien Destugues 11*a5061eceSAdrien DestuguesBitmapManager(void) 12*a5061eceSAdrien Destugues------------------- 13*a5061eceSAdrien Destugues 14*a5061eceSAdrien Destugues1. Create the bitmap list 15*a5061eceSAdrien Destugues2. Create the bitmap area 16*a5061eceSAdrien Destugues3. Allocate the access semaphore 17*a5061eceSAdrien Destugues4. Call set_buffer_area_management 18*a5061eceSAdrien Destugues5. Set up the buffer pool via bpool 19*a5061eceSAdrien Destugues 20*a5061eceSAdrien Destugues~BitmapManager(void) 21*a5061eceSAdrien Destugues-------------------- 22*a5061eceSAdrien Destugues 23*a5061eceSAdrien Destugues1. Iterate over each item in the bitmap list, removing each item, 24*a5061eceSAdrien Destugues calling brel() on its buffer, and deleting it. 25*a5061eceSAdrien Destugues2. Delete the bitmap list 26*a5061eceSAdrien Destugues3. Delete the bitmap area 27*a5061eceSAdrien Destugues4. Free the access semaphore 28*a5061eceSAdrien Destugues 29*a5061eceSAdrien DestuguesServerBitmap \*CreateBitmap(BRect bounds, color_space space, int32 flags, int32 bytes_per_row=-1, screen_id screen=B_MAIN_SCREEN_ID) 30*a5061eceSAdrien Destugues------------------------------------------------------------------------------------------------------------------------------------ 31*a5061eceSAdrien Destugues 32*a5061eceSAdrien DestuguesCreateBitmap is called by outside objects to allocate a ServerBitmap 33*a5061eceSAdrien Destuguesobject. If a problem occurs, it returns NULL. 34*a5061eceSAdrien Destugues 35*a5061eceSAdrien Destugues1. Acquire the access semaphore 36*a5061eceSAdrien Destugues2. Verify parameters and if any are invalid, spew an error to stderr and 37*a5061eceSAdrien Destugues return NULL 38*a5061eceSAdrien Destugues3. Allocate a new ServerBitmap 39*a5061eceSAdrien Destugues4. Allocate a buffer for the bitmap with the bitmap's 40*a5061eceSAdrien Destugues theoretical buffer length 41*a5061eceSAdrien Destugues5. If NULL, delete the bitmap and return NULL 42*a5061eceSAdrien Destugues6. Set the bitmap's area and buffer to the appropriate values (area_for 43*a5061eceSAdrien Destugues buffer and buffer) 44*a5061eceSAdrien Destugues7. Add the bitmap to the bitmap list 45*a5061eceSAdrien Destugues8. Release the access semaphore 46*a5061eceSAdrien Destugues9. Return the bitmap 47*a5061eceSAdrien Destugues 48*a5061eceSAdrien Destuguesvoid DeleteBitmap(ServerBitmap \*bitmap) 49*a5061eceSAdrien Destugues---------------------------------------- 50*a5061eceSAdrien Destugues 51*a5061eceSAdrien DestuguesFrees a ServerBitmap allocated by CreateBitmap() 52*a5061eceSAdrien Destugues 53*a5061eceSAdrien Destugues1. Acquire the access semaphore 54*a5061eceSAdrien Destugues2. Find the bitmap in the list 55*a5061eceSAdrien Destugues3. Remove the bitmap from the list or release the semaphore and return 56*a5061eceSAdrien Destugues if not found 57*a5061eceSAdrien Destugues4. call brel() on the bitmap's buffer if it is non-NULL 58*a5061eceSAdrien Destugues5. delete the bitmap 59*a5061eceSAdrien Destugues6. Release the access semaphore 60*a5061eceSAdrien Destugues 61