summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 00:52:33 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 00:52:33 +0000
commit1075a530e0efc3a86ed6213c9b5a65a3d6cd74da (patch)
tree679110b7ced6557efa9b05a97621a004cf1142d5 /gpu
parentb9ccf65abf3240d57a53d9d5b1caceebc0c2c19f (diff)
downloadchromium_src-1075a530e0efc3a86ed6213c9b5a65a3d6cd74da.zip
chromium_src-1075a530e0efc3a86ed6213c9b5a65a3d6cd74da.tar.gz
chromium_src-1075a530e0efc3a86ed6213c9b5a65a3d6cd74da.tar.bz2
Make TextureManager correctly delete default textures.
The default textures were not tracked correctly. This fixes that issue TEST=unit tests and GLES2 conformance tests no longer crash BUG=none Review URL: https://chromiumcodereview.appspot.com/10549002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141815 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/test_helper.cc57
-rw-r--r--gpu/command_buffer/service/test_helper.h12
-rw-r--r--gpu/command_buffer/service/texture_manager.cc10
-rw-r--r--gpu/command_buffer/service/texture_manager_unittest.cc8
4 files changed, 70 insertions, 17 deletions
diff --git a/gpu/command_buffer/service/test_helper.cc b/gpu/command_buffer/service/test_helper.cc
index 2a16ced..4ea3918 100644
--- a/gpu/command_buffer/service/test_helper.cc
+++ b/gpu/command_buffer/service/test_helper.cc
@@ -162,6 +162,63 @@ void TestHelper::SetupTextureManagerInitExpectations(
}
}
+void TestHelper::SetupTextureDestructionExpectations(
+ ::gfx::MockGLInterface* gl, GLenum target) {
+ GLuint texture_id = 0;
+ switch (target) {
+ case GL_TEXTURE_2D:
+ texture_id = kServiceDefaultTexture2dId;
+ break;
+ case GL_TEXTURE_CUBE_MAP:
+ texture_id = kServiceDefaultTextureCubemapId;
+ break;
+ case GL_TEXTURE_EXTERNAL_OES:
+ texture_id = kServiceDefaultExternalTextureId;
+ break;
+ case GL_TEXTURE_RECTANGLE_ARB:
+ texture_id = kServiceDefaultRectangleTextureId;
+ break;
+ default:
+ NOTREACHED();
+ }
+
+ EXPECT_CALL(*gl, DeleteTextures(1, Pointee(texture_id)))
+ .Times(1)
+ .RetiresOnSaturation();
+}
+
+void TestHelper::SetupTextureManagerDestructionExpectations(
+ ::gfx::MockGLInterface* gl,
+ const char* extensions) {
+ SetupTextureDestructionExpectations(gl, GL_TEXTURE_2D);
+ SetupTextureDestructionExpectations(gl, GL_TEXTURE_CUBE_MAP);
+
+ bool ext_image_external = false;
+ bool arb_texture_rectangle = false;
+ CStringTokenizer t(extensions, extensions + strlen(extensions), " ");
+ while (t.GetNext()) {
+ if (t.token() == "GL_OES_EGL_image_external") {
+ ext_image_external = true;
+ break;
+ }
+ if (t.token() == "GL_ARB_texture_rectangle") {
+ arb_texture_rectangle = true;
+ break;
+ }
+ }
+
+ if (ext_image_external) {
+ SetupTextureDestructionExpectations(gl, GL_TEXTURE_EXTERNAL_OES);
+ }
+ if (arb_texture_rectangle) {
+ SetupTextureDestructionExpectations(gl, GL_TEXTURE_RECTANGLE_ARB);
+ }
+
+ EXPECT_CALL(*gl, DeleteTextures(4, _))
+ .Times(1)
+ .RetiresOnSaturation();
+}
+
void TestHelper::SetupContextGroupInitExpectations(
::gfx::MockGLInterface* gl,
const DisallowedFeatures& disallowed_features,
diff --git a/gpu/command_buffer/service/test_helper.h b/gpu/command_buffer/service/test_helper.h
index d083e42..7515e6c 100644
--- a/gpu/command_buffer/service/test_helper.h
+++ b/gpu/command_buffer/service/test_helper.h
@@ -66,8 +66,10 @@ class TestHelper {
const char* extensions,
const char* vendor,
const char* renderer);
- static void SetupTextureManagerInitExpectations(::gfx::MockGLInterface* gl,
- const char* extensions);
+ static void SetupTextureManagerInitExpectations(
+ ::gfx::MockGLInterface* gl, const char* extensions);
+ static void SetupTextureManagerDestructionExpectations(
+ ::gfx::MockGLInterface* gl, const char* extensions);
static void SetupExpectationsForClearingUniforms(
::gfx::MockGLInterface* gl, UniformInfo* uniforms, size_t num_uniforms);
@@ -79,8 +81,10 @@ class TestHelper {
GLuint service_id);
private:
- static void SetupTextureInitializationExpectations(::gfx::MockGLInterface* gl,
- GLenum target);
+ static void SetupTextureInitializationExpectations(
+ ::gfx::MockGLInterface* gl, GLenum target);
+ static void SetupTextureDestructionExpectations(
+ ::gfx::MockGLInterface* gl, GLenum target);
};
} // namespace gles2
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 9666597..fbbdec6 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -73,16 +73,12 @@ TextureManager::~TextureManager() {
void TextureManager::Destroy(bool have_context) {
have_context_ = have_context;
texture_infos_.clear();
- GLuint ids[kNumDefaultTextures * 2];
for (int ii = 0; ii < kNumDefaultTextures; ++ii) {
- TextureInfo* texture = default_textures_[ii].get();
- mem_represented_ -= texture ? texture->estimated_size() : 0;
- ids[ii * 2 + 0] = texture ? texture->service_id() : 0;
- ids[ii * 2 + 1] = black_texture_ids_[ii];
+ default_textures_[ii] = NULL;
}
if (have_context) {
- glDeleteTextures(arraysize(ids), ids);
+ glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_);
}
DCHECK_EQ(0u, mem_represented_);
@@ -683,7 +679,7 @@ TextureManager::TextureInfo::Ref TextureManager::CreateDefaultAndBlackTextures(
// we need to manually manipulate some of the their bookkeeping.
++num_unrenderable_textures_;
TextureInfo::Ref default_texture = TextureInfo::Ref(
- new TextureInfo(NULL, ids[1]));
+ new TextureInfo(this, ids[1]));
SetInfoTarget(default_texture, target);
if (needs_faces) {
for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) {
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc
index f077114..5079e77 100644
--- a/gpu/command_buffer/service/texture_manager_unittest.cc
+++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -158,9 +158,7 @@ TEST_F(TextureManagerTest, Destroy) {
EXPECT_CALL(*gl_, DeleteTextures(1, ::testing::Pointee(kService1Id)))
.Times(1)
.RetiresOnSaturation();
- EXPECT_CALL(*gl_, DeleteTextures(8, _))
- .Times(1)
- .RetiresOnSaturation();
+ TestHelper::SetupTextureManagerDestructionExpectations(gl_.get(), "");
manager.Destroy(true);
// Check that resources got freed.
info1 = manager.GetTextureInfo(kClient1Id);
@@ -182,11 +180,9 @@ TEST_F(TextureManagerTest, DestroyUnowned) {
// Check texture got created.
TextureManager::TextureInfo* info1 = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info1 != NULL);
- EXPECT_CALL(*gl_, DeleteTextures(8, _))
- .Times(1)
- .RetiresOnSaturation();
// Check that it is not freed if it is not owned.
+ TestHelper::SetupTextureManagerDestructionExpectations(gl_.get(), "");
manager.Destroy(true);
info1 = manager.GetTextureInfo(kClient1Id);
ASSERT_TRUE(info1 == NULL);