forked from 12to11/12to11
Add tests for subsurfaces and fix bug found by them
* subcompositor.c (ViewInsert, ViewInsertAfter) (ViewInsertBefore): Update bounds for child, not parent view. * tests/Imakefile (SRCS1, OBJS1): Build imgview first. (SRCS6, OBJS6): Add subcompositor tests. (PROGRAMS): Add subsurface_test. (subsurface_test): New program target. * tests/run_tests.sh (standard_tests): Add subsurface_test. * tests/svnignore.txt: Add subsurface_test. * tests/test_harness.c (swizzle_png_row_premultiply): New function. (load_png_image): Premultiply images w/ alpha channel. * tests/test_harness.h: Include more headers.
This commit is contained in:
parent
b8143cf32b
commit
47a650cfd6
6 changed files with 61 additions and 23 deletions
|
@ -1116,7 +1116,7 @@ ViewInsert (View *view, View *child)
|
|||
ViewRecomputeChildren (child, NULL);
|
||||
|
||||
/* And update bounds. */
|
||||
ViewUpdateBoundsForInsert (view);
|
||||
ViewUpdateBoundsForInsert (child);
|
||||
|
||||
/* Now, if the subcompositor is still not garbaged, damage each
|
||||
inferior of the view. */
|
||||
|
@ -1168,7 +1168,7 @@ ViewInsertAfter (View *view, View *child, View *sibling)
|
|||
ViewRecomputeChildren (child, NULL);
|
||||
|
||||
/* And update bounds. */
|
||||
ViewUpdateBoundsForInsert (view);
|
||||
ViewUpdateBoundsForInsert (child);
|
||||
|
||||
/* Now, if the subcompositor is still not garbaged, damage each
|
||||
inferior of the view. */
|
||||
|
@ -1199,7 +1199,7 @@ ViewInsertBefore (View *view, View *child, View *sibling)
|
|||
|
||||
/* Update subcompositor bounds. Inserting a view cannot shrink
|
||||
anything. */
|
||||
ViewUpdateBoundsForInsert (view);
|
||||
ViewUpdateBoundsForInsert (child);
|
||||
|
||||
/* Now, if the subcompositor is still not garbaged, damage each
|
||||
inferior of the view. */
|
||||
|
|
|
@ -22,18 +22,20 @@ name.c: $(12TO11ROOT)/name.xml name.h @@\
|
|||
ScannerTarget(12to11-test)
|
||||
ScannerTarget(viewporter)
|
||||
|
||||
SRCS1 = $(COMMONSRCS) simple_test.c
|
||||
OBJS1 = $(COMMONOBJS) simple_test.o
|
||||
SRCS2 = $(COMMONSRCS) damage_test.c
|
||||
OBJS2 = $(COMMONOBJS) damage_test.o
|
||||
SRCS3 = $(COMMONSRCS) transform_test.c
|
||||
OBJS3 = $(COMMONSRCS) transform_test.o
|
||||
SRCS4 = $(COMMONSRCS) viewporter_test.c
|
||||
OBJS4 = $(COMMONSRCS) viewporter_test.o
|
||||
/* Not actually a test. */
|
||||
SRCS5 = $(COMMONSRCS) imgview.c
|
||||
OBJS5 = $(COMMONSRCS) imgview.o
|
||||
PROGRAMS = simple_test damage_test transform_test viewporter_test imgview
|
||||
SRCS1 = $(COMMONSRCS) imgview.c
|
||||
OBJS1 = $(COMMONSRCS) imgview.o
|
||||
SRCS2 = $(COMMONSRCS) simple_test.c
|
||||
OBJS2 = $(COMMONOBJS) simple_test.o
|
||||
SRCS3 = $(COMMONSRCS) damage_test.c
|
||||
OBJS3 = $(COMMONOBJS) damage_test.o
|
||||
SRCS4 = $(COMMONSRCS) transform_test.c
|
||||
OBJS4 = $(COMMONSRCS) transform_test.o
|
||||
SRCS5 = $(COMMONSRCS) viewporter_test.c
|
||||
OBJS5 = $(COMMONSRCS) viewporter_test.o
|
||||
SRCS6 = $(COMMONSRCS) subsurface_test.c
|
||||
OBJS6 = $(COMMONSRCS) subsurface_test.o
|
||||
PROGRAMS = imgview simple_test damage_test transform_test viewporter_test subsurface_test
|
||||
|
||||
/* Make all objects depend on HEADER. */
|
||||
$(OBJS1): $(HEADER)
|
||||
|
@ -41,12 +43,13 @@ $(OBJS1): $(HEADER)
|
|||
/* And depend on all sources and headers. */
|
||||
depend:: $(HEADER) $(SRCS1)
|
||||
|
||||
NormalProgramTarget(simple_test,$(OBJS1),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(damage_test,$(OBJS2),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(transform_test,$(OBJS3),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(viewporter_test,$(OBJS4),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(imgview,$(OBJS5),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(imgview,$(OBJS1),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(simple_test,$(OBJS2),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(damage_test,$(OBJS3),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(transform_test,$(OBJS4),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(viewporter_test,$(OBJS5),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
NormalProgramTarget(subsurface_test,$(OBJS6),NullParameter,$(LOCAL_LIBRARIES),NullParameter)
|
||||
DependTarget3($(SRCS1),$(SRCS2),$(SRCS3))
|
||||
DependTarget3($(SRCS4),$(SRCS5),NullParameter)
|
||||
DependTarget3($(SRCS4),$(SRCS5),$(SRCS6))
|
||||
|
||||
all:: $(PROGRAMS)
|
||||
|
|
|
@ -19,7 +19,10 @@
|
|||
# along with 12to11. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pushd "$(dirname $0)"
|
||||
declare -a standard_tests=( simple_test damage_test transform_test viewporter_test )
|
||||
declare -a standard_tests=(
|
||||
simple_test damage_test transform_test viewporter_test
|
||||
subsurface_test
|
||||
)
|
||||
|
||||
make -C . "${standard_tests[@]}"
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ simple_test
|
|||
damage_test
|
||||
transform_test
|
||||
viewporter_test
|
||||
subsurface_test
|
||||
imgview
|
||||
reject.dump
|
||||
Makefile
|
||||
|
|
|
@ -391,6 +391,29 @@ swizzle_png_row (unsigned char *row_data, int width)
|
|||
}
|
||||
}
|
||||
|
||||
/* Do the same, but also premultiply the individual color components
|
||||
with the alpha. */
|
||||
|
||||
static void
|
||||
swizzle_png_row_premultiply (unsigned char *row_data, int width)
|
||||
{
|
||||
int i;
|
||||
unsigned char byte_1, byte_2, byte_3, byte_4;
|
||||
|
||||
for (i = 0; i < width; ++i)
|
||||
{
|
||||
byte_1 = row_data[i * 4 + 0];
|
||||
byte_2 = row_data[i * 4 + 1];
|
||||
byte_3 = row_data[i * 4 + 2];
|
||||
byte_4 = row_data[i * 4 + 3];
|
||||
|
||||
row_data[i * 4 + 0] = (byte_3 * 1u * byte_4) / 255u;
|
||||
row_data[i * 4 + 1] = (byte_2 * 1u * byte_4) / 255u;
|
||||
row_data[i * 4 + 2] = (byte_1 * 1u * byte_4) / 255u;
|
||||
row_data[i * 4 + 3] = byte_4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Load a PNG image into a wl_buffer. The image must be either
|
||||
PNG_COLOR_TYPE_RGB or PNG_COLOR_TYPE_RGB_ALPHA. The image
|
||||
background is ignored. */
|
||||
|
@ -473,8 +496,14 @@ load_png_image (struct test_display *display, const char *filename)
|
|||
png_read_end (png_ptr, NULL);
|
||||
|
||||
for (i = 0; i < height; ++i)
|
||||
/* Swizzle the big-endian data. */
|
||||
swizzle_png_row (row_pointers[i], width);
|
||||
{
|
||||
/* Swizzle the big-endian data. */
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
swizzle_png_row_premultiply (row_pointers[i], width);
|
||||
else
|
||||
swizzle_png_row (row_pointers[i], width);
|
||||
}
|
||||
|
||||
/* Now, destroy the read struct and close the file. */
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
|
|
|
@ -19,6 +19,8 @@ along with 12to11. If not, see <https://www.gnu.org/licenses/>. */
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue