Clean up the functions in loadimage.h/cpp.
* Capitalize the function names to fit the style guide.
* Use explicit sizes in the function names to avoid any confusion about
input or output sizes.
* Use explicit sized types in the functions to avoid potential issues on
new platforms since a lot of bit-twiddling is used.
* Use size_t for all sizes.
* Use uint8_t for all binary data for input and output data so that pointer
arithmetic is much easier.
* Move templated function definitions into an .inl file so that
loadimage.h looks as clean as possible.
BUG=angle:665
Change-Id: Id7173ed66d9e1b7ee3261eea11e77d838cbd2951
Reviewed-on: https://chromium-review.googlesource.com/202590
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/renderer/loadimage.cpp b/src/libGLESv2/renderer/loadimage.cpp
index 62870c5..4a29460 100644
--- a/src/libGLESv2/renderer/loadimage.cpp
+++ b/src/libGLESv2/renderer/loadimage.cpp
@@ -1,6 +1,6 @@
#include "precompiled.h"
//
-// Copyright (c) 0013 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -12,20 +12,64 @@
namespace rx
{
-void loadAlphaDataToBGRA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadA8ToRGBA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
+ {
+ dest[x] = static_cast<uint32_t>(source[x]) << 24;
+ }
+ }
+ }
+}
+
+void LoadA8ToBGRA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
+{
+ // Same as loading to RGBA
+ LoadA8ToRGBA8(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
+}
+
+void LoadA32FToRGBA32F(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
+{
+ for (size_t z = 0; z < depth; z++)
+ {
+ for (size_t y = 0; y < height; y++)
+ {
+ const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
+ float *dest = OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
+ {
+ dest[4 * x + 0] = 0.0f;
+ dest[4 * x + 1] = 0.0f;
+ dest[4 * x + 2] = 0.0f;
+ dest[4 * x + 3] = source[x];
+ }
+ }
+ }
+}
+
+void LoadA16FToRGBA16F(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
+{
+ for (size_t z = 0; z < depth; z++)
+ {
+ for (size_t y = 0; y < height; y++)
+ {
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = 0;
dest[4 * x + 1] = 0;
@@ -36,104 +80,17 @@
}
}
-void loadAlphaDataToNative(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadL8ToRGBA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- memcpy(dest, source, width);
- }
- }
-}
-
-void loadAlphaFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const float *source = NULL;
- float *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
- {
- dest[4 * x + 0] = 0;
- dest[4 * x + 1] = 0;
- dest[4 * x + 2] = 0;
- dest[4 * x + 3] = source[x];
- }
- }
- }
-}
-
-void loadAlphaHalfFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned short *source = NULL;
- unsigned short *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
- {
- dest[4 * x + 0] = 0;
- dest[4 * x + 1] = 0;
- dest[4 * x + 2] = 0;
- dest[4 * x + 3] = source[x];
- }
- }
- }
-}
-
-void loadLuminanceDataToNative(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- memcpy(dest, source, width);
- }
- }
-}
-
-void loadLuminanceDataToBGRA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = source[x];
dest[4 * x + 1] = source[x];
@@ -144,20 +101,25 @@
}
}
-void loadLuminanceFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadL8ToBGRA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const float *source = NULL;
- float *dest = NULL;
+ // Same as loading to RGBA
+ LoadL8ToRGBA8(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
+}
- for (int z = 0; z < depth; z++)
+void LoadL32FToRGBA32F(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
+{
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
+ float *dest = OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = source[x];
dest[4 * x + 1] = source[x];
@@ -168,43 +130,17 @@
}
}
-void loadLuminanceFloatDataToRGB(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadL16FToRGBA16F(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const float *source = NULL;
- float *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
- {
- dest[3 * x + 0] = source[x];
- dest[3 * x + 1] = source[x];
- dest[3 * x + 2] = source[x];
- }
- }
- }
-}
-
-void loadLuminanceHalfFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned short *source = NULL;
- unsigned short *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = source[x];
dest[4 * x + 1] = source[x];
@@ -215,112 +151,88 @@
}
}
-void loadLuminanceAlphaDataToNative(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadLA8ToRGBA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
-
- memcpy(dest, source, width * 2);
- }
- }
-}
-
-void loadLuminanceAlphaDataToBGRA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
+ const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- dest[4 * x + 0] = source[2*x+0];
- dest[4 * x + 1] = source[2*x+0];
- dest[4 * x + 2] = source[2*x+0];
- dest[4 * x + 3] = source[2*x+1];
+ dest[4 * x + 0] = source[2 * x + 0];
+ dest[4 * x + 1] = source[2 * x + 0];
+ dest[4 * x + 2] = source[2 * x + 0];
+ dest[4 * x + 3] = source[2 * x + 1];
}
}
}
}
-void loadLuminanceAlphaFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadLA8ToBGRA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const float *source = NULL;
- float *dest = NULL;
+ // Same as loading to RGBA
+ LoadLA8ToRGBA8(width, height, depth, input, inputRowPitch, inputDepthPitch, output, outputRowPitch, outputDepthPitch);
+}
- for (int z = 0; z < depth; z++)
+void LoadLA32FToRGBA32F(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
+{
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
+ float *dest = OffsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- dest[4 * x + 0] = source[2*x+0];
- dest[4 * x + 1] = source[2*x+0];
- dest[4 * x + 2] = source[2*x+0];
- dest[4 * x + 3] = source[2*x+1];
+ dest[4 * x + 0] = source[2 * x + 0];
+ dest[4 * x + 1] = source[2 * x + 0];
+ dest[4 * x + 2] = source[2 * x + 0];
+ dest[4 * x + 3] = source[2 * x + 1];
}
}
}
}
-void loadLuminanceAlphaHalfFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadLA16FToRGBA16F(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned short *source = NULL;
- unsigned short *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- dest[4 * x + 0] = source[2*x+0];
- dest[4 * x + 1] = source[2*x+0];
- dest[4 * x + 2] = source[2*x+0];
- dest[4 * x + 3] = source[2*x+1];
+ dest[4 * x + 0] = source[2 * x + 0];
+ dest[4 * x + 1] = source[2 * x + 0];
+ dest[4 * x + 2] = source[2 * x + 0];
+ dest[4 * x + 3] = source[2 * x + 1];
}
}
}
}
-void loadRGBUByteDataToBGRX(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRGB8ToBGRX8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = source[x * 3 + 2];
dest[4 * x + 1] = source[x * 3 + 1];
@@ -331,20 +243,17 @@
}
}
-void loadRGUByteDataToBGRX(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRG8ToBGRX8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = 0x00;
dest[4 * x + 1] = source[x * 2 + 1];
@@ -355,20 +264,17 @@
}
}
-void loadRUByteDataToBGRX(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadR8ToBGRX8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[4 * x + 0] = 0x00;
dest[4 * x + 1] = 0x00;
@@ -379,228 +285,82 @@
}
}
-void loadRGBUByteDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadR5G6B5ToBGRA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- dest[4 * x + 0] = source[x * 3 + 0];
- dest[4 * x + 1] = source[x * 3 + 1];
- dest[4 * x + 2] = source[x * 3 + 2];
+ uint16_t rgb = source[x];
+ dest[4 * x + 0] = ((rgb & 0x001F) << 3) | ((rgb & 0x001F) >> 2);
+ dest[4 * x + 1] = ((rgb & 0x07E0) >> 3) | ((rgb & 0x07E0) >> 9);
+ dest[4 * x + 2] = ((rgb & 0xF800) >> 8) | ((rgb & 0xF800) >> 13);
dest[4 * x + 3] = 0xFF;
}
}
}
}
-void loadRGBSByteDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadR5G6B5ToRGBA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const char *source = NULL;
- char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- dest[4 * x + 0] = source[x * 3 + 0];
- dest[4 * x + 1] = source[x * 3 + 1];
- dest[4 * x + 2] = source[x * 3 + 2];
- dest[4 * x + 3] = 0x7F;
- }
- }
- }
-}
-
-void loadRGB565DataToBGRA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned short *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
- {
- unsigned short rgba = source[x];
- dest[4 * x + 0] = ((rgba & 0x001F) << 3) | ((rgba & 0x001F) >> 2);
- dest[4 * x + 1] = ((rgba & 0x07E0) >> 3) | ((rgba & 0x07E0) >> 9);
- dest[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
+ uint16_t rgb = source[x];
+ dest[4 * x + 0] = ((rgb & 0xF800) >> 8) | ((rgb & 0xF800) >> 13);
+ dest[4 * x + 1] = ((rgb & 0x07E0) >> 3) | ((rgb & 0x07E0) >> 9);
+ dest[4 * x + 2] = ((rgb & 0x001F) << 3) | ((rgb & 0x001F) >> 2);
dest[4 * x + 3] = 0xFF;
}
}
}
}
-void loadRGB565DataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRGBA8ToBGRA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned short *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- unsigned short rgba = source[x];
- dest[4 * x + 0] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
- dest[4 * x + 1] = ((rgba & 0x07E0) >> 3) | ((rgba & 0x07E0) >> 9);
- dest[4 * x + 2] = ((rgba & 0x001F) << 3) | ((rgba & 0x001F) >> 2);
- dest[4 * x + 3] = 0xFF;
- }
- }
- }
-}
-
-void loadRGBFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const float *source = NULL;
- float *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
- {
- dest[4 * x + 0] = source[x * 3 + 0];
- dest[4 * x + 1] = source[x * 3 + 1];
- dest[4 * x + 2] = source[x * 3 + 2];
- dest[4 * x + 3] = 1.0f;
- }
- }
- }
-}
-
-void loadRGBFloatDataToNative(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const float *source = NULL;
- float *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- memcpy(dest, source, width * 12);
- }
- }
-}
-
-void loadRGBHalfFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned short *source = NULL;
- unsigned short *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
- {
- dest[4 * x + 0] = source[x * 3 + 0];
- dest[4 * x + 1] = source[x * 3 + 1];
- dest[4 * x + 2] = source[x * 3 + 2];
- dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1
- }
- }
- }
-}
-
-void loadRGBAUByteDataToBGRA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned int *source = NULL;
- unsigned int *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
- {
- unsigned int rgba = source[x];
+ uint32_t rgba = source[x];
dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
}
}
}
}
-void loadRGBAUByteDataToNative(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRGBA4ToBGRA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned int *source = NULL;
- unsigned int *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
-
- memcpy(dest, source, width * 4);
- }
- }
-}
-
-void loadRGBA4444DataToBGRA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned short *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- unsigned short rgba = source[x];
+ uint16_t rgba = source[x];
dest[4 * x + 0] = ((rgba & 0x00F0) << 0) | ((rgba & 0x00F0) >> 4);
dest[4 * x + 1] = ((rgba & 0x0F00) >> 4) | ((rgba & 0x0F00) >> 8);
dest[4 * x + 2] = ((rgba & 0xF000) >> 8) | ((rgba & 0xF000) >> 12);
@@ -610,22 +370,19 @@
}
}
-void loadRGBA4444DataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRGBA4ToRGBA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned short *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- unsigned short rgba = source[x];
+ uint16_t rgba = source[x];
dest[4 * x + 0] = ((rgba & 0xF000) >> 8) | ((rgba & 0xF000) >> 12);
dest[4 * x + 1] = ((rgba & 0x0F00) >> 4) | ((rgba & 0x0F00) >> 8);
dest[4 * x + 2] = ((rgba & 0x00F0) << 0) | ((rgba & 0x00F0) >> 4);
@@ -635,22 +392,41 @@
}
}
-void loadRGBA5551DataToBGRA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadBGRA4ToBGRA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned short *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- unsigned short rgba = source[x];
+ uint16_t bgra = source[x];
+ dest[4 * x + 0] = ((bgra & 0xF000) >> 8) | ((bgra & 0xF000) >> 12);
+ dest[4 * x + 1] = ((bgra & 0x0F00) >> 4) | ((bgra & 0x0F00) >> 8);
+ dest[4 * x + 2] = ((bgra & 0x00F0) << 0) | ((bgra & 0x00F0) >> 4);
+ dest[4 * x + 3] = ((bgra & 0x000F) << 4) | ((bgra & 0x000F) >> 0);
+ }
+ }
+ }
+}
+
+void LoadRGB5A1ToBGRA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
+{
+ for (size_t z = 0; z < depth; z++)
+ {
+ for (size_t y = 0; y < height; y++)
+ {
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
+ {
+ uint16_t rgba = source[x];
dest[4 * x + 0] = ((rgba & 0x003E) << 2) | ((rgba & 0x003E) >> 3);
dest[4 * x + 1] = ((rgba & 0x07C0) >> 3) | ((rgba & 0x07C0) >> 8);
dest[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
@@ -659,22 +435,20 @@
}
}
}
-void loadRGBA5551DataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned short *source = NULL;
- unsigned char *dest = NULL;
- for (int z = 0; z < depth; z++)
+void LoadRGB5A1ToRGBA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
+{
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- unsigned short rgba = source[x];
+ uint16_t rgba = source[x];
dest[4 * x + 0] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13);
dest[4 * x + 1] = ((rgba & 0x07C0) >> 3) | ((rgba & 0x07C0) >> 8);
dest[4 * x + 2] = ((rgba & 0x003E) << 2) | ((rgba & 0x003E) >> 3);
@@ -684,95 +458,42 @@
}
}
-void loadRGBAFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+
+void LoadBGR5A1ToBGRA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const float *source = NULL;
- float *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<float>(output, y, z, outputRowPitch, outputDepthPitch);
- memcpy(dest, source, width * 16);
- }
- }
-}
-
-void loadRGBAHalfFloatDataToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- memcpy(dest, source, width * 8);
- }
- }
-}
-
-void loadBGRADataToBGRA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned char *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned char>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
- memcpy(dest, source, width*4);
- }
- }
-}
-
-void loadRGBA2101010ToNative(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned int *source = NULL;
- unsigned int *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
- memcpy(dest, source, width * sizeof(unsigned int));
- }
- }
-}
-
-void loadRGBA2101010ToRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
-{
- const unsigned int *source = NULL;
- unsigned char *dest = NULL;
-
- for (int z = 0; z < depth; z++)
- {
- for (int y = 0; y < height; y++)
- {
- source = offsetDataPointer<unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned char>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- unsigned int rgba = source[x];
+ uint16_t bgra = source[x];
+ dest[4 * x + 0] = ((bgra & 0xF800) >> 8) | ((bgra & 0xF800) >> 13);
+ dest[4 * x + 1] = ((bgra & 0x07C0) >> 3) | ((bgra & 0x07C0) >> 8);
+ dest[4 * x + 2] = ((bgra & 0x003E) << 2) | ((bgra & 0x003E) >> 3);
+ dest[4 * x + 3] = (bgra & 0x0001) ? 0xFF : 0;
+ }
+ }
+ }
+}
+
+void LoadRGB10A2ToRGBA8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
+{
+ for (size_t z = 0; z < depth; z++)
+ {
+ for (size_t y = 0; y < height; y++)
+ {
+ const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
+ {
+ uint32_t rgba = source[x];
dest[4 * x + 0] = (rgba & 0x000003FF) >> 2;
dest[4 * x + 1] = (rgba & 0x000FFC00) >> 12;
dest[4 * x + 2] = (rgba & 0x3FF00000) >> 22;
@@ -782,21 +503,17 @@
}
}
-void loadRGBHalfFloatDataTo999E5(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRGB16FToRGB9E5(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned short *source = NULL;
- unsigned int *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[x] = gl::convertRGBFloatsTo999E5(gl::float16ToFloat32(source[x * 3 + 0]),
gl::float16ToFloat32(source[x * 3 + 1]),
@@ -806,21 +523,17 @@
}
}
-void loadRGBFloatDataTo999E5(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRGB32FToRGB9E5(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const float *source = NULL;
- unsigned int *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
+ const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[x] = gl::convertRGBFloatsTo999E5(source[x * 3 + 0], source[x * 3 + 1], source[x * 3 + 2]);
}
@@ -828,21 +541,17 @@
}
}
-void loadRGBHalfFloatDataTo111110Float(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRGB16FToRG11B10F(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned short *source = NULL;
- unsigned int *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned short>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
+ const uint16_t *source = OffsetDataPointer<uint16_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[x] = (gl::float32ToFloat11(gl::float16ToFloat32(source[x * 3 + 0])) << 0) |
(gl::float32ToFloat11(gl::float16ToFloat32(source[x * 3 + 1])) << 11) |
@@ -852,21 +561,17 @@
}
}
-void loadRGBFloatDataTo111110Float(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRGB32FToRG11B10F(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const float *source = NULL;
- unsigned int *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
+ const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[x] = (gl::float32ToFloat11(source[x * 3 + 0]) << 0) |
(gl::float32ToFloat11(source[x * 3 + 1]) << 11) |
@@ -876,46 +581,37 @@
}
}
-
-void loadG8R24DataToR24G8(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadG8R24ToR24G8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned int *source = NULL;
- unsigned int *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<const unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
+ const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
- unsigned int d = source[x] >> 8;
- unsigned int s = source[x] & 0xFF;
+ uint32_t d = source[x] >> 8;
+ uint8_t s = source[x] & 0xFF;
dest[x] = d | (s << 24);
}
}
}
}
-void loadFloatRGBDataToHalfFloatRGBA(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadRGB32FToRGBA16F(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const float *source = NULL;
- unsigned short *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
+ const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[x * 4 + 0] = gl::float32ToFloat16(source[x * 3 + 0]);
dest[x * 4 + 1] = gl::float32ToFloat16(source[x * 3 + 1]);
@@ -926,21 +622,17 @@
}
}
-void loadUintDataToUshort(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadR32ToR16(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned int *source = NULL;
- unsigned short *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned short>(output, y, z, outputRowPitch, outputDepthPitch);
-
- for (int x = 0; x < width; x++)
+ const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
+ for (size_t x = 0; x < width; x++)
{
dest[x] = source[x] >> 16;
}
@@ -948,21 +640,18 @@
}
}
-void loadUintDataToUint24X8(int width, int height, int depth,
- const void *input, unsigned int inputRowPitch, unsigned int inputDepthPitch,
- void *output, unsigned int outputRowPitch, unsigned int outputDepthPitch)
+void LoadR32ToR24G8(size_t width, size_t height, size_t depth,
+ const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
+ uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch)
{
- const unsigned int *source = NULL;
- unsigned int *dest = NULL;
-
- for (int z = 0; z < depth; z++)
+ for (size_t z = 0; z < depth; z++)
{
- for (int y = 0; y < height; y++)
+ for (size_t y = 0; y < height; y++)
{
- source = offsetDataPointer<const unsigned int>(input, y, z, inputRowPitch, inputDepthPitch);
- dest = offsetDataPointer<unsigned int>(output, y, z, outputRowPitch, outputDepthPitch);
+ const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
+ uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
- for (int x = 0; x < width; x++)
+ for (size_t x = 0; x < width; x++)
{
dest[x] = source[x] >> 8;
}