Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: src/third_party/ply-image/src/ply-frame-buffer.c

Issue 2083008: Support ply-image splash screen display for ST1q (Closed) Base URL: http://src.chromium.org/git/chromiumos.git
Patch Set: Fix space-tab issues Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 527
528 bool 528 bool
529 ply_frame_buffer_fill (ply_frame_buffer_t *buffer, 529 ply_frame_buffer_fill (ply_frame_buffer_t *buffer,
530 ply_frame_buffer_area_t *area, 530 ply_frame_buffer_area_t *area,
531 unsigned long x, 531 unsigned long x,
532 unsigned long y, 532 unsigned long y,
533 uint32_t *data) 533 uint32_t *data)
534 { 534 {
535 char *dst, *src; 535 char *dst, *src;
536 int hdiff, vdiff; 536 int hdiff, vdiff;
537 int lines, width;
537 538
538 assert (buffer != NULL); 539 assert (buffer != NULL);
539 assert (ply_frame_buffer_device_is_open (buffer)); 540 assert (ply_frame_buffer_device_is_open (buffer));
540 assert (area != NULL); 541 assert (area != NULL);
541 542
542 hdiff = area->width - buffer->area.width; 543 hdiff = area->width - buffer->area.width;
543 vdiff = area->height - buffer->area.height; 544 vdiff = area->height - buffer->area.height;
544 545
546 lines = vdiff > 0 ? buffer->area.height : area->height;
547 width = hdiff > 0 ? buffer->area.width : area->width;
548
545 if (hdiff >= 0) 549 if (hdiff >= 0)
546 { 550 {
547 /* image is wider than buffer */ 551 /* image is wider than buffer */
548 dst = &buffer->map_address[0]; 552 dst = &buffer->map_address[0];
549 src = (char *) (data + hdiff / 2); 553 src = (char *) (data + hdiff / 2);
550 } else { 554 } else {
551 dst = &buffer->map_address[(-hdiff / 2) * sizeof(*data)]; 555 dst = &buffer->map_address[(-hdiff / 2) * buffer->bytes_per_pixel];
552 src = (char *) data; 556 src = (char *) data;
553 } 557 }
554 558
555 if (vdiff >= 0) 559 if (vdiff >= 0)
556 { 560 {
557 /* image is taller than buffer */ 561 /* image is taller than buffer */
558 src += (vdiff / 2) * area->width * sizeof(*data); 562 src += (vdiff / 2) * area->width * sizeof(*data);
559 } 563 }
560 else 564 else
561 { 565 {
562 dst += (-vdiff / 2) * buffer->row_stride * sizeof(*data); 566 dst += (-vdiff / 2) * buffer->row_stride * buffer->bytes_per_pixel;
563 } 567 }
564 568
565 if (area->width == buffer->row_stride) 569 if (buffer->bytes_per_pixel != sizeof(*data))
570 {
571 uint16_t *src_16 = 0, *src_16_end;
572 int line;
573
574 /* Handle the 16 bpp case (specifically RGB 565 case) */
575 if (buffer->bytes_per_pixel != 2)
576 return 0;
577
578 /* Allocate temporary row pixel data storage for 16 bpp displays */
579 src_16 = (uint16_t *) malloc (width * sizeof(*src_16));
580
581 if (!src_16)
582 return 0;
583
584 src_16_end = src_16 + width;
585
586 for (line = 0; line < lines; line++) {
587 uint32_t *src_32_temp;
588 uint16_t *src_16_temp;
589
590 for (src_32_temp = (uint32_t *)src, src_16_temp = src_16;
591 src_16_temp != src_16_end;
592 src_16_temp++)
593 {
594 uint32_t src_32_value = *src_32_temp++;
595 *src_16_temp = (uint16_t)(
596 ((src_32_value & 0x00F80000) >> 8) | \
597 ((src_32_value & 0x0000FC00) >> 5) | \
598 ((src_32_value & 0x000000F8) >> 3)
599 );
600 }
601 memcpy (dst, src_16, width * buffer->bytes_per_pixel);
602
603 dst += buffer->row_stride * buffer->bytes_per_pixel;
604 src += area->width * sizeof(*data);
605 }
606
607 free (src_16);
608 }
609 else if (area->width == buffer->row_stride)
566 { 610 {
567 memcpy (dst, src, area->width * area->height * sizeof(*data)); 611 memcpy (dst, src, area->width * area->height * sizeof(*data));
568 } 612 }
569 else 613 else
570 { 614 {
571 int line; 615 int line;
572 int lines = vdiff > 0 ? buffer->area.height : area->height; 616
573 int width = hdiff > 0 ? buffer->area.width : area->width;
574
575 for (line = 0; line < lines; line++) { 617 for (line = 0; line < lines; line++) {
576 memcpy (dst, src, width * sizeof(*data)); 618 memcpy (dst, src, width * sizeof(*data));
577 dst += buffer->row_stride * sizeof(*data); 619 dst += buffer->row_stride * sizeof(*data);
578 src += area->width * sizeof(*data); 620 src += area->width * sizeof(*data);
579 } 621 }
580 } 622 }
581 623
582 return 1; 624 return 1;
583 } 625 }
584 626
585 627
586 const char * 628 const char *
587 ply_frame_buffer_get_bytes (ply_frame_buffer_t *buffer) 629 ply_frame_buffer_get_bytes (ply_frame_buffer_t *buffer)
588 { 630 {
589 return (char *) buffer->shadow_buffer; 631 return (char *) buffer->shadow_buffer;
590 } 632 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698