Added a helper function for generating pointer offsets and changed type names to…

Added a helper function for generating pointer offsets and changed type names to include size for clarity. TRAC #22705 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2160 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 4760c563
...@@ -23,6 +23,18 @@ Image::Image() ...@@ -23,6 +23,18 @@ Image::Image()
mActualFormat = GL_NONE; mActualFormat = GL_NONE;
} }
template <typename T>
inline static T *offsetDataPointer(void *data, int y, int z, int rowPitch, int depthPitch)
{
return reinterpret_cast<T*>(reinterpret_cast<unsigned char*>(data) + (y * rowPitch) + (z * depthPitch));
}
template <typename T>
inline static const T *offsetDataPointer(const void *data, int y, int z, int rowPitch, int depthPitch)
{
return reinterpret_cast<const T*>(reinterpret_cast<const unsigned char*>(data) + (y * rowPitch) + (z * depthPitch));
}
void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height, GLsizei depth, void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input, int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output) size_t outputRowPitch, size_t outputDepthPitch, void *output)
...@@ -34,8 +46,8 @@ void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -34,8 +46,8 @@ void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch; source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = 0; dest[4 * x + 0] = 0;
...@@ -58,8 +70,8 @@ void Image::loadAlphaDataToNative(GLsizei width, GLsizei height, GLsizei depth, ...@@ -58,8 +70,8 @@ void Image::loadAlphaDataToNative(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch; source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, width); memcpy(dest, source, width);
} }
} }
...@@ -76,8 +88,8 @@ void Image::loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei dept ...@@ -76,8 +88,8 @@ void Image::loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei dept
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = 0; dest[4 * x + 0] = 0;
...@@ -100,8 +112,8 @@ void Image::loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei ...@@ -100,8 +112,8 @@ void Image::loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = 0; dest[4 * x + 0] = 0;
...@@ -125,9 +137,8 @@ void Image::loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height, GLsiz ...@@ -125,9 +137,8 @@ void Image::loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height, GLsiz
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch; source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
if (!native) // BGRA8 destination format if (!native) // BGRA8 destination format
{ {
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
...@@ -157,8 +168,8 @@ void Image::loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei ...@@ -157,8 +168,8 @@ void Image::loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x]; dest[4 * x + 0] = source[x];
...@@ -181,8 +192,8 @@ void Image::loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height, GLsizei d ...@@ -181,8 +192,8 @@ void Image::loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height, GLsizei d
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[3 * x + 0] = source[x]; dest[3 * x + 0] = source[x];
...@@ -204,8 +215,8 @@ void Image::loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsi ...@@ -204,8 +215,8 @@ void Image::loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsi
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x]; dest[4 * x + 0] = source[x];
...@@ -229,8 +240,8 @@ void Image::loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height, ...@@ -229,8 +240,8 @@ void Image::loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch; source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
if (!native) // BGRA8 destination format if (!native) // BGRA8 destination format
{ {
...@@ -261,8 +272,8 @@ void Image::loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height, GLs ...@@ -261,8 +272,8 @@ void Image::loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height, GLs
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[2*x+0]; dest[4 * x + 0] = source[2*x+0];
...@@ -285,8 +296,8 @@ void Image::loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, ...@@ -285,8 +296,8 @@ void Image::loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[2*x+0]; dest[4 * x + 0] = source[2*x+0];
...@@ -309,8 +320,8 @@ void Image::loadRGBUByteDataToBGRX(GLsizei width, GLsizei height, GLsizei depth, ...@@ -309,8 +320,8 @@ void Image::loadRGBUByteDataToBGRX(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch; source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 2]; dest[4 * x + 0] = source[x * 3 + 2];
...@@ -333,8 +344,8 @@ void Image::loadRGBUByteDataToRGBA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -333,8 +344,8 @@ void Image::loadRGBUByteDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch; source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 0]; dest[4 * x + 0] = source[x * 3 + 0];
...@@ -357,8 +368,8 @@ void Image::loadRGB565DataToBGRA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -357,8 +368,8 @@ void Image::loadRGB565DataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -382,8 +393,8 @@ void Image::loadRGB565DataToRGBA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -382,8 +393,8 @@ void Image::loadRGB565DataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -407,8 +418,8 @@ void Image::loadRGBFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -407,8 +418,8 @@ void Image::loadRGBFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 0]; dest[4 * x + 0] = source[x * 3 + 0];
...@@ -431,8 +442,8 @@ void Image::loadRGBFloatDataToNative(GLsizei width, GLsizei height, GLsizei dept ...@@ -431,8 +442,8 @@ void Image::loadRGBFloatDataToNative(GLsizei width, GLsizei height, GLsizei dept
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, width * 12); memcpy(dest, source, width * 12);
} }
} }
...@@ -449,8 +460,8 @@ void Image::loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei de ...@@ -449,8 +460,8 @@ void Image::loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei de
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 0]; dest[4 * x + 0] = source[x * 3 + 0];
...@@ -473,8 +484,8 @@ void Image::loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height, GLsizei depth ...@@ -473,8 +484,8 @@ void Image::loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height, GLsizei depth
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
...@@ -496,8 +507,8 @@ void Image::loadRGBAUByteDataToNative(GLsizei width, GLsizei height, GLsizei dep ...@@ -496,8 +507,8 @@ void Image::loadRGBAUByteDataToNative(GLsizei width, GLsizei height, GLsizei dep
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, width * 4); memcpy(dest, source, width * 4);
} }
...@@ -515,8 +526,8 @@ void Image::loadRGBA4444DataToBGRA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -515,8 +526,8 @@ void Image::loadRGBA4444DataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -540,8 +551,8 @@ void Image::loadRGBA4444DataToRGBA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -540,8 +551,8 @@ void Image::loadRGBA4444DataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -565,8 +576,8 @@ void Image::loadRGBA5551DataToBGRA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -565,8 +576,8 @@ void Image::loadRGBA5551DataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -590,8 +601,8 @@ void Image::loadRGBA5551DataToRGBA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -590,8 +601,8 @@ void Image::loadRGBA5551DataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -615,8 +626,8 @@ void Image::loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth ...@@ -615,8 +626,8 @@ void Image::loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch); source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch); dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, width * 16); memcpy(dest, source, width * 16);
} }
} }
...@@ -633,8 +644,8 @@ void Image::loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei d ...@@ -633,8 +644,8 @@ void Image::loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei d
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch; source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, width * 8); memcpy(dest, source, width * 8);
} }
} }
...@@ -651,8 +662,8 @@ void Image::loadBGRADataToBGRA(GLsizei width, GLsizei height, GLsizei depth, ...@@ -651,8 +662,8 @@ void Image::loadBGRADataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch; source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch; dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, width*4); memcpy(dest, source, width*4);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment