Merge branch 'tizen' into sandbox/cyeon/devel
[platform/core/uifw/libtdm.git] / tools / buffers.c
index 4d66f12..ea88179 100644 (file)
@@ -125,7 +125,7 @@ static const struct format_info format_info[] = {
        { TBM_FORMAT_RGB888, "RG24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 0, 0) },
        /* RGB32 */
        { TBM_FORMAT_ARGB8888, "AR24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 8, 24) },
-       { TBM_FORMAT_XRGB8888, "XR24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 0, 0) },
+       { TBM_FORMAT_XRGB8888, "XR24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 0, 24) },
        { TBM_FORMAT_ABGR8888, "AB24", MAKE_RGB_INFO(8, 0, 8, 8, 8, 16, 8, 24) },
        { TBM_FORMAT_XBGR8888, "XB24", MAKE_RGB_INFO(8, 0, 8, 8, 8, 16, 0, 0) },
        { TBM_FORMAT_RGBA8888, "RA24", MAKE_RGB_INFO(8, 24, 8, 16, 8, 8, 8, 0) },
@@ -186,6 +186,12 @@ struct color_yuv {
         (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \
         (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset))
 
+#define MAKE_RGBX(rgb, r, g, b) \
+               ((((r) >> (8 - (rgb)->red.length)) << (rgb)->red.offset) | \
+                (((g) >> (8 - (rgb)->green.length)) << (rgb)->green.offset) | \
+                (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \
+                (255 << (rgb)->alpha.offset))
+
 #define MAKE_RGB24(rgb, r, g, b) \
        { .value = MAKE_RGBA(rgb, r, g, b, 0) }
 
@@ -248,8 +254,12 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv,
                for (; x < width * 6 / 7; ++x)
                        y_mem[x] = colors_bottom[(x - width * 5 / 7) * 3
                                                                         / (width / 7) + 4].y;
-               for (; x < width; ++x)
-                       y_mem[x] = colors_bottom[7].y;
+               for (; x < width; ++x) {
+                       if (rand_r(&rand_seed) % 2)
+                               y_mem[x] = colors_bottom[1].y;
+                       else
+                               y_mem[x] = colors_bottom[7].y;
+               }
                y_mem += stride;
        }
 
@@ -286,8 +296,13 @@ fill_smpte_yuv_planar(const struct yuv_info *yuv,
                                                                                                 3 / (width / 7) + 4].v;
                }
                for (; x < width; x += xsub) {
-                       u_mem[x * cs / xsub] = colors_bottom[7].u;
-                       v_mem[x * cs / xsub] = colors_bottom[7].v;
+                       if (rand_r(&rand_seed) % 2) {
+                               u_mem[x * cs / xsub] = colors_bottom[1].u;
+                               v_mem[x * cs / xsub] = colors_bottom[1].v;
+                       } else {
+                               u_mem[x * cs / xsub] = colors_bottom[7].u;
+                               v_mem[x * cs / xsub] = colors_bottom[7].v;
+                       }
                }
                u_mem += stride * cs / xsub;
                v_mem += stride * cs / xsub;
@@ -592,6 +607,70 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem,
 }
 
 static void
+fill_smpte_rgb32_dont_care_alpha(const struct rgb_info *rgb, unsigned char *mem,
+                                                                unsigned int width, unsigned int height, unsigned int stride)
+{
+       const uint32_t colors_top[] = {
+               MAKE_RGBX(rgb, 192, 192, 192),  /* grey */
+               MAKE_RGBX(rgb, 192, 192, 0),    /* yellow */
+               MAKE_RGBX(rgb, 0, 192, 192),    /* cyan */
+               MAKE_RGBX(rgb, 0, 192, 0),              /* green */
+               MAKE_RGBX(rgb, 192, 0, 192),    /* magenta */
+               MAKE_RGBX(rgb, 192, 0, 0),              /* red */
+               MAKE_RGBX(rgb, 0, 0, 192),              /* blue */
+       };
+       const uint32_t colors_middle[] = {
+               MAKE_RGBX(rgb, 0, 0, 192),              /* blue */
+               MAKE_RGBX(rgb, 19, 19, 19),     /* black */
+               MAKE_RGBX(rgb, 192, 0, 192),    /* magenta */
+               MAKE_RGBX(rgb, 19, 19, 19),     /* black */
+               MAKE_RGBX(rgb, 0, 192, 192),    /* cyan */
+               MAKE_RGBX(rgb, 19, 19, 19),     /* black */
+               MAKE_RGBX(rgb, 192, 192, 192),  /* grey */
+       };
+       const uint32_t colors_bottom[] = {
+               MAKE_RGBX(rgb, 0, 33, 76),              /* in-phase */
+               MAKE_RGBX(rgb, 255, 255, 255),  /* super white */
+               MAKE_RGBX(rgb, 50, 0, 106),     /* quadrature */
+               MAKE_RGBX(rgb, 19, 19, 19),     /* black */
+               MAKE_RGBX(rgb, 9, 9, 9),                /* 3.5% */
+               MAKE_RGBX(rgb, 19, 19, 19),     /* 7.5% */
+               MAKE_RGBX(rgb, 29, 29, 29),     /* 11.5% */
+               MAKE_RGBX(rgb, 19, 19, 19),     /* black */
+       };
+       unsigned int x;
+       unsigned int y;
+
+       if (width < 8)
+               return;
+
+       for (y = 0; y < height * 6 / 9; ++y) {
+               for (x = 0; x < width; ++x)
+                       ((uint32_t *)mem)[x] = colors_top[x * 7 / width];
+               mem += stride;
+       }
+
+       for (; y < height * 7 / 9; ++y) {
+               for (x = 0; x < width; ++x)
+                       ((uint32_t *)mem)[x] = colors_middle[x * 7 / width];
+               mem += stride;
+       }
+
+       for (; y < height; ++y) {
+               for (x = 0; x < width * 5 / 7; ++x)
+                       ((uint32_t *)mem)[x] =
+                               colors_bottom[x * 4 / (width * 5 / 7)];
+               for (; x < width * 6 / 7; ++x)
+                       ((uint32_t *)mem)[x] =
+                               colors_bottom[(x - width * 5 / 7) * 3
+                                                         / (width / 7) + 4];
+               for (; x < width; ++x)
+                       ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBX(rgb, 255, 255, 255) : MAKE_RGBX(rgb, 0, 0, 0);
+               mem += stride;
+       }
+}
+
+static void
 fill_smpte(const struct format_info *info, void *planes[3], unsigned int width,
                   unsigned int height, unsigned int stride)
 {
@@ -648,7 +727,6 @@ fill_smpte(const struct format_info *info, void *planes[3], unsigned int width,
                return fill_smpte_rgb24(&info->rgb, planes[0],
                                                                width, height, stride);
        case TBM_FORMAT_ARGB8888:
-       case TBM_FORMAT_XRGB8888:
        case TBM_FORMAT_ABGR8888:
        case TBM_FORMAT_XBGR8888:
        case TBM_FORMAT_RGBA8888:
@@ -665,6 +743,9 @@ fill_smpte(const struct format_info *info, void *planes[3], unsigned int width,
        case TBM_FORMAT_BGRX1010102:
                return fill_smpte_rgb32(&info->rgb, planes[0],
                                                                width, height, stride);
+       case TBM_FORMAT_XRGB8888:
+               return fill_smpte_rgb32_dont_care_alpha(&info->rgb, planes[0],
+                                                                                               width, height, stride);
        }
 }