GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_1bpp_pixelmap_rotate.c Lines: 242 242 100.0 %
Date: 2026-03-06 19:21:09 Branches: 102 102 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Display Management (Display)                                        */
19
/**                                                                       */
20
/**************************************************************************/
21
#define GX_SOURCE_CODE
22
23
/* Include necessary system files.  */
24
25
#include "gx_api.h"
26
#include "gx_display.h"
27
#include "gx_context.h"
28
#include "gx_utility.h"
29
#include "gx_system.h"
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_display_driver_1bpp_pixelmap_raw_rotate         PORTABLE C      */
36
/*                                                           6.1.10       */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    Internal helper function that rotates an uncompressed pixelmap      */
44
/*      without transparency.                                             */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    context                               Drawing context               */
49
/*    xpos                                  x-coord of top-left draw point*/
50
/*    ypos                                  y-coord of top-left draw point*/
51
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
52
/*    angle                                 The angle to rotate           */
53
/*    cx                                    x-coord of rotate center      */
54
/*    cy                                    y-coord of rotate center      */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    status                                Completion status             */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _gx_utility_math_cos                  Compute the cosine value      */
63
/*    _gx_utility_math_sin                  Compute the sine value        */
64
/*                                                                        */
65
/*  CALLED BY                                                             */
66
/*                                                                        */
67
/*    _gx_display_driver_1bpp_pixelmap_rotate                             */
68
/*                                                                        */
69
/**************************************************************************/
70
712
static VOID _gx_display_driver_1bpp_pixelmap_raw_rotate(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap,
71
                                                        INT angle, INT cx, INT cy)
72
{
73
GX_UBYTE     *putrow;
74
GX_UBYTE     *put;
75
GX_UBYTE     *get;
76
INT           srcxres;
77
INT           srcyres;
78
INT           cosv;
79
INT           sinv;
80
INT           idxminx;
81
INT           idxmaxx;
82
INT           idxmaxy;
83
712
INT           mx[] = {-1, 1, 1, -1};
84
712
INT           my[] = {1, 1, -1, -1};
85
INT           xres;
86
INT           yres;
87
INT           x;
88
INT           y;
89
INT           xx;
90
INT           yy;
91
GX_RECTANGLE *clip;
92
INT           newxpos;
93
INT           newypos;
94
GX_UBYTE      putmask;
95
GX_UBYTE      getmask;
96
INT           putstride;
97
INT           getstride;
98
99
712
    clip = context -> gx_draw_context_clip;
100
101
    /* Set transparent color.  */
102
712
    idxminx = (angle / 90) & 0x3;
103
712
    idxmaxx = (idxminx + 2) & 0x3;
104
712
    idxmaxy = (idxminx + 1) & 0x3;
105
106
    /* Calculate the source x and y center. */
107
712
    srcxres = pixelmap -> gx_pixelmap_width >> 1;
108
712
    srcyres = pixelmap -> gx_pixelmap_height >> 1;
109
110
712
    cosv = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(angle));
111
712
    sinv = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(angle));
112
113
712
    xres = GX_FIXED_VAL_TO_INT((int)(mx[idxmaxx] * (srcxres + 2) * cosv - my[idxmaxx] * (srcyres + 2) * sinv));
114
712
    yres = GX_FIXED_VAL_TO_INT((int)(my[idxmaxy] * (srcyres + 2) * cosv + mx[idxmaxy] * (srcxres + 2) * sinv));
115
116
712
    getstride = (pixelmap -> gx_pixelmap_width + 7) >> 3;
117
712
    putstride = (context -> gx_draw_context_pitch + 7) >> 3;
118
712
    putrow = (GX_UBYTE *)context -> gx_draw_context_memory;
119
712
    putrow += clip -> gx_rectangle_top * putstride;
120
712
    putrow += clip -> gx_rectangle_left >> 3;
121
122
    /* Calculate the new rotation axis. */
123
712
    xres = GX_FIXED_VAL_TO_INT((cx - srcxres) * cosv - (cy - srcyres) * sinv) + xres;
124
712
    yres = GX_FIXED_VAL_TO_INT((cy - srcyres) * cosv + (cx - srcxres) * sinv) + yres;
125
126
712
    newxpos = xpos + cx - xres;
127
712
    newypos = ypos + cy - yres;
