forked from firka/flutter
[Impeller] Move drawAtlas golden tests to display list. (flutter/engine#53398)
Part of https://github.com/flutter/flutter/issues/142054 Moves all of the drawAtlas tests for aiks and entities into DL. This might change some of the entity goldens but ... these are easy to eyeball so it should be fine IMO.
This commit is contained in:
@@ -140,6 +140,7 @@
|
||||
../../../flutter/impeller/compiler/shader_bundle_unittests.cc
|
||||
../../../flutter/impeller/compiler/switches_unittests.cc
|
||||
../../../flutter/impeller/core/allocator_unittests.cc
|
||||
../../../flutter/impeller/display_list/aiks_dl_atlas_unittests.cc
|
||||
../../../flutter/impeller/display_list/aiks_dl_clip_unittests.cc
|
||||
../../../flutter/impeller/display_list/aiks_dl_gradient_unittests.cc
|
||||
../../../flutter/impeller/display_list/aiks_dl_opacity_unittests.cc
|
||||
|
||||
@@ -2232,70 +2232,6 @@ TEST_P(AiksTest, CanDrawPoints) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/127374.
|
||||
TEST_P(AiksTest, DrawAtlasWithColorAdvancedAndTransform) {
|
||||
// Draws the image as four squares stiched together.
|
||||
auto atlas = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto size = atlas->GetSize();
|
||||
auto image = std::make_shared<Image>(atlas);
|
||||
// Divide image into four quadrants.
|
||||
Scalar half_width = size.width / 2;
|
||||
Scalar half_height = size.height / 2;
|
||||
std::vector<Rect> texture_coordinates = {
|
||||
Rect::MakeLTRB(0, 0, half_width, half_height),
|
||||
Rect::MakeLTRB(half_width, 0, size.width, half_height),
|
||||
Rect::MakeLTRB(0, half_height, half_width, size.height),
|
||||
Rect::MakeLTRB(half_width, half_height, size.width, size.height)};
|
||||
// Position quadrants adjacent to eachother.
|
||||
std::vector<Matrix> transforms = {
|
||||
Matrix::MakeTranslation({0, 0, 0}),
|
||||
Matrix::MakeTranslation({half_width, 0, 0}),
|
||||
Matrix::MakeTranslation({0, half_height, 0}),
|
||||
Matrix::MakeTranslation({half_width, half_height, 0})};
|
||||
std::vector<Color> colors = {Color::Red(), Color::Green(), Color::Blue(),
|
||||
Color::Yellow()};
|
||||
|
||||
Paint paint;
|
||||
|
||||
Canvas canvas;
|
||||
canvas.Scale({0.25, 0.25, 1.0});
|
||||
canvas.DrawAtlas(image, transforms, texture_coordinates, colors,
|
||||
BlendMode::kModulate, {}, std::nullopt, paint);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/127374.
|
||||
TEST_P(AiksTest, DrawAtlasAdvancedAndTransform) {
|
||||
// Draws the image as four squares stiched together.
|
||||
auto atlas = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto size = atlas->GetSize();
|
||||
auto image = std::make_shared<Image>(atlas);
|
||||
// Divide image into four quadrants.
|
||||
Scalar half_width = size.width / 2;
|
||||
Scalar half_height = size.height / 2;
|
||||
std::vector<Rect> texture_coordinates = {
|
||||
Rect::MakeLTRB(0, 0, half_width, half_height),
|
||||
Rect::MakeLTRB(half_width, 0, size.width, half_height),
|
||||
Rect::MakeLTRB(0, half_height, half_width, size.height),
|
||||
Rect::MakeLTRB(half_width, half_height, size.width, size.height)};
|
||||
// Position quadrants adjacent to eachother.
|
||||
std::vector<Matrix> transforms = {
|
||||
Matrix::MakeTranslation({0, 0, 0}),
|
||||
Matrix::MakeTranslation({half_width, 0, 0}),
|
||||
Matrix::MakeTranslation({0, half_height, 0}),
|
||||
Matrix::MakeTranslation({half_width, half_height, 0})};
|
||||
|
||||
Paint paint;
|
||||
|
||||
Canvas canvas;
|
||||
canvas.Scale({0.25, 0.25, 1.0});
|
||||
canvas.DrawAtlas(image, transforms, texture_coordinates, {},
|
||||
BlendMode::kModulate, {}, std::nullopt, paint);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, CanDrawPointsWithTextureMap) {
|
||||
auto texture = CreateTextureForFixture("table_mountain_nx.png",
|
||||
/*enable_mipmapping=*/true);
|
||||
@@ -2970,38 +2906,6 @@ TEST_P(AiksTest, MipmapGenerationWorksCorrectly) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DrawAtlasPlusWideGamut) {
|
||||
EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
|
||||
PixelFormat::kB10G10R10A10XR);
|
||||
|
||||
// Draws the image as four squares stiched together.
|
||||
auto atlas =
|
||||
std::make_shared<Image>(CreateTextureForFixture("bay_bridge.jpg"));
|
||||
auto size = atlas->GetSize();
|
||||
// Divide image into four quadrants.
|
||||
Scalar half_width = size.width / 2;
|
||||
Scalar half_height = size.height / 2;
|
||||
std::vector<Rect> texture_coordinates = {
|
||||
Rect::MakeLTRB(0, 0, half_width, half_height),
|
||||
Rect::MakeLTRB(half_width, 0, size.width, half_height),
|
||||
Rect::MakeLTRB(0, half_height, half_width, size.height),
|
||||
Rect::MakeLTRB(half_width, half_height, size.width, size.height)};
|
||||
// Position quadrants adjacent to eachother.
|
||||
std::vector<Matrix> transforms = {
|
||||
Matrix::MakeTranslation({0, 0, 0}),
|
||||
Matrix::MakeTranslation({half_width, 0, 0}),
|
||||
Matrix::MakeTranslation({0, half_height, 0}),
|
||||
Matrix::MakeTranslation({half_width, half_height, 0})};
|
||||
std::vector<Color> colors = {Color::Red(), Color::Green(), Color::Blue(),
|
||||
Color::Yellow()};
|
||||
|
||||
Canvas canvas;
|
||||
canvas.DrawAtlas(atlas, transforms, texture_coordinates, colors,
|
||||
BlendMode::kPlus, {}, std::nullopt, {});
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
}
|
||||
|
||||
// https://github.com/flutter/flutter/issues/146648
|
||||
TEST_P(AiksTest, StrokedPathWithMoveToThenCloseDrawnCorrectly) {
|
||||
Path path = PathBuilder{}
|
||||
|
||||
@@ -52,6 +52,7 @@ impeller_component("display_list") {
|
||||
template("display_list_unittests_component") {
|
||||
target_name = invoker.target_name
|
||||
predefined_sources = [
|
||||
"aiks_dl_atlas_unittests.cc",
|
||||
"aiks_dl_clip_unittests.cc",
|
||||
"aiks_dl_gradient_unittests.cc",
|
||||
"aiks_dl_opacity_unittests.cc",
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "display_list/dl_sampling_options.h"
|
||||
#include "flutter/impeller/aiks/aiks_unittests.h"
|
||||
|
||||
#include "flutter/display_list/dl_blend_mode.h"
|
||||
#include "flutter/display_list/dl_builder.h"
|
||||
#include "flutter/display_list/dl_color.h"
|
||||
#include "flutter/display_list/dl_paint.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "impeller/display_list/dl_image_impeller.h"
|
||||
#include "impeller/geometry/scalar.h"
|
||||
#include "include/core/SkRSXform.h"
|
||||
#include "include/core/SkRefCnt.h"
|
||||
|
||||
namespace impeller {
|
||||
namespace testing {
|
||||
|
||||
using namespace flutter;
|
||||
|
||||
namespace {
|
||||
SkRSXform MakeTranslation(Scalar tx, Scalar ty) {
|
||||
return SkRSXform::Make(1, 0, tx, ty);
|
||||
}
|
||||
|
||||
std::tuple<std::vector<SkRect>, std::vector<SkRSXform>, sk_sp<DlImageImpeller>>
|
||||
CreateTestData(const AiksTest* test) {
|
||||
// Draws the image as four squares stiched together.
|
||||
auto atlas =
|
||||
DlImageImpeller::Make(test->CreateTextureForFixture("bay_bridge.jpg"));
|
||||
auto size = atlas->impeller_texture()->GetSize();
|
||||
// Divide image into four quadrants.
|
||||
Scalar half_width = size.width / 2;
|
||||
Scalar half_height = size.height / 2;
|
||||
std::vector<SkRect> texture_coordinates = {
|
||||
SkRect::MakeLTRB(0, 0, half_width, half_height),
|
||||
SkRect::MakeLTRB(half_width, 0, size.width, half_height),
|
||||
SkRect::MakeLTRB(0, half_height, half_width, size.height),
|
||||
SkRect::MakeLTRB(half_width, half_height, size.width, size.height)};
|
||||
// Position quadrants adjacent to eachother.
|
||||
std::vector<SkRSXform> transforms = {
|
||||
MakeTranslation(0, 0), MakeTranslation(half_width, 0),
|
||||
MakeTranslation(0, half_height),
|
||||
MakeTranslation(half_width, half_height)};
|
||||
return std::make_tuple(texture_coordinates, transforms, atlas);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_P(AiksTest, DrawAtlasNoColor) {
|
||||
DisplayListBuilder builder;
|
||||
auto [texture_coordinates, transforms, atlas] = CreateTestData(this);
|
||||
|
||||
builder.Scale(GetContentScale().x, GetContentScale().y);
|
||||
builder.DrawAtlas(atlas, transforms.data(), texture_coordinates.data(),
|
||||
/*colors=*/nullptr, /*count=*/4, DlBlendMode::kSrcOver,
|
||||
DlImageSampling::kNearestNeighbor, nullptr);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DrawAtlasWithColorAdvanced) {
|
||||
DisplayListBuilder builder;
|
||||
auto [texture_coordinates, transforms, atlas] = CreateTestData(this);
|
||||
|
||||
std::vector<DlColor> colors = {DlColor::kRed(), DlColor::kGreen(),
|
||||
DlColor::kBlue(), DlColor::kYellow()};
|
||||
|
||||
builder.Scale(GetContentScale().x, GetContentScale().y);
|
||||
builder.DrawAtlas(atlas, transforms.data(), texture_coordinates.data(),
|
||||
colors.data(), /*count=*/4, DlBlendMode::kModulate,
|
||||
DlImageSampling::kNearestNeighbor, /*cullRect=*/nullptr);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DrawAtlasWithColorSimple) {
|
||||
DisplayListBuilder builder;
|
||||
// Draws the image as four squares stiched together.
|
||||
auto [texture_coordinates, transforms, atlas] = CreateTestData(this);
|
||||
|
||||
std::vector<DlColor> colors = {DlColor::kRed(), DlColor::kGreen(),
|
||||
DlColor::kBlue(), DlColor::kYellow()};
|
||||
|
||||
builder.Scale(GetContentScale().x, GetContentScale().y);
|
||||
builder.DrawAtlas(atlas, transforms.data(), texture_coordinates.data(),
|
||||
colors.data(), /*count=*/4, DlBlendMode::kSrcATop,
|
||||
DlImageSampling::kNearestNeighbor, /*cullRect=*/nullptr);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DrawAtlasWithOpacity) {
|
||||
DisplayListBuilder builder;
|
||||
// Draws the image as four squares stiched together slightly
|
||||
// opaque
|
||||
auto [texture_coordinates, transforms, atlas] = CreateTestData(this);
|
||||
|
||||
DlPaint paint;
|
||||
paint.setAlpha(128);
|
||||
builder.Scale(GetContentScale().x, GetContentScale().y);
|
||||
builder.DrawAtlas(atlas, transforms.data(), texture_coordinates.data(),
|
||||
/*colors=*/nullptr, 4, DlBlendMode::kSrcOver,
|
||||
DlImageSampling::kNearestNeighbor, /*cullRect=*/nullptr,
|
||||
&paint);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DrawAtlasNoColorFullSize) {
|
||||
auto atlas = DlImageImpeller::Make(CreateTextureForFixture("bay_bridge.jpg"));
|
||||
auto size = atlas->impeller_texture()->GetSize();
|
||||
std::vector<SkRect> texture_coordinates = {
|
||||
SkRect::MakeLTRB(0, 0, size.width, size.height)};
|
||||
std::vector<SkRSXform> transforms = {MakeTranslation(0, 0)};
|
||||
|
||||
DisplayListBuilder builder;
|
||||
builder.Scale(GetContentScale().x, GetContentScale().y);
|
||||
builder.DrawAtlas(atlas, transforms.data(), texture_coordinates.data(),
|
||||
/*colors=*/nullptr, /*count=*/1, DlBlendMode::kSrcOver,
|
||||
DlImageSampling::kNearestNeighbor, /*cullRect=*/nullptr);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/127374.
|
||||
TEST_P(AiksTest, DrawAtlasAdvancedAndTransform) {
|
||||
DisplayListBuilder builder;
|
||||
// Draws the image as four squares stiched together.
|
||||
auto [texture_coordinates, transforms, atlas] = CreateTestData(this);
|
||||
|
||||
builder.Scale(0.25, 0.25);
|
||||
builder.DrawAtlas(atlas, transforms.data(), texture_coordinates.data(),
|
||||
/*colors=*/nullptr, /*count=*/4, DlBlendMode::kModulate,
|
||||
DlImageSampling::kNearestNeighbor, /*cullRect=*/nullptr);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/127374.
|
||||
TEST_P(AiksTest, DrawAtlasWithColorAdvancedAndTransform) {
|
||||
DisplayListBuilder builder;
|
||||
// Draws the image as four squares stiched together.
|
||||
auto [texture_coordinates, transforms, atlas] = CreateTestData(this);
|
||||
std::vector<DlColor> colors = {DlColor::kRed(), DlColor::kGreen(),
|
||||
DlColor::kBlue(), DlColor::kYellow()};
|
||||
|
||||
builder.Scale(0.25, 0.25);
|
||||
builder.DrawAtlas(atlas, transforms.data(), texture_coordinates.data(),
|
||||
colors.data(), /*count=*/4, DlBlendMode::kModulate,
|
||||
DlImageSampling::kNearestNeighbor, /*cullRect=*/nullptr);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, DrawAtlasPlusWideGamut) {
|
||||
DisplayListBuilder builder;
|
||||
EXPECT_EQ(GetContext()->GetCapabilities()->GetDefaultColorFormat(),
|
||||
PixelFormat::kB10G10R10A10XR);
|
||||
|
||||
// Draws the image as four squares stiched together.
|
||||
auto [texture_coordinates, transforms, atlas] = CreateTestData(this);
|
||||
std::vector<DlColor> colors = {DlColor::kRed(), DlColor::kGreen(),
|
||||
DlColor::kBlue(), DlColor::kYellow()};
|
||||
|
||||
builder.DrawAtlas(atlas, transforms.data(), texture_coordinates.data(),
|
||||
colors.data(), /*count=*/4, DlBlendMode::kPlus,
|
||||
DlImageSampling::kNearestNeighbor, /*cullRect=*/nullptr);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
@@ -1418,202 +1418,6 @@ TEST_P(EntityTest, BorderMaskBlurCoverageIsCorrect) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasNoColor) {
|
||||
// Draws the image as four squares stiched together.
|
||||
auto atlas = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto size = atlas->GetSize();
|
||||
// Divide image into four quadrants.
|
||||
Scalar half_width = size.width / 2;
|
||||
Scalar half_height = size.height / 2;
|
||||
std::vector<Rect> texture_coordinates = {
|
||||
Rect::MakeLTRB(0, 0, half_width, half_height),
|
||||
Rect::MakeLTRB(half_width, 0, size.width, half_height),
|
||||
Rect::MakeLTRB(0, half_height, half_width, size.height),
|
||||
Rect::MakeLTRB(half_width, half_height, size.width, size.height)};
|
||||
// Position quadrants adjacent to eachother.
|
||||
std::vector<Matrix> transforms = {
|
||||
Matrix::MakeTranslation({0, 0, 0}),
|
||||
Matrix::MakeTranslation({half_width, 0, 0}),
|
||||
Matrix::MakeTranslation({0, half_height, 0}),
|
||||
Matrix::MakeTranslation({half_width, half_height, 0})};
|
||||
std::shared_ptr<AtlasContents> contents = std::make_shared<AtlasContents>();
|
||||
|
||||
contents->SetTransforms(std::move(transforms));
|
||||
contents->SetTextureCoordinates(std::move(texture_coordinates));
|
||||
contents->SetTexture(atlas);
|
||||
contents->SetBlendMode(BlendMode::kSource);
|
||||
|
||||
Entity e;
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasWithColorAdvanced) {
|
||||
// Draws the image as four squares stiched together.
|
||||
auto atlas = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto size = atlas->GetSize();
|
||||
// Divide image into four quadrants.
|
||||
Scalar half_width = size.width / 2;
|
||||
Scalar half_height = size.height / 2;
|
||||
std::vector<Rect> texture_coordinates = {
|
||||
Rect::MakeLTRB(0, 0, half_width, half_height),
|
||||
Rect::MakeLTRB(half_width, 0, size.width, half_height),
|
||||
Rect::MakeLTRB(0, half_height, half_width, size.height),
|
||||
Rect::MakeLTRB(half_width, half_height, size.width, size.height)};
|
||||
// Position quadrants adjacent to eachother.
|
||||
std::vector<Matrix> transforms = {
|
||||
Matrix::MakeTranslation({0, 0, 0}),
|
||||
Matrix::MakeTranslation({half_width, 0, 0}),
|
||||
Matrix::MakeTranslation({0, half_height, 0}),
|
||||
Matrix::MakeTranslation({half_width, half_height, 0})};
|
||||
std::vector<Color> colors = {Color::Red(), Color::Green(), Color::Blue(),
|
||||
Color::Yellow()};
|
||||
std::shared_ptr<AtlasContents> contents = std::make_shared<AtlasContents>();
|
||||
|
||||
contents->SetTransforms(std::move(transforms));
|
||||
contents->SetTextureCoordinates(std::move(texture_coordinates));
|
||||
contents->SetTexture(atlas);
|
||||
contents->SetColors(colors);
|
||||
contents->SetBlendMode(BlendMode::kModulate);
|
||||
|
||||
Entity e;
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasWithColorSimple) {
|
||||
// Draws the image as four squares stiched together. Because blend modes
|
||||
// aren't implented this ends up as four solid color blocks.
|
||||
auto atlas = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto size = atlas->GetSize();
|
||||
// Divide image into four quadrants.
|
||||
Scalar half_width = size.width / 2;
|
||||
Scalar half_height = size.height / 2;
|
||||
std::vector<Rect> texture_coordinates = {
|
||||
Rect::MakeLTRB(0, 0, half_width, half_height),
|
||||
Rect::MakeLTRB(half_width, 0, size.width, half_height),
|
||||
Rect::MakeLTRB(0, half_height, half_width, size.height),
|
||||
Rect::MakeLTRB(half_width, half_height, size.width, size.height)};
|
||||
// Position quadrants adjacent to eachother.
|
||||
std::vector<Matrix> transforms = {
|
||||
Matrix::MakeTranslation({0, 0, 0}),
|
||||
Matrix::MakeTranslation({half_width, 0, 0}),
|
||||
Matrix::MakeTranslation({0, half_height, 0}),
|
||||
Matrix::MakeTranslation({half_width, half_height, 0})};
|
||||
std::vector<Color> colors = {Color::Red(), Color::Green(), Color::Blue(),
|
||||
Color::Yellow()};
|
||||
std::shared_ptr<AtlasContents> contents = std::make_shared<AtlasContents>();
|
||||
|
||||
contents->SetTransforms(std::move(transforms));
|
||||
contents->SetTextureCoordinates(std::move(texture_coordinates));
|
||||
contents->SetTexture(atlas);
|
||||
contents->SetColors(colors);
|
||||
contents->SetBlendMode(BlendMode::kSourceATop);
|
||||
|
||||
Entity e;
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasUsesProvidedCullRectForCoverage) {
|
||||
auto atlas = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto size = atlas->GetSize();
|
||||
|
||||
Scalar half_width = size.width / 2;
|
||||
Scalar half_height = size.height / 2;
|
||||
std::vector<Rect> texture_coordinates = {
|
||||
Rect::MakeLTRB(0, 0, half_width, half_height),
|
||||
Rect::MakeLTRB(half_width, 0, size.width, half_height),
|
||||
Rect::MakeLTRB(0, half_height, half_width, size.height),
|
||||
Rect::MakeLTRB(half_width, half_height, size.width, size.height)};
|
||||
std::vector<Matrix> transforms = {
|
||||
Matrix::MakeTranslation({0, 0, 0}),
|
||||
Matrix::MakeTranslation({half_width, 0, 0}),
|
||||
Matrix::MakeTranslation({0, half_height, 0}),
|
||||
Matrix::MakeTranslation({half_width, half_height, 0})};
|
||||
|
||||
std::shared_ptr<AtlasContents> contents = std::make_shared<AtlasContents>();
|
||||
|
||||
contents->SetTransforms(std::move(transforms));
|
||||
contents->SetTextureCoordinates(std::move(texture_coordinates));
|
||||
contents->SetTexture(atlas);
|
||||
contents->SetBlendMode(BlendMode::kSource);
|
||||
|
||||
auto transform = Matrix::MakeScale(GetContentScale());
|
||||
Entity e;
|
||||
e.SetTransform(transform);
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_EQ(contents->GetCoverage(e).value(),
|
||||
Rect::MakeSize(size).TransformBounds(transform));
|
||||
|
||||
contents->SetCullRect(Rect::MakeLTRB(0, 0, 10, 10));
|
||||
|
||||
ASSERT_EQ(contents->GetCoverage(e).value(),
|
||||
Rect::MakeLTRB(0, 0, 10, 10).TransformBounds(transform));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasWithOpacity) {
|
||||
// Draws the image as four squares stiched together slightly
|
||||
// opaque
|
||||
auto atlas = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto size = atlas->GetSize();
|
||||
// Divide image into four quadrants.
|
||||
Scalar half_width = size.width / 2;
|
||||
Scalar half_height = size.height / 2;
|
||||
std::vector<Rect> texture_coordinates = {
|
||||
Rect::MakeLTRB(0, 0, half_width, half_height),
|
||||
Rect::MakeLTRB(half_width, 0, size.width, half_height),
|
||||
Rect::MakeLTRB(0, half_height, half_width, size.height),
|
||||
Rect::MakeLTRB(half_width, half_height, size.width, size.height)};
|
||||
// Position quadrants adjacent to eachother.
|
||||
std::vector<Matrix> transforms = {
|
||||
Matrix::MakeTranslation({0, 0, 0}),
|
||||
Matrix::MakeTranslation({half_width, 0, 0}),
|
||||
Matrix::MakeTranslation({0, half_height, 0}),
|
||||
Matrix::MakeTranslation({half_width, half_height, 0})};
|
||||
|
||||
std::shared_ptr<AtlasContents> contents = std::make_shared<AtlasContents>();
|
||||
|
||||
contents->SetTransforms(std::move(transforms));
|
||||
contents->SetTextureCoordinates(std::move(texture_coordinates));
|
||||
contents->SetTexture(atlas);
|
||||
contents->SetBlendMode(BlendMode::kSource);
|
||||
contents->SetAlpha(0.5);
|
||||
|
||||
Entity e;
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, DrawAtlasNoColorFullSize) {
|
||||
auto atlas = CreateTextureForFixture("bay_bridge.jpg");
|
||||
auto size = atlas->GetSize();
|
||||
std::vector<Rect> texture_coordinates = {
|
||||
Rect::MakeLTRB(0, 0, size.width, size.height)};
|
||||
std::vector<Matrix> transforms = {Matrix::MakeTranslation({0, 0, 0})};
|
||||
std::shared_ptr<AtlasContents> contents = std::make_shared<AtlasContents>();
|
||||
|
||||
contents->SetTransforms(std::move(transforms));
|
||||
contents->SetTextureCoordinates(std::move(texture_coordinates));
|
||||
contents->SetTexture(atlas);
|
||||
contents->SetBlendMode(BlendMode::kSource);
|
||||
|
||||
Entity e;
|
||||
e.SetTransform(Matrix::MakeScale(GetContentScale()));
|
||||
e.SetContents(contents);
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(std::move(e)));
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, SolidFillCoverageIsCorrect) {
|
||||
// No transform
|
||||
{
|
||||
|
||||
@@ -523,10 +523,25 @@ impeller_Play_AiksTest_DrawAdvancedBlendPartlyOffscreen_Vulkan.png
|
||||
impeller_Play_AiksTest_DrawAtlasAdvancedAndTransform_Metal.png
|
||||
impeller_Play_AiksTest_DrawAtlasAdvancedAndTransform_OpenGLES.png
|
||||
impeller_Play_AiksTest_DrawAtlasAdvancedAndTransform_Vulkan.png
|
||||
impeller_Play_AiksTest_DrawAtlasNoColorFullSize_Metal.png
|
||||
impeller_Play_AiksTest_DrawAtlasNoColorFullSize_OpenGLES.png
|
||||
impeller_Play_AiksTest_DrawAtlasNoColorFullSize_Vulkan.png
|
||||
impeller_Play_AiksTest_DrawAtlasNoColor_Metal.png
|
||||
impeller_Play_AiksTest_DrawAtlasNoColor_OpenGLES.png
|
||||
impeller_Play_AiksTest_DrawAtlasNoColor_Vulkan.png
|
||||
impeller_Play_AiksTest_DrawAtlasPlusWideGamut_Metal.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithColorAdvancedAndTransform_Metal.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithColorAdvancedAndTransform_OpenGLES.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithColorAdvancedAndTransform_Vulkan.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithColorAdvanced_Metal.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithColorAdvanced_OpenGLES.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithColorAdvanced_Vulkan.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithColorSimple_Metal.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithColorSimple_OpenGLES.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithColorSimple_Vulkan.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithOpacity_Metal.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithOpacity_OpenGLES.png
|
||||
impeller_Play_AiksTest_DrawAtlasWithOpacity_Vulkan.png
|
||||
impeller_Play_AiksTest_DrawLinesRenderCorrectly_Metal.png
|
||||
impeller_Play_AiksTest_DrawLinesRenderCorrectly_OpenGLES.png
|
||||
impeller_Play_AiksTest_DrawLinesRenderCorrectly_Vulkan.png
|
||||
|
||||
Reference in New Issue
Block a user