Subversion Repositories Kolibri OS

Rev

Rev 4359 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4315 Serge 1
 
2
3
 
4
#include 
5
#include 
6
#include 
7
#include 
8
9
 
10
 
11
12
 
13
#define SRV_GET_CAPS                3
14
15
 
16
 
17
#define __ALIGN_MASK(x,mask)  (((x)+(mask))&~(mask))
18
#define ALIGN(x,a)            __ALIGN_MASK(x,(typeof(x))(a)-1)
19
20
 
21
22
 
23
{
24
	uint32_t width;
25
	uint32_t height;
26
	void *data;
27
	uint32_t pitch;
28
	uint32_t bo;
29
	uint32_t bo_size;
30
	uint32_t flags;
31
} surface_t;
32
33
 
34
 
35
void uxa_fini();
36
37
 
38
int sna_destroy_bitmap(bitmap_t * bitmap);
39
int sna_lock_bitmap(bitmap_t * bitmap);
40
int sna_resize_bitmap(bitmap_t *bitmap);
41
//int sna_blit_copy(bitmap_t * src_bitmap, int dst_x, int dst_y,
42
//				  int w, int h, int src_x, int src_y);
43
int sna_blit_tex(bitmap_t * src_bitmap, bool scale, int dst_x, int dst_y,
44
				 int w, int h, int src_x, int src_y);
45
46
 
47
 
48
static uint32_t hw_caps;
49
50
 
51
 
52
{
53
	uint32_t api_version;
54
	ioctl_t io;
55
56
 
57
		return caps & hw_caps;
58
59
 
4367 Serge 60
	service = get_service("DISPLAY");
4315 Serge 61
	if (service == 0)
62
		goto fail;
63
64
 
65
	io.io_code = SRV_GETVERSION;
66
	io.input = NULL;
67
	io.inp_size = 0;
68
	io.output = &api_version;
69
	io.out_size = BUFFER_SIZE(1);
70
71
 
72
		goto fail;
73
74
 
75
		(DISPLAY_VERSION < (api_version >> 16)))
76
		goto fail;
77
78
 
79
80
 
81
		printf("2D caps %s%s%s\n",
82
			   (hw_caps & HW_BIT_BLIT) != 0 ? "HW_BIT_BLIT " : "",
83
			   (hw_caps & HW_TEX_BLIT) != 0 ? "HW_TEX_BLIT " : "",
84
			   (hw_caps & HW_VID_BLIT) != 0 ? "HW_VID_BLIT " : "");
85
86
 
87
#endif
4367 Serge 88
4315 Serge 89
 
90
	service = 0;
91
	return 0;
92
};
93
94
 
95
{
96
//	if (hw_caps != 0)
97
//		uxa_fini();
98
};
99
100
 
101
 
102
{
103
	uint32_t size, bo_size;
104
	uint32_t pitch, max_pitch;
105
	void *buffer;
106
	surface_t *sf;
107
108
 
109
	bitmap->data = (void *) -1;
110
	bitmap->pitch = -1;
111
112
 
113
//		return sna_create_bitmap(bitmap);
114
115
 
116
	max_pitch = ALIGN(bitmap->max_width * 4, 16);
117
118
 
119
	bo_size = ALIGN(max_pitch * bitmap->max_height, 4096);
120
121
 
122
		bo_size = size;
123
124
 
125
	if (sf == NULL)
126
		return -1;
127
128
 
129
130
 
131
	{
132
		free(sf);
133
		return -1;
134
	};
135
136
 
137
	sf->height = bitmap->height;
138
	sf->data = buffer;
139
	sf->pitch = pitch;
140
	sf->bo = 0;
141
	sf->bo_size = bo_size;
142
	sf->flags = bitmap->flags;
143
144
 
145
146
 
147
//            bitmap, bitmap->handle, bitmap->data, bitmap->width, bitmap->height);
148
149
 
150
};
151
152
 
153
{
154
	surface_t *sf = to_surface(bitmap);
155
156
 
157
//		return sna_destroy_bitmap(bitmap);
158
159
 
160
	free(sf);
161
162
 
163
	bitmap->data = (void *) -1;
164
	bitmap->pitch = -1;
165
166
 
167
};
168
169
 
170
{
171
	surface_t *sf = to_surface(bitmap);
172
173
 
174
		return 0;
175
176
 
177
//		return sna_lock_bitmap(bitmap);
178
179
 
180
	bitmap->pitch = sf->pitch;
181
182
 
183
};
184
185
 
186
                int w, int h, int src_x, int src_y)
187
{
188
	struct blit_call bc;
189
	int ret;
190
191
 
192
193
 
194
//		return sna_blit_tex(bitmap, false, dst_x, dst_y, w, h, src_x, src_y);
195
196
 
197
	bc.dsty     = dst_y;
198
	bc.w        = w;
199
	bc.h        = h;
200
	bc.srcx     = 0;
201
	bc.srcy     = 0;
202
	bc.srcw     = w;
203
	bc.srch     = h;
204
	bc.stride   = sf->pitch;
205
	bc.bitmap   = sf->data;
206
207
 
208
    "int $0x40":"=a"(ret):"a"(73), "b"(0x00),
209
	"c"(&bc):"memory");
210
211
 
212
	bitmap->pitch = -1;
213
214
 
215
};
216
217
 
218
{
219
	struct blit_call bc;
220
	int ret;
221
222
 
223
224
 
225
//		return sna_blit_tex(bitmap, true, dst_x, dst_y, w, h, 0, 0);
226
227
 
228
	bc.dsty = dst_y;
229
	bc.w = w;
230
	bc.h = h;
231
	bc.srcx = 0;
232
	bc.srcy = 0;
233
	bc.srcw = w;
234
	bc.srch = h;
235
	bc.stride = sf->pitch;
236
	bc.bitmap = sf->data;
237
238
 
239
    "int $0x40":"=a"(ret):"a"(73), "b"(0x00),
240
	"c"(&bc):"memory");
241
242
 
243
	bitmap->pitch = -1;
244
245
 
246
};
247
248
 
249
{
250
	uint32_t size;
251
	uint32_t pitch;
252
253
 
254
255
 
256
257
 
258
//	{
259
//		return sna_resize_bitmap(bitmap);
260
//	};
261
262
 
263
	size = ALIGN(pitch * bitmap->height, 4096);
264
265
 
266
	bitmap->data = (void *) -1;
267
268
 
269
	{
270
		sf->data = user_realloc(sf->data, size);	/* grow buffer */
271
		if (sf->data == NULL)
272
			return -1;
273
274
 
275
	} else if (size < sf->bo_size)
276
		user_unmap(sf->data, size, sf->bo_size - size);	/* unmap unused pages */
277
278
 
279
	sf->height = bitmap->height;
280
	sf->pitch  = pitch;
281
282
 
283
};
284
4367 Serge 285
 
286
{
287
    return 0;
288
};
289