OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 unsigned mip_height = image::ComputeMipDimension(level, height()); | 139 unsigned mip_height = image::ComputeMipDimension(level, height()); |
140 DCHECK(dst_left + src_width <= mip_width && | 140 DCHECK(dst_left + src_width <= mip_width && |
141 dst_top + src_height <= mip_height); | 141 dst_top + src_height <= mip_height); |
142 bool compressed = Texture::IsCompressedFormat(format()); | 142 bool compressed = Texture::IsCompressedFormat(format()); |
143 bool entire_rect = dst_left == 0 && dst_top == 0 && | 143 bool entire_rect = dst_left == 0 && dst_top == 0 && |
144 src_width == mip_width && src_height == mip_height; | 144 src_width == mip_width && src_height == mip_height; |
145 DCHECK(!compressed || entire_rect); | 145 DCHECK(!compressed || entire_rect); |
146 | 146 |
147 uint8* dst = | 147 uint8* dst = |
148 GetMipData(level) + | 148 GetMipData(level) + |
149 image::ComputeMipChainSize(mip_width, dst_top, format(), 1) + | 149 image::ComputePitch(format(), mip_width) * dst_top + |
150 image::ComputeMipChainSize(dst_left, 1, format(), 1); | 150 image::ComputePitch(format(), dst_left); |
151 | 151 |
152 const uint8* src = static_cast<const uint8*>(src_data); | 152 const uint8* src = static_cast<const uint8*>(src_data); |
153 if (!compressed) { | 153 if (!compressed) { |
154 unsigned bytes_per_line = image::ComputePitch(format(), src_width); | 154 unsigned bytes_per_line = image::ComputePitch(format(), src_width); |
155 int dst_pitch = image::ComputePitch(format(), mip_width); | 155 int dst_pitch = image::ComputePitch(format(), mip_width); |
156 for (unsigned yy = 0; yy < src_height; ++yy) { | 156 for (unsigned yy = 0; yy < src_height; ++yy) { |
157 memcpy(dst, src, bytes_per_line); | 157 memcpy(dst, src, bytes_per_line); |
158 src += src_pitch; | 158 src += src_pitch; |
159 dst += dst_pitch; | 159 dst += dst_pitch; |
160 } | 160 } |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 return false; | 559 return false; |
560 } | 560 } |
561 return true; | 561 return true; |
562 } | 562 } |
563 | 563 |
564 ObjectBase::Ref Bitmap::Create(ServiceLocator* service_locator) { | 564 ObjectBase::Ref Bitmap::Create(ServiceLocator* service_locator) { |
565 return ObjectBase::Ref(new Bitmap(service_locator)); | 565 return ObjectBase::Ref(new Bitmap(service_locator)); |
566 } | 566 } |
567 | 567 |
568 } // namespace o3d | 568 } // namespace o3d |
OLD | NEW |