128
129
    /* For every pixel in destination bitmap, find its position in source bitmap,
130
       and set the pixel with the value in source bitmap.  */
131
150359
    for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++)
132
    {
133
149647
        put = putrow;
134
149647
        putmask = (GX_UBYTE)(0x80 >> (clip -> gx_rectangle_left & 0x07));
135
136
34447700
        for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++)
137
        {
138
34298053
            xx = (x - xres) * cosv + (y - yres) * sinv;
139
34298053
            yy = (y - yres) * cosv - (x - xres) * sinv;
140
141
34298053
            xx = GX_FIXED_VAL_TO_INT(xx) + cx;
142
34298053
            yy = GX_FIXED_VAL_TO_INT(yy) + cy;
143
144

34298053
            if ((xx >= 0) && (xx < pixelmap -> gx_pixelmap_width) &&
145
25557400
                (yy >= 0) && (yy < pixelmap -> gx_pixelmap_height))
146
            {
147
19177278
                get = (GX_UBYTE *)pixelmap -> gx_pixelmap_data;
148
19177278
                get += yy * getstride;
149
19177278
                get += xx >> 3;
150
19177278
                getmask = (GX_UBYTE)(0x80 >> (xx & 0x07));
151
152
19177278
                if ((*get) & getmask)
153
                {
154
8254568
                    *put |= putmask;
155
                }
156
                else
157
                {
158
10922710
                    *put = (GX_UBYTE)(*put & (~putmask));
159
                }
160
            }
161
162
34298053
            putmask >>= 1;
163
34298053
            if (putmask == 0)
164
            {
165
4289770
                put++;
166
4289770
                putmask = 0x80;
167
            }
168
        }
169
149647
        putrow += putstride;
170
    }
171
712
}
172
173
/**************************************************************************/
174
/*                                                                        */
175
/*  FUNCTION                                               RELEASE        */
176
/*                                                                        */
177
/*    _gx_display_driver_1bpp_pixelmap_transparent_rotate PORTABLE C      */
178
/*                                                           6.1.10       */
179
/*  AUTHOR                                                                */
180
/*                                                                        */
181
/*    Kenneth Maxwell, Microsoft Corporation                              */
182
/*                                                                        */
183
/*  DESCRIPTION                                                           */
184
/*                                                                        */
185
/*    Internal helper function that rotate an uncompressed pixelmap       */
186
/*      with transparent info.                                            */
187
/*                                                                        */
188
/*  INPUT                                                                 */
189
/*                                                                        */
190
/*    context                               Drawing context               */
191
/*    xpos                                  x-coord of top-left draw point*/
192
/*    ypos                                  y-coord of top-left draw point*/
193
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
194
/*    angle                                 The angle to rotate           */
195
/*    rot_cx                                x-coord of rotate center      */
196
/*    rot_cy                                y-coord of rotate center      */
197
/*                                                                        */
198
/*  OUTPUT                                                                */
199
/*                                                                        */
200
/*    status                                Completion status             */
201
/*                                                                        */
202
/*  CALLS                                                                 */
203
/*                                                                        */
204
/*    _gx_utility_math_cos                  Compute the cosine value      */
205
/*    _gx_utility_math_sin                  Compute the sine value        */
206
/*                                                                        */
207
/*  CALLED BY                                                             */
208
/*                                                                        */
209
/*    _gx_display_driver_1bpp_pixelmap_rotate                             */
210
/*                                                                        */
211
/**************************************************************************/
212
712
static VOID _gx_display_driver_1bpp_pixelmap_transparent_rotate(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap,
213
                                                                INT angle, INT cx, INT cy)
