On Tue, Feb 2, 2016 at 8:28 AM, <[email protected]> wrote: > From: Bill Spitzak <[email protected]> > > If a negative value is used for the subsampling, then -n subsamples are > used at scale==1, and fewer are used at larger scale, more are used at > smaller scale, so that the total number of samples is approximately > the same. The computed value is rounded up to the next power of 2. > > The scale demo is modified to allow these negative numbers, and initially > uses -12. > > Signed-off-by: Bill Spitzak <[email protected]> > --- > demos/scale.ui | 5 +++-- > pixman/pixman-filter.c | 24 ++++++++++++++++++++++++ > 2 files changed, 27 insertions(+), 2 deletions(-) > > diff --git a/demos/scale.ui b/demos/scale.ui > index b62cbfb..1e77f56 100644 > --- a/demos/scale.ui > +++ b/demos/scale.ui > @@ -24,12 +24,12 @@ > <property name="page_size">10</property> > </object> > <object class="GtkAdjustment" id="subsample_adjustment"> > - <property name="lower">0</property> > + <property name="lower">-256</property> > <property name="upper">12</property> > <property name="step_increment">1</property> > <property name="page_increment">1</property> > <property name="page_size">0</property> > - <property name="value">4</property> > + <property name="value">-12</property> > </object> > <object class="GtkWindow" id="main"> > <child> > @@ -321,6 +321,7 @@ > <object class="GtkSpinButton" > id="subsample_spin_button"> > <property name="visible">True</property> > <property > name="adjustment">subsample_adjustment</property> > + <property name="value">-12</property> > </object> > <packing> > <property name="left_attach">1</property> > diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c > index f28cc29..6e8024a 100644 > --- a/pixman/pixman-filter.c > +++ b/pixman/pixman-filter.c > @@ -342,14 +342,38 @@ filter_width(pixman_kernel_t reconstruct, > pixman_kernel_t sample, > double* size, int* subsample_bits) > { > int width; > + /* IMPULSE.x does not work for size < 1.0 */ > if (reconstruct == PIXMAN_KERNEL_IMPULSE && *size < 1.0) > *size = 1.0; > + /* Convolution adds the widths of the filters together */ > width = ceil (filters[reconstruct].width + *size * > filters[sample].width); > + /* If there will only be one sample, it must be 1.0 due to normalization, > + and subsampling is useless. */ > if (width <= 1) > { > width = 1; > *subsample_bits = 0; > } > + else if (*subsample_bits < 0) > + { > + /* The intention was to do -n / size rounded up to the next power of > 2, > + but this non-linear function seems to work better. For large size > + it is the width of the BOX.BOX filter. For small size it reduces > + samples by 2 at maximum. */ > + double desired_samples = -*subsample_bits; > + if (sample == PIXMAN_KERNEL_IMPULSE) > + ; /* For x.IMPULSE no scaling is done */ > + else if (*size >= 1.0) > + desired_samples *= 2.0 / (*size + 1.0); > + else > + desired_samples *= 2.0 / ((*size + 1.0) * *size); > + *subsample_bits = (int) ceil (log2(desired_samples) - .01); > + if (*subsample_bits < 0) > + *subsample_bits = 0; > + else if (*subsample_bits > 8) > + /* Assume we cannot see more than 256 different shades and limit > subsampling */ > + *subsample_bits = 8; > + } > return width; > } > > -- > 1.9.1 > > _______________________________________________ > Pixman mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/pixman
I tried applying just the first hunk (the scale.ui change) without the second hunk to see If I get any visual errors in scale demo, but couldn't see anything wrong. So, I would need to see some form of test/example that is affected by this patch, as I don't have the knowledge to even ACK it. Otherwise, you will need to get someone else to review this (Soren ?). Oded _______________________________________________ Pixman mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/pixman
