Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_texture_registrar_test.cc File Reference

Go to the source code of this file.

Classes

class  FlTextureRegistrarTest
 

Functions

 G_DECLARE_FINAL_TYPE (FlTestRegistrarTexture, fl_test_registrar_texture, FL, TEST_REGISTRAR_TEXTURE, FlTextureGL) struct _FlTestRegistrarTexture
 A simple texture.
 
 G_DEFINE_TYPE (FlTestRegistrarTexture, fl_test_registrar_texture, fl_texture_gl_get_type()) static gboolean fl_test_registrar_texture_populate(FlTextureGL *texture
 
static void fl_test_registrar_texture_class_init (FlTestRegistrarTextureClass *klass)
 
static void fl_test_registrar_texture_init (FlTestRegistrarTexture *self)
 
static FlTestRegistrarTexture * fl_test_registrar_texture_new ()
 
static gpointer add_mock_texture_to_registrar (gpointer pointer)
 
 TEST_F (FlTextureRegistrarTest, MockRegistrar)
 
 TEST_F (FlTextureRegistrarTest, RegisterTexture)
 
 TEST_F (FlTextureRegistrarTest, MarkTextureFrameAvailable)
 
 TEST_F (FlTextureRegistrarTest, MarkInvalidTextureFrameAvailable)
 
 TEST_F (FlTextureRegistrarTest, RegistrarRegisterTextureInMultipleThreads)
 

Variables

static constexpr uint32_t kBufferWidth = 4u
 
static constexpr uint32_t kBufferHeight = 4u
 
static constexpr uint32_t kRealBufferWidth = 2u
 
static constexpr uint32_t kRealBufferHeight = 2u
 
static constexpr uint64_t kThreadCount = 16u
 
uint32_t * target = GL_TEXTURE_2D
 
uint32_t uint32_t * format = GL_R8
 
uint32_t uint32_t uint32_t * width = kRealBufferWidth
 
uint32_t uint32_t uint32_t uint32_t * height = kRealBufferHeight
 
uint32_t uint32_t uint32_t uint32_t GError ** error
 
return TRUE
 

Function Documentation

◆ add_mock_texture_to_registrar()

static gpointer add_mock_texture_to_registrar ( gpointer  pointer)
static

Definition at line 70 of file fl_texture_registrar_test.cc.

70 {
71 g_return_val_if_fail(FL_IS_TEXTURE_REGISTRAR(pointer), nullptr);
72 FlTextureRegistrar* registrar = FL_TEXTURE_REGISTRAR(pointer);
73 g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
75 int64_t* id = g_new0(int64_t, 1);
77 return id;
78}
g_autoptr(FlEngine) engine
G_MODULE_EXPORT int64_t fl_texture_get_id(FlTexture *self)
Definition fl_texture.cc:20
G_MODULE_EXPORT gboolean fl_texture_registrar_register_texture(FlTextureRegistrar *self, FlTexture *texture)
static FlTestRegistrarTexture * fl_test_registrar_texture_new()
FlTexture * texture
const uintptr_t id

References fl_test_registrar_texture_new(), fl_texture_get_id(), fl_texture_registrar_register_texture(), g_autoptr(), id, and texture.

Referenced by TEST_F().

◆ fl_test_registrar_texture_class_init()

static void fl_test_registrar_texture_class_init ( FlTestRegistrarTextureClass *  klass)
static

Definition at line 58 of file fl_texture_registrar_test.cc.

59 {
60 FL_TEXTURE_GL_CLASS(klass)->populate = fl_test_registrar_texture_populate;
61}

◆ fl_test_registrar_texture_init()

static void fl_test_registrar_texture_init ( FlTestRegistrarTexture *  self)
static

Definition at line 63 of file fl_texture_registrar_test.cc.

63{}

◆ fl_test_registrar_texture_new()

static FlTestRegistrarTexture * fl_test_registrar_texture_new ( )
static

Definition at line 65 of file fl_texture_registrar_test.cc.

65 {
66 return FL_TEST_REGISTRAR_TEXTURE(
67 g_object_new(fl_test_registrar_texture_get_type(), nullptr));
68}

Referenced by add_mock_texture_to_registrar(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ G_DECLARE_FINAL_TYPE()

G_DECLARE_FINAL_TYPE ( FlTestRegistrarTexture  ,
fl_test_registrar_texture  ,
FL  ,
TEST_REGISTRAR_TEXTURE  ,
FlTextureGL   
)

A simple texture.

Definition at line 25 of file fl_texture_registrar_test.cc.

32 {
33 FlTextureGL parent_instance;
34};

◆ G_DEFINE_TYPE()

G_DEFINE_TYPE ( FlTestRegistrarTexture  ,
fl_test_registrar_texture  ,
fl_texture_gl_get_type()   
)

◆ TEST_F() [1/5]

TEST_F ( FlTextureRegistrarTest  ,
MarkInvalidTextureFrameAvailable   
)

Definition at line 156 of file fl_texture_registrar_test.cc.

156 {
159 RegisterExternalTexture,
160 ([](auto engine, int64_t texture_id) { return kSuccess; }));
163 UnregisterExternalTexture,
164 ([](auto engine, int64_t texture_id) { return kSuccess; }));
166 MOCK_ENGINE_PROC(MarkExternalTextureFrameAvailable,
167 ([](auto engine, int64_t texture_id) {
169 }));
170
171 g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
172 g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
173
174 EXPECT_TRUE(fl_texture_registrar_register_texture(registrar, texture));
175 EXPECT_FALSE(
177}
@ kInternalInconsistency
Definition embedder.h:76
@ kSuccess
Definition embedder.h:73
FlutterEngine engine
Definition main.cc:84
FlutterEngineProcTable * fl_engine_get_embedder_api(FlEngine *self)
Definition fl_engine.cc:920
G_MODULE_EXPORT gboolean fl_texture_registrar_mark_texture_frame_available(FlTextureRegistrar *self, FlTexture *texture)
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
#define MOCK_ENGINE_PROC(proc, mock_impl)
FlutterEngineRegisterExternalTextureFnPtr RegisterExternalTexture
Definition embedder.h:3783
FlutterEngineUnregisterExternalTextureFnPtr UnregisterExternalTexture
Definition embedder.h:3784
FlutterEngineMarkExternalTextureFrameAvailableFnPtr MarkExternalTextureFrameAvailable
Definition embedder.h:3786
int64_t texture_id

References engine, fl_engine_get_embedder_api(), fl_test_registrar_texture_new(), fl_texture_registrar_mark_texture_frame_available(), fl_texture_registrar_new(), fl_texture_registrar_register_texture(), g_autoptr(), kInternalInconsistency, kSuccess, FlutterEngineProcTable::MarkExternalTextureFrameAvailable, MOCK_ENGINE_PROC, FlutterEngineProcTable::RegisterExternalTexture, texture, texture_id, and FlutterEngineProcTable::UnregisterExternalTexture.

◆ TEST_F() [2/5]

TEST_F ( FlTextureRegistrarTest  ,
MarkTextureFrameAvailable   
)

Definition at line 129 of file fl_texture_registrar_test.cc.

129 {
130 bool register_called = false;
132 MOCK_ENGINE_PROC(RegisterExternalTexture,
133 ([&register_called](auto engine, int64_t texture_id) {
134 register_called = true;
135 return kSuccess;
136 }));
139 UnregisterExternalTexture,
140 ([](auto engine, int64_t texture_id) { return kSuccess; }));
143 MarkExternalTextureFrameAvailable,
144 ([](auto engine, int64_t texture_id) { return kSuccess; }));
145
146 g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
147 g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
148
149 EXPECT_TRUE(fl_texture_registrar_register_texture(registrar, texture));
150 EXPECT_TRUE(register_called);
151 EXPECT_TRUE(
153}

