Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added at golden test
  • Loading branch information
gaaclarke committed Nov 15, 2024
commit 2bf0e96235e96aac1b55cc8b0c84b5d704abba1e
2 changes: 2 additions & 0 deletions impeller/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ impeller_component("renderer_unittests") {
"../fixtures",
"../playground:playground_test",
"../tessellator:tessellator_libtess",
"//flutter/impeller/display_list:aiks_unittests",
"//flutter/impeller/display_list:display_list",
"//flutter/testing:testing_lib",
]

Expand Down
41 changes: 40 additions & 1 deletion impeller/renderer/blit_pass_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// found in the LICENSE file.

#include <cstdint>
#include "flutter/display_list/dl_builder.h"
#include "flutter/impeller/display_list/aiks_unittests.h"
#include "flutter/impeller/display_list/dl_image_impeller.h"
#include "fml/mapping.h"
#include "gtest/gtest.h"
#include "impeller/base/validation.h"
Expand All @@ -16,7 +19,12 @@
namespace impeller {
namespace testing {

using BlitPassTest = PlaygroundTest;
using flutter::DisplayListBuilder;
using flutter::DlColor;
using flutter::DlImageSampling;
using flutter::DlPaint;

using BlitPassTest = AiksPlayground;
INSTANTIATE_PLAYGROUND_SUITE(BlitPassTest);

TEST_P(BlitPassTest, BlitAcrossDifferentPixelFormatsFails) {
Expand Down Expand Up @@ -230,5 +238,36 @@ TEST_P(BlitPassTest, CanResizeTextures) {
EXPECT_TRUE(context->GetCommandQueue()->Submit({std::move(cmd_buffer)}).ok());
}

TEST_P(BlitPassTest, CanResizeTexturesPlayground) {
auto context = GetContext();
auto cmd_buffer = context->CreateCommandBuffer();
auto blit_pass = cmd_buffer->CreateBlitPass();

std::shared_ptr<Texture> src = CreateTextureForFixture("kalimba.jpg");

TextureDescriptor dst_format;
dst_format.storage_mode = StorageMode::kDevicePrivate;
dst_format.format = PixelFormat::kR8G8B8A8UNormInt;
dst_format.size = {src->GetSize().width / 2, src->GetSize().height};
dst_format.usage = TextureUsage::kShaderRead | TextureUsage::kShaderWrite;
auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);

ASSERT_TRUE(dst);
ASSERT_TRUE(src);

EXPECT_TRUE(blit_pass->ResizeTexture(src, dst));
EXPECT_TRUE(blit_pass->EncodeCommands(GetContext()->GetResourceAllocator()));
EXPECT_TRUE(context->GetCommandQueue()->Submit({std::move(cmd_buffer)}).ok());

DisplayListBuilder builder;
builder.Scale(GetContentScale().x, GetContentScale().y);
DlPaint paint;
paint.setColor(DlColor::kRed());
auto image = DlImageImpeller::Make(dst);
builder.DrawImage(image, SkPoint::Make(100.0, 100.0),
DlImageSampling::kNearestNeighbor, &paint);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

} // namespace testing
} // namespace impeller