BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / accelerants / s3 / savage_draw.cpp
blobe5d0fcb3177c958b6d7e5ed23ef37df20e30373e
1 /*
2 Haiku S3 Savage driver adapted from the X.org Savage driver.
4 Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
5 Copyright (c) 2003-2006, X.Org Foundation
7 Copyright 2007-2008 Haiku, Inc. All rights reserved.
8 Distributed under the terms of the MIT license.
10 Authors:
11 Gerald Zajac 2006-2008
15 #include "accel.h"
16 #include "savage.h"
20 void
21 Savage_FillRectangle(engine_token *et, uint32 color, fill_rect_params *pList, uint32 count)
23 int cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
24 | BCI_CMD_DEST_PBD_NEW | BCI_CMD_SRC_SOLID | BCI_CMD_SEND_COLOR;
26 (void)et; // avoid compiler warning for unused arg
28 BCI_CMD_SET_ROP(cmd, 0xF0); // use GXcopy for rop
30 while (count--) {
31 int x = pList->left;
32 int y = pList->top;
33 int w = pList->right - x + 1;
34 int h = pList->bottom - y + 1;
36 BCI_GET_PTR;
38 gInfo.WaitQueue(7);
40 BCI_SEND(cmd);
41 BCI_SEND(gInfo.sharedInfo->frameBufferOffset);
42 BCI_SEND(gInfo.sharedInfo->globalBitmapDesc);
44 BCI_SEND(color);
45 BCI_SEND(BCI_X_Y(x, y));
46 BCI_SEND(BCI_W_H(w, h));
48 pList++;
53 void
54 Savage_FillSpan(engine_token *et, uint32 color, uint16 *pList, uint32 count)
56 int cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
57 | BCI_CMD_DEST_PBD_NEW | BCI_CMD_SRC_SOLID | BCI_CMD_SEND_COLOR;
59 (void)et; // avoid compiler warning for unused arg
61 BCI_CMD_SET_ROP(cmd, 0xF0); // use GXcopy for rop
63 while (count--) {
64 int y = *pList++;
65 int x = *pList++;
66 int w = *pList++ - x + 1;
68 BCI_GET_PTR;
70 // The MediaPlayer in Zeta 1.21 displays a window which has 2 zero width
71 // spans which the Savage chips display as a line completely across the
72 // screen; thus, the following if statement discards any span with zero
73 // or negative width.
75 if (w <= 0)
76 continue;
78 gInfo.WaitQueue(7);
80 BCI_SEND(cmd);
81 BCI_SEND(gInfo.sharedInfo->frameBufferOffset);
82 BCI_SEND(gInfo.sharedInfo->globalBitmapDesc);
84 BCI_SEND(color);
85 BCI_SEND(BCI_X_Y(x, y));
86 BCI_SEND(BCI_W_H(w, 1));
91 void
92 Savage_InvertRectangle(engine_token *et, fill_rect_params *pList, uint32 count)
94 int cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
95 | BCI_CMD_DEST_PBD_NEW;
97 (void)et; // avoid compiler warning for unused arg
99 BCI_CMD_SET_ROP(cmd, 0x55); // use GXinvert for rop
101 while (count--) {
102 int x = pList->left;
103 int y = pList->top;
104 int w = pList->right - x + 1;
105 int h = pList->bottom - y + 1;
107 BCI_GET_PTR;
109 gInfo.WaitQueue(7);
111 BCI_SEND(cmd);
112 BCI_SEND(gInfo.sharedInfo->frameBufferOffset);
113 BCI_SEND(gInfo.sharedInfo->globalBitmapDesc);
115 BCI_SEND(BCI_X_Y(x, y));
116 BCI_SEND(BCI_W_H(w, h));
118 pList++;
123 void
124 Savage_ScreenToScreenBlit(engine_token *et, blit_params *pList, uint32 count)
126 (void)et; // avoid compiler warning for unused arg
128 while (count--) {
129 int cmd;
130 int src_x = pList->src_left;
131 int src_y = pList->src_top;
132 int dest_x = pList->dest_left;
133 int dest_y = pList->dest_top;
134 int width = pList->width;
135 int height = pList->height;
137 BCI_GET_PTR;
139 cmd = BCI_CMD_RECT | BCI_CMD_DEST_PBD_NEW | BCI_CMD_SRC_SBD_COLOR_NEW;
140 BCI_CMD_SET_ROP(cmd, 0xCC); // use GXcopy for rop
142 if (dest_x <= src_x) {
143 cmd |= BCI_CMD_RECT_XP;
144 } else {
145 src_x += width;
146 dest_x += width;
149 if (dest_y <= src_y) {
150 cmd |= BCI_CMD_RECT_YP;
151 } else {
152 src_y += height;
153 dest_y += height;
156 gInfo.WaitQueue(9);
158 BCI_SEND(cmd);
160 BCI_SEND(gInfo.sharedInfo->frameBufferOffset);
161 BCI_SEND(gInfo.sharedInfo->globalBitmapDesc);
163 BCI_SEND(gInfo.sharedInfo->frameBufferOffset);
164 BCI_SEND(gInfo.sharedInfo->globalBitmapDesc);
166 BCI_SEND(BCI_X_Y(src_x, src_y));
167 BCI_SEND(BCI_X_Y(dest_x, dest_y));
168 BCI_SEND(BCI_W_H(width + 1, height + 1));
170 pList++;