From patchwork Fri Feb 3 14:41:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 93175 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp652740obz; Fri, 3 Feb 2017 06:41:33 -0800 (PST) X-Received: by 10.99.160.84 with SMTP id u20mr18084905pgn.141.1486132892956; Fri, 03 Feb 2017 06:41:32 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id v1si25600660pfg.106.2017.02.03.06.41.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 06:41:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F5FC6EB9D; Fri, 3 Feb 2017 14:41:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id 33EB26EB9D for ; Fri, 3 Feb 2017 14:41:30 +0000 (UTC) Received: from e110455-lin.cambridge.arm.com (e110455-lin.cambridge.arm.com [10.2.131.175]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id v13EfSOh005193; Fri, 3 Feb 2017 14:41:28 GMT From: Liviu Dudau To: Emil Velikov Subject: [PATCH libdrm] tests: Fix pattern filler routines for 10-bit RGB colours Date: Fri, 3 Feb 2017 14:41:27 +0000 Message-Id: <20170203144127.15960-1-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.11.0 Cc: DRI-devel X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The routines that fill the framebuffer with colour data don't work properly for data formats that use 10 bits for RGB colours. Add sibling routines for those formats and use them where appropriate. Signed-off-by: Liviu Dudau --- tests/util/pattern.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 2 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 00b08a8c..4eed9771 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -70,6 +70,12 @@ struct color_yuv { (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \ (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset)) +#define MAKE_RGBA30(rgb, r, g, b, a) \ + ((((r) >> (10 - (rgb)->red.length)) << (rgb)->red.offset) | \ + (((g) >> (10 - (rgb)->green.length)) << (rgb)->green.offset) | \ + (((b) >> (10 - (rgb)->blue.length)) << (rgb)->blue.offset) | \ + (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset)) + #define MAKE_RGB24(rgb, r, g, b) \ { .value = MAKE_RGBA(rgb, r, g, b, 0) } @@ -461,6 +467,67 @@ static void fill_smpte_rgb32(const struct util_rgb_info *rgb, void *mem, } } +static void fill_smpte_rgb30(const struct util_rgb_info *rgb, void *mem, + unsigned int width, unsigned int height, + unsigned int stride) +{ + const uint32_t colors_top[] = { + MAKE_RGBA30(rgb, 768, 768, 768, 255), /* grey */ + MAKE_RGBA30(rgb, 768, 768, 0, 255), /* yellow */ + MAKE_RGBA30(rgb, 0, 768, 768, 255), /* cyan */ + MAKE_RGBA30(rgb, 0, 768, 0, 255), /* green */ + MAKE_RGBA30(rgb, 768, 0, 768, 255), /* magenta */ + MAKE_RGBA30(rgb, 768, 0, 0, 255), /* red */ + MAKE_RGBA30(rgb, 0, 0, 768, 255), /* blue */ + }; + const uint32_t colors_middle[] = { + MAKE_RGBA30(rgb, 0, 0, 768, 127), /* blue */ + MAKE_RGBA30(rgb, 76, 76, 76, 127), /* black */ + MAKE_RGBA30(rgb, 768, 0, 768, 127), /* magenta */ + MAKE_RGBA30(rgb, 76, 76, 76, 127), /* black */ + MAKE_RGBA30(rgb, 0, 768, 768, 127), /* cyan */ + MAKE_RGBA30(rgb, 76, 76, 76, 127), /* black */ + MAKE_RGBA30(rgb, 768, 768, 768, 127), /* grey */ + }; + const uint32_t colors_bottom[] = { + MAKE_RGBA30(rgb, 0, 132, 304, 255), /* in-phase */ + MAKE_RGBA30(rgb, 1020, 1020, 1020, 255),/* super white */ + MAKE_RGBA30(rgb, 200, 0, 424, 255), /* quadrature */ + MAKE_RGBA30(rgb, 76, 76, 76, 255), /* black */ + MAKE_RGBA30(rgb, 36, 36, 36, 255), /* 3.5% */ + MAKE_RGBA30(rgb, 76, 76, 76, 255), /* 7.5% */ + MAKE_RGBA30(rgb, 116, 116, 116, 255), /* 11.5% */ + MAKE_RGBA30(rgb, 76, 76, 76, 255), /* black */ + }; + unsigned int x; + unsigned int y; + + 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] = colors_bottom[7]; + mem += stride; + } +} + static void fill_smpte(const struct util_format_info *info, void *planes[3], unsigned int width, unsigned int height, unsigned int stride) @@ -525,6 +592,8 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_RGBX8888: case DRM_FORMAT_BGRA8888: case DRM_FORMAT_BGRX8888: + return fill_smpte_rgb32(&info->rgb, planes[0], + width, height, stride); case DRM_FORMAT_ARGB2101010: case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_ABGR2101010: @@ -533,7 +602,7 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_RGBX1010102: case DRM_FORMAT_BGRA1010102: case DRM_FORMAT_BGRX1010102: - return fill_smpte_rgb32(&info->rgb, planes[0], + return fill_smpte_rgb30(&info->rgb, planes[0], width, height, stride); } } @@ -747,6 +816,33 @@ static void fill_tiles_rgb32(const struct util_format_info *info, void *mem, make_pwetty(mem_base, width, height, stride, info->format); } +static void fill_tiles_rgb30(const struct util_format_info *info, void *mem, + unsigned int width, unsigned int height, + unsigned int stride) +{ + const struct util_rgb_info *rgb = &info->rgb; + void *mem_base = mem; + unsigned int x, y; + + for (y = 0; y < height; ++y) { + for (x = 0; x < width; ++x) { + div_t d = div(x+y, width); + uint32_t rgb32 = 0x004c1408 * (d.quot >> 6) + + 0x00284480 * (d.rem >> 6); + uint32_t alpha = ((y < height/2) && (x < width/2)) ? 127 : 255; + uint32_t color = + MAKE_RGBA30(rgb, (rgb32 >> 16) & 0x3ff, + (rgb32 >> 8) & 0x3ff, rgb32 & 0x3ff, + alpha); + + ((uint32_t *)mem)[x] = color; + } + mem += stride; + } + + make_pwetty(mem_base, width, height, stride, info->format); +} + static void fill_tiles(const struct util_format_info *info, void *planes[3], unsigned int width, unsigned int height, unsigned int stride) @@ -811,6 +907,8 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_RGBX8888: case DRM_FORMAT_BGRA8888: case DRM_FORMAT_BGRX8888: + return fill_tiles_rgb32(info, planes[0], + width, height, stride); case DRM_FORMAT_ARGB2101010: case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_ABGR2101010: @@ -819,7 +917,7 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_RGBX1010102: case DRM_FORMAT_BGRA1010102: case DRM_FORMAT_BGRX1010102: - return fill_tiles_rgb32(info, planes[0], + return fill_tiles_rgb30(info, planes[0], width, height, stride); } }