Moved load*Data methods to Image.

TRAC #18714 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@831 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 6e4b1219
...@@ -210,139 +210,10 @@ IDirect3DSurface9 *Image::getSurface() ...@@ -210,139 +210,10 @@ IDirect3DSurface9 *Image::getSurface()
return mSurface; return mSurface;
} }
Texture::Texture(GLuint id) : RefCountObject(id), mSerial(issueSerial())
{
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
mMagFilter = GL_LINEAR;
mWrapS = GL_REPEAT;
mWrapT = GL_REPEAT;
mDirtyParameters = true;
mDirtyImages = true;
mIsRenderable = false;
}
Texture::~Texture()
{
}
Blit *Texture::getBlitter()
{
Context *context = getContext();
return context->getBlitter();
}
// Returns true on successful filter state update (valid enum parameter)
bool Texture::setMinFilter(GLenum filter)
{
switch (filter)
{
case GL_NEAREST:
case GL_LINEAR:
case GL_NEAREST_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
{
if (mMinFilter != filter)
{
mMinFilter = filter;
mDirtyParameters = true;
}
return true;
}
default:
return false;
}
}
// Returns true on successful filter state update (valid enum parameter)
bool Texture::setMagFilter(GLenum filter)
{
switch (filter)
{
case GL_NEAREST:
case GL_LINEAR:
{
if (mMagFilter != filter)
{
mMagFilter = filter;
mDirtyParameters = true;
}
return true;
}
default:
return false;
}
}
// Returns true on successful wrap state update (valid enum parameter)
bool Texture::setWrapS(GLenum wrap)
{
switch (wrap)
{
case GL_REPEAT:
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
{
if (mWrapS != wrap)
{
mWrapS = wrap;
mDirtyParameters = true;
}
return true;
}
default:
return false;
}
}
// Returns true on successful wrap state update (valid enum parameter)
bool Texture::setWrapT(GLenum wrap)
{
switch (wrap)
{
case GL_REPEAT:
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
{
if (mWrapT != wrap)
{
mWrapT = wrap;
mDirtyParameters = true;
}
return true;
}
default:
return false;
}
}
GLenum Texture::getMinFilter() const
{
return mMinFilter;
}
GLenum Texture::getMagFilter() const
{
return mMagFilter;
}
GLenum Texture::getWrapS() const
{
return mWrapS;
}
GLenum Texture::getWrapT() const
{
return mWrapT;
}
// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
// into the target pixel rectangle at output with outputPitch bytes in between each line. // into the target pixel rectangle at output with outputPitch bytes in between each line.
void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, void Image::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type,
GLint unpackAlignment, const void *input, size_t outputPitch, void *output, D3DFORMAT targetFormat) const GLint unpackAlignment, const void *input, size_t outputPitch, void *output) const
{ {
GLsizei inputPitch = -ComputePitch(width, format, type, unpackAlignment); GLsizei inputPitch = -ComputePitch(width, format, type, unpackAlignment);
input = ((char*)input) - inputPitch * (height - 1); input = ((char*)input) - inputPitch * (height - 1);
...@@ -353,29 +224,29 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei ...@@ -353,29 +224,29 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei
switch (format) switch (format)
{ {
case GL_ALPHA: case GL_ALPHA:
loadAlphaImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadAlphaData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_LUMINANCE: case GL_LUMINANCE:
loadLuminanceImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output, targetFormat == D3DFMT_L8); loadLuminanceData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output, getD3DFormat() == D3DFMT_L8);
break; break;
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
loadLuminanceAlphaImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output, targetFormat == D3DFMT_A8L8); loadLuminanceAlphaData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output, getD3DFormat() == D3DFMT_A8L8);
break; break;
case GL_RGB: case GL_RGB:
loadRGBUByteImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGBUByteData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_RGBA: case GL_RGBA:
if (supportsSSE2()) if (supportsSSE2())
{ {
loadRGBAUByteImageDataSSE2(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGBAUByteDataSSE2(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
} }
else else
{ {
loadRGBAUByteImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGBAUByteData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
} }
break; break;
case GL_BGRA_EXT: case GL_BGRA_EXT:
loadBGRAImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadBGRAData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -384,7 +255,7 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei ...@@ -384,7 +255,7 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei
switch (format) switch (format)
{ {
case GL_RGB: case GL_RGB:
loadRGB565ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGB565Data(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -393,7 +264,7 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei ...@@ -393,7 +264,7 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei
switch (format) switch (format)
{ {
case GL_RGBA: case GL_RGBA:
loadRGBA4444ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGBA4444Data(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -402,7 +273,7 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei ...@@ -402,7 +273,7 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei
switch (format) switch (format)
{ {
case GL_RGBA: case GL_RGBA:
loadRGBA5551ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGBA5551Data(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -412,19 +283,19 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei ...@@ -412,19 +283,19 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei
{ {
// float textures are converted to RGBA, not BGRA, as they're stored that way in D3D // float textures are converted to RGBA, not BGRA, as they're stored that way in D3D
case GL_ALPHA: case GL_ALPHA:
loadAlphaFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadAlphaFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_LUMINANCE: case GL_LUMINANCE:
loadLuminanceFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadLuminanceFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
loadLuminanceAlphaFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadLuminanceAlphaFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_RGB: case GL_RGB:
loadRGBFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGBFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_RGBA: case GL_RGBA:
loadRGBAFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGBAFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -434,19 +305,19 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei ...@@ -434,19 +305,19 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei
{ {
// float textures are converted to RGBA, not BGRA, as they're stored that way in D3D // float textures are converted to RGBA, not BGRA, as they're stored that way in D3D
case GL_ALPHA: case GL_ALPHA:
loadAlphaHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadAlphaHalfFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_LUMINANCE: case GL_LUMINANCE:
loadLuminanceHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadLuminanceHalfFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
loadLuminanceAlphaHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadLuminanceAlphaHalfFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_RGB: case GL_RGB:
loadRGBHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGBHalfFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case GL_RGBA: case GL_RGBA:
loadRGBAHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadRGBAHalfFloatData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -455,7 +326,7 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei ...@@ -455,7 +326,7 @@ void Texture::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei
} }
} }
void Texture::loadAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadAlphaData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
...@@ -475,7 +346,7 @@ void Texture::loadAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GL ...@@ -475,7 +346,7 @@ void Texture::loadAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GL
} }
} }
void Texture::loadAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadAlphaFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const float *source = NULL; const float *source = NULL;
...@@ -495,7 +366,7 @@ void Texture::loadAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei widt ...@@ -495,7 +366,7 @@ void Texture::loadAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei widt
} }
} }
void Texture::loadAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadAlphaHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
...@@ -515,7 +386,7 @@ void Texture::loadAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei ...@@ -515,7 +386,7 @@ void Texture::loadAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei
} }
} }
void Texture::loadLuminanceImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadLuminanceData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const
{ {
const int destBytesPerPixel = native? 1: 4; const int destBytesPerPixel = native? 1: 4;
...@@ -544,7 +415,7 @@ void Texture::loadLuminanceImageData(GLint xoffset, GLint yoffset, GLsizei width ...@@ -544,7 +415,7 @@ void Texture::loadLuminanceImageData(GLint xoffset, GLint yoffset, GLsizei width
} }
} }
void Texture::loadLuminanceFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadLuminanceFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const float *source = NULL; const float *source = NULL;
...@@ -564,7 +435,7 @@ void Texture::loadLuminanceFloatImageData(GLint xoffset, GLint yoffset, GLsizei ...@@ -564,7 +435,7 @@ void Texture::loadLuminanceFloatImageData(GLint xoffset, GLint yoffset, GLsizei
} }
} }
void Texture::loadLuminanceHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadLuminanceHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
...@@ -584,7 +455,7 @@ void Texture::loadLuminanceHalfFloatImageData(GLint xoffset, GLint yoffset, GLsi ...@@ -584,7 +455,7 @@ void Texture::loadLuminanceHalfFloatImageData(GLint xoffset, GLint yoffset, GLsi
} }
} }
void Texture::loadLuminanceAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadLuminanceAlphaData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const
{ {
const int destBytesPerPixel = native? 2: 4; const int destBytesPerPixel = native? 2: 4;
...@@ -613,7 +484,7 @@ void Texture::loadLuminanceAlphaImageData(GLint xoffset, GLint yoffset, GLsizei ...@@ -613,7 +484,7 @@ void Texture::loadLuminanceAlphaImageData(GLint xoffset, GLint yoffset, GLsizei
} }
} }
void Texture::loadLuminanceAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadLuminanceAlphaFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const float *source = NULL; const float *source = NULL;
...@@ -633,7 +504,7 @@ void Texture::loadLuminanceAlphaFloatImageData(GLint xoffset, GLint yoffset, GLs ...@@ -633,7 +504,7 @@ void Texture::loadLuminanceAlphaFloatImageData(GLint xoffset, GLint yoffset, GLs
} }
} }
void Texture::loadLuminanceAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadLuminanceAlphaHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
...@@ -653,7 +524,7 @@ void Texture::loadLuminanceAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, ...@@ -653,7 +524,7 @@ void Texture::loadLuminanceAlphaHalfFloatImageData(GLint xoffset, GLint yoffset,
} }
} }
void Texture::loadRGBUByteImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGBUByteData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
...@@ -673,7 +544,7 @@ void Texture::loadRGBUByteImageData(GLint xoffset, GLint yoffset, GLsizei width, ...@@ -673,7 +544,7 @@ void Texture::loadRGBUByteImageData(GLint xoffset, GLint yoffset, GLsizei width,
} }
} }
void Texture::loadRGB565ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGB565Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
...@@ -694,7 +565,7 @@ void Texture::loadRGB565ImageData(GLint xoffset, GLint yoffset, GLsizei width, G ...@@ -694,7 +565,7 @@ void Texture::loadRGB565ImageData(GLint xoffset, GLint yoffset, GLsizei width, G
} }
} }
void Texture::loadRGBFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGBFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const float *source = NULL; const float *source = NULL;
...@@ -714,7 +585,7 @@ void Texture::loadRGBFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, ...@@ -714,7 +585,7 @@ void Texture::loadRGBFloatImageData(GLint xoffset, GLint yoffset, GLsizei width,
} }
} }
void Texture::loadRGBHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGBHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
...@@ -734,7 +605,7 @@ void Texture::loadRGBHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei wi ...@@ -734,7 +605,7 @@ void Texture::loadRGBHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei wi
} }
} }
void Texture::loadRGBAUByteImageDataSSE2(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGBAUByteDataSSE2(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned int *source = NULL; const unsigned int *source = NULL;
...@@ -776,7 +647,7 @@ void Texture::loadRGBAUByteImageDataSSE2(GLint xoffset, GLint yoffset, GLsizei w ...@@ -776,7 +647,7 @@ void Texture::loadRGBAUByteImageDataSSE2(GLint xoffset, GLint yoffset, GLsizei w
} }
} }
void Texture::loadRGBAUByteImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGBAUByteData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned int *source = NULL; const unsigned int *source = NULL;
...@@ -794,7 +665,7 @@ void Texture::loadRGBAUByteImageData(GLint xoffset, GLint yoffset, GLsizei width ...@@ -794,7 +665,7 @@ void Texture::loadRGBAUByteImageData(GLint xoffset, GLint yoffset, GLsizei width
} }
} }
void Texture::loadRGBA4444ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGBA4444Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
...@@ -815,7 +686,7 @@ void Texture::loadRGBA4444ImageData(GLint xoffset, GLint yoffset, GLsizei width, ...@@ -815,7 +686,7 @@ void Texture::loadRGBA4444ImageData(GLint xoffset, GLint yoffset, GLsizei width,
} }
} }
void Texture::loadRGBA5551ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGBA5551Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
...@@ -836,7 +707,7 @@ void Texture::loadRGBA5551ImageData(GLint xoffset, GLint yoffset, GLsizei width, ...@@ -836,7 +707,7 @@ void Texture::loadRGBA5551ImageData(GLint xoffset, GLint yoffset, GLsizei width,
} }
} }
void Texture::loadRGBAFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGBAFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const float *source = NULL; const float *source = NULL;
...@@ -850,7 +721,7 @@ void Texture::loadRGBAFloatImageData(GLint xoffset, GLint yoffset, GLsizei width ...@@ -850,7 +721,7 @@ void Texture::loadRGBAFloatImageData(GLint xoffset, GLint yoffset, GLsizei width
} }
} }
void Texture::loadRGBAHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadRGBAHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
...@@ -864,7 +735,7 @@ void Texture::loadRGBAHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei w ...@@ -864,7 +735,7 @@ void Texture::loadRGBAHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei w
} }
} }
void Texture::loadBGRAImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadBGRAData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
...@@ -878,18 +749,18 @@ void Texture::loadBGRAImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs ...@@ -878,18 +749,18 @@ void Texture::loadBGRAImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs
} }
} }
void Texture::loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const { int inputPitch, const void *input, size_t outputPitch, void *output) const {
switch (getD3DFormat()) switch (getD3DFormat())
{ {
case D3DFMT_DXT1: case D3DFMT_DXT1:
loadDXT1ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadDXT1Data(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case D3DFMT_DXT3: case D3DFMT_DXT3:
loadDXT3ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadDXT3Data(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
case D3DFMT_DXT5: case D3DFMT_DXT5:
loadDXT5ImageData(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output); loadDXT5Data(xoffset, yoffset, width, height, inputPitch, input, outputPitch, output);
break; break;
} }
} }
...@@ -1004,7 +875,7 @@ static void FlipCopyDXT5BlockHalf(const unsigned int* source, unsigned int* dest ...@@ -1004,7 +875,7 @@ static void FlipCopyDXT5BlockHalf(const unsigned int* source, unsigned int* dest
FlipCopyDXT1BlockHalf(source + 2, dest + 2); FlipCopyDXT1BlockHalf(source + 2, dest + 2);
} }
void Texture::loadDXT1ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadDXT1Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
ASSERT(xoffset % 4 == 0); ASSERT(xoffset % 4 == 0);
...@@ -1052,7 +923,7 @@ void Texture::loadDXT1ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs ...@@ -1052,7 +923,7 @@ void Texture::loadDXT1ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs
} }
} }
void Texture::loadDXT3ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadDXT3Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
ASSERT(xoffset % 4 == 0); ASSERT(xoffset % 4 == 0);
...@@ -1102,7 +973,7 @@ void Texture::loadDXT3ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs ...@@ -1102,7 +973,7 @@ void Texture::loadDXT3ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs
} }
} }
void Texture::loadDXT5ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image::loadDXT5Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const int inputPitch, const void *input, size_t outputPitch, void *output) const
{ {
ASSERT(xoffset % 4 == 0); ASSERT(xoffset % 4 == 0);
...@@ -1152,6 +1023,135 @@ void Texture::loadDXT5ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs ...@@ -1152,6 +1023,135 @@ void Texture::loadDXT5ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLs
} }
} }
Texture::Texture(GLuint id) : RefCountObject(id), mSerial(issueSerial())
{
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
mMagFilter = GL_LINEAR;
mWrapS = GL_REPEAT;
mWrapT = GL_REPEAT;
mDirtyParameters = true;
mDirtyImages = true;
mIsRenderable = false;
}
Texture::~Texture()
{
}
Blit *Texture::getBlitter()
{
Context *context = getContext();
return context->getBlitter();
}
// Returns true on successful filter state update (valid enum parameter)
bool Texture::setMinFilter(GLenum filter)
{
switch (filter)
{
case GL_NEAREST:
case GL_LINEAR:
case GL_NEAREST_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
{
if (mMinFilter != filter)
{
mMinFilter = filter;
mDirtyParameters = true;
}
return true;
}
default:
return false;
}
}
// Returns true on successful filter state update (valid enum parameter)
bool Texture::setMagFilter(GLenum filter)
{
switch (filter)
{
case GL_NEAREST:
case GL_LINEAR:
{
if (mMagFilter != filter)
{
mMagFilter = filter;
mDirtyParameters = true;
}
return true;
}
default:
return false;
}
}
// Returns true on successful wrap state update (valid enum parameter)
bool Texture::setWrapS(GLenum wrap)
{
switch (wrap)
{
case GL_REPEAT:
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
{
if (mWrapS != wrap)
{
mWrapS = wrap;
mDirtyParameters = true;
}
return true;
}
default:
return false;
}
}
// Returns true on successful wrap state update (valid enum parameter)
bool Texture::setWrapT(GLenum wrap)
{
switch (wrap)
{
case GL_REPEAT:
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
{
if (mWrapT != wrap)
{
mWrapT = wrap;
mDirtyParameters = true;
}
return true;
}
default:
return false;
}
}
GLenum Texture::getMinFilter() const
{
return mMinFilter;
}
GLenum Texture::getMagFilter() const
{
return mMagFilter;
}
GLenum Texture::getWrapS() const
{
return mWrapS;
}
GLenum Texture::getWrapT() const
{
return mWrapT;
}
void Texture::setImage(GLint unpackAlignment, const void *pixels, Image *image) void Texture::setImage(GLint unpackAlignment, const void *pixels, Image *image)
{ {
if (pixels != NULL) if (pixels != NULL)
...@@ -1161,7 +1161,7 @@ void Texture::setImage(GLint unpackAlignment, const void *pixels, Image *image) ...@@ -1161,7 +1161,7 @@ void Texture::setImage(GLint unpackAlignment, const void *pixels, Image *image)
if (SUCCEEDED(result)) if (SUCCEEDED(result))
{ {
loadImageData(0, 0, image->getWidth(), image->getHeight(), image->getFormat(), image->getType(), unpackAlignment, pixels, locked.Pitch, locked.pBits, image->getD3DFormat()); image->loadData(0, 0, image->getWidth(), image->getHeight(), image->getFormat(), image->getType(), unpackAlignment, pixels, locked.Pitch, locked.pBits);
image->unlock(); image->unlock();
} }
...@@ -1181,7 +1181,7 @@ void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, Image *i ...@@ -1181,7 +1181,7 @@ void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, Image *i
{ {
int inputPitch = ComputeCompressedPitch(image->getWidth(), image->getFormat()); int inputPitch = ComputeCompressedPitch(image->getWidth(), image->getFormat());
int inputSize = ComputeCompressedSize(image->getWidth(), image->getHeight(), image->getFormat()); int inputSize = ComputeCompressedSize(image->getWidth(), image->getHeight(), image->getFormat());
loadCompressedImageData(0, 0, image->getWidth(), image->getHeight(), -inputPitch, static_cast<const char*>(pixels) + inputSize - inputPitch, locked.Pitch, locked.pBits); image->loadCompressedData(0, 0, image->getWidth(), image->getHeight(), -inputPitch, static_cast<const char*>(pixels) + inputSize - inputPitch, locked.Pitch, locked.pBits);
image->unlock(); image->unlock();
} }
...@@ -1217,7 +1217,7 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig ...@@ -1217,7 +1217,7 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
if (SUCCEEDED(result)) if (SUCCEEDED(result))
{ {
loadImageData(xoffset, transformPixelYOffset(yoffset, height, image->getHeight()), width, height, format, type, unpackAlignment, pixels, locked.Pitch, locked.pBits, image->getD3DFormat()); image->loadData(xoffset, transformPixelYOffset(yoffset, height, image->getHeight()), width, height, format, type, unpackAlignment, pixels, locked.Pitch, locked.pBits);
image->unlock(); image->unlock();
} }
...@@ -1257,7 +1257,7 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL ...@@ -1257,7 +1257,7 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL
{ {
int inputPitch = ComputeCompressedPitch(width, format); int inputPitch = ComputeCompressedPitch(width, format);
int inputSize = ComputeCompressedSize(width, height, format); int inputSize = ComputeCompressedSize(width, height, format);
loadCompressedImageData(xoffset, transformPixelYOffset(yoffset, height, image->getHeight()), width, height, -inputPitch, static_cast<const char*>(pixels) + inputSize - inputPitch, locked.Pitch, locked.pBits); image->loadCompressedData(xoffset, transformPixelYOffset(yoffset, height, image->getHeight()), width, height, -inputPitch, static_cast<const char*>(pixels) + inputSize - inputPitch, locked.Pitch, locked.pBits);
image->unlock(); image->unlock();
} }
......
...@@ -66,6 +66,58 @@ class Image ...@@ -66,6 +66,58 @@ class Image
bool isDirty() const {return mSurface && mDirty;} bool isDirty() const {return mSurface && mDirty;}
IDirect3DSurface9 *getSurface(); IDirect3DSurface9 *getSurface();
void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type,
GLint unpackAlignment, const void *input, std::size_t outputPitch, void *output) const;
void loadAlphaData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadAlphaFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadAlphaHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const;
void loadLuminanceFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceAlphaData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const;
void loadLuminanceAlphaFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceAlphaHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBUByteData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGB565Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAUByteDataSSE2(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAUByteData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBA4444Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBA5551Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAHalfFloatData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadBGRAData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT1Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT3Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT5Data(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
private: private:
DISALLOW_COPY_AND_ASSIGN(Image); DISALLOW_COPY_AND_ASSIGN(Image);
...@@ -157,58 +209,6 @@ class Texture : public RefCountObject ...@@ -157,58 +209,6 @@ class Texture : public RefCountObject
private: private:
DISALLOW_COPY_AND_ASSIGN(Texture); DISALLOW_COPY_AND_ASSIGN(Texture);
void loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type,
GLint unpackAlignment, const void *input, std::size_t outputPitch, void *output, D3DFORMAT targetFormat) const;
void loadAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const;
void loadLuminanceFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceAlphaImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) const;
void loadLuminanceAlphaFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadLuminanceAlphaHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBUByteImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGB565ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAUByteImageDataSSE2(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAUByteImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBA4444ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBA5551ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadRGBAHalfFloatImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadBGRAImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT1ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT3ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadDXT5ImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
static unsigned int issueSerial(); static unsigned int issueSerial();
const unsigned int mSerial; const unsigned int mSerial;
......
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