mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
test: replaced ClipPath with clip()
This commit is contained in:
parent
8f8af68955
commit
ab54345d9a
3 changed files with 35 additions and 49 deletions
|
@ -237,7 +237,7 @@ TEST_CASE("Paint Identifier", "[capiPaint]")
|
|||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_CASE("Paint Clip Path Composite Method", "[capiPaint]")
|
||||
TEST_CASE("Paint Clipping", "[capiPaint]")
|
||||
{
|
||||
Tvg_Paint* paint = tvg_shape_new();
|
||||
REQUIRE(paint);
|
||||
|
@ -245,21 +245,13 @@ TEST_CASE("Paint Clip Path Composite Method", "[capiPaint]")
|
|||
Tvg_Paint* target = tvg_shape_new();
|
||||
REQUIRE(target);
|
||||
|
||||
REQUIRE(tvg_paint_set_composite_method(paint, NULL, TVG_COMPOSITE_METHOD_NONE) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_set_composite_method(paint, target, TVG_COMPOSITE_METHOD_NONE) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_set_composite_method(paint, NULL, TVG_COMPOSITE_METHOD_CLIP_PATH) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_set_clip(paint, NULL) == TVG_RESULT_SUCCESS);
|
||||
|
||||
Tvg_Paint* target2 = tvg_shape_new();
|
||||
REQUIRE(target2);
|
||||
REQUIRE(tvg_paint_set_composite_method(paint, target2, TVG_COMPOSITE_METHOD_CLIP_PATH) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(tvg_paint_set_clip(paint, target2) == TVG_RESULT_SUCCESS);
|
||||
|
||||
const Tvg_Paint* target3 = nullptr;
|
||||
Tvg_Composite_Method method = TVG_COMPOSITE_METHOD_NONE;
|
||||
REQUIRE(tvg_paint_get_composite_method(paint, NULL, &method) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_composite_method(paint, &target3, NULL) == TVG_RESULT_INVALID_ARGUMENT);
|
||||
REQUIRE(tvg_paint_get_composite_method(paint, &target3, &method) == TVG_RESULT_SUCCESS);
|
||||
REQUIRE(method == TVG_COMPOSITE_METHOD_CLIP_PATH);
|
||||
REQUIRE(target2 == target3);
|
||||
REQUIRE(tvg_paint_set_clip(paint, NULL) == TVG_RESULT_SUCCESS);
|
||||
|
||||
REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ TEST_CASE("Duplication", "[tvgPaint]")
|
|||
|
||||
auto comp = Shape::gen();
|
||||
REQUIRE(comp);
|
||||
REQUIRE(shape->composite(std::move(comp), CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(shape->clip(std::move(comp)) == Result::Success);
|
||||
|
||||
//Duplication
|
||||
auto dup = tvg::cast<Shape>(shape->duplicate());
|
||||
|
@ -199,8 +199,6 @@ TEST_CASE("Duplication", "[tvgPaint]")
|
|||
REQUIRE(m.e31 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(m.e32 == Approx(0.0f).margin(0.000001));
|
||||
REQUIRE(m.e33 == Approx(1.0f).margin(0.000001));
|
||||
|
||||
REQUIRE(dup->composite(nullptr) == CompositeMethod::ClipPath);
|
||||
}
|
||||
|
||||
TEST_CASE("Composition", "[tvgPaint]")
|
||||
|
@ -212,23 +210,19 @@ TEST_CASE("Composition", "[tvgPaint]")
|
|||
REQUIRE(shape->composite(nullptr) == CompositeMethod::None);
|
||||
|
||||
auto comp = Shape::gen();
|
||||
REQUIRE(shape->composite(nullptr, CompositeMethod::ClipPath) == Result::InvalidArguments);
|
||||
REQUIRE(shape->composite(std::move(comp), CompositeMethod::None) == Result::InvalidArguments);
|
||||
|
||||
//ClipPath
|
||||
//Clipping
|
||||
comp = Shape::gen();
|
||||
auto pComp = comp.get();
|
||||
REQUIRE(shape->composite(std::move(comp), CompositeMethod::ClipPath) == Result::Success);
|
||||
|
||||
const Paint* pComp2 = nullptr;
|
||||
REQUIRE(shape->composite(&pComp2) == CompositeMethod::ClipPath);
|
||||
REQUIRE(pComp == pComp2);
|
||||
REQUIRE(shape->clip(std::move(comp)) == Result::Success);
|
||||
|
||||
//AlphaMask
|
||||
comp = Shape::gen();
|
||||
pComp = comp.get();
|
||||
REQUIRE(shape->composite(std::move(comp), CompositeMethod::AlphaMask) == Result::Success);
|
||||
|
||||
const Paint* pComp2 = nullptr;
|
||||
REQUIRE(shape->composite(&pComp2) == CompositeMethod::AlphaMask);
|
||||
REQUIRE(pComp == pComp2);
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
|||
REQUIRE(basicPicture2->composite(std::move(rectMask2), tvg::CompositeMethod::InvAlphaMask) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture2)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture3->composite(std::move(rectMask3), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture3->clip(std::move(rectMask3)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture3)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture4->composite(std::move(rectMask4), tvg::CompositeMethod::LumaMask) == Result::Success);
|
||||
|
@ -166,10 +166,10 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
|||
REQUIRE(canvas->push(std::move(basicPicture5)) == Result::Success);
|
||||
|
||||
// Rle
|
||||
REQUIRE(basicPicture6->composite(std::move(rleMask), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture6->clip(std::move(rleMask)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture6)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture7->composite(std::move(rleMask7), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture7->clip(std::move(rleMask7)) == Result::Success);
|
||||
REQUIRE(basicPicture7->opacity(100) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture7)) == Result::Success);
|
||||
|
||||
|
@ -222,7 +222,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
|||
REQUIRE(basicPicture2->composite(std::move(rectMask2), tvg::CompositeMethod::InvAlphaMask) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture2)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture3->composite(std::move(rectMask3), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture3->clip(std::move(rectMask3)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture3)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture4->composite(std::move(rectMask4), tvg::CompositeMethod::LumaMask) == Result::Success);
|
||||
|
@ -232,10 +232,10 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
|||
REQUIRE(canvas->push(std::move(basicPicture5)) == Result::Success);
|
||||
|
||||
// Rle
|
||||
REQUIRE(basicPicture6->composite(std::move(rleMask), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture6->clip(std::move(rleMask)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture6)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture7->composite(std::move(rleMask7), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture7->clip(std::move(rleMask7)) == Result::Success);
|
||||
REQUIRE(basicPicture7->opacity(100) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture7)) == Result::Success);
|
||||
|
||||
|
@ -286,7 +286,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
|||
REQUIRE(basicPicture2->composite(std::move(rectMask2), tvg::CompositeMethod::InvAlphaMask) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture2)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture3->composite(std::move(rectMask3), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture3->clip(std::move(rectMask3)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture3)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture4->composite(std::move(rectMask4), tvg::CompositeMethod::LumaMask) == Result::Success);
|
||||
|
@ -296,10 +296,10 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
|||
REQUIRE(canvas->push(std::move(basicPicture5)) == Result::Success);
|
||||
|
||||
// Rle
|
||||
REQUIRE(basicPicture6->composite(std::move(rleMask), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture6->clip(std::move(rleMask)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture6)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture7->composite(std::move(rleMask7), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture7->clip(std::move(rleMask7)) == Result::Success);
|
||||
REQUIRE(basicPicture7->opacity(100) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture7)) == Result::Success);
|
||||
|
||||
|
@ -350,7 +350,7 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
|||
REQUIRE(basicPicture2->composite(std::move(rectMask2), tvg::CompositeMethod::InvAlphaMask) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture2)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture3->composite(std::move(rectMask3), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture3->clip(std::move(rectMask3)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture3)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture4->composite(std::move(rectMask4), tvg::CompositeMethod::LumaMask) == Result::Success);
|
||||
|
@ -360,10 +360,10 @@ TEST_CASE("Image Draw", "[tvgSwEngine]")
|
|||
REQUIRE(canvas->push(std::move(basicPicture5)) == Result::Success);
|
||||
|
||||
// Rle
|
||||
REQUIRE(basicPicture6->composite(std::move(rleMask), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture6->clip(std::move(rleMask)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture6)) == Result::Success);
|
||||
|
||||
REQUIRE(basicPicture7->composite(std::move(rleMask7), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicPicture7->clip(std::move(rleMask7)) == Result::Success);
|
||||
REQUIRE(basicPicture7->opacity(100) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicPicture7)) == Result::Success);
|
||||
|
||||
|
@ -419,7 +419,7 @@ TEST_CASE("Rect Draw", "[tvgSwEngine]")
|
|||
REQUIRE(basicShape2->composite(std::move(basicMask2), tvg::CompositeMethod::InvAlphaMask) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicShape2)) == Result::Success);
|
||||
|
||||
REQUIRE(basicShape3->composite(std::move(basicMask3), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicShape3->clip(std::move(basicMask3)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicShape3)) == Result::Success);
|
||||
|
||||
REQUIRE(basicShape4->composite(std::move(basicMask4), tvg::CompositeMethod::LumaMask) == Result::Success);
|
||||
|
@ -477,7 +477,7 @@ TEST_CASE("RLE Draw", "[tvgSwEngine]")
|
|||
REQUIRE(basicShape2->composite(std::move(basicMask2), tvg::CompositeMethod::InvAlphaMask) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicShape2)) == Result::Success);
|
||||
|
||||
REQUIRE(basicShape3->composite(std::move(basicMask3), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(basicShape3->clip(std::move(basicMask3)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(basicShape3)) == Result::Success);
|
||||
|
||||
REQUIRE(basicShape4->composite(std::move(basicMask4), tvg::CompositeMethod::LumaMask) == Result::Success);
|
||||
|
@ -769,7 +769,7 @@ TEST_CASE("Filling LumaMask", "[tvgSwEngine]")
|
|||
REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
|
||||
}
|
||||
|
||||
TEST_CASE("Filling ClipPath", "[tvgSwEngine]")
|
||||
TEST_CASE("Filling Clipping", "[tvgSwEngine]")
|
||||
{
|
||||
REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
|
||||
|
||||
|
@ -797,10 +797,10 @@ TEST_CASE("Filling ClipPath", "[tvgSwEngine]")
|
|||
REQUIRE(linearFill->linear(0.0f, 0.0f, 100.0f, 120.0f) == Result::Success);
|
||||
REQUIRE(radialFill->radial(50.0f, 50.0f, 50.0f) == Result::Success);
|
||||
|
||||
//Mask
|
||||
auto mask = tvg::Shape::gen();
|
||||
REQUIRE(mask);
|
||||
REQUIRE(mask->appendCircle(50, 50, 50, 50) == Result::Success);
|
||||
//Clipper
|
||||
auto clipper = tvg::Shape::gen();
|
||||
REQUIRE(clipper);
|
||||
REQUIRE(clipper->appendCircle(50, 50, 50, 50) == Result::Success);
|
||||
|
||||
//Filled Shapes
|
||||
auto shape3 = tvg::Shape::gen();
|
||||
|
@ -818,7 +818,7 @@ TEST_CASE("Filling ClipPath", "[tvgSwEngine]")
|
|||
REQUIRE(scene);
|
||||
REQUIRE(scene->push(std::move(shape3)) == Result::Success);
|
||||
REQUIRE(scene->push(std::move(shape4)) == Result::Success);
|
||||
REQUIRE(scene->composite(std::move(mask), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(scene->clip(std::move(clipper)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(scene)) == Result::Success);
|
||||
|
||||
//Draw
|
||||
|
@ -1162,7 +1162,7 @@ TEST_CASE("RLE Filling InvLumaMask", "[tvgSwEngine]")
|
|||
REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success);
|
||||
}
|
||||
|
||||
TEST_CASE("RLE Filling ClipPath", "[tvgSwEngine]")
|
||||
TEST_CASE("RLE Filling Clipping", "[tvgSwEngine]")
|
||||
{
|
||||
REQUIRE(Initializer::init(CanvasEngine::Sw, 0) == Result::Success);
|
||||
|
||||
|
@ -1191,9 +1191,9 @@ TEST_CASE("RLE Filling ClipPath", "[tvgSwEngine]")
|
|||
REQUIRE(radialFill->radial(50.0f, 50.0f, 50.0f) == Result::Success);
|
||||
|
||||
//Mask
|
||||
auto mask = tvg::Shape::gen();
|
||||
REQUIRE(mask);
|
||||
REQUIRE(mask->appendCircle(50, 50, 50, 50) == Result::Success);
|
||||
auto clipper = tvg::Shape::gen();
|
||||
REQUIRE(clipper);
|
||||
REQUIRE(clipper->appendCircle(50, 50, 50, 50) == Result::Success);
|
||||
|
||||
//Filled Shapes
|
||||
auto shape3 = tvg::Shape::gen();
|
||||
|
@ -1211,7 +1211,7 @@ TEST_CASE("RLE Filling ClipPath", "[tvgSwEngine]")
|
|||
REQUIRE(scene);
|
||||
REQUIRE(scene->push(std::move(shape3)) == Result::Success);
|
||||
REQUIRE(scene->push(std::move(shape4)) == Result::Success);
|
||||
REQUIRE(scene->composite(std::move(mask), tvg::CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(scene->clip(std::move(clipper)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(scene)) == Result::Success);
|
||||
|
||||
//Draw
|
||||
|
@ -1299,7 +1299,7 @@ TEST_CASE("Blending Images", "[tvgSwEngine]")
|
|||
REQUIRE(picture);
|
||||
REQUIRE(picture->load(data, 200, 300, false) == Result::Success);
|
||||
REQUIRE(picture->blend(BlendMethod::Lighten) == Result::Success);
|
||||
REQUIRE(picture->composite(std::move(clipper), CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(picture->clip(std::move(clipper)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(picture)) == Result::Success);
|
||||
|
||||
//scaled images
|
||||
|
@ -1320,7 +1320,7 @@ TEST_CASE("Blending Images", "[tvgSwEngine]")
|
|||
REQUIRE(picture3->load(data, 200, 300, false) == Result::Success);
|
||||
REQUIRE(picture3->scale(2) == Result::Success);
|
||||
REQUIRE(picture3->blend(BlendMethod::Lighten) == Result::Success);
|
||||
REQUIRE(picture3->composite(std::move(clipper2), CompositeMethod::ClipPath) == Result::Success);
|
||||
REQUIRE(picture3->clip(std::move(clipper2)) == Result::Success);
|
||||
REQUIRE(canvas->push(std::move(picture3)) == Result::Success);
|
||||
|
||||
//normal image
|
||||
|
|
Loading…
Add table
Reference in a new issue