References engine, fl_engine_get_embedder_api(), fl_test_registrar_texture_new(), fl_texture_registrar_mark_texture_frame_available(), fl_texture_registrar_new(), fl_texture_registrar_register_texture(), g_autoptr(), kSuccess, FlutterEngineProcTable::MarkExternalTextureFrameAvailable, MOCK_ENGINE_PROC, FlutterEngineProcTable::RegisterExternalTexture, texture, texture_id, and FlutterEngineProcTable::UnregisterExternalTexture.

◆ TEST_F() [3/5]

TEST_F ( FlTextureRegistrarTest  ,
MockRegistrar   
)

Definition at line 83 of file fl_texture_registrar_test.cc.

83 {
84 g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
85 g_autoptr(FlMockTextureRegistrar) registrar = fl_mock_texture_registrar_new();
86 EXPECT_TRUE(FL_IS_MOCK_TEXTURE_REGISTRAR(registrar));
87
89 FL_TEXTURE_REGISTRAR(registrar), texture));
92 FL_TEXTURE_REGISTRAR(registrar), texture));
95 FL_TEXTURE_REGISTRAR(registrar), texture));
96 EXPECT_EQ(fl_mock_texture_registrar_get_texture(registrar), nullptr);
97}
G_MODULE_EXPORT gboolean fl_texture_registrar_unregister_texture(FlTextureRegistrar *self, FlTexture *texture)
FlTexture * fl_mock_texture_registrar_get_texture(FlMockTextureRegistrar *self)
FlMockTextureRegistrar * fl_mock_texture_registrar_new()
gboolean fl_mock_texture_registrar_get_frame_available(FlMockTextureRegistrar *self)

