void NewTexture::Initialize()
{
- if( mNativeImage )
+ if( EventThreadServices::IsCoreRunning() )
{
- mRenderObject = new Render::NewTexture( mNativeImage );
- }
- else
- {
- mRenderObject = new Render::NewTexture( mType, mFormat, mWidth, mHeight );
- }
+ if( mNativeImage )
+ {
+ mRenderObject = new Render::NewTexture( mNativeImage );
+ }
+ else
+ {
+ mRenderObject = new Render::NewTexture( mType, mFormat, mWidth, mHeight );
+ }
- AddTexture( mEventThreadServices.GetUpdateManager(), *mRenderObject );
+ AddTexture( mEventThreadServices.GetUpdateManager(), *mRenderObject );
+ }
}
NewTexture::~NewTexture()
}
}
-void NewTexture::Upload( PixelDataPtr pixelData )
+bool NewTexture::Upload( PixelDataPtr pixelData )
{
- Upload( pixelData, 0u, 0u, 0u, 0u, mWidth, mHeight );
+ return Upload( pixelData, 0u, 0u, 0u, 0u, mWidth, mHeight );
}
-void NewTexture::Upload( PixelDataPtr pixelData,
+bool NewTexture::Upload( PixelDataPtr pixelData,
unsigned int layer, unsigned int mipmap,
unsigned int xOffset, unsigned int yOffset,
unsigned int width, unsigned int height )
{
- if( mNativeImage )
- {
- DALI_LOG_ERROR( "OpenGLES does not support uploading data to native texture");
- }
- else
+ bool result(false);
+ if( EventThreadServices::IsCoreRunning() && mRenderObject )
{
- unsigned int pixelDataSize = pixelData->GetWidth()*pixelData->GetHeight();
- if( pixelData->GetBuffer() == NULL || pixelDataSize == 0 )
+ if( mNativeImage )
{
- DALI_LOG_ERROR( "PixelData is empty");
+ DALI_LOG_ERROR( "OpenGL ES does not support uploading data to native texture");
}
else
{
- Pixel::Format pixelDataFormat = pixelData->GetPixelFormat();
- if( ( pixelDataFormat == mFormat ) || ( (pixelDataFormat == Pixel::RGB888 ) && ( mFormat == Pixel::RGBA8888 ) ) )
+ unsigned int pixelDataSize = pixelData->GetWidth()*pixelData->GetHeight();
+ if( pixelData->GetBuffer() == NULL || pixelDataSize == 0 )
{
- if( pixelDataSize < width * height )
- {
- DALI_LOG_ERROR( "Pixel data of an incorrect size when trying to update texture");
- }
- else if( ( xOffset + width > ( mWidth / (1<<mipmap) ) ) ||
- ( yOffset + height > ( mHeight / (1<<mipmap) ) ) )
+ DALI_LOG_ERROR( "PixelData is empty");
+ }
+ else
+ {
+ Pixel::Format pixelDataFormat = pixelData->GetPixelFormat();
+ if( ( pixelDataFormat == mFormat ) || ( (pixelDataFormat == Pixel::RGB888 ) && ( mFormat == Pixel::RGBA8888 ) ) )
{
- DALI_LOG_ERROR( "Texture update area out of bounds");
+ if( pixelDataSize < width * height )
+ {
+ DALI_LOG_ERROR( "PixelData of an incorrect size when trying to update texture");
+ }
+ else if( ( xOffset + width > ( mWidth / (1<<mipmap) ) ) ||
+ ( yOffset + height > ( mHeight / (1<<mipmap) ) ) )
+ {
+ DALI_LOG_ERROR( "Texture update area out of bounds");
+ }
+ else
+ {
+ //Parameters are correct. Send message to upload data to the texture
+ UploadParams params = { layer, mipmap, xOffset, yOffset, width, height };
+ UploadTextureMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, pixelData, params );
+ result = true;
+ }
}
else
{
- //Parameters are correct. Send message to upload data to the texture
- UploadParams params = { layer, mipmap, xOffset, yOffset, width, height };
- UploadTextureMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, pixelData, params );
+ DALI_LOG_ERROR( "Bad format");
}
}
- else
- {
- DALI_LOG_ERROR( "Bad format");
- }
}
}
+
+ return result;
}
void NewTexture::GenerateMipmaps()
{
- GenerateMipmapsMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject );
+ if( EventThreadServices::IsCoreRunning() && mRenderObject )
+ {
+ GenerateMipmapsMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject );
+ }
}
unsigned int NewTexture::GetWidth() const