diff options
author | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-04 00:45:16 +0000 |
---|---|---|
committer | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-04 00:45:16 +0000 |
commit | 17feef0bc90120cd94c7e11f218d9b5f0faf1a21 (patch) | |
tree | 93b7ad75c3b8c2f1ab42631269175ba8fed57513 /o3d/core/cross | |
parent | 37a594c5a5eb5977811be046829501a70256eeba (diff) | |
download | chromium_src-17feef0bc90120cd94c7e11f218d9b5f0faf1a21.zip chromium_src-17feef0bc90120cd94c7e11f218d9b5f0faf1a21.tar.gz chromium_src-17feef0bc90120cd94c7e11f218d9b5f0faf1a21.tar.bz2 |
Fixes for last bitmap change
Added tests to gyp build
Review URL: http://codereview.chromium.org/159835
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22352 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core/cross')
-rw-r--r-- | o3d/core/cross/bitmap.cc | 12 | ||||
-rw-r--r-- | o3d/core/cross/bitmap.h | 14 | ||||
-rw-r--r-- | o3d/core/cross/command_buffer/texture_cb.cc | 14 | ||||
-rw-r--r-- | o3d/core/cross/gl/texture_gl.cc | 25 | ||||
-rw-r--r-- | o3d/core/cross/message_queue.cc | 9 |
5 files changed, 27 insertions, 47 deletions
diff --git a/o3d/core/cross/bitmap.cc b/o3d/core/cross/bitmap.cc index 31ba128..3c5f610 100644 --- a/o3d/core/cross/bitmap.cc +++ b/o3d/core/cross/bitmap.cc @@ -195,9 +195,8 @@ void Bitmap::SetRect( int src_pitch) { DCHECK(src_data); DCHECK(level < static_cast<int>(num_mipmaps()) && level >= 0); - unsigned mip_width; - unsigned mip_height; - Bitmap::GetMipSize(level, width(), height(), &mip_width, &mip_height); + unsigned mip_width = Bitmap::GetMipDimension(level, width()); + unsigned mip_height = Bitmap::GetMipDimension(level, height()); DCHECK(dst_left + src_width <= mip_width && dst_top + src_height <= mip_height); bool compressed = Texture::IsCompressedFormat(format()); @@ -237,9 +236,8 @@ void Bitmap::SetFaceRect( int src_pitch) { DCHECK(src_data); DCHECK(level < static_cast<int>(num_mipmaps()) && level >= 0); - unsigned mip_width; - unsigned mip_height; - Bitmap::GetMipSize(level, width(), height(), &mip_width, &mip_height); + unsigned mip_width = Bitmap::GetMipDimension(level, width()); + unsigned mip_height = Bitmap::GetMipDimension(level, height()); DCHECK(dst_left + src_width <= mip_width && dst_top + src_height <= mip_height); bool compressed = Texture::IsCompressedFormat(format()); @@ -441,7 +439,7 @@ void Bitmap::DrawImage(Bitmap* src_img, LanczosScale(src_img_data, src_x, src_y, src_width, src_height, src_img->width_, src_img->height_, - dst_img_data, width_, + dst_img_data, width_ * components, dst_x, dst_y, dst_width, dst_height, width_, height_, components); diff --git a/o3d/core/cross/bitmap.h b/o3d/core/cross/bitmap.h index 87fab79..0491aac 100644 --- a/o3d/core/cross/bitmap.h +++ b/o3d/core/cross/bitmap.h @@ -86,16 +86,10 @@ class Bitmap : public ParamObject { width <= kMaxImageDimension && height < kMaxImageDimension;
}
- // Computes the width and height of a mip.
- static void GetMipSize(int level,
- unsigned width,
- unsigned height,
- unsigned* mip_width,
- unsigned* mip_height) {
- unsigned w = width >> level;
- unsigned h = height >> level;
- *mip_width = w > 0 ? w : 1u;
- *mip_height = h > 0 ? h : 1u;
+ // Computes one dimension of a mip.
+ static unsigned GetMipDimension(int level, unsigned dimension) {
+ unsigned v = dimension >> level;
+ return v > 0 ? v : 1u;
}
// Creates a copy of a bitmap, copying the pixels as well.
diff --git a/o3d/core/cross/command_buffer/texture_cb.cc b/o3d/core/cross/command_buffer/texture_cb.cc index ff03c6a..e9d5e52 100644 --- a/o3d/core/cross/command_buffer/texture_cb.cc +++ b/o3d/core/cross/command_buffer/texture_cb.cc @@ -345,10 +345,9 @@ bool Texture2DCB::Lock(int level, void** data, int* pitch) { backing_bitmap_->Allocate(format(), width(), height(), levels(), false); } *data = backing_bitmap_->GetMipData(level); - unsigned int mip_width; - unsigned int mip_height; - Bitmap::GetMipSize(level, width(), height(), &mip_width, &mip_height); - if (IsCompressed()) { + unsigned int mip_width = Bitmap::GetMipDimension(level, width()); + unsigned int mip_height = Bitmap::GetMipDimension(level, height()); + if (!IsCompressed()) { *pitch = Bitmap::GetMipChainSize(mip_width, 1,format(), 1); } else { unsigned blocks_across = (mip_width + 3) / 4; @@ -548,11 +547,8 @@ bool TextureCUBECB::Lock(CubeFace face, int level, void** data, int* pitch) { levels(), true); } *data = backing_bitmap_->GetFaceMipData(face, level); - unsigned int mip_width; - unsigned int mip_height; - Bitmap::GetMipSize(level, edge_length(), edge_length(), - &mip_width, &mip_height); - if (IsCompressed()) { + unsigned int mip_width = Bitmap::GetMipDimension(level, edge_length()); + if (!IsCompressed()) { *pitch = Bitmap::GetMipChainSize(mip_width, 1,format(), 1); } else { unsigned blocks_across = (mip_width + 3) / 4; diff --git a/o3d/core/cross/gl/texture_gl.cc b/o3d/core/cross/gl/texture_gl.cc index ff9588f..3972a50 100644 --- a/o3d/core/cross/gl/texture_gl.cc +++ b/o3d/core/cross/gl/texture_gl.cc @@ -398,9 +398,8 @@ void Texture2DGL::SetRect(int level, return; } - unsigned mip_width; - unsigned mip_height; - Bitmap::GetMipSize(level, width(), height(), &mip_width, &mip_height); + unsigned mip_width = Bitmap::GetMipDimension(level, width()); + unsigned mip_height = Bitmap::GetMipDimension(level, height()); if (dst_left + src_width > mip_width || dst_top + src_height > mip_height) { @@ -488,10 +487,9 @@ bool Texture2DGL::Lock(int level, void** data, int* pitch) { backing_bitmap_->Allocate(format(), width(), height(), levels(), false); } *data = backing_bitmap_->GetMipData(level); - unsigned int mip_width; - unsigned int mip_height; - Bitmap::GetMipSize(level, width(), height(), &mip_width, &mip_height); - if (IsCompressed()) { + unsigned int mip_width = Bitmap::GetMipDimension(level, width()); + unsigned int mip_height = Bitmap::GetMipDimension(level, height()); + if (!IsCompressed()) { *pitch = Bitmap::GetMipChainSize(mip_width, 1,format(), 1); } else { unsigned blocks_across = (mip_width + 3) / 4; @@ -778,10 +776,8 @@ void TextureCUBEGL::SetRect(TextureCUBE::CubeFace face, return; } - unsigned mip_width; - unsigned mip_height; - Bitmap::GetMipSize( - level, edge_length(), edge_length(), &mip_width, &mip_height); + unsigned mip_width = Bitmap::GetMipDimension(level, edge_length()); + unsigned mip_height = mip_width; if (dst_left + src_width > mip_width || dst_top + src_height > mip_height) { @@ -873,11 +869,8 @@ bool TextureCUBEGL::Lock(CubeFace face, int level, void** data, int* pitch) { levels(), true); } *data = backing_bitmap_->GetFaceMipData(face, level); - unsigned int mip_width; - unsigned int mip_height; - Bitmap::GetMipSize(level, edge_length(), edge_length(), - &mip_width, &mip_height); - if (IsCompressed()) { + unsigned int mip_width = Bitmap::GetMipDimension(level, edge_length()); + if (!IsCompressed()) { *pitch = Bitmap::GetMipChainSize(mip_width, 1,format(), 1); } else { unsigned blocks_across = (mip_width + 3) / 4; diff --git a/o3d/core/cross/message_queue.cc b/o3d/core/cross/message_queue.cc index 9e0f579..a7ff10f 100644 --- a/o3d/core/cross/message_queue.cc +++ b/o3d/core/cross/message_queue.cc @@ -590,11 +590,10 @@ bool MessageQueue::ProcessUpdateTexture2D(ConnectedClient* client, return false; } - unsigned int mip_width; - unsigned int mip_height; - Bitmap::GetMipSize(level, texture_object->width(), texture_object->height(), - &mip_width, &mip_height); - + unsigned int mip_width = + Bitmap::GetMipDimension(level, texture_object->width()); + unsigned int mip_height = + Bitmap::GetMipDimension(level, texture_object->height()); if (number_of_bytes != Bitmap::GetMipChainSize(mip_width, mip_height, texture_object->format(), 1)) { |