References fl_mock_texture_registrar_get_frame_available(), fl_mock_texture_registrar_get_texture(), fl_mock_texture_registrar_new(), fl_test_registrar_texture_new(), fl_texture_registrar_mark_texture_frame_available(), fl_texture_registrar_register_texture(), fl_texture_registrar_unregister_texture(), g_autoptr(), and texture.

◆ TEST_F() [4/5]

TEST_F ( FlTextureRegistrarTest  ,
RegisterTexture   
)

Definition at line 100 of file fl_texture_registrar_test.cc.

100 {
101 bool register_called = false;
103 MOCK_ENGINE_PROC(RegisterExternalTexture,
104 ([&register_called](auto engine, int64_t texture_id) {
105 register_called = true;
106 return kSuccess;
107 }));
108 bool unregister_called = false;
110 MOCK_ENGINE_PROC(UnregisterExternalTexture,
111 ([&unregister_called](auto engine, int64_t texture_id) {
112 unregister_called = true;
113 return kSuccess;
114 }));
115
116 g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
117 g_autoptr(FlTexture) texture = FL_TEXTURE(fl_test_registrar_texture_new());
118
119 // EXPECT_FALSE(fl_texture_registrar_unregister_texture(registrar, texture));
120 EXPECT_FALSE(register_called);
121 EXPECT_TRUE(fl_texture_registrar_register_texture(registrar, texture));
122 EXPECT_TRUE(register_called);
123 EXPECT_FALSE(unregister_called);
124 EXPECT_TRUE(fl_texture_registrar_unregister_texture(registrar, texture));
125 EXPECT_TRUE(unregister_called);
126}

References engine, fl_engine_get_embedder_api(), fl_test_registrar_texture_new(), fl_texture_registrar_new(), fl_texture_registrar_register_texture(), fl_texture_registrar_unregister_texture(), g_autoptr(), kSuccess, MOCK_ENGINE_PROC, FlutterEngineProcTable::RegisterExternalTexture, texture, texture_id, and FlutterEngineProcTable::UnregisterExternalTexture.

◆ TEST_F() [5/5]

TEST_F ( FlTextureRegistrarTest  ,
RegistrarRegisterTextureInMultipleThreads   
)

Definition at line 181 of file fl_texture_registrar_test.cc.

181 {
184 RegisterExternalTexture,
185 ([](auto engine, int64_t texture_id) { return kSuccess; }));
188 UnregisterExternalTexture,
189 ([](auto engine, int64_t texture_id) { return kSuccess; }));
190
191 g_autoptr(FlTextureRegistrar) registrar = fl_texture_registrar_new(engine);
192 GThread* threads[kThreadCount];
193 int64_t ids[kThreadCount];
194
195 for (uint64_t t = 0; t < kThreadCount; t++) {
196 threads[t] =
197 g_thread_new(nullptr, add_mock_texture_to_registrar, registrar);
198 ASSERT_NE(threads[t], nullptr);
199 }
200 for (uint64_t t = 0; t < kThreadCount; t++) {
201 g_autofree int64_t* id = static_cast<int64_t*>(g_thread_join(threads[t]));
202 ASSERT_NE(id, nullptr);
203 ids[t] = *id;
204 }
205 // Check all the textures were created.
206 for (uint64_t t = 0; t < kThreadCount; t++) {
207 EXPECT_TRUE(fl_texture_registrar_lookup_texture(registrar, ids[t]) != NULL);
208 }
209}
FlTexture * fl_texture_registrar_lookup_texture(FlTextureRegistrar *self, int64_t texture_id)
static gpointer add_mock_texture_to_registrar(gpointer pointer)
static constexpr uint64_t kThreadCount

References add_mock_texture_to_registrar(), engine, fl_engine_get_embedder_api(), fl_texture_registrar_lookup_texture(), fl_texture_registrar_new(), g_autoptr(), id, kSuccess, kThreadCount, MOCK_ENGINE_PROC, FlutterEngineProcTable::RegisterExternalTexture, texture_id, and FlutterEngineProcTable::UnregisterExternalTexture.

Variable Documentation

◆ error

