Commit 6e4cfceb by Geoff Lang Committed by Commit Bot

Refactor ANGLE's image manipulation code into a static library.

Allows for chromium to make use of some of the functionality. BUG=612205 Change-Id: Ib4435ca44775a3a554b0fb3bd384bd4d31d7952d Reviewed-on: https://chromium-review.googlesource.com/351753Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 91d56945
...@@ -150,6 +150,29 @@ static_library("angle_common") { ...@@ -150,6 +150,29 @@ static_library("angle_common") {
] ]
} }
config("angle_image_util_config") {
include_dirs = [
"include",
"src",
]
}
source_set("angle_image_util") {
sources = rebase_path(gles_gypi.libangle_image_util_sources, ".", "src")
configs -= angle_undefine_configs
configs += [
":internal_config",
"//build/config/compiler:no_chromium_code",
]
public_configs = [ ":angle_image_util_config" ]
public_deps = [
":angle_common",
]
}
static_library("translator_lib") { static_library("translator_lib") {
sources = rebase_path(compiler_gypi.angle_translator_lib_sources, ".", "src") sources = rebase_path(compiler_gypi.angle_translator_lib_sources, ".", "src")
defines = [] defines = []
...@@ -292,6 +315,7 @@ static_library("libANGLE") { ...@@ -292,6 +315,7 @@ static_library("libANGLE") {
":angle_common", ":angle_common",
] ]
deps = [ deps = [
":angle_image_util",
":commit_id", ":commit_id",
":includes", ":includes",
":translator_static", ":translator_static",
......
...@@ -143,6 +143,33 @@ ...@@ -143,6 +143,33 @@
}, },
{ {
'target_name': 'angle_image_util',
'type': 'static_library',
'includes': [ '../build/common_defines.gypi', ],
'sources':
[
'<@(libangle_image_util_sources)',
],
'include_dirs':
[
'.',
'../include',
],
'dependencies':
[
'angle_common',
],
'direct_dependent_settings':
{
'include_dirs':
[
'<(angle_path)/include',
'<(angle_path)/src',
],
},
},
{
'target_name': 'copy_scripts', 'target_name': 'copy_scripts',
'type': 'none', 'type': 'none',
'includes': [ '../build/common_defines.gypi', ], 'includes': [ '../build/common_defines.gypi', ],
......
//
// Copyright (c) 2016 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.
//
// Color.h : Defines the Color type used throughout the ANGLE libraries
#ifndef COMMON_COLOR_H_
#define COMMON_COLOR_H_
namespace angle
{
template <typename T>
struct Color
{
T red;
T green;
T blue;
T alpha;
Color();
Color(T r, T g, T b, T a);
};
template <typename T>
bool operator==(const Color<T> &a, const Color<T> &b);
template <typename T>
bool operator!=(const Color<T> &a, const Color<T> &b);
typedef Color<float> ColorF;
typedef Color<int> ColorI;
typedef Color<unsigned int> ColorUI;
} // namespace angle
// TODO: Move this fully into the angle namespace
namespace gl
{
template <typename T>
using Color = angle::Color<T>;
using ColorF = angle::ColorF;
using ColorI = angle::ColorI;
using ColorUI = angle::ColorUI;
} // namespace gl
#include "Color.inl"
#endif // COMMON_COLOR_H_
//
// Copyright (c) 2016 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.
//
// Color.inl : Inline definitions of some functions from Color.h
namespace angle
{
template <typename T>
Color<T>::Color() : Color(0, 0, 0, 0)
{
}
template <typename T>
Color<T>::Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a)
{
}
template <typename T>
bool operator==(const Color<T> &a, const Color<T> &b)
{
return a.red == b.red &&
a.green == b.green &&
a.blue == b.blue &&
a.alpha == b.alpha;
}
template <typename T>
bool operator!=(const Color<T> &a, const Color<T> &b)
{
return !(a == b);
}
} // namespace angle
...@@ -798,8 +798,8 @@ inline uint16_t RotR16(uint16_t x, int8_t r) ...@@ -798,8 +798,8 @@ inline uint16_t RotR16(uint16_t x, int8_t r)
return (x >> r) | (x << (16 - r)); return (x >> r) | (x << (16 - r));
} }
#define ANGLE_ROTL(x,y) RotL(x,y) #define ANGLE_ROTL(x, y) ::rx::RotL(x, y)
#define ANGLE_ROTR16(x,y) RotR16(x,y) #define ANGLE_ROTR16(x, y) ::rx::RotR16(x, y)
#endif // namespace rx #endif // namespace rx
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
// copyimage.cpp: Defines image copying functions // copyimage.cpp: Defines image copying functions
#include "libANGLE/renderer/copyimage.h" #include "image_util/copyimage.h"
namespace rx namespace angle
{ {
void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest) void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest)
...@@ -19,4 +19,4 @@ void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest) ...@@ -19,4 +19,4 @@ void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest)
(argb & 0x000000FF) << 16; // Move blue to red (argb & 0x000000FF) << 16; // Move blue to red
} }
} // namespace rx } // namespace angle
...@@ -6,15 +6,16 @@ ...@@ -6,15 +6,16 @@
// copyimage.h: Defines image copying functions // copyimage.h: Defines image copying functions
#ifndef LIBANGLE_RENDERER_D3D_COPYIMAGE_H_ #ifndef IMAGEUTIL_COPYIMAGE_H_
#define LIBANGLE_RENDERER_D3D_COPYIMAGE_H_ #define IMAGEUTIL_COPYIMAGE_H_
#include "common/mathutil.h" #include "common/Color.h"
#include "libANGLE/angletypes.h"
#include "image_util/imageformats.h"
#include <stdint.h> #include <stdint.h>
namespace rx namespace angle
{ {
template <typename sourceType, typename colorDataType> template <typename sourceType, typename colorDataType>
...@@ -28,8 +29,8 @@ void CopyPixel(const uint8_t *source, uint8_t *dest); ...@@ -28,8 +29,8 @@ void CopyPixel(const uint8_t *source, uint8_t *dest);
void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest); void CopyBGRA8ToRGBA8(const uint8_t *source, uint8_t *dest);
} // namespace rx } // namespace angle
#include "copyimage.inl" #include "copyimage.inl"
#endif // LIBANGLE_RENDERER_D3D_COPYIMAGE_H_ #endif // IMAGEUTIL_COPYIMAGE_H_
...@@ -6,19 +6,21 @@ ...@@ -6,19 +6,21 @@
// copyimage.inl: Defines image copying functions // copyimage.inl: Defines image copying functions
namespace rx namespace angle
{ {
template <typename sourceType, typename colorDataType> template <typename sourceType, typename colorDataType>
inline void ReadColor(const uint8_t *source, uint8_t *dest) inline void ReadColor(const uint8_t *source, uint8_t *dest)
{ {
sourceType::readColor(reinterpret_cast<gl::Color<colorDataType>*>(dest), reinterpret_cast<const sourceType*>(source)); sourceType::readColor(reinterpret_cast<Color<colorDataType>*>(dest),
reinterpret_cast<const sourceType*>(source));
} }
template <typename destType, typename colorDataType> template <typename destType, typename colorDataType>
inline void WriteColor(const uint8_t *source, uint8_t *dest) inline void WriteColor(const uint8_t *source, uint8_t *dest)
{ {
destType::writeColor(reinterpret_cast<destType*>(dest), reinterpret_cast<const gl::Color<colorDataType>*>(source)); destType::writeColor(reinterpret_cast<destType*>(dest),
reinterpret_cast<const Color<colorDataType>*>(source));
} }
template <typename sourceType, typename destType, typename colorDataType> template <typename sourceType, typename destType, typename colorDataType>
...@@ -29,4 +31,4 @@ inline void CopyPixel(const uint8_t *source, uint8_t *dest) ...@@ -29,4 +31,4 @@ inline void CopyPixel(const uint8_t *source, uint8_t *dest)
WriteColor<destType, colorDataType>(&temp, dest); WriteColor<destType, colorDataType>(&temp, dest);
} }
} } // namespace angle
//
// Copyright (c) 2002-2015 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.
//
// generatemip.h: Defines the GenerateMip function, templated on the format
// type of the image for which mip levels are being generated.
#ifndef IMAGEUTIL_GENERATEMIP_H_
#define IMAGEUTIL_GENERATEMIP_H_
#include <stddef.h>
#include <stdint.h>
namespace angle
{
template <typename T>
inline void GenerateMip(size_t sourceWidth,
size_t sourceHeight,
size_t sourceDepth,
const uint8_t *sourceData,
size_t sourceRowPitch,
size_t sourceDepthPitch,
uint8_t *destData,
size_t destRowPitch,
size_t destDepthPitch);
} // namespace angle
#include "generatemip.inl"
#endif // IMAGEUTIL_GENERATEMIP_H_
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include "common/mathutil.h" #include "common/mathutil.h"
namespace rx #include "image_util/imageformats.h"
namespace angle
{ {
namespace priv namespace priv
...@@ -245,7 +247,7 @@ static MipGenerationFunction GetMipGenerationFunction(size_t sourceWidth, size_t ...@@ -245,7 +247,7 @@ static MipGenerationFunction GetMipGenerationFunction(size_t sourceWidth, size_t
return NULL; return NULL;
} }
} } // namespace priv
template <typename T> template <typename T>
inline void GenerateMip(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth, inline void GenerateMip(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
...@@ -263,4 +265,4 @@ inline void GenerateMip(size_t sourceWidth, size_t sourceHeight, size_t sourceDe ...@@ -263,4 +265,4 @@ inline void GenerateMip(size_t sourceWidth, size_t sourceHeight, size_t sourceDe
mipWidth, mipHeight, mipDepth, destData, destRowPitch, destDepthPitch); mipWidth, mipHeight, mipDepth, destData, destRowPitch, destDepthPitch);
} }
} } // namespace angle
...@@ -6,7 +6,12 @@ ...@@ -6,7 +6,12 @@
#include "common/mathutil.h" #include "common/mathutil.h"
namespace rx #include <string.h>
namespace angle
{
namespace priv
{ {
template <typename T> template <typename T>
...@@ -21,6 +26,8 @@ inline const T *OffsetDataPointer(const uint8_t *data, size_t y, size_t z, size_ ...@@ -21,6 +26,8 @@ inline const T *OffsetDataPointer(const uint8_t *data, size_t y, size_t z, size_
return reinterpret_cast<const T*>(data + (y * rowPitch) + (z * depthPitch)); return reinterpret_cast<const T*>(data + (y * rowPitch) + (z * depthPitch));
} }
} // namespace priv
template <typename type, size_t componentCount> template <typename type, size_t componentCount>
inline void LoadToNative(size_t width, size_t height, size_t depth, inline void LoadToNative(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
...@@ -39,8 +46,8 @@ inline void LoadToNative(size_t width, size_t height, size_t depth, ...@@ -39,8 +46,8 @@ inline void LoadToNative(size_t width, size_t height, size_t depth,
{ {
for (size_t z = 0; z < depth; z++) for (size_t z = 0; z < depth; z++)
{ {
const type *source = OffsetDataPointer<type>(input, 0, z, inputRowPitch, inputDepthPitch); const type *source = priv::OffsetDataPointer<type>(input, 0, z, inputRowPitch, inputDepthPitch);
type *dest = OffsetDataPointer<type>(output, 0, z, outputRowPitch, outputDepthPitch); type *dest = priv::OffsetDataPointer<type>(output, 0, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, layerSize); memcpy(dest, source, layerSize);
} }
...@@ -51,8 +58,8 @@ inline void LoadToNative(size_t width, size_t height, size_t depth, ...@@ -51,8 +58,8 @@ inline void LoadToNative(size_t width, size_t height, size_t depth,
{ {
for (size_t y = 0; y < height; y++) for (size_t y = 0; y < height; y++)
{ {
const type *source = OffsetDataPointer<type>(input, y, z, inputRowPitch, inputDepthPitch); const type *source = priv::OffsetDataPointer<type>(input, y, z, inputRowPitch, inputDepthPitch);
type *dest = OffsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch); type *dest = priv::OffsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, width * sizeof(type) * componentCount); memcpy(dest, source, width * sizeof(type) * componentCount);
} }
} }
...@@ -70,8 +77,8 @@ inline void LoadToNative3To4(size_t width, size_t height, size_t depth, ...@@ -70,8 +77,8 @@ inline void LoadToNative3To4(size_t width, size_t height, size_t depth,
{ {
for (size_t y = 0; y < height; y++) for (size_t y = 0; y < height; y++)
{ {
const type *source = OffsetDataPointer<type>(input, y, z, inputRowPitch, inputDepthPitch); const type *source = priv::OffsetDataPointer<type>(input, y, z, inputRowPitch, inputDepthPitch);
type *dest = OffsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch); type *dest = priv::OffsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x++) for (size_t x = 0; x < width; x++)
{ {
dest[x * 4 + 0] = source[x * 3 + 0]; dest[x * 4 + 0] = source[x * 3 + 0];
...@@ -94,8 +101,8 @@ inline void Load32FTo16F(size_t width, size_t height, size_t depth, ...@@ -94,8 +101,8 @@ inline void Load32FTo16F(size_t width, size_t height, size_t depth,
{ {
for (size_t y = 0; y < height; y++) for (size_t y = 0; y < height; y++)
{ {
const float *source = OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch); const float *source = priv::OffsetDataPointer<float>(input, y, z, inputRowPitch, inputDepthPitch);
uint16_t *dest = OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch); uint16_t *dest = priv::OffsetDataPointer<uint16_t>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < elementWidth; x++) for (size_t x = 0; x < elementWidth; x++)
{ {
...@@ -117,8 +124,8 @@ inline void LoadCompressedToNative(size_t width, size_t height, size_t depth, ...@@ -117,8 +124,8 @@ inline void LoadCompressedToNative(size_t width, size_t height, size_t depth,
{ {
for (size_t y = 0; y < rows; ++y) for (size_t y = 0; y < rows; ++y)
{ {
const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch); const uint8_t *source = priv::OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint8_t *dest = OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); uint8_t *dest = priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
memcpy(dest, source, columns * blockSize); memcpy(dest, source, columns * blockSize);
} }
} }
...@@ -140,7 +147,7 @@ inline void Initialize4ComponentData(size_t width, size_t height, size_t depth, ...@@ -140,7 +147,7 @@ inline void Initialize4ComponentData(size_t width, size_t height, size_t depth,
{ {
for (size_t y = 0; y < height; y++) for (size_t y = 0; y < height; y++)
{ {
type *destRow = OffsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch); type *destRow = priv::OffsetDataPointer<type>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x++) for (size_t x = 0; x < width; x++)
{ {
type* destPixel = destRow + x * 4; type* destPixel = destRow + x * 4;
...@@ -153,4 +160,4 @@ inline void Initialize4ComponentData(size_t width, size_t height, size_t depth, ...@@ -153,4 +160,4 @@ inline void Initialize4ComponentData(size_t width, size_t height, size_t depth,
} }
} }
} } // namespace angle
...@@ -6,12 +6,13 @@ ...@@ -6,12 +6,13 @@
// loadimage_etc.cpp: Decodes ETC and EAC encoded textures. // loadimage_etc.cpp: Decodes ETC and EAC encoded textures.
#include "libANGLE/renderer/d3d/loadimage_etc.h" #include "image_util/loadimage.h"
#include "libANGLE/renderer/imageformats.h" #include "common/mathutil.h"
#include "libANGLE/renderer/d3d/loadimage.h"
namespace rx #include "image_util/imageformats.h"
namespace angle
{ {
namespace namespace
{ {
...@@ -165,18 +166,15 @@ struct ETC2Block ...@@ -165,18 +166,15 @@ struct ETC2Block
} }
private: private:
union union {
{
// Individual, differential, H and T modes // Individual, differential, H and T modes
struct struct
{ {
union union {
{
// Individual and differential modes // Individual and differential modes
struct struct
{ {
union union {
{
struct // Individual colors struct // Individual colors
{ {
unsigned char R2 : 4; unsigned char R2 : 4;
...@@ -286,8 +284,7 @@ struct ETC2Block ...@@ -286,8 +284,7 @@ struct ETC2Block
// Single channel block // Single channel block
struct struct
{ {
union union {
{
unsigned char us; unsigned char us;
signed char s; signed char s;
} base_codeword; } base_codeword;
...@@ -1177,9 +1174,9 @@ void LoadR11EACToR8(size_t width, ...@@ -1177,9 +1174,9 @@ void LoadR11EACToR8(size_t width,
for (size_t y = 0; y < height; y += 4) for (size_t y = 0; y < height; y += 4)
{ {
const ETC2Block *sourceRow = const ETC2Block *sourceRow =
OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch); priv::OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch);
uint8_t *destRow = uint8_t *destRow =
OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x += 4) for (size_t x = 0; x < width; x += 4)
{ {
...@@ -1209,9 +1206,9 @@ void LoadRG11EACToRG8(size_t width, ...@@ -1209,9 +1206,9 @@ void LoadRG11EACToRG8(size_t width,
for (size_t y = 0; y < height; y += 4) for (size_t y = 0; y < height; y += 4)
{ {
const ETC2Block *sourceRow = const ETC2Block *sourceRow =
OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch); priv::OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch);
uint8_t *destRow = uint8_t *destRow =
OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x += 4) for (size_t x = 0; x < width; x += 4)
{ {
...@@ -1245,9 +1242,9 @@ void LoadETC2RGB8ToRGBA8(size_t width, ...@@ -1245,9 +1242,9 @@ void LoadETC2RGB8ToRGBA8(size_t width,
for (size_t y = 0; y < height; y += 4) for (size_t y = 0; y < height; y += 4)
{ {
const ETC2Block *sourceRow = const ETC2Block *sourceRow =
OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch); priv::OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch);
uint8_t *destRow = uint8_t *destRow =
OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x += 4) for (size_t x = 0; x < width; x += 4)
{ {
...@@ -1277,9 +1274,9 @@ void LoadETC2RGB8ToBC1(size_t width, ...@@ -1277,9 +1274,9 @@ void LoadETC2RGB8ToBC1(size_t width,
for (size_t y = 0; y < height; y += 4) for (size_t y = 0; y < height; y += 4)
{ {
const ETC2Block *sourceRow = const ETC2Block *sourceRow =
OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch); priv::OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch);
uint8_t *destRow = uint8_t *destRow = priv::OffsetDataPointer<uint8_t>(output, y / 4, z, outputRowPitch,
OffsetDataPointer<uint8_t>(output, y / 4, z, outputRowPitch, outputDepthPitch); outputDepthPitch);
for (size_t x = 0; x < width; x += 4) for (size_t x = 0; x < width; x += 4)
{ {
...@@ -1311,9 +1308,9 @@ void LoadETC2RGBA8ToRGBA8(size_t width, ...@@ -1311,9 +1308,9 @@ void LoadETC2RGBA8ToRGBA8(size_t width,
for (size_t y = 0; y < height; y += 4) for (size_t y = 0; y < height; y += 4)
{ {
const ETC2Block *sourceRow = const ETC2Block *sourceRow =
OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch); priv::OffsetDataPointer<ETC2Block>(input, y / 4, z, inputRowPitch, inputDepthPitch);
uint8_t *destRow = uint8_t *destRow =
OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch); priv::OffsetDataPointer<uint8_t>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x += 4) for (size_t x = 0; x < width; x += 4)
{ {
...@@ -1501,4 +1498,4 @@ void LoadETC2SRGBA8ToSRGBA8(size_t width, ...@@ -1501,4 +1498,4 @@ void LoadETC2SRGBA8ToSRGBA8(size_t width,
outputRowPitch, outputDepthPitch, true); outputRowPitch, outputDepthPitch, true);
} }
} // namespace rx } // namespace angle
...@@ -8,20 +8,27 @@ ...@@ -8,20 +8,27 @@
// in a separated file for GCC, which can enable SSE usage only per-file, // in a separated file for GCC, which can enable SSE usage only per-file,
// not for code blocks that use SSE2 explicitly. // not for code blocks that use SSE2 explicitly.
#include "libANGLE/renderer/d3d/loadimage.h" #include "image_util/loadimage.h"
#include "common/mathutil.h"
#include "common/platform.h" #include "common/platform.h"
#ifdef ANGLE_USE_SSE #ifdef ANGLE_USE_SSE
#include <emmintrin.h> #include <emmintrin.h>
#endif #endif
namespace rx namespace angle
{ {
void LoadA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, void LoadA8ToBGRA8_SSE2(size_t width,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, size_t height,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch) size_t depth,
const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ {
#if defined(ANGLE_USE_SSE) #if defined(ANGLE_USE_SSE)
__m128i zeroWide = _mm_setzero_si128(); __m128i zeroWide = _mm_setzero_si128();
...@@ -30,8 +37,10 @@ void LoadA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, ...@@ -30,8 +37,10 @@ void LoadA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
{ {
for (size_t y = 0; y < height; y++) for (size_t y = 0; y < height; y++)
{ {
const uint8_t *source = OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch); const uint8_t *source =
uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch); priv::OffsetDataPointer<uint8_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint32_t *dest =
priv::OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
size_t x = 0; size_t x = 0;
...@@ -43,15 +52,15 @@ void LoadA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, ...@@ -43,15 +52,15 @@ void LoadA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
for (; x + 7 < width; x += 8) for (; x + 7 < width; x += 8)
{ {
__m128i sourceData = _mm_loadl_epi64(reinterpret_cast<const __m128i*>(&source[x])); __m128i sourceData = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(&source[x]));
// Interleave each byte to 16bit, make the lower byte to zero // Interleave each byte to 16bit, make the lower byte to zero
sourceData = _mm_unpacklo_epi8(zeroWide, sourceData); sourceData = _mm_unpacklo_epi8(zeroWide, sourceData);
// Interleave each 16bit to 32bit, make the lower 16bit to zero // Interleave each 16bit to 32bit, make the lower 16bit to zero
__m128i lo = _mm_unpacklo_epi16(zeroWide, sourceData); __m128i lo = _mm_unpacklo_epi16(zeroWide, sourceData);
__m128i hi = _mm_unpackhi_epi16(zeroWide, sourceData); __m128i hi = _mm_unpackhi_epi16(zeroWide, sourceData);
_mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), lo); _mm_store_si128(reinterpret_cast<__m128i *>(&dest[x]), lo);
_mm_store_si128(reinterpret_cast<__m128i*>(&dest[x + 4]), hi); _mm_store_si128(reinterpret_cast<__m128i *>(&dest[x + 4]), hi);
} }
// Handle the remainder // Handle the remainder
...@@ -69,9 +78,15 @@ void LoadA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, ...@@ -69,9 +78,15 @@ void LoadA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
#endif #endif
} }
void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, void LoadRGBA8ToBGRA8_SSE2(size_t width,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, size_t height,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch) size_t depth,
const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{ {
#if defined(ANGLE_USE_SSE) #if defined(ANGLE_USE_SSE)
__m128i brMask = _mm_set1_epi32(0x00ff00ff); __m128i brMask = _mm_set1_epi32(0x00ff00ff);
...@@ -80,8 +95,10 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, ...@@ -80,8 +95,10 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
{ {
for (size_t y = 0; y < height; y++) for (size_t y = 0; y < height; y++)
{ {
const uint32_t *source = OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch); const uint32_t *source =
uint32_t *dest = OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch); priv::OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint32_t *dest =
priv::OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
size_t x = 0; size_t x = 0;
...@@ -94,15 +111,17 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, ...@@ -94,15 +111,17 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
for (; x + 3 < width; x += 4) for (; x + 3 < width; x += 4)
{ {
__m128i sourceData = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&source[x])); __m128i sourceData = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&source[x]));
// Mask out g and a, which don't change // Mask out g and a, which don't change
__m128i gaComponents = _mm_andnot_si128(brMask, sourceData); __m128i gaComponents = _mm_andnot_si128(brMask, sourceData);
// Mask out b and r // Mask out b and r
__m128i brComponents = _mm_and_si128(sourceData, brMask); __m128i brComponents = _mm_and_si128(sourceData, brMask);
// Swap b and r // Swap b and r
__m128i brSwapped = _mm_shufflehi_epi16(_mm_shufflelo_epi16(brComponents, _MM_SHUFFLE(2, 3, 0, 1)), _MM_SHUFFLE(2, 3, 0, 1)); __m128i brSwapped =
_mm_shufflehi_epi16(_mm_shufflelo_epi16(brComponents, _MM_SHUFFLE(2, 3, 0, 1)),
_MM_SHUFFLE(2, 3, 0, 1));
__m128i result = _mm_or_si128(gaComponents, brSwapped); __m128i result = _mm_or_si128(gaComponents, brSwapped);
_mm_store_si128(reinterpret_cast<__m128i*>(&dest[x]), result); _mm_store_si128(reinterpret_cast<__m128i *>(&dest[x]), result);
} }
// Perform leftover writes // Perform leftover writes
...@@ -120,6 +139,4 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth, ...@@ -120,6 +139,4 @@ void LoadRGBA8ToBGRA8_SSE2(size_t width, size_t height, size_t depth,
return; return;
#endif #endif
} }
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <memory> #include <memory>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/Color.h"
#include "libANGLE/Debug.h" #include "libANGLE/Debug.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/RefCountObject.h" #include "libANGLE/RefCountObject.h"
......
...@@ -45,28 +45,6 @@ enum SamplerType ...@@ -45,28 +45,6 @@ enum SamplerType
SAMPLER_VERTEX SAMPLER_VERTEX
}; };
template <typename T>
struct Color
{
T red;
T green;
T blue;
T alpha;
Color() : red(0), green(0), blue(0), alpha(0) { }
Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a) { }
};
template <typename T>
bool operator==(const Color<T> &a, const Color<T> &b);
template <typename T>
bool operator!=(const Color<T> &a, const Color<T> &b);
typedef Color<float> ColorF;
typedef Color<int> ColorI;
typedef Color<unsigned int> ColorUI;
struct Rectangle struct Rectangle
{ {
Rectangle() : x(0), y(0), width(0), height(0) {} Rectangle() : x(0), y(0), width(0), height(0) {}
......
...@@ -9,21 +9,6 @@ ...@@ -9,21 +9,6 @@
namespace gl namespace gl
{ {
template <typename T>
bool operator==(const Color<T> &a, const Color<T> &b)
{
return a.red == b.red &&
a.green == b.green &&
a.blue == b.blue &&
a.alpha == b.alpha;
}
template <typename T>
bool operator!=(const Color<T> &a, const Color<T> &b)
{
return !(a == b);
}
inline bool operator==(const Rectangle &a, const Rectangle &b) inline bool operator==(const Rectangle &a, const Rectangle &b)
{ {
return a.x == b.x && return a.x == b.x &&
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <vector> #include <vector>
#include <cstdint> #include <cstdint>
#include "common/Color.h"
#include "common/Optional.h" #include "common/Optional.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
......
...@@ -9,13 +9,14 @@ ...@@ -9,13 +9,14 @@
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/copyimage.h"
#include "libANGLE/renderer/d3d/d3d11/copyvertex.h" #include "libANGLE/renderer/d3d/d3d11/copyvertex.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/generatemip.h"
#include "libANGLE/renderer/d3d/loadimage.h"
namespace rx namespace rx
{ {
...@@ -48,7 +49,7 @@ static const FastCopyFunctionMap &GetFastCopyFunctionMap(DXGI_FORMAT dxgiFormat) ...@@ -48,7 +49,7 @@ static const FastCopyFunctionMap &GetFastCopyFunctionMap(DXGI_FORMAT dxgiFormat)
static FastCopyFunctionMap fastCopyMap; static FastCopyFunctionMap fastCopyMap;
if (fastCopyMap.empty()) if (fastCopyMap.empty())
{ {
fastCopyMap[gl::FormatType(GL_RGBA, GL_UNSIGNED_BYTE)] = CopyBGRA8ToRGBA8; fastCopyMap[gl::FormatType(GL_RGBA, GL_UNSIGNED_BYTE)] = angle::CopyBGRA8ToRGBA8;
} }
return fastCopyMap; return fastCopyMap;
} }
......
...@@ -21,10 +21,15 @@ template = """// GENERATED FILE - DO NOT EDIT. ...@@ -21,10 +21,15 @@ template = """// GENERATED FILE - DO NOT EDIT.
// //
#include "libANGLE/renderer/d3d/d3d11/load_functions_table.h" #include "libANGLE/renderer/d3d/d3d11/load_functions_table.h"
#include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include "libANGLE/renderer/d3d/loadimage.h"
#include "libANGLE/renderer/d3d/loadimage_etc.h" using namespace angle;
namespace rx namespace rx
{{ {{
......
...@@ -51,12 +51,15 @@ template_texture_format_table_autogen_cpp = """// GENERATED FILE - DO NOT EDIT. ...@@ -51,12 +51,15 @@ template_texture_format_table_autogen_cpp = """// GENERATED FILE - DO NOT EDIT.
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include "libANGLE/renderer/copyimage.h" #include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/load_functions_table.h" #include "libANGLE/renderer/d3d/d3d11/load_functions_table.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/generatemip.h"
#include "libANGLE/renderer/d3d/loadimage.h" using namespace angle;
namespace rx namespace rx
{{ {{
......
...@@ -10,10 +10,15 @@ ...@@ -10,10 +10,15 @@
// //
#include "libANGLE/renderer/d3d/d3d11/load_functions_table.h" #include "libANGLE/renderer/d3d/d3d11/load_functions_table.h"
#include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include "libANGLE/renderer/d3d/loadimage.h"
#include "libANGLE/renderer/d3d/loadimage_etc.h" using namespace angle;
namespace rx namespace rx
{ {
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
#include <functional> #include <functional>
#include <vector> #include <vector>
#include "libANGLE/angletypes.h" #include "common/Color.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
......
...@@ -11,12 +11,15 @@ ...@@ -11,12 +11,15 @@
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include "libANGLE/renderer/copyimage.h" #include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/load_functions_table.h" #include "libANGLE/renderer/d3d/d3d11/load_functions_table.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/renderer/d3d/generatemip.h"
#include "libANGLE/renderer/d3d/loadimage.h" using namespace angle;
namespace rx namespace rx
{ {
......
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h" #include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/copyimage.h" #include "image_util/copyimage.h"
#include "image_util/generatemip.h"
#include "image_util/loadimage.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h" #include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/vertexconversion.h" #include "libANGLE/renderer/d3d/d3d9/vertexconversion.h"
#include "libANGLE/renderer/d3d/generatemip.h"
#include "libANGLE/renderer/d3d/loadimage.h"
namespace rx namespace rx
{ {
...@@ -49,7 +50,7 @@ static const FastCopyFunctionMap &GetFastCopyFunctionMap(D3DFORMAT d3dFormat) ...@@ -49,7 +50,7 @@ static const FastCopyFunctionMap &GetFastCopyFunctionMap(D3DFORMAT d3dFormat)
static FastCopyFunctionMap fastCopyMap; static FastCopyFunctionMap fastCopyMap;
if (fastCopyMap.empty()) if (fastCopyMap.empty())
{ {
fastCopyMap[gl::FormatType(GL_RGBA, GL_UNSIGNED_BYTE)] = CopyBGRA8ToRGBA8; fastCopyMap[gl::FormatType(GL_RGBA, GL_UNSIGNED_BYTE)] = angle::CopyBGRA8ToRGBA8;
} }
return fastCopyMap; return fastCopyMap;
} }
...@@ -109,6 +110,8 @@ static inline void InsertD3DFormatInfo(D3D9FormatInfoMap *map, D3DFORMAT format, ...@@ -109,6 +110,8 @@ static inline void InsertD3DFormatInfo(D3D9FormatInfoMap *map, D3DFORMAT format,
static D3D9FormatInfoMap BuildD3D9FormatInfoMap() static D3D9FormatInfoMap BuildD3D9FormatInfoMap()
{ {
using namespace angle; // For image reading and mipmap generation functions
D3D9FormatInfoMap map; D3D9FormatInfoMap map;
// | D3DFORMAT | S |W |H | R | G | B | A | L | D | S | Internal format | Mip generation function | Color read function | // | D3DFORMAT | S |W |H | R | G | B | A | L | D | S | Internal format | Mip generation function | Color read function |
...@@ -166,6 +169,8 @@ typedef std::map<GLint, InitializeTextureDataFunction> InternalFormatInitialzerM ...@@ -166,6 +169,8 @@ typedef std::map<GLint, InitializeTextureDataFunction> InternalFormatInitialzerM
static InternalFormatInitialzerMap BuildInternalFormatInitialzerMap() static InternalFormatInitialzerMap BuildInternalFormatInitialzerMap()
{ {
using namespace angle; // For image initialization functions
InternalFormatInitialzerMap map; InternalFormatInitialzerMap map;
map.insert(InternalFormatInitialzerPair(GL_RGB16F, Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>)); map.insert(InternalFormatInitialzerPair(GL_RGB16F, Initialize4ComponentData<GLhalf, 0x0000, 0x0000, 0x0000, gl::Float16One>));
...@@ -232,6 +237,8 @@ static inline void InsertD3D9FormatInfo(D3D9FormatMap *map, GLenum internalForma ...@@ -232,6 +237,8 @@ static inline void InsertD3D9FormatInfo(D3D9FormatMap *map, GLenum internalForma
static D3D9FormatMap BuildD3D9FormatMap() static D3D9FormatMap BuildD3D9FormatMap()
{ {
using namespace angle; // For image loading functions
D3D9FormatMap map; D3D9FormatMap map;
// | Internal format | Texture format | Render format | Load function | // | Internal format | Texture format | Render format | Load function |
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D9_RENDERER9UTILS_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D9_RENDERER9UTILS_H_
#define LIBANGLE_RENDERER_D3D_D3D9_RENDERER9UTILS_H_ #define LIBANGLE_RENDERER_D3D_D3D9_RENDERER9UTILS_H_
#include "libANGLE/angletypes.h" #include "common/Color.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
......
//
// Copyright (c) 2002-2015 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.
//
// generatemip.h: Defines the GenerateMip function, templated on the format
// type of the image for which mip levels are being generated.
#ifndef LIBANGLE_RENDERER_D3D_GENERATEMIP_H_
#define LIBANGLE_RENDERER_D3D_GENERATEMIP_H_
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/imageformats.h"
namespace rx
{
template <typename T>
inline void GenerateMip(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
uint8_t *destData, size_t destRowPitch, size_t destDepthPitch);
}
#include "generatemip.inl"
#endif // LIBANGLE_RENDERER_D3D_GENERATEMIP_H_
//
// Copyright (c) 2013-2015 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.
//
// loadimage_etc.h: Decodes ETC and EAC encoded textures.
#ifndef LIBANGLE_RENDERER_D3D_LOADIMAGE_ETC_H_
#define LIBANGLE_RENDERER_D3D_LOADIMAGE_ETC_H_
#include "libANGLE/angletypes.h"
#include <stdint.h>
namespace rx
{
void LoadETC1RGB8ToRGBA8(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);
void LoadETC1RGB8ToBC1(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);
void LoadEACR11ToR8(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);
void LoadEACR11SToR8(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);
void LoadEACRG11ToRG8(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);
void LoadEACRG11SToRG8(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);
void LoadETC2RGB8ToRGBA8(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);
void LoadETC2SRGB8ToRGBA8(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);
void LoadETC2RGB8A1ToRGBA8(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);
void LoadETC2SRGB8A1ToRGBA8(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);
void LoadETC2RGBA8ToRGBA8(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);
void LoadETC2SRGBA8ToSRGBA8(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);
}
#endif // LIBANGLE_RENDERER_D3D_LOADIMAGE_ETC_H_
...@@ -9,9 +9,12 @@ ...@@ -9,9 +9,12 @@
#include "libANGLE/renderer/renderer_utils.h" #include "libANGLE/renderer/renderer_utils.h"
#include "image_util/copyimage.h"
#include "image_util/imageformats.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/copyimage.h"
#include "libANGLE/renderer/imageformats.h" #include <string.h>
namespace rx namespace rx
{ {
...@@ -31,6 +34,8 @@ static inline void InsertFormatWriteFunctionMapping(FormatWriteFunctionMap *map, ...@@ -31,6 +34,8 @@ static inline void InsertFormatWriteFunctionMapping(FormatWriteFunctionMap *map,
static FormatWriteFunctionMap BuildFormatWriteFunctionMap() static FormatWriteFunctionMap BuildFormatWriteFunctionMap()
{ {
using namespace angle; // For image writing functions
FormatWriteFunctionMap map; FormatWriteFunctionMap map;
// clang-format off // clang-format off
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
'libangle_common_sources': 'libangle_common_sources':
[ [
'common/BitSetIterator.h', 'common/BitSetIterator.h',
'common/Color.h',
'common/Color.inl',
'common/Float16ToFloat32.cpp', 'common/Float16ToFloat32.cpp',
'common/MemoryBuffer.cpp', 'common/MemoryBuffer.cpp',
'common/MemoryBuffer.h', 'common/MemoryBuffer.h',
...@@ -36,6 +38,21 @@ ...@@ -36,6 +38,21 @@
'common/utilities.h', 'common/utilities.h',
'common/version.h', 'common/version.h',
], ],
'libangle_image_util_sources':
[
'image_util/copyimage.cpp',
'image_util/copyimage.h',
'image_util/copyimage.inl',
'image_util/generatemip.h',
'image_util/generatemip.inl',
'image_util/imageformats.cpp',
'image_util/imageformats.h',
'image_util/loadimage.cpp',
'image_util/loadimage.h',
'image_util/loadimage.inl',
'image_util/loadimage_etc.cpp',
'image_util/loadimage_sse2.cpp',
],
'libangle_includes': 'libangle_includes':
[ [
'../include/angle_gl.h', '../include/angle_gl.h',
...@@ -170,10 +187,6 @@ ...@@ -170,10 +187,6 @@
'libANGLE/renderer/TextureImpl.h', 'libANGLE/renderer/TextureImpl.h',
'libANGLE/renderer/TransformFeedbackImpl.h', 'libANGLE/renderer/TransformFeedbackImpl.h',
'libANGLE/renderer/VertexArrayImpl.h', 'libANGLE/renderer/VertexArrayImpl.h',
'libANGLE/renderer/copyimage.cpp',
'libANGLE/renderer/copyimage.h',
'libANGLE/renderer/copyimage.inl',
'libANGLE/renderer/imageformats.h',
'libANGLE/renderer/renderer_utils.cpp', 'libANGLE/renderer/renderer_utils.cpp',
'libANGLE/renderer/renderer_utils.h', 'libANGLE/renderer/renderer_utils.h',
'libANGLE/signal_utils.cpp', 'libANGLE/signal_utils.cpp',
...@@ -206,8 +219,6 @@ ...@@ -206,8 +219,6 @@
'libANGLE/renderer/d3d/formatutilsD3D.h', 'libANGLE/renderer/d3d/formatutilsD3D.h',
'libANGLE/renderer/d3d/FramebufferD3D.cpp', 'libANGLE/renderer/d3d/FramebufferD3D.cpp',
'libANGLE/renderer/d3d/FramebufferD3D.h', 'libANGLE/renderer/d3d/FramebufferD3D.h',
'libANGLE/renderer/d3d/generatemip.h',
'libANGLE/renderer/d3d/generatemip.inl',
'libANGLE/renderer/d3d/HLSLCompiler.cpp', 'libANGLE/renderer/d3d/HLSLCompiler.cpp',
'libANGLE/renderer/d3d/HLSLCompiler.h', 'libANGLE/renderer/d3d/HLSLCompiler.h',
'libANGLE/renderer/d3d/ImageD3D.cpp', 'libANGLE/renderer/d3d/ImageD3D.cpp',
...@@ -216,12 +227,6 @@ ...@@ -216,12 +227,6 @@
'libANGLE/renderer/d3d/IndexBuffer.h', 'libANGLE/renderer/d3d/IndexBuffer.h',
'libANGLE/renderer/d3d/IndexDataManager.cpp', 'libANGLE/renderer/d3d/IndexDataManager.cpp',
'libANGLE/renderer/d3d/IndexDataManager.h', 'libANGLE/renderer/d3d/IndexDataManager.h',
'libANGLE/renderer/d3d/loadimage.cpp',
'libANGLE/renderer/d3d/loadimage.h',
'libANGLE/renderer/d3d/loadimage.inl',
'libANGLE/renderer/d3d/loadimageSSE2.cpp',
'libANGLE/renderer/d3d/loadimage_etc.cpp',
'libANGLE/renderer/d3d/loadimage_etc.h',
'libANGLE/renderer/d3d/NativeWindowD3D.cpp', 'libANGLE/renderer/d3d/NativeWindowD3D.cpp',
'libANGLE/renderer/d3d/NativeWindowD3D.h', 'libANGLE/renderer/d3d/NativeWindowD3D.h',
'libANGLE/renderer/d3d/ProgramD3D.cpp', 'libANGLE/renderer/d3d/ProgramD3D.cpp',
...@@ -642,6 +647,7 @@ ...@@ -642,6 +647,7 @@
'translator_static', 'translator_static',
'commit_id', 'commit_id',
'angle_common', 'angle_common',
'angle_image_util',
], ],
'includes': [ '../build/common_defines.gypi', ], 'includes': [ '../build/common_defines.gypi', ],
'include_dirs': 'include_dirs':
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "test_utils/ANGLETest.h" #include "test_utils/ANGLETest.h"
#include "libANGLE/renderer/imageformats.h" #include "image_util/imageformats.h"
using namespace angle; using namespace angle;
...@@ -135,7 +135,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR4G4B4A4) ...@@ -135,7 +135,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR4G4B4A4)
return; return;
} }
runTest<rx::R4G4B4A4>(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4); runTest<R4G4B4A4>(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
} }
// Validation test for rx::R5G5B5A1's writeColor functions // Validation test for rx::R5G5B5A1's writeColor functions
...@@ -150,7 +150,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR5G5B5A1) ...@@ -150,7 +150,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR5G5B5A1)
return; return;
} }
runTest<rx::R5G5B5A1>(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1); runTest<R5G5B5A1>(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
} }
// Validation test for rx::R5G6B5's writeColor functions // Validation test for rx::R5G6B5's writeColor functions
...@@ -165,7 +165,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR5G6B5) ...@@ -165,7 +165,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR5G6B5)
return; return;
} }
runTest<rx::R5G6B5>(GL_RGB, GL_UNSIGNED_SHORT_5_6_5); runTest<R5G6B5>(GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
} }
// Validation test for rx::R8G8B8A8's writeColor functions // Validation test for rx::R8G8B8A8's writeColor functions
...@@ -180,7 +180,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR8G8B8A8) ...@@ -180,7 +180,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR8G8B8A8)
return; return;
} }
runTest<rx::R8G8B8A8>(GL_RGBA, GL_UNSIGNED_BYTE); runTest<R8G8B8A8>(GL_RGBA, GL_UNSIGNED_BYTE);
} }
// Validation test for rx::R8G8B8's writeColor functions // Validation test for rx::R8G8B8's writeColor functions
...@@ -196,7 +196,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR8G8B8) ...@@ -196,7 +196,7 @@ TEST_P(D3DImageFormatConversionTest, WriteColorFunctionR8G8B8)
} }
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
runTest<rx::R8G8B8>(GL_RGB, GL_UNSIGNED_BYTE); runTest<R8G8B8>(GL_RGB, GL_UNSIGNED_BYTE);
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
......
...@@ -9,27 +9,27 @@ ...@@ -9,27 +9,27 @@
#include "test_utils/ANGLETest.h" #include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h" #include "test_utils/gl_raii.h"
#include "libANGLE/renderer/imageformats.h" #include "image_util/imageformats.h"
using namespace angle; using namespace angle;
namespace namespace
{ {
GLColor Convert565(const rx::R5G6B5 &rgb565) GLColor Convert565(const R5G6B5 &rgb565)
{ {
gl::ColorF colorf; gl::ColorF colorf;
rx::R5G6B5::readColor(&colorf, &rgb565); R5G6B5::readColor(&colorf, &rgb565);
Vector4 vecColor(colorf.red, colorf.green, colorf.blue, colorf.alpha); Vector4 vecColor(colorf.red, colorf.green, colorf.blue, colorf.alpha);
return GLColor(vecColor); return GLColor(vecColor);
} }
rx::R5G6B5 Convert565(const GLColor &glColor) R5G6B5 Convert565(const GLColor &glColor)
{ {
const Vector4 &vecColor = glColor.toNormalizedVector(); const Vector4 &vecColor = glColor.toNormalizedVector();
gl::ColorF colorf(vecColor.x, vecColor.y, vecColor.z, vecColor.w); gl::ColorF colorf(vecColor.x, vecColor.y, vecColor.z, vecColor.w);
rx::R5G6B5 rgb565; R5G6B5 rgb565;
rx::R5G6B5::writeColor(&rgb565, &colorf); R5G6B5::writeColor(&rgb565, &colorf);
return rgb565; return rgb565;
} }
...@@ -165,7 +165,7 @@ TEST_P(SixteenBppTextureTest, RGB565Validation) ...@@ -165,7 +165,7 @@ TEST_P(SixteenBppTextureTest, RGB565Validation)
GLuint test; GLuint test;
memcpy(&test, &GLColor::black, 4); memcpy(&test, &GLColor::black, 4);
rx::R5G6B5 pixels[4] = {Convert565(GLColor::red), Convert565(GLColor::green), R5G6B5 pixels[4] = {Convert565(GLColor::red), Convert565(GLColor::green),
Convert565(GLColor::blue), Convert565(GLColor::yellow)}; Convert565(GLColor::blue), Convert565(GLColor::yellow)};
glClearColor(0, 0, 0, 0); glClearColor(0, 0, 0, 0);
...@@ -525,7 +525,7 @@ TEST_P(SixteenBppTextureTestES3, RGB565FramebufferReadback) ...@@ -525,7 +525,7 @@ TEST_P(SixteenBppTextureTestES3, RGB565FramebufferReadback)
if (colorReadFormat == GL_RGB && colorReadType == GL_UNSIGNED_SHORT_5_6_5) if (colorReadFormat == GL_RGB && colorReadType == GL_UNSIGNED_SHORT_5_6_5)
{ {
std::vector<rx::R5G6B5> readColors(w * h); std::vector<R5G6B5> readColors(w * h);
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, readColors.data()); glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, readColors.data());
int hoffset = (h - 1) * w; int hoffset = (h - 1) * w;
......
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