 |
Flutter Impeller
|
|
|
| | INSTANTIATE_OPENGLES_PLAYGROUND_SUITE (InteropPlaygroundTest) |
| |
| | TEST_P (InteropPlaygroundTest, CanCreateContext) |
| |
| | TEST_P (InteropPlaygroundTest, CanCreateDisplayListBuilder) |
| |
| | TEST_P (InteropPlaygroundTest, CanCreateSurface) |
| |
| | TEST_P (InteropPlaygroundTest, CanDrawRect) |
| |
| | TEST_P (InteropPlaygroundTest, CanDrawImage) |
| |
| | TEST_P (InteropPlaygroundTest, CanCreateOpenGLImage) |
| |
| | TEST_P (InteropPlaygroundTest, CanCreateParagraphs) |
| |
| | IMPELLER_DEFINE_HANDLE (FlagHandle) |
| |
| | IMPELLER_DEFINE_HANDLE (TestHandle) |
| |
| | TEST (InteropObjectTest, CanCreateScoped) |
| |
| | TEST (InteropObjectTest, CanCreate) |
| |
| | TEST (InteropObjectTest, CanCopyAssignMove) |
| |
◆ InteropPlaygroundTest
◆ IMPELLER_DEFINE_HANDLE() [1/2]
| impeller::interop::testing::IMPELLER_DEFINE_HANDLE |
( |
FlagHandle |
| ) |
|
◆ IMPELLER_DEFINE_HANDLE() [2/2]
| impeller::interop::testing::IMPELLER_DEFINE_HANDLE |
( |
TestHandle |
| ) |
|
◆ INSTANTIATE_OPENGLES_PLAYGROUND_SUITE()
◆ TEST() [1/3]
| impeller::interop::testing::TEST |
( |
InteropObjectTest |
, |
|
|
CanCopyAssignMove |
|
|
) |
| |
Definition at line 75 of file object_unittests.cc.
76 auto o = Create<TestObject>(1, 2.3,
'd');
77 ASSERT_EQ(o->GetRefCountForTests(), 1u);
80 ASSERT_EQ(o->GetRefCountForTests(), 2u);
82 ASSERT_EQ(o->GetRefCountForTests(), 3u);
84 ASSERT_EQ(o->GetRefCountForTests(), 4u);
86 ASSERT_EQ(o->GetRefCountForTests(), 1u);
90 ASSERT_EQ(o->GetRefCountForTests(), 2u);
91 ASSERT_EQ(o1->GetRefCountForTests(), 2u);
94 auto move_o = std::move(o);
95 ASSERT_EQ(move_o->GetRefCountForTests(), 1u);
◆ TEST() [2/3]
| impeller::interop::testing::TEST |
( |
InteropObjectTest |
, |
|
|
CanCreate |
|
|
) |
| |
Definition at line 68 of file object_unittests.cc.
69 auto object = Create<TestObject>(1, 1.3,
'c');
70 ASSERT_EQ(object->GetArg1(), 1);
71 ASSERT_EQ(object->GetArg2(), 1.3);
72 ASSERT_EQ(object->GetArg3(),
'c');
◆ TEST() [3/3]
| impeller::interop::testing::TEST |
( |
InteropObjectTest |
, |
|
|
CanCreateScoped |
|
|
) |
| |
◆ TEST_P() [1/7]
◆ TEST_P() [2/7]
◆ TEST_P() [3/7]
Definition at line 116 of file impeller_unittests.cc.
117 auto context = GetInteropContext();
119 auto impeller_context = context->GetContext();
121 if (impeller_context->GetBackendType() !=
123 GTEST_SKIP() <<
"This test works with OpenGL handles is only suitable for "
128 const auto& gl_context = ContextGLES::Cast(*impeller_context);
129 const auto& gl = gl_context.GetReactor()->GetProcTable();
131 constexpr
ISize external_texture_size = {200, 300};
133 Allocation texture_data;
135 texture_data.Truncate(
Bytes{external_texture_size.Area() * 4u},
false));
137 const auto kClearColor = Color::Fuchsia().ToR8G8B8A8();
139 for (
size_t i = 0; i < external_texture_size.Area() * 4u; i += 4u) {
140 memcpy(texture_data.GetBuffer() + i, kClearColor.data(), 4);
143 GLuint external_texture = GL_NONE;
144 gl.GenTextures(1u, &external_texture);
145 ASSERT_NE(external_texture, 0u);
146 gl.BindTexture(GL_TEXTURE_2D, external_texture);
147 gl.TexImage2D(GL_TEXTURE_2D,
150 external_texture_size.width,
151 external_texture_size.height,
155 texture_data.GetBuffer()
160 desc.
size = {external_texture_size.
width, external_texture_size.height};
167 ASSERT_TRUE(texture);
177 auto dl = Adopt<DisplayList>(
180 OpenPlaygroundHere([&](
const auto& context,
const auto& surface) ->
bool {
References impeller::BackendCast< ContextGLES, Context >::Cast(), impeller::Color::Fuchsia(), impeller::Allocation::GetBuffer(), impeller::interop::ImpellerDisplayListBuilderCreateDisplayListNew(), impeller::interop::ImpellerDisplayListBuilderDrawTexture(), impeller::interop::ImpellerDisplayListBuilderNew(), impeller::interop::ImpellerSurfaceDrawDisplayList(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), impeller::interop::ImpellerTextureGetOpenGLHandle(), kImpellerPixelFormatRGBA8888, kImpellerTextureSamplingLinear, impeller::Context::kOpenGLES, ImpellerTextureDescriptor::mip_count, ImpellerTextureDescriptor::pixel_format, ImpellerTextureDescriptor::size, impeller::Color::ToR8G8B8A8(), impeller::Allocation::Truncate(), and ImpellerISize::width.
◆ TEST_P() [4/7]
Definition at line 186 of file impeller_unittests.cc.
189 ASSERT_TRUE(type_context);
194 ASSERT_TRUE(builder);
220 std::string text =
"the ⚡️ quick ⚡️ brown 🦊 fox jumps over the lazy dog 🐶.";
224 reinterpret_cast<const uint8_t*
>(text.data()),
228 auto paragraph = Adopt<Paragraph>(
230 ASSERT_TRUE(paragraph);
238 auto dl = Adopt<DisplayList>(
242 OpenPlaygroundHere([&](
const auto& context,
const auto& surface) ->
bool {
References color, impeller::interop::ImpellerDisplayListBuilderCreateDisplayListNew(), impeller::interop::ImpellerDisplayListBuilderDrawParagraph(), impeller::interop::ImpellerDisplayListBuilderNew(), impeller::interop::ImpellerPaintNew(), impeller::interop::ImpellerPaintSetColor(), impeller::interop::ImpellerParagraphBuilderAddText(), impeller::interop::ImpellerParagraphBuilderBuildParagraphNew(), impeller::interop::ImpellerParagraphBuilderNew(), impeller::interop::ImpellerParagraphBuilderPushStyle(), impeller::interop::ImpellerParagraphStyleNew(), impeller::interop::ImpellerParagraphStyleSetBackground(), impeller::interop::ImpellerParagraphStyleSetFontSize(), impeller::interop::ImpellerParagraphStyleSetForeground(), impeller::interop::ImpellerSurfaceDrawDisplayList(), and impeller::interop::ImpellerTypographyContextNew().
◆ TEST_P() [5/7]
◆ TEST_P() [6/7]
Definition at line 83 of file impeller_unittests.cc.
84 auto compressed = LoadFixtureImageCompressed(
85 flutter::testing::OpenFixtureAsMapping(
"boston.jpg"));
86 ASSERT_NE(compressed,
nullptr);
87 auto decompressed = compressed->Decode().ConvertToRGBA();
88 ASSERT_TRUE(decompressed.IsValid());
90 mapping.
data = decompressed.GetAllocation()->GetMapping();
91 mapping.
length = decompressed.GetAllocation()->GetSize();
93 auto context = GetInteropContext();
96 desc.
size = {decompressed.GetSize().
width, decompressed.GetSize().height};
99 context.GetC(), &desc, &mapping,
nullptr));
100 ASSERT_TRUE(texture);
107 auto dl = Adopt<DisplayList>(
110 OpenPlaygroundHere([&](
const auto& context,
const auto& surface) ->
bool {
References ImpellerMapping::data, impeller::interop::ImpellerDisplayListBuilderCreateDisplayListNew(), impeller::interop::ImpellerDisplayListBuilderDrawTexture(), impeller::interop::ImpellerDisplayListBuilderNew(), impeller::interop::ImpellerSurfaceDrawDisplayList(), impeller::interop::ImpellerTextureCreateWithContentsNew(), kImpellerPixelFormatRGBA8888, kImpellerTextureSamplingLinear, ImpellerMapping::length, ImpellerTextureDescriptor::mip_count, ImpellerTextureDescriptor::pixel_format, ImpellerTextureDescriptor::size, and ImpellerISize::width.
◆ TEST_P() [7/7]
Definition at line 61 of file impeller_unittests.cc.
69 color = {1.0, 0.0, 0.0, 1.0};
73 auto dl = Adopt<DisplayList>(
77 OpenPlaygroundHere([&](
const auto& context,
const auto& surface) ->
bool {
References color, impeller::interop::ImpellerDisplayListBuilderCreateDisplayListNew(), impeller::interop::ImpellerDisplayListBuilderDrawRect(), impeller::interop::ImpellerDisplayListBuilderNew(), impeller::interop::ImpellerDisplayListBuilderTranslate(), impeller::interop::ImpellerPaintNew(), impeller::interop::ImpellerPaintSetColor(), and impeller::interop::ImpellerSurfaceDrawDisplayList().
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerParagraph IMPELLER_NULLABLE ImpellerParagraphBuilderBuildParagraphNew(ImpellerParagraphBuilder IMPELLER_NONNULL paragraph_builder, float width)
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerSurface IMPELLER_NULLABLE ImpellerSurfaceCreateWrappedFBONew(ImpellerContext IMPELLER_NULLABLE context, uint64_t fbo, ImpellerPixelFormat format, const ImpellerISize *IMPELLER_NULLABLE size)
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerTexture IMPELLER_NULLABLE ImpellerTextureCreateWithOpenGLTextureHandleNew(ImpellerContext IMPELLER_NONNULL context, const ImpellerTextureDescriptor *IMPELLER_NONNULL descriptor, uint64_t handle)
IMPELLER_EXPORT void ImpellerDisplayListBuilderRelease(ImpellerDisplayListBuilder IMPELLER_NULLABLE builder)
IMPELLER_EXPORT void ImpellerDisplayListBuilderRestore(ImpellerDisplayListBuilder IMPELLER_NONNULL builder)
IMPELLER_EXPORT void ImpellerDisplayListBuilderDrawRect(ImpellerDisplayListBuilder IMPELLER_NONNULL builder, const ImpellerRect *IMPELLER_NONNULL rect, ImpellerPaint IMPELLER_NONNULL paint)
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerTypographyContext IMPELLER_NULLABLE ImpellerTypographyContextNew()
IMPELLER_EXPORT void ImpellerDisplayListBuilderGetTransform(ImpellerDisplayListBuilder IMPELLER_NONNULL builder, ImpellerMatrix *IMPELLER_NONNULL out_transform)
IMPELLER_EXPORT uint32_t ImpellerDisplayListBuilderGetSaveCount(ImpellerDisplayListBuilder IMPELLER_NONNULL builder)
IMPELLER_EXPORT void ImpellerDisplayListBuilderDrawTexture(ImpellerDisplayListBuilder IMPELLER_NONNULL builder, ImpellerTexture IMPELLER_NONNULL texture, const ImpellerPoint *IMPELLER_NONNULL point, ImpellerTextureSampling sampling, ImpellerPaint IMPELLER_NULLABLE paint)
IMPELLER_EXPORT void ImpellerDisplayListBuilderTranslate(ImpellerDisplayListBuilder IMPELLER_NONNULL builder, float x_translation, float y_translation)
IMPELLER_EXPORT void ImpellerDisplayListBuilderSave(ImpellerDisplayListBuilder IMPELLER_NONNULL builder)
IMPELLER_EXPORT uint64_t ImpellerTextureGetOpenGLHandle(ImpellerTexture IMPELLER_NONNULL texture)
IMPELLER_EXPORT bool ImpellerSurfaceDrawDisplayList(ImpellerSurface IMPELLER_NULLABLE surface, ImpellerDisplayList IMPELLER_NONNULL display_list)
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerDisplayList IMPELLER_NULLABLE ImpellerDisplayListBuilderCreateDisplayListNew(ImpellerDisplayListBuilder IMPELLER_NONNULL builder)
IMPELLER_EXPORT void ImpellerParagraphStyleSetFontSize(ImpellerParagraphStyle IMPELLER_NONNULL paragraph_style, float size)
@ kImpellerPixelFormatRGBA8888
ScopedObject< Object > Ref(Object *object)
IMPELLER_EXPORT void ImpellerPaintSetColor(ImpellerPaint IMPELLER_NONNULL paint, const ImpellerColor *IMPELLER_NONNULL color)
IMPELLER_EXPORT void ImpellerParagraphStyleSetBackground(ImpellerParagraphStyle IMPELLER_NONNULL paragraph_style, ImpellerPaint IMPELLER_NONNULL paint)
IMPELLER_EXPORT void ImpellerParagraphStyleSetForeground(ImpellerParagraphStyle IMPELLER_NONNULL paragraph_style, ImpellerPaint IMPELLER_NONNULL paint)
constexpr Matrix ToImpellerType(const ImpellerMatrix &m)
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerTexture IMPELLER_NULLABLE ImpellerTextureCreateWithContentsNew(ImpellerContext IMPELLER_NONNULL context, const ImpellerTextureDescriptor *IMPELLER_NONNULL descriptor, const ImpellerMapping *IMPELLER_NONNULL contents, void *IMPELLER_NULLABLE contents_on_release_user_data)
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerDisplayListBuilder IMPELLER_NULLABLE ImpellerDisplayListBuilderNew(const ImpellerRect *IMPELLER_NULLABLE cull_rect)
IMPELLER_EXPORT void ImpellerParagraphBuilderPushStyle(ImpellerParagraphBuilder IMPELLER_NONNULL paragraph_builder, ImpellerParagraphStyle IMPELLER_NONNULL style)
ImpellerPixelFormat pixel_format
IMPELLER_EXPORT void ImpellerDisplayListBuilderDrawParagraph(ImpellerDisplayListBuilder IMPELLER_NONNULL builder, ImpellerParagraph IMPELLER_NONNULL paragraph, const ImpellerPoint *IMPELLER_NONNULL point)
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerPaint IMPELLER_NULLABLE ImpellerPaintNew()
ScopedObject< Object > Adopt(Object *object)
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerParagraphStyle IMPELLER_NULLABLE ImpellerParagraphStyleNew()
@ kImpellerTextureSamplingLinear
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerParagraphBuilder IMPELLER_NULLABLE ImpellerParagraphBuilderNew(ImpellerTypographyContext IMPELLER_NONNULL context)
const uint8_t *IMPELLER_NONNULL data
IMPELLER_EXPORT void ImpellerParagraphBuilderAddText(ImpellerParagraphBuilder IMPELLER_NONNULL paragraph_builder, const uint8_t *IMPELLER_NULLABLE data, uint32_t length)
AllocationSize< 1u > Bytes