2 Copyright 2010 Haiku, Inc. All rights reserved.
3 Distributed under the terms of the MIT license.
10 #include "accelerant.h"
14 // Constants for the DST_FORMAT register based upon the color depth.
16 static const uint32 fmtColorDepth
[] = {
17 0x10000, // 1 byte/pixel
18 0x30000, // 2 bytes/pixel
19 0x50000, // 3 bytes/pixel (not used)
20 0x50000 // 4 bytes/pixel
25 TDFX_FillRectangle(engine_token
* et
, uint32 color
, fill_rect_params
* list
,
28 (void)et
; // avoid compiler warning for unused arg
30 DisplayModeEx
& mode
= gInfo
.sharedInfo
->displayMode
;
31 uint32 fmt
= mode
.bytesPerRow
| fmtColorDepth
[mode
.bytesPerPixel
- 1];
34 OUTREG32(DST_FORMAT
, fmt
);
35 OUTREG32(COLOR_BACK
, color
);
36 OUTREG32(COLOR_FORE
, color
);
41 int w
= list
->right
- x
+ 1;
42 int h
= list
->bottom
- y
+ 1;
45 OUTREG32(DST_SIZE
, w
| (h
<< 16));
46 OUTREG32(DST_XY
, x
| (y
<< 16));
47 OUTREG32(CMD_2D
, RECTANGLE_FILL
| CMD_2D_GO
| (ROP_COPY
<< 24));
55 TDFX_FillSpan(engine_token
* et
, uint32 color
, uint16
* list
, uint32 count
)
57 (void)et
; // avoid compiler warning for unused arg
59 DisplayModeEx
& mode
= gInfo
.sharedInfo
->displayMode
;
60 uint32 fmt
= mode
.bytesPerRow
| fmtColorDepth
[mode
.bytesPerPixel
- 1];
63 OUTREG32(DST_FORMAT
, fmt
);
64 OUTREG32(COLOR_BACK
, color
);
65 OUTREG32(COLOR_FORE
, color
);
70 int w
= *list
++ - x
+ 1;
73 continue; // discard span with zero or negative width
76 OUTREG32(DST_SIZE
, w
| (1 << 16));
77 OUTREG32(DST_XY
, x
| (y
<< 16));
78 OUTREG32(CMD_2D
, RECTANGLE_FILL
| CMD_2D_GO
| (ROP_COPY
<< 24));
84 TDFX_InvertRectangle(engine_token
* et
, fill_rect_params
* list
, uint32 count
)
86 (void)et
; // avoid compiler warning for unused arg
88 DisplayModeEx
& mode
= gInfo
.sharedInfo
->displayMode
;
89 uint32 fmt
= mode
.bytesPerRow
| fmtColorDepth
[mode
.bytesPerPixel
- 1];
92 OUTREG32(DST_FORMAT
, fmt
);
97 int w
= list
->right
- x
+ 1;
98 int h
= list
->bottom
- y
+ 1;
101 OUTREG32(DST_SIZE
, w
| (h
<< 16));
102 OUTREG32(DST_XY
, x
| (y
<< 16));
103 OUTREG32(CMD_2D
, RECTANGLE_FILL
| CMD_2D_GO
| (ROP_INVERT
<< 24));
111 TDFX_ScreenToScreenBlit(engine_token
* et
, blit_params
* list
, uint32 count
)
113 (void)et
; // avoid compiler warning for unused arg
115 DisplayModeEx
& mode
= gInfo
.sharedInfo
->displayMode
;
116 uint32 fmt
= mode
.bytesPerRow
| fmtColorDepth
[mode
.bytesPerPixel
- 1];
119 OUTREG32(DST_FORMAT
, fmt
);
120 OUTREG32(SRC_FORMAT
, fmt
);
123 int src_x
= list
->src_left
;
124 int src_y
= list
->src_top
;
125 int dest_x
= list
->dest_left
;
126 int dest_y
= list
->dest_top
;
127 int width
= list
->width
;
128 int height
= list
->height
;
130 uint32 cmd
= SCRN_TO_SCRN_BLIT
| CMD_2D_GO
| (ROP_COPY
<< 24);
132 if (src_x
<= dest_x
) {
133 cmd
|= X_RIGHT_TO_LEFT
;
138 if (src_y
<= dest_y
) {
139 cmd
|= Y_BOTTOM_TO_TOP
;
145 OUTREG32(SRC_XY
, src_x
| (src_y
<< 16));
146 OUTREG32(DST_SIZE
, (width
+ 1) | ((height
+ 1) << 16));
147 OUTREG32(DST_XY
, dest_x
| (dest_y
<< 16));
148 OUTREG32(CMD_2D
, cmd
);