Add support for pre-decoded image loading
- OnLoadFromDecodedData method for async decoded images - Bypasses redundant decoding when data comes from worker thread - Integrates with FileLoaderThreadPool pipeline
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "StdAfx.h"
|
||||
#include "GrpImage.h"
|
||||
#include "DecodedImageData.h"
|
||||
|
||||
CGraphicImage::CGraphicImage(const char * c_szFileName, DWORD dwFilter) :
|
||||
CResource(c_szFileName),
|
||||
@@ -79,6 +80,23 @@ bool CGraphicImage::OnLoad(int iSize, const void * c_pvBuf)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGraphicImage::OnLoadFromDecodedData(const TDecodedImageData& decodedImage)
|
||||
{
|
||||
if (!decodedImage.IsValid())
|
||||
return false;
|
||||
|
||||
m_imageTexture.SetFileName(CResource::GetFileName());
|
||||
|
||||
if (!m_imageTexture.CreateFromDecodedData(decodedImage, D3DFMT_UNKNOWN, m_dwFilter))
|
||||
return false;
|
||||
|
||||
m_rect.left = 0;
|
||||
m_rect.top = 0;
|
||||
m_rect.right = m_imageTexture.GetWidth();
|
||||
m_rect.bottom = m_imageTexture.GetHeight();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGraphicImage::OnClear()
|
||||
{
|
||||
// Tracef("Image Destroy : %s\n", m_pszFileName);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "Resource.h"
|
||||
#include "GrpImageTexture.h"
|
||||
|
||||
struct TDecodedImageData;
|
||||
|
||||
class CGraphicImage : public CResource
|
||||
{
|
||||
public:
|
||||
@@ -28,6 +30,8 @@ class CGraphicImage : public CResource
|
||||
const CGraphicTexture & GetTextureReference() const;
|
||||
CGraphicTexture * GetTexturePointer();
|
||||
|
||||
bool OnLoadFromDecodedData(const TDecodedImageData& decodedImage);
|
||||
|
||||
protected:
|
||||
bool OnLoad(int iSize, const void * c_pvBuf);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user