diff --git a/subcompositor.c b/subcompositor.c
index 3cd4ec6..0b91c22 100644
--- a/subcompositor.c
+++ b/subcompositor.c
@@ -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. */
diff --git a/tests/Imakefile b/tests/Imakefile
index 643bf94..48871fd 100644
--- a/tests/Imakefile
+++ b/tests/Imakefile
@@ -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)
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 9959590..e93bb87 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -19,7 +19,10 @@
# along with 12to11. If not, see .
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[@]}"
diff --git a/tests/svnignore.txt b/tests/svnignore.txt
index 6ef7a4e..a006657 100644
--- a/tests/svnignore.txt
+++ b/tests/svnignore.txt
@@ -5,6 +5,7 @@ simple_test
damage_test
transform_test
viewporter_test
+subsurface_test
imgview
reject.dump
Makefile
diff --git a/tests/test_harness.c b/tests/test_harness.c
index f2c4177..5c084a7 100644
--- a/tests/test_harness.c
+++ b/tests/test_harness.c
@@ -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);
diff --git a/tests/test_harness.h b/tests/test_harness.h
index 90d5ab4..d95bfc8 100644
--- a/tests/test_harness.h
+++ b/tests/test_harness.h
@@ -19,6 +19,8 @@ along with 12to11. If not, see . */
#include
#include
+#include
+#include
#include
#include