| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Gets the number of mip-maps required for a full chain starting at | 72 // Gets the number of mip-maps required for a full chain starting at |
| 73 // width x height. | 73 // width x height. |
| 74 inline unsigned int ComputeMipMapCount( | 74 inline unsigned int ComputeMipMapCount( |
| 75 unsigned int width, unsigned int height) { | 75 unsigned int width, unsigned int height) { |
| 76 return 1 + base::bits::Log2Floor(std::max(width, height)); | 76 return 1 + base::bits::Log2Floor(std::max(width, height)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Gets the smallest power-of-two value that is at least as high as | 79 // Gets the smallest power-of-two value that is at least as high as |
| 80 // dimension. This is the POT dimension used in ScaleUpToPOT. | 80 // dimension. This is the POT dimension used in ScaleUpToPOT. |
| 81 inline unsigned int ComputePOTSize(unsigned int dimension) { | 81 inline unsigned int ComputePOTSize(unsigned int dimension) { |
| 82 return 1 << base::bits::Log2Ceiling(dimension); | 82 return (dimension == 0) ? 0 : 1 << base::bits::Log2Ceiling(dimension); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Computes one dimension of a mip. | 85 // Computes one dimension of a mip. |
| 86 inline unsigned ComputeMipDimension(int level, unsigned dimension) { | 86 inline unsigned ComputeMipDimension(int level, unsigned dimension) { |
| 87 unsigned v = dimension >> level; | 87 unsigned v = dimension >> level; |
| 88 return v > 0 ? v : 1u; | 88 return v > 0 ? v : 1u; |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Computes the size of the buffer containing a mip-map chain, given its base | 91 // Computes the size of the buffer containing a mip-map chain, given its base |
| 92 // width, height, format and number of mip-map levels. | 92 // width, height, format and number of mip-map levels. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 int* src_pitch, | 279 int* src_pitch, |
| 280 int* dst_y, | 280 int* dst_y, |
| 281 int dst_width, | 281 int dst_width, |
| 282 int* dst_height); | 282 int* dst_height); |
| 283 | 283 |
| 284 } // namespace image | 284 } // namespace image |
| 285 } // namespace o3d | 285 } // namespace o3d |
| 286 | 286 |
| 287 #endif // O3D_CORE_CROSS_IMAGE_UTILS_H_ | 287 #endif // O3D_CORE_CROSS_IMAGE_UTILS_H_ |
| 288 | 288 |
| OLD | NEW |