diff --git a/doc/sexblitter-perfection.png b/doc/sexblitter-perfection.png new file mode 100644 index 000000000..ec287fd24 Binary files /dev/null and b/doc/sexblitter-perfection.png differ diff --git a/doc/worldmap-sexblitter.png b/doc/worldmap-sexblitter.png new file mode 100644 index 000000000..b86978861 Binary files /dev/null and b/doc/worldmap-sexblitter.png differ diff --git a/tests/visual.cpp b/tests/visual.cpp index c03883d37..57bc52f0b 100644 --- a/tests/visual.cpp +++ b/tests/visual.cpp @@ -465,7 +465,7 @@ TEST_CASE("Visual") { { 0xff605040, 0xffcccccc, 0xff605040, 0xff605040 }, { 0xff605040, 0xff605040, 0xffcccccc, 0xff605040 }, { 0xff605040, 0xff605040, 0xff605040, 0xffcccccc } }; - const char* egcs[4] = { "▟", "▙", "▜", "▛" }; + const char* egcs[] = { "▟", "▙", "▜", "▛" }; for(int i = 0 ; i < 4 ; ++i){ auto ncv = ncvisual_from_rgba(pixels[i], 2, 2 * sizeof(**pixels), 2); REQUIRE(nullptr != ncv); @@ -508,7 +508,7 @@ TEST_CASE("Visual") { { 0xff605040, 0xffcccccc, 0xffcccccc, 0xff605040 }, { 0xff605040, 0xffcccccc, 0xff605040, 0xffcccccc }, { 0xff605040, 0xff605040, 0xffcccccc, 0xffcccccc } }; - const char* egcs[6] = { "▀", "▌", "▚", "▚", "▌", "▀" }; + const char* egcs[] = { "▀", "▌", "▚", "▚", "▌", "▀" }; for(size_t i = 0 ; i < sizeof(egcs) / sizeof(*egcs) ; ++i){ auto ncv = ncvisual_from_rgba(pixels[i], 2, 2 * sizeof(**pixels), 2); REQUIRE(nullptr != ncv); @@ -556,7 +556,7 @@ TEST_CASE("Visual") { { 0xff605040, 0xffcccccc, 0xff444444, 0xff605040 }, { 0xff605040, 0xffeeeeee, 0xff605040, 0xffcccccc }, { 0xff605040, 0xff605040, 0xffeeeeee, 0xffcccccc } }; - const char* egcs[6] = { "▟", "▜", "▟", "▙", "▌", "▀" }; + const char* egcs[] = { "▟", "▜", "▟", "▙", "▌", "▀" }; for(size_t i = 0 ; i < sizeof(egcs) / sizeof(*egcs) ; ++i){ auto ncv = ncvisual_from_rgba(pixels[i], 2, 2 * sizeof(**pixels), 2); REQUIRE(nullptr != ncv); @@ -594,5 +594,47 @@ TEST_CASE("Visual") { ncvisual_destroy(ncv); } } + + // quadblitter with one pair plus two split + SUBCASE("QuadblitterAllDifferent") { + const uint32_t pixels[6][4] = { + { 0xffdddddd, 0xff000000, 0xff111111, 0xff222222 }, + { 0xff000000, 0xff111111, 0xffdddddd, 0xff222222 }, + { 0xff111111, 0xffdddddd, 0xff000000, 0xff222222 }, + { 0xff000000, 0xffcccccc, 0xff222222, 0xffeeeeee }, + { 0xff222222, 0xff000000, 0xffeeeeee, 0xffcccccc, } }; + const char* egcs[] = { "▟", "▜", "▙", "▌", "▀" }; + for(size_t i = 0 ; i < sizeof(egcs) / sizeof(*egcs) ; ++i){ + auto ncv = ncvisual_from_rgba(pixels[i], 2, 2 * sizeof(**pixels), 2); + REQUIRE(nullptr != ncv); + struct ncvisual_options vopts = { + .n = nullptr, + .scaling = NCSCALE_NONE, + .y = 0, + .x = 0, + .begy = 0, + .begx = 0, + .leny = 0, + .lenx = 0, + .blitter = NCBLIT_2x2, + .flags = 0, + }; + auto ncvp = ncvisual_render(nc_, ncv, &vopts); + REQUIRE(nullptr != ncvp); + int dimy, dimx; + ncplane_dim_yx(ncvp, &dimy, &dimx); + CHECK(1 == dimy); + CHECK(1 == dimx); + uint16_t stylemask; + uint64_t channels; + auto egc = ncplane_at_yx(ncvp, 0, 0, &stylemask, &channels); + CHECK(0 == strcmp(egcs[i], egc)); + CHECK(0 == stylemask); + CHECK(0x111111 == channels_fg_rgb(channels)); + CHECK(0xdddddd == channels_bg_rgb(channels)); + free(egc); + ncvisual_destroy(ncv); + } + } CHECK(!notcurses_stop(nc_)); }