Metatarget for copying of testfile fixed.
[AROS.git] / workbench / libs / gallium / bltpiperesourcerastport.c
blobce6d2ea03cb15d8bb88e8e28448d4802b752d36a
1 /*
2 Copyright 2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <graphics/rastport.h>
7 #include <hidd/graphics.h>
8 #include <proto/alib.h>
9 #include <proto/layers.h>
10 #include <proto/graphics.h>
11 #include <gallium/pipe/p_state.h>
12 #include <aros/debug.h>
14 #include "gallium_intern.h"
16 #define HIDD_BM_OBJ(bitmap) (*(OOP_Object **)&((bitmap)->Planes[0]))
18 /*****************************************************************************
20 NAME */
22 AROS_LH8(void, BltPipeResourceRastPort,
24 /* SYNOPSIS */
25 AROS_LHA(struct pipe_resource *, srcPipeResource, A0),
26 AROS_LHA(LONG , xSrc, D0),
27 AROS_LHA(LONG , ySrc, D1),
28 AROS_LHA(struct RastPort * , destRP, A1),
29 AROS_LHA(LONG , xDest, D2),
30 AROS_LHA(LONG , yDest, D3),
31 AROS_LHA(LONG , xSize, D4),
32 AROS_LHA(LONG , ySize, D5),
34 /* LOCATION */
35 struct Library *, GalliumBase, 8, Gallium)
37 /* NAME
39 FUNCTION
40 Copies part of pipe resource onto rast port. Clips output by using layers of
41 rastport.
43 INPUTS
44 srcPipeResource - Copy from this pipe resource.
45 xSrc, ySrc - This is the upper left corner of the area to copy.
46 destRP - Destination RastPort.
47 xDest, yDest - Upper left corner where to place the copy
48 xSize, ySize - The size of the area to copy
50 RESULT
52 BUGS
54 INTERNALS
56 HISTORY
58 *****************************************************************************/
60 AROS_LIBFUNC_INIT
62 struct Layer *L = destRP->Layer;
63 struct ClipRect *CR;
64 struct Rectangle renderableLayerRect;
65 BOOL copied = FALSE;
67 struct HIDDT_WinSys * ws = (struct HIDDT_WinSys *)srcPipeResource->screen->winsys;
68 if (!ws)
69 return;
71 if (!IsLayerVisible(L))
72 return;
74 LockLayerRom(L);
76 renderableLayerRect.MinX = L->bounds.MinX + xDest;
77 renderableLayerRect.MaxX = L->bounds.MinX + xDest + xSize - 1;
78 renderableLayerRect.MinY = L->bounds.MinY + yDest;
79 renderableLayerRect.MaxY = L->bounds.MinY + yDest + ySize - 1;
80 if (renderableLayerRect.MinX < L->bounds.MinX)
81 renderableLayerRect.MinX = L->bounds.MinX;
82 if (renderableLayerRect.MaxX > L->bounds.MaxX)
83 renderableLayerRect.MaxX = L->bounds.MaxX;
84 if (renderableLayerRect.MinY < L->bounds.MinY)
85 renderableLayerRect.MinY = L->bounds.MinY;
86 if (renderableLayerRect.MaxY > L->bounds.MaxY)
87 renderableLayerRect.MaxY = L->bounds.MaxY;
90 /* Do not clip renderableLayerRect to screen rast port. CRs are already clipped and unclipped
91 layer coords are needed. */
93 CR = L->ClipRect;
95 for (;NULL != CR; CR = CR->Next)
97 D(bug("Cliprect (%d, %d, %d, %d), lobs=%p\n",
98 CR->bounds.MinX, CR->bounds.MinY, CR->bounds.MaxX, CR->bounds.MaxY,
99 CR->lobs));
101 /* I assume this means the cliprect is visible */
102 if (NULL == CR->lobs)
104 struct Rectangle result;
106 if (AndRectRect(&renderableLayerRect, &CR->bounds, &result))
108 /* This clip rect intersects renderable layer rect */
109 struct pHidd_Gallium_DisplayResource drmsg = {
110 mID : OOP_GetMethodID(IID_Hidd_Gallium, moHidd_Gallium_DisplayResource),
111 resource : srcPipeResource,
112 srcx : xSrc + result.MinX - L->bounds.MinX - xDest, /* x in the source buffer */
113 srcy : ySrc + result.MinY - L->bounds.MinY - yDest, /* y in the source buffer */
114 bitmap: destRP->BitMap,
115 dstx : result.MinX, /* Absolute (on bitmap) X of dest blit */
116 dsty : result.MinY, /* Absolute (on bitmap) Y of dest blit */
117 width : result.MaxX - result.MinX + 1, /* width of the rect in source buffer */
118 height : result.MaxY - result.MinY + 1, /* height of the rect in source buffer */
120 OOP_DoMethod(ws->driver, (OOP_Msg)&drmsg);
122 copied = TRUE;
127 /* Notify the bitmap about blitting */
128 if (copied)
130 struct pHidd_BitMap_UpdateRect urmsg = {
131 mID : OOP_GetMethodID(IID_Hidd_BitMap, moHidd_BitMap_UpdateRect),
132 x : renderableLayerRect.MinX,
133 y : renderableLayerRect.MinY,
134 width : renderableLayerRect.MaxX - renderableLayerRect.MinX + 1,
135 height : renderableLayerRect.MaxY - renderableLayerRect.MinY + 1
138 OOP_Object * bm = HIDD_BM_OBJ(destRP->BitMap);
139 OOP_DoMethod(bm, (OOP_Msg)&urmsg);
142 UnlockLayerRom(L);
144 AROS_LIBFUNC_EXIT