Clean up PackPixels.
BUG=angleproject:1455
Change-Id: I263719cc77ff80580a551683d062e862dee1bdab
Reviewed-on: https://chromium-review.googlesource.com/365826
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/renderer_utils.cpp b/src/libANGLE/renderer/renderer_utils.cpp
index 140182e..fad6d6b 100644
--- a/src/libANGLE/renderer/renderer_utils.cpp
+++ b/src/libANGLE/renderer/renderer_utils.cpp
@@ -13,6 +13,7 @@
#include "image_util/imageformats.h"
#include "libANGLE/formatutils.h"
+#include "libANGLE/renderer/Format.h"
#include <string.h>
@@ -170,9 +171,8 @@
}
void PackPixels(const PackPixelsParams ¶ms,
- const gl::InternalFormat &sourceFormatInfo,
+ const angle::Format &sourceFormat,
const FastCopyFunctionMap &fastCopyFunctionsMap,
- ColorReadFunction colorReadFunction,
int inputPitchIn,
const uint8_t *sourceIn,
uint8_t *destWithoutOffset)
@@ -188,18 +188,20 @@
inputPitch = -inputPitch;
}
- if (sourceFormatInfo.format == params.format && sourceFormatInfo.type == params.type)
+ const auto &sourceGLInfo = gl::GetInternalFormatInfo(sourceFormat.glInternalFormat);
+
+ if (sourceGLInfo.format == params.format && sourceGLInfo.type == params.type)
{
// Direct copy possible
for (int y = 0; y < params.area.height; ++y)
{
memcpy(destWithOffset + y * params.outputPitch, source + y * inputPitch,
- params.area.width * sourceFormatInfo.pixelBytes);
+ params.area.width * sourceGLInfo.pixelBytes);
}
return;
}
- ASSERT(sourceFormatInfo.pixelBytes > 0);
+ ASSERT(sourceGLInfo.pixelBytes > 0);
gl::FormatType formatType(params.format, params.type);
ColorCopyFunction fastCopyFunc = GetFastCopyFunction(fastCopyFunctionsMap, formatType);
@@ -215,7 +217,7 @@
{
uint8_t *dest =
destWithOffset + y * params.outputPitch + x * destFormatInfo.pixelBytes;
- const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
+ const uint8_t *src = source + y * inputPitch + x * sourceGLInfo.pixelBytes;
fastCopyFunc(src, dest);
}
@@ -231,12 +233,14 @@
sizeof(temp) >= sizeof(gl::ColorI),
"Unexpected size of gl::Color struct.");
+ const auto &colorReadFunction = sourceFormat.colorReadFunction;
+
for (int y = 0; y < params.area.height; ++y)
{
for (int x = 0; x < params.area.width; ++x)
{
uint8_t *dest = destWithOffset + y * params.outputPitch + x * destFormatInfo.pixelBytes;
- const uint8_t *src = source + y * inputPitch + x * sourceFormatInfo.pixelBytes;
+ const uint8_t *src = source + y * inputPitch + x * sourceGLInfo.pixelBytes;
// readFunc and writeFunc will be using the same type of color, CopyTexImage
// will not allow the copy otherwise.