Add stroke alpha blend reference tests
This commit is contained in:
@@ -6,8 +6,11 @@
|
||||
|
||||
using pp::paint::BlendMode;
|
||||
using pp::paint::Rgba;
|
||||
using pp::paint::StrokeBlendMode;
|
||||
using pp::paint::blend_mode_name;
|
||||
using pp::paint::blend_pixels;
|
||||
using pp::paint::blend_stroke_alpha;
|
||||
using pp::paint::stroke_blend_mode_name;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -91,6 +94,39 @@ void clamps_inputs_and_names_modes(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, blend_mode_name(BlendMode::overlay) == std::string_view("overlay"));
|
||||
}
|
||||
|
||||
void stroke_alpha_blend_modes_match_shader_reference_vectors(pp::tests::Harness& h)
|
||||
{
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.2F, 0.8F, 0.25F, StrokeBlendMode::normal), 0.35F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.6F, 0.5F, 1.0F, StrokeBlendMode::multiply), 0.3F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.6F, 0.2F, 1.0F, StrokeBlendMode::subtract), 0.4F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.6F, 0.2F, 1.0F, StrokeBlendMode::darken), 0.2F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.75F, 0.25F, 1.0F, StrokeBlendMode::overlay), 0.625F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.4F, 0.5F, 1.0F, StrokeBlendMode::color_dodge), 0.8F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.6F, 0.5F, 1.0F, StrokeBlendMode::color_burn), 0.2F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.75F, 0.5F, 1.0F, StrokeBlendMode::linear_burn), 0.25F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.2F, 0.2F, 1.0F, StrokeBlendMode::hard_mix), 0.0F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.7F, 0.8F, 1.0F, StrokeBlendMode::hard_mix), 1.0F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.5F, 0.25F, 0.16F, StrokeBlendMode::linear_height), 0.637170F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.5F, 0.25F, 0.16F, StrokeBlendMode::height), 0.228217F));
|
||||
}
|
||||
|
||||
void stroke_alpha_blend_modes_handle_edges_and_names(pp::tests::Harness& h)
|
||||
{
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.8F, 0.2F, 0.0F, StrokeBlendMode::multiply), 0.8F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.0F, 0.8F, 1.0F, StrokeBlendMode::color_dodge), 0.0F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.8F, 1.0F, 1.0F, StrokeBlendMode::color_dodge), 1.0F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(1.0F, 0.2F, 1.0F, StrokeBlendMode::color_burn), 1.0F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.8F, 0.0F, 1.0F, StrokeBlendMode::color_burn), 0.0F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.0F, 1.0F, 1.0F, StrokeBlendMode::hard_mix), 0.0F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(-1.0F, 2.0F, 2.0F, StrokeBlendMode::normal), 1.0F));
|
||||
PP_EXPECT(h, near(blend_stroke_alpha(0.2F, 0.2F, 0.5F, static_cast<StrokeBlendMode>(255)), 1.0F));
|
||||
|
||||
PP_EXPECT(h, stroke_blend_mode_name(StrokeBlendMode::normal) == std::string_view("normal"));
|
||||
PP_EXPECT(h, stroke_blend_mode_name(StrokeBlendMode::linear_height) == std::string_view("linear_height"));
|
||||
PP_EXPECT(h, stroke_blend_mode_name(StrokeBlendMode::height) == std::string_view("height"));
|
||||
PP_EXPECT(h, stroke_blend_mode_name(static_cast<StrokeBlendMode>(255)) == std::string_view("unknown"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -101,5 +137,7 @@ int main()
|
||||
harness.run("multiply_and_screen_are_bounded", multiply_and_screen_are_bounded);
|
||||
harness.run("color_dodge_and_overlay_handle_extremes", color_dodge_and_overlay_handle_extremes);
|
||||
harness.run("clamps_inputs_and_names_modes", clamps_inputs_and_names_modes);
|
||||
harness.run("stroke_alpha_blend_modes_match_shader_reference_vectors", stroke_alpha_blend_modes_match_shader_reference_vectors);
|
||||
harness.run("stroke_alpha_blend_modes_handle_edges_and_names", stroke_alpha_blend_modes_handle_edges_and_names);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user