summaryrefslogtreecommitdiffstats
path: root/o3d/core/win
diff options
context:
space:
mode:
authortschmelcher@chromium.org <tschmelcher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 21:20:47 +0000
committertschmelcher@chromium.org <tschmelcher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 21:20:47 +0000
commit88e6577f7fd716a7f0d9f0590d030af6372c6333 (patch)
treebca566c86d617151b4044f620bb6d19be0e10957 /o3d/core/win
parent7968428a96099f945dcd1381aefb60b0a2faa484 (diff)
downloadchromium_src-88e6577f7fd716a7f0d9f0590d030af6372c6333.zip
chromium_src-88e6577f7fd716a7f0d9f0590d030af6372c6333.tar.gz
chromium_src-88e6577f7fd716a7f0d9f0590d030af6372c6333.tar.bz2
Add an API to allow JavaScript to determine the framerate of individual dynamic textures.
TEST=loaded O3D on a test page on Linux and used the new API to display the framerate BUG=none Review URL: http://codereview.chromium.org/5591006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core/win')
-rw-r--r--o3d/core/win/d3d9/texture_d3d9.cc64
1 files changed, 37 insertions, 27 deletions
diff --git a/o3d/core/win/d3d9/texture_d3d9.cc b/o3d/core/win/d3d9/texture_d3d9.cc
index 8cb411c..c90d3f1 100644
--- a/o3d/core/win/d3d9/texture_d3d9.cc
+++ b/o3d/core/win/d3d9/texture_d3d9.cc
@@ -260,7 +260,7 @@ void SetTextureRectCompressed(Texture::Format format,
}
}
-void SetTextureRect(
+bool SetTextureRect(
ServiceLocator* service_locator,
IDirect3DTexture9* d3d_texture,
Texture::Format format,
@@ -280,7 +280,7 @@ void SetTextureRect(
if (!HR(d3d_texture->LockRect(
level, &out_rect, compressed ? NULL : &rect, 0))) {
O3D_ERROR(service_locator) << "Failed to Lock Texture2D (D3D9)";
- return;
+ return false;
}
const uint8* src = static_cast<const uint8*>(src_data);
@@ -294,11 +294,12 @@ void SetTextureRect(
}
if (!HR(d3d_texture->UnlockRect(level))) {
O3D_ERROR(service_locator) << "Failed to Unlock Texture2D (D3D9)";
- return;
+ return false;
}
+ return true;
}
-void SetTextureFaceRect(
+bool SetTextureFaceRect(
ServiceLocator* service_locator,
IDirect3DCubeTexture9* d3d_texture,
Texture::Format format,
@@ -321,7 +322,7 @@ void SetTextureFaceRect(
if (!HR(d3d_texture->LockRect(
d3d_face, level, &out_rect, compressed ? NULL : &rect, 0))) {
O3D_ERROR(service_locator) << "Failed to Lock TextureCUBE (D3D9)";
- return;
+ return false;
}
const uint8* src = static_cast<const uint8*>(src_data);
@@ -335,8 +336,9 @@ void SetTextureFaceRect(
}
if (!HR(d3d_texture->UnlockRect(d3d_face, level))) {
O3D_ERROR(service_locator) << "Failed to Unlock TextureCUBE (D3D9)";
- return;
+ return false;
}
+ return true;
}
} // unnamed namespace
@@ -550,6 +552,7 @@ void Texture2DD3D9::SetRect(int level,
return;
}
+ bool success = true;
if (resize_to_pot_) {
DCHECK(backing_bitmap_->image_data());
DCHECK(!compressed);
@@ -559,16 +562,19 @@ void Texture2DD3D9::SetRect(int level,
level, dst_left, dst_top, src_width, src_height, src_data, src_pitch);
UpdateBackedMipLevel(level);
} else {
- SetTextureRect(service_locator(),
- d3d_texture_,
- format(),
- level,
- dst_left,
- dst_top,
- src_width,
- src_height,
- src_data,
- src_pitch);
+ success = SetTextureRect(service_locator(),
+ d3d_texture_,
+ format(),
+ level,
+ dst_left,
+ dst_top,
+ src_width,
+ src_height,
+ src_data,
+ src_pitch);
+ }
+ if (success && level == 0) {
+ TextureUpdated();
}
}
@@ -877,6 +883,7 @@ void TextureCUBED3D9::SetRect(TextureCUBE::CubeFace face,
return;
}
+ bool success = true;
if (resize_to_pot_) {
Bitmap* backing_bitmap = backing_bitmaps_[face].Get();
DCHECK(backing_bitmap->image_data());
@@ -887,17 +894,20 @@ void TextureCUBED3D9::SetRect(TextureCUBE::CubeFace face,
level, dst_left, dst_top, src_width, src_height, src_data, src_pitch);
UpdateBackedMipLevel(face, level);
} else {
- SetTextureFaceRect(service_locator(),
- d3d_cube_texture_,
- format(),
- face,
- level,
- dst_left,
- dst_top,
- src_width,
- src_height,
- src_data,
- src_pitch);
+ success = SetTextureFaceRect(service_locator(),
+ d3d_cube_texture_,
+ format(),
+ face,
+ level,
+ dst_left,
+ dst_top,
+ src_width,
+ src_height,
+ src_data,
+ src_pitch);
+ }
+ if (success && level == 0) {
+ TextureUpdated();
}
}