Project import generated by Copybara.

GitOrigin-RevId: 6e4aff1cc351be3ae4537b677f36d139ee50ce09
This commit is contained in:
MediaPipe Team
2021-03-25 22:09:18 -04:00
committed by chuoling
parent a92cff7a60
commit 7c331ad58b
175 changed files with 4804 additions and 1325 deletions
+1 -1
View File
@@ -782,7 +782,7 @@ bool GlContext::CheckForGlErrors() { return CheckForGlErrors(false); }
bool GlContext::CheckForGlErrors(bool force) {
#if UNSAFE_EMSCRIPTEN_SKIP_GL_ERROR_HANDLING
if (!force) {
LOG_FIRST_N(WARNING, 1) << "MediaPipe OpenGL error checking is disabled";
LOG_FIRST_N(WARNING, 1) << "OpenGL error checking is disabled";
return false;
}
#endif
+11 -11
View File
@@ -52,15 +52,15 @@ GlTextureBufferSharedPtr GlTextureBufferPool::GetBuffer() {
// Return a shared_ptr with a custom deleter that adds the buffer back
// to our available list.
std::weak_ptr<GlTextureBufferPool> weak_pool(shared_from_this());
return std::shared_ptr<GlTextureBuffer>(buffer.release(),
[weak_pool](GlTextureBuffer* buf) {
auto pool = weak_pool.lock();
if (pool) {
pool->Return(buf);
} else {
delete buf;
}
});
return std::shared_ptr<GlTextureBuffer>(
buffer.release(), [weak_pool](GlTextureBuffer* buf) {
auto pool = weak_pool.lock();
if (pool) {
pool->Return(absl::WrapUnique(buf));
} else {
delete buf;
}
});
}
std::pair<int, int> GlTextureBufferPool::GetInUseAndAvailableCounts() {
@@ -68,12 +68,12 @@ std::pair<int, int> GlTextureBufferPool::GetInUseAndAvailableCounts() {
return {in_use_count_, available_.size()};
}
void GlTextureBufferPool::Return(GlTextureBuffer* buf) {
void GlTextureBufferPool::Return(std::unique_ptr<GlTextureBuffer> buf) {
std::vector<std::unique_ptr<GlTextureBuffer>> trimmed;
{
absl::MutexLock lock(&mutex_);
--in_use_count_;
available_.emplace_back(buf);
available_.emplace_back(std::move(buf));
TrimAvailable(&trimmed);
}
// The trimmed buffers will be released without holding the lock.
+1 -1
View File
@@ -56,7 +56,7 @@ class GlTextureBufferPool
int keep_count);
// Return a buffer to the pool.
void Return(GlTextureBuffer* buf);
void Return(std::unique_ptr<GlTextureBuffer> buf);
// If the total number of buffers is greater than keep_count, destroys any
// surplus buffers that are no longer in use.