Cache the computation of getD3DFormat

Trac #19259 Issue=268 Instead of looking this up every time, we'll just compute it when the type/format changes. Signed-off-by: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@918 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 1dda3b18
......@@ -85,6 +85,7 @@ Image::Image()
mDirty = false;
mD3DPool = D3DPOOL_SYSTEMMEM;
mD3DFormat = D3DFMT_UNKNOWN;
}
Image::~Image()
......@@ -107,6 +108,8 @@ bool Image::redefine(GLenum format, GLsizei width, GLsizei height, GLenum type,
mHeight = height;
mFormat = format;
mType = type;
// compute the d3d format that will be used
mD3DFormat = ConvertTextureFormatType(mFormat, mType);
if (mSurface)
{
......@@ -222,7 +225,11 @@ bool Image::isRenderable() const
D3DFORMAT Image::getD3DFormat() const
{
return ConvertTextureFormatType(mFormat, mType);
// this should only happen if the image hasn't been redefined first
// which would be a bug by the caller
ASSERT(mD3DFormat != D3DFMT_UNKNOWN);
return mD3DFormat;
}
IDirect3DSurface9 *Image::getSurface()
......
......@@ -136,6 +136,7 @@ class Image
bool mDirty;
D3DPOOL mD3DPool; // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable.
D3DFORMAT mD3DFormat;
IDirect3DSurface9 *mSurface;
};
......
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