/* This is how case 2 looks like: only x1 is inside the cliprect that is behind it x0 x1 this is how the cliprect behind has to be split y0 nnnnnnn nnononoooo MinY nnnnnooo nnnononooo nnnnnooo nnononoooo nnnnnooo nnnononooo nnnnnooo nnononoooo MaxY nnnnnooo y1 nnnnnnn M M i a n x X X*//* Rectangle R is pointing to the rectangle with the n's. ClipRect CR has the rectagle with the o's.*/struct ClipRect * Case_2(struct Rectangle * R, struct ClipRect * CR, struct BitMap * display_bm, struct Layer * newlayer, struct Layer * passivelayer){ struct ClipRect * CR_New1; struct BitMap * bm_old; /* Get a new structure for a 2nd ClipRect */ CR_New1 = _AllocClipRect(newlayer); /* If the ClipRect with the o's already had some backed up pixels in a bitmap-structure, then we have to split up the info found there in a bitmap which contains the info about the n's and the other one about the o's. If there were no backed up pixels so far we have to back up the ones that are overlapped now. This is the case for the part with the n's. */ if (NULL != CR_New1) { /* Initialize New1, it will contain the right part (o's) */ CR_New1->bounds.MinX = DEF_X1+1; CR_New1->bounds.MinY = DEF_MINY; CR_New1->bounds.MaxX = DEF_MAXX; CR_New1->bounds.MaxY = DEF_MAXY; CR_New1->lobs = CR->lobs; /* The new ClipRect goes behind the old one in the list */ CR_New1->Next = CR->Next; CR ->Next = CR_New1; bm_old = CR->BitMap; if (NULL != bm_old) { /* get two new bitmap structures they have the same height, but different width, but only if it's not a simple layer */ if (0 == (passivelayer->Flags & LAYERSIMPLE)) { if (0 == (passivelayer->Flags & LAYERSUPER)) { /* the "left" one (n's), ClipRect CR will hold it */ DEF_DO_THE_BLIT_CR(DEF_MINX, DEF_MINY, DEF_X1, DEF_MAXY, display_bm); /* the "right" one (o's) */ DEF_DO_THE_BLIT(CR_New1, CR-> lobs, display_bm); /* Dispose the old bitmap structure as everything that was backed up there is now in the two other bitmap structures */ FreeBitMap(bm_old); } else { CR_New1->BitMap = passivelayer->SuperBitMap; } } /* if (not a simple layer) */ if (CR->lobs->priority < newlayer->priority) CR -> lobs = newlayer; } else { /* get one new bitmap structure, if there is none. But only get it if the new layer is in front of the passive layer*/ /* the "left" one (n's) */ if (newlayer->priority > passivelayer->priority) { /* only for non-simple layers */ if (0 == (passivelayer->Flags & LAYERSIMPLE)) { ULONG AllocBitMapFlag = 0; struct BitMap * DestBM; LONG DestX, DestY; if ((CR->Flags & CR_NEEDS_NO_LAYERBLIT_DAMAGE) != 0 ) AllocBitMapFlag = BMF_CLEAR; if (0 == (passivelayer->Flags & LAYERSUPER)) { CR ->BitMap = AllocBitMap( DEF_X1 - DEF_MINX + 1 + 16, DEF_MAXY - DEF_MINY + 1, display_bm->Depth, AllocBitMapFlag, display_bm); /* out of memory */ if (NULL == CR->BitMap) return NULL; DestBM = CR->BitMap; DestX = DEF_MINX & 0x0f; DestY = 0; } else { /* it has a superbitmap */ DestX = CR->bounds.MinX - passivelayer->bounds.MinX + passivelayer->Scroll_X; DestY = CR->bounds.MinY - passivelayer->bounds.MinY + passivelayer->Scroll_Y; DestBM = passivelayer->SuperBitMap; CR -> BitMap = DestBM; } /* and back up the information for the part with the n's from the info found in the display bitmap. */ if (0 == AllocBitMapFlag) BltBitMap( display_bm, /* SrcBitMap = Display BitMap */ DEF_MINX, /* SrcX - no optimization !!! */ DEF_MINY, /* SrcY */ DestBM, /* DestBitMap */ DestX, /* DestX - optimized */ DestY, /* DestY */ DEF_X1 - DEF_MINX + 1, /* SizeX */ DEF_MAXY - DEF_MINY + 1,/* SizeY */ 0x0c0, /* Vanilla Copy */ 0xff, /* Mask */ NULL ); } /* if (not a simple layer) */ /* * Only update the lobs entry in the CR if the lobs pointer is NULL * or if the newlayer is further in the front than the previous layer * hiding this cliprect. */ if (NULL == CR->lobs || CR->lobs->priority < newlayer->priority ) CR -> lobs = newlayer; } } /* leave this code down here, otherwise the DEFs will go wrong */ /* Change CR, it will contain the left part (n's) */ CR->bounds.MaxX = DEF_X1; } return CR_New1;}