214
{
215
GX_UBYTE     *putrow;
216
GX_UBYTE     *put;
217
GX_UBYTE     *get;
218
GX_UBYTE      putmask;
219
GX_UBYTE      transmask;
220
GX_UBYTE      getmask;
221
INT           putstride;
222
INT           getstride;
223
INT           srcxres;
224
INT           srcyres;
225
INT           cosv;
226
INT           sinv;
227
INT           idxminx;
228
INT           idxmaxx;
229
INT           idxmaxy;
230
712
INT           mx[] = {-1, 1, 1, -1};
231
712
INT           my[] = {1, 1, -1, -1};
232
INT           xres;
233
INT           yres;
234
INT           x;
235
INT           y;
236
INT           xx;
237
INT           yy;
238
GX_RECTANGLE *clip;
239
INT           newxpos;
240
INT           newypos;
241
242
712
    clip = context -> gx_draw_context_clip;
243
712
    putstride = (context -> gx_draw_context_pitch + 7) >> 3;
244
712
    getstride = (pixelmap -> gx_pixelmap_width + 3) >> 2;
245
246
    /* Set transparent color.  */
247
712
    idxminx = (angle / 90) & 0x3;
248
712
    idxmaxx = (idxminx + 2) & 0x3;
249
712
    idxmaxy = (idxminx + 1) & 0x3;
250
251
    /* Calculate the source x and y center. */
252
712
    srcxres = pixelmap -> gx_pixelmap_width >> 1;
253
712
    srcyres = pixelmap -> gx_pixelmap_height >> 1;
254
255
712
    cosv = _gx_utility_math_cos(GX_FIXED_VAL_MAKE(angle));
256
712
    sinv = _gx_utility_math_sin(GX_FIXED_VAL_MAKE(angle));
257
258
712
    xres = GX_FIXED_VAL_TO_INT((mx[idxmaxx] * (srcxres + 2) * cosv - my[idxmaxx] * (srcyres + 2) * sinv));
259
712
    yres = GX_FIXED_VAL_TO_INT((my[idxmaxy] * (srcyres + 2) * cosv + mx[idxmaxy] * (srcxres + 2) * sinv));
260
261
712
    putrow = (GX_UBYTE *)context -> gx_draw_context_memory;
262
712
    putrow += clip -> gx_rectangle_top * putstride;
263
712
    putrow += clip -> gx_rectangle_left >> 3;
264
265
    /* Calculate the new rotation axis. */
266
712
    xres = GX_FIXED_VAL_TO_INT((cx - srcxres) * cosv - (cy - srcyres) * sinv) + xres;
267
712
    yres = GX_FIXED_VAL_TO_INT((cy - srcyres) * cosv + (cx - srcxres) * sinv) + yres;
268
269
712
    newxpos = xpos + cx - xres;
270
712
    newypos = ypos + cy - yres;
271
272
    /* For every pixel in destination bitmap, find its position in source bitmap,
273
       and set the pixel with the value in source bitmap.  */
274
166948
    for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++)
275
    {
276
166236
        put = putrow;
277
166236
        putmask = (GX_UBYTE)(0x80 >> (clip -> gx_rectangle_left & 0x07));
278
279
44643251
        for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++)
280
        {
281
44477015
            xx = GX_FIXED_VAL_TO_INT((x - xres) * cosv + (y - yres) * sinv) + cx;
282
44477015
            yy = GX_FIXED_VAL_TO_INT((y - yres) * cosv - (x - xres) * sinv) + cy;
283
284

44477015
            if ((xx >= 0) && (xx < pixelmap -> gx_pixelmap_width) &&
285
30360721
                (yy >= 0) && (yy < pixelmap -> gx_pixelmap_height))
286
            {
287
26410992
                get = (GX_UBYTE *)pixelmap -> gx_pixelmap_data;
288
26410992
                get += yy * getstride;
289
26410992
                get += xx >> 2;
290
291
26410992
                transmask = (GX_UBYTE)(0x40 >> ((xx & 0x03) << 1));
292
26410992
                if (transmask & (*get))
293
                {
294
16141951
                    getmask = (GX_UBYTE)(transmask << 1);
295
16141951
                    if ((*get) & getmask)
296
                    {
297
5988038
                        *put |= putmask;
298
                    }
299
                    else
300
                    {
301
10153913
                        *put = (GX_UBYTE)(*put & (~putmask));
302
                    }
303
                }
304
            }
305
306
44477015
            putmask >>= 1;
307
44477015
            if (putmask == 0)
308
            {
309
5553005
                put++;
310
5553005
                putmask = 0x80;
311
            }
312
        }
313
166236
        putrow += putstride;
314
    }
