diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 18:55:49 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 18:55:49 +0000 |
commit | 00f893d36bc4b9bdf8d0ca824478707b8c52c550 (patch) | |
tree | 43bd4e1f3add11d9da2a1b7b94f3b88b6d33f8d4 /gpu/command_buffer/service/texture_manager.cc | |
parent | 3b51bda549c3cb24e896703a6ce69807cf1a2ba2 (diff) | |
download | chromium_src-00f893d36bc4b9bdf8d0ca824478707b8c52c550.zip chromium_src-00f893d36bc4b9bdf8d0ca824478707b8c52c550.tar.gz chromium_src-00f893d36bc4b9bdf8d0ca824478707b8c52c550.tar.bz2 |
Fixes for the default texture.
Since we are simulating non-shared resources on top
of shared resources we can't actually let contexts
use texture 0 because they are all sharing it.
Also, moved the black textures to the texture manager.
TEST=unit tests and ran conformance tests
BUG=none
Review URL: http://codereview.chromium.org/3150026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57214 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/texture_manager.cc')
-rw-r--r-- | gpu/command_buffer/service/texture_manager.cc | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc index 2556197..607938e 100644 --- a/gpu/command_buffer/service/texture_manager.cc +++ b/gpu/command_buffer/service/texture_manager.cc @@ -75,6 +75,15 @@ void TextureManager::Destroy(bool have_context) { } texture_infos_.erase(texture_infos_.begin()); } + if (have_context) { + GLuint ids[] = { + black_2d_texture_id_, + black_cube_texture_id_, + default_texture_2d_->service_id(), + default_texture_cube_map_->service_id(), + }; + glDeleteTextures(arraysize(ids), ids); + } } bool TextureManager::TextureInfo::CanRender( @@ -352,18 +361,50 @@ TextureManager::TextureManager( max_cube_map_levels_(ComputeMipMapCount(max_cube_map_texture_size, max_cube_map_texture_size, max_cube_map_texture_size)), - num_unrenderable_textures_(0) { - default_texture_2d_ = TextureInfo::Ref(new TextureInfo(0)); + num_unrenderable_textures_(0), + black_2d_texture_id_(0), + black_cube_texture_id_(0) { +} + +bool TextureManager::Initialize() { + // TODO(gman): The default textures have to be real textures, not the 0 + // texture because we simulate non shared resources on top of shared + // resources and all contexts that share resource share the same default + // texture. + + // Make default textures and texture for replacing non-renderable textures. + GLuint ids[4]; + glGenTextures(arraysize(ids), ids); + static uint8 black[] = {0, 0, 0, 255}; + for (int ii = 0; ii < 2; ++ii) { + glBindTexture(GL_TEXTURE_2D, ids[ii]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, + GL_UNSIGNED_BYTE, black); + glBindTexture(GL_TEXTURE_CUBE_MAP, ids[2 + ii]); + for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { + glTexImage2D(GLES2Util::IndexToGLFaceTarget(ii), 0, GL_RGBA, 1, 1, 0, + GL_RGBA, GL_UNSIGNED_BYTE, black); + } + } + glBindTexture(GL_TEXTURE_2D, 0); + glBindTexture(GL_TEXTURE_CUBE_MAP, 0); + + default_texture_2d_ = TextureInfo::Ref(new TextureInfo(ids[1])); SetInfoTarget(default_texture_2d_, GL_TEXTURE_2D); default_texture_2d_->SetLevelInfo( this, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); - default_texture_cube_map_ = TextureInfo::Ref(new TextureInfo(0)); + default_texture_cube_map_ = TextureInfo::Ref(new TextureInfo(ids[3])); SetInfoTarget(default_texture_cube_map_, GL_TEXTURE_CUBE_MAP); for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { default_texture_cube_map_->SetLevelInfo( this, GLES2Util::IndexToGLFaceTarget(ii), 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); } + + black_2d_texture_id_ = ids[0]; + black_cube_texture_id_ = ids[2]; + + return true; } bool TextureManager::ValidForTarget( |