6 #include "flutter/display_list/dl_builder.h"
9 #include "fml/mapping.h"
10 #include "gtest/gtest.h"
22 using flutter::DisplayListBuilder;
23 using flutter::DlColor;
24 using flutter::DlImageSampling;
25 using flutter::DlPaint;
32 auto context = GetContext();
33 auto cmd_buffer = context->CreateCommandBuffer();
34 auto blit_pass = cmd_buffer->CreateBlitPass();
38 src_desc.
size = {100, 100};
40 auto src = context->GetResourceAllocator()->CreateTexture(src_desc);
44 dst_format.
size = {100, 100};
46 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
48 EXPECT_FALSE(blit_pass->AddCopy(src, dst));
53 auto context = GetContext();
54 auto cmd_buffer = context->CreateCommandBuffer();
55 auto blit_pass = cmd_buffer->CreateBlitPass();
60 src_desc.
size = {100, 100};
61 auto src = context->GetResourceAllocator()->CreateTexture(src_desc);
65 dst_format.
size = {100, 100};
66 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
68 EXPECT_FALSE(blit_pass->AddCopy(src, dst));
73 auto context = GetContext();
74 auto cmd_buffer = context->CreateCommandBuffer();
75 auto blit_pass = cmd_buffer->CreateBlitPass();
79 src_desc.
size = {100, 100};
81 auto src = context->GetResourceAllocator()->CreateTexture(src_desc);
85 dst_format.
size = {100, 100};
87 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
89 EXPECT_TRUE(blit_pass->AddCopy(src, dst));
94 auto context = GetContext();
95 auto cmd_buffer = context->CreateCommandBuffer();
96 auto blit_pass = cmd_buffer->CreateBlitPass();
101 dst_format.
size = {100, 100};
102 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
105 src_format.
size = 40000;
107 auto src = context->GetResourceAllocator()->CreateBuffer(src_format);
124 auto context = GetContext();
125 auto cmd_buffer = context->CreateCommandBuffer();
126 auto blit_pass = cmd_buffer->CreateBlitPass();
131 dst_format.
size = {1000, 1000};
132 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
137 auto src = context->GetResourceAllocator()->CreateBuffer(src_format);
144 EXPECT_TRUE(blit_pass->EncodeCommands());
145 EXPECT_TRUE(context->GetCommandQueue()->Submit({std::move(cmd_buffer)}).ok());
150 auto context = GetContext();
151 auto cmd_buffer = context->CreateCommandBuffer();
152 auto blit_pass = cmd_buffer->CreateBlitPass();
157 dst_format.
size = {1000, 1000};
158 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
163 auto src = context->GetResourceAllocator()->CreateBuffer(src_format);
177 auto context = GetContext();
178 auto cmd_buffer = context->CreateCommandBuffer();
179 auto blit_pass = cmd_buffer->CreateBlitPass();
184 dst_format.
size = {1000, 1000};
186 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
191 auto src = context->GetResourceAllocator()->CreateBuffer(src_format);
198 EXPECT_TRUE(blit_pass->EncodeCommands());
199 EXPECT_TRUE(context->GetCommandQueue()->Submit({std::move(cmd_buffer)}).ok());
203 auto context = GetContext();
204 auto cmd_buffer = context->CreateCommandBuffer();
205 auto blit_pass = cmd_buffer->CreateBlitPass();
210 dst_format.
size = {10, 10};
212 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
217 src_format.
size = {100, 100};
218 auto src = context->GetResourceAllocator()->CreateTexture(src_format);
228 auto mapping = fml::DataMapping(bytes);
229 auto staging = context->GetResourceAllocator()->CreateBufferWithCopy(mapping);
233 ASSERT_TRUE(staging);
236 EXPECT_TRUE(blit_pass->ResizeTexture(src, dst));
237 EXPECT_TRUE(blit_pass->EncodeCommands());
238 EXPECT_TRUE(context->GetCommandQueue()->Submit({std::move(cmd_buffer)}).ok());
242 auto context = GetContext();
243 auto cmd_buffer = context->CreateCommandBuffer();
244 auto blit_pass = cmd_buffer->CreateBlitPass();
246 std::shared_ptr<Texture> src = CreateTextureForFixture(
"kalimba.jpg");
251 dst_format.
size = {src->GetSize().
width / 2, src->GetSize().height};
253 auto dst = context->GetResourceAllocator()->CreateTexture(dst_format);
258 EXPECT_TRUE(blit_pass->ResizeTexture(src, dst));
259 EXPECT_TRUE(blit_pass->EncodeCommands());
260 EXPECT_TRUE(context->GetCommandQueue()->Submit({std::move(cmd_buffer)}).ok());
262 DisplayListBuilder builder;
263 builder.Scale(GetContentScale().
x, GetContentScale().y);
265 paint.setColor(DlColor::kRed());
268 DlImageSampling::kNearestNeighbor, &paint);
269 ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
TEST_P(AiksTest, DrawAtlasNoColor)
INSTANTIATE_PLAYGROUND_SUITE(AiksTest)
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
constexpr size_t GetByteSizeOfBaseMipLevel() const