315
712
}
316
317
/**************************************************************************/
318
/*                                                                        */
319
/*  FUNCTION                                               RELEASE        */
320
/*                                                                        */
321
/*    _gx_display_driver_1bpp_pixelmap_simple_rotate      PORTABLE C      */
322
/*                                                           6.1.7        */
323
/*  AUTHOR                                                                */
324
/*                                                                        */
325
/*    Kenneth Maxwell, Microsoft Corporation                              */
326
/*                                                                        */
327
/*  DESCRIPTION                                                           */
328
/*                                                                        */
329
/*    Internal help function that hangles 90, 180 and 270 degree pixelmap */
330
/*    rotation.                                                           */
331
/*                                                                        */
332
/*  INPUT                                                                 */
333
/*                                                                        */
334
/*    context                               Drawing context               */
335
/*    xpos                                  x-coord of top-left draw point*/
336
/*    ypos                                  y-coord of top-left draw point*/
337
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
338
/*    angle                                 The angle to rotate           */
339
/*    rot_cx                                x-coord of rotate center      */
340
/*    rot_cy                                y-coord of rotate center      */
341
/*                                                                        */
342
/*  OUTPUT                                                                */
343
/*                                                                        */
344
/*    status                                Completion status             */
345
/*                                                                        */
346
/*  CALLS                                                                 */
347
/*                                                                        */
348
/*    None                                                                */
349
/*                                                                        */
350
/*  CALLED BY                                                             */
351
/*                                                                        */
352
/*    _gx_display_driver_1bpp_pixelmap_rotate                             */
353
/*                                                                        */
354
/**************************************************************************/
355
6
static VOID _gx_display_driver_1bpp_pixelmap_simple_rotate(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap,
356
                                                           INT angle, INT cx, INT cy)
357
{
358
GX_UBYTE     *putrow;
359
GX_UBYTE     *put;
360
GX_UBYTE      putmask;
361
GX_UBYTE     *get;
362
GX_UBYTE      getmask;
363
INT           putstride;
364
INT           width;
365
INT           height;
366
INT           x;
367
INT           y;
368
GX_RECTANGLE *clip;
369
INT           newxpos;
370
INT           newypos;
371
372
6
    clip = context -> gx_draw_context_clip;
373
6
    putstride = (context -> gx_draw_context_pitch + 7) >> 3;
374
375
6
    putrow = (GX_UBYTE *)context -> gx_draw_context_memory;
376
6
    putrow += clip -> gx_rectangle_top * putstride;
377
6
    putrow += clip -> gx_rectangle_left >> 3;
378
379
6
    if (angle == 90)
380
    {
381
2
        width = pixelmap -> gx_pixelmap_height;
382
2
        height = (pixelmap -> gx_pixelmap_width + 7) >> 3;
383
384
2
        newxpos = xpos + cx - (width - 1 - cy);
385
2
        newypos = ypos + cy - cx;
386
387
473
        for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++)
388
        {
389
471
            put = putrow;
390
471
            putmask = (GX_UBYTE)(0x80 >> (clip -> gx_rectangle_left & 0x07));
391
392
59817
            for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++)
393
            {
394
59346
                get = (GX_UBYTE *)pixelmap -> gx_pixelmap_data;
395
59346
                get += (width - 1 - x) * height;
396
59346
                get += y >> 3;
397
398
59346
                getmask = (GX_UBYTE)(0x80 >> (y & 0x07));
399
400
59346
                if ((*get) & getmask)
401
                {
402
25869
                    *put |= putmask;
403
                }
404
                else
405
                {
406
33477
                    *put = (GX_UBYTE)(*put & (~putmask));
407
                }
408
409
59346
                putmask >>= 1;
410
59346
                if (putmask == 0)
411
                {
412
7536
                    putmask = 0x80;
413
7536
                    put++;
414
                }
415
            }
416
471
            putrow += putstride;
417
        }
418
    }
419
4
    else if (angle == 180)
420
    {
421
2
        width = pixelmap -> gx_pixelmap_width;
422
2
        height = pixelmap -> gx_pixelmap_height;
423
424
2
        newxpos = xpos + cx - (width - 1 - cx);
425
2
        newypos = ypos + cy - (height - 1 - cy);
426
427
235
        for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++)
428
        {
429
233
            putmask = (GX_UBYTE)(0x80 >> (clip -> gx_rectangle_left & 0x07));
430
233
            put = putrow;
431
432
51552
            for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++)
433
            {
434
51319
                get = (GX_UBYTE *)pixelmap -> gx_pixelmap_data;
435
51319
                get += (height - 1 - y) * ((width + 7) >> 3);
436
51319
                get += (width - 1 - x) >> 3;
437
438
51319
                getmask = (GX_UBYTE)(0x80 >> ((width - 1 - x) & 0x07));
439
440
51319
                if ((*get) & getmask)
441
                {
442
22704
                    *put |= putmask;
443
                }
444
                else
445
                {
446
28615
                    *put = (GX_UBYTE)(*put & (~putmask));
447
                }
448
449
51319
                putmask >>= 1;
450
51319
                if (putmask == 0)
451
                {
452
6455
                    putmask = 0x80;
453
6455
                    put++;
454
                }
455
            }
