add place-holder directory for the a3000 wd533c93 scsi controller implementation.
[AROS.git] / workbench / libs / mesa / mesa3dgl_support.c
blobb8c25f36636c6783a5cedc364fabd7e410ad8b01
1 /*
2 Copyright © 2009-2019, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
8 #include <proto/utility.h>
9 #include <proto/exec.h>
10 #include <proto/graphics.h>
11 #include <proto/cybergraphics.h>
13 #include <cybergraphx/cybergraphics.h>
14 #include <graphics/rpattr.h>
16 #include "mesa3dgl_support.h"
18 VOID MESA3DGLSelectRastPort(struct mesa3dgl_context * ctx, struct TagItem * tagList)
20 D(bug("[MESA3DGL] %s()\n", __func__));
22 ctx->Screen = (struct Screen *)GetTagData(GLA_Screen, 0, tagList);
23 ctx->window = (struct Window *)GetTagData(GLA_Window, 0, tagList);
24 ctx->visible_rp = (struct RastPort *)GetTagData(GLA_RastPort, 0, tagList);
26 if (ctx->Screen)
28 D(bug("[MESA3DGL] %s: Screen @ 0x%p\n", __func__, ctx->Screen));
29 if (ctx->window)
31 D(bug("[MESA3DGL] %s: Window @ 0x%p\n", __func__, ctx->window));
32 if (!(ctx->visible_rp))
34 /* Use the windows rastport */
35 ctx->visible_rp = ctx->window->RPort;
36 D(bug("[MESA3DGL] %s: Windows RastPort @ 0x%p\n", __func__, ctx->visible_rp));
39 else
41 if (!(ctx->visible_rp))
43 /* Use the screens rastport */
44 ctx->visible_rp = &ctx->Screen->RastPort;
45 D(bug("[MESA3DGL] %s: Screens RastPort @ 0x%p\n", __func__, ctx->visible_rp));
49 else
51 /* Not passed a screen */
52 if (ctx->window)
54 D(bug("[MESA3DGL] %s: Window @ 0x%p\n", __func__, ctx->window));
55 /* Use the windows Screen */
56 ctx->Screen = ctx->window->WScreen;
57 D(bug("[MESA3DGL] %s: Windows Screen @ 0x%p\n", __func__, ctx->Screen));
59 if (!(ctx->visible_rp))
61 /* Use the windows rastport */
62 ctx->visible_rp = ctx->window->RPort;
63 D(bug("[MESA3DGL] %s: Windows RastPort @ 0x%p\n", __func__, ctx->visible_rp));
66 else
68 /* Only Passed A Rastport */
69 D(bug("[MESA3DGL] %s: Using RastPort only!\n"));
73 D(bug("[MESA3DGL] %s: Using RastPort @ 0x%p\n", __func__, ctx->visible_rp));
76 BOOL MESA3DGLStandardInit(struct mesa3dgl_context * ctx, struct TagItem *tagList)
78 LONG requestedwidth = 0, requestedheight = 0;
79 LONG requestedright = 0, requestedbottom = 0;
80 LONG defaultleft = 0, defaulttop = 0;
81 LONG defaultright = 0, defaultbottom = 0;
83 D(bug("[MESA3DGL] %s(ctx @ 0x%p, taglist @ 0x%p)\n", __func__, ctx, tagList));
85 /* Set the defaults based on window information */
86 if (ctx->window)
88 if(!(ctx->window->Flags & WFLG_GIMMEZEROZERO))
90 defaultleft = ctx->window->BorderLeft;
91 defaulttop = ctx->window->BorderTop;
92 defaultright = ctx->window->BorderRight;
93 defaultbottom = ctx->window->BorderBottom;
97 D(bug("[MESA3DGL] %s: Using RastPort @ 0x%p\n", __func__, ctx->visible_rp));
99 ctx->visible_rp = CloneRastPort(ctx->visible_rp);
101 D(bug("[MESA3DGL] %s: Cloned RastPort @ 0x%p\n", __func__, ctx->visible_rp));
103 /* We assume left and top are given or if there is a window, set to border left/top
104 or if there is no window set to 0 */
105 ctx->left = GetTagData(GLA_Left, defaultleft, tagList);
106 ctx->top = GetTagData(GLA_Top, defaulttop, tagList);
108 requestedright = GetTagData(GLA_Right, -1, tagList);
109 requestedbottom = GetTagData(GLA_Bottom, -1, tagList);
110 requestedwidth = GetTagData(GLA_Width, -1 , tagList);
111 requestedheight = GetTagData(GLA_Height, -1 , tagList);
113 /* Calculate rastport dimensions */
114 ctx->visible_rp_width =
115 ctx->visible_rp->Layer->bounds.MaxX - ctx->visible_rp->Layer->bounds.MinX + 1;
117 ctx->visible_rp_height =
118 ctx->visible_rp->Layer->bounds.MaxY - ctx->visible_rp->Layer->bounds.MinY + 1;
120 /* right will be either passed or calculated from width or 0 */
121 ctx->right = 0;
122 if (requestedright < 0)
124 if (requestedwidth >= 0)
126 requestedright = ctx->visible_rp_width - ctx->left - requestedwidth;
127 if (requestedright < 0) requestedright = 0;
129 else
130 requestedright = defaultright; /* Set the default here, not in GetDataData */
132 ctx->right = requestedright;
134 /* bottom will be either passed or calculated from height or 0 */
135 ctx->bottom = 0;
136 if (requestedbottom < 0)
138 if (requestedheight >= 0)
140 requestedbottom = ctx->visible_rp_height - ctx->top - requestedheight;
141 if (requestedbottom < 0) requestedbottom = 0;
143 else
144 requestedbottom = defaultbottom; /* Set the default here, not in GetDataData */
146 ctx->bottom = requestedbottom;
148 /* Init screen information */
149 if (ctx->Screen)
150 ctx->BitsPerPixel = GetCyberMapAttr(ctx->Screen->RastPort.BitMap, CYBRMATTR_BPPIX) * 8;
152 D(bug("[MESA3DGL] %s: Context Base dimensions set -:\n", __func__));
153 D(bug("[MESA3DGL] %s: ctx->visible_rp_width = %d\n", __func__, ctx->visible_rp_width));
154 D(bug("[MESA3DGL] %s: ctx->visible_rp_height = %d\n", __func__, ctx->visible_rp_height));
155 D(bug("[MESA3DGL] %s: ctx->left = %d\n", __func__, ctx->left));
156 D(bug("[MESA3DGL] %s: ctx->right = %d\n", __func__, ctx->right));
157 D(bug("[MESA3DGL] %s: ctx->top = %d\n", __func__, ctx->top));
158 D(bug("[MESA3DGL] %s: ctx->bottom = %d\n", __func__, ctx->bottom));
160 return TRUE;
163 VOID MESA3DGLRecalculateBufferWidthHeight(struct mesa3dgl_context * ctx)
165 ULONG newwidth = 0;
166 ULONG newheight = 0;
168 D(bug("[MESA3DGL] %s(0x%p)\n", __func__, ctx));
170 ctx->visible_rp_width =
171 ctx->visible_rp->Layer->bounds.MaxX - ctx->visible_rp->Layer->bounds.MinX + 1;
173 ctx->visible_rp_height =
174 ctx->visible_rp->Layer->bounds.MaxY - ctx->visible_rp->Layer->bounds.MinY + 1;
177 newwidth = ctx->visible_rp_width - ctx->left - ctx->right;
178 newheight = ctx->visible_rp_height - ctx->top - ctx->bottom;
180 if (newwidth < 0) newwidth = 0;
181 if (newheight < 0) newheight = 0;
184 if ((newwidth != ctx->framebuffer->width) || (newheight != ctx->framebuffer->height))
186 /* The drawing area size has changed. Buffer must change */
187 D(bug("[MESA3DGL] %s: current height = %d\n", __func__, ctx->framebuffer->height));
188 D(bug("[MESA3DGL] %s: current width = %d\n", __func__, ctx->framebuffer->width));
189 D(bug("[MESA3DGL] %s: new height = %d\n", __func__, newheight));
190 D(bug("[MESA3DGL] %s: new width = %d\n", __func__, newwidth));
192 ctx->framebuffer->width = newwidth;
193 ctx->framebuffer->height = newheight;
194 ctx->framebuffer->resized = TRUE;
196 if (ctx->window)
198 struct Rectangle rastcliprect;
199 struct TagItem crptags[] =
201 { RPTAG_ClipRectangle , (IPTR)&rastcliprect },
202 { RPTAG_ClipRectangleFlags , (RPCRF_RELRIGHT | RPCRF_RELBOTTOM) },
203 { TAG_DONE }
206 D(bug("[MESA3DGL] %s: Clipping Rastport to Window's dimensions\n", __func__));
208 /* Clip the rastport to the visible area */
209 rastcliprect.MinX = ctx->left;
210 rastcliprect.MinY = ctx->top;
211 rastcliprect.MaxX = ctx->left + ctx->framebuffer->width;
212 rastcliprect.MaxY = ctx->top + ctx->framebuffer->height;
213 SetRPAttrsA(ctx->visible_rp, crptags);
216 D(bug("[MESA3DGL] %s: done\n", __func__));
219 VOID MESA3DGLFreeContext(struct mesa3dgl_context * ctx)
221 if (ctx)
223 FreeVec(ctx);