OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [framebuf/] [current/] [src/] [linear.c] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      linear.c
4
//
5
//      Generic implementations of some of the driver functions for linear
6
//      framebuffers.
7
//
8
//==========================================================================
9
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
10
// -------------------------------------------                              
11
// This file is part of eCos, the Embedded Configurable Operating System.   
12
// Copyright (C) 2008 Free Software Foundation, Inc.                        
13
//
14
// eCos is free software; you can redistribute it and/or modify it under    
15
// the terms of the GNU General Public License as published by the Free     
16
// Software Foundation; either version 2 or (at your option) any later      
17
// version.                                                                 
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT      
20
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
22
// for more details.                                                        
23
//
24
// You should have received a copy of the GNU General Public License        
25
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
26
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
27
//
28
// As a special exception, if other files instantiate templates or use      
29
// macros or inline functions from this file, or you compile this file      
30
// and link it with other works to produce a work based on this file,       
31
// this file does not by itself cause the resulting work to be covered by   
32
// the GNU General Public License. However the source code for this file    
33
// must still be made available in accordance with section (3) of the GNU   
34
// General Public License v2.                                               
35
//
36
// This exception does not invalidate any other reasons why a work based    
37
// on this file might be covered by the GNU General Public License.         
38
// -------------------------------------------                              
39
// ####ECOSGPLCOPYRIGHTEND####                                              
40
//==========================================================================
41
//###DESCRIPTIONBEGIN####
42
//
43
// Author(s):     bartv
44
// Date:          2005-03-29
45
//
46
//###DESCRIPTIONEND####
47
//========================================================================
48
 
49
#include <cyg/infra/cyg_type.h>
50
#include <cyg/io/framebuf.h>
51
 
52
// The real implementations for most of the functions are actually
53
// inlines held in framebuf.inl. That allows the implementation to be
54
// shared between the functions and the macros.
55
#include <cyg/io/framebuf.inl>
56
 
57
// ----------------------------------------------------------------------------
58
void
59
cyg_fb_linear_write_pixel_1LE(cyg_fb* fb,
60
                              cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour)
61
{
62
    cyg_fb_linear_write_pixel_1LE_inl(fb->fb_base, fb->fb_stride, x, y, colour);
63
}
64
 
65
cyg_fb_colour
66
cyg_fb_linear_read_pixel_1LE(cyg_fb* fb,
67
                             cyg_ucount16 x, cyg_ucount16 y)
68
{
69
    return cyg_fb_linear_read_pixel_1LE_inl(fb->fb_base, fb->fb_stride, x, y);
70
}
71
 