456
233
            putrow += putstride;
457
        }
458
    }
459
    else
460
    {
461
2
        height = pixelmap -> gx_pixelmap_width;
462
463
2
        newxpos = xpos + cx - cy;
464
2
        newypos = ypos + cx - (height - 1 - cy);
465
466
349
        for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++)
467
        {
468
347
            putmask = (GX_UBYTE)(0x80 >> (clip -> gx_rectangle_left & 0x07));
469
347
            put = putrow;
470
471
44069
            for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++)
472
            {
473
43722
                get = (GX_UBYTE *)pixelmap -> gx_pixelmap_data;
474
43722
                get += x * ((height + 7) >> 3);
475
43722
                get += (height - 1 - y) >> 3;
476
477
43722
                getmask = (GX_UBYTE)(0x80 >> ((height - 1 - y) & 0x07));
478
479
43722
                if ((*get) & getmask)
480
                {
481
17931
                    *put |= putmask;
482
                }
483
                else
484
                {
485
25791
                    *put = (GX_UBYTE)(*put & (~putmask));
486
                }
487
488
43722
                putmask >>= 1;
489
43722
                if (putmask == 0)
490
                {
491
5312
                    putmask = 0x80;
492
5312
                    put++;
493
                }
494
            }
495
496
347
            putrow += putstride;
497
        }
498
    }
499
6
}
500
/**************************************************************************/
501
/*                                                                        */
502
/*  FUNCTION                                               RELEASE        */
503
/*                                                                        */
504
/*    _gx_display_driver_1bpp_pixelmap_simple_transparent_rotate          */
505
/*                                                        PORTABLE C      */
506
/*                                                           6.1.7        */
507
/*  AUTHOR                                                                */
508
/*                                                                        */
509
/*    Kenneth Maxwell, Microsoft Corporation                              */
510
/*                                                                        */
511
/*  DESCRIPTION                                                           */
512
/*                                                                        */
513
/*    Internal help function that hangles 90, 180 and 270 degree pixelmap */
514
/*    rotation.                                                           */
515
/*                                                                        */
516
/*  INPUT                                                                 */
517
/*                                                                        */
518
/*    context                               Drawing context               */
519
/*    xpos                                  x-coord of top-left draw point*/
520
/*    ypos                                  y-coord of top-left draw point*/
521
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
522
/*    angle                                 The angle to rotate           */
523
/*    rot_cx                                x-coord of rotate center      */
524
/*    rot_cy                                y-coord of rotate center      */
525
/*                                                                        */
526
/*  OUTPUT                                                                */
527
/*                                                                        */
528
/*    status                                Completion status             */
529
/*                                                                        */
530
/*  CALLS                                                                 */
531
/*                                                                        */
532
/*    None                                                                */
533
/*                                                                        */
534
/*  CALLED BY                                                             */
535
/*                                                                        */
536
/*    _gx_display_driver_1bpp_pixelmap_rotate                             */
537
/*                                                                        */
538
/**************************************************************************/
539
6
static VOID _gx_display_driver_1bpp_pixelmap_simple_transparent_rotate(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap,
540
                                                                       INT angle, INT cx, INT cy)
541
{
542
GX_UBYTE     *get;
543
INT           width;
544
INT           height;
545
INT           x;
546
INT           y;
547
GX_RECTANGLE *clip;
548
INT           newxpos;
549
INT           newypos;
550
GX_UBYTE     *put;
551
GX_UBYTE     *putrow;
552
INT           putstride;
553
GX_UBYTE      putmask;
554
INT           getstride;
555
GX_UBYTE      transmask;
556
GX_UBYTE      getmask;
557
558
6
    clip = context -> gx_draw_context_clip;
559
    /* 1bpp transparent pixelmap is stored as one bit color, one bit trans-mask. */
560
6
    getstride = (pixelmap -> gx_pixelmap_width + 3) >> 2;
561
6
    putstride = (context -> gx_draw_context_pitch + 7) >> 3;
562
6
    putrow = (GX_UBYTE *)context -> gx_draw_context_memory;
563
6
    putrow += clip -> gx_rectangle_top * putstride;
564
6
    putrow += clip -> gx_rectangle_left >> 3;
565
566
6
    clip = context -> gx_draw_context_clip;
567
568
6
    if (angle == 90)
569
    {
570
2
        width = pixelmap -> gx_pixelmap_height;
571
572
2
        newxpos = xpos + cx - (width - 1 - cy);
573
2
        newypos = ypos + cy - cx;
574
575
377
        for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++)
576
        {
577
375
            put = putrow;
578
375
            putmask = (GX_UBYTE)(0x80 >> (clip -> gx_rectangle_left & 0x07));
579
580
375
            transmask = (GX_UBYTE)(0x40 >> ((y & 0x03) << 1));
581
375
            getmask = (GX_UBYTE)(transmask << 1);
582
583
79260
            for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++)
584
            {
585
78885
                get = (GX_UBYTE *)pixelmap -> gx_pixelmap_data;
586
78885
                get += (width - 1 - x) * getstride;
587
78885
                get += y >> 2;
588
589
                /* if not transparent, draw pixel. else skip. */
590
78885
                if (transmask & *(get))
591
                {
592
46717
                    if ((*get) & getmask)
593
                    {
594
16750
                        *put |= putmask;
595
                    }
596
                    else
597
                    {
598
29967
                        *put = (GX_UBYTE)(*put & (~putmask));
599
                    }
600
                }
601
602
78885
                putmask >>= 1;
603
78885
                if (putmask == 0)
604
                {
605
9675
                    putmask = 0x80;
606
9675
                    put++;
607
                }
608
            }
609
375
            putrow += putstride;
610
        }
611
    }
612
4
    else if (angle == 180)
613
    {
614
2
        width = pixelmap -> gx_pixelmap_width;
615
2
        height = pixelmap -> gx_pixelmap_height;
616
617
2
        newxpos = xpos + cx - (width - 1 - cx);
618
2
        newypos = ypos + cy - (height - 1 - cy);
619
620
365
        for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++)
621
        {
622
363
            put = putrow;
623
363
            putmask = (GX_UBYTE)(0x80 >> (clip -> gx_rectangle_left & 0x07));
624
625
69708
            for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++)
626
            {
627
69345
                get = (GX_UBYTE *)pixelmap -> gx_pixelmap_data;
628
69345
                get += (height - 1 - y) * getstride;
629
69345
                get += (width - 1 - x) >> 2;
630
631
69345
                transmask = (GX_UBYTE)(0x40 >> (((width - 1 - x) & 0x03) << 1));
632
633
                /* if not transparent, draw pixel. else skip. */
634
69345
                if (transmask & *(get))
635
                {
636
44878
                    getmask = (GX_UBYTE)(transmask << 1);
637
44878
                    if ((*get) & getmask)
638
                    {
639
16750
                        *put |= putmask;
640
                    }
641
                    else
642
                    {
643
28128
                        *put = (GX_UBYTE)(*put & (~putmask));
644
                    }
645
                }
646
647
69345
                putmask >>= 1;
648
69345
                if (putmask == 0)
649
                {
650
8787
                    putmask = 0x80;
651
8787
                    put++;
652
                }
653
            }
654
363
            putrow += putstride;
655
        }
656
    }
657
    else
658
    {
659
2
        height = pixelmap -> gx_pixelmap_width;
660
661
2
        newxpos = xpos + cx - cy;
662
2
        newypos = ypos + cy - (height - 1 - cx);
663
664
293
        for (y = clip -> gx_rectangle_top - newypos; y <= clip -> gx_rectangle_bottom - newypos; y++)
665
        {
666
291
            put = putrow;
667
291
            putmask = (GX_UBYTE)(0x80 >> (clip -> gx_rectangle_left & 0x07));
668
669
66660
            for (x = clip -> gx_rectangle_left - newxpos; x <= clip -> gx_rectangle_right - newxpos; x++)
670
            {
671
66369
                get = (GX_UBYTE *)pixelmap -> gx_pixelmap_data;
672
66369
                get += x * getstride;
673
66369
                get += (height - 1 - y) >> 2;
674
675
66369
                transmask = (GX_UBYTE)(0x40 >> (((height - 1 - y) & 0x03) << 1));
676
677
                /* if not transparent, draw pixel. else skip. */
678
66369
                if (transmask & *(get))
679
                {
680
42907
                    getmask = (GX_UBYTE)(transmask << 1);
681
42907
                    if ((*get) & getmask)
682
                    {
683
16750
                        *put |= putmask;
684
                    }
685
                    else
686
                    {
687
26157
                        *put = (GX_UBYTE)(*put & (~putmask));
688
                    }
689
                }
690
691
66369
                putmask >>= 1;
692
66369
                if (putmask == 0)
693
                {
694
8259
                    putmask = 0x80;
695
8259
                    put++;
696
                }
697
            }
698
291
            putrow += putstride;
699
        }
700
    }
