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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/third_party/ply-image/src/ply-frame-buffer.c
diff --git a/src/third_party/ply-image/src/ply-frame-buffer.c b/src/third_party/ply-image/src/ply-frame-buffer.c
old mode 100644
new mode 100755
index 88d6804f46e88bd87af2281ee3b40731d4fecf73..b0c64b7a0fd386b9e978839c1df3632cdc67516d
--- a/src/third_party/ply-image/src/ply-frame-buffer.c
+++ b/src/third_party/ply-image/src/ply-frame-buffer.c
@@ -534,6 +534,7 @@ ply_frame_buffer_fill (ply_frame_buffer_t *buffer,
{
char *dst, *src;
int hdiff, vdiff;
+ int lines, width;
assert (buffer != NULL);
assert (ply_frame_buffer_device_is_open (buffer));
@@ -542,13 +543,16 @@ ply_frame_buffer_fill (ply_frame_buffer_t *buffer,
hdiff = area->width - buffer->area.width;
vdiff = area->height - buffer->area.height;
+ lines = vdiff > 0 ? buffer->area.height : area->height;
+ width = hdiff > 0 ? buffer->area.width : area->width;
+
if (hdiff >= 0)
{
/* image is wider than buffer */
dst = &buffer->map_address[0];
src = (char *) (data + hdiff / 2);
} else {
- dst = &buffer->map_address[(-hdiff / 2) * sizeof(*data)];
+ dst = &buffer->map_address[(-hdiff / 2) * buffer->bytes_per_pixel];
src = (char *) data;
}
@@ -559,19 +563,57 @@ ply_frame_buffer_fill (ply_frame_buffer_t *buffer,
}
else
{
- dst += (-vdiff / 2) * buffer->row_stride * sizeof(*data);
+ dst += (-vdiff / 2) * buffer->row_stride * buffer->bytes_per_pixel;
}
- if (area->width == buffer->row_stride)
+ if (buffer->bytes_per_pixel != sizeof(*data))
+ {
+ uint16_t *src_16 = 0, *src_16_end;
+ int line;
+
+ /* Handle the 16 bpp case (specifically RGB 565 case) */
+ if (buffer->bytes_per_pixel != 2)
+ return 0;
+
+ /* Allocate temporary row pixel data storage for 16 bpp displays */
+ src_16 = (uint16_t *) malloc (width * sizeof(*src_16));
+
+ if (!src_16)
+ return 0;
+
+ src_16_end = src_16 + width;
+
+ for (line = 0; line < lines; line++) {
+ uint32_t *src_32_temp;
+ uint16_t *src_16_temp;
+
+ for (src_32_temp = (uint32_t *)src, src_16_temp = src_16;
+ src_16_temp != src_16_end;
+ src_16_temp++)
+ {
+ uint32_t src_32_value = *src_32_temp++;
+ *src_16_temp = (uint16_t)(
+ ((src_32_value & 0x00F80000) >> 8) | \
+ ((src_32_value & 0x0000FC00) >> 5) | \
+ ((src_32_value & 0x000000F8) >> 3)
+ );
+ }
+ memcpy (dst, src_16, width * buffer->bytes_per_pixel);
+
+ dst += buffer->row_stride * buffer->bytes_per_pixel;
+ src += area->width * sizeof(*data);
+ }
+
+ free (src_16);
+ }
+ else if (area->width == buffer->row_stride)
{
memcpy (dst, src, area->width * area->height * sizeof(*data));
}
else
{
int line;
- int lines = vdiff > 0 ? buffer->area.height : area->height;
- int width = hdiff > 0 ? buffer->area.width : area->width;
-
+
for (line = 0; line < lines; line++) {
memcpy (dst, src, width * sizeof(*data));
dst += buffer->row_stride * sizeof(*data);
« 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