OLD | NEW |
1 /* ply-frame-buffer.c - framebuffer abstraction | 1 /* ply-frame-buffer.c - framebuffer abstraction |
2 * | 2 * |
3 * Copyright (C) 2006, 2007, 2008 Red Hat, Inc. | 3 * Copyright (C) 2006, 2007, 2008 Red Hat, Inc. |
4 * 2008 Charlie Brej <cbrej@cs.man.ac.uk> | 4 * 2008 Charlie Brej <cbrej@cs.man.ac.uk> |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by | 7 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation; either version 2, or (at your option) | 8 * the Free Software Foundation; either version 2, or (at your option) |
9 * any later version. | 9 * any later version. |
10 * | 10 * |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 hdiff = area->width - buffer->area.width; | 543 hdiff = area->width - buffer->area.width; |
544 vdiff = area->height - buffer->area.height; | 544 vdiff = area->height - buffer->area.height; |
545 | 545 |
546 lines = vdiff > 0 ? buffer->area.height : area->height; | 546 lines = vdiff > 0 ? buffer->area.height : area->height; |
547 width = hdiff > 0 ? buffer->area.width : area->width; | 547 width = hdiff > 0 ? buffer->area.width : area->width; |
548 | 548 |
549 if (hdiff >= 0) | 549 if (hdiff >= 0) |
550 { | 550 { |
551 /* image is wider than buffer */ | 551 /* image is wider than buffer */ |
552 dst = &buffer->map_address[0]; | 552 dst = &buffer->map_address[0]; |
553 src = (char *) (data + hdiff / 2); | 553 src = (char *) (data + hdiff / 2 - x); |
554 } else { | 554 } else { |
555 dst = &buffer->map_address[(-hdiff / 2) * buffer->bytes_per_pixel]; | 555 dst = &buffer->map_address[(-hdiff / 2 + x) * buffer->bytes_per_pixel]; |
556 src = (char *) data; | 556 src = (char *) data; |
557 } | 557 } |
558 | 558 |
559 if (vdiff >= 0) | 559 if (vdiff >= 0) |
560 { | 560 { |
561 /* image is taller than buffer */ | 561 /* image is taller than buffer */ |
562 src += (vdiff / 2) * area->width * sizeof(*data); | 562 src += (vdiff / 2 - y) * area->width * sizeof(*data); |
563 } | 563 } |
564 else | 564 else |
565 { | 565 { |
566 dst += (-vdiff / 2) * buffer->row_stride * buffer->bytes_per_pixel; | 566 dst += (-vdiff / 2 + y) * buffer->row_stride * buffer->bytes_per_pixel; |
567 } | 567 } |
568 | 568 |
569 if (buffer->bytes_per_pixel != sizeof(*data)) | 569 if (buffer->bytes_per_pixel != sizeof(*data)) |
570 { | 570 { |
571 uint16_t *src_16 = 0, *src_16_end; | 571 uint16_t *src_16 = 0, *src_16_end; |
572 int line; | 572 int line; |
573 | 573 |
574 /* Handle the 16 bpp case (specifically RGB 565 case) */ | 574 /* Handle the 16 bpp case (specifically RGB 565 case) */ |
575 if (buffer->bytes_per_pixel != 2) | 575 if (buffer->bytes_per_pixel != 2) |
576 return 0; | 576 return 0; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 | 633 |
634 | 634 |
635 void | 635 void |
636 ply_frame_buffer_clear (ply_frame_buffer_t *buffer) | 636 ply_frame_buffer_clear (ply_frame_buffer_t *buffer) |
637 { | 637 { |
638 assert (buffer != NULL); | 638 assert (buffer != NULL); |
639 assert (ply_frame_buffer_device_is_open (buffer)); | 639 assert (ply_frame_buffer_device_is_open (buffer)); |
640 memset (&buffer->map_address[0], 0, | 640 memset (&buffer->map_address[0], 0, |
641 buffer->area.width * buffer->area.height * buffer->bytes_per_pixel); | 641 buffer->area.width * buffer->area.height * buffer->bytes_per_pixel); |
642 } | 642 } |
OLD | NEW |