701
6
}
702
703
/**************************************************************************/
704
/*                                                                        */
705
/*  FUNCTION                                               RELEASE        */
706
/*                                                                        */
707
/*    _gx_display_driver_1bpp_pixelmap_rotate             PORTABLE C      */
708
/*                                                           6.1          */
709
/*  AUTHOR                                                                */
710
/*                                                                        */
711
/*    Kenneth Maxwell, Microsoft Corporation                              */
712
/*                                                                        */
713
/*  DESCRIPTION                                                           */
714
/*                                                                        */
715
/*    This service rotate a monochrome format pixelmap to canvas memory.  */
716
/*                                                                        */
717
/*  INPUT                                                                 */
718
/*                                                                        */
719
/*    context                               Drawing context               */
720
/*    xpos                                  x-coord of top-left draw point*/
721
/*    ypos                                  y-coord of top-left draw point*/
722
/*    pixelmap                              Pointer to GX_PIXELMAP struct */
723
/*    angle                                 The angle to rotate           */
724
/*    rot_cx                                x-coord of rotating center.   */
725
/*    rot_cy                                y-coord of rotationg center.  */
726
/*                                                                        */
727
/*  OUTPUT                                                                */
728
/*                                                                        */
729
/*    status                                Completion status             */
730
/*                                                                        */
731
/*  CALLS                                                                 */
732
/*                                                                        */
733
/*    _gx_display_driver_1bpp_pixelmap_simple_transparent_rotate          */
734
/*                                          Real pixelmap rotate function */
735
/*                                            which rotate image for 90,  */
736
/*                                            180 and 270 degree          */
737
/*    _gx_display_driver_1bpp_pixelmap_simple_rotate                      */
738
/*                                          Real pixelmap rotate function */
739
/*                                            which rotate image for 90,  */
740
/*                                            180 and 270 degree          */
741
/*    _gx_display_driver_1bpp_pixelmap_transparent_rotate                 */
742
/*                                          Real pixelmap rotate function */
743
/*    _gx_display_driver_1bpp_pixelmap_raw_rotate                         */
744
/*                                          Real pixelmap rotate function */
745
/*                                                                        */
746
/*  CALLED BY                                                             */
747
/*                                                                        */
748
/*    Application Code                                                    */
749
/*    GUIX Internal Code                                                  */
750
/*                                                                        */
751
/**************************************************************************/
752
1436
VOID _gx_display_driver_1bpp_pixelmap_rotate(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap,
753
                                             INT angle, INT rot_cx, INT rot_cy)
754
{
755
1436
    if (angle % 90 == 0)
756
    {
757
        /* Simple angle rotate: 90 degree, 180 degree and 270 degree.  */
758
12
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
759
        {
760
6
            _gx_display_driver_1bpp_pixelmap_simple_transparent_rotate(context, xpos, ypos, pixelmap, angle, rot_cx, rot_cy);
761
        }
762
        else
763
        {
764
6
            _gx_display_driver_1bpp_pixelmap_simple_rotate(context, xpos, ypos, pixelmap, angle, rot_cx, rot_cy);
765
        }
766
    }
767
    else
768
    {
769
1424
        if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT)
770
        {
771
            /* no compression or alpha */
772
712
            _gx_display_driver_1bpp_pixelmap_transparent_rotate(context, xpos, ypos, pixelmap, angle, rot_cx, rot_cy);
773
        }
774
        else
775
        {
776
            /* no compression or alpha */
777
712
            _gx_display_driver_1bpp_pixelmap_raw_rotate(context, xpos, ypos, pixelmap, angle, rot_cx, rot_cy);
778
        }
779
    }
780
781
1436
    return;
782
}
783