From f13903b7c5ba53cf383f8f3c67816274f9307db0 Mon Sep 17 00:00:00 2001 From: Camillo Lugaresi Date: Tue, 15 Nov 2022 16:01:08 -0800 Subject: [PATCH] Call SimplePool methods directly This removes redundant helper functions in GpuBufferMultiPool. PiperOrigin-RevId: 488782516 --- mediapipe/gpu/gpu_buffer_multi_pool.cc | 21 +++------------------ mediapipe/gpu/gpu_buffer_multi_pool.h | 5 +---- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/mediapipe/gpu/gpu_buffer_multi_pool.cc b/mediapipe/gpu/gpu_buffer_multi_pool.cc index 9c3c9a33e..d03ae06aa 100644 --- a/mediapipe/gpu/gpu_buffer_multi_pool.cc +++ b/mediapipe/gpu/gpu_buffer_multi_pool.cc @@ -21,12 +21,6 @@ #include "mediapipe/framework/port/logging.h" #include "mediapipe/gpu/gpu_shared_data_internal.h" -#if MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER -#include "CoreFoundation/CFBase.h" -#include "mediapipe/objc/CFHolder.h" -#include "mediapipe/objc/util.h" -#endif // MEDIAPIPE_GPU_BUFFER_USE_CV_PIXEL_BUFFER - namespace mediapipe { // Keep this many buffers allocated for a given frame size. @@ -87,20 +81,11 @@ GpuBuffer GpuBufferMultiPool::GetBuffer(int width, int height, std::shared_ptr pool = RequestPool(key); if (pool) { // Note: we release our multipool lock before accessing the simple pool. - return GetBufferFromSimplePool(key, *pool); + return GpuBuffer(pool->GetBuffer()); } else { - return GetBufferWithoutPool(key); + return GpuBuffer( + SimplePool::CreateBufferWithoutPool(width, height, format)); } } -GpuBuffer GpuBufferMultiPool::GetBufferFromSimplePool( - BufferSpec spec, GpuBufferMultiPool::SimplePool& pool) { - return GpuBuffer(pool.GetBuffer()); -} - -GpuBuffer GpuBufferMultiPool::GetBufferWithoutPool(const BufferSpec& spec) { - return GpuBuffer(SimplePool::CreateBufferWithoutPool(spec.width, spec.height, - spec.format)); -} - } // namespace mediapipe diff --git a/mediapipe/gpu/gpu_buffer_multi_pool.h b/mediapipe/gpu/gpu_buffer_multi_pool.h index f48577854..7feb39ad4 100644 --- a/mediapipe/gpu/gpu_buffer_multi_pool.h +++ b/mediapipe/gpu/gpu_buffer_multi_pool.h @@ -82,11 +82,8 @@ class GpuBufferMultiPool { std::shared_ptr MakeSimplePool(const BufferSpec& spec); // Requests a simple buffer pool for the given spec. This may return nullptr // if we have not yet reached a sufficient number of requests to allocate a - // pool, in which case the caller should invoke GetBufferWithoutPool instead - // of GetBufferFromSimplePool. + // pool, in which case the caller should invoke CreateBufferWithoutPool. std::shared_ptr RequestPool(const BufferSpec& spec); - GpuBuffer GetBufferFromSimplePool(BufferSpec spec, SimplePool& pool); - GpuBuffer GetBufferWithoutPool(const BufferSpec& spec); absl::Mutex mutex_; mediapipe::ResourceCache> cache_