void BltRPtoCR(struct RastPort * rp, struct ClipRect * cr, ULONG Mode, struct LayersBase * LayersBase) { BltBitMap(rp->BitMap, cr->bounds.MinX, cr->bounds.MinY, cr->BitMap, ALIGN_OFFSET(cr->bounds.MinX), 0, cr->bounds.MaxX - cr->bounds.MinX + 1, cr->bounds.MaxY - cr->bounds.MinY + 1, Mode, ~0, NULL); }
struct DragObj * PRIVATE CreateDragObj(struct DragGadget *dg,int x,int y) { struct Screen *scr; struct RastPort *rp; struct DragObj *gdo; ULONG line; int wordwidth; int width,height,depth; int i = 0,xpos,ypos; scr = dg->dg_Window->WScreen; rp = &scr->RastPort; if (dg->dg_Flags & DGF_IMAGES && ((struct ImageNode *)dg->dg_Object.od_Object)->in_Image) dg->dg_Image = ((struct ImageNode *)dg->dg_Object.od_Object)->in_Image; if (!dg->dg_Width || !dg->dg_Height) { if ((dg->dg_Type == LISTVIEW_KIND) && !dg->dg_Image) { dg->dg_Width = dg->dg_Gadget->Width-20; dg->dg_Height = dg->dg_ItemHeight; } else if (!dg->dg_RenderHook && dg->dg_Image) { dg->dg_Width = dg->dg_Image->Width; dg->dg_Height = dg->dg_Image->Height; } else /* be sure width & height are not zero */ { dg->dg_Width = dg->dg_Gadget->Width; dg->dg_Height = dg->dg_Gadget->Height; } } width = dg->dg_Width; height = dg->dg_Height; memset(&dm,0,sizeof(struct DropMessage)); if (dg->dg_Type == LISTVIEW_KIND) { xpos = dg->dg_Gadget->LeftEdge+2; ypos = dg->dg_Gadget->TopEdge+2; dg->dg_Object.od_Object = NULL; if (y < ypos || y > ypos+dg->dg_Gadget->Height-5) return(NULL); line = (y-ypos)/dg->dg_ItemHeight; ypos += line*dg->dg_ItemHeight; GT_GetGadgetAttrs(dg->dg_Gadget,dg->dg_Window,NULL,GTLV_Labels,&dg->dg_List,TAG_END); if (dg->dg_List && !IsListEmpty(dg->dg_List)) { GT_GetGadgetAttrs(dg->dg_Gadget,dg->dg_Window,NULL,GTLV_Top,&i,TAG_END); i += line; if (i < CountNodes(dg->dg_List)) { struct Node *ln; dm.dm_SourceEntry = i; for(ln = dg->dg_List->lh_Head;i;i--,ln = ln->ln_Succ); if (dg->dg_Flags & DGF_TREEVIEW && TREENODE(ln)->tn_Flags & TNF_STATIC) { mx = ~0L; // avoid a following drag return(NULL); } dg->dg_Object.od_Object = ln; if (dg->dg_ObjectFunc) dg->dg_ObjectFunc(dg->dg_Window,dg->dg_Gadget,&dg->dg_Object,dm.dm_SourceEntry); } } } else { if (dg->dg_ObjectFunc) dg->dg_ObjectFunc(dg->dg_Window,dg->dg_Gadget,&dg->dg_Object,0L); dm.dm_SourceEntry = dg->dg_SourceEntry; xpos = x-width/2; ypos = y-height/2; } if (!dg->dg_Object.od_Object) { mx = ~0L; // avoid a following drag return(NULL); } wordwidth = (width + 15) >> 4; depth = GetBitMapAttr(rp->BitMap,BMA_DEPTH); if (dg->dg_Object.od_Object && (gdo = AllocMem(sizeof(struct DragObj), MEMF_CLEAR | MEMF_PUBLIC))) { #ifdef LOCKLAYERS LockLayers(&scr->LayerInfo); UnlockLayer(dg->dg_Window->RPort->Layer); #endif gdo->do_Screen = scr; gdo->do_ScrRPort = rp; gdo->do_BitMap = AllocBitMap(width,height,depth,BMF_CLEAR | BMF_MINPLANES,!(GetBitMapAttr( rp->BitMap, BMA_FLAGS ) & BMF_INTERLEAVED) ? rp->BitMap : NULL); gdo->do_SaveBack = AllocBitMap(width,height,depth,BMF_CLEAR | BMF_MINPLANES,rp->BitMap); gdo->do_RefreshMap = AllocBitMap(width*2,height*2,depth,BMF_CLEAR | BMF_MINPLANES,rp->BitMap); if (GetBitMapAttr(gdo->do_BitMap,BMA_FLAGS) & BMF_STANDARD) i = MEMF_CHIP | MEMF_PUBLIC; else i = 0; gdo->do_FullShadow = AllocMem(2*wordwidth*height,i | MEMF_CLEAR); gdo->do_HalfShadow = AllocMem(2*wordwidth*height,i); if (gdo->do_BitMap && gdo->do_SaveBack && gdo->do_RefreshMap && gdo->do_FullShadow && gdo->do_HalfShadow) { InitRastPort(&gdo->do_RPort); gdo->do_RPort.BitMap = gdo->do_BitMap; InitRastPort(&gdo->do_RefreshRPort); gdo->do_RefreshRPort.BitMap = gdo->do_RefreshMap; gdo->do_DragGadget = dg; CopyMem(&dg->dg_Object,&dm.dm_Object,sizeof(struct ObjectDescription)); dm.dm_Window = dg->dg_Window; dm.dm_Gadget = dg->dg_Gadget; /*** create the drag&drop image ***/ if (dg->dg_RenderHook) { struct LVDrawMsg lvdm; SetFont(&gdo->do_RPort,scr->RastPort.Font); lvdm.lvdm_MethodID = LV_DRAW; lvdm.lvdm_RastPort = &gdo->do_RPort; lvdm.lvdm_DrawInfo = GetScreenDrawInfo(scr); lvdm.lvdm_Bounds.MinX = 0; lvdm.lvdm_Bounds.MinY = 0; lvdm.lvdm_Bounds.MaxX = width-1; lvdm.lvdm_Bounds.MaxY = height-1; lvdm.lvdm_State = LVR_SELECTED; CallHookPkt(dg->dg_RenderHook,dm.dm_Object.od_Object,&lvdm); FreeScreenDrawInfo(scr,lvdm.lvdm_DrawInfo); } else if (dg->dg_Image) DrawImage(&gdo->do_RPort,dg->dg_Image,0,0); else ClipBlit(dg->dg_Window->RPort,xpos,ypos,&gdo->do_RPort,0,0,width,height,0xc0); /*** initialize drag object structure ***/ gdo->do_X = -9999; gdo->do_Y = ypos+dg->dg_Window->TopEdge; gdo->do_PX = -9999; gdo->do_Width = width; gdo->do_Height = height; gdo->do_DeltaX = xpos-x+dg->dg_Window->LeftEdge; gdo->do_DeltaY = ypos-y+dg->dg_Window->TopEdge; gdo->do_Mask = gdo->do_FullShadow; /*** create masks (transparent and full imagery) ***/ if (CyberGfxBase && (GetBitMapAttr(gdo->do_BitMap,BMA_FLAGS) & BMF_STANDARD) == 0L) { struct BitMap tbm; ULONG col; InitBitMap(&tbm,1,width,height); tbm.Planes[0] = (UBYTE *)gdo->do_FullShadow; /* if (!GetCyberMapAttr(gdo->do_BitMap, CYBRMATTR_PIXELFMT)) */ if (GetBitMapAttr(gdo->do_BitMap, BMA_DEPTH) > 8L) { ULONG triplet[3]; GetRGB32(scr->ViewPort.ColorMap,0L,1L,triplet); col = (triplet[0] & 0xff0000) | (triplet[1] & 0xff00) | (triplet[2] & 0xff); } else col = 0; // ExtractColor(rp,&tbm,col,xpos,ypos,width,height); ExtractColor(&gdo->do_RPort,&tbm,col,0,0,width,height); BltBitMap(&tbm,0,0,&tbm,0,0,width,height,0x50,0xff,NULL); // invertieren der Maske } else { UWORD *p = gdo->do_FullShadow; for(ypos = 0;ypos < height;ypos++) { for(xpos = 0;xpos < wordwidth;xpos++,p++) { for(i = 0;i < depth;i++) *p |= *((UWORD *)gdo->do_BitMap->Planes[i]+ypos*(gdo->do_BitMap->BytesPerRow >> 1)+xpos); } } } { UWORD *p = gdo->do_HalfShadow; CopyMem(gdo->do_FullShadow,p,2*wordwidth*height); for(line = 0x5555,ypos = 0;ypos < height;ypos++) { line = ~line; for(xpos = 0;xpos < wordwidth;xpos++,p++) *p &= (UWORD)line; } } if (!boopsigad) FakeInputEvent(); UpdateDragObj(gdo,gdo->do_X,gdo->do_Y); /* show drag object */ return(gdo); }
/* * Check whether the appearance of the VSprite has been changed * somehow. If for example the Image Data has changed, then * I will try to update the BitMap of the IntVSprite structure * to the new image data. */ BOOL _ValidateIntVSprite(struct IntVSprite * ivs, struct RastPort * rp, BOOL force_change, struct GfxBase * GfxBase) { struct VSprite * vs = ivs->VSprite; /* * Check whether the ImageData pointer has changed */ if (vs->ImageData != ivs->OrigImageData || force_change) { struct BitMap bm; #if 0 kprintf("%s: Imagedata has changed (old:%p-new:%p)!\n", __FUNCTION__, vs->ImageData, ivs->OrigImageData); kprintf("PlanePick: %02x, rp->BitMap:%p\n",vs->PlanePick,rp->BitMap); #endif /* * Only need to get a new bitmap if * something in the size of the bob has changed. */ if ((ivs->Width != vs->Width ) || (ivs->Height != vs->Height) || (ivs->Depth != vs->Depth ) ) { if (NULL != ivs->ImageData) FreeBitMap(ivs->ImageData); if (NULL != ivs->SaveBuffer) FreeBitMap(ivs->SaveBuffer); /* * Now get a new bitmap */ ivs->ImageData = AllocBitMap(vs->Width<<4, vs->Height, vs->Depth, BMF_CLEAR, rp->BitMap); ivs->SaveBuffer = AllocBitMap(vs->Width<<4, vs->Height, vs->Depth, 0, rp->BitMap); ivs->Width = vs->Width; ivs->Height = vs->Height; ivs->Depth = vs->Depth; } ivs->OrigImageData = vs->ImageData; /* * Blit the image data from the VSprite into the * ImageData (BitMap) of the IntVSprite */ InitBitMap(&bm, ivs->Depth, ivs->Width<<4, ivs->Height); { UBYTE *imagedata = (UBYTE *)vs->ImageData; WORD d, shift; for (d = 0, shift = 1; d < 8; d++, shift *= 2) { if (vs->PlanePick & shift) { bm.Planes[d] = imagedata; imagedata += (bm.Rows * bm.BytesPerRow); } else { bm.Planes[d] = (vs->PlaneOnOff & shift) ? (PLANEPTR)-1 : NULL; } } } BltBitMap(&bm, 0, 0, ivs->ImageData, 0, 0, ivs->Width << 4, ivs->Height, 0x0c0, vs->PlanePick, NULL); } return TRUE; }
/// /// MyBltMaskBitMap() static void MyBltMaskBitMap(const struct BitMap *srcBitMap, LONG xSrc, LONG ySrc, struct BitMap *destBitMap, LONG xDest, LONG yDest, LONG xSize, LONG ySize, struct BitMap *maskBitMap) { BltBitMap(srcBitMap,xSrc,ySrc,destBitMap, xDest, yDest, xSize, ySize, 0x99,~0,NULL); BltBitMap(maskBitMap,xSrc,ySrc,destBitMap, xDest, yDest, xSize, ySize, 0xe2,~0,NULL); BltBitMap(srcBitMap,xSrc,ySrc,destBitMap, xDest, yDest, xSize, ySize, 0x99,~0,NULL); }
// Window backfill void ASM SAVEDS PatternBackfill( REG(a0, PatternInstance *instance), REG(a2, struct RastPort *rport), REG(a1, struct BackFillInfo *info)) { PatternData *pattern; struct RastPort rp; short border_pen=0; // Copy rastport and clear any layer clipping rp=*rport; rp.Layer=0; // Get pattern pattern=instance->pattern; // Get border pen colour if (pattern->border_pen!=0) { border_pen=(pattern->border_pen==-1)?0:pattern->border_pen; } // Valid picture? if (pattern->valid && !instance->disabled && pattern->bitmap) { short offsetx,offsety; short SrcOffsetX,SrcOffsetY; short FirstSizeX,FirstSizeY; short SecondMinX,SecondMinY; short SecondSizeX,SecondSizeY; short Pos,Size; BOOL center=0; // Get offset #ifdef __AROS__ offsetx=info->bounds.MinX; offsety=info->bounds.MinY; #else offsetx=info->offsetx; offsety=info->offsety; #endif // Get centering flag if (pattern->flags&PATF_CENTER) center=1; // Icon mode, real-time scrolling? if (instance->hook.h_Data && environment->env->display_options&DISPOPTF_REALTIME_SCROLL) { BackdropInfo *info; // Get info pointer info=(BackdropInfo *)instance->hook.h_Data; // Adjust offset offsetx+=info->offset_x;//%pattern->width; offsety+=info->offset_y;//%pattern->height; } // Center pattern? if (center && info->layer) { short x,y,x0,y0,x1,y1; BOOL fail=0; // Get size of window FirstSizeX=(info->layer->bounds.MaxX-info->layer->bounds.MinX)+1; FirstSizeY=(info->layer->bounds.MaxY-info->layer->bounds.MinY)+1; // Get position of tile within window x=info->layer->bounds.MinX+((FirstSizeX-pattern->width)>>1); y=info->layer->bounds.MinY+((FirstSizeY-pattern->height)>>1); // Get position of tile x0=x; y0=y; x1=x+pattern->width-1; y1=y+pattern->height-1; // Check drawing does not go outside bounds if (x0<info->bounds.MinX) x0=info->bounds.MinX; else if (x0>info->bounds.MaxX) fail=1; if (y0<info->bounds.MinY) y0=info->bounds.MinY; else if (y0>info->bounds.MaxY) fail=1; if (x1>info->bounds.MaxX) x1=info->bounds.MaxX; else if (x1<info->bounds.MinX) fail=1; if (y1>info->bounds.MaxY) y1=info->bounds.MaxY; else if (y1<info->bounds.MinY) fail=1; // Ok to draw? if (!fail) { // Get position in source image SrcOffsetX=x0-x; SrcOffsetY=y0-y; // Blit the tile BltBitMap( pattern->bitmap, SrcOffsetX,SrcOffsetY, rp.BitMap, x0,y0, (x1-x0)+1,(y1-y0)+1, 0xc0,0xff,0); } // If we failed, just get the full center position to clear around it else { x0=x; y0=y; x1=x+pattern->width-1; y1=y+pattern->height-1; } // Set pen to clear other areas SetAPen(&rp,border_pen); SetDrMd(&rp,JAM1); // To the left of the image? if (info->bounds.MinX<x0) safe_RectFill(&rp, info->bounds.MinX,info->bounds.MinY, (info->bounds.MaxX<x0-1)?info->bounds.MaxX:(x0-1),info->bounds.MaxY); // To the right of the image? if (info->bounds.MaxX>x1) safe_RectFill(&rp, (info->bounds.MinX>x1)?info->bounds.MinX:(x1+1),info->bounds.MinY, info->bounds.MaxX,info->bounds.MaxY); // Above the image? if (info->bounds.MinY<y0) safe_RectFill(&rp, (info->bounds.MinX<x0)?x0:info->bounds.MinX,info->bounds.MinY, (info->bounds.MaxX>x1)?x1:info->bounds.MaxX,(info->bounds.MaxY<y0-1)?info->bounds.MaxY:(y0-1)); // Below the image? if (info->bounds.MaxY>y1) safe_RectFill(&rp, (info->bounds.MinX<x0)?x0:info->bounds.MinX,(info->bounds.MinY>y1)?info->bounds.MinY:(y1+1), (info->bounds.MaxX>x1)?x1:info->bounds.MaxX,info->bounds.MaxY); return; }
// Load a backfill pattern; pattern must be locked exclusively void GetPattern(PatternData *pattern,struct Screen *screen,ULONG border_col) { // Initially make invalid pattern->valid=FALSE; pattern->border_pen=0; // Set screen pointer pattern->screen=screen; // Check for invalid data if (!pattern->data) { // Update border pen GetPatternBorder(pattern,screen,border_col); return; } // Bitmap pattern? if (pattern->prefs.wbp_Flags&WBPF_PATTERN) { UWORD *ptr,*planes[MAXDEPTH]; short num,row,col,pen; // Get plane pointers for (num=0;num<pattern->prefs.wbp_Depth;num++) { planes[num]=((UWORD *)pattern->data)+(PAT_HEIGHT*num); } pattern->fill_plane_key=0; // Clear fill initially for (num=0,ptr=pattern->fill[0];num<128;num++,ptr++) *ptr=0; // Under 37 use fill pattern as supplied if (((struct Library *)GfxBase)->lib_Version<39) { for (num=0;num<pattern->prefs.wbp_Depth;num++) { CopyMem( (char *)planes[num], (char *)pattern->fill[num], PAT_HEIGHT*sizeof(UWORD)); } pattern->fill_plane_key=pattern->prefs.wbp_Depth; } // Otherwise, we need to remap else { // Go through pattern rows for (row=0;row<PAT_HEIGHT;row++) { // Go through bits for (col=0;col<PAT_WIDTH;col++) { // Clear pen pen=0; // Calculate pixel colour for (num=0;num<pattern->prefs.wbp_Depth;num++) { // Is bit set in this bitplane? if (planes[num][row]&(1<<col)) pen|=(1<<num); } // Pixel set? if (pen) { // Map pens 4-7 to top four colours if (pen>=4 && screen->RastPort.BitMap->Depth<=8) { pen=(1<<screen->RastPort.BitMap->Depth)-(8-pen); } // Remap for (num=0;num<8;num++) { // Want this bit? if (pen&(1<<num)) { // Set bit pattern->fill[num][row]|=1<<col; if (num>=pattern->fill_plane_key) pattern->fill_plane_key=num+1; } } } } } } // Any data? if (pattern->fill_plane_key>0) { short depth; // Get depth for bitmap if (((struct Library *)GfxBase)->lib_Version>=39) depth=GetBitMapAttr(screen->RastPort.BitMap,BMA_DEPTH); else depth=screen->RastPort.BitMap->Depth; // Check its not too deep if (depth>8) depth=8; // Allocate bitmap for pattern if ((pattern->pattern_bitmap= NewBitMap( PATTILE_SIZE, PATTILE_SIZE, depth, BMF_CLEAR, 0))) { struct RastPort rp; struct BitMap *bitmap; // Initialise dummy rastport InitRastPort(&rp); rp.BitMap=pattern->pattern_bitmap; // Set fill pattern SetAfPt(&rp,pattern->fill[0],-4); // Fill bitmap SetRast(&rp,0); RectFill(&rp,0,0,PATTILE_SIZE-1,PATTILE_SIZE-1); // Is the screen a non-standard bitmap? if (((struct Library *)GfxBase)->lib_Version>=39 && !(GetBitMapAttr(screen->RastPort.BitMap,BMA_FLAGS)&BMF_STANDARD)) { // Try and allocate friend bitmap if ((bitmap= NewBitMap( PATTILE_SIZE, PATTILE_SIZE, depth, BMF_CLEAR, screen->RastPort.BitMap))) { // Copy to friend bitmap BltBitMap( pattern->pattern_bitmap,0,0, bitmap,0,0, PATTILE_SIZE,PATTILE_SIZE, 0xc0,0xff,0); // Free original bitmap DisposeBitMap(pattern->pattern_bitmap); // Use new bitmap pointer pattern->pattern_bitmap=bitmap; } } // Get bitmap pointer pattern->bitmap=pattern->pattern_bitmap; // Get pattern size pattern->width=PATTILE_SIZE; pattern->height=PATTILE_SIZE; } } } // Picture; must have datatypes else if (DataTypesBase) { short len; BOOL remap=1; long precision=PRECISION_IMAGE; char name[256]; long ver=0; struct Library *pdt; #ifdef PATCH_OK APTR patchhandle=0; #endif // Check picture datatype version if ((pdt=OpenLibrary("sys:classes/datatypes/picture.datatype",0)) || (pdt=OpenLibrary("picture.datatype",0))) { // Get version ver=pdt->lib_Version; CloseLibrary(pdt); } // No remap? if ((len=strlen(pattern->data))>8 && stricmp(pattern->data+len-8,".noremap")==0) remap=0; // Precision? if (len>6 && stricmp(pattern->data+len-6,".exact")==0) precision=PRECISION_EXACT; // Specified in prefs? else if (pattern->precision) { if (pattern->precision==-1) remap=0; else if (pattern->precision==1) precision=PRECISION_ICON; else if (pattern->precision==2) precision=PRECISION_GUI; else if (pattern->precision==3) precision=PRECISION_EXACT; } #ifdef PATCH_OK // If we've got v43 of the datatype, we don't need the fastram patch if (ver<43) { // Add this task to the patchlist for allocbitmap patchhandle=AddAllocBitmapPatch(FindTask(0),screen); } #endif // Turn back on requesters ((struct Process *)FindTask(0))->pr_WindowPtr=GUI->window; // Check for random pictures, and then load picture if (pattern_check_random(pattern,name) && (pattern->object= NewDTObject(name, DTA_GroupID,GID_PICTURE, PDTA_Screen,screen, PDTA_FreeSourceBitMap,TRUE, (ver>42)?PDTA_DestMode:TAG_IGNORE,MODE_V43, (ver>42)?PDTA_UseFriendBitMap:TAG_IGNORE,TRUE, TAG_END))) { struct BitMapHeader *header; struct BitMap *bitmap; D_S(struct FileInfoBlock, fib) // Get file information if (GetFileInfo(name,fib) && strnicmp(fib->fib_Comment,"dopus ",6)==0) { char *args=fib->fib_Comment+6; short val; rexx_skip_space(&args); while ((val=rexx_match_keyword(&args,background_key,0))!=-1) { // Tile/center/stretch if (val==3) pattern->flags&=~(PATF_CENTER|PATF_STRETCH); else if (val==4) { pattern->flags|=PATF_CENTER; pattern->flags&=~PATF_STRETCH; } else if (val==5 && pattern->prefs.wbp_Which==0) { pattern->flags|=PATF_STRETCH; pattern->flags&=~PATF_CENTER; } // Precision else if (val==6) { // Get precision rexx_skip_space(&args); if ((val=rexx_match_keyword(&args,precision_key,0))>-1) { if (val==0) remap=0; else if (val==1) precision=PRECISION_GUI; else if (val==2) precision=PRECISION_ICON; else if (val==3) precision=PRECISION_IMAGE; else if (val==4) precision=PRECISION_EXACT; } } // Border else if (val==8) { // Off? rexx_skip_space(&args); if (rexx_match_keyword(&args,on_off_strings2,0)==0) border_col&=~ENVBF_USE_COLOUR; else { border_col=ENVBF_USE_COLOUR; border_col|=Atoh(args,-1)<<8; } } } } // Layout picture (should check for success) SetDTAttrs(pattern->object,0,0, OBP_Precision,precision, PDTA_Remap,remap, TAG_END); DoMethod(pattern->object,DTM_PROCLAYOUT,0,1); // Get bitmap pointer and header GetDTAttrs(pattern->object, PDTA_BitMap,&bitmap, PDTA_DestBitMap,&pattern->bitmap, PDTA_BitMapHeader,&header, TAG_END); // No dest bitmap? if (!pattern->bitmap) pattern->bitmap=bitmap; // Valid bitmap? if (pattern->bitmap) { // Get width and height pattern->width=header->bmh_Width; pattern->height=header->bmh_Height; } } // Turn off requesters ((struct Process *)FindTask(0))->pr_WindowPtr=(APTR)-1; #ifdef PATCH_OK // Remove this task from the patchlist for allocbitmap if (patchhandle) RemAllocBitmapPatch(patchhandle); #endif // Got bitmap? if (pattern->bitmap) { // Stretch? if (pattern->flags&PATF_STRETCH) { // Not the size of the screen? if (pattern->width!=screen->Width || pattern->height!=screen->Height) { // Allocate a bitmap for the stretched picture if ((pattern->pattern_bitmap= NewBitMap( screen->Width, screen->Height, GetBitMapAttr(pattern->bitmap,BMA_DEPTH), BMF_CLEAR, screen->RastPort.BitMap))) { struct BitScaleArgs scale; // Scale bitmap scale.bsa_SrcX=0; scale.bsa_SrcY=0; scale.bsa_SrcWidth=pattern->width; scale.bsa_SrcHeight=pattern->height; scale.bsa_DestX=0; scale.bsa_DestY=0; scale.bsa_DestWidth=screen->Width; scale.bsa_DestHeight=screen->Height; scale.bsa_XSrcFactor=scale.bsa_SrcWidth; scale.bsa_XDestFactor=scale.bsa_DestWidth; scale.bsa_YSrcFactor=scale.bsa_SrcHeight; scale.bsa_YDestFactor=scale.bsa_DestHeight; scale.bsa_SrcBitMap=pattern->bitmap; scale.bsa_DestBitMap=pattern->pattern_bitmap; scale.bsa_Flags=0; BitMapScale(&scale); // Get pointer to scaled bitmap pattern->bitmap=pattern->pattern_bitmap; pattern->width=screen->Width; pattern->height=screen->Height; } } } } // Update border pen GetPatternBorder(pattern,screen,border_col); } // Pattern ok now pattern->valid=TRUE; }
void BBB(struct BitMap *a,WORD b, WORD c,struct BitMap *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,UBYTE j,UWORD *k) {BltBitMap(a,b,c,d,e,f,g,h,i,j,k);}
HOOKPROTO(BackFillCode, VOID, struct RastPort *rp, struct LayerMsg *lmsg) { struct BackfillInfo *info = (struct BackfillInfo *)hook->h_Data; struct PictureFrame *pic = info->Picture; WORD minx, miny, maxx, maxy; minx = lmsg->bounds.MinX; miny = lmsg->bounds.MinY; maxx = lmsg->bounds.MaxX; maxy = lmsg->bounds.MaxY; LONG offx = lmsg->offsetx - info->subleft; LONG offy = lmsg->offsety - info->subtop; ULONG width, height, bmp_width = pic->Width, bmp_height = pic->Height; LONG xoffset = (info->left+offx) % bmp_width; LONG yoffset = (info->top+offy) % bmp_height; LONG srcx = xoffset, srcy = yoffset; struct BitMap *ysrc = pic->BMp, *dst = rp->BitMap; bmp_width -= xoffset; bmp_height -= yoffset; for(UWORD y = miny; y <= maxy; y += height) { height = min((ULONG)maxy-y+1, bmp_height); struct BitMap *src = ysrc; for(UWORD x = minx; x <= maxx; x += width) { width = min((ULONG)maxx-x+1, bmp_width); BltBitMap(src, srcx, srcy, dst, x, y, width, height, 0x0c0, ~0, NULL); if(src == dst) { bmp_width *= 2; } else if(x == minx && srcx) { srcx = 0; bmp_width = pic->Width; } else { src = dst; srcx = x; srcy = y; bmp_width = pic->Width; } } if(ysrc == dst) { bmp_height *= 2; } else if(y == miny && yoffset) { srcx = xoffset; srcy = yoffset = 0; bmp_width = pic->Width - xoffset; bmp_height = pic->Height; } else { ysrc = dst; srcx = minx; srcy = y; bmp_height = pic->Height; } } }
///ImageBackFill_CopyTiledBitMap() static void ImageBackFill_CopyTiledBitMap ( struct RastPort *SrcRast, WORD SrcOffsetX, WORD SrcOffsetY, WORD SrcSizeX, WORD SrcSizeY, struct RastPort *DstRast, struct Rectangle *DstAreaBounds, struct Rectangle *DstFillBounds, ULONG blit_MODE ) { WORD FirstSizeX; // the width of the rectangle to blit as the first column WORD FirstSizeY; // the height of the rectangle to blit as the first row WORD SecondMinX; // the left edge of the second column WORD SecondMinY; // the top edge of the second column WORD SecondSizeX; // the width of the second column WORD SecondSizeY; // the height of the second column WORD PosX, PosY; // used as starting position in the "exponential" blit WORD SizeX, SizeY; // used as bitmap size in the "exponential" blit WORD SrcX, SrcY; // used as bitmap size in the "exponential" blit struct BitMap *Src = SrcRast->BitMap; struct BitMap *Dst = DstRast->BitMap; #if defined(DEBUG) int xcount; int ycount; #endif D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap(mode %d)\n", blit_MODE)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: SrcRast @ %x, DstRast @ %x\n", SrcRast, DstRast)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds @ %x, FillBounds @ %x\n", DstAreaBounds, DstFillBounds)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds.MinX %d\n", DstAreaBounds->MinX)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds.MinY %d\n", DstAreaBounds->MinY)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds.MaxX %d\n", DstAreaBounds->MaxX)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds.MaxY %d\n", DstAreaBounds->MaxY)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: AreaBounds Width %d Height %d\n", (DstAreaBounds->MaxX - DstAreaBounds->MinX) + 1, (DstAreaBounds->MaxY - DstAreaBounds->MinY) + 1)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds.MinX %d\n", DstFillBounds->MinX)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds.MinY %d\n", DstFillBounds->MinY)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds.MaxX %d\n", DstFillBounds->MaxX)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds.MaxY %d\n", DstFillBounds->MaxY)); D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: FillBounds Width %d Height %d\n", (DstAreaBounds->MaxX - DstAreaBounds->MinX) + 1, (DstAreaBounds->MaxY - DstAreaBounds->MinY) + 1)); FirstSizeX = MIN(SrcSizeX - SrcOffsetX, RECTSIZEX(DstFillBounds)); // the width of the first tile, this is either the rest of the tile right to SrcOffsetX or the width of the dest rect, if the rect is narrow SecondMinX = DstFillBounds->MinX + FirstSizeX; // the start for the second tile (if used) SecondSizeX = MIN(SrcOffsetX, DstFillBounds->MaxX-SecondMinX + 1); // the width of the second tile (we want the whole tile to be SrcSizeX pixels wide, if we use SrcSizeX-SrcOffsetX pixels for the left part we'll use SrcOffsetX for the right part) FirstSizeY = MIN(SrcSizeY - SrcOffsetY, RECTSIZEY(DstFillBounds)); // the same values are calculated for y direction SecondMinY = DstFillBounds->MinY + FirstSizeY; SecondSizeY = MIN(SrcOffsetY, DstFillBounds->MaxY - SecondMinY + 1); if (blit_MODE == blit_MODE_Blit) // blit the first piece of the tile { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: 1st Tile Part @ %d,%d [%d x %d]\n", DstFillBounds->MinX, DstFillBounds->MinY, FirstSizeX, FirstSizeY)); BltBitMap(Src, SrcOffsetX, SrcOffsetY, Dst, DstFillBounds->MinX, DstFillBounds->MinY, FirstSizeX, FirstSizeY, 0xC0, -1, NULL); if (SecondSizeX > 0) // if SrcOffset was 0 or the dest rect was too narrow, we won't need a second column { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: 2nd Tile Part @ %d,%d [%d x %d]\n", SecondMinX, DstFillBounds->MinY, SecondSizeX, FirstSizeY)); BltBitMap(Src, 0, SrcOffsetY, Dst, SecondMinX, DstFillBounds->MinY, SecondSizeX, FirstSizeY, 0xC0, -1, NULL); } if (SecondSizeY > 0) // is a second row necessary? { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: 3rd Tile Part @ %d,%d [%d x %d]\n", DstFillBounds->MinX, SecondMinY, FirstSizeX, SecondSizeY)); BltBitMap(Src, SrcOffsetX, 0, Dst, DstFillBounds->MinX, SecondMinY, FirstSizeX, SecondSizeY, 0xC0, -1, NULL); if (SecondSizeX > 0) { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: 4th Tile Part @ %d,%d [%d x %d]\n", SecondMinX, SecondMinY, SecondSizeX, SecondSizeY)); BltBitMap(Src, 0, 0, Dst, SecondMinX, SecondMinY, SecondSizeX, SecondSizeY, 0xC0, -1, NULL); } } #if defined(DEBUG) xcount = 2; #endif //Generates the first row of the tiles .... for (PosX = DstFillBounds->MinX + SrcSizeX, SizeX = MIN(SrcSizeX, (DstFillBounds->MaxX - PosX) + 1);PosX <= DstFillBounds->MaxX;) { #if defined(DEBUG) D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: Row 1 Tile %d @ %d,%d [%d x %d]\n", xcount, PosX, DstFillBounds->MinY, SizeX, MIN(SrcSizeY, RECTSIZEY(DstFillBounds)))); xcount++; #endif BltBitMap(Dst, DstFillBounds->MinX, DstFillBounds->MinY, Dst, PosX, DstFillBounds->MinY, SizeX, MIN(SrcSizeY, RECTSIZEY(DstFillBounds)), 0xC0, -1, NULL); PosX += SizeX; SizeX = MIN(SrcSizeX, (DstFillBounds->MaxX - PosX) + 1); } #if defined(DEBUG) ycount = 2; #endif // .. now Blit the first row down several times to fill the whole dest rect for (PosY = DstFillBounds->MinY + SrcSizeY, SizeY = MIN(SrcSizeY, (DstFillBounds->MaxY - PosY) + 1);PosY <= DstFillBounds->MaxY;) { #if defined(DEBUG) D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: Row %d @ %d,%d [%d x %d]\n", ycount, DstFillBounds->MinX, PosY, MIN(SrcSizeX, RECTSIZEX(DstFillBounds)), SizeY)); ycount++; #endif BltBitMap(Dst, DstFillBounds->MinX, DstFillBounds->MinY, Dst, DstFillBounds->MinX, PosY, MIN(SrcSizeX, RECTSIZEX(DstFillBounds)), SizeY, 0xC0, -1, NULL); PosY += SizeY; SizeY = MIN(SrcSizeY, (DstFillBounds->MaxY - PosY) + 1); } } else if (blit_MODE == blit_MODE_Clip) { for (SrcY = MOD(SrcOffsetY + MOD((DstFillBounds->MinY - DstAreaBounds->MinY), SrcSizeY - 1), SrcSizeY - 1), PosY = DstFillBounds->MinY, SizeY = MIN((SrcSizeY - SrcY), (DstFillBounds->MaxY - DstFillBounds->MinY ) + 1); PosY <= DstFillBounds->MaxY;) { for (SrcX = MOD(SrcOffsetX + MOD((DstFillBounds->MinX - DstAreaBounds->MinX), SrcSizeY - 1), SrcSizeX - 1), PosX = DstFillBounds->MinX, SizeX = MIN((SrcSizeX - SrcX), (DstFillBounds->MaxX - DstFillBounds->MinX ) + 1); PosX <= DstFillBounds->MaxX;) { D(bug("[IconWindow.ImageBackFill] ImageBackFill_CopyTiledBitMap: ClipBlit @ %d,%d [%d x %d]\n", PosX, PosY, SizeX, SizeY)); ClipBlit(SrcRast, SrcX, SrcY, DstRast, PosX, PosY, SizeX, SizeY, 0xC0); if (SrcX != 0) SrcX = 0; PosX += SizeX; SizeX = MIN(SrcSizeX, (DstFillBounds->MaxX - PosX) + 1); } if (SrcY != 0) SrcY = 0; PosY += SizeY; SizeY = MIN(SrcSizeY, (DstFillBounds->MaxY - PosY) + 1); } } }