uint32_t uint32_t uint32_t uint32_t GError** error
Initial value:
{
EXPECT_TRUE(FL_IS_TEST_REGISTRAR_TEXTURE(texture))

Definition at line 45 of file fl_texture_registrar_test.cc.

◆ format

* format = GL_R8

Definition at line 42 of file fl_texture_registrar_test.cc.

Referenced by _glTexImage2D(), impeller::BytesForTextureRegion(), impeller::BytesPerBlockForPixelFormat(), impeller::BytesPerPixelForPixelFormat(), impeller::BytesPerRowForTextureWidth(), impeller::ChooseSurfaceFormat(), vulkan::VulkanDevice::ChooseSurfaceFormat(), clipboard_get_data(), clipboard_get_data(), flutter::GPUSurfaceVulkan::ColorTypeFromFormat(), impeller::CompressedBlockHeightForPixelFormat(), impeller::CompressedBlockWidthForPixelFormat(), impeller::CompressedTextureFamilyForFormat(), impeller::ContainsFormat(), flutter::ImageDescriptor::CreateImageInfo(), impeller::DecompressedImage::DecompressedImage(), Skwasm::DlWimpImageFromPixels::DlWimpImageFromPixels(), impeller::BlitCopyTextureToBufferCommandGLES::Encode(), flutter::EncodeImage(), flutter::EncodeImage(), fl_framebuffer_new(), impeller::FromMTLPixelFormat(), impeller::GetBytesPerPixel(), impeller::HasSuitableColorFormat(), impeller::HasSuitableDepthStencilFormat(), impeller::interop::ImpellerSurfaceCreateWrappedFBONew(), InferVulkanPlatformViewCreationCallback(), flutter::testing::DlOpenGLSurfaceProvider::InitializeSurface(), flutter::testing::DlSurfaceProviderImpeller::InitializeSurface(), flutter::testing::DlSurfaceProviderSkiaMetal::InitializeSurface(), flutter::testing::DlSoftwareSurfaceProvider::InitializeSurface(), InitializeSwapchain(), InternalFlutterGpu_Context_SupportsTextureFormat(), InternalFlutterGpu_Surface_Initialize(), InternalFlutterGpu_Texture_Initialize(), impeller::IsCompressed(), impeller::IsDepthWritable(), impeller::IsStencilWritable(), tonic::Log(), flutter::testing::DlSurfaceProvider::MakeInfo(), flutter::testing::DlOpenGLSurfaceProvider::MakeOffscreenSurface(), flutter::testing::DlSurfaceProviderImpeller::MakeOffscreenSurface(), flutter::testing::DlSoftwareSurfaceProvider::MakeOffscreenSurface(), flutter::testing::DlSurfaceProviderImpeller::MakeOffscreenSurface(), MakeRenderTargetFromBackingStoreImpeller(), MakeSkSurfaceFromBackingStore(), impeller::Allocator::MinimumBytesPerRow(), impeller::testing::mockReadPixels(), impeller::testing::mockTexImage2D(), impeller::testing::mockTexSubImage2D(), impeller::PixelFormatIsDepthStencil(), impeller::PixelFormatToString(), flutter::EmbedderSurfaceVulkan::PresentImage(), flutter::EmbedderSurfaceVulkanImpeller::PresentImage(), flutter::egl::ProcTable::ProcTable(), Skwasm::Surface::RasterizeImage(), Skwasm::Surface::RasterizeImageOnWorker(), flutter::testing::RenderEnvironment::RenderEnvironment(), flutter::Rasterizer::Screenshot::Screenshot(), flutter::Rasterizer::ScreenshotLastLayerTree(), impeller::RenderPassBuilderVK::SetColorAttachment(), impeller::PipelineDescriptor::SetDepthPixelFormat(), impeller::RenderPassBuilderVK::SetDepthStencilAttachment(), impeller::SwapchainTransientsMTL::SetSizeAndFormat(), impeller::RenderPassBuilderVK::SetStencilAttachment(), impeller::PipelineDescriptor::SetStencilPixelFormat(), base::StringPrintf(), flutter::testing::DlOpenGLSurfaceProvider::SupportsPixelFormat(), flutter::testing::DlSurfaceProviderImpeller::SupportsPixelFormat(), flutter::testing::DlSurfaceProviderSkiaMetal::SupportsPixelFormat(), flutter::gpu::Surface::Surface(), surface_rasterizeImage(), surface_rasterizeImageOnWorker(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::egl::ProcTable::TexImage2D(), impeller::android::ToAHardwareBufferFormat(), flutter::CanvasImage::toByteData(), impeller::ToImageAspectFlags(), impeller::interop::ToImpellerType(), impeller::ToMTLPixelFormat(), impeller::ToPixelFormat(), impeller::ToPixelFormat(), impeller::ToPixelFormatGLES(), impeller::ToRenderBufferFormat(), impeller::ToVKImageAspectFlags(), impeller::ToVKImageFormat(), impeller::AllocatorVK::ToVKImageUsageFlags(), impeller::ContextMTL::UpdateOffscreenLayerPixelFormat(), impeller::VkFormatToImpellerFormat(), flutter::WrapOnscreenSurface(), impeller::WrapTextureWithRenderTarget(), and flutter::gpu::Surface::~Surface().

◆ height

* height = kRealBufferHeight

Definition at line 44 of file fl_texture_registrar_test.cc.

◆ kBufferHeight

constexpr uint32_t kBufferHeight = 4u
staticconstexpr

Definition at line 20 of file fl_texture_registrar_test.cc.

◆ kBufferWidth

constexpr uint32_t kBufferWidth = 4u
staticconstexpr

Definition at line 19 of file fl_texture_registrar_test.cc.

◆ kRealBufferHeight

constexpr uint32_t kRealBufferHeight = 2u
staticconstexpr

Definition at line 22 of file fl_texture_registrar_test.cc.

◆ kRealBufferWidth

constexpr uint32_t kRealBufferWidth = 2u
staticconstexpr

Definition at line 21 of file fl_texture_registrar_test.cc.

◆ kThreadCount

constexpr uint64_t kThreadCount = 16u
staticconstexpr

◆ target

* target = GL_TEXTURE_2D

Definition at line 41 of file fl_texture_registrar_test.cc.

Referenced by _eglCreateImageKHR(), _glBindTexture(), flutter::FlutterPlatformNodeDelegate::AccessibilityPerformAction(), ui::AXPlatformRelationWin::AddTarget(), impeller::TextureGLES::Bind(), flutter::egl::ProcTable::BindTexture(), flutter::EmbedderRenderTargetCache::CacheRenderTarget(), impeller::ProcTableGLES::CheckFramebufferStatusDebug(), flutter::AccessibilityBridge::CommitUpdates(), impeller::compiler::Compiler::Compiler(), impeller::TextureGLES::ComputeTypeForBinding(), impeller::SamplerGLES::ConfigureBoundTexture(), impeller::RenderTargetAllocator::CreateOffscreen(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::testing::RenderPassGLESCommandTest::CreateRenderPassGLESContext(), tonic::DartInvokeField(), flutter::AccessibilityBridgeMac::DispatchAccessibilityAction(), flutter::AccessibilityBridgeWindows::DispatchAccessibilityAction(), flutter::FlutterWindowsEngine::DispatchSemanticsAction(), impeller::DisplayListToTexture(), fl_test_texture_populate(), fl_texture_gl_populate(), impeller::EntityPassTarget::Flip(), ui::AXPlatformRelationWin::get_target(), ui::AXPlatformNodeBase::GetInvalidValue(), flutter::EmbedderRenderTargetCache::GetRenderTarget(), impeller::GetVKClearValues(), impeller::Matrix::MakeLookAt(), flutter::testing::DlSurfaceProviderImpeller::MakeOffscreenSurface(), impeller::testing::mockBeginQueryEXT(), impeller::testing::mockBindFramebuffer(), impeller::testing::mockBindTexture(), impeller::testing::mockBufferSubData(), impeller::testing::mockCheckFramebufferStatus(), impeller::testing::mockDiscardFramebufferEXT(), impeller::testing::mockGetQueryObjectui64vEXT(), impeller::testing::mockGetQueryObjectuivEXT(), impeller::testing::mockInvalidateFramebuffer(), impeller::testing::mockTexImage2D(), impeller::testing::mockTexSubImage2D(), impeller::interop::testing::PlaygroundTest::OpenPlaygroundHere(), impeller::compiler::OutputBundleDepfile(), impeller::TextureGLES::SetAsFramebufferAttachment(), impeller::compiler::StringStartsWith(), impeller::compiler::TargetPlatformFromCommandLine(), impeller::testing::TEST(), impeller::testing::TEST(), TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), impeller::testing::TEST_P(), flutter::egl::ProcTable::TexImage2D(), flutter::egl::ProcTable::TexParameteri(), and flutter::AccessibilityBridgeMac::~AccessibilityBridgeMac().

◆ TRUE

return TRUE

Definition at line 55 of file fl_texture_registrar_test.cc.

◆ width

* width = kRealBufferWidth

Definition at line 43 of file fl_texture_registrar_test.cc.