diff options
author | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-27 08:16:30 +0000 |
---|---|---|
committer | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-27 08:16:30 +0000 |
commit | 73ec57ae143da9b6a9a993b292b96156e90584e4 (patch) | |
tree | e388fcffccb9a9a96212003c4fa9448e724ca6d0 | |
parent | 461cf10d60bbee2999e6d947def279e8e527d645 (diff) | |
download | chromium_src-73ec57ae143da9b6a9a993b292b96156e90584e4.zip chromium_src-73ec57ae143da9b6a9a993b292b96156e90584e4.tar.gz chromium_src-73ec57ae143da9b6a9a993b292b96156e90584e4.tar.bz2 |
Clear textures on creation for D3D because it
does not
Review URL: http://codereview.chromium.org/174530
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24603 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | o3d/core/win/d3d9/texture_d3d9.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/o3d/core/win/d3d9/texture_d3d9.cc b/o3d/core/win/d3d9/texture_d3d9.cc index a352e98..b2e309f 100644 --- a/o3d/core/win/d3d9/texture_d3d9.cc +++ b/o3d/core/win/d3d9/texture_d3d9.cc @@ -399,6 +399,26 @@ Texture2DD3D9* Texture2DD3D9::Create(ServiceLocator* service_locator, height, resize_to_pot, enable_render_surfaces); + + // Clear the texture. + // This is platform specific because some platforms, (command-buffers), + // will guarantee the textures are cleared so we don't have to. + { + size_t row_size = image::ComputeMipChainSize(mip_width, 1, format, 1); + scoped_array<uint8> zero(new uint8[row_size]); + memset(zero.get(), 0, row_size); + for (int level = 0; level < levels; ++level) { + if (enable_render_surfaces) { + texture->GetRenderSurface(level); + } else { + texture->SetRect(level, 0, 0, + image::ComputeMipDimension(level, mip_width), + image::ComputeMipDimension(level, mip_height), + zero.get(), 0); + } + } + } + if (resize_to_pot) { texture->backing_bitmap_->Allocate(format, width, height, levels, Bitmap::IMAGE); @@ -718,6 +738,27 @@ TextureCUBED3D9* TextureCUBED3D9::Create(ServiceLocator* service_locator, levels, resize_to_pot, enable_render_surfaces); + + // Clear the texture. + // This is platform specific because some platforms, (command-buffers), will + // guarantee the textures are cleared so we don't have to. + { + size_t row_size = image::ComputeMipChainSize(edge, 1, format, 1); + scoped_array<uint8> zero(new uint8[row_size]); + memset(zero.get(), 0, row_size); + for (int level = 0; level < levels; ++level) { + for (int face = 0; face < static_cast<int>(NUMBER_OF_FACES); ++face) { + if (enable_render_surfaces) { + texture->GetRenderSurface(static_cast<CubeFace>(face), level); + } else { + texture->SetRect(static_cast<CubeFace>(face),level , 0, 0, + image::ComputeMipDimension(level, edge), + image::ComputeMipDimension(level, edge), + zero.get(), 0); + } + } + } + } if (resize_to_pot) { for (int ii = 0; ii < static_cast<int>(NUMBER_OF_FACES); ++ii) { texture->backing_bitmaps_[ii]->Allocate( |