tests/alpha-blend: use image-iter.h
Simplify the code by using ready-made helpers. No change in behaviour. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
67331be0cd
commit
f212a703cf
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "weston-test-client-helper.h"
|
#include "weston-test-client-helper.h"
|
||||||
#include "weston-test-fixture-compositor.h"
|
#include "weston-test-fixture-compositor.h"
|
||||||
|
#include "image-iter.h"
|
||||||
#include "color_util.h"
|
#include "color_util.h"
|
||||||
|
|
||||||
struct setup_args {
|
struct setup_args {
|
||||||
@ -110,22 +111,14 @@ unpremult_float(struct color_float *cf)
|
|||||||
static void
|
static void
|
||||||
fill_alpha_pattern(struct buffer *buf)
|
fill_alpha_pattern(struct buffer *buf)
|
||||||
{
|
{
|
||||||
void *pixels;
|
struct image_header ih = image_header_from(buf->image);
|
||||||
int stride_bytes;
|
|
||||||
int w, h;
|
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
assert(pixman_image_get_format(buf->image) == PIXMAN_a8r8g8b8);
|
assert(ih.pixman_format == PIXMAN_a8r8g8b8);
|
||||||
|
assert(ih.width == BLOCK_WIDTH * ALPHA_STEPS);
|
||||||
|
|
||||||
pixels = pixman_image_get_data(buf->image);
|
for (y = 0; y < ih.height; y++) {
|
||||||
stride_bytes = pixman_image_get_stride(buf->image);
|
uint32_t *row = image_header_get_row_u32(&ih, y);
|
||||||
w = pixman_image_get_width(buf->image);
|
|
||||||
h = pixman_image_get_height(buf->image);
|
|
||||||
|
|
||||||
assert(w == BLOCK_WIDTH * ALPHA_STEPS);
|
|
||||||
|
|
||||||
for (y = 0; y < h; y++) {
|
|
||||||
uint32_t *row = pixels + y * stride_bytes;
|
|
||||||
uint32_t step;
|
uint32_t step;
|
||||||
|
|
||||||
for (step = 0; step < (uint32_t)ALPHA_STEPS; step++) {
|
for (step = 0; step < (uint32_t)ALPHA_STEPS; step++) {
|
||||||
@ -140,7 +133,6 @@ fill_alpha_pattern(struct buffer *buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
compare_float(float ref, float dst, int x, const char *chan, float *max_diff)
|
compare_float(float ref, float dst, int x, const char *chan, float *max_diff)
|
||||||
{
|
{
|
||||||
@ -269,16 +261,12 @@ pixels_monotonic(const uint32_t *row, int x)
|
|||||||
static void *
|
static void *
|
||||||
get_middle_row(struct buffer *buf)
|
get_middle_row(struct buffer *buf)
|
||||||
{
|
{
|
||||||
const int y = (BLOCK_WIDTH - 1) / 2; /* middle row */
|
struct image_header ih = image_header_from(buf->image);
|
||||||
void *pixels;
|
|
||||||
int stride_bytes;
|
|
||||||
|
|
||||||
assert(pixman_image_get_width(buf->image) >= BLOCK_WIDTH * ALPHA_STEPS);
|
assert(ih.width >= BLOCK_WIDTH * ALPHA_STEPS);
|
||||||
assert(pixman_image_get_height(buf->image) >= BLOCK_WIDTH);
|
assert(ih.height >= BLOCK_WIDTH);
|
||||||
|
|
||||||
pixels = pixman_image_get_data(buf->image);
|
return image_header_get_row_u32(&ih, (BLOCK_WIDTH - 1) / 2);
|
||||||
stride_bytes = pixman_image_get_stride(buf->image);
|
|
||||||
return pixels + y * stride_bytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
Loading…
Reference in New Issue
Block a user