72
void
73
cyg_fb_linear_write_hline_1LE(cyg_fb* fb,
74
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
75
{
76
}
77
 
78
void
79
cyg_fb_linear_write_vline_1LE(cyg_fb* fb,
80
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
81
{
82
    cyg_fb_linear_write_vline_1LE_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
83
}
84
 
85
void
86
cyg_fb_linear_fill_block_1LE(cyg_fb* fb,
87
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour)
88
{
89
}
90
 
91
void
92
cyg_fb_linear_write_block_1LE(cyg_fb* fb,
93
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
94
                              const void* source, cyg_ucount16 offset, cyg_ucount16 source_stride)
95
{
96
}
97
 
98
void
99
cyg_fb_linear_read_block_1LE(cyg_fb* fb,
100
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
101
                             void* dest, cyg_ucount16 offset, cyg_ucount16 dest_stride)
102
{
103
}
104
 
105
void
106
cyg_fb_linear_move_block_1LE_impl(void* fbaddr, cyg_ucount16 stride,
107
                                  cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
108
                                  cyg_ucount16 new_x, cyg_ucount16 new_y)
109
{
110
}
111
 
112
void
113
cyg_fb_linear_move_block_1LE(cyg_fb* fb,
114
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
115
                             cyg_ucount16 new_x, cyg_ucount16 new_y)
116
{
117
    cyg_fb_linear_move_block_1LE_inl(fb->fb_base, fb->fb_stride, x, y, width, height, new_x, new_y);
118
}
119
 
120
// ----------------------------------------------------------------------------
121
void
122
cyg_fb_linear_write_pixel_1BE(cyg_fb* fb,
123
                              cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour)
124
{
125
    cyg_fb_linear_write_pixel_1BE_inl(fb->fb_base, fb->fb_stride, x, y, colour);
126
}
127
 
128
cyg_fb_colour
129
cyg_fb_linear_read_pixel_1BE(cyg_fb* fb,
130
                             cyg_ucount16 x, cyg_ucount16 y)
131
{
132
    return cyg_fb_linear_read_pixel_1BE_inl(fb->fb_base, fb->fb_stride, x, y);
133
}
134
 
135
void
136
cyg_fb_linear_write_hline_1BE(cyg_fb* fb,
137
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
138
{
139
}
140
 
141
void
142
cyg_fb_linear_write_vline_1BE(cyg_fb* fb,
143
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
144
{
145
    cyg_fb_linear_write_vline_1BE_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
146
}
147
 
148
void
149
cyg_fb_linear_fill_block_1BE(cyg_fb* fb,
150
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour)
151
{
152
}
153
 
154
void
155
cyg_fb_linear_write_block_1BE(cyg_fb* fb,
156
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
157
                              const void* source, cyg_ucount16 offset, cyg_ucount16 source_stride)
158
{
159
}
160
 
161
void
162
cyg_fb_linear_read_block_1BE(cyg_fb* fb,
163
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
164
                             void* dest, cyg_ucount16 offset, cyg_ucount16 dest_stride)
165
{
166
}
167
 
168
void
169
cyg_fb_linear_move_block_1BE_impl(void* fbaddr, cyg_ucount16 stride,
170
                                  cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
171
                                  cyg_ucount16 new_x, cyg_ucount16 new_y)
172
{
173
}
174
 
175
void
176
cyg_fb_linear_move_block_1BE(cyg_fb* fb,
177
                          cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
178
                          cyg_ucount16 new_x, cyg_ucount16 new_y)
179
{
180
    cyg_fb_linear_move_block_1LE_inl(fb->fb_base, fb->fb_stride, x, y, width, height, new_x, new_y);
181
}
182
 
183
// ----------------------------------------------------------------------------
184
 
185
void
186
cyg_fb_linear_write_pixel_2LE(cyg_fb* fb,
187
                              cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour)
188
{
189
    cyg_fb_linear_write_pixel_2LE_inl(fb->fb_base, fb->fb_stride, x, y, colour);
190
}
191
 
192
cyg_fb_colour
193
cyg_fb_linear_read_pixel_2LE(cyg_fb* fb,
194
                             cyg_ucount16 x, cyg_ucount16 y)
195
{
196
    return cyg_fb_linear_read_pixel_2LE_inl(fb->fb_base, fb->fb_stride, x, y);
197
}
198
 
199
void
200
cyg_fb_linear_write_hline_2LE(cyg_fb* fb,
201
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
202
{
203
}
204
 
205
void
206
cyg_fb_linear_write_vline_2LE(cyg_fb* fb,
207
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
208
{
209
    cyg_fb_linear_write_vline_2LE_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
210
}
211
 
212
void
213
cyg_fb_linear_fill_block_2LE(cyg_fb* fb,
214
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour)
215
{
216
}
217
 
218
void
219
cyg_fb_linear_write_block_2LE(cyg_fb* fb,
220
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
221
                              const void* source, cyg_ucount16 offset, cyg_ucount16 source_stride)
222
{
223
}
224
 
225
void
226
cyg_fb_linear_read_block_2LE(cyg_fb* fb,
227
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
228
                             void* dest, cyg_ucount16 offset, cyg_ucount16 dest_stride)
229
{
230
}
231
 
232
void
233
cyg_fb_linear_move_block_2LE_impl(void* fbaddr, cyg_ucount16 stride,
234
                                  cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
235
                                  cyg_ucount16 new_x, cyg_ucount16 new_y)
236
{
237
}
238
 
239
void
240
cyg_fb_linear_move_block_2LE(cyg_fb* fb,
241
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
242
                             cyg_ucount16 new_x, cyg_ucount16 new_y)
243
{
244
    cyg_fb_linear_move_block_2LE_inl(fb->fb_base, fb->fb_stride, x, y, width, height, new_x, new_y);
245
}
246
 
247
// ----------------------------------------------------------------------------
248
 
249
void
250
cyg_fb_linear_write_pixel_2BE(cyg_fb* fb,
251
                              cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour)
252
{
253
    cyg_fb_linear_write_pixel_2BE_inl(fb->fb_base, fb->fb_stride, x, y, colour);
254
}
255
 
256
cyg_fb_colour
257
cyg_fb_linear_read_pixel_2BE(cyg_fb* fb,
258
                             cyg_ucount16 x, cyg_ucount16 y)
259
{
260
    return cyg_fb_linear_read_pixel_2BE_inl(fb->fb_base, fb->fb_stride, x, y);
261
}
262
 
263
void
264
cyg_fb_linear_write_hline_2BE(cyg_fb* fb,
265
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
266
{
267
}
268
 
269
void
270
cyg_fb_linear_write_vline_2BE(cyg_fb* fb,
271
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
272
{
273
    cyg_fb_linear_write_vline_2BE_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
274
}
275
 
276
void
277
cyg_fb_linear_fill_block_2BE(cyg_fb* fb,
278
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour)
279
{
280
}
281
 
282
void
283
cyg_fb_linear_write_block_2BE(cyg_fb* fb,
284
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
285
                              const void* source, cyg_ucount16 offset, cyg_ucount16 source_stride)
286
{
287
}
288
 
289
void
290
cyg_fb_linear_read_block_2BE(cyg_fb* fb,
291
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
292
                             void* dest, cyg_ucount16 offset, cyg_ucount16 dest_stride)
293
{
294
}
295
 
296
void
297
cyg_fb_linear_move_block_2BE_impl(void* fbaddr, cyg_ucount16 stride,
298
                                  cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
299
                                  cyg_ucount16 new_x, cyg_ucount16 new_y)
300
{
301
}
302
 
303
void
304
cyg_fb_linear_move_block_2BE(cyg_fb* fb,
305
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
306
                             cyg_ucount16 new_x, cyg_ucount16 new_y)
307
{
308
    cyg_fb_linear_move_block_2BE_inl(fb->fb_base, fb->fb_stride, x, y, width, height, new_x, new_y);
309
}
310
 
311
// ----------------------------------------------------------------------------
312
void
313
cyg_fb_linear_write_pixel_4LE(cyg_fb* fb,
314
                              cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour)
315
{
316
    cyg_fb_linear_write_pixel_4LE_inl(fb->fb_base, fb->fb_stride, x, y, colour);
317
}
318
 
319
cyg_fb_colour
320
cyg_fb_linear_read_pixel_4LE(cyg_fb* fb,
321
                             cyg_ucount16 x, cyg_ucount16 y)
322
{
323
    return cyg_fb_linear_read_pixel_4LE_inl(fb->fb_base, fb->fb_stride, x, y);
324
}
325
 
326
void
327
cyg_fb_linear_write_hline_4LE(cyg_fb* fb,
328
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
329
{
330
}
331
 
332
void
333
cyg_fb_linear_write_vline_4LE(cyg_fb* fb,
334
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
335
{
336
    cyg_fb_linear_write_vline_4LE_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
337
}
338
 
339
void
340
cyg_fb_linear_fill_block_4LE(cyg_fb* fb,
341
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour)
342
{
343
}
344
 
345
void
346
cyg_fb_linear_write_block_4LE(cyg_fb* fb,
347
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
348
                              const void* source, cyg_ucount16 offset, cyg_ucount16 source_stride)
349
{
350
}
351
 
352
void
353
cyg_fb_linear_read_block_4LE(cyg_fb* fb,
354
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
355
                             void* dest, cyg_ucount16 offset, cyg_ucount16 dest_stride)
356
{
357
}
358
 
359
void
360
cyg_fb_linear_move_block_4LE_impl(void* fbaddr, cyg_ucount16 stride,
361
                                  cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
362
                                  cyg_ucount16 new_x, cyg_ucount16 new_y)
363
{
364
}
365
 
366
void
367
cyg_fb_linear_move_block_4LE(cyg_fb* fb,
368
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
369
                             cyg_ucount16 new_x, cyg_ucount16 new_y)
370
{
371
    cyg_fb_linear_move_block_4LE_inl(fb->fb_base, fb->fb_stride, x, y, width, height, new_x, new_y);
372
}
373
 
374
// ----------------------------------------------------------------------------
375
void
376
cyg_fb_linear_write_pixel_4BE(cyg_fb* fb,
377
                              cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour)
378
{
379
    cyg_fb_linear_write_pixel_4BE_inl(fb->fb_base, fb->fb_stride, x, y, colour);
380
}
381
 
382
cyg_fb_colour
383
cyg_fb_linear_read_pixel_4BE(cyg_fb* fb,
384
                             cyg_ucount16 x, cyg_ucount16 y)
385
{
386
    return cyg_fb_linear_read_pixel_4BE_inl(fb->fb_base, fb->fb_stride, x, y);
387
}
388
 
389
void
390
cyg_fb_linear_write_hline_4BE(cyg_fb* fb,
391
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
392
{
393
    cyg_fb_linear_write_vline_4BE_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
394
}
395
 
396
void
397
cyg_fb_linear_write_vline_4BE(cyg_fb* fb,
398
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
399
{
400
}
401
 
402
void
403
cyg_fb_linear_fill_block_4BE(cyg_fb* fb,
404
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour)
405
{
406
}
407
 
408
void
409
cyg_fb_linear_write_block_4BE(cyg_fb* fb,
410
                              cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
411
                              const void* source, cyg_ucount16 offset, cyg_ucount16 source_stride)
412
{
413
}
414
 
415
void
416
cyg_fb_linear_read_block_4BE(cyg_fb* fb,
417
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
418
                             void* dest, cyg_ucount16 offset, cyg_ucount16 dest_stride)
419
{
420
}
421
 
422
void
423
cyg_fb_linear_move_block_4BE_impl(void* fbaddr, cyg_ucount16 stride,
424
                                  cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
425
                                  cyg_ucount16 new_x, cyg_ucount16 new_y)
426
{
427
}
428
 
429
void
430
cyg_fb_linear_move_block_4BE(cyg_fb* fb,
431
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
432
                             cyg_ucount16 new_x, cyg_ucount16 new_y)
433
{
434
    cyg_fb_linear_move_block_4BE_inl(fb->fb_base, fb->fb_stride, x, y, width, height, new_x, new_y);
435
}
436
 
437
// ----------------------------------------------------------------------------
438
 
439
void
440
cyg_fb_linear_write_pixel_8(cyg_fb* fb,
441
                            cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour)
442
{
443
    cyg_fb_linear_write_pixel_8_inl(fb->fb_base, fb->fb_stride, x, y, colour);
444
}
445
 
446
cyg_fb_colour
447
cyg_fb_linear_read_pixel_8(cyg_fb* fb,
448
                           cyg_ucount16 x, cyg_ucount16 y)
449
{
450
    return cyg_fb_linear_read_pixel_8_inl(fb->fb_base, fb->fb_stride, x, y);
451
}
452
 
453
void
454
cyg_fb_linear_write_hline_8(cyg_fb* fb,
455
                            cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
456
{
457
    cyg_fb_linear_write_hline_8_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
458
}
459
 
460
void
461
cyg_fb_linear_write_vline_8(cyg_fb* fb,
462
                            cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
463
{
464
    cyg_fb_linear_write_vline_8_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
465
}
466
 
467
void
468
cyg_fb_linear_fill_block_8(cyg_fb* fb,
469
                           cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour)
470
{
471
    cyg_fb_linear_fill_block_8_inl(fb->fb_base, fb->fb_stride, x, y, width, height, colour);
472
}
473
 
474
void
475
cyg_fb_linear_write_block_8(cyg_fb* fb,
476
                            cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
477
                            const void* source, cyg_ucount16 offset, cyg_ucount16 source_stride)
478
{
479
    cyg_fb_linear_write_block_8_inl(fb->fb_base, fb->fb_stride, x, y, width, height, source, offset, source_stride);
480
}
481
 
482
void
483
cyg_fb_linear_read_block_8(cyg_fb* fb,
484
                           cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
485
                           void* dest, cyg_ucount16 offset, cyg_ucount16 dest_stride)
486
{
487
    cyg_fb_linear_read_block_8_inl(fb->fb_base, fb->fb_stride, x, y, width, height, dest, offset, dest_stride);
488
}
489
 
490
void
491
cyg_fb_linear_move_block_8_impl(void* fbaddr, cyg_ucount16 stride,
492
                                cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
493
                                cyg_ucount16 new_x, cyg_ucount16 new_y)
494
{
495
    cyg_uint8*  source;
496
    cyg_uint8*  dest;
497
    int         i;
498
 
499
    source  = ((cyg_uint8*)fbaddr) + (    y * stride) +     x;
500
    dest    = ((cyg_uint8*)fbaddr) + (new_y * stride) + new_x;
501
 
502
    if ((new_y < y)             ||  // Possible overlapping blocks but no conflict
503
        (new_y > (y + height))  ||  // No overlap
504
        ((new_x + width) < x)   ||  // No overlap
505
        (new_x > (x + width))) {    // No overlap
506
 
507
        for ( ; height; height--) {
508
            __builtin_memcpy(dest, source, width);
509
            source  += stride;
510
            dest    += stride;
511
        }
512
        return;
513
    }
514
 
515
    // There is an overlap. Can we do a safe bottom-to-top lot of memcpy()'s ?
516
    if (new_y > y) {
517
        source += (height * stride);
518
        dest   += (height * stride);
519
 
520
        for ( ; height; height--) {
521
            source  -= stride;
522
            dest    -= stride;
523
            __builtin_memcpy(dest, source, width);
524
        }
525
        return;
526
    }
527
 
528
    // We must have (y == new_y) and an overlap, i.e. a short
529
    // horizontal move. We could use memmove() but the default
530
    // implementation is no better than what we can do here.
531
    if (new_x < x) {
532
        stride -= width;
533
        for ( ; height; height--) {
534
            for ( i = width; i ; i--) {
535
                *dest++ = *source++;
536
            }
537
            source  += stride;
538
            dest    += stride;
539
        }
540
    } else if (new_x > x) {
541
        source  += width;
542
        dest    += width;
543
        stride  += width;
544
        for ( ; height; height--) {
545
            for ( i = width; i; i--) {
546
                *--dest = *--source;
547
            }
548
            source  += stride;
549
            dest    += stride;
550
        }
551
    }
552
}
553
 
554
void
555
cyg_fb_linear_move_block_8(cyg_fb* fb,
556
                           cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
557
                           cyg_ucount16 new_x, cyg_ucount16 new_y)
558
{
559
    cyg_fb_linear_move_block_8_inl(fb->fb_base, fb->fb_stride, x, y, width, height, new_x, new_y);
560
}
561
 
562
// ----------------------------------------------------------------------------
563
void
564
cyg_fb_linear_write_pixel_16(cyg_fb* fb,
565
                             cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour)
566
{
567
    cyg_fb_linear_write_pixel_16_inl(fb->fb_base, fb->fb_stride, x, y, colour);
568
}
569
 
570
cyg_fb_colour
571
cyg_fb_linear_read_pixel_16(cyg_fb* fb,
572
                            cyg_ucount16 x, cyg_ucount16 y)
573
{
574
    return cyg_fb_linear_read_pixel_16_inl(fb->fb_base, fb->fb_stride, x, y);
575
}
576
 
577
void
578
cyg_fb_linear_write_hline_16(cyg_fb* fb,
579
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
580
{
581
    cyg_fb_linear_write_hline_16_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
582
}
583
 
584
void
585
cyg_fb_linear_write_vline_16(cyg_fb* fb,
586
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
587
{
588
    cyg_fb_linear_write_vline_16_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
589
}
590
 
591
void
592
cyg_fb_linear_fill_block_16(cyg_fb* fb,
593
                            cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour)
594
{
595
    cyg_fb_linear_fill_block_16_inl(fb->fb_base, fb->fb_stride, x, y, width, height, colour);
596
}
597
 
598
void
599
cyg_fb_linear_write_block_16(cyg_fb* fb,
600
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
601
                             const void* source, cyg_ucount16 offset, cyg_ucount16 source_stride)
602
{
603
    cyg_fb_linear_write_block_16_inl(fb->fb_base, fb->fb_stride, x, y, width, height, source, offset, source_stride);
604
}
605
 
606
void
607
cyg_fb_linear_read_block_16(cyg_fb* fb,
608
                            cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
609
                            void* dest, cyg_ucount16 offset, cyg_ucount16 dest_stride)
610
{
611
    cyg_fb_linear_read_block_16_inl(fb->fb_base, fb->fb_stride, x, y, width, height, dest, offset, dest_stride);
612
}
613
 
614
void
615
cyg_fb_linear_move_block_16_impl(void* fbaddr, cyg_ucount16 stride8,
616
                                  cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
617
                                  cyg_ucount16 new_x, cyg_ucount16 new_y)
618
{
619
    cyg_uint16* source;
620
    cyg_uint16* dest;
621
    int         i;
622
 
623
    source  = ((cyg_uint16*)(((cyg_uint8*)fbaddr) + (    y * stride8))) + x;
624
    dest    = ((cyg_uint16*)(((cyg_uint8*)fbaddr) + (new_y * stride8))) + new_x;
625
 
626
    if ((new_y < y)             ||  // Possible overlapping blocks but no conflict
627
        (new_y > (y + height))  ||  // No overlap
628
        ((new_x + width) < x)   ||  // No overlap
629
        (new_x > (x + width))) {    // No overlap
630
 
631
        width <<= 1;
632
        for ( ; height; height--) {
633
            __builtin_memcpy(dest, source, width);
634
            source  = (cyg_uint16*)(((cyg_uint8*)source) + stride8);
635
            dest    = (cyg_uint16*)(((cyg_uint8*)source) + stride8);
636
        }
637
        return;
638
    }
639
 
640
    // There is an overlap. Can we do a safe bottom-to-top lot of memcpy()'s ?
641
    if (new_y > y) {
642
        source = (cyg_uint16*)(((cyg_uint8*)source) + (height * stride8));
643
        dest   = (cyg_uint16*)(((cyg_uint8*)dest)   + (height * stride8));
644
        width <<= 1;
645
        for ( ; height; height--) {
646
            source   = (cyg_uint16*)(((cyg_uint8*)source) - stride8);
647
            dest     = (cyg_uint16*)(((cyg_uint8*)dest) - stride8);
648
            __builtin_memcpy(dest, source, width);
649
        }
650
        return;
651
    }
652
 
653
    // We must have (y == new_y) and an overlap, i.e. a short
654
    // horizontal move. We could use memmove() but the default
655
    // implementation is no better than what we can do here.
656
    if (new_x < x) {
657
        stride8 -= (width << 1);
658
        for ( ; height; height--) {
659
            for ( i = width; i ; i--) {
660
                *dest++ = *source++;
661
            }
662
            source  = (cyg_uint16*)(((cyg_uint8*)source) + stride8);
663
            dest    = (cyg_uint16*)(((cyg_uint8*)dest) + stride8);
664
        }
665
    } else if (new_x > x) {
666
        source  += width;
667
        dest    += width;
668
        stride8 += (width << 1);
669
        for ( ; height; height--) {
670
            for ( i = width; i ; i--) {
671
                *--dest = *--source;
672
            }
673
            source  = (cyg_uint16*)(((cyg_uint8*)source) + stride8);
674
            dest    = (cyg_uint16*)(((cyg_uint8*)dest) + stride8);
675
        }
676
    }
677
}
678
 
679
void
680
cyg_fb_linear_move_block_16(cyg_fb* fb,
681
                            cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
682
                            cyg_ucount16 new_x, cyg_ucount16 new_y)
683
{
684
    cyg_fb_linear_move_block_16_inl(fb->fb_base, fb->fb_stride, x, y, width, height, new_x, new_y);
685
}
686
 
687
// ----------------------------------------------------------------------------
688
void
689
cyg_fb_linear_write_pixel_32(cyg_fb* fb,
690
                             cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour)
691
{
692
    cyg_fb_linear_write_pixel_32_inl(fb->fb_base, fb->fb_stride, x, y, colour);
693
}
694
 
695
cyg_fb_colour
696
cyg_fb_linear_read_pixel_32(cyg_fb* fb,
697
                            cyg_ucount16 x, cyg_ucount16 y)
698
{
699
    return cyg_fb_linear_read_pixel_32_inl(fb->fb_base, fb->fb_stride, x, y);
700
}
701
 
702
void
703
cyg_fb_linear_write_hline_32(cyg_fb* fb,
704
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
705
{
706
    cyg_fb_linear_write_hline_32_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
707
}
708
 
709
void
710
cyg_fb_linear_write_vline_32(cyg_fb* fb,
711
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour)
712
{
713
    cyg_fb_linear_write_vline_32_inl(fb->fb_base, fb->fb_stride, x, y, len, colour);
714
}
715
 
716
void
717
cyg_fb_linear_fill_block_32(cyg_fb* fb,
718
                            cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour)
719
{
720
    cyg_fb_linear_fill_block_32_inl(fb->fb_base, fb->fb_stride, x, y, width, height, colour);
721
}
722
 
723
void
724
cyg_fb_linear_write_block_32(cyg_fb* fb,
725
                             cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
726
                             const void* source, cyg_ucount16 offset, cyg_ucount16 source_stride)
727
{
728
    cyg_fb_linear_write_block_32_inl(fb->fb_base, fb->fb_stride, x, y, width, height, source, offset, source_stride);
729
}
730
 
731
void
732
cyg_fb_linear_read_block_32(cyg_fb* fb,
733
                            cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
734
                            void* dest, cyg_ucount16 offset, cyg_ucount16 dest_stride)
735
{
736
    cyg_fb_linear_read_block_32_inl(fb->fb_base, fb->fb_stride, x, y, width, height, dest, offset, dest_stride);
737
}
738
 
739
void
740
cyg_fb_linear_move_block_32_impl(void* fbaddr, cyg_ucount16 stride8,
741
                                  cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
742
                                  cyg_ucount16 new_x, cyg_ucount16 new_y)
743
{
744
    cyg_uint32* source;
745
    cyg_uint32* dest;
746
    int         i;
747
 
748
    source  = ((cyg_uint32*)(((cyg_uint8*)fbaddr) + (    y * stride8))) + x;
749
    dest    = ((cyg_uint32*)(((cyg_uint8*)fbaddr) + (new_y * stride8))) + new_x;
750
 
751
    if ((new_y < y)             ||  // Possible overlapping blocks but no conflict
752
        (new_y > (y + height))  ||  // No overlap
753
        ((new_x + width) < x)   ||  // No overlap
754
        (new_x > (x + width))) {    // No overlap
755
 
756
        width <<= 2;
757
        for ( ; height; height--) {
758
            __builtin_memcpy(dest, source, width);
759
            source  = (cyg_uint32*)(((cyg_uint8*)source) + stride8);
760
            dest    = (cyg_uint32*)(((cyg_uint8*)source) + stride8);
761
        }
762
        return;
763
    }
764
 
765
    // There is an overlap. Can we do a safe bottom-to-top lot of memcpy()'s ?
766
    if (new_y > y) {
767
        source  = (cyg_uint32*)(((cyg_uint8*)source) + (height * stride8));
768
        dest    = (cyg_uint32*)(((cyg_uint8*)dest)   + (height * stride8));
769
        width <<= 2;
770
        for ( ; height; height--) {
771
            source   = (cyg_uint32*)(((cyg_uint8*)source) - stride8);
772
            dest     = (cyg_uint32*)(((cyg_uint8*)dest) - stride8);
773
            __builtin_memcpy(dest, source, width);
774
        }
775
        return;
776
    }
777
 
778
    // We must have (y == new_y) and an overlap, i.e. a short
779
    // horizontal move. We could use memmove() but the default
780
    // implementation is no better than what we can do here.
781
    if (new_x < x) {
782
        stride8 -= (width << 2);
783
        for ( ; height; height--) {
784
            for ( i = width; i ; i--) {
785
                *dest++ = *source++;
786
            }
787
            source  = (cyg_uint32*)(((cyg_uint8*)source) + stride8);
788
            dest    = (cyg_uint32*)(((cyg_uint8*)dest) + stride8);
789
        }
790
    } else if (new_x > x) {
791
        source  += width;
792
        dest    += width;
793
        stride8 += (width << 2);
794
        for ( ; height; height--) {
795
            for ( i = width; i ; i--) {
796
                *--dest = *--source;
797
            }
798
            source  = (cyg_uint32*)(((cyg_uint8*)source) + stride8);
799
            dest    = (cyg_uint32*)(((cyg_uint8*)dest) + stride8);
800
        }
801
    }
802
}
803
 
804
void
805
cyg_fb_linear_move_block_32(cyg_fb* fb,
806
                            cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height,
807
                            cyg_ucount16 new_x, cyg_ucount16 new_y)
808
{
809
    cyg_fb_linear_move_block_32_inl(fb->fb_base, fb->fb_stride, x, y, width, height, new_x, new_y);
810
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.