Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

changed: avoid a memcpy per texture where possible

We still copy if the image is too big for the texture or if POT textures
are required
  • Loading branch information...
commit 865f231861ae075cb6d8847fa1a46fcb372d9c0a 1 parent f61b591
theuni authored
Showing with 15 additions and 4 deletions.
  1. +15 −2 xbmc/guilib/Texture.cpp
  2. +0 −2  xbmc/guilib/TextureBundleXBT.cpp
View
17 xbmc/guilib/Texture.cpp
@@ -96,8 +96,12 @@ void CBaseTexture::Update(unsigned int width, unsigned int height, unsigned int
{ // compressed format that we don't support
Allocate(width, height, XB_FMT_A8R8G8B8);
CDDSImage::Decompress(m_pixels, std::min(width, m_textureWidth), std::min(height, m_textureHeight), GetPitch(m_textureWidth), pixels, format);
+ ClampToEdge();
+ delete[] pixels;
}
- else
+ else if (!g_Windowing.SupportsNPOT((m_format & XB_FMT_DXT_MASK) != 0) ||
+ width > g_Windowing.GetMaxTextureSize() ||
+ height > g_Windowing.GetMaxTextureSize() )
{
Allocate(width, height, format);
@@ -119,8 +123,17 @@ void CBaseTexture::Update(unsigned int width, unsigned int height, unsigned int
dst += dstPitch;
}
}
+ ClampToEdge();
+ delete[] pixels;
+ }
+ else
+ {
+ // We already have a suitable image that does not need to be modified
+ // Don't delete, the dtor handles it.
+ m_textureWidth = width;
+ m_textureHeight = height;
+ m_pixels=(unsigned char *) pixels;
}
- ClampToEdge();
if (loadToGPU)
LoadToGPU();
View
2  xbmc/guilib/TextureBundleXBT.cpp
@@ -236,8 +236,6 @@ bool CTextureBundleXBT::ConvertFrameToTexture(const CStdString& name, CXBTFFrame
*ppTexture = new CTexture();
(*ppTexture)->LoadFromMemory(frame.GetWidth(), frame.GetHeight(), 0, frame.GetFormat(), buffer);
- delete[] buffer;
-
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.