Make it possible to override the SimplePool factory used by MultiPool

This means MultiPool no longer needs a SetFlushPlatformCaches method, which was too specific to the CVPixelBufferPool.

PiperOrigin-RevId: 488783003
This commit is contained in:
Camillo Lugaresi
2022-11-15 16:14:27 -08:00
committed by Copybara-Service
parent 267476657d
commit b9fa2e3496
6 changed files with 31 additions and 29 deletions
+6 -2
View File
@@ -86,8 +86,12 @@ GpuResources::GpuResources(std::shared_ptr<GlContext> gl_context) {
std::make_shared<GlContextExecutor>(gl_context.get());
#if __APPLE__
texture_caches_ = std::make_shared<CvTextureCacheManager>();
gpu_buffer_pool().SetFlushPlatformCaches(
[tc = texture_caches_] { tc->FlushTextureCaches(); });
gpu_buffer_pool().SetSimplePoolFactory(
[tc = texture_caches_](const GpuBufferMultiPool::BufferSpec& spec,
const MultiPoolOptions& options) {
return CvPixelBufferPoolWrapper::Create(spec.width, spec.height,
spec.format, options, tc.get());
});
#if MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER
texture_caches_->RegisterTextureCache(gl_context->cv_texture_cache());
#endif // MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER