Rev 876 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 876 | Rev 877 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | int Line(draw_t *draw) |
|
- | 2 | { |
|
- | 3 | local_pixmap_t *dstpixmap; |
|
- | 4 | clip_t clip; |
|
- | 5 | int x0, y0, x1, y1; |
|
- | 6 | ||
- | 7 | dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ; |
|
- | 8 | ||
- | 9 | x0 = draw->x0; |
|
- | 10 | y0 = draw->y0; |
|
- | 11 | ||
- | 12 | x1 = draw->x1; |
|
- | 13 | y1 = draw->y1; |
|
- | 14 | ||
- | 15 | clip.xmin = 0; |
|
- | 16 | clip.ymin = 0; |
|
- | 17 | clip.xmax = dstpixmap->width-1; |
|
- | 18 | clip.ymax = dstpixmap->height-1; |
|
- | 19 | ||
- | 20 | if ( !LineClip(&clip, &x0, &y0, &x1, &y1 )) |
|
- | 21 | { |
|
- | 22 | u32_t efl; |
|
- | 23 | u32_t *ring, write; |
|
- | 24 | ||
- | 25 | efl = safe_cli(); |
|
- | 26 | ||
- | 27 | #if R300_PIO |
|
- | 28 | ||
- | 29 | R5xxFIFOWait(6); |
|
- | 30 | ||
- | 31 | OUTREG(R5XX_DP_GUI_MASTER_CNTL, |
|
- | 32 | rhd.gui_control | |
|
- | 33 | R5XX_GMC_BRUSH_SOLID_COLOR | |
|
- | 34 | R5XX_GMC_SRC_DATATYPE_COLOR | |
|
- | 35 | R5XX_GMC_CLR_CMP_CNTL_DIS | |
|
- | 36 | R5XX_GMC_WR_MSK_DIS | |
|
- | 37 | R5XX_ROP3_P |
|
- | 38 | ); |
|
- | 39 | ||
- | 40 | OUTREG(R5XX_DST_LINE_PATCOUNT, 0x55 << R5XX_BRES_CNTL_SHIFT); |
|
- | 41 | ||
- | 42 | OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color); |
|
- | 43 | OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset); |
|
- | 44 | ||
- | 45 | OUTREG(R5XX_DST_LINE_START,(y0<<16)|x0); |
|
- | 46 | OUTREG(R5XX_DST_LINE_END,(y1<<16)|x1); |
|
- | 47 | #else |
|
- | 48 | BEGIN_RING(); |
|
- | 49 | OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_POLYLINE, 4)); |
|
- | 50 | OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | |
|
- | 51 | RADEON_GMC_BRUSH_SOLID_COLOR | |
|
- | 52 | RADEON_GMC_DST_32BPP | |
|
- | 53 | RADEON_GMC_SRC_DATATYPE_COLOR | |
|
- | 54 | R5XX_GMC_CLR_CMP_CNTL_DIS | |
|
- | 55 | R5XX_GMC_WR_MSK_DIS | |
|
- | 56 | R5XX_ROP3_P); |
|
- | 57 | ||
- | 58 | OUT_RING(dstpixmap->pitch_offset); |
|
- | 59 | OUT_RING(draw->color); |
|
- | 60 | OUT_RING((y0<<16)|x0); |
|
- | 61 | OUT_RING((y1<<16)|x1); |
|
- | 62 | COMMIT_RING(); |
|
- | 63 | ||
- | 64 | #endif |
|
- | 65 | safe_sti(efl); |
|
- | 66 | }; |
|
- | 67 | return ERR_OK; |
|
- | 68 | } |
|
Line 1... | Line 69... | ||
1 | int DrawRect(draw_t* draw) |
69 | |
2 | { |
70 | int DrawRect(draw_t* draw) |
3 | int x0, y0, x1, y1; |
71 | { |
Line 213... | Line 281... | ||
213 | return ERR_OK; |
281 | } ; |
214 | } |
282 | return ERR_OK; |
215 | 283 | } |
|
216 | int Line2P(draw_t *draw) |
284 | |
Line 217... | Line -... | ||
217 | { |
- | |
218 | local_pixmap_t *dstpixmap; |
- | |
219 | int x0, y0, x1, y1; |
- | |
220 | - | ||
221 | dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ; |
- | |
222 | - | ||
223 | x0 = draw->x0; |
- | |
224 | y0 = draw->y0; |
- | |
225 | - | ||
226 | x1 = draw->x1; |
- | |
227 | y1 = draw->y1; |
- | |
228 | - | ||
229 | if ( !LineClip(&clip, &x0, &y0, &x1, &y1 )) |
- | |
230 | { |
- | |
231 | u32 efl; |
- | |
232 | u32 *ring, write; |
- | |
233 | - | ||
234 | efl = safe_cli(); |
- | |
235 | - | ||
236 | #if R300_PIO |
- | |
237 | - | ||
238 | R5xxFIFOWait(6); |
- | |
239 | - | ||
240 | OUTREG(R5XX_DP_GUI_MASTER_CNTL, |
- | |
241 | rhd.gui_control | |
- | |
242 | R5XX_GMC_BRUSH_SOLID_COLOR | |
- | |
243 | R5XX_GMC_SRC_DATATYPE_COLOR | |
- | |
244 | R5XX_GMC_CLR_CMP_CNTL_DIS | |
- | |
245 | R5XX_GMC_WR_MSK_DIS | |
- | |
246 | R5XX_ROP3_P |
- | |
247 | ); |
- | |
248 | - | ||
249 | OUTREG(R5XX_DST_LINE_PATCOUNT, 0x55 << R5XX_BRES_CNTL_SHIFT); |
- | |
250 | - | ||
251 | OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color); |
- | |
252 | OUTREG(R5XX_DST_PITCH_OFFSET, rhd.dst_pitch_offset); |
- | |
253 | - | ||
254 | OUTREG(R5XX_DST_LINE_START,(y0<<16)|x0); |
- | |
255 | OUTREG(R5XX_DST_LINE_END,(y1<<16)|x1); |
- | |
256 | - | ||
257 | #else |
- | |
258 | - | ||
259 | BEGIN_RING(); |
- | |
260 | OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_POLYLINE, 4)); |
- | |
261 | OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | |
- | |
262 | RADEON_GMC_BRUSH_SOLID_COLOR | |
- | |
263 | RADEON_GMC_DST_32BPP | |
- | |
264 | RADEON_GMC_SRC_DATATYPE_COLOR | |
- | |
265 | R5XX_GMC_CLR_CMP_CNTL_DIS | |
- | |
266 | R5XX_GMC_WR_MSK_DIS | |
- | |
267 | R5XX_ROP3_P); |
- | |
268 | - | ||
269 | OUT_RING(rhd.dst_pitch_offset); |
- | |
270 | OUT_RING(draw->color); |
- | |
271 | OUT_RING((y0<<16)|x0); |
- | |
272 | OUT_RING((y1<<16)|x1); |
- | |
273 | COMMIT_RING(); |
- | |
274 | - | ||
275 | #endif |
- | |
276 | safe_sti(efl); |
285 | #endif |
277 | - | ||
Line 278... | Line -... | ||
278 | }; |
- | |
279 | return ERR_OK; |
- | |
280 | } |
- | |
281 | #endif |
- | |
282 | - | ||
283 | int CreatePixmap(pixmap_t *io) |
- | |
284 | { |
- | |
285 | local_pixmap_t *pixmap; |
- | |
286 | - | ||
287 | unsigned pitch; |
- | |
288 | size_t size; |
- | |
289 | - | ||
290 | void *local; |
- | |
291 | - | ||
292 | if( (io->width == 0) || (io->width > 2048)|| |
- | |
293 | (io->height == 0)|| (io->height > 2048)) |
- | |
294 | { |
- | |
295 | dbgprintf("Invalid pixmap size w:%d h:%d\n", io->width,io->height); |
- | |
296 | return ERR_PARAM; |
- | |
297 | }; |
- | |
298 | - | ||
299 | pitch = ((io->width+15)&~15)*4; |
- | |
300 | size = pitch*io->height; |
- | |
301 | - | ||
302 | dbgprintf("pitch = %d\n", pitch); |
- | |
303 | - | ||
304 | local = rhd_mem_alloc(&rhd,RHD_MEM_FB,size) ; |
- | |
305 | if ( !local) |
- | |
306 | { |
- | |
307 | dbgprintf("Not enough memory for pixmap\n"); |
- | |
308 | return ERR_PARAM; |
- | |
309 | }; |
- | |
310 | - | ||
311 | pixmap = malloc(sizeof(local_pixmap_t)); |
- | |
312 | if(!pixmap) |
- | |
313 | { |
- | |
314 | rhd_mem_free(&rhd, RHD_MEM_FB,local); |
- | |
315 | return ERR_PARAM; |
- | |
316 | } |
- | |
317 | else |
- | |
318 | { |
- | |
319 | void *mapped; |
- | |
320 | - | ||
321 | size = (size+4095) & ~ 4095; |
- | |
322 | - | ||
323 | if (mapped = UserAlloc(size)) |
- | |
324 | { |
- | |
325 | CommitPages(mapped, ((u32_t)local+rhd.PhisBase)|7|(1<<9), size); |
- | |
326 | - | ||
327 | io->mapped = mapped; |
- | |
328 | io->pitch = pitch; |
- | |
329 | io->handle = (u32_t)pixmap; |
- | |
330 | - | ||
331 | pixmap->width = io->width; |
- | |
332 | pixmap->height = io->height; |
- | |
333 | pixmap->format = PICT_a8r8g8b8; |
- | |
334 | pixmap->flags = io->flags; |
- | |
335 | pixmap->pitch = pitch; |
- | |
336 | pixmap->mapped = mapped; |
- | |
337 | pixmap->pitch_offset = ((pitch/64)<<22)| (((u32_t)local+rhd.FbIntAddress)>>10); |
- | |
338 | pixmap->local = local; |
- | |
339 | - | ||
340 | dbgprintf("pixmap.pitch_offset: %x\n", pixmap->pitch_offset); |
- | |
341 | dbgprintf("width: %d height: %d\n",pixmap->width,pixmap->height ); |
- | |
342 | dbgprintf("map at %x\n", pixmap->mapped); |
- | |
343 | - | ||
344 | return ERR_OK; |
- | |
345 | }; |
- | |
346 | rhd_mem_free(&rhd, RHD_MEM_FB,local); |
- | |
347 | free(pixmap); |
- | |
348 | }; |
- | |
349 | return ERR_PARAM; |
- | |
350 | }; |
- | |
351 | - | ||
352 | - | ||
353 | int DestroyPixmap( pixmap_t *io ) |
- | |
354 | { |
- | |
355 | local_pixmap_t *pixmap; |
- | |
356 | size_t size; |
- | |
357 | - | ||
358 | dbgprintf("Destroy pixmap %x\n", io->handle); |
- | |
359 | - | ||
360 | if(io->handle == -1) |
- | |
361 | return ERR_PARAM; |
- | |
362 | else |
- | |
363 | pixmap = (local_pixmap_t*)io->handle; |
- | |
364 | - | ||
365 | size = (pixmap->pitch*pixmap->height+4095) & ~ 4095; |
- | |
366 | - | ||
367 | UnmapPages(pixmap->mapped, size); |
- | |
368 | UserFree(pixmap->mapped); |
- | |
369 | - | ||
370 | rhd_mem_free(&rhd,RHD_MEM_FB,pixmap->local); |
- | |
371 | free(pixmap); |
- | |
372 | - | ||
373 | io->format = 0; |
- | |
374 | io->pitch = 0; |
- | |
375 | io->mapped = NULL; |
- | |
376 | io->handle = 0; |
- | |
377 | - | ||
378 | return ERR_OK; |
- | |
379 | }; |
- | |
Line 380... | Line 286... | ||
380 | 286 | ||
Line 381... | Line 287... | ||
381 | #if 0 |
287 | |
382 | 288 | #if 0 |