Re: [Pixman] [Patch] Gradient dithering into pixman (Try 2)

2018-04-28 Thread Marc Jeanmougin

Hi,

Can I get any input if my second patch follows "the right approach"? Are 
there any astylerc or clang_format to check that my code complies with 
code style ?


Thanks



On 04/19/2018 08:41 PM, Marc Jeanmougin wrote:


Hi,

Could anyone help me from here? If there is still a fundamental 
problem with the patch, I'll be happy to rework it (or if there is 
anything more needed in it)


From what I gathered, pixman is without maintainer, so I'm not sure 
either how to proceed or who to contact...


--

Marc


On 04/08/2018 10:46 PM, Marc Jeanmougin wrote:

Hi, I'm back :)


I tried to implement the proposed changes :

* the gradient walker now deals with argb_t (floats) and not uint32_t
* all gradients are WIDE because of the above change
* WIDE formats (using argb_t) can be dithered on write_back call
depending on the "dither" property of the image (set with
pixman_image_set_dither)
* The dithering is still random. I could try to implement other ones if
it's really needed for the patch to be accepted


Thanks for any feedback, please do tell if there are any more changes
needed for the patch to be accepted.



___
Pixman mailing list
Pixman@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pixman




___
Pixman mailing list
Pixman@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pixman


___
Pixman mailing list
Pixman@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pixman


Re: [Pixman] [Patch] Gradient dithering into pixman (Try 2)

2018-04-19 Thread Marc Jeanmougin
Hi,

Could anyone help me from here? If there is still a fundamental problem
with the patch, I'll be happy to rework it (or if there is anything more
needed in it)

From what I gathered, pixman is without maintainer, so I'm not sure
either how to proceed or who to contact...

-- 

Marc


On 04/08/2018 10:46 PM, Marc Jeanmougin wrote:
> Hi, I'm back :)
>
>
> I tried to implement the proposed changes :
>
> * the gradient walker now deals with argb_t (floats) and not uint32_t
> * all gradients are WIDE because of the above change
> * WIDE formats (using argb_t) can be dithered on write_back call
> depending on the "dither" property of the image (set with
> pixman_image_set_dither)
> * The dithering is still random. I could try to implement other ones if
> it's really needed for the patch to be accepted
>
>
> Thanks for any feedback, please do tell if there are any more changes
> needed for the patch to be accepted.
>
>
>
> ___
> Pixman mailing list
> Pixman@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pixman



signature.asc
Description: OpenPGP digital signature
___
Pixman mailing list
Pixman@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/pixman


[Pixman] [Patch] Gradient dithering into pixman (Try 2)

2018-04-08 Thread Marc Jeanmougin
Hi, I'm back :)


I tried to implement the proposed changes :

* the gradient walker now deals with argb_t (floats) and not uint32_t
* all gradients are WIDE because of the above change
* WIDE formats (using argb_t) can be dithered on write_back call
depending on the "dither" property of the image (set with
pixman_image_set_dither)
* The dithering is still random. I could try to implement other ones if
it's really needed for the patch to be accepted


Thanks for any feedback, please do tell if there are any more changes
needed for the patch to be accepted.

-- 
Marc
From 2cd0d0a12c9a68bdedde10ae4b10c335f8961501 Mon Sep 17 00:00:00 2001
From: Marc Jeanmougin 
Date: Sun, 8 Apr 2018 22:25:27 +0200
Subject: [PATCH] Adds a gradient dithering function to pixman.

This dithering is random, resulting is no artifacts and very smooth result,
and uses a very fast prng (xorshift algorithm).

Also adds a pixman_image_set_dithering to toggle the feature,
and a pixman_dither_t type for possible future other implementations.

Signed-off-by: Marc Jeanmougin 
---
 .gitignore   |  2 ++
 pixman/pixman-bits-image.c   | 47 
 pixman/pixman-conical-gradient.c |  7 ++
 pixman/pixman-general.c  |  3 ++-
 pixman/pixman-gradient-walker.c  | 24 +---
 pixman/pixman-image.c| 12 ++
 pixman/pixman-linear-gradient.c  | 11 --
 pixman/pixman-private.h  |  7 +-
 pixman/pixman-radial-gradient.c  | 18 +++
 pixman/pixman-utils.c| 10 +
 pixman/pixman.h  |  9 
 11 files changed, 108 insertions(+), 42 deletions(-)

diff --git a/.gitignore b/.gitignore
index a245b69..02ad685 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,3 +53,5 @@ test/trap-crasher
 *.ilk
 *.obj
 *.exe
+*.log
+*.trs
diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c
index dcdcc69..bdedb99 100644
--- a/pixman/pixman-bits-image.c
+++ b/pixman/pixman-bits-image.c
@@ -752,6 +752,51 @@ _pixman_bits_image_src_iter_init (pixman_image_t *image, pixman_iter_t *iter)
 iter->get_scanline = _pixman_iter_get_scanline_noop;
 }
 
+
+static float 
+dither_channel (float f, int n_bits, uint32_t *state)
+{
+uint32_t u, i_rem;
+float f_rem;
+if (f>1.0) f = 1.0;
+if (f<0) f = 0.;
+
+u = f * (1 << n_bits);
+u -= (u >> n_bits);
+f_rem = ( (float)(1<common.state);
+pixman_format_code_t format = image->format;
+
+if(image->common.dither == PIXMAN_DITHER_NONE)
+return;
+
+a_size = PIXMAN_FORMAT_A (format);
+r_size = PIXMAN_FORMAT_R (format);
+g_size = PIXMAN_FORMAT_G (format);
+b_size = PIXMAN_FORMAT_B (format);
+
+for (i = 0; i < width; ++i) {
+buf[i].a = dither_channel(buf[i].a, a_size, state);
+buf[i].r = dither_channel(buf[i].r, r_size, state);
+buf[i].g = dither_channel(buf[i].g, g_size, state);
+buf[i].b = dither_channel(buf[i].b, b_size, state);
+}
+}
+
 static uint32_t *
 dest_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
 {
@@ -856,6 +901,8 @@ dest_write_back_wide (pixman_iter_t *iter)
 int width  = iter->width;
 const uint32_t *buffer = iter->buffer;
 
+dither (image, (argb_t*)buffer, width);
+
 image->store_scanline_float (image, x, y, width, buffer);
 
 if (image->common.alpha_map)
diff --git a/pixman/pixman-conical-gradient.c b/pixman/pixman-conical-gradient.c
index 8bb46ae..35a64f4 100644
--- a/pixman/pixman-conical-gradient.c
+++ b/pixman/pixman-conical-gradient.c
@@ -57,11 +57,11 @@ conical_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
 int x = iter->x;
 int y = iter->y;
 int width = iter->width;
-uint32_t *buffer = iter->buffer;
+argb_t *buffer = (argb_t*)(iter->buffer);
 
 gradient_t *gradient = (gradient_t *)image;
 conical_gradient_t *conical = (conical_gradient_t *)image;
-uint32_t   *end = buffer + width;
+argb_t   *end = buffer + width;
 pixman_gradient_walker_t walker;
 pixman_bool_t affine = TRUE;
 double cx = 1.;
@@ -165,9 +165,6 @@ conical_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
 {
 uint32_t *buffer = conical_get_scanline_narrow (iter, NULL);
 
-pixman_expand_to_float (
-	(argb_t *)buffer, buffer, PIXMAN_a8r8g8b8, iter->width);
-
 return buffer;
 }
 
diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c
index 6141cb0..809df2c 100644
--- a/pixman/pixman-general.c
+++ b/pixman/pixman-general.c
@@ -141,7 +141,8 @@