Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: gpu/command_buffer/client/program_info_manager.cc

Issue 817653003: Update from https://crrev.com/309717 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/client/program_info_manager.cc
diff --git a/gpu/command_buffer/client/program_info_manager.cc b/gpu/command_buffer/client/program_info_manager.cc
index c0f8600aa87567360a93116217f01e229c93173d..f667d6dbdcc3736708c6723d4ca607588f73bf08 100644
--- a/gpu/command_buffer/client/program_info_manager.cc
+++ b/gpu/command_buffer/client/program_info_manager.cc
@@ -194,7 +194,11 @@ class CachedProgramInfoManager : public ProgramInfoManager {
bool GetProgramiv(GLenum pname, GLint* params);
// Updates the program info after a successful link.
- void Update(GLES2Implementation* gl, GLuint program);
+ void Update(GLES2Implementation* gl,
+ GLuint program,
+ const std::vector<int8>& result);
+
+ bool cached() const { return cached_; }
private:
bool cached_;
@@ -315,12 +319,12 @@ template<typename T> static T LocalGetAs(
}
void CachedProgramInfoManager::Program::Update(
- GLES2Implementation* gl, GLuint program) {
+ GLES2Implementation* gl,
+ GLuint program,
+ const std::vector<int8>& result) {
if (cached_) {
return;
}
- std::vector<int8> result;
- gl->GetProgramInfoCHROMIUMHelper(program, &result);
if (result.empty()) {
// This should only happen on a lost context.
return;
@@ -388,7 +392,22 @@ CachedProgramInfoManager::Program*
return NULL;
}
Program* info = &it->second;
- info->Update(gl, program);
+ if (info->cached())
+ return info;
+ std::vector<int8> result;
+ {
+ base::AutoUnlock unlock(lock_);
+ // lock_ can't be held across IPC call or else it may deadlock in pepper.
+ // http://crbug.com/418651
+ gl->GetProgramInfoCHROMIUMHelper(program, &result);
+ }
+
+ it = program_infos_.find(program);
+ if (it == program_infos_.end()) {
+ return NULL;
+ }
+ info = &it->second;
+ info->Update(gl, program, result);
return info;
}
@@ -418,20 +437,24 @@ bool CachedProgramInfoManager::GetProgramiv(
GLint CachedProgramInfoManager::GetAttribLocation(
GLES2Implementation* gl, GLuint program, const char* name) {
- base::AutoLock auto_lock(lock_);
- Program* info = GetProgramInfo(gl, program);
- if (info) {
- return info->GetAttribLocation(name);
+ {
+ base::AutoLock auto_lock(lock_);
+ Program* info = GetProgramInfo(gl, program);
+ if (info) {
+ return info->GetAttribLocation(name);
+ }
}
return gl->GetAttribLocationHelper(program, name);
}
GLint CachedProgramInfoManager::GetUniformLocation(
GLES2Implementation* gl, GLuint program, const char* name) {
- base::AutoLock auto_lock(lock_);
- Program* info = GetProgramInfo(gl, program);
- if (info) {
- return info->GetUniformLocation(name);
+ {
+ base::AutoLock auto_lock(lock_);
+ Program* info = GetProgramInfo(gl, program);
+ if (info) {
+ return info->GetUniformLocation(name);
+ }
}
return gl->GetUniformLocationHelper(program, name);
}
@@ -440,31 +463,32 @@ bool CachedProgramInfoManager::GetActiveAttrib(
GLES2Implementation* gl,
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
GLint* size, GLenum* type, char* name) {
- base::AutoLock auto_lock(lock_);
- Program* info = GetProgramInfo(gl, program);
- if (info) {
- const Program::VertexAttrib* attrib_info =
- info->GetAttribInfo(index);
- if (attrib_info) {
- if (size) {
- *size = attrib_info->size;
- }
- if (type) {
- *type = attrib_info->type;
- }
- if (length || name) {
- GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1,
- std::max(static_cast<size_t>(0),
- attrib_info->name.size()));
- if (length) {
- *length = max_size;
+ {
+ base::AutoLock auto_lock(lock_);
+ Program* info = GetProgramInfo(gl, program);
+ if (info) {
+ const Program::VertexAttrib* attrib_info = info->GetAttribInfo(index);
+ if (attrib_info) {
+ if (size) {
+ *size = attrib_info->size;
+ }
+ if (type) {
+ *type = attrib_info->type;
}
- if (name && bufsize > 0) {
- memcpy(name, attrib_info->name.c_str(), max_size);
- name[max_size] = '\0';
+ if (length || name) {
+ GLsizei max_size = std::min(
+ static_cast<size_t>(bufsize) - 1,
+ std::max(static_cast<size_t>(0), attrib_info->name.size()));
+ if (length) {
+ *length = max_size;
+ }
+ if (name && bufsize > 0) {
+ memcpy(name, attrib_info->name.c_str(), max_size);
+ name[max_size] = '\0';
+ }
}
+ return true;
}
- return true;
}
}
return gl->GetActiveAttribHelper(
@@ -475,30 +499,32 @@ bool CachedProgramInfoManager::GetActiveUniform(
GLES2Implementation* gl,
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length,
GLint* size, GLenum* type, char* name) {
- base::AutoLock auto_lock(lock_);
- Program* info = GetProgramInfo(gl, program);
- if (info) {
- const Program::UniformInfo* uniform_info = info->GetUniformInfo(index);
- if (uniform_info) {
- if (size) {
- *size = uniform_info->size;
- }
- if (type) {
- *type = uniform_info->type;
- }
- if (length || name) {
- GLsizei max_size = std::min(static_cast<size_t>(bufsize) - 1,
- std::max(static_cast<size_t>(0),
- uniform_info->name.size()));
- if (length) {
- *length = max_size;
+ {
+ base::AutoLock auto_lock(lock_);
+ Program* info = GetProgramInfo(gl, program);
+ if (info) {
+ const Program::UniformInfo* uniform_info = info->GetUniformInfo(index);
+ if (uniform_info) {
+ if (size) {
+ *size = uniform_info->size;
+ }
+ if (type) {
+ *type = uniform_info->type;
}
- if (name && bufsize > 0) {
- memcpy(name, uniform_info->name.c_str(), max_size);
- name[max_size] = '\0';
+ if (length || name) {
+ GLsizei max_size = std::min(
+ static_cast<size_t>(bufsize) - 1,
+ std::max(static_cast<size_t>(0), uniform_info->name.size()));
+ if (length) {
+ *length = max_size;
+ }
+ if (name && bufsize > 0) {
+ memcpy(name, uniform_info->name.c_str(), max_size);
+ name[max_size] = '\0';
+ }
}
+ return true;
}
- return true;
}
}
return gl->GetActiveUniformHelper(
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | gpu/command_buffer/common/gles2_cmd_format_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698