start service tasks separately in-case platforms need to perform additional set-up...
[AROS.git] / workbench / libs / gallium / bltpiperesourcerastport.c
blobe4c114a7fbd63789cbdc457319c6c1dc02d65af5
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 /*****************************************************************************
18 NAME */
20 AROS_LH8(void, BltPipeResourceRastPort,
22 /* SYNOPSIS */
23 AROS_LHA(struct pipe_resource *, srcPipeResource, A0),
24 AROS_LHA(LONG , xSrc, D0),
25 AROS_LHA(LONG , ySrc, D1),
26 AROS_LHA(struct RastPort * , destRP, A1),
27 AROS_LHA(LONG , xDest, D2),
28 AROS_LHA(LONG , yDest, D3),
29 AROS_LHA(LONG , xSize, D4),
30 AROS_LHA(LONG , ySize, D5),
32 /* LOCATION */
33 struct Library *, GalliumBase, 8, Gallium)
35 /* FUNCTION
36 Copies part of pipe resource onto rast port. Clips output by using layers of
37 rastport.
39 INPUTS
40 srcPipeResource - Copy from this pipe resource.
41 xSrc, ySrc - This is the upper left corner of the area to copy.
42 destRP - Destination RastPort.
43 xDest, yDest - Upper left corner where to place the copy
44 xSize, ySize - The size of the area to copy
46 RESULT
48 BUGS
50 INTERNALS
52 HISTORY
54 *****************************************************************************/
56 AROS_LIBFUNC_INIT
58 struct Layer *L = destRP->Layer;
59 struct ClipRect *CR;
60 struct Rectangle renderableLayerRect;
61 BOOL copied = FALSE;
63 struct HIDDT_WinSys * ws = (struct HIDDT_WinSys *)srcPipeResource->screen->winsys;
64 if (!ws)
65 return;
67 if (!IsLayerVisible(L))
68 return;
70 LockLayerRom(L);
72 renderableLayerRect.MinX = L->bounds.MinX + xDest;
73 renderableLayerRect.MaxX = L->bounds.MinX + xDest + xSize - 1;
74 renderableLayerRect.MinY = L->bounds.MinY + yDest;
75 renderableLayerRect.MaxY = L->bounds.MinY + yDest + ySize - 1;
76 if (renderableLayerRect.MinX < L->bounds.MinX)
77 renderableLayerRect.MinX = L->bounds.MinX;
78 if (renderableLayerRect.MaxX > L->bounds.MaxX)
79 renderableLayerRect.MaxX = L->bounds.MaxX;
80 if (renderableLayerRect.MinY < L->bounds.MinY)
81 renderableLayerRect.MinY = L->bounds.MinY;
82 if (renderableLayerRect.MaxY > L->bounds.MaxY)
83 renderableLayerRect.MaxY = L->bounds.MaxY;
86 /* Do not clip renderableLayerRect to screen rast port. CRs are already clipped and unclipped
87 layer coords are needed. */
89 CR = L->ClipRect;
91 for (;NULL != CR; CR = CR->Next)
93 D(bug("Cliprect (%d, %d, %d, %d), lobs=%p\n",
94 CR->bounds.MinX, CR->bounds.MinY, CR->bounds.MaxX, CR->bounds.MaxY,
95 CR->lobs));
97 /* I assume this means the cliprect is visible */
98 if (NULL == CR->lobs)
100 struct Rectangle result;
102 if (AndRectRect(&renderableLayerRect, &CR->bounds, &result))
104 /* This clip rect intersects renderable layer rect */
105 struct pHidd_Gallium_DisplayResource drmsg = {
106 mID : OOP_GetMethodID(IID_Hidd_Gallium, moHidd_Gallium_DisplayResource),
107 resource : srcPipeResource,
108 srcx : xSrc + result.MinX - L->bounds.MinX - xDest, /* x in the source buffer */
109 srcy : ySrc + result.MinY - L->bounds.MinY - yDest, /* y in the source buffer */
110 bitmap: destRP->BitMap,
111 dstx : result.MinX, /* Absolute (on bitmap) X of dest blit */
112 dsty : result.MinY, /* Absolute (on bitmap) Y of dest blit */
113 width : result.MaxX - result.MinX + 1, /* width of the rect in source buffer */
114 height : result.MaxY - result.MinY + 1, /* height of the rect in source buffer */
116 OOP_DoMethod(ws->driver, (OOP_Msg)&drmsg);
118 copied = TRUE;
123 /* Notify the bitmap about blitting */
124 if (copied)
126 struct pHidd_BitMap_UpdateRect urmsg = {
127 mID : OOP_GetMethodID(IID_Hidd_BitMap, moHidd_BitMap_UpdateRect),
128 x : renderableLayerRect.MinX,
129 y : renderableLayerRect.MinY,
130 width : renderableLayerRect.MaxX - renderableLayerRect.MinX + 1,
131 height : renderableLayerRect.MaxY - renderableLayerRect.MinY + 1
134 OOP_Object * bm = HIDD_BM_OBJ(destRP->BitMap);
135 OOP_DoMethod(bm, (OOP_Msg)&urmsg);
138 UnlockLayerRom(L);
140 AROS_LIBFUNC_EXIT