revert between 56095 -> 55830 in arch
[AROS.git] / workbench / hidds / nouveau / nouveau_bitmapclass.c
blobefdd02e6ed4ddf6b9fbd461ad8e18b2582ba017c
1 /*
2 Copyright © 2010-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "nouveau_intern.h"
8 #define DEBUG 0
9 #include <aros/debug.h>
10 #include <proto/oop.h>
11 #include <proto/utility.h>
13 #include "arosdrmmode.h"
15 #undef HiddBitMapAttrBase
16 #undef HiddPixFmtAttrBase
17 #undef HiddBitMapNouveauAttrBase
19 #define HiddBitMapAttrBase (SD(cl)->bitMapAttrBase)
20 #define HiddPixFmtAttrBase (SD(cl)->pixFmtAttrBase)
21 #define HiddBitMapNouveauAttrBase (SD(cl)->bitMapNouveauAttrBase)
23 #define GART_TRANSFER_ALLOWED(width, height) ((((width) * (height)) >= (32 * 32)) && (carddata->GART))
25 VOID HIDDNouveauSetOffsets(OOP_Object * bm, LONG newxoffset, LONG newyoffset)
27 OOP_Class * cl = OOP_OCLASS(bm);
28 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, bm);
29 bmdata->xoffset = newxoffset;
30 bmdata->yoffset = newyoffset;
33 /* PUBLIC METHODS */
34 OOP_Object * METHOD(NouveauBitMap, Root, New)
36 IPTR width, height, depth, displayable, bytesperpixel;
37 OOP_Object * pf;
38 struct HIDDNouveauBitMapData * bmdata = NULL;
39 HIDDT_StdPixFmt stdfmt = vHidd_StdPixFmt_Unknown;
40 struct CardData * carddata = &(SD(cl)->carddata);
42 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
44 if (!o)
45 goto exit_fail;
47 bmdata = OOP_INST_DATA(cl, o);
49 /* Initialize default values */
50 bmdata->fbid = 0;
51 bmdata->xoffset = 0;
52 bmdata->yoffset = 0;
53 bmdata->bo = NULL;
55 OOP_GetAttr(o, aHidd_BitMap_Width, &width);
56 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
57 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (APTR)&pf);
58 OOP_GetAttr(o, aHidd_BitMap_Displayable, &displayable);
59 OOP_GetAttr(pf, aHidd_PixFmt_StdPixFmt, &stdfmt);
60 OOP_GetAttr(pf, aHidd_PixFmt_BytesPerPixel, &bytesperpixel);
61 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
63 D(bug("[Nouveau] BitMap New: %d x %d x %d\n", width, height, depth));
65 /* Check if requested format is one of the supported ones */
66 if ((stdfmt != vHidd_StdPixFmt_BGR032) && (stdfmt != vHidd_StdPixFmt_RGB16_LE))
67 goto exit_fail;
69 /* Check if requested depth is a supported one */
70 if (depth < 16)
71 goto exit_fail;
73 /* Check if requested byted per pixel is a supported one */
74 if ((bytesperpixel != 2) && (bytesperpixel != 4))
75 goto exit_fail;
77 /* Initialize properties */
78 bmdata->width = width;
79 bmdata->height = height;
80 bmdata->depth = depth;
81 bmdata->bytesperpixel = bytesperpixel;
82 bmdata->pitch = bmdata->width * bmdata->bytesperpixel;
83 if (carddata->architecture >= NV_ARCH_50)
84 bmdata->pitch = (bmdata->pitch + 255) & ~255;
85 else
86 bmdata->pitch = (bmdata->pitch + 63) & ~63;
88 if (displayable) bmdata->displayable = TRUE; else bmdata->displayable = FALSE;
89 InitSemaphore(&bmdata->semaphore);
91 LOCK_ENGINE
92 /* Creation of buffer object */
93 nouveau_bo_new(SD(cl)->carddata.dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_MAP, 0,
94 bmdata->pitch * bmdata->height,
95 &bmdata->bo);
96 UNLOCK_ENGINE
98 if (bmdata->bo == NULL)
99 goto exit_fail;
101 bmdata->compositor = (OOP_Object *)GetTagData(aHidd_BitMap_Nouveau_CompositorHidd, 0, msg->attrList);
102 if (bmdata->compositor == NULL)
103 goto exit_fail;
105 return o;
107 exit_fail:
109 bug("[Nouveau]: Failed to create bitmap %dx%d %d %d\n", width, height, depth, stdfmt);
111 if (o)
113 OOP_MethodID disp_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
114 OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
117 return NULL;
120 VOID NouveauBitMap__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
122 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
124 D(bug("[Nouveau] Dispose %x\n", o));
126 LOCK_ENGINE
127 /* Unregister from framebuffer if needed */
128 if (bmdata->fbid != 0)
130 struct nouveau_device_priv *nvdev = nouveau_device(SD(cl)->carddata.dev);
131 drmModeRmFB(nvdev->fd, bmdata->fbid);
132 bmdata->fbid = 0;
135 if (bmdata->bo)
137 UNMAP_BUFFER
138 nouveau_bo_ref(NULL, &bmdata->bo); /* Release reference */
140 UNLOCK_ENGINE
142 OOP_DoSuperMethod(cl, o, msg);
145 VOID METHOD(NouveauBitMap, Root, Get)
147 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
148 ULONG idx;
150 if (IS_BITMAP_ATTR(msg->attrID, idx))
152 switch (idx)
154 case aoHidd_BitMap_LeftEdge:
155 *msg->storage = bmdata->xoffset;
156 return;
157 case aoHidd_BitMap_TopEdge:
158 *msg->storage = bmdata->yoffset;
159 return;
163 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
166 VOID METHOD(NouveauBitMap, Root, Set)
168 struct TagItem *tag, *tstate;
169 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
170 ULONG idx;
171 LONG newxoffset = bmdata->xoffset;
172 LONG newyoffset = bmdata->yoffset;
174 tstate = msg->attrList;
175 while((tag = NextTagItem(&tstate)))
177 if(IS_BITMAP_ATTR(tag->ti_Tag, idx))
179 switch(idx)
181 case aoHidd_BitMap_LeftEdge:
182 newxoffset = tag->ti_Data;
183 break;
184 case aoHidd_BitMap_TopEdge:
185 newyoffset = tag->ti_Data;
186 break;
191 if ((newxoffset != bmdata->xoffset) || (newyoffset != bmdata->yoffset))
193 /* If there was a change requested, validate it */
194 struct pHidd_Compositor_ValidateBitMapPositionChange vbpcmsg =
196 mID : SD(cl)->mid_ValidateBitMapPositionChange,
197 bm : o,
198 newxoffset : &newxoffset,
199 newyoffset : &newyoffset
202 OOP_DoMethod(bmdata->compositor, (OOP_Msg)&vbpcmsg);
204 if ((newxoffset != bmdata->xoffset) || (newyoffset != bmdata->yoffset))
206 /* If change passed validation, execute it */
207 struct pHidd_Compositor_BitMapPositionChanged bpcmsg =
209 mID : SD(cl)->mid_BitMapPositionChanged,
210 bm : o
213 HIDDNouveauSetOffsets(o, newxoffset, newyoffset);
215 OOP_DoMethod(bmdata->compositor, (OOP_Msg)&bpcmsg);
219 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
222 VOID METHOD(NouveauBitMap, Hidd_BitMap, PutPixel)
224 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
225 IPTR addr = (msg->x * bmdata->bytesperpixel) + (bmdata->pitch * msg->y);
227 /* FIXME "Optimistics" synchronization (yes, I know it's wrong) */
228 IPTR map = (IPTR)bmdata->bo->map;
230 /* If the current map was NULL, wait until bitmap lock is released.
231 When it happens, map the buffer */
232 if (map == (IPTR)NULL)
234 LOCK_BITMAP
235 MAP_BUFFER
236 addr += (IPTR)bmdata->bo->map;
238 else
239 addr += map;
241 switch(bmdata->bytesperpixel)
243 case(1):
244 /* Not supported */
245 break;
246 case(2):
247 writew(msg->pixel, (APTR)addr);
248 break;
249 case(4):
250 writel(msg->pixel, (APTR)addr);
251 break;
254 if (map == (IPTR)NULL)
255 UNLOCK_BITMAP
258 HIDDT_Pixel METHOD(NouveauBitMap, Hidd_BitMap, GetPixel)
260 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
261 IPTR addr = (msg->x * bmdata->bytesperpixel) + (bmdata->pitch * msg->y);
262 HIDDT_Pixel pixel = 0;
264 /* FIXME "Optimistics" synchronization (yes, I know it's wrong) */
265 IPTR map = (IPTR)bmdata->bo->map;
267 /* If the current map was NULL, wait until bitmap lock is released.
268 When it happens, map the buffer */
269 if (map == (IPTR)NULL)
271 LOCK_BITMAP
272 MAP_BUFFER
273 addr += (IPTR)bmdata->bo->map;
275 else
276 addr += map;
278 switch(bmdata->bytesperpixel)
280 case(1):
281 /* Not supported */
282 break;
283 case(2):
284 pixel = readw((APTR)addr);
285 break;
286 case(4):
287 pixel = readl((APTR)addr);
288 break;
291 if (map == (IPTR)NULL)
292 UNLOCK_BITMAP
294 return pixel;
297 VOID METHOD(NouveauBitMap, Hidd_BitMap, Clear)
299 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
300 struct CardData * carddata = &(SD(cl)->carddata);
301 BOOL ret = FALSE;
303 LOCK_ENGINE
305 LOCK_BITMAP
306 UNMAP_BUFFER
308 switch(carddata->architecture)
310 case(NV_ARCH_03):
311 case(NV_ARCH_04):
312 case(NV_ARCH_10):
313 case(NV_ARCH_20):
314 case(NV_ARCH_30):
315 case(NV_ARCH_40):
316 ret = HIDDNouveauNV04FillSolidRect(carddata, bmdata,
317 0, 0, bmdata->width - 1, bmdata->height - 1, GC_DRMD(msg->gc), GC_BG(msg->gc));
318 break;
319 case(NV_ARCH_50):
320 ret = HIDDNouveauNV50FillSolidRect(carddata, bmdata,
321 0, 0, bmdata->width - 1, bmdata->height - 1, GC_DRMD(msg->gc), GC_BG(msg->gc));
322 break;
323 case(NV_ARCH_C0):
324 ret = HIDDNouveauNVC0FillSolidRect(carddata, bmdata,
325 0, 0, bmdata->width - 1, bmdata->height - 1, GC_DRMD(msg->gc), GC_BG(msg->gc));
326 break;
329 UNLOCK_BITMAP
331 UNLOCK_ENGINE
333 if (ret)
334 return;
336 /* Fallback to default method */
337 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
340 /* There is no pHidd_BitMap_FillRect structure - it's the same as pHidd_BitMap_DrawRect */
341 #define pHidd_BitMap_FillRect pHidd_BitMap_DrawRect
343 VOID METHOD(NouveauBitMap, Hidd_BitMap, FillRect)
345 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
346 struct CardData * carddata = &(SD(cl)->carddata);
347 BOOL ret = FALSE;
349 LOCK_ENGINE
351 LOCK_BITMAP
352 UNMAP_BUFFER
354 switch(carddata->architecture)
356 case(NV_ARCH_03):
357 case(NV_ARCH_04):
358 case(NV_ARCH_10):
359 case(NV_ARCH_20):
360 case(NV_ARCH_30):
361 case(NV_ARCH_40):
362 ret = HIDDNouveauNV04FillSolidRect(carddata, bmdata,
363 msg->minX, msg->minY, msg->maxX, msg->maxY, GC_DRMD(msg->gc), GC_FG(msg->gc));
364 break;
365 case(NV_ARCH_50):
366 ret = HIDDNouveauNV50FillSolidRect(carddata, bmdata,
367 msg->minX, msg->minY, msg->maxX, msg->maxY, GC_DRMD(msg->gc), GC_FG(msg->gc));
368 break;
369 case(NV_ARCH_C0):
370 ret = HIDDNouveauNVC0FillSolidRect(carddata, bmdata,
371 msg->minX, msg->minY, msg->maxX, msg->maxY, GC_DRMD(msg->gc), GC_FG(msg->gc));
372 break;
375 UNLOCK_BITMAP
377 UNLOCK_ENGINE
379 if (ret)
380 return;
382 /* Fallback to default method */
383 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
386 VOID METHOD(NouveauBitMap, Hidd_BitMap, PutImage)
388 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
389 struct CardData * carddata = &(SD(cl)->carddata);
391 LOCK_ENGINE
393 LOCK_BITMAP
395 /* For larger transfers use GART */
396 if (GART_TRANSFER_ALLOWED(msg->width, msg->height))
398 BOOL result = FALSE;
400 /* RAM->CPU->GART GART->GPU->VRAM */
401 UNMAP_BUFFER
403 ObtainSemaphore(&carddata->gartsemaphore);
405 result = HiddNouveauNVAccelUploadM2MF(
406 msg->pixels, msg->modulo, msg->pixFmt,
407 msg->x, msg->y, msg->width, msg->height,
408 cl, o);
410 ReleaseSemaphore(&carddata->gartsemaphore);
412 if (result)
414 UNLOCK_BITMAP;
415 UNLOCK_ENGINE;
416 return;
420 /* Fallback */
422 /* RAM->CPU->VRAM */
424 APTR dstBuff = NULL;
426 MAP_BUFFER
428 /* Calculate destination buffer pointer */
429 dstBuff = (APTR)((IPTR)bmdata->bo->map + (msg->y * bmdata->pitch) + (msg->x * bmdata->bytesperpixel));
431 HiddNouveauWriteFromRAM(
432 msg->pixels, msg->modulo, msg->pixFmt,
433 dstBuff, bmdata->pitch,
434 msg->width, msg->height,
435 cl, o);
438 UNLOCK_BITMAP
440 UNLOCK_ENGINE
443 VOID METHOD(NouveauBitMap, Hidd_BitMap, GetImage)
445 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
446 struct CardData * carddata = &(SD(cl)->carddata);
448 LOCK_ENGINE
450 LOCK_BITMAP
452 /* For larger transfers use GART */
453 if (GART_TRANSFER_ALLOWED(msg->width, msg->height))
455 BOOL result = FALSE;
457 /* VRAM->CPU->GART GART->GPU->RAM */
458 UNMAP_BUFFER
460 ObtainSemaphore(&carddata->gartsemaphore);
462 result = HiddNouveauNVAccelDownloadM2MF(
463 msg->pixels, msg->modulo, msg->pixFmt,
464 msg->x, msg->y, msg->width, msg->height,
465 cl, o);
467 ReleaseSemaphore(&carddata->gartsemaphore);
469 if (result)
471 UNLOCK_BITMAP;
472 UNLOCK_ENGINE;
473 return;
477 /* Fallback */
479 /* VRAM->CPU->RAM */
481 APTR srcBuff = NULL;
483 MAP_BUFFER
485 /* Calculate source buffer pointer */
486 srcBuff = (APTR)((IPTR)bmdata->bo->map + (msg->y * bmdata->pitch) + (msg->x * bmdata->bytesperpixel));
488 HiddNouveauReadIntoRAM(
489 srcBuff, bmdata->pitch,
490 msg->pixels, msg->modulo, msg->pixFmt,
491 msg->width, msg->height,
492 cl, o);
495 UNLOCK_BITMAP
496 UNLOCK_ENGINE
499 VOID METHOD(NouveauBitMap, Hidd_BitMap, PutAlphaImage)
501 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
502 struct CardData * carddata = &(SD(cl)->carddata);
504 LOCK_ENGINE
505 LOCK_BITMAP
507 /* Try hardware method NV10-NV40*/
508 if (
509 ((carddata->architecture >= NV_ARCH_10) && (carddata->architecture <= NV_ARCH_40))
511 && (bmdata->bytesperpixel > 1)
512 && (GART_TRANSFER_ALLOWED(msg->width, msg->height)))
514 BOOL result = FALSE;
516 /* RAM->CPU->GART GART->GPU->VRAM */
517 UNMAP_BUFFER
519 ObtainSemaphore(&carddata->gartsemaphore);
521 result = HiddNouveauAccelARGBUpload3D(
522 msg->pixels, msg->modulo,
523 msg->x, msg->y, msg->width, msg->height,
524 cl, o);
526 ReleaseSemaphore(&carddata->gartsemaphore);
528 if (result)
530 MAP_BUFFER; /* FIXME: This is needed to flush execution buffer, atrifact otherwise */
531 UNLOCK_BITMAP;
532 UNLOCK_ENGINE;
533 return;
537 /* Try optimization for NV50 */
538 if (
539 (carddata->architecture >= NV_ARCH_50)
541 && (bmdata->bytesperpixel > 1)
542 && (GART_TRANSFER_ALLOWED(msg->width, msg->height)))
544 /* Hardware method is not currently possible for NV50 as the implementation
545 relies on tiled bitmaps. AROS uses linear bitmaps for all card families.
546 The optimization in this case is to use base class implementation,
547 which does GetImage->Process->PutImage. Since all NV50 cards are
548 PCI-E based, the greatest limiting factor - VRAM->RAM download
549 speed - is not a problem (1.1 Gbps on my GF8300). This approach is
550 actually faster than "per-pixel" functions below by order of 10. */
552 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
553 UNLOCK_BITMAP;
554 UNLOCK_ENGINE;
555 return;
558 /* Fallback to software method */
559 switch(bmdata->bytesperpixel)
561 case 1:
562 /* Not supported */
563 break;
565 case 2:
567 MAP_BUFFER
569 HIDDNouveauBitMapPutAlphaImage16(bmdata, msg->pixels, msg->modulo, msg->x,
570 msg->y, msg->width, msg->height);
572 break;
574 case 4:
576 MAP_BUFFER
578 HIDDNouveauBitMapPutAlphaImage32(bmdata, msg->pixels, msg->modulo, msg->x,
579 msg->y, msg->width, msg->height);
581 break;
582 } /* switch(bmdata->bytesperpixel) */
584 UNLOCK_BITMAP
585 UNLOCK_ENGINE
588 ULONG METHOD(NouveauBitMap, Hidd_BitMap, BytesPerLine)
590 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
592 return (bmdata->pitch);
595 BOOL METHOD(NouveauBitMap, Hidd_BitMap, ObtainDirectAccess)
597 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
599 LOCK_ENGINE
600 LOCK_BITMAP
601 MAP_BUFFER
603 *msg->addressReturn = (UBYTE*)bmdata->bo->map;
604 *msg->widthReturn = bmdata->pitch / bmdata->bytesperpixel;
605 *msg->heightReturn = bmdata->height;
606 *msg->bankSizeReturn = *msg->memSizeReturn = bmdata->pitch * bmdata->height;
608 return TRUE;
611 VOID METHOD(NouveauBitMap, Hidd_BitMap, ReleaseDirectAccess)
613 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
615 UNLOCK_BITMAP
616 UNLOCK_ENGINE
619 #define COMPLEMENT_JAM2_DECISION_BLOCK \
620 else if (GC_DRMD(msg->gc) == vHidd_GC_DrawMode_Invert) \
622 /* COMPLEMENT - read & write. Base method uses GetImage/PutImage. \
623 It is better to use it, if GetImage is fast(==PCIE) */ \
624 if (GART_TRANSFER_ALLOWED(msg->width, msg->height) && (carddata->IsPCIE)) \
626 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); \
627 return; \
630 else \
632 /* JAM2 - only write. Base method uses PutImage. It is \
633 better to use it, if it is accelerated */ \
634 if (GART_TRANSFER_ALLOWED(msg->width, msg->height)) \
636 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); \
637 return; \
642 VOID METHOD(NouveauBitMap, Hidd_BitMap, PutAlphaTemplate)
644 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
645 struct CardData * carddata = &(SD(cl)->carddata);
647 /* Select acceleration method based on hardware and buffer size */
648 if (GC_COLEXP(msg->gc) == vHidd_GC_ColExp_Transparent)
650 /* JAM1 - read & write. Base method uses GetImage/PutImage.
651 Use 3D alpha blending where possible */
652 if (GART_TRANSFER_ALLOWED(msg->width, msg->height))
654 /* These cards support 3D alpha blending */
655 if ((carddata->architecture >= NV_ARCH_10) && (carddata->architecture <= NV_ARCH_40))
657 BOOL result = FALSE;
658 HIDDT_Color color;
659 LONG fg_red, fg_green, fg_blue;
661 HIDD_BM_UnmapPixel(o, GC_FG(msg->gc), &color);
663 fg_red = color.red >> 8;
664 fg_green = color.green >> 8;
665 fg_blue = color.blue >> 8;
667 LOCK_ENGINE
668 LOCK_BITMAP
669 UNMAP_BUFFER
671 ObtainSemaphore(&carddata->gartsemaphore);
673 result = HiddNouveauAccelAPENUpload3D(msg->alpha, msg->invertalpha,
674 msg->modulo, (fg_red << 16) | (fg_green << 8) | fg_blue,
675 msg->x, msg->y, msg->width, msg->height, cl, o);
677 ReleaseSemaphore(&carddata->gartsemaphore);
678 MAP_BUFFER; /* FIXME: This is needed to flush execution buffer, atrifact otherwise */
679 UNLOCK_BITMAP
680 UNLOCK_ENGINE
682 if (result) return;
685 /* These cards don't support 3D alpha blending (yet), but they are all
686 PCIE so GetImage is fast */
687 if (carddata->architecture >= NV_ARCH_50)
689 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
690 return;
694 COMPLEMENT_JAM2_DECISION_BLOCK
696 /* This is software fallback */
697 LOCK_BITMAP
698 MAP_BUFFER
700 switch(bmdata->bytesperpixel)
702 case 1:
703 /* Not supported */
704 break;
706 case 2:
708 HIDDNouveauBitMapPutAlphaTemplate16(bmdata, msg->gc, o, msg->invertalpha,
709 msg->alpha, msg->modulo, msg->x, msg->y, msg->width, msg->height);
711 break;
713 case 4:
715 HIDDNouveauBitMapPutAlphaTemplate32(bmdata, msg->gc, o, msg->invertalpha,
716 msg->alpha, msg->modulo, msg->x, msg->y, msg->width, msg->height);
718 break;
719 } /* switch(bmdata->bytesperpixel) */
721 UNLOCK_BITMAP
724 VOID METHOD(NouveauBitMap, Hidd_BitMap, PutTemplate)
726 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
727 struct CardData * carddata = &(SD(cl)->carddata);
729 /* Select execution method based on hardware and buffer size */
730 if (GC_COLEXP(msg->gc) == vHidd_GC_ColExp_Transparent)
732 /* JAM1 - read & write. Base method uses GetImage/PutImage.
733 Use software fallback. It performs only limited writes and thus it
734 is faster than base method. */
736 COMPLEMENT_JAM2_DECISION_BLOCK
738 /* This is software fallback */
739 LOCK_BITMAP
740 MAP_BUFFER
742 switch(bmdata->bytesperpixel)
744 case 1:
745 /* Not supported */
746 break;
748 case 2:
750 struct pHidd_BitMap_PutMemTemplate16 __m =
752 SD(cl)->mid_PutMemTemplate16, msg->gc, msg->masktemplate, msg->modulo,
753 msg->srcx, bmdata->bo->map, bmdata->pitch, msg->x, msg->y,
754 msg->width, msg->height, msg->inverttemplate
755 }, *m = &__m;
756 OOP_DoMethod(o, (OOP_Msg)m);
758 break;
760 case 4:
762 struct pHidd_BitMap_PutMemTemplate32 __m =
764 SD(cl)->mid_PutMemTemplate32, msg->gc, msg->masktemplate, msg->modulo,
765 msg->srcx, bmdata->bo->map, bmdata->pitch, msg->x, msg->y,
766 msg->width, msg->height, msg->inverttemplate
767 }, *m = &__m;
768 OOP_DoMethod(o, (OOP_Msg)m);
770 break;
771 } /* switch(bmdata->bytesperpixel) */
773 UNLOCK_BITMAP
776 VOID METHOD(NouveauBitMap, Hidd_BitMap, PutPattern)
778 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
779 struct CardData * carddata = &(SD(cl)->carddata);
781 /* Select execution method based on hardware and buffer size */
782 if (GC_COLEXP(msg->gc) == vHidd_GC_ColExp_Transparent)
784 /* JAM1 - read & write. Base method uses GetImage/PutImage.
785 Use software fallback. It performs only limited writes and thus it
786 is faster than base method. */
788 COMPLEMENT_JAM2_DECISION_BLOCK
790 /* This is software fallback */
791 LOCK_BITMAP
792 MAP_BUFFER
794 switch(bmdata->bytesperpixel)
796 case 1:
797 /* Not supported */
798 break;
800 case 2:
802 struct pHidd_BitMap_PutMemPattern16 __m =
804 SD(cl)->mid_PutMemPattern16, msg->gc, msg->pattern, msg->patternsrcx,
805 msg->patternsrcy, msg->patternheight, msg->patterndepth, msg->patternlut,
806 msg->invertpattern, msg->mask, msg->maskmodulo, msg->masksrcx,
807 bmdata->bo->map, bmdata->pitch, msg->x, msg->y, msg->width, msg->height
808 }, *m = &__m;
809 OOP_DoMethod(o, (OOP_Msg)m);
811 break;
813 case 4:
815 struct pHidd_BitMap_PutMemPattern32 __m =
817 SD(cl)->mid_PutMemPattern32, msg->gc, msg->pattern, msg->patternsrcx,
818 msg->patternsrcy, msg->patternheight, msg->patterndepth, msg->patternlut,
819 msg->invertpattern, msg->mask, msg->maskmodulo, msg->masksrcx,
820 bmdata->bo->map, bmdata->pitch, msg->x,msg->y, msg->width,
821 msg->height
822 }, *m = &__m;
823 OOP_DoMethod(o, (OOP_Msg)m);
825 break;
826 } /* switch(bmdata->bytesperpixel) */
828 UNLOCK_BITMAP
831 VOID METHOD(NouveauBitMap, Hidd_BitMap, DrawLine)
833 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
835 LOCK_BITMAP
837 if ((GC_DRMD(msg->gc) == vHidd_GC_DrawMode_Copy) && (GC_COLMASK(msg->gc) == ~0))
839 MAP_BUFFER
841 HIDDNouveauBitMapDrawSolidLine(bmdata, msg->gc, msg->x1, msg->y1, msg->x2, msg->y2);
843 UNLOCK_BITMAP
845 return;
848 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
850 UNLOCK_BITMAP
853 VOID METHOD(NouveauBitMap, Hidd_BitMap, UpdateRect)
855 struct HIDDNouveauBitMapData * bmdata = OOP_INST_DATA(cl, o);
857 if (bmdata->displayable)
859 struct pHidd_Compositor_BitMapRectChanged brcmsg =
861 mID : SD(cl)->mid_BitMapRectChanged,
862 bm : o,
863 x : msg->x,
864 y : msg->y,
865 width : msg->width,
866 height : msg->height
869 OOP_DoMethod(bmdata->compositor, (OOP_Msg)&brcmsg);