summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-24 23:56:17 +0000
committerpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-24 23:56:17 +0000
commit0e201d69b5225914df58223e926e6b7c5c03faaa (patch)
treefab83490e6f3160824f5381740f140fec62f2818
parent849a9148c98069fc889128fd1ca2353045810d61 (diff)
downloadchromium_src-0e201d69b5225914df58223e926e6b7c5c03faaa.zip
chromium_src-0e201d69b5225914df58223e926e6b7c5c03faaa.tar.gz
chromium_src-0e201d69b5225914df58223e926e6b7c5c03faaa.tar.bz2
Merge 78467 - Fixed bug in DetachShader.
TEST=unit tests BUG=none Review URL: http://codereview.chromium.org/6677089 TBR=gman@chromium.org Review URL: http://codereview.chromium.org/6713117 git-svn-id: svn://svn.chromium.org/chrome/branches/696/src@79346 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc6
-rw-r--r--gpu/command_buffer/service/program_manager.cc6
-rw-r--r--gpu/command_buffer/service/program_manager.h2
-rw-r--r--gpu/command_buffer/service/program_manager_unittest.cc2
-rw-r--r--gpu/command_buffer/service/shader_manager.h15
-rw-r--r--gpu/command_buffer/service/shader_translator.h2
6 files changed, 22 insertions, 11 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 29ba3d6..60f5b81 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -4449,8 +4449,12 @@ void GLES2DecoderImpl::DoDetachShader(
if (!shader_info) {
return;
}
+ if (!program_info->DetachShader(shader_manager(), shader_info)) {
+ SetGLError(GL_INVALID_OPERATION,
+ "glDetachShader: shader not attached to program");
+ return;
+ }
glDetachShader(program_info->service_id(), shader_info->service_id());
- program_info->DetachShader(shader_manager(), shader_info);
}
void GLES2DecoderImpl::DoValidateProgram(GLuint program_client_id) {
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc
index 2b9ed0b..683449a 100644
--- a/gpu/command_buffer/service/program_manager.cc
+++ b/gpu/command_buffer/service/program_manager.cc
@@ -377,13 +377,17 @@ bool ProgramManager::ProgramInfo::AttachShader(
return true;
}
-void ProgramManager::ProgramInfo::DetachShader(
+bool ProgramManager::ProgramInfo::DetachShader(
ShaderManager* shader_manager,
ShaderManager::ShaderInfo* info) {
DCHECK(shader_manager);
DCHECK(info);
+ if (attached_shaders_[ShaderTypeToIndex(info->shader_type())].get() != info) {
+ return false;
+ }
attached_shaders_[ShaderTypeToIndex(info->shader_type())] = NULL;
shader_manager->UnuseShader(info);
+ return true;
}
void ProgramManager::ProgramInfo::DetachShaders(ShaderManager* shader_manager) {
diff --git a/gpu/command_buffer/service/program_manager.h b/gpu/command_buffer/service/program_manager.h
index f3088d6..5c0070f 100644
--- a/gpu/command_buffer/service/program_manager.h
+++ b/gpu/command_buffer/service/program_manager.h
@@ -134,7 +134,7 @@ class ProgramManager {
}
bool AttachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info);
- void DetachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info);
+ bool DetachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info);
bool CanLink() const;
diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc
index 8e08051..2f37cfd 100644
--- a/gpu/command_buffer/service/program_manager_unittest.cc
+++ b/gpu/command_buffer/service/program_manager_unittest.cc
@@ -457,6 +457,8 @@ TEST_F(ProgramManagerWithShaderTest, AttachDetachShader) {
EXPECT_FALSE(program_info->CanLink());
fshader->SetStatus(true, "", NULL);
EXPECT_TRUE(program_info->CanLink());
+ EXPECT_TRUE(program_info->DetachShader(&shader_manager, fshader));
+ EXPECT_FALSE(program_info->DetachShader(&shader_manager, fshader));
shader_manager.Destroy(false);
}
diff --git a/gpu/command_buffer/service/shader_manager.h b/gpu/command_buffer/service/shader_manager.h
index f826a3c..548a965 100644
--- a/gpu/command_buffer/service/shader_manager.h
+++ b/gpu/command_buffer/service/shader_manager.h
@@ -32,13 +32,6 @@ class ShaderManager {
typedef scoped_refptr<ShaderInfo> Ref;
typedef ShaderTranslator::VariableInfo VariableInfo;
- explicit ShaderInfo(GLuint service_id, GLenum shader_type)
- : use_count_(0),
- service_id_(service_id),
- shader_type_(shader_type),
- valid_(false) {
- }
-
void Update(const char* source) {
source_.reset(source ? new std::string(source) : NULL);
}
@@ -84,6 +77,14 @@ class ShaderManager {
friend class base::RefCounted<ShaderInfo>;
friend class ShaderManager;
+
+ ShaderInfo(GLuint service_id, GLenum shader_type)
+ : use_count_(0),
+ service_id_(service_id),
+ shader_type_(shader_type),
+ valid_(false) {
+ }
+
~ShaderInfo() { }
void IncUseCount() {
diff --git a/gpu/command_buffer/service/shader_translator.h b/gpu/command_buffer/service/shader_translator.h
index 9e834ea..948a00d 100644
--- a/gpu/command_buffer/service/shader_translator.h
+++ b/gpu/command_buffer/service/shader_translator.h
@@ -62,7 +62,7 @@ class ShaderTranslatorInterface {
class ShaderTranslator : public ShaderTranslatorInterface {
public:
ShaderTranslator();
- ~ShaderTranslator();
+ virtual ~ShaderTranslator();
// Overridden from ShaderTranslatorInterface.
virtual bool Init(